-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
3 changed files
with
99 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/vhbbHeppy74X: 2622d68bf0f0c58cacf0e195c4dc5005c04e459f | ||
refs/heads/vhbbHeppy74X: 93f895fddf946c4ee7aae23815a1b6b95f6a2099 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
trunk/FWCore/Framework/interface/UnscheduledCallProducer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |