CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::MixingModule Class Reference

#include <MixingModule.h>

Inheritance diagram for edm::MixingModule:
edm::BMixingModule edm::stream::EDProducer< GlobalCache< MixingCache::Config > >

Public Types

typedef std::vector< DigiAccumulatorMixMod * > Accumulators
 
- Public Types inherited from edm::stream::EDProducer< GlobalCache< MixingCache::Config > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

void accumulateEvent (Event const &event, EventSetup const &setup)
 
void accumulateEvent (PileUpEventPrincipal const &event, EventSetup const &setup, edm::StreamID const &)
 
virtual void beginJob ()
 
void beginLuminosityBlock (LuminosityBlock const &l1, EventSetup const &c) override
 
void beginRun (Run const &r1, EventSetup const &c) override
 
void endLuminosityBlock (LuminosityBlock const &l1, EventSetup const &c) override
 
void endRun (Run const &r1, EventSetup const &c) override
 
void finalizeEvent (Event &event, EventSetup const &setup) override
 
void initializeEvent (Event const &event, EventSetup const &setup) override
 
 MixingModule (const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
 
void reload (const edm::EventSetup &) override
 
 ~MixingModule () override
 
- Public Member Functions inherited from edm::BMixingModule
virtual void addPileups (const int bcr, EventPrincipal *ep, unsigned int eventId, unsigned int worker, const edm::EventSetup &c)
 
double averageNumber () const
 
void beginLuminosityBlock (const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
 
void beginRun (const edm::Run &r, const edm::EventSetup &setup) override
 
 BMixingModule (const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
 
void endLuminosityBlock (const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
 
void endRun (const edm::Run &r, const edm::EventSetup &setup) override
 
virtual void finalizeEvent (edm::Event &event, const edm::EventSetup &setup)
 
virtual void initializeEvent (const edm::Event &event, const edm::EventSetup &setup)
 
bool poisson () const
 
void produce (edm::Event &e1, const edm::EventSetup &c) override
 
virtual void setBcrOffset ()
 
virtual void setSourceOffset (const unsigned int s)
 
 ~BMixingModule () override
 
- Public Member Functions inherited from edm::stream::EDProducer< GlobalCache< MixingCache::Config > >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void addSignals (const edm::Event &e, const edm::EventSetup &es) override
 
virtual void branchesActivate (const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label)
 
void checkSignal (const edm::Event &e) override
 
void createDigiAccumulators (const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
 
void createnewEDProduct () override
 
void doPileUp (edm::Event &e, const edm::EventSetup &es) override
 
bool pileAllWorkers (EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
 
void put (edm::Event &e, const edm::EventSetup &es) override
 

Private Attributes

std::vector< AdjusterBase * > adjusters_
 
std::vector< AdjusterBase * > adjustersObjects_
 
Accumulators digiAccumulators_
 
InputTag inputTagPlayback_
 
bool mixProdStep1_
 
bool mixProdStep2_
 
CrossingFramePlaybackInfoNewplaybackInfo_
 
bool useCurrentProcessOnly_
 
std::vector< std::string > wantedBranches_
 
std::vector< MixingWorkerBase * > workers_
 
std::vector< MixingWorkerBase * > workersObjects_
 
bool wrapLongTimes_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::BMixingModule
static void globalEndJob (MixingCache::Config *)
 
static std::unique_ptr< MixingCache::ConfiginitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Member Functions inherited from edm::BMixingModule
void beginStream (edm::StreamID) override
 
void dropUnwantedBranches (std::vector< std::string > const &wantedBranches)
 
void endStream () override
 
void setupPileUpEvent (const edm::EventSetup &setup)
 
void update (edm::EventSetup const &)
 
- Protected Attributes inherited from edm::BMixingModule
int bunchSpace_
 
bool checktof_
 
bool doit_ [4]
 
unsigned int eventId_
 
std::vector< std::shared_ptr< PileUp > > inputSources_
 
int maxBunch_
 
int minBunch_
 
bool const mixProdStep1_
 
bool const mixProdStep2_
 
edm::ESWatcher< MixingRcdparameterWatcher_
 
bool playback_
 
bool readDB_
 
std::vector< float > TrueNumInteractions_
 
int vertexOffset_
 
- Static Protected Attributes inherited from edm::BMixingModule
static const unsigned int maxNbSources_ = 4
 

Detailed Description

Definition at line 49 of file MixingModule.h.

Member Typedef Documentation

Definition at line 51 of file MixingModule.h.

Constructor & Destructor Documentation

MixingModule::MixingModule ( const edm::ParameterSet ps,
MixingCache::Config const *  globalConf 
)
explicit

standard constructor

Definition at line 41 of file MixingModule.cc.

References adjustersObjects_, edm::binary_search_all(), MicroEventContent_cff::branch, branchesActivate(), edm::BMixingModule::bunchSpace_, createDigiAccumulators(), DigiHGCalTB160_cff::crossingFrames, edm::BMixingModule::dropUnwantedBranches(), edm::InputTag::encode(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, cuy::ii, HLT_2018_cff::InputTag, inputTagPlayback_, edm::InputTag::instance(), edm::InputTag::kSkipCurrentProcess, label, LogDebug, DigiHGCalTB160_cff::makeCrossingFrame, edm::BMixingModule::maxBunch_, edm::BMixingModule::maxNbSources_, edm::BMixingModule::minBunch_, mixProdStep1_, mixProdStep2_, names, mixObjects_cfi::pcrossingFrames, edm::BMixingModule::playback_, muonDTDigis_cfi::pset, edm::sort_all(), AlCaHLTBitMon_QueryRunRegistry::string, fireworks::subdets, GlobalPosition_Frontier_DevDB_cff::tag, triggerMatcherToHLTDebug_cfi::tags, useCurrentProcessOnly_, wantedBranches_, workersObjects_, and wrapLongTimes_.

42  : BMixingModule(ps_mix, globalConf),
44  mixProdStep2_(ps_mix.getParameter<bool>("mixProdStep2")),
45  mixProdStep1_(ps_mix.getParameter<bool>("mixProdStep1")),
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  ParameterSet ps = ps_mix.getParameter<ParameterSet>("mixObjects");
76  std::vector<std::string> names = ps.getParameterNames();
77  for (std::vector<std::string>::iterator it = names.begin(); it != names.end(); ++it) {
78  ParameterSet pset = ps.getParameter<ParameterSet>((*it));
79  if (!pset.exists("type"))
80  continue; //to allow replacement by empty pset
81  std::string object = pset.getParameter<std::string>("type");
82  std::vector<InputTag> tags = pset.getParameter<std::vector<InputTag> >("input");
83 
84  //if (!mixProdStep2_) {
85 
86  InputTag tagCF = InputTag();
87  std::string labelCF = " ";
88 
89  if (object == "SimTrack") {
90  InputTag tag;
91  if (!tags.empty())
92  tag = tags[0];
94 
95  branchesActivate(TypeID(typeid(std::vector<SimTrack>)).friendlyClassName(), std::string(""), tag, label);
96  adjustersObjects_.push_back(new Adjuster<std::vector<SimTrack> >(tag, consumesCollector(), wrapLongTimes_));
97  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
98  if (makeCrossingFrame) {
100  minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF));
101  produces<CrossingFrame<SimTrack> >(label);
102  }
103  consumes<std::vector<SimTrack> >(tag);
104 
105  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
106  << label;
107  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
108 
109  } else if (object == "RecoTrack") {
110  InputTag tag;
111  if (!tags.empty())
112  tag = tags[0];
114 
115  branchesActivate(TypeID(typeid(std::vector<reco::Track>)).friendlyClassName(), std::string(""), tag, label);
117  TypeID(typeid(std::vector<reco::TrackExtra>)).friendlyClassName(), std::string(""), tag, label);
119  TypeID(typeid(edm::OwnVector<TrackingRecHit, edm::ClonePolicy<TrackingRecHit> >)).friendlyClassName(),
120  std::string(""),
121  tag,
122  label);
123  adjustersObjects_.push_back(
124  new Adjuster<edm::OwnVector<TrackingRecHit> >(tag, consumesCollector(), wrapLongTimes_));
125  // note: no crossing frame is foreseen to be used for this object type
126 
127  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
128  << label;
129  //std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
130 
131  } else if (object == "SimVertex") {
132  InputTag tag;
133  if (!tags.empty())
134  tag = tags[0];
136 
137  branchesActivate(TypeID(typeid(std::vector<SimVertex>)).friendlyClassName(), std::string(""), tag, label);
138  adjustersObjects_.push_back(new Adjuster<std::vector<SimVertex> >(tag, consumesCollector(), wrapLongTimes_));
139  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
140  if (makeCrossingFrame) {
142  minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF));
143  produces<CrossingFrame<SimVertex> >(label);
144  }
145  consumes<std::vector<SimVertex> >(tag);
146 
147  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag " << tag.encode() << ", label will be "
148  << label;
149  // std::cout <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label<<std::endl;
150 
151  } else if (object == "HepMCProduct") {
152  InputTag tag;
153  if (!tags.empty())
154  tag = tags[0];
156 
157  branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(), std::string(""), tag, label);
158  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
159  if (makeCrossingFrame) {
161  minBunch_, maxBunch_, bunchSpace_, std::string(""), label, labelCF, maxNbSources_, tag, tagCF, tags));
162  produces<CrossingFrame<HepMCProduct> >(label);
163  }
164  consumes<HepMCProduct>(tag);
165 
166  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
167  << label;
168  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
169  for (size_t i = 1; i < tags.size(); ++i) {
170  InputTag fallbackTag = tags[i];
171  std::string fallbackLabel;
173  TypeID(typeid(HepMCProduct)).friendlyClassName(), std::string(""), fallbackTag, fallbackLabel);
174  mayConsume<HepMCProduct>(fallbackTag);
175  }
176 
177  } else if (object == "PCaloHit") {
178  std::vector<std::string> subdets = pset.getParameter<std::vector<std::string> >("subdets");
179  std::vector<std::string> crossingFrames =
180  pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
182  for (unsigned int ii = 0; ii < subdets.size(); ++ii) {
183  InputTag tag;
184  if (tags.size() == 1)
185  tag = tags[0];
186  else if (tags.size() > 1)
187  tag = tags[ii];
189 
190  branchesActivate(TypeID(typeid(std::vector<PCaloHit>)).friendlyClassName(), subdets[ii], tag, label);
191  adjustersObjects_.push_back(new Adjuster<std::vector<PCaloHit> >(tag, consumesCollector(), wrapLongTimes_));
192  if (binary_search_all(crossingFrames, tag.instance())) {
194  minBunch_, maxBunch_, bunchSpace_, subdets[ii], label, labelCF, maxNbSources_, tag, tagCF));
195  produces<CrossingFrame<PCaloHit> >(label);
196  consumes<std::vector<PCaloHit> >(tag);
197  }
198 
199  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
200  << label;
201  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
202  }
203 
204  } else if (object == "PSimHit") {
205  std::vector<std::string> subdets = pset.getParameter<std::vector<std::string> >("subdets");
206  std::vector<std::string> crossingFrames =
207  pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
209  std::vector<std::string> pcrossingFrames =
210  pset.getUntrackedParameter<std::vector<std::string> >("pcrossingFrames", std::vector<std::string>());
212  for (unsigned int ii = 0; ii < subdets.size(); ++ii) {
213  InputTag tag;
214  if (tags.size() == 1)
215  tag = tags[0];
216  else if (tags.size() > 1)
217  tag = tags[ii];
219 
220  branchesActivate(TypeID(typeid(std::vector<PSimHit>)).friendlyClassName(), subdets[ii], tag, label);
221  adjustersObjects_.push_back(new Adjuster<std::vector<PSimHit> >(tag, consumesCollector(), wrapLongTimes_));
222  if (binary_search_all(crossingFrames, tag.instance())) {
223  bool makePCrossingFrame = binary_search_all(pcrossingFrames, tag.instance());
225  maxBunch_,
226  bunchSpace_,
227  subdets[ii],
228  label,
229  labelCF,
231  tag,
232  tagCF,
233  makePCrossingFrame));
234  produces<CrossingFrame<PSimHit> >(label);
235  if (makePCrossingFrame) {
236  produces<PCrossingFrame<PSimHit> >(label);
237  }
238  consumes<std::vector<PSimHit> >(tag);
239  }
240 
241  LogInfo("MixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
242  << label;
243  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
244  }
245  } else {
246  LogWarning("MixingModule")
247  << "You have asked to mix an unknown type of object(" << object
248  << ").\n If you want to include it in mixing, please contact the authors of the MixingModule!";
249  }
250  //} //if for mixProdStep2
251  } //while over the mixObjects parameters
252 
254  for (unsigned int branch = 0; branch < wantedBranches_.size(); ++branch)
255  LogDebug("MixingModule") << "Will keep branch " << wantedBranches_[branch] << " for mixing ";
256 
258 
259  produces<PileupMixingContent>();
260 
261  produces<CrossingFramePlaybackInfoNew>();
262 
263  edm::ConsumesCollector iC(consumesCollector());
264  // Create and configure digitizers
265  createDigiAccumulators(ps_mix, iC);
266  }
#define LogDebug(id)
T getParameter(std::string const &) const
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:104
const std::string names[nVars_]
char const * label
Accumulators digiAccumulators_
Definition: MixingModule.h:112
static const std::string kSkipCurrentProcess
Definition: InputTag.h:53
static const unsigned int maxNbSources_
ii
Definition: cuy.py:590
virtual void branchesActivate(const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
std::vector< std::string > wantedBranches_
Definition: MixingModule.h:107
InputTag inputTagPlayback_
Definition: MixingModule.h:98
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:106
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)
static const std::string subdets[7]
Definition: TrackUtils.cc:60
BMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
MixingModule::~MixingModule ( )
override

