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{
141  ci, static_cast<unsigned int>(Transition::Event), mod->esGetTokenIndices(Transition::Event), false};
142  EventSignalsSentry sentry(act, mcc);
143  mod->analyze(e, c);
144  return true;
145 }
147 
150 
152  RunPrincipal const& rp,
153  EventSetupImpl const& ci,
154  ModuleCallingContext const* mcc) {
155  auto mod = m_streamModules[id];
156  setupRun(mod, rp.index());
157 
158  Run r(rp, moduleDescription_, mcc, false);
159  const EventSetup c{
160  ci, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun), false};
161  r.setConsumer(mod);
162  mod->beginRun(r, c);
163 }
164 
166  RunPrincipal const& rp,
167  EventSetupImpl const& ci,
168  ModuleCallingContext const* mcc) {
169  auto mod = m_streamModules[id];
170  Run r(rp, moduleDescription_, mcc, true);
171  r.setConsumer(mod);
172  const EventSetup c{
173  ci, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun), false};
174  mod->endRun(r, c);
176 }
177 
179  LuminosityBlockPrincipal const& lbp,
180  EventSetupImpl const& ci,
181  ModuleCallingContext const* mcc) {
182  auto mod = m_streamModules[id];
184 
185  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
186  lb.setConsumer(mod);
187  const EventSetup c{ci,
188  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
189  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
190  false};
191  mod->beginLuminosityBlock(lb, c);
192 }
194  LuminosityBlockPrincipal const& lbp,
195  EventSetupImpl const& ci,
196  ModuleCallingContext const* mcc) {
197  auto mod = m_streamModules[id];
198  LuminosityBlock lb(lbp, moduleDescription_, mcc, true);
199  lb.setConsumer(mod);
200  const EventSetup c{ci,
201  static_cast<unsigned int>(Transition::EndLuminosityBlock),
202  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
203  false};
204  mod->endLuminosityBlock(lb, c);
206 }
207 
210 
213 }
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:35
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