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_() {
48  LogInfo("MixingModule") << " The MixingModule was run in the Standard mode.";
49  if (mixProdStep1_)
50  LogInfo("MixingModule") << " The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
51  if (mixProdStep2_)
52  LogInfo("MixingModule") << " The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
53 
54  useCurrentProcessOnly_ = false;
55  if (ps_mix.exists("useCurrentProcessOnly")) {
56  useCurrentProcessOnly_ = ps_mix.getParameter<bool>("useCurrentProcessOnly");
57  LogInfo("MixingModule") << " using given Parameter 'useCurrentProcessOnly' =" << useCurrentProcessOnly_;
58  }
59  std::string labelPlayback;
60  if (ps_mix.exists("LabelPlayback")) {
61  labelPlayback = ps_mix.getParameter<std::string>("LabelPlayback");
62  }
63  if (labelPlayback.empty()) {
64  labelPlayback = ps_mix.getParameter<std::string>("@module_label");
65  }
66  if (playback_) {
68  consumes<CrossingFramePlaybackInfoNew>(inputTagPlayback_);
69  }
70  wrapLongTimes_ = false;
71  if (ps_mix.exists("WrapLongTimes")) {
72  wrapLongTimes_ = ps_mix.getParameter<bool>("WrapLongTimes");
73  }
74 
75  skipSignal_ = false;
76  if (ps_mix.exists("skipSignal")) {
77  skipSignal_ = ps_mix.getParameter<bool>("skipSignal");
78  }
79 
80  ParameterSet ps = ps_mix.getParameter<ParameterSet>("mixObjects");
81  std::vector<std::string> names = ps.getParameterNames();
82  for (std::vector<std::string>::iterator it = names.begin(); it != names.end(); ++it) {
84  if (!pset.exists("type"))
85  continue; //to allow replacement by empty pset
86  std::string object = pset.getParameter<std::string>("type");
87  std::vector<InputTag> tags = pset.getParameter<std::vector<InputTag> >("input");
88 
89  //if (!mixProdStep2_) {
90 
91  InputTag tagCF = InputTag();
92  std::string labelCF = " ";
93 
94  if (object == "SimTrack") {
95  InputTag tag;
96  if (!tags.empty())
97  tag = tags[0];
99 
100  branchesActivate(TypeID(typeid(std::vector<SimTrack>)).friendlyClassName(), std::string(""), tag, label);
101  adjustersObjects_.push_back(new Adjuster<std::vector<SimTrack> >(tag, consumesCollector(), wrapLongTimes_));
102  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
103  if (makeCrossingFrame) {
105  minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF));
106  produces<CrossingFrame<SimTrack> >(label);
107  }
108  consumes<std::vector<SimTrack> >(tag);
109 
110  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
111  << label;
112  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
113 
114  } else if (object == "RecoTrack") {
115  InputTag tag;
116  if (!tags.empty())
117  tag = tags[0];
119 
120  branchesActivate(TypeID(typeid(std::vector<reco::Track>)).friendlyClassName(), std::string(""), tag, label);
122  TypeID(typeid(std::vector<reco::TrackExtra>)).friendlyClassName(), std::string(""), tag, label);
125  std::string(""),
126  tag,
127  label);
128  adjustersObjects_.push_back(
129  new Adjuster<edm::OwnVector<TrackingRecHit> >(tag, consumesCollector(), wrapLongTimes_));
130  // note: no crossing frame is foreseen to be used for this object type
131 
132  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
133  << label;
134  //std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
135 
136  } else if (object == "SimVertex") {
137  InputTag tag;
138  if (!tags.empty())
139  tag = tags[0];
141 
142  branchesActivate(TypeID(typeid(std::vector<SimVertex>)).friendlyClassName(), std::string(""), tag, label);
143  adjustersObjects_.push_back(new Adjuster<std::vector<SimVertex> >(tag, consumesCollector(), wrapLongTimes_));
144  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
145  if (makeCrossingFrame) {
147  minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF));
148  produces<CrossingFrame<SimVertex> >(label);
149  }
150  consumes<std::vector<SimVertex> >(tag);
151 
152  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag " << tag.encode() << ", label will be "
153  << label;
154  // std::cout <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label<<std::endl;
155 
156  } else if (object == "HepMCProduct") {
157  InputTag tag;
158  if (!tags.empty())
159  tag = tags[0];
161 
162  branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(), std::string(""), tag, label);
163  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
164  if (makeCrossingFrame) {
166  minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF, tags));
167  produces<CrossingFrame<HepMCProduct> >(label);
168  }
169  consumes<HepMCProduct>(tag);
170 
171  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
172  << label;
173  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
174  for (size_t i = 1; i < tags.size(); ++i) {
175  InputTag fallbackTag = tags[i];
176  std::string fallbackLabel;
178  TypeID(typeid(HepMCProduct)).friendlyClassName(), std::string(""), fallbackTag, fallbackLabel);
179  mayConsume<HepMCProduct>(fallbackTag);
180  }
181 
182  } else if (object == "PCaloHit") {
183  std::vector<std::string> subdets = pset.getParameter<std::vector<std::string> >("subdets");
184  std::vector<std::string> crossingFrames =
185  pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
187  for (unsigned int ii = 0; ii < subdets.size(); ++ii) {
188  InputTag tag;
189  if (tags.size() == 1)
190  tag = tags[0];
191  else if (tags.size() > 1)
192  tag = tags[ii];
194 
195  branchesActivate(TypeID(typeid(std::vector<PCaloHit>)).friendlyClassName(), subdets[ii], tag, label);
196  adjustersObjects_.push_back(new Adjuster<std::vector<PCaloHit> >(tag, consumesCollector(), wrapLongTimes_));
197  if (binary_search_all(crossingFrames, tag.instance())) {
199  minBunch_, maxBunch_, bunchSpace_, subdets[ii], label, labelCF, maxNbSources_, tag, tagCF));
200  produces<CrossingFrame<PCaloHit> >(label);
201  consumes<std::vector<PCaloHit> >(tag);
202  }
203 
204  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
205  << label;
206  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
207  }
208 
209  } else if (object == "PSimHit") {
210  std::vector<std::string> subdets = pset.getParameter<std::vector<std::string> >("subdets");
211  std::vector<std::string> crossingFrames =
212  pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
214  std::vector<std::string> pcrossingFrames =
215  pset.getUntrackedParameter<std::vector<std::string> >("pcrossingFrames", std::vector<std::string>());
217  for (unsigned int ii = 0; ii < subdets.size(); ++ii) {
218  InputTag tag;
219  if (tags.size() == 1)
220  tag = tags[0];
221  else if (tags.size() > 1)
222  tag = tags[ii];
224 
225  branchesActivate(TypeID(typeid(std::vector<PSimHit>)).friendlyClassName(), subdets[ii], tag, label);
226  adjustersObjects_.push_back(new Adjuster<std::vector<PSimHit> >(tag, consumesCollector(), wrapLongTimes_));
227  if (binary_search_all(crossingFrames, tag.instance())) {
228  bool makePCrossingFrame = binary_search_all(pcrossingFrames, tag.instance());
230  maxBunch_,
231  bunchSpace_,
232  subdets[ii],
233  label,
234  labelCF,
236  tag,
237  tagCF,
238  makePCrossingFrame));
239  produces<CrossingFrame<PSimHit> >(label);
240  if (makePCrossingFrame) {
241  produces<PCrossingFrame<PSimHit> >(label);
242  }
243  consumes<std::vector<PSimHit> >(tag);
244  }
245 
246  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
247  << label;
248  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
249  }
250  } else {
251  LogWarning("MixingModule")
252  << "You have asked to mix an unknown type of object(" << object
253  << ").\n If you want to include it in mixing, please contact the authors of the MixingModule!";
254  }
255  //} //if for mixProdStep2
256  } //while over the mixObjects parameters
257 
259  for (unsigned int branch = 0; branch < wantedBranches_.size(); ++branch)
260  LogDebug("MixingModule") << "Will keep branch " << wantedBranches_[branch] << " for mixing ";
261 
263 
264  produces<PileupMixingContent>();
265 
266  produces<CrossingFramePlaybackInfoNew>();
267 
268  edm::ConsumesCollector iC(consumesCollector());
269  // Create and configure digitizers
270  createDigiAccumulators(ps_mix, iC);
271  }
272 
274  ParameterSet const& digiPSet = mixingPSet.getParameterSet("digitizers");
275  std::vector<std::string> digiNames = digiPSet.getParameterNames();
276  for (auto const& digiName : digiNames) {
277  ParameterSet const& pset = digiPSet.getParameterSet(digiName);
278  if (pset.existsAs<edm::InputTag>("HepMCProductLabel")) {
279  consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("HepMCProductLabel"));
280  }
281  std::unique_ptr<DigiAccumulatorMixMod> accumulator = std::unique_ptr<DigiAccumulatorMixMod>(
282  DigiAccumulatorMixModFactory::get()->makeDigiAccumulator(pset, producesCollector(), iC));
283  // Create appropriate DigiAccumulator
284  if (accumulator.get() != nullptr) {
285  digiAccumulators_.push_back(accumulator.release());
286  }
287  }
288  }
289 
291  // TODO for esConsumes migration: assume for now this function is mostly unused
292  //change the basic parameters.
294  setup.get<MixingRcd>().get(config);
295  minBunch_ = config->minBunch();
296  maxBunch_ = config->maxBunch();
297  bunchSpace_ = config->bunchSpace();
298  //propagate to change the workers
299  for (unsigned int ii = 0; ii < workersObjects_.size(); ++ii) {
300  workersObjects_[ii]->reload(setup);
301  }
302  }
303 
305  const std::string& subdet,
306  InputTag& tag,
307  std::string& label) {
308  label = tag.label() + tag.instance();
309  wantedBranches_.push_back(friendlyName + '_' + tag.label() + '_' + tag.instance());
310 
311  //if useCurrentProcessOnly, we have to change the input tag
314  tag = InputTag(tag.label(), tag.instance(), processName);
315  }
316  }
317 
319  if (adjusters_.empty()) {
320  for (auto const& adjuster : adjustersObjects_) {
321  if (skipSignal_ or adjuster->checkSignal(e)) {
322  adjusters_.push_back(adjuster);
323  }
324  }
325  }
326  if (workers_.empty()) {
327  for (auto const& worker : workersObjects_) {
328  if (skipSignal_ or worker->checkSignal(e)) {
329  workers_.push_back(worker);
330  }
331  }
332  }
333  }
334 
336  //create playback info
338  //and CrossingFrames
339  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
340  workers_[ii]->createnewEDProduct();
341  }
342  }
343 
344  // Virtual destructor needed.
346  for (auto& worker : workersObjects_) {
347  delete worker;
348  }
349 
350  for (auto& adjuster : adjustersObjects_) {
351  delete adjuster;
352  }
353 
354  for (auto& digiAccumulator : digiAccumulators_) {
355  delete digiAccumulator;
356  }
357  }
358 
360  if (skipSignal_) {
361  return;
362  }
363 
364  LogDebug("MixingModule") << "===============> adding signals for " << e.id();
365 
367  // fill in signal part of CrossingFrame
368  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
369  workers_[ii]->addSignals(e);
370  }
371  }
372 
373  bool MixingModule::pileAllWorkers(EventPrincipal const& eventPrincipal,
374  ModuleCallingContext const* mcc,
375  int bunchCrossing,
376  int eventId,
377  int& vertexOffset,
378  const edm::EventSetup& setup,
379  StreamID const& streamID) {
380  InternalContext internalContext(eventPrincipal.id(), mcc);
381  ParentContext parentContext(&internalContext);
382  ModuleCallingContext moduleCallingContext(&moduleDescription());
383  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
384 
385  for (auto const& adjuster : adjusters_) {
386  adjuster->doOffset(bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
387  }
388  PileUpEventPrincipal pep(eventPrincipal, &moduleCallingContext, bunchCrossing);
389 
390  accumulateEvent(pep, setup, streamID);
391 
392  for (auto const& worker : workers_) {
393  LogDebug("MixingModule") << " merging Event: id " << eventPrincipal.id();
394  // std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl;
395 
396  worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
397  }
398 
399  return true;
400  }
401 
403  using namespace std::placeholders;
404 
405  // Don't allocate because PileUp will do it for us.
406  std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
407  std::vector<size_t> sizes;
408  sizes.reserve(maxNbSources_ * (maxBunch_ + 1 - minBunch_));
409  size_t playbackCounter = 0U;
411  edm::Handle<CrossingFramePlaybackInfoExtended> oldFormatPlaybackInfo_H;
412  bool oldFormatPlayback = false;
413  if (playback_) {
414  bool got = e.getByLabel(inputTagPlayback_, playbackInfo_H);
415  if (!got) {
416  bool gotOld = e.getByLabel(inputTagPlayback_, oldFormatPlaybackInfo_H);
417  if (!gotOld) {
418  throw cms::Exception("MixingProductNotFound")
419  << " No "
420  "CrossingFramePlaybackInfoNew on the input file, but playback "
421  "option set!!!!! Please change the input file if you really want "
422  "playback!!!!!!"
423  << std::endl;
424  }
425  oldFormatPlayback = true;
426  }
427  }
428 
429  // source[0] is "real" pileup. Check to see that this is what we are doing.
430 
431  std::vector<int> PileupList;
432  PileupList.clear();
433  TrueNumInteractions_.clear();
434 
435  std::shared_ptr<PileUp> source0 = inputSources_[0];
436 
437  if ((source0 && source0->doPileUp(0)) && !playback_) {
438  // if((!inputSources_[0] || !inputSources_[0]->doPileUp()) && !playback_ )
439 
440  // Pre-calculate all pileup distributions before we go fishing for events
441 
442  source0->CalculatePileup(minBunch_, maxBunch_, PileupList, TrueNumInteractions_, e.streamID());
443  }
444 
445  // pre-populate Pileup information
446  // necessary for luminosity-dependent effects during hit accumulation
447 
448  std::vector<int> numInteractionList;
449  std::vector<int> bunchCrossingList;
450  std::vector<float> TrueInteractionList;
451  std::vector<edm::EventID> eventInfoList; // will be empty if we pre-populate, but it's not used in digitizers
452 
453  if (!playback_) {
454  //Makin' a list: Basically, we don't care about the "other" sources at this point.
455  for (int bunchCrossing = minBunch_; bunchCrossing <= maxBunch_; ++bunchCrossing) {
456  bunchCrossingList.push_back(bunchCrossing);
457  if (!inputSources_[0] || !inputSources_[0]->doPileUp(0)) {
458  numInteractionList.push_back(0);
459  TrueInteractionList.push_back(0);
460  } else {
461  numInteractionList.push_back(PileupList[bunchCrossing - minBunch_]);
462  TrueInteractionList.push_back((TrueNumInteractions_)[bunchCrossing - minBunch_]);
463  }
464  }
465  } else { // have to read PU information from playback info
466  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
467  bunchCrossingList.push_back(bunchIdx);
468  for (size_t readSrcIdx = 0; readSrcIdx < maxNbSources_; ++readSrcIdx) {
469  if (oldFormatPlayback) {
470  std::vector<edm::EventID> const& playEventID =
471  oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
472  size_t numberOfEvents = playEventID.size();
473  if (readSrcIdx == 0) {
474  PileupList.push_back(numberOfEvents);
475  TrueNumInteractions_.push_back(numberOfEvents);
476  numInteractionList.push_back(numberOfEvents);
477  TrueInteractionList.push_back(numberOfEvents);
478  }
479  } else {
480  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
481  if (readSrcIdx == 0) {
482  PileupList.push_back(numberOfEvents);
483  TrueNumInteractions_.push_back(numberOfEvents);
484  numInteractionList.push_back(numberOfEvents);
485  TrueInteractionList.push_back(numberOfEvents);
486  }
487  }
488  }
489  }
490  }
491 
492  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
493  accItr != accEnd;
494  ++accItr) {
495  (*accItr)->StorePileupInformation(
496  bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList, bunchSpace_);
497  }
498 
499  // for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
500  // std::cout << " bunch ID, Pileup, True " << bunchIdx << " " << PileupList[bunchIdx-minBunch_] << " " << TrueNumInteractions_[bunchIdx-minBunch_] << std::endl;
501  //}
502 
503  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
504  for (size_t setBcrIdx = 0; setBcrIdx < workers_.size(); ++setBcrIdx) {
505  workers_[setBcrIdx]->setBcrOffset();
506  }
507  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
508  accItr != accEnd;
509  ++accItr) {
510  (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
511  }
512 
513  for (size_t readSrcIdx = 0; readSrcIdx < maxNbSources_; ++readSrcIdx) {
514  std::shared_ptr<PileUp> source = inputSources_[readSrcIdx]; // this looks like we create
515  // new PileUp objects for each
516  // source for each event?
517  // Why?
518  for (size_t setSrcIdx = 0; setSrcIdx < workers_.size(); ++setSrcIdx) {
519  workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
520  }
521 
522  if (!source || !source->doPileUp(bunchIdx)) {
523  sizes.push_back(0U);
524  if (playback_ && !oldFormatPlayback) {
525  playbackCounter += playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
526  }
527  continue;
528  }
529 
530  // int eventId = 0;
531  int vertexOffset = 0;
532 
533  ModuleCallingContext const* mcc = e.moduleCallingContext();
534  if (!playback_) {
535  // non-minbias pileup only gets one event for now. Fix later if desired.
536  int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx - minBunch_] : 1);
537  sizes.push_back(numberOfEvents);
538  inputSources_[readSrcIdx]->readPileUp(e.id(),
539  recordEventID,
540  std::bind(&MixingModule::pileAllWorkers,
541  std::ref(*this),
542  _1,
543  mcc,
544  bunchIdx,
545  _2,
546  vertexOffset,
547  std::ref(setup),
548  e.streamID()),
549  numberOfEvents,
550  e.streamID());
551  } else if (oldFormatPlayback) {
552  std::vector<edm::EventID> const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
553  size_t numberOfEvents = playEventID.size();
554  if (readSrcIdx == 0) {
555  PileupList.push_back(numberOfEvents);
556  TrueNumInteractions_.push_back(numberOfEvents);
557  }
558  sizes.push_back(numberOfEvents);
559  std::vector<EventID>::const_iterator begin = playEventID.begin();
560  std::vector<EventID>::const_iterator end = playEventID.end();
561  inputSources_[readSrcIdx]->playOldFormatPileUp(begin,
562  end,
563  recordEventID,
564  std::bind(&MixingModule::pileAllWorkers,
565  std::ref(*this),
566  _1,
567  mcc,
568  bunchIdx,
569  _2,
570  vertexOffset,
571  std::ref(setup),
572  e.streamID()));
573  } else {
574  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
575  if (readSrcIdx == 0) {
576  PileupList.push_back(numberOfEvents);
577  TrueNumInteractions_.push_back(numberOfEvents);
578  }
579  sizes.push_back(numberOfEvents);
580  std::vector<SecondaryEventIDAndFileInfo>::const_iterator begin = playbackInfo_H->getEventId(playbackCounter);
581  playbackCounter += numberOfEvents;
582  std::vector<SecondaryEventIDAndFileInfo>::const_iterator end = playbackInfo_H->getEventId(playbackCounter);
583  inputSources_[readSrcIdx]->playPileUp(begin,
584  end,
585  recordEventID,
586  std::bind(&MixingModule::pileAllWorkers,
587  std::ref(*this),
588  _1,
589  mcc,
590  bunchIdx,
591  _2,
592  vertexOffset,
593  std::ref(setup),
594  e.streamID()));
595  }
596  }
597  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
598  accItr != accEnd;
599  ++accItr) {
600  (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
601  }
602  }
603 
604  // Save playback information
605  for (auto const item : recordEventID) {
606  eventInfoList.emplace_back(item.eventID());
607  }
608 
609  // setInfo swaps recordEventID, so recordEventID is useless (empty) after the call.
610  playbackInfo_->setInfo(recordEventID, sizes);
611 
612  // Keep track of pileup accounting...
613 
614  std::unique_ptr<PileupMixingContent> PileupMixing_;
615 
616  PileupMixing_ = std::make_unique<PileupMixingContent>(
617  bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList, bunchSpace_);
618 
619  e.put(std::move(PileupMixing_));
620 
621  // we have to do the ToF transformation for PSimHits once all pileup has been added
622  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
623  workers_[ii]->setTof();
624  workers_[ii]->put(e);
625  }
626  }
627 
629  if (playbackInfo_) {
630  std::unique_ptr<CrossingFramePlaybackInfoNew> pOut(playbackInfo_);
631  e.put(std::move(pOut));
632  }
633  }
634 
636  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
637  accItr != accEnd;
638  ++accItr) {
639  (*accItr)->beginRun(run, setup);
640  }
642  }
643 
645  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
646  accItr != accEnd;
647  ++accItr) {
648  (*accItr)->endRun(run, setup);
649  }
651  }
652 
654  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
655  accItr != accEnd;
656  ++accItr) {
657  (*accItr)->beginLuminosityBlock(lumi, setup);
658  }
660  }
661 
663  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
664  accItr != accEnd;
665  ++accItr) {
666  (*accItr)->endLuminosityBlock(lumi, setup);
667  }
669  }
670 
672  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
673  accItr != accEnd;
674  ++accItr) {
675  (*accItr)->initializeEvent(event, setup);
676  }
677  }
678 
680  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
681  accItr != accEnd;
682  ++accItr) {
683  (*accItr)->accumulate(event, setup);
684  }
685  }
686 
688  edm::EventSetup const& setup,
689  edm::StreamID const& streamID) {
690  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
691  accItr != accEnd;
692  ++accItr) {
693  (*accItr)->accumulate(event, setup, streamID);
694  }
695  }
696 
698  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
699  accItr != accEnd;
700  ++accItr) {
701  (*accItr)->finalizeEvent(event, setup);
702  }
703  }
704 } // namespace edm
edm::BMixingModule::endRun
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
Definition: BMixingModule.cc:258
edm::BMixingModule::inputSources_
std::vector< std::shared_ptr< PileUp > > inputSources_
Definition: BMixingModule.h:108
edm::StreamID
Definition: StreamID.h:30
CrossingFramePlaybackInfoNew::getEventId
std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator getEventId(size_t offset) const
Definition: CrossingFramePlaybackInfoNew.h:41
edm::BMixingModule::endLuminosityBlock
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
Definition: BMixingModule.cc:251
edm::source
static const std::string source("source")
edm::BMixingModule::bunchSpace_
int bunchSpace_
Definition: BMixingModule.h:91
Handle.h
ModuleCallingContext.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
MixingRcd
Definition: MixingRcd.h:24
mps_fire.i
i
Definition: mps_fire.py:428
edm::BMixingModule::minBunch_
int minBunch_
Definition: BMixingModule.h:94
MessageLogger.h
CrossingFramePlaybackInfoNew.h
ESHandle.h
edm::sort_all
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
edm::ModuleContextSentry
Definition: ModuleContextSentry.h:11
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
TriggerNamesService.h
edm::Run
Definition: Run.h:45
MixingModuleConfig.h
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:174
edm::MixingModule::reload
void reload(const edm::EventSetup &) override
Definition: MixingModule.cc:290
edm
HLT enums.
Definition: AlignableModifier.h:19
fireworks::subdets
static const std::string subdets[7]
Definition: TrackUtils.cc:60
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::BMixingModule::maxBunch_
int maxBunch_
Definition: BMixingModule.h:95
Algorithms.h
TypeID.h
L1TrackObjectNtupleMaker_cfg.pOut
pOut
Definition: L1TrackObjectNtupleMaker_cfg.py:172
edm::ClonePolicy
Definition: ClonePolicy.h:6
CrossingFramePlaybackInfoExtended::getStartEventId
std::vector< edm::EventID > getStartEventId(const unsigned int s, const int bcr) const
Definition: CrossingFramePlaybackInfoExtended.h:31
PileUpEventPrincipal
Definition: PileUpEventPrincipal.h:19
edm::BMixingModule::TrueNumInteractions_
std::vector< float > TrueNumInteractions_
Definition: BMixingModule.h:103
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::MixingModule::doPileUp
void doPileUp(edm::Event &e, const edm::EventSetup &es) override
Definition: MixingModule.cc:402
edm::Handle
Definition: AssociativeIterator.h:50
edm::EventPrincipal::id
EventID const & id() const
Definition: EventPrincipal.h:96
edm::BMixingModule
Definition: BMixingModule.h:40
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::MixingWorker
Definition: MixingWorker.h:40
edm::MixingModule::playbackInfo_
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:101
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
edm::MixingModule::wrapLongTimes_
bool wrapLongTimes_
Definition: MixingModule.h:109
edm::MixingModule::createnewEDProduct
void createnewEDProduct() override
Definition: MixingModule.cc:335
edm::BMixingModule::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
Definition: BMixingModule.cc:235
edm::MixingModule::endRun
void endRun(Run const &r1, EventSetup const &c) override
Definition: MixingModule.cc:644
edm::MixingModule::endLuminosityBlock
void endLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
Definition: MixingModule.cc:662
CrossingFramePlaybackInfoNew
Definition: CrossingFramePlaybackInfoNew.h:22
CrossingFramePlaybackInfoExtended.h
edm::MixingModule::mixProdStep2_
bool mixProdStep2_
Definition: MixingModule.h:99
EDMException.h
config
Definition: config.py:1
edm::MixingModule::initializeEvent
void initializeEvent(Event const &event, EventSetup const &setup) override
Definition: MixingModule.cc:671
edm::EventPrincipal
Definition: EventPrincipal.h:48
edm::MixingModule::MixingModule
MixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
Definition: MixingModule.cc:41
MixingModule.h
edm::MixingModule::checkSignal
void checkSignal(const edm::Event &e) override
Definition: MixingModule.cc:318
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
edm::BMixingModule::maxNbSources_
const static unsigned int maxNbSources_
Definition: BMixingModule.h:101
DigiAccumulatorMixMod.h
Service.h
edm::MixingModule::wantedBranches_
std::vector< std::string > wantedBranches_
Definition: MixingModule.h:107
submitPVResolutionJobs.config
config
parse the configuration file
Definition: submitPVResolutionJobs.py:281
edm::BMixingModule::playback_
bool playback_
Definition: BMixingModule.h:100
mps_fire.end
end
Definition: mps_fire.py:242
Provenance.h
edm::ESHandle
Definition: DTSurvey.h:22
edm::MixingModule::inputTagPlayback_
InputTag inputTagPlayback_
Definition: MixingModule.h:98
PileUpEventPrincipal.h
edm::InternalContext
Definition: InternalContext.h:23
edm::binary_search_all
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:58
edm::MixingModule::createDigiAccumulators
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
Definition: MixingModule.cc:273
edm::MixingModule::workersObjects_
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:106
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::MixingModule::branchesActivate
virtual void branchesActivate(const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label)
Definition: MixingModule.cc:304
edm::ParentContext
Definition: ParentContext.h:27
edm::MixingModule::useCurrentProcessOnly_
bool useCurrentProcessOnly_
Definition: MixingModule.h:108
edm::MixingModule::skipSignal_
bool skipSignal_
Definition: MixingModule.h:110
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
BranchDescription.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
edm::MixingCache::Config
Definition: BMixingModule.h:29
edm::friendlyname::friendlyName
std::string friendlyName(std::string const &iFullName)
Definition: FriendlyName.cc:278
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:679
edm::ParameterSet::getParameterNames
std::vector< std::string > getParameterNames() const
Definition: ParameterSet.cc:663
edm::MixingModule::adjusters_
std::vector< AdjusterBase * > adjusters_
Definition: MixingModule.h:103
edm::Service
Definition: Service.h:30
DigiHGCalTB160_cff.crossingFrames
crossingFrames
Definition: DigiHGCalTB160_cff.py:7
genPUProtons_cfi.bunchCrossingList
bunchCrossingList
Definition: genPUProtons_cfi.py:5
edm::BMixingModule::dropUnwantedBranches
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
Definition: BMixingModule.cc:307
InternalContext.h
edm::MixingModule::put
void put(edm::Event &e, const edm::EventSetup &es) override
Definition: MixingModule.cc:628
CrossingFramePlaybackInfoNew::setInfo
void setInfo(std::vector< edm::SecondaryEventIDAndFileInfo > &eventInfo, std::vector< size_t > &sizes)
Definition: CrossingFramePlaybackInfoNew.h:35
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::EventSetup
Definition: EventSetup.h:58
edm::Adjuster
Definition: Adjuster.h:39
edm::MixingModule::accumulateEvent
void accumulateEvent(Event const &event, EventSetup const &setup)
Definition: MixingModule.cc:679
edm::MixingModule::~MixingModule
~MixingModule() override
Definition: MixingModule.cc:345
edm::MixingModule::workers_
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:105
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::MixingModule::beginRun
void beginRun(Run const &r1, EventSetup const &c) override
Definition: MixingModule.cc:635
DigiHGCalTB160_cff.makeCrossingFrame
makeCrossingFrame
Definition: DigiHGCalTB160_cff.py:24
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
TrackingRecHit
Definition: TrackingRecHit.h:21
ValueMap.h
edm::MixingModule::pileAllWorkers
bool pileAllWorkers(EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
Definition: MixingModule.cc:373
edm::MixingModule::mixProdStep1_
bool mixProdStep1_
Definition: MixingModule.h:100
mixOne_premix_on_sim_cfi.accumulator
accumulator
Definition: mixOne_premix_on_sim_cfi.py:167
ParentContext.h
edm::TypeID
Definition: TypeID.h:22
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::MixingModule::addSignals
void addSignals(const edm::Event &e, const edm::EventSetup &es) override
Definition: MixingModule.cc:359
edm::MixingModule::adjustersObjects_
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:104
edm::MixingModule::digiAccumulators_
Accumulators digiAccumulators_
Definition: MixingModule.h:113
Exception
Definition: hltDiff.cc:245
edm::MixingModule::finalizeEvent
void finalizeEvent(Event &event, EventSetup const &setup) override
Definition: MixingModule.cc:697
EventSetup.h
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MixingWorker.h
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
edm::InputTag::kSkipCurrentProcess
static const std::string kSkipCurrentProcess
Definition: InputTag.h:53
ConsumesCollector.h
DigiAccumulatorMixModFactory.h
edm::HepMCProduct
Definition: HepMCProduct.h:21
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
CrossingFramePlaybackInfoNew::getNumberOfEvents
size_t getNumberOfEvents(int bunchIdx, size_t sourceNumber) const
Definition: CrossingFramePlaybackInfoNew.h:47
lumi
Definition: LumiSectionData.h:20
mixObjects_cfi.pcrossingFrames
pcrossingFrames
Definition: mixObjects_cfi.py:50
ModuleContextSentry.h
edm::MixingModule::beginLuminosityBlock
void beginLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
Definition: MixingModule.cc:653
cuy.ii
ii
Definition: cuy.py:589
edm::BMixingModule::beginRun
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
Definition: BMixingModule.cc:243
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::OwnVector
Definition: OwnVector.h:24
edm::DigiAccumulatorMixModFactory::get
static DigiAccumulatorMixModFactory const * get()
Definition: DigiAccumulatorMixModFactory.cc:18
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
Adjuster.h