Default destructor

Definition at line 339 of file MixingModule.cc.

References adjustersObjects_, digiAccumulators_, and workersObjects_.

339  {
340  for (auto& worker : workersObjects_) {
341  delete worker;
342  }
343 
344  for (auto& adjuster : adjustersObjects_) {
345  delete adjuster;
346  }
347 
348  for (auto& digiAccumulator : digiAccumulators_) {
349  delete digiAccumulator;
350  }
351  }
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:104
Accumulators digiAccumulators_
Definition: MixingModule.h:112
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:106

Member Function Documentation

void MixingModule::accumulateEvent ( edm::Event const &  event,
edm::EventSetup const &  setup 
)

Definition at line 669 of file MixingModule.cc.

References digiAccumulators_.

Referenced by addSignals(), beginJob(), and pileAllWorkers().

669  {
670  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
671  accItr != accEnd;
672  ++accItr) {
673  (*accItr)->accumulate(event, setup);
674  }
675  }
Accumulators digiAccumulators_
Definition: MixingModule.h:112
Definition: event.py:1
void MixingModule::accumulateEvent ( PileUpEventPrincipal const &  event,
edm::EventSetup const &  setup,
edm::StreamID const &  streamID 
)

Definition at line 677 of file MixingModule.cc.

References digiAccumulators_.

