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
25 
28 
29 using namespace edm::stream;
30 //
31 // constants, enums and typedefs
32 //
33 
34 //
35 // static data member definitions
36 //
37 
38 //
39 // constructors and destructor
40 //
42 {
43 }
44 
45 // EDAnalyzerAdaptorBase::EDAnalyzerAdaptorBase(const EDAnalyzerAdaptorBase& rhs)
46 // {
47 // // do actual copying here;
48 // }
49 
51 {
52  for(auto m: m_streamModules) {
53  delete m;
54  }
55 }
56 
57 //
58 // assignment operators
59 //
60 // const EDAnalyzerAdaptorBase& EDAnalyzerAdaptorBase::operator=(const EDAnalyzerAdaptorBase& rhs)
61 // {
62 // //An exception safe implementation is
63 // EDAnalyzerAdaptorBase temp(rhs);
64 // swap(rhs);
65 //
66 // return *this;
67 // }
68 
69 //
70 // member functions
71 //
72 void
74  m_streamModules.resize(iPrealloc.numberOfStreams(),
75  static_cast<stream::EDAnalyzerBase*>(nullptr));
77 }
78 
79 void
81  for(auto mod : m_streamModules) {
82  mod->registerProductsAndCallbacks(mod, reg);
83  }
84 }
85 
86 void
87 EDAnalyzerAdaptorBase::itemsToGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
88  assert(not m_streamModules.empty());
89  m_streamModules[0]->itemsToGet(iType,iIndices);
90 }
91 void
92 EDAnalyzerAdaptorBase::itemsMayGet(BranchType iType, std::vector<ProductResolverIndexAndSkipBit>& iIndices) const {
93  assert(not m_streamModules.empty());
94  m_streamModules[0]->itemsMayGet(iType,iIndices);
95 }
96 
97 std::vector<edm::ProductResolverIndexAndSkipBit> const&
99  assert(not m_streamModules.empty());
100  return m_streamModules[0]->itemsToGetFromEvent();
101 }
102 
103 void
105  ProductResolverIndexHelper const& iHelper,
106  bool iPrefetchMayGet) {
107  for(auto mod: m_streamModules) {
108  mod->updateLookup(iType,iHelper,iPrefetchMayGet);
109  }
110 }
111 
112 const edm::EDConsumerBase*
114  return m_streamModules[0];
115 }
116 
117 void
119  ProductRegistry const& preg,
120  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
121  std::string const& processName) const {
122  assert(not m_streamModules.empty());
123  return m_streamModules[0]->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, processName);
124 }
125 
126 std::vector<edm::ConsumesInfo>
128  assert(not m_streamModules.empty());
129  return m_streamModules[0]->consumesInfo();
130 }
131 
132 bool
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  EventSignalsSentry sentry(act,mcc);
141  mod->analyze(e, c);
142  return true;
143 }
144 void
146 
147 }
148 
149 void
151  m_streamModules[id]->beginStream(id);
152 }
153 void
155  m_streamModules[id]->endStream();
156 }
157 
158 void
160  RunPrincipal const& rp,
161  EventSetup const& c,
162  ModuleCallingContext const* mcc)
163 {
164  auto mod = m_streamModules[id];
165  setupRun(mod, rp.index());
166 
167  Run r(rp, moduleDescription_, mcc);
168  r.setConsumer(mod);
169  mod->beginRun(r, c);
170 
171 }
172 
173 void
175  RunPrincipal const& rp,
176  EventSetup const& c,
177  ModuleCallingContext const* mcc)
178 {
179  auto mod = m_streamModules[id];
180  Run r(rp, moduleDescription_, mcc);
181  r.setConsumer(mod);
182  mod->endRun(r, c);
184 }
185 
186 void
188  LuminosityBlockPrincipal const& lbp,
189  EventSetup const& c,
190  ModuleCallingContext const* mcc) {
191  auto mod = m_streamModules[id];
193 
194  LuminosityBlock lb(lbp, moduleDescription_, mcc);
195  lb.setConsumer(mod);
196  mod->beginLuminosityBlock(lb, c);
197 }
198 void
200  LuminosityBlockPrincipal const& lbp,
201  EventSetup const& c,
202  ModuleCallingContext const* mcc)
203 {
204  auto mod = m_streamModules[id];
205  LuminosityBlock lb(lbp, moduleDescription_, mcc);
206  lb.setConsumer(mod);
207  mod->endLuminosityBlock(lb, c);
209 
210 }
211 
212 void
214 void
216 void
218 {
219  for(auto mod: m_streamModules) {
220  mod->preForkReleaseResources();
221  }
222 }
223 void
224 EDAnalyzerAdaptorBase::doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
225 {
226  for(auto mod: m_streamModules) {
227  mod->postForkReacquireResources(iChildIndex,iNumberOfChildren);
228  }
229 }
230 
231 void
234 }
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
void registerProductsAndCallbacks(EDAnalyzerAdaptorBase const *, ProductRegistry *reg)
void setConsumer(EDConsumerBase const *iConsumer)
void doRespondToCloseInputFile(FileBlock const &fb)
bool doEvent(EventPrincipal const &ep, EventSetup const &c, ActivityRegistry *, ModuleCallingContext const *)
std::vector< EDAnalyzerBase * > m_streamModules
const EDConsumerBase * consumer() const
void doPreallocate(PreallocationConfiguration const &)
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
LuminosityBlockIndex index() const
void setConsumer(EDConsumerBase const *iConsumer)
Definition: Event.cc:38
std::vector< ConsumesInfo > consumesInfo() const
virtual void setupLuminosityBlock(EDAnalyzerBase *, LuminosityBlockIndex)=0
BranchType
Definition: BranchType.h:11
void doStreamBeginRun(StreamID id, RunPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
void doStreamEndLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
void doPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren)
StreamID streamID() const
void doStreamBeginLuminosityBlock(StreamID id, LuminosityBlockPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
void doStreamEndRun(StreamID id, RunPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *)
virtual void streamEndLuminosityBlockSummary(EDAnalyzerBase *, edm::LuminosityBlock const &, edm::EventSetup const &)=0
virtual void setupRun(EDAnalyzerBase *, RunIndex)=0
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent() 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:53
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:49
void doRespondToOpenInputFile(FileBlock const &fb)
Definition: Run.h:42
void setModuleDescriptionPtr(EDAnalyzerBase *m)
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const