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 <array>
15 #include <cassert>
16 
17 // user include files
28 
32 
33 using namespace edm::stream;
34 //
35 // constants, enums and typedefs
36 //
37 
38 //
39 // static data member definitions
40 //
41 
42 //
43 // constructors and destructor
44 //
46 
47 // EDAnalyzerAdaptorBase::EDAnalyzerAdaptorBase(const EDAnalyzerAdaptorBase& rhs)
48 // {
49 // // do actual copying here;
50 // }
51 
53  for (auto m : m_streamModules) {
54  delete m;
55  }
56 }
57 
59  for (auto m : m_streamModules) {
60  delete m;
61  }
62  m_streamModules.clear();
63 }
64 
65 //
66 // assignment operators
67 //
68 // const EDAnalyzerAdaptorBase& EDAnalyzerAdaptorBase::operator=(const EDAnalyzerAdaptorBase& rhs)
69 // {
70 // //An exception safe implementation is
71 // EDAnalyzerAdaptorBase temp(rhs);
72 // swap(rhs);
73 //
74 // return *this;
75 // }
76 
77 //
78 // member functions
79 //
81  m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<stream::EDAnalyzerBase*>(nullptr));
83  preallocRuns(iPrealloc.numberOfRuns());
85 }
86 
88  for (auto mod : m_streamModules) {
89  mod->registerProductsAndCallbacks(mod, reg);
90  }
91 }
92 
93 void EDAnalyzerAdaptorBase::itemsToGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
94  assert(not m_streamModules.empty());
95  m_streamModules[0]->itemsToGet(iType, iIndices);
96 }
97 void EDAnalyzerAdaptorBase::itemsMayGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
98  assert(not m_streamModules.empty());
99  m_streamModules[0]->itemsMayGet(iType, iIndices);
100 }
101 
102 std::vector<edm::ProductResolverIndexAndSkipBit> const& EDAnalyzerAdaptorBase::itemsToGetFrom(BranchType iType) const {
103  assert(not m_streamModules.empty());
104  return m_streamModules[0]->itemsToGetFrom(iType);
105 }
106 
107 std::vector<edm::ESResolverIndex> const& EDAnalyzerAdaptorBase::esGetTokenIndicesVector(edm::Transition iTrans) const {
108  assert(not m_streamModules.empty());
109  return m_streamModules[0]->esGetTokenIndicesVector(iTrans);
110 }
111 
112 std::vector<edm::ESRecordIndex> const& EDAnalyzerAdaptorBase::esGetTokenRecordIndicesVector(
113  edm::Transition iTrans) const {
114  assert(not m_streamModules.empty());
115  return m_streamModules[0]->esGetTokenRecordIndicesVector(iTrans);
116 }
117 
119  ProductResolverIndexHelper const& iHelper,
120  bool iPrefetchMayGet) {
121  for (auto mod : m_streamModules) {
122  mod->updateLookup(iType, iHelper, iPrefetchMayGet);
123  }
124 }
125 
127  for (auto mod : m_streamModules) {
128  mod->updateLookup(iPI);
129  }
130 }
131 
133 
135  std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
136  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
137  ProductRegistry const& preg,
138  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
139  std::string const& processName) const {
140  assert(not m_streamModules.empty());
141  return m_streamModules[0]->modulesWhoseProductsAreConsumed(
142  modules, modulesInPreviousProcesses, preg, labelsToDesc, processName);
143 }
144 
146  for (auto mod : m_streamModules) {
147  mod->convertCurrentProcessAlias(processName);
148  }
149 }
150 
151 std::vector<edm::ConsumesInfo> EDAnalyzerAdaptorBase::consumesInfo() const {
152  assert(not m_streamModules.empty());
153  return m_streamModules[0]->consumesInfo();
154 }
155 
157  ActivityRegistry* act,
158  ModuleCallingContext const* mcc) {
159  EventPrincipal const& ep = info.principal();
160  assert(ep.streamID() < m_streamModules.size());
161  auto mod = m_streamModules[ep.streamID()];
162  Event e(ep, moduleDescription_, mcc);
163  e.setConsumer(mod);
164  ESParentContext parentC(mcc);
165  const EventSetup c{
166  info, static_cast<unsigned int>(Transition::Event), mod->esGetTokenIndices(Transition::Event), parentC};
167  EventSignalsSentry sentry(act, mcc);
168  mod->analyze(e, c);
169  return true;
170 }
171 
174 
176  RunTransitionInfo const& info,
177  ModuleCallingContext const* mcc) {
178  RunPrincipal const& rp = info.principal();
179  auto mod = m_streamModules[id];
180  setupRun(mod, rp.index());
181 
182  Run r(rp, moduleDescription_, mcc, false);
183  ESParentContext parentC(mcc);
184  const EventSetup c{
185  info, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun), parentC};
186  r.setConsumer(mod);
187  mod->beginRun(r, c);
188 }
189 
191  RunTransitionInfo const& info,
192  ModuleCallingContext const* mcc) {
193  auto mod = m_streamModules[id];
194  Run r(info, moduleDescription_, mcc, true);
195  r.setConsumer(mod);
196  ESParentContext parentC(mcc);
197  const EventSetup c{
198  info, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun), parentC};
199  mod->endRun(r, c);
201 }
202 
204  LumiTransitionInfo const& info,
205  ModuleCallingContext const* mcc) {
206  LuminosityBlockPrincipal const& lbp = info.principal();
207  auto mod = m_streamModules[id];
209 
210  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
211  lb.setConsumer(mod);
212  ESParentContext parentC(mcc);
213  const EventSetup c{info,
214  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
215  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
216  parentC};
217  mod->beginLuminosityBlock(lb, c);
218 }
220  LumiTransitionInfo const& info,
221  ModuleCallingContext const* mcc) {
222  auto mod = m_streamModules[id];
223  LuminosityBlock lb(info, moduleDescription_, mcc, true);
224  lb.setConsumer(mod);
225  ESParentContext parentC(mcc);
226  const EventSetup c{info,
227  static_cast<unsigned int>(Transition::EndLuminosityBlock),
228  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
229  parentC};
230  mod->endLuminosityBlock(lb, c);
232 }
233 
235  m->setModuleDescriptionPtr(&moduleDescription_);
236 }
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
void registerProductsAndCallbacks(EDAnalyzerAdaptorBase const *, ProductRegistry *reg)
static const TGPicture * info(bool iBackgroundIsBlack)
void setConsumer(EDConsumerBase const *iConsumer)
std::vector< ConsumesInfo > consumesInfo() const
virtual void preallocRuns(unsigned int)
std::vector< EDAnalyzerBase * > m_streamModules
void doPreallocate(PreallocationConfiguration const &)
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
void doStreamEndLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
assert(be >=bs)
virtual void setupLuminosityBlock(EDAnalyzerBase *, LuminosityBlockIndex)=0
BranchType
Definition: BranchType.h:11
void doStreamBeginLuminosityBlock(StreamID, LumiTransitionInfo const &, ModuleCallingContext const *)
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
void convertCurrentProcessAlias(std::string const &processName)
const EDConsumerBase * consumer() const
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
Transition
Definition: Transition.h:12
RunIndex index() const
Definition: RunPrincipal.h:56
virtual void streamEndLuminosityBlockSummary(EDAnalyzerBase *, edm::LuminosityBlock const &, edm::EventSetup const &)=0
virtual void setupRun(EDAnalyzerBase *, RunIndex)=0
void doStreamBeginRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
virtual void preallocLumis(unsigned int)
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector(edm::Transition iTrans) const
LuminosityBlockIndex index() const
void modulesWhoseProductsAreConsumed(std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modules, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
bool doEvent(EventTransitionInfo const &, ActivityRegistry *, ModuleCallingContext const *)
std::vector< ESResolverIndex > const & esGetTokenIndicesVector(edm::Transition iTrans) const
virtual void streamEndRunSummary(EDAnalyzerBase *, edm::Run const &, edm::EventSetup const &)=0
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
void doStreamEndRun(StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: Run.h:45
void setModuleDescriptionPtr(EDAnalyzerBase *m)