679  {
680  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
681  accItr != accEnd;
682  ++accItr) {
683  (*accItr)->accumulate(event, setup, streamID);
684  }
685  }
Accumulators digiAccumulators_
Definition: MixingModule.h:112
Definition: event.py:1
void MixingModule::addSignals ( const edm::Event e,
const edm::EventSetup es 
)
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 353 of file MixingModule.cc.

References accumulateEvent(), edm::EventBase::id(), cuy::ii, LogDebug, and workers_.

Referenced by beginJob().

353  {
354  LogDebug("MixingModule") << "===============> adding signals for " << e.id();
355 
357  // fill in signal part of CrossingFrame
358  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
359  workers_[ii]->addSignals(e);
360  }
361  }
#define LogDebug(id)
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:105
ii
Definition: cuy.py:590
edm::EventID id() const
Definition: EventBase.h:59
void accumulateEvent(Event const &event, EventSetup const &setup)
virtual void edm::MixingModule::beginJob ( void  )
inlinevirtual
void MixingModule::beginLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  setup 
)
override

Definition at line 643 of file MixingModule.cc.

References edm::BMixingModule::beginLuminosityBlock(), and digiAccumulators_.

Referenced by beginJob().

643  {
644  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
645  accItr != accEnd;
646  ++accItr) {
647  (*accItr)->beginLuminosityBlock(lumi, setup);
648  }
650  }
Accumulators digiAccumulators_
Definition: MixingModule.h:112
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void MixingModule::beginRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
)
override

