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 
30 
31 namespace edm {
32 
34  : iCounter_(0),
35  act_table_(nullptr),
36  moduleChanger_(nullptr),
37  moduleDescription_("Looper", "looper"),
38  moduleCallingContext_(&moduleDescription_) {}
40 
42 
44  const edm::EventSetupImpl& esi,
45  edm::ProcessingController& ioController,
46  StreamContext* streamContext) {
48  streamContext->setEventID(eventPrincipal.id());
49  streamContext->setRunIndex(eventPrincipal.luminosityBlockPrincipal().runPrincipal().index());
50  streamContext->setLuminosityBlockIndex(eventPrincipal.luminosityBlockPrincipal().index());
51  streamContext->setTimestamp(eventPrincipal.time());
52  ParentContext parentContext(streamContext);
53  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
55  event.setConsumer(this);
56 
58  try {
60  const EventSetup es{
61  esi, static_cast<unsigned int>(Transition::Event), esGetTokenIndices(Transition::Event), parentC, false};
62  status = duringLoop(event, es, ioController);
63  } catch (cms::Exception& e) {
64  e.addContext("Calling the 'duringLoop' method of a looper");
67  edm::printCmsExceptionWarning("SkipEvent", e);
68  } else {
69  throw;
70  }
71  }
72  return status;
73  }
74 
77  const EventSetup es{
78  esi, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC, false};
79  return endOfLoop(es, iCounter_);
80  }
81 
83  ++iCounter_;
84 
85  std::set<edm::eventsetup::EventSetupRecordKey> const& keys = modifyingRecords();
86  for_all(keys,
87  std::bind(&eventsetup::EventSetupProvider::resetRecordPlusDependentRecords, esp, std::placeholders::_1));
88  }
89 
92  beginOfJob(EventSetup{iImpl,
93  static_cast<unsigned int>(Transition::BeginRun),
95  parentC,
96  false});
97  }
100 
102 
103  void EDLooperBase::doBeginRun(RunPrincipal& iRP, EventSetupImpl const& iES, ProcessContext* processContext) {
105  LuminosityBlockID(iRP.run(), 0),
106  iRP.index(),
108  iRP.beginTime(),
109  processContext);
110  ParentContext parentContext(&globalContext);
111  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
113  run.setConsumer(this);
115  const EventSetup es{
116  iES, static_cast<unsigned int>(Transition::BeginRun), esGetTokenIndices(Transition::BeginRun), parentC, false};
117  beginRun(run, es);
118  }
119 
120  void EDLooperBase::doEndRun(RunPrincipal& iRP, EventSetupImpl const& iES, ProcessContext* processContext) {
122  LuminosityBlockID(iRP.run(), 0),
123  iRP.index(),
125  iRP.endTime(),
126  processContext);
127  ParentContext parentContext(&globalContext);
128  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
130  run.setConsumer(this);
132  const EventSetup es{
133  iES, static_cast<unsigned int>(Transition::EndRun), esGetTokenIndices(Transition::EndRun), parentC, false};
134  endRun(run, es);
135  }
137  EventSetupImpl const& iES,
138  ProcessContext* processContext) {
140  iLB.id(),
141  iLB.runPrincipal().index(),
142  iLB.index(),
143  iLB.beginTime(),
144  processContext);
145  ParentContext parentContext(&globalContext);
146  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
147  LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_, false);
148  luminosityBlock.setConsumer(this);
150  const EventSetup es{iES,
151  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
153  parentC,
154  false};
155  beginLuminosityBlock(luminosityBlock, es);
156  }
158  EventSetupImpl const& iES,
159  ProcessContext* processContext) {
161  iLB.id(),
162  iLB.runPrincipal().index(),
163  iLB.index(),
164  iLB.beginTime(),
165  processContext);
166  ParentContext parentContext(&globalContext);
167  ModuleContextSentry moduleContextSentry(&moduleCallingContext_, parentContext);
168  LuminosityBlock luminosityBlock(iLB, moduleDescription_, &moduleCallingContext_, true);
169  luminosityBlock.setConsumer(this);
171  const EventSetup es{iES,
172  static_cast<unsigned int>(Transition::EndLuminosityBlock),
174  parentC,
175  false};
176  endLuminosityBlock(luminosityBlock, es);
177  }
178 
179  void EDLooperBase::beginRun(Run const&, EventSetup const&) {}
180  void EDLooperBase::endRun(Run const&, EventSetup const&) {}
183 
185 
186  std::set<eventsetup::EventSetupRecordKey> EDLooperBase::modifyingRecords() const {
187  return std::set<eventsetup::EventSetupRecordKey>();
188  }
189 
190  void EDLooperBase::copyInfo(const ScheduleInfo& iInfo) { scheduleInfo_ = std::make_unique<ScheduleInfo>(iInfo); }
192 
194  const ScheduleInfo* EDLooperBase::scheduleInfo() const { return scheduleInfo_.get(); }
195 
196 } // namespace edm
edm::EDLooperBase::Status
Status
Definition: EDLooperBase.h:80
edm::RunPrincipal::endTime
Timestamp const & endTime() const
Definition: RunPrincipal.h:69
edm::LuminosityBlockPrincipal::runPrincipal
RunPrincipal const & runPrincipal() const
Definition: LuminosityBlockPrincipal.h:45
ModuleCallingContext.h
edm::EventPrincipal::luminosityBlockPrincipal
LuminosityBlockPrincipal const & luminosityBlockPrincipal() const
Definition: EventPrincipal.h:81
funct::false
false
Definition: Factorize.h:29
edm::StreamContext::setTransition
void setTransition(Transition v)
Definition: StreamContext.h:65
EventSetupProvider.h
ScheduleInfo.h
edm::EDLooperBase::EDLooperBase
EDLooperBase()
Definition: EDLooperBase.cc:33
edm::exception_actions::Rethrow
Definition: ExceptionActions.h:11
edm::ModuleContextSentry
Definition: ModuleContextSentry.h:11
edm::EventSetupImpl
Definition: EventSetupImpl.h:49
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
mps_update.status
status
Definition: mps_update.py:69
edm::Run
Definition: Run.h:45
edm::EDLooperBase::copyInfo
void copyInfo(ScheduleInfo const &)
Definition: EDLooperBase.cc:190
LuminosityBlock.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::Transition::Event
edm::ProcessContext
Definition: ProcessContext.h:27
edm::printCmsExceptionWarning
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e)
Definition: ExceptionMessages.cc:25
edm::StreamContext::setTimestamp
void setTimestamp(Timestamp const &v)
Definition: StreamContext.h:69
edm::LuminosityBlockPrincipal
Definition: LuminosityBlockPrincipal.h:31
Algorithms.h
edm::StreamContext::setLuminosityBlockIndex
void setLuminosityBlockIndex(LuminosityBlockIndex const &v)
Definition: StreamContext.h:68
relativeConstraints.keys
keys
Definition: relativeConstraints.py:89
edm::EDLooperBase::doBeginRun
void doBeginRun(RunPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:103
edm::EDLooperBase::prepareForNextLoop
void prepareForNextLoop(eventsetup::EventSetupProvider *esp)
Definition: EDLooperBase.cc:82
edm::EDLooperBase::doStartingNewLoop
void doStartingNewLoop()
Definition: EDLooperBase.cc:41
edm::EDLooperBase::~EDLooperBase
~EDLooperBase() noexcept(false) override
Definition: EDLooperBase.cc:39
edm::EventPrincipal::id
EventID const & id() const
Definition: EventPrincipal.h:92
edm::GlobalContext::Transition::kEndRun
edm::EDLooperBase::setModuleChanger
void setModuleChanger(ModuleChanger *)
Definition: EDLooperBase.cc:191
edm::ProcessingController
Definition: ProcessingController.h:29
edm::eventsetup::EventSetupProvider::resetRecordPlusDependentRecords
void resetRecordPlusDependentRecords(EventSetupRecordKey const &)
Used when we need to force a Record to reset all its proxies.
Definition: EventSetupProvider.cc:369
edm::for_all
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
edm::EDLooperBase::act_table_
ExceptionToActionTable const * act_table_
Definition: EDLooperBase.h:150
ModuleDescription.h
edm::EDLooperBase::iCounter_
unsigned int iCounter_
Definition: EDLooperBase.h:149
edm::RunPrincipal::beginTime
Timestamp const & beginTime() const
Definition: RunPrincipal.h:67
edm::EventPrincipal::time
Timestamp const & time() const
Definition: EventPrincipal.h:94
edm::EventPrincipal
Definition: EventPrincipal.h:46
edm::StreamContext
Definition: StreamContext.h:31
edm::EDLooperBase::moduleChanger_
edm::propagate_const< ModuleChanger * > moduleChanger_
Definition: EDLooperBase.h:153
edm::eventsetup::EventSetupProvider
Definition: EventSetupProvider.h:50
EventPrincipal.h
edm::EDLooperBase::endRun
virtual void endRun(Run const &, EventSetup const &)
Called after all event modules have processed the end of a Run.
Definition: EDLooperBase.cc:180
edm::EDLooperBase::scheduleInfo
ScheduleInfo const * scheduleInfo() const
This returns a non-zero value after the constructor has been called.
Definition: EDLooperBase.cc:194
edm::ActivityRegistry
Definition: ActivityRegistry.h:134
edm::EDLooperBase::beginRun
virtual void beginRun(Run const &, EventSetup const &)
Called after all event modules have processed the begin of a Run.
Definition: EDLooperBase.cc:179
Run.h
edm::EDLooperBase::startingNewLoop
virtual void startingNewLoop(unsigned int)=0
edm::GlobalContext::Transition::kEndLuminosityBlock
edm::Transition::BeginLuminosityBlock
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
edm::ParentContext
Definition: ParentContext.h:27
edm::RunPrincipal::index
RunIndex index() const
Definition: RunPrincipal.h:57
edm::EDLooperBase::endLuminosityBlock
virtual void endLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Called after all event modules have processed the end of a LuminosityBlock.
Definition: EDLooperBase.cc:182
edm::GlobalContext
Definition: GlobalContext.h:29
edm::EDLooperBase::moduleDescription_
ModuleDescription moduleDescription_
Definition: EDLooperBase.h:155
GlobalContext.h
ESParentContext.h
Event.h
edm::LuminosityBlockIndex::invalidLuminosityBlockIndex
static LuminosityBlockIndex invalidLuminosityBlockIndex()
Definition: LuminosityBlockIndex.cc:9
edm::LuminosityBlock::setConsumer
void setConsumer(EDConsumerBase const *iConsumer)
Definition: LuminosityBlock.cc:34
edm::EDLooperBase::moduleChanger
ModuleChanger * moduleChanger()
This only returns a non-zero value during the call to endOfLoop.
Definition: EDLooperBase.cc:193
edm::EDLooperBase::doEndLuminosityBlock
void doEndLuminosityBlock(LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:157
EDLooperBase.h
edm::EDLooperBase::endOfLoop
virtual Status endOfLoop(EventSetup const &, unsigned int iCounter)=0
edm::EDLooperBase::moduleCallingContext_
ModuleCallingContext moduleCallingContext_
Definition: EDLooperBase.h:156
ExceptionMessages.h
RunPrincipal.h
edmPickEvents.event
event
Definition: edmPickEvents.py:273
edm::RunPrincipal::run
RunNumber_t run() const
Definition: RunPrincipal.h:61
edm::EDLooperBase::doDuringLoop
Status doDuringLoop(EventPrincipal &eventPrincipal, EventSetupImpl const &es, ProcessingController &, StreamContext *)
Definition: EDLooperBase.cc:43
edm::GlobalContext::Transition::kBeginLuminosityBlock
writedatasetfile.action
action
Definition: writedatasetfile.py:8
edm::StreamContext::setEventID
void setEventID(EventID const &v)
Definition: StreamContext.h:66
ExceptionActions.h
edm::StreamContext::Transition::kEvent
edm::EventSetup
Definition: EventSetup.h:58
edm::ESParentContext
Definition: ESParentContext.h:21
edm::EDLooperBase::kContinue
Definition: EDLooperBase.h:80
edm::ScheduleInfo
Definition: ScheduleInfo.h:32
edm::EDLooperBase::endOfJob
virtual void endOfJob()
Definition: EDLooperBase.cc:101
LuminosityBlockPrincipal.h
edm::EDLooperBase::doEndOfLoop
Status doEndOfLoop(EventSetupImpl const &es)
Definition: EDLooperBase.cc:75
ParentContext.h
edm::Transition::EndLuminosityBlock
edm::EDLooperBase::doEndRun
void doEndRun(RunPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:120
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::StreamContext::setRunIndex
void setRunIndex(RunIndex const &v)
Definition: StreamContext.h:67
edm::LuminosityBlockPrincipal::id
LuminosityBlockID id() const
Definition: LuminosityBlockPrincipal.h:53
edm::EDConsumerBase::esGetTokenIndices
ESProxyIndex const * esGetTokenIndices(edm::Transition iTrans) const
Definition: EDConsumerBase.h:120
edm::Transition::BeginRun
edm::EDLooperBase::duringLoop
virtual Status duringLoop(Event const &, EventSetup const &, ProcessingController &)=0
edm::EDLooperBase::attachTo
virtual void attachTo(ActivityRegistry &)
Override this method if you need to monitor the state of the processing.
Definition: EDLooperBase.cc:184
EventSetup.h
Exception.h
edm::ExceptionToActionTable::find
exception_actions::ActionCodes find(const std::string &category) const
Definition: ExceptionActions.cc:85
edm::EDLooperBase::modifyingRecords
virtual std::set< eventsetup::EventSetupRecordKey > modifyingRecords() const
Definition: EDLooperBase.cc:186
cms::Exception
Definition: Exception.h:70
edm::LuminosityBlockPrincipal::index
LuminosityBlockIndex index() const
Definition: LuminosityBlockPrincipal.h:51
edm::LuminosityBlockPrincipal::beginTime
Timestamp const & beginTime() const
Definition: LuminosityBlockPrincipal.h:55
StreamContext.h
edm::RunPrincipal
Definition: RunPrincipal.h:34
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::Transition::EndRun
edm::EDLooperBase::scheduleInfo_
edm::propagate_const< std::unique_ptr< ScheduleInfo > > scheduleInfo_
Definition: EDLooperBase.h:152
ModuleContextSentry.h
edm::GlobalContext::Transition::kBeginRun
edm::EDLooperBase::doBeginLuminosityBlock
void doBeginLuminosityBlock(LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:136
edm::ModuleChanger
Definition: ModuleChanger.h:36
edm::exception_actions::ActionCodes
ActionCodes
Definition: ExceptionActions.h:11
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::EDLooperBase::beginOfJob
virtual void beginOfJob()
Definition: EDLooperBase.cc:99
edm::EDLooperBase::beginLuminosityBlock
virtual void beginLuminosityBlock(LuminosityBlock const &, EventSetup const &)
Called after all event modules have processed the begin of a LuminosityBlock.
Definition: EDLooperBase.cc:181