CMS 3D CMS Logo

EDLooperBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: <package>
4 // Module: EDLooperBase
5 //
6 // Author: Valentin Kuznetsov
7 // Created: Wed Jul 5 11:44:26 EDT 2006
8 
29 
30 namespace edm {
31 
33  : iCounter_(0),
34  act_table_(nullptr),
35  moduleChanger_(nullptr),
36  moduleDescription_("Looper", "looper"),
37  moduleCallingContext_(&moduleDescription_) {}
39 
41 
43  const edm::EventSetupImpl& esi,
44  edm::ProcessingController& ioController,
45  StreamContext* streamContext) {
47  streamContext->setEventID(eventPrincipal.id());
48  streamContext->setRunIndex(eventPrincipal.luminosityBlockPrincipal().runPrincipal().index());
49  streamContext->setLuminosityBlockIndex(eventPrincipal.luminosityBlockPrincipal().index());
50  streamContext->setTimestamp(eventPrincipal.time());
51  ParentContext parentContext(streamContext);
52  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
54 
56  try {
57  const EventSetup es{esi, static_cast<unsigned int>(Transition::Event), nullptr, false};
58  status = duringLoop(event, es, ioController);
59  } catch (cms::Exception& e) {
60  e.addContext("Calling the 'duringLoop' method of a looper");
62  if (action != exception_actions::Rethrow) {
63  edm::printCmsExceptionWarning("SkipEvent", e);
64  } else {
65  throw;
66  }
67  }
68  return status;
69  }
70 
72  const EventSetup es{esi, static_cast<unsigned int>(Transition::EndRun), nullptr, false};
73  return endOfLoop(es, iCounter_);
74  }
75 
77  ++iCounter_;
78 
79  std::set<edm::eventsetup::EventSetupRecordKey> const& keys = modifyingRecords();
80  for_all(keys,
81  std::bind(&eventsetup::EventSetupProvider::resetRecordPlusDependentRecords, esp, std::placeholders::_1));
82  }
83 
85  beginOfJob(EventSetup{iImpl, static_cast<unsigned int>(Transition::BeginRun), nullptr, false});
86  }
89 
91 
92  void EDLooperBase::doBeginRun(RunPrincipal& iRP, EventSetupImpl const& iES, ProcessContext* processContext) {
94  LuminosityBlockID(iRP.run(), 0),
95  iRP.index(),
97  iRP.beginTime(),
98  processContext);
99  ParentContext parentContext(&globalContext);
100  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
102  const EventSetup es{iES, static_cast<unsigned int>(Transition::BeginRun), nullptr, false};
103  beginRun(run, es);
104  }
105 
106  void EDLooperBase::doEndRun(RunPrincipal& iRP, EventSetupImpl const& iES, ProcessContext* processContext) {
108  LuminosityBlockID(iRP.run(), 0),
109  iRP.index(),
111  iRP.endTime(),
112  processContext);
113  ParentContext parentContext(&globalContext);
114  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
116  const EventSetup es{iES, static_cast<unsigned int>(Transition::EndRun), nullptr, false};
117  endRun(run, es);
118  }
120  EventSetupImpl const& iES,
121  ProcessContext* processContext) {
123  iLB.id(),
124  iLB.runPrincipal().index(),
125  iLB.index(),
126  iLB.beginTime(),
127  processContext);
128  ParentContext parentContext(&globalContext);
129  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
130  LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_, false);
131  const EventSetup es{iES, static_cast<unsigned int>(Transition::BeginLuminosityBlock), nullptr, false};
132  beginLuminosityBlock(luminosityBlock, es);
133  }
135  EventSetupImpl const& iES,
136  ProcessContext* processContext) {
138  iLB.id(),
139  iLB.runPrincipal().index(),
140  iLB.index(),
141  iLB.beginTime(),
142  processContext);
143  ParentContext parentContext(&globalContext);
144  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
145  LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_, true);
146  const EventSetup es{iES, static_cast<unsigned int>(Transition::EndLuminosityBlock), nullptr, false};
147  endLuminosityBlock(luminosityBlock, es);
148  }
149 
150  void EDLooperBase::beginRun(Run const&, EventSetup const&) {}
151  void EDLooperBase::endRun(Run const&, EventSetup const&) {}
154 
156 
157  std::set<eventsetup::EventSetupRecordKey> EDLooperBase::modifyingRecords() const {
158  return std::set<eventsetup::EventSetupRecordKey>();
159  }
160 
161  void EDLooperBase::copyInfo(const ScheduleInfo& iInfo) { scheduleInfo_ = std::make_unique<ScheduleInfo>(iInfo); }
163 
165  const ScheduleInfo* EDLooperBase::scheduleInfo() const { return scheduleInfo_.get(); }
166 
167 } // namespace edm
RunPrincipal const & runPrincipal() const
void setTimestamp(Timestamp const &v)
Definition: StreamContext.h:69
virtual Status endOfLoop(EventSetup const &, unsigned int iCounter)=0
void doEndLuminosityBlock(LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
ModuleCallingContext moduleCallingContext_
Definition: EDLooperBase.h:155
Timestamp const & beginTime() const
unsigned int iCounter_
Definition: EDLooperBase.h:148
#define nullptr
EventID const & id() const
virtual ~EDLooperBase() noexcept(false)
Definition: EDLooperBase.cc:38
Status doEndOfLoop(EventSetupImpl const &es)
Definition: EDLooperBase.cc:71
std::string const & category() const
Definition: Exception.cc:143
exception_actions::ActionCodes find(const std::string &category) const
LuminosityBlockIndex index() const
RunNumber_t run() const
Definition: RunPrincipal.h:60
virtual Status duringLoop(Event const &, EventSetup const &, ProcessingController &)=0
virtual std::set< eventsetup::EventSetupRecordKey > modifyingRecords() const
virtual void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Called after all event modules have processed the begin of a LuminosityBlock.
void setTransition(Transition v)
Definition: StreamContext.h:65
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
Timestamp const & time() const
ModuleDescription moduleDescription_
Definition: EDLooperBase.h:154
void setLuminosityBlockIndex(LuminosityBlockIndex const &v)
Definition: StreamContext.h:68
LuminosityBlockPrincipal const & luminosityBlockPrincipal() const
Timestamp const & beginTime() const
Definition: RunPrincipal.h:66
Status doDuringLoop(EventPrincipal &eventPrincipal, EventSetupImpl const &es, ProcessingController &, StreamContext *)
Definition: EDLooperBase.cc:42
Timestamp const & endTime() const
Definition: RunPrincipal.h:68
virtual void endOfJob()
Definition: EDLooperBase.cc:90
void doBeginRun(RunPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:92
void resetRecordPlusDependentRecords(EventSetupRecordKey const &)
Used when we need to force a Record to reset all its proxies.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
ScheduleInfo const * scheduleInfo() const
This returns a non-zero value after the constructor has been called.
static LuminosityBlockIndex invalidLuminosityBlockIndex()
void setModuleChanger(ModuleChanger *)
edm::propagate_const< std::unique_ptr< ScheduleInfo > > scheduleInfo_
Definition: EDLooperBase.h:151
ExceptionToActionTable const * act_table_
Definition: EDLooperBase.h:149
void copyInfo(ScheduleInfo const &)
void doBeginLuminosityBlock(LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
#define noexcept
virtual void beginOfJob()
Definition: EDLooperBase.cc:88
void addContext(std::string const &context)
Definition: Exception.cc:165
virtual void endRun(Run const &, EventSetup const &)
Called after all event modules have processed the end of a Run.
void prepareForNextLoop(eventsetup::EventSetupProvider *esp)
Definition: EDLooperBase.cc:76
virtual void beginRun(Run const &, EventSetup const &)
Called after all event modules have processed the begin of a Run.
RunIndex index() const
Definition: RunPrincipal.h:56
virtual void startingNewLoop(unsigned int)=0
void setEventID(EventID const &v)
Definition: StreamContext.h:66
HLT enums.
ModuleChanger * moduleChanger()
This only returns a non-zero value during the call to endOfLoop.
edm::propagate_const< ModuleChanger * > moduleChanger_
Definition: EDLooperBase.h:152
void doEndRun(RunPrincipal &, EventSetupImpl const &, ProcessContext *)
void setRunIndex(RunIndex const &v)
Definition: StreamContext.h:67
virtual void attachTo(ActivityRegistry &)
Override this method if you need to monitor the state of the processing.
void doStartingNewLoop()
Definition: EDLooperBase.cc:40
Definition: Run.h:45
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e)
virtual void endLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Called after all event modules have processed the end of a LuminosityBlock.