Definition at line 625 of file MixingModule.cc.

References edm::BMixingModule::beginRun(), and digiAccumulators_.

Referenced by beginJob().

625  {
626  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
627  accItr != accEnd;
628  ++accItr) {
629  (*accItr)->beginRun(run, setup);
630  }
632  }
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
Accumulators digiAccumulators_
Definition: MixingModule.h:112
void MixingModule::branchesActivate ( const std::string &  friendlyName,
const std::string &  subdet,
InputTag tag,
std::string &  label 
)
privatevirtual

Definition at line 298 of file MixingModule.cc.

References EgammaHLTValidationUtils::getProcessName(), HLT_2018_cff::InputTag, edm::InputTag::instance(), edm::InputTag::label(), SimL1EmulatorRepack_CalouGT_cff::processName, AlCaHLTBitMon_QueryRunRegistry::string, useCurrentProcessOnly_, and wantedBranches_.

Referenced by beginJob(), and MixingModule().

301  {
302  label = tag.label() + tag.instance();
303  wantedBranches_.push_back(friendlyName + '_' + tag.label() + '_' + tag.instance());
304 
305  //if useCurrentProcessOnly, we have to change the input tag
308  tag = InputTag(tag.label(), tag.instance(), processName);
309  }
310  }
char const * label
std::string friendlyName(std::string const &iFullName)
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
std::vector< std::string > wantedBranches_
Definition: MixingModule.h:107
void MixingModule::checkSignal ( const edm::Event e)
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 312 of file MixingModule.cc.

References adjusters_, adjustersObjects_, workers_, and workersObjects_.

Referenced by beginJob().

312  {
313  if (adjusters_.empty()) {
314  for (auto const& adjuster : adjustersObjects_) {
315  if (adjuster->checkSignal(e)) {
316  adjusters_.push_back(adjuster);
317  }
318  }
319  }
320  if (workers_.empty()) {
321  for (auto const& worker : workersObjects_) {
322  if (worker->checkSignal(e)) {
323  workers_.push_back(worker);
324  }
325  }
326  }
327  }
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:104
std::vector< AdjusterBase * > adjusters_
Definition: MixingModule.h:103
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:105
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:106
void MixingModule::createDigiAccumulators ( const edm::ParameterSet mixingPSet,
edm::ConsumesCollector iC 
)
private

Definition at line 268 of file MixingModule.cc.

References mixOne_premix_on_sim_cfi::accumulator, digiAccumulators_, edm::ParameterSet::existsAs(), edm::DigiAccumulatorMixModFactory::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::ParameterSet::getParameterSet(), edm::DigiAccumulatorMixModFactory::makeDigiAccumulator(), and muonDTDigis_cfi::pset.

