CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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>());
186  sort_all(crossingFrames);
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>());
213  sort_all(crossingFrames);
214  std::vector<std::string> pcrossingFrames =
215  pset.getUntrackedParameter<std::vector<std::string> >("pcrossingFrames", std::vector<std::string>());
216  sort_all(pcrossingFrames);
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  if (globalConf->configFromDB_) {
270  configToken_ = esConsumes<edm::Transition::BeginLuminosityBlock>();
271  }
272  // Create and configure digitizers
273  createDigiAccumulators(ps_mix, iC);
274  }
275 
277  ParameterSet const& digiPSet = mixingPSet.getParameterSet("digitizers");
278  std::vector<std::string> digiNames = digiPSet.getParameterNames();
279  for (auto const& digiName : digiNames) {
280  ParameterSet const& pset = digiPSet.getParameterSet(digiName);
281  if (pset.existsAs<edm::InputTag>("HepMCProductLabel")) {
282  consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("HepMCProductLabel"));
283  }
284  std::unique_ptr<DigiAccumulatorMixMod> accumulator = std::unique_ptr<DigiAccumulatorMixMod>(
285  DigiAccumulatorMixModFactory::get()->makeDigiAccumulator(pset, producesCollector(), iC));
286  // Create appropriate DigiAccumulator
287  if (accumulator.get() != nullptr) {
288  digiAccumulators_.push_back(accumulator.release());
289  }
290  }
291  }
292 
294  //change the basic parameters.
295  auto const& config = setup.getData(configToken_);
296  minBunch_ = config.minBunch();
297  maxBunch_ = config.maxBunch();
298  bunchSpace_ = config.bunchSpace();
299  //propagate to change the workers
300  for (unsigned int ii = 0; ii < workersObjects_.size(); ++ii) {
302  }
303  }
304 
306  const std::string& subdet,
307  InputTag& tag,
308  std::string& label) {
309  label = tag.label() + tag.instance();
310  wantedBranches_.push_back(friendlyName + '_' + tag.label() + '_' + tag.instance());
311 
312  //if useCurrentProcessOnly, we have to change the input tag
315  tag = InputTag(tag.label(), tag.instance(), processName);
316  }
317  }
318 
320  if (adjusters_.empty()) {
321  for (auto const& adjuster : adjustersObjects_) {
322  if (skipSignal_ or adjuster->checkSignal(e)) {
323  adjusters_.push_back(adjuster);
324  }
325  }
326  }
327  if (workers_.empty()) {
328  for (auto const& worker : workersObjects_) {
329  if (skipSignal_ or worker->checkSignal(e)) {
330  workers_.push_back(worker);
331  }
332  }
333  }
334  }
335 
337  //create playback info
339  //and CrossingFrames
340  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
341  workers_[ii]->createnewEDProduct();
342  }
343  }
344 
345  // Virtual destructor needed.
347  for (auto& worker : workersObjects_) {
348  delete worker;
349  }
350 
351  for (auto& adjuster : adjustersObjects_) {
352  delete adjuster;
353  }
354 
355  for (auto& digiAccumulator : digiAccumulators_) {
356  delete digiAccumulator;
357  }
358  }
359 
361  if (skipSignal_) {
362  return;
363  }
364 
365  LogDebug("MixingModule") << "===============> adding signals for " << e.id();
366 
367  accumulateEvent(e, setup);
368  // fill in signal part of CrossingFrame
369  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
370  workers_[ii]->addSignals(e);
371  }
372  }
373 
374  bool MixingModule::pileAllWorkers(EventPrincipal const& eventPrincipal,
375  ModuleCallingContext const* mcc,
376  int bunchCrossing,
377  int eventId,
378  int& vertexOffset,
379  const edm::EventSetup& setup,
380  StreamID const& streamID) {
381  InternalContext internalContext(eventPrincipal.id(), mcc);
382  ParentContext parentContext(&internalContext);
383  ModuleCallingContext moduleCallingContext(&moduleDescription());
384  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
385 
386  for (auto const& adjuster : adjusters_) {
387  adjuster->doOffset(bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
388  }
389  PileUpEventPrincipal pep(eventPrincipal, &moduleCallingContext, bunchCrossing);
390 
391  accumulateEvent(pep, setup, streamID);
392 
393  for (auto const& worker : workers_) {
394  LogDebug("MixingModule") << " merging Event: id " << eventPrincipal.id();
395  // std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl;
396 
397  worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
398  }
399 
400  return true;
401  }
402 
404  using namespace std::placeholders;
405 
406  // Don't allocate because PileUp will do it for us.
407  std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
408  std::vector<size_t> sizes;
409  sizes.reserve(maxNbSources_ * (maxBunch_ + 1 - minBunch_));
410  size_t playbackCounter = 0U;
412  edm::Handle<CrossingFramePlaybackInfoExtended> oldFormatPlaybackInfo_H;
413  bool oldFormatPlayback = false;
414  if (playback_) {
415  bool got = e.getByLabel(inputTagPlayback_, playbackInfo_H);
416  if (!got) {
417  bool gotOld = e.getByLabel(inputTagPlayback_, oldFormatPlaybackInfo_H);
418  if (!gotOld) {
419  throw cms::Exception("MixingProductNotFound")
420  << " No "
421  "CrossingFramePlaybackInfoNew on the input file, but playback "
422  "option set!!!!! Please change the input file if you really want "
423  "playback!!!!!!"
424  << std::endl;
425  }
426  oldFormatPlayback = true;
427  }
428  }
429 
430  // source[0] is "real" pileup. Check to see that this is what we are doing.
431 
432  std::vector<int> PileupList;
433  PileupList.clear();
434  TrueNumInteractions_.clear();
435 
436  std::shared_ptr<PileUp> source0 = inputSources_[0];
437 
438  if ((source0 && source0->doPileUp(0)) && !playback_) {
439  // if((!inputSources_[0] || !inputSources_[0]->doPileUp()) && !playback_ )
440 
441  // Pre-calculate all pileup distributions before we go fishing for events
442 
443  source0->CalculatePileup(minBunch_, maxBunch_, PileupList, TrueNumInteractions_, e.streamID());
444  }
445 
446  // pre-populate Pileup information
447  // necessary for luminosity-dependent effects during hit accumulation
448 
449  std::vector<int> numInteractionList;
450  std::vector<int> bunchCrossingList;
451  std::vector<float> TrueInteractionList;
452  std::vector<edm::EventID> eventInfoList; // will be empty if we pre-populate, but it's not used in digitizers
453 
454  if (!playback_) {
455  //Makin' a list: Basically, we don't care about the "other" sources at this point.
456  for (int bunchCrossing = minBunch_; bunchCrossing <= maxBunch_; ++bunchCrossing) {
457  bunchCrossingList.push_back(bunchCrossing);
458  if (!inputSources_[0] || !inputSources_[0]->doPileUp(0)) {
459  numInteractionList.push_back(0);
460  TrueInteractionList.push_back(0);
461  } else {
462  numInteractionList.push_back(PileupList[bunchCrossing - minBunch_]);
463  TrueInteractionList.push_back((TrueNumInteractions_)[bunchCrossing - minBunch_]);
464  }
465  }
466  } else { // have to read PU information from playback info
467  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
468  bunchCrossingList.push_back(bunchIdx);
469  for (size_t readSrcIdx = 0; readSrcIdx < maxNbSources_; ++readSrcIdx) {
470  if (oldFormatPlayback) {
471  std::vector<edm::EventID> const& playEventID =
472  oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
473  size_t numberOfEvents = playEventID.size();
474  if (readSrcIdx == 0) {
475  PileupList.push_back(numberOfEvents);
476  TrueNumInteractions_.push_back(numberOfEvents);
477  numInteractionList.push_back(numberOfEvents);
478  TrueInteractionList.push_back(numberOfEvents);
479  }
480  } else {
481  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
482  if (readSrcIdx == 0) {
483  PileupList.push_back(numberOfEvents);
484  TrueNumInteractions_.push_back(numberOfEvents);
485  numInteractionList.push_back(numberOfEvents);
486  TrueInteractionList.push_back(numberOfEvents);
487  }
488  }
489  }
490  }
491  }
492 
493  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
494  accItr != accEnd;
495  ++accItr) {
496  (*accItr)->StorePileupInformation(
497  bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList, bunchSpace_);
498  }
499 
500  // for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
501  // std::cout << " bunch ID, Pileup, True " << bunchIdx << " " << PileupList[bunchIdx-minBunch_] << " " << TrueNumInteractions_[bunchIdx-minBunch_] << std::endl;
502  //}
503 
504  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
505  for (size_t setBcrIdx = 0; setBcrIdx < workers_.size(); ++setBcrIdx) {
506  workers_[setBcrIdx]->setBcrOffset();
507  }
508  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
509  accItr != accEnd;
510  ++accItr) {
511  (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
512  }
513 
514  for (size_t readSrcIdx = 0; readSrcIdx < maxNbSources_; ++readSrcIdx) {
515  std::shared_ptr<PileUp> source = inputSources_[readSrcIdx]; // this looks like we create
516  // new PileUp objects for each
517  // source for each event?
518  // Why?
519  for (size_t setSrcIdx = 0; setSrcIdx < workers_.size(); ++setSrcIdx) {
520  workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
521  }
522 
523  if (!source || !source->doPileUp(bunchIdx)) {
524  sizes.push_back(0U);
525  if (playback_ && !oldFormatPlayback) {
526  playbackCounter += playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
527  }
528  continue;
529  }
530 
531  // int eventId = 0;
532  int vertexOffset = 0;
533 
535  if (!playback_) {
536  // non-minbias pileup only gets one event for now. Fix later if desired.
537  int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx - minBunch_] : 1);
538  sizes.push_back(numberOfEvents);
539  inputSources_[readSrcIdx]->readPileUp(e.id(),
540  recordEventID,
541  std::bind(&MixingModule::pileAllWorkers,
542  std::ref(*this),
543  _1,
544  mcc,
545  bunchIdx,
546  _2,
547  vertexOffset,
548  std::ref(setup),
549  e.streamID()),
550  numberOfEvents,
551  e.streamID());
552  } else if (oldFormatPlayback) {
553  std::vector<edm::EventID> const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
554  size_t numberOfEvents = playEventID.size();
555  if (readSrcIdx == 0) {
556  PileupList.push_back(numberOfEvents);
557  TrueNumInteractions_.push_back(numberOfEvents);
558  }
559  sizes.push_back(numberOfEvents);
560  std::vector<EventID>::const_iterator begin = playEventID.begin();
561  std::vector<EventID>::const_iterator end = playEventID.end();
562  inputSources_[readSrcIdx]->playOldFormatPileUp(begin,
563  end,
564  recordEventID,
565  std::bind(&MixingModule::pileAllWorkers,
566  std::ref(*this),
567  _1,
568  mcc,
569  bunchIdx,
570  _2,
571  vertexOffset,
572  std::ref(setup),
573  e.streamID()));
574  } else {
575  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
576  if (readSrcIdx == 0) {
577  PileupList.push_back(numberOfEvents);
578  TrueNumInteractions_.push_back(numberOfEvents);
579  }
580  sizes.push_back(numberOfEvents);
581  std::vector<SecondaryEventIDAndFileInfo>::const_iterator begin = playbackInfo_H->getEventId(playbackCounter);
582  playbackCounter += numberOfEvents;
583  std::vector<SecondaryEventIDAndFileInfo>::const_iterator end = playbackInfo_H->getEventId(playbackCounter);
584  inputSources_[readSrcIdx]->playPileUp(begin,
585  end,
586  recordEventID,
587  std::bind(&MixingModule::pileAllWorkers,
588  std::ref(*this),
589  _1,
590  mcc,
591  bunchIdx,
592  _2,
593  vertexOffset,
594  std::ref(setup),
595  e.streamID()));
596  }
597  }
598  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
599  accItr != accEnd;
600  ++accItr) {
601  (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
602  }
603  }
604 
605  // Save playback information
606  for (auto const item : recordEventID) {
607  eventInfoList.emplace_back(item.eventID());
608  }
609 
610  // setInfo swaps recordEventID, so recordEventID is useless (empty) after the call.
611  playbackInfo_->setInfo(recordEventID, sizes);
612 
613  // Keep track of pileup accounting...
614 
615  std::unique_ptr<PileupMixingContent> PileupMixing_;
616 
617  PileupMixing_ = std::make_unique<PileupMixingContent>(
618  bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList, bunchSpace_);
619 
620  e.put(std::move(PileupMixing_));
621 
622  // we have to do the ToF transformation for PSimHits once all pileup has been added
623  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
624  workers_[ii]->setTof();
625  workers_[ii]->put(e);
626  }
627  }
628 
630  if (playbackInfo_) {
631  std::unique_ptr<CrossingFramePlaybackInfoNew> pOut(playbackInfo_);
632  e.put(std::move(pOut));
633  }
634  }
635 
637  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
638  accItr != accEnd;
639  ++accItr) {
640  (*accItr)->beginRun(run, setup);
641  }
642  BMixingModule::beginRun(run, setup);
643  }
644 
646  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
647  accItr != accEnd;
648  ++accItr) {
649  (*accItr)->endRun(run, setup);
650  }
651  BMixingModule::endRun(run, setup);
652  }
653 
655  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
656  accItr != accEnd;
657  ++accItr) {
658  (*accItr)->beginLuminosityBlock(lumi, setup);
659  }
661  }
662 
664  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
665  accItr != accEnd;
666  ++accItr) {
667  (*accItr)->endLuminosityBlock(lumi, setup);
668  }
670  }
671 
673  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
674  accItr != accEnd;
675  ++accItr) {
676  (*accItr)->initializeEvent(event, setup);
677  }
678  }
679 
681  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
682  accItr != accEnd;
683  ++accItr) {
684  (*accItr)->accumulate(event, setup);
685  }
686  }
687 
689  edm::EventSetup const& setup,
690  edm::StreamID const& streamID) {
691  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
692  accItr != accEnd;
693  ++accItr) {
694  (*accItr)->accumulate(event, setup, streamID);
695  }
696  }
697 
699  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
700  accItr != accEnd;
701  ++accItr) {
702  (*accItr)->finalizeEvent(event, setup);
703  }
704  }
705 } // namespace edm
void setInfo(std::vector< edm::SecondaryEventIDAndFileInfo > &eventInfo, std::vector< size_t > &sizes)
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:133
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
static std::string const source("source")
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::ESGetToken< MixingModuleConfig, MixingRcd > configToken_
Definition: MixingModule.h:103
~MixingModule() override
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
EventID const & id() const
bool exists(std::string const &parameterName) const
checks if a parameter exists
void addSignals(const edm::Event &e, const edm::EventSetup &es) override
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:105
int ii
Definition: cuy.py:589
std::vector< AdjusterBase * > adjusters_
Definition: MixingModule.h:104
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
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:106
bool getData(T &iHolder) const
Definition: EventSetup.h:122
char const * label
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:253
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::unique_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, ProducesCollector, ConsumesCollector &) const
Accumulators digiAccumulators_
Definition: MixingModule.h:114
void initializeEvent(Event const &event, EventSetup const &setup) override
def move
Definition: eostools.py:511
static const std::string kSkipCurrentProcess
Definition: InputTag.h:53
MixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
Definition: MixingModule.cc:41
static const unsigned int maxNbSources_
std::vector< std::string > names
std::vector< float > TrueNumInteractions_
void beginRun(Run const &r1, EventSetup const &c) override
std::vector< std::string > getParameterNames() const
list lumi
Definition: dqmdumpme.py:53
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:101
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
virtual void branchesActivate(const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label)
Log< level::Info, false > LogInfo
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
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< std::string > wantedBranches_
Definition: MixingModule.h:108
InputTag inputTagPlayback_
Definition: MixingModule.h:98
std::string const & label() const
Definition: InputTag.h:36
tuple config
parse the configuration file
edm::EventID id() const
Definition: EventBase.h:59
void accumulateEvent(Event const &event, EventSetup const &setup)
void createnewEDProduct() override
std::vector< std::shared_ptr< PileUp > > inputSources_
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:107
string end
Definition: dataset.py:937
StreamID streamID() const
Definition: Event.h:98
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
Log< level::Warning, false > LogWarning
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
Definition: Run.h:45
#define LogDebug(id)
void endRun(Run const &r1, EventSetup const &c) override