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
27 
31 
32 using namespace edm::stream;
33 //
34 // constants, enums and typedefs
35 //
36 
37 //
38 // static data member definitions
39 //
40 
41 //
42 // constructors and destructor
43 //
45 
46 // EDAnalyzerAdaptorBase::EDAnalyzerAdaptorBase(const EDAnalyzerAdaptorBase& rhs)
47 // {
48 // // do actual copying here;
49 // }
50 
52  for (auto m : m_streamModules) {
53  delete m;
54  }
55 }
56 
58  for (auto m : m_streamModules) {
59  delete m;
60  }
61  m_streamModules.clear();
62 }
63 
64 //
65 // assignment operators
66 //
67 // const EDAnalyzerAdaptorBase& EDAnalyzerAdaptorBase::operator=(const EDAnalyzerAdaptorBase& rhs)
68 // {
69 // //An exception safe implementation is
70 // EDAnalyzerAdaptorBase temp(rhs);
71 // swap(rhs);
72 //
73 // return *this;
74 // }
75 
76 //
77 // member functions
78 //
80  m_streamModules.resize(iPrealloc.numberOfStreams(), static_cast<stream::EDAnalyzerBase*>(nullptr));
83 }
84 
86  for (auto mod : m_streamModules) {
87  mod->registerProductsAndCallbacks(mod, reg);
88  }
89 }
90 
91 void EDAnalyzerAdaptorBase::itemsToGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
92  assert(not m_streamModules.empty());
93  m_streamModules[0]->itemsToGet(iType, iIndices);
94 }
95 void EDAnalyzerAdaptorBase::itemsMayGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
96  assert(not m_streamModules.empty());
97  m_streamModules[0]->itemsMayGet(iType, iIndices);
98 }
99 
100 std::vector<edm::ProductResolverIndexAndSkipBit> const& EDAnalyzerAdaptorBase::itemsToGetFrom(BranchType iType) const {
101  assert(not m_streamModules.empty());
102  return m_streamModules[0]->itemsToGetFrom(iType);
103 }
104 
105 std::vector<edm::ESProxyIndex> const& EDAnalyzerAdaptorBase::esGetTokenIndicesVector(edm::Transition iTrans) const {
106  assert(not m_streamModules.empty());
107  return m_streamModules[0]->esGetTokenIndicesVector(iTrans);
108 }
109 
110 std::vector<edm::ESRecordIndex> const& EDAnalyzerAdaptorBase::esGetTokenRecordIndicesVector(
111  edm::Transition iTrans) const {
112  assert(not m_streamModules.empty());
113  return m_streamModules[0]->esGetTokenRecordIndicesVector(iTrans);
114 }
115 
117  ProductResolverIndexHelper const& iHelper,
118  bool iPrefetchMayGet) {
119  for (auto mod : m_streamModules) {
120  mod->updateLookup(iType, iHelper, iPrefetchMayGet);
121  }
122 }
123 
125  for (auto mod : m_streamModules) {
126  mod->updateLookup(iPI);
127  }
128 }
129 
131 
133  std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modules,
134  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
135  ProductRegistry const& preg,
136  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
137  std::string const& processName) const {
138  assert(not m_streamModules.empty());
139  return m_streamModules[0]->modulesWhoseProductsAreConsumed(
140  modules, modulesInPreviousProcesses, preg, labelsToDesc, processName);
141 }
142 
144  for (auto mod : m_streamModules) {
145  mod->convertCurrentProcessAlias(processName);
146  }
147 }
148 
149 std::vector<edm::ConsumesInfo> EDAnalyzerAdaptorBase::consumesInfo() const {
150  assert(not m_streamModules.empty());
151  return m_streamModules[0]->consumesInfo();
152 }
153 
155  ActivityRegistry* act,
156  ModuleCallingContext const* mcc) {
157  EventPrincipal const& ep = info.principal();
158  assert(ep.streamID() < m_streamModules.size());
159  auto mod = m_streamModules[ep.streamID()];
160  Event e(ep, moduleDescription_, mcc);
161  e.setConsumer(mod);
162  ESParentContext parentC(mcc);
163  const EventSetup c{
164  info, static_cast<unsigned int>(Transition::Event), mod->esGetTokenIndices(Transition::Event), parentC};
165  EventSignalsSentry sentry(act, mcc);
166  mod->analyze(e, c);
167  return true;
168 }
169 
172 
174  RunTransitionInfo const& info,
175  ModuleCallingContext const* mcc) {
176  RunPrincipal const& rp = info.principal();
177  auto mod = m_streamModules[id];
178  setupRun(mod, rp.index());
179 
180  Run r(rp, moduleDescription_, mcc, false);
181  ESParentContext parentC(mcc);
182  const EventSetup c{
183  info, static_cast<unsigned int>(Transition::BeginRun), mod->esGetTokenIndices(Transition::BeginRun), parentC};
184  r.setConsumer(mod);
185  mod->beginRun(r, c);
186 }
187 
189  RunTransitionInfo const& info,
190  ModuleCallingContext const* mcc) {
191  auto mod = m_streamModules[id];
192  Run r(info, moduleDescription_, mcc, true);
193  r.setConsumer(mod);
194  ESParentContext parentC(mcc);
195  const EventSetup c{
196  info, static_cast<unsigned int>(Transition::EndRun), mod->esGetTokenIndices(Transition::EndRun), parentC};
197  mod->endRun(r, c);
199 }
200 
202  LumiTransitionInfo const& info,
203  ModuleCallingContext const* mcc) {
204  LuminosityBlockPrincipal const& lbp = info.principal();
205  auto mod = m_streamModules[id];
207 
208  LuminosityBlock lb(lbp, moduleDescription_, mcc, false);
209  lb.setConsumer(mod);
210  ESParentContext parentC(mcc);
211  const EventSetup c{info,
212  static_cast<unsigned int>(Transition::BeginLuminosityBlock),
213  mod->esGetTokenIndices(Transition::BeginLuminosityBlock),
214  parentC};
215  mod->beginLuminosityBlock(lb, c);
216 }
218  LumiTransitionInfo const& info,
219  ModuleCallingContext const* mcc) {
220  auto mod = m_streamModules[id];
221  LuminosityBlock lb(info, moduleDescription_, mcc, true);
222  lb.setConsumer(mod);
223  ESParentContext parentC(mcc);
224  const EventSetup c{info,
225  static_cast<unsigned int>(Transition::EndLuminosityBlock),
226  mod->esGetTokenIndices(Transition::EndLuminosityBlock),
227  parentC};
228  mod->endLuminosityBlock(lb, c);
230 }
231 
233  m->setModuleDescriptionPtr(&moduleDescription_);
234 }
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
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< ESProxyIndex > const & esGetTokenIndicesVector(edm::Transition iTrans) const
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType) const
Transition
Definition: Transition.h:12
RunIndex index() const
Definition: RunPrincipal.h:57
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 *)
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)