Referenced by beginJob(), and MixingModule().

268  {
269  ParameterSet const& digiPSet = mixingPSet.getParameterSet("digitizers");
270  std::vector<std::string> digiNames = digiPSet.getParameterNames();
271  for (auto const& digiName : digiNames) {
272  ParameterSet const& pset = digiPSet.getParameterSet(digiName);
273  if (pset.existsAs<edm::InputTag>("HepMCProductLabel")) {
274  consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("HepMCProductLabel"));
275  }
276  std::unique_ptr<DigiAccumulatorMixMod> accumulator = std::unique_ptr<DigiAccumulatorMixMod>(
277  DigiAccumulatorMixModFactory::get()->makeDigiAccumulator(pset, producesCollector(), iC));
278  // Create appropriate DigiAccumulator
279  if (accumulator.get() != nullptr) {
280  digiAccumulators_.push_back(accumulator.release());
281  }
282  }
283  }
std::unique_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, ProducesCollector, ConsumesCollector &) const
Accumulators digiAccumulators_
Definition: MixingModule.h:112
ParameterSet const & getParameterSet(std::string const &) const
static DigiAccumulatorMixModFactory const * get()
void MixingModule::createnewEDProduct ( )
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 329 of file MixingModule.cc.

References cuy::ii, edm::BMixingModule::maxBunch_, edm::BMixingModule::maxNbSources_, edm::BMixingModule::minBunch_, playbackInfo_, and workers_.

Referenced by beginJob().

329  {
330  //create playback info
332  //and CrossingFrames
333  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
334  workers_[ii]->createnewEDProduct();
335  }
336  }
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:105
static const unsigned int maxNbSources_
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:101
ii
Definition: cuy.py:590
void MixingModule::doPileUp ( edm::Event e,
const edm::EventSetup es 
)
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 392 of file MixingModule.cc.

References begin, genPUProtons_cfi::bunchCrossingList, edm::BMixingModule::bunchSpace_, digiAccumulators_, end, Exception, edm::Event::getByLabel(), CrossingFramePlaybackInfoNew::getEventId(), CrossingFramePlaybackInfoNew::getNumberOfEvents(), CrossingFramePlaybackInfoExtended::getStartEventId(), edm::EventBase::id(), cuy::ii, edm::BMixingModule::inputSources_, inputTagPlayback_, B2GTnPMonitor_cfi::item, edm::BMixingModule::maxBunch_, edm::BMixingModule::maxNbSources_, edm::BMixingModule::minBunch_, edm::Event::moduleCallingContext(), eostools::move(), pileAllWorkers(), edm::BMixingModule::playback_, playbackInfo_, edm::Event::put(), CrossingFramePlaybackInfoNew::setInfo(), edm::source(), edm::Event::streamID(), edm::BMixingModule::TrueNumInteractions_, mitigatedMETSequence_cff::U, and workers_.

Referenced by beginJob().

