CMS 3D CMS Logo

OutputModuleCommunicatorT.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
3 
17 
19 
24 
25 namespace {
26  template <typename F>
27  void async( edm::OutputModule& iMod, F&& iFunc ) {
29  }
30 
31  template <typename F>
32  void async( edm::one::OutputModuleBase& iMod, F&& iFunc ) {
34  }
35 
36  template <typename F>
37  void async( edm::limited::OutputModuleBase& iMod, F&& iFunc ) {
38  iMod.queue().push(std::move(iFunc));
39  }
40 
41  template <typename F>
42  void async( edm::global::OutputModuleBase&, F iFunc ) {
43  auto t = edm::make_functor_task(tbb::task::allocate_root(), iFunc);
44  tbb::task::spawn(*t);
45  }
46 }
47 
48 namespace edm {
49 
50  template<typename T>
51  void
53  module().doCloseFile();
54  }
55 
56  template<typename T>
57  bool
59  return module().shouldWeCloseFile();
60  }
61 
62  template<typename T>
63  void
65  module().doOpenFile(fb);
66  }
67 
68  template<typename T>
69  void
71  edm::RunPrincipal const& rp,
72  ProcessContext const* processContext,
73  ActivityRegistry* activityRegistry) {
74  auto token = ServiceRegistry::instance().presentToken();
76  LuminosityBlockID(rp.run(), 0),
77  rp.index(),
79  rp.endTime(),
80  processContext);
81  auto t = [&mod = module(), &rp, globalContext, token, desc = &description(), activityRegistry, iTask]() mutable {
82  std::exception_ptr ex;
83  try {
84  ServiceRegistry::Operate op(token);
85  ParentContext parentContext(&globalContext);
86  ModuleCallingContext mcc(desc);
87  ModuleContextSentry moduleContextSentry(&mcc, parentContext);
88  activityRegistry->preModuleWriteRunSignal_(globalContext, mcc);
89  auto sentry( make_sentry(activityRegistry,
90  [&globalContext, &mcc](ActivityRegistry* activityRegistry) {
91  activityRegistry->postModuleWriteRunSignal_(globalContext, mcc);
92  }));
93  mod.doWriteRun(rp, &mcc);
94  } catch(...) {
95  ex = std::current_exception();
96  }
97  iTask.doneWaiting(ex);
98  };
99  async(module(), std::move(t));
100  }
101 
102  template<typename T>
103  void
106  ProcessContext const* processContext,
107  ActivityRegistry* activityRegistry) {
108  auto token = ServiceRegistry::instance().presentToken();
110  lbp.id(),
111  lbp.runPrincipal().index(),
112  lbp.index(),
113  lbp.beginTime(),
114  processContext);
115  auto t=[&mod = module(), &lbp, activityRegistry, token, globalContext,desc = &description(),iTask]() mutable {
116  std::exception_ptr ex;
117  try {
118  ServiceRegistry::Operate op(token);
119 
120  ParentContext parentContext(&globalContext);
121  ModuleCallingContext mcc(desc);
122  ModuleContextSentry moduleContextSentry(&mcc, parentContext);
123  activityRegistry->preModuleWriteLumiSignal_(globalContext, mcc);
124  auto sentry( make_sentry(activityRegistry,
125  [&globalContext, &mcc](ActivityRegistry* activityRegistry) {
126  activityRegistry->postModuleWriteLumiSignal_(globalContext, mcc);
127  }));
128  mod.doWriteLuminosityBlock(lbp, &mcc);
129  } catch(...) {
130  ex = std::current_exception();
131  }
132  iTask.doneWaiting(ex);
133  };
134  async(module(), std::move(t));
135  }
136 
137  template<typename T>
138  bool OutputModuleCommunicatorT<T>::wantAllEvents() const {return module().wantAllEvents();}
139 
140  template<typename T>
141  bool OutputModuleCommunicatorT<T>::limitReached() const {return module().limitReached();}
142 
143  template<typename T>
145 
146  template<typename T>
148  return module().keptProducts();
149  }
150 
151  template<typename T>
153  module().selectProducts(preg, helper);
154  }
155 
156  template<typename T>
157  void OutputModuleCommunicatorT<T>::setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
158  bool anyProductProduced) {
159  module().setEventSelectionInfo(outputModulePathPositions, anyProductProduced);
160  }
161 
162  template<typename T>
164  return module().description();
165  }
166 
167  namespace impl {
168  std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(void *) {
169  return std::unique_ptr<edm::OutputModuleCommunicator>{};
170  }
171  std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(::edm::OutputModule * iMod){
172  return std::make_unique<OutputModuleCommunicatorT<edm::OutputModule>>(iMod);
173  }
174  std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(::edm::global::OutputModuleBase * iMod){
175  return std::make_unique<OutputModuleCommunicatorT<edm::global::OutputModuleBase>>(iMod);
176  }
177  std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(::edm::one::OutputModuleBase * iMod){
178  return std::make_unique<OutputModuleCommunicatorT<edm::one::OutputModuleBase>>(iMod);
179  }
180  std::unique_ptr<edm::OutputModuleCommunicator> createCommunicatorIfNeeded(::edm::limited::OutputModuleBase * iMod){
181  return std::make_unique<OutputModuleCommunicatorT<edm::limited::OutputModuleBase>>(iMod);
182  }
183  }
184 }
185 
186 namespace edm {
191 }
RunPrincipal const & runPrincipal() const
void push(T &&iAction)
asynchronously pushes functor iAction into queue
SharedResourcesAcquirer & sharedResourcesAcquirer()
std::unique_ptr< T, F > make_sentry(T *iObject, F iFunc)
NOTE: if iObject is null, then iFunc will not be called.
Definition: make_sentry.h:29
Definition: helper.py:1
Timestamp const & beginTime() const
std::array< SelectedProducts, NumBranchTypes > SelectedProductsForBranchType
FunctorTask< F > * make_functor_task(ALLOC &&iAlloc, F f)
Definition: FunctorTask.h:47
void selectProducts(edm::ProductRegistry const &preg, ThinnedAssociationsHelper const &) override
SharedResourcesAcquirer & sharedResourcesAcquirer()
Definition: OutputModule.h:91
PostModuleWriteLumi postModuleWriteLumiSignal_
void configure(edm::OutputModuleDescription const &desc) override
LuminosityBlockIndex index() const
void push(T &&iAction)
asynchronously pushes functor iAction into queue
RunNumber_t run() const
Definition: RunPrincipal.h:61
ServiceToken presentToken() const
void writeRunAsync(WaitingTaskHolder iTask, edm::RunPrincipal const &rp, ProcessContext const *, ActivityRegistry *) override
ModuleDescription const & description() const override
edm::SelectedProductsForBranchType const & keptProducts() const override
void doneWaiting(std::exception_ptr iExcept)
static ServiceRegistry & instance()
Timestamp const & endTime() const
Definition: RunPrincipal.h:77
std::unique_ptr< edm::OutputModuleCommunicator > createCommunicatorIfNeeded(void *)
PostModuleWriteRun postModuleWriteRunSignal_
static LuminosityBlockIndex invalidLuminosityBlockIndex()
SerialTaskQueueChain & serialQueueChain() const
void writeLumiAsync(WaitingTaskHolder iTask, edm::LuminosityBlockPrincipal const &lbp, ProcessContext const *, ActivityRegistry *) override
void setEventSelectionInfo(std::map< std::string, std::vector< std::pair< std::string, int > > > const &outputModulePathPositions, bool anyProductProduced) override
PreModuleWriteRun preModuleWriteRunSignal_
RunIndex index() const
Definition: RunPrincipal.h:53
HLT enums.
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:281
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
Definition: vlib.h:208
void openFile(edm::FileBlock const &fb) override
def move(src, dest)
Definition: eostools.py:510