CMS 3D CMS Logo

EDAnalyzerAdaptorBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/Framework
4 // Class : edm::stream::EDAnalyzerAdaptorBase
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: Fri, 02 Aug 2013 21:43:44 GMT
11 //
12 
13 // system include files
14 #include <cassert>
15 
16 // user include files
26 
29 
30 using namespace edm::stream;
31 //
32 // constants, enums and typedefs
33 //
34 
35 //
36 // static data member definitions
37 //
38 
39 //
40 // constructors and destructor
41 //
43 
44 // EDAnalyzerAdaptorBase::EDAnalyzerAdaptorBase(const EDAnalyzerAdaptorBase& rhs)
45 // {
46 // // do actual copying here;
47 // }
48 
50  for (auto m : m_streamModules) {
51  delete m;
52  }
53 }
54 
55 //
56 // assignment operators
57 //
58 // const EDAnalyzerAdaptorBase& EDAnalyzerAdaptorBase::operator=(const EDAnalyzerAdaptorBase& rhs)
59 // {
60 // //An exception safe implementation is
61 // EDAnalyzerAdaptorBase temp(rhs);
62 // swap(rhs);
63 //
64 // return *this;
65 // }
66 
67 //
68 // member functions
69 //
71  m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<stream::EDAnalyzerBase*>(nullptr));
74 }
75 
77  for (auto mod : m_streamModules) {
78  mod->registerProductsAndCallbacks(mod, reg);
79  }
80 }
81 
82 void EDAnalyzerAdaptorBase::itemsToGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
83  assert(not m_streamModules.empty());
84  m_streamModules[0]->itemsToGet(iType, iIndices);
85 }
86 void EDAnalyzerAdaptorBase::itemsMayGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
87  assert(not m_streamModules.empty());
88  m_streamModules[0]->itemsMayGet(iType, iIndices);
89 }
90 
91 std::vector<edm::ProductResolverIndexAndSkipBit> const& EDAnalyzerAdaptorBase::itemsToGetFrom(BranchType iType) const {
92  assert(not m_streamModules.empty());
93  return m_streamModules[0]->itemsToGetFrom(iType);
94 }
95 
97  ProductResolverIndexHelper const& iHelper,
98  bool iPrefetchMayGet) {
99  for (auto mod : m_streamModules) {
100  mod->updateLookup(iType, iHelper, iPrefetchMayGet);
101  }
102 }
103 
105  for (auto mod : m_streamModules) {
106  mod->updateLookup(iPI);
107  }
108 }
109 
111 
113  std::vector<ModuleDescription const*>& modules,
114  ProductRegistry const& preg,
115  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
116  std::string const& processName) const {
117  assert(not m_streamModules.empty());
118  return m_streamModules[0]->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, processName);
119 }
120 
122  for (auto mod : m_streamModules) {
123  mod->convertCurrentProcessAlias(processName);
124  }
125 }
126 
127 std::vector<edm::ConsumesInfo> EDAnalyzerAdaptorBase::consumesInfo() const {
128  assert(not m_streamModules.empty());
129  return m_streamModules[0]->consumesInfo();
130 }
131 
133  EventSetupImpl const& ci,
134  ActivityRegistry* act,
135  ModuleCallingContext const* mcc) {
136  assert(ep.streamID() < m_streamModules.size());
137  auto mod = m_streamModules[ep.streamID()];
138  Event e(ep, moduleDescription_, mcc);
139  e.setConsumer(mod);
140  const EventSetup c{ci, static_cast<unsigned int>(Transition::Event), mod->esGetTokenIndices(Transition::Event)};
141  EventSignalsSentry sentry(act, mcc);
142  mod->analyze(e, c);
143  return true;
144 }
146 
149 
151  RunPrincipal const& rp,
152  EventSetupImpl const& ci,
153  ModuleCallingContext const* mcc) {
154  auto mod = m_streamModules[id];
155  setupRun(mod, rp.index());
156 
157  Run r(rp, moduleDescription_, mcc, false);
158  const EventSetup c{ci, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun)};
159  r.setConsumer(mod);
160  mod->beginRun(r, c);
161 }
162 
164  RunPrincipal const& rp,
165  EventSetupImpl const& ci,
166  ModuleCallingContext const* mcc) {
167  auto mod = m_streamModules[id];
168  Run r(rp, moduleDescription_, mcc, true);
169  r.setConsumer(mod);
170  const EventSetup c{ci, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun)};
171  mod->endRun(r, c);
173 }
174 
176  LuminosityBlockPrincipal const& lbp,
177  EventSetupImpl const& ci,
178  ModuleCallingContext const* mcc) {
179  auto mod = m_streamModules[id];
181 
182  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
183  lb.setConsumer(mod);
184  const EventSetup c{ci,
185  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
186  mod->esGetTokenIndices(Transition::BeginLuminosityBlock)};
187  mod->beginLuminosityBlock(lb, c);
188 }
190  LuminosityBlockPrincipal const& lbp,
191  EventSetupImpl const& ci,
192  ModuleCallingContext const* mcc) {
193  auto mod = m_streamModules[id];
194  LuminosityBlock lb(lbp, moduleDescription_, mcc, true);
195  lb.setConsumer(mod);
196  const EventSetup c{ci,
197  static_cast<unsigned int>(Transition::EndLuminosityBlock),
198  mod->esGetTokenIndices(Transition::EndLuminosityBlock)};
199  mod->endLuminosityBlock(lb, c);
201 }
202 
205 
208 }
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
void registerProductsAndCallbacks(EDAnalyzerAdaptorBase const *, ProductRegistry *reg)
void setConsumer(EDConsumerBase const *iConsumer)
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
void doStreamBeginRun(StreamID id, RunPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
void doRespondToCloseInputFile(FileBlock const &fb)
std::vector< EDAnalyzerBase * > m_streamModules
const EDConsumerBase * consumer() const
void doPreallocate(PreallocationConfiguration const &)
void doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
LuminosityBlockIndex index() const
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Event.cc:37
std::vector< ConsumesInfo > consumesInfo() const
virtual void setupLuminosityBlock(EDAnalyzerBase *, LuminosityBlockIndex)=0
BranchType
Definition: BranchType.h:11
void convertCurrentProcessAlias(std::string const &processName)
StreamID streamID() const
virtual void streamEndLuminosityBlockSummary(EDAnalyzerBase *, edm::LuminosityBlock const &, edm::EventSetup const &)=0
virtual void setupRun(EDAnalyzerBase *, RunIndex)=0
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
void doStreamEndRun(StreamID id, RunPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *)
bool doEvent(EventPrincipal const &ep, EventSetupImpl const &c, ActivityRegistry *, ModuleCallingContext const *)
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
void setModuleDescriptionPtr(ModuleDescription const *iDesc)
RunIndex index() const
Definition: RunPrincipal.h:56
virtual void preallocLumis(unsigned int)
virtual void streamEndRunSummary(EDAnalyzerBase *, edm::Run const &, edm::EventSetup const &)=0
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Run.h:51
void doRespondToOpenInputFile(FileBlock const &fb)
Definition: Run.h:45
void setModuleDescriptionPtr(EDAnalyzerBase *m)
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const