392  {
393  using namespace std::placeholders;
394 
395  // Don't allocate because PileUp will do it for us.
396  std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
397  std::vector<size_t> sizes;
398  sizes.reserve(maxNbSources_ * (maxBunch_ + 1 - minBunch_));
399  size_t playbackCounter = 0U;
401  edm::Handle<CrossingFramePlaybackInfoExtended> oldFormatPlaybackInfo_H;
402  bool oldFormatPlayback = false;
403  if (playback_) {
404  bool got = e.getByLabel(inputTagPlayback_, playbackInfo_H);
405  if (!got) {
406  bool gotOld = e.getByLabel(inputTagPlayback_, oldFormatPlaybackInfo_H);
407  if (!gotOld) {
408  throw cms::Exception("MixingProductNotFound")
409  << " No "
410  "CrossingFramePlaybackInfoNew on the input file, but playback "
411  "option set!!!!! Please change the input file if you really want "
412  "playback!!!!!!"
413  << std::endl;
414  }
415  oldFormatPlayback = true;
416  }
417  }
418 
419  // source[0] is "real" pileup. Check to see that this is what we are doing.
420 
421  std::vector<int> PileupList;
422  PileupList.clear();
423  TrueNumInteractions_.clear();
424 
425  std::shared_ptr<PileUp> source0 = inputSources_[0];
426 
427  if ((source0 && source0->doPileUp(0)) && !playback_) {
428  // if((!inputSources_[0] || !inputSources_[0]->doPileUp()) && !playback_ )
429 
430  // Pre-calculate all pileup distributions before we go fishing for events
431 
432  source0->CalculatePileup(minBunch_, maxBunch_, PileupList, TrueNumInteractions_, e.streamID());
433  }
434 
435  // pre-populate Pileup information
436  // necessary for luminosity-dependent effects during hit accumulation
437 
438  std::vector<int> numInteractionList;
439  std::vector<int> bunchCrossingList;
440  std::vector<float> TrueInteractionList;
441  std::vector<edm::EventID> eventInfoList; // will be empty if we pre-populate, but it's not used in digitizers
442 
443  if (!playback_) {
444  //Makin' a list: Basically, we don't care about the "other" sources at this point.
445  for (int bunchCrossing = minBunch_; bunchCrossing <= maxBunch_; ++bunchCrossing) {
446  bunchCrossingList.push_back(bunchCrossing);
447  if (!inputSources_[0] || !inputSources_[0]->doPileUp(0)) {
448  numInteractionList.push_back(0);
449  TrueInteractionList.push_back(0);
450  } else {
451  numInteractionList.push_back(PileupList[bunchCrossing - minBunch_]);
452  TrueInteractionList.push_back((TrueNumInteractions_)[bunchCrossing - minBunch_]);
453  }
454  }
455  } else { // have to read PU information from playback info
456  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
457  bunchCrossingList.push_back(bunchIdx);
458  for (size_t readSrcIdx = 0; readSrcIdx < maxNbSources_; ++readSrcIdx) {
459  if (oldFormatPlayback) {
460  std::vector<edm::EventID> const& playEventID =
461  oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
462  size_t numberOfEvents = playEventID.size();
463  if (readSrcIdx == 0) {
464  PileupList.push_back(numberOfEvents);
465  TrueNumInteractions_.push_back(numberOfEvents);
466  numInteractionList.push_back(numberOfEvents);
467  TrueInteractionList.push_back(numberOfEvents);
468  }
469  } else {
470  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
471  if (readSrcIdx == 0) {
472  PileupList.push_back(numberOfEvents);
473  TrueNumInteractions_.push_back(numberOfEvents);
474  numInteractionList.push_back(numberOfEvents);
475  TrueInteractionList.push_back(numberOfEvents);
476  }
477  }
478  }
479  }
480  }
481 
482  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
483  accItr != accEnd;
484  ++accItr) {
485  (*accItr)->StorePileupInformation(
486  bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList, bunchSpace_);
487  }
488 
489  // for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
490  // std::cout << " bunch ID, Pileup, True " << bunchIdx << " " << PileupList[bunchIdx-minBunch_] << " " << TrueNumInteractions_[bunchIdx-minBunch_] << std::endl;
491  //}
492 
493  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
494  for (size_t setBcrIdx = 0; setBcrIdx < workers_.size(); ++setBcrIdx) {
495  workers_[setBcrIdx]->setBcrOffset();
496  }
497  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
498  accItr != accEnd;
499  ++accItr) {
500  (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
501  }
502 
503  for (size_t readSrcIdx = 0; readSrcIdx < maxNbSources_; ++readSrcIdx) {
504  std::shared_ptr<PileUp> source = inputSources_[readSrcIdx]; // this looks like we create
505  // new PileUp objects for each
506  // source for each event?
507  // Why?
508  for (size_t setSrcIdx = 0; setSrcIdx < workers_.size(); ++setSrcIdx) {
509  workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
510  }
511 
512  if (!source || !source->doPileUp(bunchIdx)) {
513  sizes.push_back(0U);
514  if (playback_ && !oldFormatPlayback) {
515  playbackCounter += playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
516  }
517  continue;
518  }
519 
520  // int eventId = 0;
521  int vertexOffset = 0;
522 
523  ModuleCallingContext const* mcc = e.moduleCallingContext();
524  if (!playback_) {
525  // non-minbias pileup only gets one event for now. Fix later if desired.
526  int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx - minBunch_] : 1);
527  sizes.push_back(numberOfEvents);
528  inputSources_[readSrcIdx]->readPileUp(e.id(),
529  recordEventID,
530  std::bind(&MixingModule::pileAllWorkers,
531  std::ref(*this),
532  _1,
533  mcc,
534  bunchIdx,
535  _2,
536  vertexOffset,
537  std::ref(setup),
538  e.streamID()),
539  numberOfEvents,
540  e.streamID());
541  } else if (oldFormatPlayback) {
542  std::vector<edm::EventID> const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
543  size_t numberOfEvents = playEventID.size();
544  if (readSrcIdx == 0) {
545  PileupList.push_back(numberOfEvents);
546  TrueNumInteractions_.push_back(numberOfEvents);
547  }
548  sizes.push_back(numberOfEvents);
549  std::vector<EventID>::const_iterator begin = playEventID.begin();
550  std::vector<EventID>::const_iterator end = playEventID.end();
551  inputSources_[readSrcIdx]->playOldFormatPileUp(begin,
552  end,
553  recordEventID,
554  std::bind(&MixingModule::pileAllWorkers,
555  std::ref(*this),
556  _1,
557  mcc,
558  bunchIdx,
559  _2,
560  vertexOffset,
561  std::ref(setup),
562  e.streamID()));
563  } else {
564  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
565  if (readSrcIdx == 0) {
566  PileupList.push_back(numberOfEvents);
567  TrueNumInteractions_.push_back(numberOfEvents);
568  }
569  sizes.push_back(numberOfEvents);
570  std::vector<SecondaryEventIDAndFileInfo>::const_iterator begin = playbackInfo_H->getEventId(playbackCounter);
571  playbackCounter += numberOfEvents;
572  std::vector<SecondaryEventIDAndFileInfo>::const_iterator end = playbackInfo_H->getEventId(playbackCounter);
573  inputSources_[readSrcIdx]->playPileUp(begin,
574  end,
575  recordEventID,
576  std::bind(&MixingModule::pileAllWorkers,
577  std::ref(*this),
578  _1,
579  mcc,
580  bunchIdx,
581  _2,
582  vertexOffset,
583  std::ref(setup),
584  e.streamID()));
585  }
586  }
587  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
588  accItr != accEnd;
589  ++accItr) {
590  (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
591  }
592  }
593 
594  // Save playback information
595  for (auto const item : recordEventID) {
596  eventInfoList.emplace_back(item.eventID());
597  }
598 
599  // setInfo swaps recordEventID, so recordEventID is useless (empty) after the call.
600  playbackInfo_->setInfo(recordEventID, sizes);
601 
602  // Keep track of pileup accounting...
603 
604  std::unique_ptr<PileupMixingContent> PileupMixing_;
605 
606  PileupMixing_ = std::unique_ptr<PileupMixingContent>(new PileupMixingContent(
607  bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList, bunchSpace_));
608 
609  e.put(std::move(PileupMixing_));
610 
611  // we have to do the ToF transformation for PSimHits once all pileup has been added
612  for (unsigned int ii = 0; ii < workers_.size(); ++ii) {
613  workers_[ii]->setTof();
614  workers_[ii]->put(e);
615  }
616  }
void setInfo(std::vector< edm::SecondaryEventIDAndFileInfo > &eventInfo, std::vector< size_t > &sizes)
std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator getEventId(size_t offset) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
static std::string const source("source")
std::vector< edm::EventID > getStartEventId(const unsigned int s, const int bcr) const
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:105
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:247
Accumulators digiAccumulators_
Definition: MixingModule.h:112
size_t getNumberOfEvents(int bunchIdx, size_t sourceNumber) const
static const unsigned int maxNbSources_
#define end
Definition: vmac.h:39
std::vector< float > TrueNumInteractions_
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:101
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:488
ii
Definition: cuy.py:590
bool pileAllWorkers(EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
InputTag inputTagPlayback_
Definition: MixingModule.h:98
edm::EventID id() const
Definition: EventBase.h:59
#define begin
Definition: vmac.h:32
std::vector< std::shared_ptr< PileUp > > inputSources_
StreamID streamID() const
Definition: Event.h:96
void doPileUp(edm::Event &e, const edm::EventSetup &es) override
def move(src, dest)
Definition: eostools.py:511
void MixingModule::endLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  setup 
)
override

