CMS 3D CMS Logo

MixingModule.cc
Go to the documentation of this file.
1 // File: MixingModule.cc
2 // Description: see MixingModule.h
3 // Author: Ursula Berthon, LLR Palaiseau, Bill Tanenbaum
4 //
5 //--------------------------------------------
6 
7 #include <functional>
8 #include <memory>
9 
10 #include "MixingModule.h"
11 #include "MixingWorker.h"
12 #include "Adjuster.h"
13 
37 
38 namespace edm {
39 
40  // Constructor
42  BMixingModule(ps_mix, globalConf),
43  inputTagPlayback_(),
44  mixProdStep2_(ps_mix.getParameter<bool>("mixProdStep2")),
45  mixProdStep1_(ps_mix.getParameter<bool>("mixProdStep1")),
46  digiAccumulators_()
47  {
48  if (!mixProdStep1_ && !mixProdStep2_) LogInfo("MixingModule") << " The MixingModule was run in the Standard mode.";
49  if (mixProdStep1_) LogInfo("MixingModule") << " The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
50  if (mixProdStep2_) LogInfo("MixingModule") << " The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
51 
53  if (ps_mix.exists("useCurrentProcessOnly")) {
54  useCurrentProcessOnly_=ps_mix.getParameter<bool>("useCurrentProcessOnly");
55  LogInfo("MixingModule") <<" using given Parameter 'useCurrentProcessOnly' ="<<useCurrentProcessOnly_;
56  }
57  std::string labelPlayback;
58  if (ps_mix.exists("LabelPlayback")) {
59  labelPlayback = ps_mix.getParameter<std::string>("LabelPlayback");
60  }
61  if (labelPlayback.empty()) {
62  labelPlayback = ps_mix.getParameter<std::string>("@module_label");
63  }
64  if (playback_) {
66  consumes<CrossingFramePlaybackInfoNew>(inputTagPlayback_);
67  }
68  wrapLongTimes_ = false;
69  if (ps_mix.exists("WrapLongTimes")) {
70  wrapLongTimes_ = ps_mix.getParameter<bool>("WrapLongTimes");
71  }
72 
73 
74  ParameterSet ps=ps_mix.getParameter<ParameterSet>("mixObjects");
75  std::vector<std::string> names = ps.getParameterNames();
76  for(std::vector<std::string>::iterator it=names.begin();it!= names.end();++it) {
77  ParameterSet pset=ps.getParameter<ParameterSet>((*it));
78  if (!pset.exists("type")) continue; //to allow replacement by empty pset
79  std::string object = pset.getParameter<std::string>("type");
80  std::vector<InputTag> tags=pset.getParameter<std::vector<InputTag> >("input");
81 
82  //if (!mixProdStep2_) {
83 
84  InputTag tagCF = InputTag();
85  std::string labelCF = " ";
86 
87  if (object=="SimTrack") {
88  InputTag tag;
89  if (!tags.empty()) tag=tags[0];
91 
92  branchesActivate(TypeID(typeid(std::vector<SimTrack>)).friendlyClassName(),std::string(""),tag,label);
93  adjustersObjects_.push_back(new Adjuster<std::vector<SimTrack> >(tag, consumesCollector(),wrapLongTimes_));
94  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
95  if(makeCrossingFrame) {
97  produces<CrossingFrame<SimTrack> >(label);
98  }
99  consumes<std::vector<SimTrack> >(tag);
100 
101  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
102  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
103 
104  } else if (object=="RecoTrack") {
105  InputTag tag;
106  if (!tags.empty()) tag=tags[0];
108 
109  branchesActivate(TypeID(typeid(std::vector<reco::Track>)).friendlyClassName(),std::string(""),tag,label);
110  branchesActivate(TypeID(typeid(std::vector<reco::TrackExtra>)).friendlyClassName(),std::string(""),tag,label);
112  adjustersObjects_.push_back(new Adjuster<edm::OwnVector<TrackingRecHit> >(tag, consumesCollector(),wrapLongTimes_));
113  // note: no crossing frame is foreseen to be used for this object type
114 
115  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
116  //std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
117 
118  } else if (object=="SimVertex") {
119  InputTag tag;
120  if (!tags.empty()) tag=tags[0];
122 
123  branchesActivate(TypeID(typeid(std::vector<SimVertex>)).friendlyClassName(),std::string(""),tag,label);
124  adjustersObjects_.push_back(new Adjuster<std::vector<SimVertex> >(tag, consumesCollector(),wrapLongTimes_));
125  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
126  if(makeCrossingFrame) {
128  produces<CrossingFrame<SimVertex> >(label);
129  }
130  consumes<std::vector<SimVertex> >(tag);
131 
132  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label;
133  // std::cout <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label<<std::endl;
134 
135  } else if (object=="HepMCProduct") {
136  InputTag tag;
137  if (!tags.empty()) tag=tags[0];
139 
140  branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(),std::string(""),tag,label);
141  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
142  if(makeCrossingFrame) {
143  workersObjects_.push_back(new MixingWorker<HepMCProduct>(minBunch_,maxBunch_,bunchSpace_,std::string(""),label,labelCF,maxNbSources_,tag,tagCF,tags));
144  produces<CrossingFrame<HepMCProduct> >(label);
145  }
146  consumes<HepMCProduct>(tag);
147 
148  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
149  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
150  for(size_t i = 1; i < tags.size(); ++i) {
151  InputTag fallbackTag = tags[i];
152  std::string fallbackLabel;
153  branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(),std::string(""),fallbackTag,fallbackLabel);
154  mayConsume<HepMCProduct>(fallbackTag);
155  }
156 
157  } else if (object=="PCaloHit") {
158  std::vector<std::string> subdets=pset.getParameter<std::vector<std::string> >("subdets");
159  std::vector<std::string> crossingFrames=pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
160  sort_all(crossingFrames);
161  for (unsigned int ii=0;ii<subdets.size();++ii) {
162  InputTag tag;
163  if (tags.size()==1) tag=tags[0];
164  else if(tags.size()>1) tag=tags[ii];
166 
167  branchesActivate(TypeID(typeid(std::vector<PCaloHit>)).friendlyClassName(),subdets[ii],tag,label);
168  adjustersObjects_.push_back(new Adjuster<std::vector<PCaloHit> >(tag, consumesCollector(),wrapLongTimes_));
169  if(binary_search_all(crossingFrames, tag.instance())) {
170  workersObjects_.push_back(new MixingWorker<PCaloHit>(minBunch_,maxBunch_,bunchSpace_,subdets[ii],label,labelCF,maxNbSources_,tag,tagCF));
171  produces<CrossingFrame<PCaloHit> >(label);
172  consumes<std::vector<PCaloHit> >(tag);
173  }
174 
175  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
176  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
177 
178  }
179 
180  } else if (object=="PSimHit") {
181  std::vector<std::string> subdets=pset.getParameter<std::vector<std::string> >("subdets");
182  std::vector<std::string> crossingFrames=pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
183  sort_all(crossingFrames);
184  std::vector<std::string> pcrossingFrames=pset.getUntrackedParameter<std::vector<std::string> >("pcrossingFrames", std::vector<std::string>());
185  sort_all(pcrossingFrames);
186  for (unsigned int ii=0;ii<subdets.size();++ii) {
187  InputTag tag;
188  if (tags.size()==1) tag=tags[0];
189  else if(tags.size()>1) tag=tags[ii];
191 
192  branchesActivate(TypeID(typeid(std::vector<PSimHit>)).friendlyClassName(),subdets[ii],tag,label);
193  adjustersObjects_.push_back(new Adjuster<std::vector<PSimHit> >(tag, consumesCollector(),wrapLongTimes_));
194  if(binary_search_all(crossingFrames, tag.instance())) {
195  bool makePCrossingFrame = binary_search_all(pcrossingFrames, tag.instance());
196  workersObjects_.push_back(new MixingWorker<PSimHit>(minBunch_,maxBunch_,bunchSpace_,subdets[ii],label,labelCF,maxNbSources_,tag,tagCF, makePCrossingFrame));
197  produces<CrossingFrame<PSimHit> >(label);
198  if(makePCrossingFrame) {
199  produces<PCrossingFrame<PSimHit> >(label);
200  }
201  consumes<std::vector<PSimHit> >(tag);
202  }
203 
204  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
205  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
206  }
207  } else {
208  LogWarning("MixingModule") <<"You have asked to mix an unknown type of object("<<object<<").\n If you want to include it in mixing, please contact the authors of the MixingModule!";
209  }
210  //} //if for mixProdStep2
211  }//while over the mixObjects parameters
212 
214  for (unsigned int branch=0;branch<wantedBranches_.size();++branch) LogDebug("MixingModule")<<"Will keep branch "<<wantedBranches_[branch]<<" for mixing ";
215 
217 
218  produces<PileupMixingContent>();
219 
220  produces<CrossingFramePlaybackInfoNew>();
221 
222  edm::ConsumesCollector iC(consumesCollector());
223  // Create and configure digitizers
224  createDigiAccumulators(ps_mix, iC);
225  }
226 
227 
229  ParameterSet const& digiPSet = mixingPSet.getParameterSet("digitizers");
230  std::vector<std::string> digiNames = digiPSet.getParameterNames();
231  for(auto const& digiName : digiNames) {
232  ParameterSet const& pset = digiPSet.getParameterSet(digiName);
233  if(pset.existsAs<edm::InputTag>("HepMCProductLabel")) {
234  consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("HepMCProductLabel"));
235  }
236  std::unique_ptr<DigiAccumulatorMixMod> accumulator = std::unique_ptr<DigiAccumulatorMixMod>(DigiAccumulatorMixModFactory::get()->makeDigiAccumulator(pset, *this, iC));
237  // Create appropriate DigiAccumulator
238  if(accumulator.get() != nullptr) {
239  digiAccumulators_.push_back(accumulator.release());
240  }
241  }
242  }
243 
245  //change the basic parameters.
247  setup.get<MixingRcd>().get(config);
248  minBunch_=config->minBunch();
249  maxBunch_=config->maxBunch();
250  bunchSpace_=config->bunchSpace();
251  //propagate to change the workers
252  for (unsigned int ii=0;ii<workersObjects_.size();++ii){
253  workersObjects_[ii]->reload(setup);
254  }
255  }
256 
258 
259  label=tag.label()+tag.instance();
260  wantedBranches_.push_back(friendlyName + '_' +
261  tag.label() + '_' +
262  tag.instance());
263 
264  //if useCurrentProcessOnly, we have to change the input tag
267  tag = InputTag(tag.label(),tag.instance(),processName);
268  }
269  }
270 
272  if (adjusters_.empty()){
273  for (auto const& adjuster : adjustersObjects_) {
274  if (adjuster->checkSignal(e)){
275  adjusters_.push_back(adjuster);
276  }
277  }
278  }
279  if (workers_.empty()){
280  for (auto const& worker : workersObjects_) {
281  if (worker->checkSignal(e)){
282  workers_.push_back(worker);
283  }
284  }
285  }
286  }
287 
289  //create playback info
291  //and CrossingFrames
292  for (unsigned int ii=0;ii<workers_.size();++ii){
293  workers_[ii]->createnewEDProduct();
294  }
295  }
296 
297  // Virtual destructor needed.
299  for (auto& worker : workersObjects_) {
300  delete worker;
301  }
302 
303  for (auto& adjuster : adjustersObjects_) {
304  delete adjuster;
305  }
306 
307  for (auto& digiAccumulator : digiAccumulators_) {
308  delete digiAccumulator;
309  }
310  }
311 
313 
314  LogDebug("MixingModule")<<"===============> adding signals for "<<e.id();
315 
316  accumulateEvent(e, setup);
317  // fill in signal part of CrossingFrame
318  for (unsigned int ii=0;ii<workers_.size();++ii) {
319  workers_[ii]->addSignals(e);
320  }
321  }
322 
323  bool MixingModule::pileAllWorkers(EventPrincipal const& eventPrincipal,
324  ModuleCallingContext const* mcc,
325  int bunchCrossing, int eventId,
326  int& vertexOffset,
327  const edm::EventSetup& setup,
328  StreamID const& streamID) {
329 
330 
331  InternalContext internalContext(eventPrincipal.id(), mcc);
332  ParentContext parentContext(&internalContext);
333  ModuleCallingContext moduleCallingContext(&moduleDescription());
334  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
335 
336  for (auto const& adjuster : adjusters_) {
337  adjuster->doOffset(bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
338  }
339  PileUpEventPrincipal pep(eventPrincipal, &moduleCallingContext, bunchCrossing);
340 
341  accumulateEvent(pep, setup, streamID);
342 
343  for (auto const& worker : workers_) {
344  LogDebug("MixingModule") <<" merging Event: id " << eventPrincipal.id();
345  // std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl;
346 
347  worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
348  }
349 
350  return true;
351  }
352 
354  using namespace std::placeholders;
355 
356  // Don't allocate because PileUp will do it for us.
357  std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
358  std::vector<size_t> sizes;
359  sizes.reserve(maxNbSources_*(maxBunch_ + 1 - minBunch_));
360  size_t playbackCounter = 0U;
362  edm::Handle<CrossingFramePlaybackInfoExtended> oldFormatPlaybackInfo_H;
363  bool oldFormatPlayback = false;
364  if (playback_) {
365  bool got = e.getByLabel(inputTagPlayback_, playbackInfo_H);
366  if (!got) {
367  bool gotOld = e.getByLabel(inputTagPlayback_, oldFormatPlaybackInfo_H);
368  if (!gotOld) {
369  throw cms::Exception("MixingProductNotFound") << " No "
370  "CrossingFramePlaybackInfoNew on the input file, but playback "
371  "option set!!!!! Please change the input file if you really want "
372  "playback!!!!!!" << std::endl;
373  }
374  oldFormatPlayback = true;
375  }
376  }
377 
378  // source[0] is "real" pileup. Check to see that this is what we are doing.
379 
380  std::vector<int> PileupList;
381  PileupList.clear();
382  TrueNumInteractions_.clear();
383 
384  std::shared_ptr<PileUp> source0 = inputSources_[0];
385 
386  if((source0 && source0->doPileUp(0) ) && !playback_) {
387  // if((!inputSources_[0] || !inputSources_[0]->doPileUp()) && !playback_ )
388 
389  // Pre-calculate all pileup distributions before we go fishing for events
390 
391  source0->CalculatePileup(minBunch_, maxBunch_, PileupList, TrueNumInteractions_, e.streamID());
392 
393  }
394 
395  // pre-populate Pileup information
396  // necessary for luminosity-dependent effects during hit accumulation
397 
398  std::vector<int> numInteractionList;
399  std::vector<int> bunchCrossingList;
400  std::vector<float> TrueInteractionList;
401  std::vector<edm::EventID> eventInfoList; // will be empty if we pre-populate, but it's not used in digitizers
402 
403  if(!playback_) {
404 
405  //Makin' a list: Basically, we don't care about the "other" sources at this point.
406  for (int bunchCrossing=minBunch_;bunchCrossing<=maxBunch_;++bunchCrossing) {
407  bunchCrossingList.push_back(bunchCrossing);
408  if(!inputSources_[0] || !inputSources_[0]->doPileUp(0)) {
409  numInteractionList.push_back(0);
410  TrueInteractionList.push_back(0);
411  }
412  else {
413  numInteractionList.push_back(PileupList[bunchCrossing-minBunch_]);
414  TrueInteractionList.push_back((TrueNumInteractions_)[bunchCrossing-minBunch_]);
415  }
416  }
417  }
418  else{ // have to read PU information from playback info
419  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
420  bunchCrossingList.push_back(bunchIdx);
421  for (size_t readSrcIdx=0; readSrcIdx<maxNbSources_; ++readSrcIdx) {
422 
423  if(oldFormatPlayback) {
424  std::vector<edm::EventID> const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
425  size_t numberOfEvents = playEventID.size();
426  if(readSrcIdx == 0) {
427  PileupList.push_back(numberOfEvents);
428  TrueNumInteractions_.push_back(numberOfEvents);
429  numInteractionList.push_back(numberOfEvents);
430  TrueInteractionList.push_back(numberOfEvents);
431  }
432  } else {
433  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
434  if(readSrcIdx == 0) {
435  PileupList.push_back(numberOfEvents);
436  TrueNumInteractions_.push_back(numberOfEvents);
437  numInteractionList.push_back(numberOfEvents);
438  TrueInteractionList.push_back(numberOfEvents);
439  }
440  }
441  }
442  }
443  }
444 
445  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
446  (*accItr)->StorePileupInformation( bunchCrossingList,
447  numInteractionList,
448  TrueInteractionList,
449  eventInfoList,
450  bunchSpace_);
451  }
452 
453 
454  // for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
455  // std::cout << " bunch ID, Pileup, True " << bunchIdx << " " << PileupList[bunchIdx-minBunch_] << " " << TrueNumInteractions_[bunchIdx-minBunch_] << std::endl;
456  //}
457 
458  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
459  for (size_t setBcrIdx=0; setBcrIdx<workers_.size(); ++setBcrIdx) {
460  workers_[setBcrIdx]->setBcrOffset();
461  }
462  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
463  (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
464  }
465 
466  for (size_t readSrcIdx=0; readSrcIdx<maxNbSources_; ++readSrcIdx) {
467  std::shared_ptr<PileUp> source = inputSources_[readSrcIdx]; // this looks like we create
468  // new PileUp objects for each
469  // source for each event?
470  // Why?
471  for (size_t setSrcIdx=0; setSrcIdx<workers_.size(); ++setSrcIdx) {
472  workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
473  }
474 
475  if (!source || !source->doPileUp(bunchIdx)) {
476  sizes.push_back(0U);
477  if(playback_ && !oldFormatPlayback) {
478  playbackCounter += playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
479  }
480  continue;
481  }
482 
483  // int eventId = 0;
484  int vertexOffset = 0;
485 
487  if (!playback_) {
488  // non-minbias pileup only gets one event for now. Fix later if desired.
489  int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx - minBunch_] : 1);
490  sizes.push_back(numberOfEvents);
491  inputSources_[readSrcIdx]->readPileUp(e.id(), recordEventID,
492  std::bind(&MixingModule::pileAllWorkers, std::ref(*this), _1, mcc, bunchIdx,
493  _2, vertexOffset, std::ref(setup), e.streamID()), numberOfEvents, e.streamID());
494  } else if(oldFormatPlayback) {
495  std::vector<edm::EventID> const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
496  size_t numberOfEvents = playEventID.size();
497  if(readSrcIdx == 0) {
498  PileupList.push_back(numberOfEvents);
499  TrueNumInteractions_.push_back(numberOfEvents);
500  }
501  sizes.push_back(numberOfEvents);
502  std::vector<EventID>::const_iterator begin = playEventID.begin();
503  std::vector<EventID>::const_iterator end = playEventID.end();
504  inputSources_[readSrcIdx]->playOldFormatPileUp(
505  begin, end, recordEventID,
506  std::bind(&MixingModule::pileAllWorkers, std::ref(*this), _1, mcc, bunchIdx,
507  _2, vertexOffset, std::ref(setup), e.streamID()));
508  } else {
509  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
510  if(readSrcIdx == 0) {
511  PileupList.push_back(numberOfEvents);
512  TrueNumInteractions_.push_back(numberOfEvents);
513  }
514  sizes.push_back(numberOfEvents);
515  std::vector<SecondaryEventIDAndFileInfo>::const_iterator begin = playbackInfo_H->getEventId(playbackCounter);
516  playbackCounter += numberOfEvents;
517  std::vector<SecondaryEventIDAndFileInfo>::const_iterator end = playbackInfo_H->getEventId(playbackCounter);
518  inputSources_[readSrcIdx]->playPileUp(
519  begin, end, recordEventID,
520  std::bind(&MixingModule::pileAllWorkers, std::ref(*this), _1, mcc, bunchIdx,
521  _2, vertexOffset, std::ref(setup), e.streamID()));
522  }
523  }
524  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
525  (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
526  }
527  }
528 
529  // Save playback information
530  for (auto const item : recordEventID) {
531  eventInfoList.emplace_back(item.eventID());
532  }
533 
534  // setInfo swaps recordEventID, so recordEventID is useless (empty) after the call.
535  playbackInfo_->setInfo(recordEventID, sizes);
536 
537  // Keep track of pileup accounting...
538 
539 
540  std::unique_ptr<PileupMixingContent> PileupMixing_;
541 
542  PileupMixing_ = std::unique_ptr<PileupMixingContent>(new PileupMixingContent(bunchCrossingList,
543  numInteractionList,
544  TrueInteractionList,
545  eventInfoList,
546  bunchSpace_));
547 
548  e.put(std::move(PileupMixing_));
549 
550  // we have to do the ToF transformation for PSimHits once all pileup has been added
551  for (unsigned int ii=0;ii<workers_.size();++ii) {
552  workers_[ii]->setTof();
553  workers_[ii]->put(e);
554  }
555  }
556 
558 
559  if (playbackInfo_) {
560  std::unique_ptr<CrossingFramePlaybackInfoNew> pOut(playbackInfo_);
561  e.put(std::move(pOut));
562  }
563  }
564 
566  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
567  (*accItr)->beginRun(run, setup);
568  }
569  BMixingModule::beginRun( run, setup);
570  }
571 
573  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
574  (*accItr)->endRun(run, setup);
575  }
576  BMixingModule::endRun( run, setup);
577  }
578 
580  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
581  (*accItr)->beginLuminosityBlock(lumi, setup);
582  }
584  }
585 
587  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
588  (*accItr)->endLuminosityBlock(lumi, setup);
589  }
591  }
592 
593  void
595  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
596  (*accItr)->initializeEvent(event, setup);
597  }
598  }
599 
600  void
602  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
603  (*accItr)->accumulate(event, setup);
604  }
605  }
606 
607  void
609  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
610  (*accItr)->accumulate(event, setup, streamID);
611  }
612  }
613 
614  void
616  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
617  (*accItr)->finalizeEvent(event, setup);
618  }
619  }
620 }//edm
#define LogDebug(id)
void setInfo(std::vector< edm::SecondaryEventIDAndFileInfo > &eventInfo, std::vector< size_t > &sizes)
std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator getEventId(size_t offset) const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
void beginLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
const int & bunchSpace() const
static std::string const source("source")
std::vector< edm::EventID > getStartEventId(const unsigned int s, const int bcr) const
~MixingModule() override
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
std::vector< float > TrueNumInteractions_
EventID const & id() const
bool exists(std::string const &parameterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
void addSignals(const edm::Event &e, const edm::EventSetup &es) override
const std::string names[nVars_]
std::string encode() const
Definition: InputTag.cc:159
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
void put(edm::Event &e, const edm::EventSetup &es) override
const int & maxBunch() const
config
Definition: looper.py:291
char const * label
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:241
void reload(const edm::EventSetup &) override
std::string friendlyName(std::string const &iFullName)
void endLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
void checkSignal(const edm::Event &e) override
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:97
Accumulators digiAccumulators_
Definition: MixingModule.h:104
void initializeEvent(Event const &event, EventSetup const &setup) override
static const std::string kSkipCurrentProcess
Definition: InputTag.h:53
MixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
Definition: MixingModule.cc:41
std::vector< AdjusterBase * > adjusters_
Definition: MixingModule.h:95
size_t getNumberOfEvents(int bunchIdx, size_t sourceNumber) const
static const unsigned int maxNbSources_
#define end
Definition: vmac.h:39
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:98
void beginRun(Run const &r1, EventSetup const &c) override
std::vector< std::string > getParameterNames() const
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:93
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
ii
Definition: cuy.py:590
virtual void branchesActivate(const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label)
bool pileAllWorkers(EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
ParameterSet const & getParameterSet(std::string const &) const
std::vector< std::string > wantedBranches_
Definition: MixingModule.h:99
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:96
InputTag inputTagPlayback_
Definition: MixingModule.h:90
std::string const & label() const
Definition: InputTag.h:36
edm::EventID id() const
Definition: EventBase.h:59
#define begin
Definition: vmac.h:32
HLT enums.
void accumulateEvent(Event const &event, EventSetup const &setup)
void createnewEDProduct() override
std::vector< std::shared_ptr< PileUp > > inputSources_
std::unique_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, ProducerBase &, ConsumesCollector &) const
T get() const
Definition: EventSetup.h:71
StreamID streamID() const
Definition: Event.h:95
const int & minBunch() const
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:58
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
void finalizeEvent(Event &event, EventSetup const &setup) override
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
static DigiAccumulatorMixModFactory const * get()
static const std::string subdets[7]
Definition: TrackUtils.cc:60
std::string const & instance() const
Definition: InputTag.h:37
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void doPileUp(edm::Event &e, const edm::EventSetup &es) override
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
Definition: Run.h:45
void endRun(Run const &r1, EventSetup const &c) override