Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 123245
b: refs/heads/vhbbHeppy74X
c: 93f895f
h: refs/heads/vhbbHeppy74X
i:
  123243: 1ca708e
  • Loading branch information
William Tanenbaum committed Apr 26, 2013
1 parent 8ef7b02 commit fe454af
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 81 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/vhbbHeppy74X: 2622d68bf0f0c58cacf0e195c4dc5005c04e459f
refs/heads/vhbbHeppy74X: 93f895fddf946c4ee7aae23815a1b6b95f6a2099
81 changes: 1 addition & 80 deletions trunk/FWCore/Framework/interface/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#include "FWCore/Framework/interface/ExceptionHelpers.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/OccurrenceTraits.h"
#include "FWCore/Framework/interface/UnscheduledHandler.h"
#include "FWCore/Framework/interface/UnscheduledCallProducer.h"
#include "FWCore/Framework/src/Path.h"
#include "FWCore/Framework/src/RunStopwatch.h"
#include "FWCore/Framework/src/Worker.h"
Expand Down Expand Up @@ -350,85 +350,6 @@ namespace edm {
EventSetup const& es;
};

class UnscheduledCallProducer : public UnscheduledHandler {
public:
UnscheduledCallProducer() : UnscheduledHandler(), labelToWorkers_() {}
void addWorker(Worker* aWorker) {
assert(0 != aWorker);
labelToWorkers_[aWorker->description().moduleLabel()] = aWorker;
}

template <typename T>
void runNow(typename T::MyPrincipal& p, EventSetup const& es) {
//do nothing for event since we will run when requested
if(!T::isEvent_) {
for(std::map<std::string, Worker*>::iterator it = labelToWorkers_.begin(), itEnd=labelToWorkers_.end();
it != itEnd;
++it) {
CPUTimer timer;
try {
it->second->doWork<T>(p, es, nullptr, &timer);
}
catch (cms::Exception & ex) {
std::ostringstream ost;
if (T::isEvent_) {
ost << "Calling event method";
}
else if (T::begin_ && T::branchType_ == InRun) {
ost << "Calling beginRun";
}
else if (T::begin_ && T::branchType_ == InLumi) {
ost << "Calling beginLuminosityBlock";
}
else if (!T::begin_ && T::branchType_ == InLumi) {
ost << "Calling endLuminosityBlock";
}
else if (!T::begin_ && T::branchType_ == InRun) {
ost << "Calling endRun";
}
else {
// It should be impossible to get here ...
ost << "Calling unknown function";
}
ost << " for unscheduled module " << it->second->description().moduleName()
<< "/'" << it->second->description().moduleLabel() << "'";
ex.addContext(ost.str());
ost.str("");
ost << "Processing " << p.id();
ex.addContext(ost.str());
throw;
}
}
}
}

private:
virtual bool tryToFillImpl(std::string const& moduleLabel,
EventPrincipal& event,
EventSetup const& eventSetup,
CurrentProcessingContext const* iContext) {
std::map<std::string, Worker*>::const_iterator itFound =
labelToWorkers_.find(moduleLabel);
if(itFound != labelToWorkers_.end()) {
CPUTimer timer;
try {
itFound->second->doWork<OccurrenceTraits<EventPrincipal, BranchActionBegin> >(event, eventSetup, iContext, &timer);
}
catch (cms::Exception & ex) {
std::ostringstream ost;
ost << "Calling produce method for unscheduled module "
<< itFound->second->description().moduleName() << "/'"
<< itFound->second->description().moduleLabel() << "'";
ex.addContext(ost.str());
throw;
}
return true;
}
return false;
}
std::map<std::string, Worker*> labelToWorkers_;
};

void
inline
Schedule::reportSkipped(EventPrincipal const& ep) const {
Expand Down
97 changes: 97 additions & 0 deletions trunk/FWCore/Framework/interface/UnscheduledCallProducer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#ifndef FWCore_Framework_UnscheduledCallProducer_h
#define FWCore_Framework_UnscheduledCallProducer_h

#include "FWCore/Framework/interface/UnscheduledHandler.h"

#include "FWCore/Framework/interface/BranchActionType.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/OccurrenceTraits.h"
#include "FWCore/Framework/src/Worker.h"

#include <map>
#include <string>
#include <sstream>

namespace edm {
class UnscheduledCallProducer : public UnscheduledHandler {
public:
UnscheduledCallProducer() : UnscheduledHandler(), labelToWorkers_() {}
void addWorker(Worker* aWorker) {
assert(0 != aWorker);
labelToWorkers_[aWorker->description().moduleLabel()] = aWorker;
}

template <typename T>
void runNow(typename T::MyPrincipal& p, EventSetup const& es) {
//do nothing for event since we will run when requested
if(!T::isEvent_) {
for(std::map<std::string, Worker*>::iterator it = labelToWorkers_.begin(), itEnd=labelToWorkers_.end();
it != itEnd;
++it) {
CPUTimer timer;
try {
it->second->doWork<T>(p, es, nullptr, &timer);
}
catch (cms::Exception & ex) {
std::ostringstream ost;
if (T::isEvent_) {
ost << "Calling event method";
}
else if (T::begin_ && T::branchType_ == InRun) {
ost << "Calling beginRun";
}
else if (T::begin_ && T::branchType_ == InLumi) {
ost << "Calling beginLuminosityBlock";
}
else if (!T::begin_ && T::branchType_ == InLumi) {
ost << "Calling endLuminosityBlock";
}
else if (!T::begin_ && T::branchType_ == InRun) {
ost << "Calling endRun";
}
else {
// It should be impossible to get here ...
ost << "Calling unknown function";
}
ost << " for unscheduled module " << it->second->description().moduleName()
<< "/'" << it->second->description().moduleLabel() << "'";
ex.addContext(ost.str());
ost.str("");
ost << "Processing " << p.id();
ex.addContext(ost.str());
throw;
}
}
}
}

private:
virtual bool tryToFillImpl(std::string const& moduleLabel,
EventPrincipal& event,
EventSetup const& eventSetup,
CurrentProcessingContext const* iContext) {
std::map<std::string, Worker*>::const_iterator itFound =
labelToWorkers_.find(moduleLabel);
if(itFound != labelToWorkers_.end()) {
CPUTimer timer;
try {
itFound->second->doWork<OccurrenceTraits<EventPrincipal, BranchActionBegin> >(event, eventSetup, iContext, &timer);
}
catch (cms::Exception & ex) {
std::ostringstream ost;
ost << "Calling produce method for unscheduled module "
<< itFound->second->description().moduleName() << "/'"
<< itFound->second->description().moduleLabel() << "'";
ex.addContext(ost.str());
throw;
}
return true;
}
return false;
}
std::map<std::string, Worker*> labelToWorkers_;
};

}

#endif

0 comments on commit fe454af

Please sign in to comment.