Definition at line 652 of file MixingModule.cc.

References digiAccumulators_, and edm::BMixingModule::endLuminosityBlock().

Referenced by beginJob().

652  {
653  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
654  accItr != accEnd;
655  ++accItr) {
656  (*accItr)->endLuminosityBlock(lumi, setup);
657  }
659  }
Accumulators digiAccumulators_
Definition: MixingModule.h:112
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void MixingModule::endRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
)
override

Definition at line 634 of file MixingModule.cc.

References digiAccumulators_, and edm::BMixingModule::endRun().

Referenced by beginJob().

634  {
635  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
636  accItr != accEnd;
637  ++accItr) {
638  (*accItr)->endRun(run, setup);
639  }
641  }
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
Accumulators digiAccumulators_
Definition: MixingModule.h:112
void MixingModule::finalizeEvent ( edm::Event event,
edm::EventSetup const &  setup 
)
override

Definition at line 687 of file MixingModule.cc.

References digiAccumulators_.

Referenced by beginJob().

687  {
688  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
689  accItr != accEnd;
690  ++accItr) {
691  (*accItr)->finalizeEvent(event, setup);
692  }
693  }
Accumulators digiAccumulators_
Definition: MixingModule.h:112
void MixingModule::initializeEvent ( edm::Event const &  event,
edm::EventSetup const &  setup 
)
override

Definition at line 661 of file MixingModule.cc.

References digiAccumulators_.

Referenced by beginJob().

661  {
662  for (Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end();
663  accItr != accEnd;
664  ++accItr) {
665  (*accItr)->initializeEvent(event, setup);
666  }
667  }
Accumulators digiAccumulators_
Definition: MixingModule.h:112
Definition: event.py:1
bool MixingModule::pileAllWorkers ( EventPrincipal const &  ep,
ModuleCallingContext const *  mcc,
int  bcr,
int  id,
int &  offset,
const edm::EventSetup setup,
edm::StreamID const &  streamID 
)
private

