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");
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
edm::EDLooperBase::Status
Status
Definition: EDLooperBase.h:79
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:32
edm::exception_actions::Rethrow
Definition: ExceptionActions.h:11
edm::ModuleContextSentry
Definition: ModuleContextSentry.h:11
edm::EventSetupImpl
Definition: EventSetupImpl.h:48
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:161
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:92
edm::EDLooperBase::prepareForNextLoop
void prepareForNextLoop(eventsetup::EventSetupProvider *esp)
Definition: EDLooperBase.cc:76
edm::EDLooperBase::doStartingNewLoop
void doStartingNewLoop()
Definition: EDLooperBase.cc:40
edm::EventPrincipal::id
EventID const & id() const
Definition: EventPrincipal.h:92
edm::GlobalContext::Transition::kEndRun
edm::EDLooperBase::setModuleChanger
void setModuleChanger(ModuleChanger *)
Definition: EDLooperBase.cc:162
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:367
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:149
ModuleDescription.h
edm::EDLooperBase::iCounter_
unsigned int iCounter_
Definition: EDLooperBase.h:148
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:152
edm::eventsetup::EventSetupProvider
Definition: EventSetupProvider.h:49
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:151
edm::EDLooperBase::scheduleInfo
ScheduleInfo const * scheduleInfo() const
This returns a non-zero value after the constructor has been called.
Definition: EDLooperBase.cc:165
edm::ActivityRegistry
Definition: ActivityRegistry.h:133
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:150
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:153
edm::GlobalContext
Definition: GlobalContext.h:29
edm::EDLooperBase::~EDLooperBase
virtual ~EDLooperBase() noexcept(false)
Definition: EDLooperBase.cc:38
edm::EDLooperBase::moduleDescription_
ModuleDescription moduleDescription_
Definition: EDLooperBase.h:154
GlobalContext.h
Event.h
edm::LuminosityBlockIndex::invalidLuminosityBlockIndex
static LuminosityBlockIndex invalidLuminosityBlockIndex()
Definition: LuminosityBlockIndex.cc:9
edm::EDLooperBase::moduleChanger
ModuleChanger * moduleChanger()
This only returns a non-zero value during the call to endOfLoop.
Definition: EDLooperBase.cc:164
edm::EDLooperBase::doEndLuminosityBlock
void doEndLuminosityBlock(LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:134
EDLooperBase.h
edm::EDLooperBase::endOfLoop
virtual Status endOfLoop(EventSetup const &, unsigned int iCounter)=0
edm::EDLooperBase::moduleCallingContext_
ModuleCallingContext moduleCallingContext_
Definition: EDLooperBase.h:155
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:42
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:57
edm::EDLooperBase::kContinue
Definition: EDLooperBase.h:79
edm::ScheduleInfo
Definition: ScheduleInfo.h:32
edm::EDLooperBase::endOfJob
virtual void endOfJob()
Definition: EDLooperBase.cc:90
LuminosityBlockPrincipal.h
edm::EDLooperBase::doEndOfLoop
Status doEndOfLoop(EventSetupImpl const &es)
Definition: EDLooperBase.cc:71
ParentContext.h
edm::Transition::EndLuminosityBlock
edm::EDLooperBase::doEndRun
void doEndRun(RunPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:106
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::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:155
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:157
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:151
ModuleContextSentry.h
edm::GlobalContext::Transition::kBeginRun
edm::EDLooperBase::doBeginLuminosityBlock
void doBeginLuminosityBlock(LuminosityBlockPrincipal &, EventSetupImpl const &, ProcessContext *)
Definition: EDLooperBase.cc:119
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:88
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:152