Definition at line 363 of file MixingModule.cc.

References accumulateEvent(), adjusters_, edm::BMixingModule::bunchSpace_, edm::EventPrincipal::id(), LogDebug, and workers_.

Referenced by beginJob(), and doPileUp().

369  {
370  InternalContext internalContext(eventPrincipal.id(), mcc);
371  ParentContext parentContext(&internalContext);
372  ModuleCallingContext moduleCallingContext(&moduleDescription());
373  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
374 
375  for (auto const& adjuster : adjusters_) {
376  adjuster->doOffset(bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
377  }
378  PileUpEventPrincipal pep(eventPrincipal, &moduleCallingContext, bunchCrossing);
379 
380  accumulateEvent(pep, setup, streamID);
381 
382  for (auto const& worker : workers_) {
383  LogDebug("MixingModule") << " merging Event: id " << eventPrincipal.id();
384  // std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl;
385 
386  worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
387  }
388 
389  return true;
390  }
#define LogDebug(id)
std::vector< AdjusterBase * > adjusters_
Definition: MixingModule.h:103
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:105
void accumulateEvent(Event const &event, EventSetup const &setup)
void MixingModule::put ( edm::Event e,
const edm::EventSetup es 
)
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 618 of file MixingModule.cc.

References eostools::move(), playbackInfo_, and edm::Event::put().

Referenced by beginJob().

618  {
619  if (playbackInfo_) {
620  std::unique_ptr<CrossingFramePlaybackInfoNew> pOut(playbackInfo_);
621  e.put(std::move(pOut));
622  }
623  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:101
def move(src, dest)
Definition: eostools.py:511
void MixingModule::reload ( const edm::EventSetup setup)
overridevirtual

Reimplemented from edm::BMixingModule.

Definition at line 285 of file MixingModule.cc.

References MixingModuleConfig::bunchSpace(), edm::BMixingModule::bunchSpace_, looper::config, edm::EventSetup::get(), cuy::ii, MixingModuleConfig::maxBunch(), edm::BMixingModule::maxBunch_, MixingModuleConfig::minBunch(), edm::BMixingModule::minBunch_, and workersObjects_.

Referenced by beginJob().

285  {
286  //change the basic parameters.
288  setup.get<MixingRcd>().get(config);
289  minBunch_ = config->minBunch();
290  maxBunch_ = config->maxBunch();
291  bunchSpace_ = config->bunchSpace();
292  //propagate to change the workers
293  for (unsigned int ii = 0; ii < workersObjects_.size(); ++ii) {
294  workersObjects_[ii]->reload(setup);
295  }
296  }
const int & bunchSpace() const
const int & maxBunch() const
config
Definition: looper.py:291
ii
Definition: cuy.py:590
T get() const
Definition: EventSetup.h:73
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:106
const int & minBunch() const

Member Data Documentation

std::vector<AdjusterBase*> edm::MixingModule::adjusters_
private

Definition at line 103 of file MixingModule.h.

Referenced by checkSignal(), and pileAllWorkers().

std::vector<AdjusterBase*> edm::MixingModule::adjustersObjects_
private

Definition at line 104 of file MixingModule.h.

Referenced by checkSignal(), MixingModule(), and ~MixingModule().

Accumulators edm::MixingModule::digiAccumulators_
private
InputTag edm::MixingModule::inputTagPlayback_
private

Definition at line 98 of file MixingModule.h.

Referenced by doPileUp(), and MixingModule().

bool edm::MixingModule::mixProdStep1_
private

Definition at line 100 of file MixingModule.h.

Referenced by MixingModule().

bool edm::MixingModule::mixProdStep2_
private

Definition at line 99 of file MixingModule.h.

Referenced by MixingModule().

CrossingFramePlaybackInfoNew* edm::MixingModule::playbackInfo_
private

Definition at line 101 of file MixingModule.h.

Referenced by createnewEDProduct(), doPileUp(), and put().

bool edm::MixingModule::useCurrentProcessOnly_
private

Definition at line 108 of file MixingModule.h.

Referenced by branchesActivate(), and MixingModule().

std::vector<std::string> edm::MixingModule::wantedBranches_
private

Definition at line 107 of file MixingModule.h.

Referenced by branchesActivate(), and MixingModule().

std::vector<MixingWorkerBase*> edm::MixingModule::workers_
private

Definition at line 105 of file MixingModule.h.

Referenced by addSignals(), checkSignal(), createnewEDProduct(), doPileUp(), and pileAllWorkers().

std::vector<MixingWorkerBase*> edm::MixingModule::workersObjects_
private

Definition at line 106 of file MixingModule.h.

Referenced by checkSignal(), MixingModule(), reload(), and ~MixingModule().

bool edm::MixingModule::wrapLongTimes_
private

Definition at line 109 of file MixingModule.h.

Referenced by MixingModule().