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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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
 
void 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, inputTagPlayback_, edm::InputTag::instance(), edm::InputTag::kSkipCurrentProcess, diffTwoXMLs::label, LogDebug, DigiHGCalTB160_cff::makeCrossingFrame, edm::BMixingModule::maxBunch_, edm::BMixingModule::maxNbSources_, edm::BMixingModule::minBunch_, mixProdStep1_, mixProdStep2_, cscdqm::h::names, edm::BMixingModule::playback_, muonDTDigis_cfi::pset, edm::sort_all(), AlCaHLTBitMon_QueryRunRegistry::string, fireworks::subdets, GlobalPosition_Frontier_DevDB_cff::tag, useCurrentProcessOnly_, wantedBranches_, workersObjects_, and wrapLongTimes_.

41  :
42  BMixingModule(ps_mix, globalConf),
44  mixProdStep2_(ps_mix.getParameter<bool>("mixProdStep2")),
45  mixProdStep1_(ps_mix.getParameter<bool>("mixProdStep1")),
47  {
48  if (!mixProdStep1_ && !mixProdStep2_) LogInfo("MixingModule") << " The MixingModule was run in the Standard mode.";
49  if (mixProdStep1_) LogInfo("MixingModule") << " The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
50  if (mixProdStep2_) LogInfo("MixingModule") << " The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
51 
53  if (ps_mix.exists("useCurrentProcessOnly")) {
54  useCurrentProcessOnly_=ps_mix.getParameter<bool>("useCurrentProcessOnly");
55  LogInfo("MixingModule") <<" using given Parameter 'useCurrentProcessOnly' ="<<useCurrentProcessOnly_;
56  }
57  std::string labelPlayback;
58  if (ps_mix.exists("LabelPlayback")) {
59  labelPlayback = ps_mix.getParameter<std::string>("LabelPlayback");
60  }
61  if (labelPlayback.empty()) {
62  labelPlayback = ps_mix.getParameter<std::string>("@module_label");
63  }
64  if (playback_) {
65  inputTagPlayback_ = InputTag(labelPlayback, "", edm::InputTag::kSkipCurrentProcess);
66  consumes<CrossingFramePlaybackInfoNew>(inputTagPlayback_);
67  }
68  wrapLongTimes_ = false;
69  if (ps_mix.exists("WrapLongTimes")) {
70  wrapLongTimes_ = ps_mix.getParameter<bool>("WrapLongTimes");
71  }
72 
73 
74  ParameterSet ps=ps_mix.getParameter<ParameterSet>("mixObjects");
75  std::vector<std::string> names = ps.getParameterNames();
76  for(std::vector<std::string>::iterator it=names.begin();it!= names.end();++it) {
77  ParameterSet pset=ps.getParameter<ParameterSet>((*it));
78  if (!pset.exists("type")) continue; //to allow replacement by empty pset
79  std::string object = pset.getParameter<std::string>("type");
80  std::vector<InputTag> tags=pset.getParameter<std::vector<InputTag> >("input");
81 
82  //if (!mixProdStep2_) {
83 
84  InputTag tagCF = InputTag();
85  std::string labelCF = " ";
86 
87  if (object=="SimTrack") {
88  InputTag tag;
89  if (!tags.empty()) tag=tags[0];
91 
92  branchesActivate(TypeID(typeid(std::vector<SimTrack>)).friendlyClassName(),std::string(""),tag,label);
93  adjustersObjects_.push_back(new Adjuster<std::vector<SimTrack> >(tag, consumesCollector(),wrapLongTimes_));
94  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
95  if(makeCrossingFrame) {
97  produces<CrossingFrame<SimTrack> >(label);
98  }
99  consumes<std::vector<SimTrack> >(tag);
100 
101  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
102  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
103 
104  } else if (object=="RecoTrack") {
105  InputTag tag;
106  if (!tags.empty()) tag=tags[0];
108 
109  branchesActivate(TypeID(typeid(std::vector<reco::Track>)).friendlyClassName(),std::string(""),tag,label);
110  branchesActivate(TypeID(typeid(std::vector<reco::TrackExtra>)).friendlyClassName(),std::string(""),tag,label);
111  branchesActivate(TypeID(typeid(edm::OwnVector<TrackingRecHit,edm::ClonePolicy<TrackingRecHit> >)).friendlyClassName(),std::string(""),tag,label);
112  adjustersObjects_.push_back(new Adjuster<edm::OwnVector<TrackingRecHit> >(tag, consumesCollector(),wrapLongTimes_));
113  // note: no crossing frame is foreseen to be used for this object type
114 
115  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
116  //std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
117 
118  } else if (object=="SimVertex") {
119  InputTag tag;
120  if (!tags.empty()) tag=tags[0];
122 
123  branchesActivate(TypeID(typeid(std::vector<SimVertex>)).friendlyClassName(),std::string(""),tag,label);
124  adjustersObjects_.push_back(new Adjuster<std::vector<SimVertex> >(tag, consumesCollector(),wrapLongTimes_));
125  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
126  if(makeCrossingFrame) {
128  produces<CrossingFrame<SimVertex> >(label);
129  }
130  consumes<std::vector<SimVertex> >(tag);
131 
132  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label;
133  // std::cout <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label<<std::endl;
134 
135  } else if (object=="HepMCProduct") {
136  InputTag tag;
137  if (!tags.empty()) tag=tags[0];
139 
140  branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(),std::string(""),tag,label);
141  bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false);
142  if(makeCrossingFrame) {
143  workersObjects_.push_back(new MixingWorker<HepMCProduct>(minBunch_,maxBunch_,bunchSpace_,std::string(""),label,labelCF,maxNbSources_,tag,tagCF,tags));
144  produces<CrossingFrame<HepMCProduct> >(label);
145  }
146  consumes<HepMCProduct>(tag);
147 
148  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
149  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
150  for(size_t i = 1; i < tags.size(); ++i) {
151  InputTag fallbackTag = tags[i];
152  std::string fallbackLabel;
153  branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(),std::string(""),fallbackTag,fallbackLabel);
154  mayConsume<HepMCProduct>(fallbackTag);
155  }
156 
157  } else if (object=="PCaloHit") {
158  std::vector<std::string> subdets=pset.getParameter<std::vector<std::string> >("subdets");
159  std::vector<std::string> crossingFrames=pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
161  for (unsigned int ii=0;ii<subdets.size();++ii) {
162  InputTag tag;
163  if (tags.size()==1) tag=tags[0];
164  else if(tags.size()>1) tag=tags[ii];
166 
167  branchesActivate(TypeID(typeid(std::vector<PCaloHit>)).friendlyClassName(),subdets[ii],tag,label);
168  adjustersObjects_.push_back(new Adjuster<std::vector<PCaloHit> >(tag, consumesCollector(),wrapLongTimes_));
169  if(binary_search_all(crossingFrames, tag.instance())) {
171  produces<CrossingFrame<PCaloHit> >(label);
172  consumes<std::vector<PCaloHit> >(tag);
173  }
174 
175  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
176  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
177 
178  }
179 
180  } else if (object=="PSimHit") {
181  std::vector<std::string> subdets=pset.getParameter<std::vector<std::string> >("subdets");
182  std::vector<std::string> crossingFrames=pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>());
184  for (unsigned int ii=0;ii<subdets.size();++ii) {
185  InputTag tag;
186  if (tags.size()==1) tag=tags[0];
187  else if(tags.size()>1) tag=tags[ii];
189 
190  branchesActivate(TypeID(typeid(std::vector<PSimHit>)).friendlyClassName(),subdets[ii],tag,label);
191  adjustersObjects_.push_back(new Adjuster<std::vector<PSimHit> >(tag, consumesCollector(),wrapLongTimes_));
192  if(binary_search_all(crossingFrames, tag.instance())) {
194  produces<CrossingFrame<PSimHit> >(label);
195  consumes<std::vector<PSimHit> >(tag);
196  }
197 
198  LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label;
199  // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl;
200  }
201  } else {
202  LogWarning("MixingModule") <<"You have asked to mix an unknown type of object("<<object<<").\n If you want to include it in mixing, please contact the authors of the MixingModule!";
203  }
204  //} //if for mixProdStep2
205  }//while over the mixObjects parameters
206 
208  for (unsigned int branch=0;branch<wantedBranches_.size();++branch) LogDebug("MixingModule")<<"Will keep branch "<<wantedBranches_[branch]<<" for mixing ";
209 
211 
212  produces<PileupMixingContent>();
213 
214  produces<CrossingFramePlaybackInfoNew>();
215 
216  edm::ConsumesCollector iC(consumesCollector());
217  // Create and configure digitizers
218  createDigiAccumulators(ps_mix, iC);
219  }
#define LogDebug(id)
T getParameter(std::string const &) const
static const HistoName names[]
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
Accumulators digiAccumulators_
Definition: MixingModule.h:104
static const std::string kSkipCurrentProcess
Definition: InputTag.h:50
static const unsigned int maxNbSources_
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:98
ii
Definition: cuy.py:588
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:120
std::vector< std::string > wantedBranches_
Definition: MixingModule.h:99
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:96
InputTag inputTagPlayback_
Definition: MixingModule.h:90
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:76
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 292 of file MixingModule.cc.

References adjustersObjects_, digiAccumulators_, and workersObjects_.

292  {
293  for (auto& worker : workersObjects_) {
294  delete worker;
295  }
296 
297  for (auto& adjuster : adjustersObjects_) {
298  delete adjuster;
299  }
300 
301  for (auto& digiAccumulator : digiAccumulators_) {
302  delete digiAccumulator;
303  }
304  }
Accumulators digiAccumulators_
Definition: MixingModule.h:104
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:98
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:96

Member Function Documentation

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

Definition at line 593 of file MixingModule.cc.

References digiAccumulators_.

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

593  {
594  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
595  (*accItr)->accumulate(event, setup);
596  }
597  }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Accumulators digiAccumulators_
Definition: MixingModule.h:104
Definition: event.py:1
void MixingModule::accumulateEvent ( PileUpEventPrincipal const &  event,
edm::EventSetup const &  setup,
edm::StreamID const &  streamID 
)

Definition at line 600 of file MixingModule.cc.

References digiAccumulators_.

600  {
601  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
602  (*accItr)->accumulate(event, setup, streamID);
603  }
604  }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Accumulators digiAccumulators_
Definition: MixingModule.h:104
Definition: event.py:1
void MixingModule::addSignals ( const edm::Event e,
const edm::EventSetup es 
)
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 306 of file MixingModule.cc.

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

Referenced by beginJob().

306  {
307 
308  LogDebug("MixingModule")<<"===============> adding signals for "<<e.id();
309 
311  // fill in signal part of CrossingFrame
312  for (unsigned int ii=0;ii<workers_.size();++ii) {
313  workers_[ii]->addSignals(e);
314  }
315  }
#define LogDebug(id)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:97
ii
Definition: cuy.py:588
edm::EventID id() const
Definition: EventBase.h:60
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 571 of file MixingModule.cc.

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

Referenced by beginJob().

571  {
572  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
573  (*accItr)->beginLuminosityBlock(lumi, setup);
574  }
576  }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Accumulators digiAccumulators_
Definition: MixingModule.h:104
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 557 of file MixingModule.cc.

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

Referenced by beginJob().

557  {
558  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
559  (*accItr)->beginRun(run, setup);
560  }
562  }
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Accumulators digiAccumulators_
Definition: MixingModule.h:104
void MixingModule::branchesActivate ( const std::string &  friendlyName,
const std::string &  subdet,
InputTag tag,
std::string &  label 
)
privatevirtual

Definition at line 251 of file MixingModule.cc.

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

Referenced by beginJob(), and MixingModule().

251  {
252 
253  label=tag.label()+tag.instance();
254  wantedBranches_.push_back(friendlyName + '_' +
255  tag.label() + '_' +
256  tag.instance());
257 
258  //if useCurrentProcessOnly, we have to change the input tag
261  tag = InputTag(tag.label(),tag.instance(),processName);
262  }
263  }
std::string friendlyName(std::string const &iFullName)
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
std::vector< std::string > wantedBranches_
Definition: MixingModule.h:99
void MixingModule::checkSignal ( const edm::Event e)
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 265 of file MixingModule.cc.

References adjusters_, adjustersObjects_, workers_, and workersObjects_.

Referenced by beginJob().

265  {
266  if (adjusters_.empty()){
267  for (auto const& adjuster : adjustersObjects_) {
268  if (adjuster->checkSignal(e)){
269  adjusters_.push_back(adjuster);
270  }
271  }
272  }
273  if (workers_.empty()){
274  for (auto const& worker : workersObjects_) {
275  if (worker->checkSignal(e)){
276  workers_.push_back(worker);
277  }
278  }
279  }
280  }
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:97
std::vector< AdjusterBase * > adjusters_
Definition: MixingModule.h:95
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:98
std::vector< AdjusterBase * > adjustersObjects_
Definition: MixingModule.h:96
void MixingModule::createDigiAccumulators ( const edm::ParameterSet mixingPSet,
edm::ConsumesCollector iC 
)
private

Definition at line 222 of file MixingModule.cc.

References 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().

222  {
223  ParameterSet const& digiPSet = mixingPSet.getParameterSet("digitizers");
224  std::vector<std::string> digiNames = digiPSet.getParameterNames();
225  for(auto const& digiName : digiNames) {
226  ParameterSet const& pset = digiPSet.getParameterSet(digiName);
227  if(pset.existsAs<edm::InputTag>("HepMCProductLabel")) {
228  consumes<HepMCProduct>(pset.getParameter<edm::InputTag>("HepMCProductLabel"));
229  }
230  std::unique_ptr<DigiAccumulatorMixMod> accumulator = std::unique_ptr<DigiAccumulatorMixMod>(DigiAccumulatorMixModFactory::get()->makeDigiAccumulator(pset, *this, iC));
231  // Create appropriate DigiAccumulator
232  if(accumulator.get() != nullptr) {
233  digiAccumulators_.push_back(accumulator.release());
234  }
235  }
236  }
Accumulators digiAccumulators_
Definition: MixingModule.h:104
ParameterSet const & getParameterSet(std::string const &) const
std::unique_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, ProducerBase &, ConsumesCollector &) const
static DigiAccumulatorMixModFactory const * get()
void MixingModule::createnewEDProduct ( )
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 282 of file MixingModule.cc.

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

Referenced by beginJob().

282  {
283  //create playback info
285  //and CrossingFrames
286  for (unsigned int ii=0;ii<workers_.size();++ii){
287  workers_[ii]->createnewEDProduct();
288  }
289  }
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:97
static const unsigned int maxNbSources_
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:93
ii
Definition: cuy.py:588
void MixingModule::doPileUp ( edm::Event e,
const edm::EventSetup es 
)
overrideprivatevirtual

Reimplemented from edm::BMixingModule.

Definition at line 345 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_, 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().

345  {
346  using namespace std::placeholders;
347 
348  // Don't allocate because PileUp will do it for us.
349  std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
350  std::vector<size_t> sizes;
351  sizes.reserve(maxNbSources_*(maxBunch_ + 1 - minBunch_));
352  size_t playbackCounter = 0U;
354  edm::Handle<CrossingFramePlaybackInfoExtended> oldFormatPlaybackInfo_H;
355  bool oldFormatPlayback = false;
356  if (playback_) {
357  bool got = e.getByLabel(inputTagPlayback_, playbackInfo_H);
358  if (!got) {
359  bool gotOld = e.getByLabel(inputTagPlayback_, oldFormatPlaybackInfo_H);
360  if (!gotOld) {
361  throw cms::Exception("MixingProductNotFound") << " No "
362  "CrossingFramePlaybackInfoNew on the input file, but playback "
363  "option set!!!!! Please change the input file if you really want "
364  "playback!!!!!!" << std::endl;
365  }
366  oldFormatPlayback = true;
367  }
368  }
369 
370  // source[0] is "real" pileup. Check to see that this is what we are doing.
371 
372  std::vector<int> PileupList;
373  PileupList.clear();
374  TrueNumInteractions_.clear();
375 
376  std::shared_ptr<PileUp> source0 = inputSources_[0];
377 
378  if((source0 && source0->doPileUp(0) ) && !playback_) {
379  // if((!inputSources_[0] || !inputSources_[0]->doPileUp()) && !playback_ )
380 
381  // Pre-calculate all pileup distributions before we go fishing for events
382 
383  source0->CalculatePileup(minBunch_, maxBunch_, PileupList, TrueNumInteractions_, e.streamID());
384 
385  }
386 
387  // pre-populate Pileup information
388  // necessary for luminosity-dependent effects during hit accumulation
389 
390  std::vector<int> numInteractionList;
391  std::vector<int> bunchCrossingList;
392  std::vector<float> TrueInteractionList;
393  std::vector<edm::EventID> eventInfoList; // will be empty if we pre-populate, but it's not used in digitizers
394 
395  if(!playback_) {
396 
397  //Makin' a list: Basically, we don't care about the "other" sources at this point.
398  for (int bunchCrossing=minBunch_;bunchCrossing<=maxBunch_;++bunchCrossing) {
399  bunchCrossingList.push_back(bunchCrossing);
400  if(!inputSources_[0] || !inputSources_[0]->doPileUp(0)) {
401  numInteractionList.push_back(0);
402  TrueInteractionList.push_back(0);
403  }
404  else {
405  numInteractionList.push_back(PileupList[bunchCrossing-minBunch_]);
406  TrueInteractionList.push_back((TrueNumInteractions_)[bunchCrossing-minBunch_]);
407  }
408  }
409  }
410  else{ // have to read PU information from playback info
411  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
412  bunchCrossingList.push_back(bunchIdx);
413  for (size_t readSrcIdx=0; readSrcIdx<maxNbSources_; ++readSrcIdx) {
414 
415  if(oldFormatPlayback) {
416  std::vector<edm::EventID> const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
417  size_t numberOfEvents = playEventID.size();
418  if(readSrcIdx == 0) {
419  PileupList.push_back(numberOfEvents);
420  TrueNumInteractions_.push_back(numberOfEvents);
421  numInteractionList.push_back(numberOfEvents);
422  TrueInteractionList.push_back(numberOfEvents);
423  }
424  } else {
425  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
426  if(readSrcIdx == 0) {
427  PileupList.push_back(numberOfEvents);
428  TrueNumInteractions_.push_back(numberOfEvents);
429  numInteractionList.push_back(numberOfEvents);
430  TrueInteractionList.push_back(numberOfEvents);
431  }
432  }
433  }
434  }
435  }
436 
437  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
438  (*accItr)->StorePileupInformation( bunchCrossingList,
439  numInteractionList,
440  TrueInteractionList,
441  eventInfoList,
442  bunchSpace_);
443  }
444 
445 
446  // for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
447  // std::cout << " bunch ID, Pileup, True " << bunchIdx << " " << PileupList[bunchIdx-minBunch_] << " " << TrueNumInteractions_[bunchIdx-minBunch_] << std::endl;
448  //}
449 
450  for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) {
451  for (size_t setBcrIdx=0; setBcrIdx<workers_.size(); ++setBcrIdx) {
452  workers_[setBcrIdx]->setBcrOffset();
453  }
454  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
455  (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
456  }
457 
458  for (size_t readSrcIdx=0; readSrcIdx<maxNbSources_; ++readSrcIdx) {
459  std::shared_ptr<PileUp> source = inputSources_[readSrcIdx]; // this looks like we create
460  // new PileUp objects for each
461  // source for each event?
462  // Why?
463  for (size_t setSrcIdx=0; setSrcIdx<workers_.size(); ++setSrcIdx) {
464  workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
465  }
466 
467  if (!source || !source->doPileUp(bunchIdx)) {
468  sizes.push_back(0U);
469  if(playback_ && !oldFormatPlayback) {
470  playbackCounter += playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
471  }
472  continue;
473  }
474 
475  // int eventId = 0;
476  int vertexOffset = 0;
477 
478  ModuleCallingContext const* mcc = e.moduleCallingContext();
479  if (!playback_) {
480  // non-minbias pileup only gets one event for now. Fix later if desired.
481  int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx - minBunch_] : 1);
482  sizes.push_back(numberOfEvents);
483  inputSources_[readSrcIdx]->readPileUp(e.id(), recordEventID,
484  std::bind(&MixingModule::pileAllWorkers, std::ref(*this), _1, mcc, bunchIdx,
485  _2, vertexOffset, std::ref(setup), e.streamID()), numberOfEvents, e.streamID());
486  } else if(oldFormatPlayback) {
487  std::vector<edm::EventID> const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
488  size_t numberOfEvents = playEventID.size();
489  if(readSrcIdx == 0) {
490  PileupList.push_back(numberOfEvents);
491  TrueNumInteractions_.push_back(numberOfEvents);
492  }
493  sizes.push_back(numberOfEvents);
494  std::vector<EventID>::const_iterator begin = playEventID.begin();
495  std::vector<EventID>::const_iterator end = playEventID.end();
496  inputSources_[readSrcIdx]->playOldFormatPileUp(
497  begin, end, recordEventID,
498  std::bind(&MixingModule::pileAllWorkers, std::ref(*this), _1, mcc, bunchIdx,
499  _2, vertexOffset, std::ref(setup), e.streamID()));
500  } else {
501  size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
502  if(readSrcIdx == 0) {
503  PileupList.push_back(numberOfEvents);
504  TrueNumInteractions_.push_back(numberOfEvents);
505  }
506  sizes.push_back(numberOfEvents);
507  std::vector<SecondaryEventIDAndFileInfo>::const_iterator begin = playbackInfo_H->getEventId(playbackCounter);
508  playbackCounter += numberOfEvents;
509  std::vector<SecondaryEventIDAndFileInfo>::const_iterator end = playbackInfo_H->getEventId(playbackCounter);
510  inputSources_[readSrcIdx]->playPileUp(
511  begin, end, recordEventID,
512  std::bind(&MixingModule::pileAllWorkers, std::ref(*this), _1, mcc, bunchIdx,
513  _2, vertexOffset, std::ref(setup), e.streamID()));
514  }
515  }
516  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
517  (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
518  }
519  }
520 
521  // Save playback information
522  for (auto const item : recordEventID) {
523  eventInfoList.emplace_back(item.eventID());
524  }
525 
526  // setInfo swaps recordEventID, so recordEventID is useless (empty) after the call.
527  playbackInfo_->setInfo(recordEventID, sizes);
528 
529  // Keep track of pileup accounting...
530 
531 
532  std::unique_ptr<PileupMixingContent> PileupMixing_;
533 
534  PileupMixing_ = std::unique_ptr<PileupMixingContent>(new PileupMixingContent(bunchCrossingList,
535  numInteractionList,
536  TrueInteractionList,
537  eventInfoList,
538  bunchSpace_));
539 
540  e.put(std::move(PileupMixing_));
541 
542  // we have to do the ToF transformation for PSimHits once all pileup has been added
543  for (unsigned int ii=0;ii<workers_.size();++ii) {
544  workers_[ii]->setTof();
545  workers_[ii]->put(e);
546  }
547  }
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:136
static std::string const source("source")
std::vector< edm::EventID > getStartEventId(const unsigned int s, const int bcr) const
std::vector< float > TrueNumInteractions_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:258
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:97
Accumulators digiAccumulators_
Definition: MixingModule.h:104
size_t getNumberOfEvents(int bunchIdx, size_t sourceNumber) const
static const unsigned int maxNbSources_
#define end
Definition: vmac.h:39
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:93
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:475
ii
Definition: cuy.py:588
InputTag inputTagPlayback_
Definition: MixingModule.h:90
edm::EventID id() const
Definition: EventBase.h:60
#define begin
Definition: vmac.h:32
std::vector< std::shared_ptr< PileUp > > inputSources_
StreamID streamID() const
Definition: Event.h:95
void doPileUp(edm::Event &e, const edm::EventSetup &es) override
def move(src, dest)
Definition: eostools.py:510
void pileAllWorkers(EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
void MixingModule::endLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  setup 
)
override

Definition at line 578 of file MixingModule.cc.

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

Referenced by beginJob().

578  {
579  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
580  (*accItr)->endLuminosityBlock(lumi, setup);
581  }
583  }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Accumulators digiAccumulators_
Definition: MixingModule.h:104
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 564 of file MixingModule.cc.

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

Referenced by beginJob().

564  {
565  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
566  (*accItr)->endRun(run, setup);
567  }
569  }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
Accumulators digiAccumulators_
Definition: MixingModule.h:104
void MixingModule::finalizeEvent ( edm::Event event,
edm::EventSetup const &  setup 
)
override

Definition at line 607 of file MixingModule.cc.

References digiAccumulators_.

Referenced by beginJob().

607  {
608  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
609  (*accItr)->finalizeEvent(event, setup);
610  }
611  }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Accumulators digiAccumulators_
Definition: MixingModule.h:104
void MixingModule::initializeEvent ( edm::Event const &  event,
edm::EventSetup const &  setup 
)
override

Definition at line 586 of file MixingModule.cc.

References digiAccumulators_.

Referenced by beginJob().

586  {
587  for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) {
588  (*accItr)->initializeEvent(event, setup);
589  }
590  }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Accumulators digiAccumulators_
Definition: MixingModule.h:104
Definition: event.py:1
void 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 317 of file MixingModule.cc.

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

Referenced by beginJob(), and doPileUp().

322  {
323 
324 
325  InternalContext internalContext(eventPrincipal.id(), mcc);
326  ParentContext parentContext(&internalContext);
327  ModuleCallingContext moduleCallingContext(&moduleDescription());
328  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
329 
330  for (auto const& adjuster : adjusters_) {
331  adjuster->doOffset(bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
332  }
333  PileUpEventPrincipal pep(eventPrincipal, &moduleCallingContext, bunchCrossing);
334 
335  accumulateEvent(pep, setup, streamID);
336 
337  for (auto const& worker : workers_) {
338  LogDebug("MixingModule") <<" merging Event: id " << eventPrincipal.id();
339  // std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl;
340 
341  worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
342  }
343  }
#define LogDebug(id)
std::vector< MixingWorkerBase * > workers_
Definition: MixingModule.h:97
std::vector< AdjusterBase * > adjusters_
Definition: MixingModule.h:95
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 549 of file MixingModule.cc.

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

Referenced by beginJob().

549  {
550 
551  if (playbackInfo_) {
552  std::unique_ptr<CrossingFramePlaybackInfoNew> pOut(playbackInfo_);
553  e.put(std::move(pOut));
554  }
555  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
CrossingFramePlaybackInfoNew * playbackInfo_
Definition: MixingModule.h:93
def move(src, dest)
Definition: eostools.py:510
void MixingModule::reload ( const edm::EventSetup setup)
overridevirtual

Reimplemented from edm::BMixingModule.

Definition at line 238 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().

238  {
239  //change the basic parameters.
241  setup.get<MixingRcd>().get(config);
242  minBunch_=config->minBunch();
243  maxBunch_=config->maxBunch();
244  bunchSpace_=config->bunchSpace();
245  //propagate to change the workers
246  for (unsigned int ii=0;ii<workersObjects_.size();++ii){
247  workersObjects_[ii]->reload(setup);
248  }
249  }
const int & bunchSpace() const
const int & maxBunch() const
config
Definition: looper.py:287
std::vector< MixingWorkerBase * > workersObjects_
Definition: MixingModule.h:98
ii
Definition: cuy.py:588
const T & get() const
Definition: EventSetup.h:59
const int & minBunch() const

Member Data Documentation

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

Definition at line 95 of file MixingModule.h.

Referenced by checkSignal(), and pileAllWorkers().

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

Definition at line 96 of file MixingModule.h.

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

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

Definition at line 90 of file MixingModule.h.

Referenced by doPileUp(), and MixingModule().

bool edm::MixingModule::mixProdStep1_
private

Definition at line 92 of file MixingModule.h.

Referenced by MixingModule().

bool edm::MixingModule::mixProdStep2_
private

Definition at line 91 of file MixingModule.h.

Referenced by MixingModule().

CrossingFramePlaybackInfoNew* edm::MixingModule::playbackInfo_
private

Definition at line 93 of file MixingModule.h.

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

bool edm::MixingModule::useCurrentProcessOnly_
private

Definition at line 100 of file MixingModule.h.

Referenced by branchesActivate(), and MixingModule().

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

Definition at line 99 of file MixingModule.h.

Referenced by branchesActivate(), and MixingModule().

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

Definition at line 97 of file MixingModule.h.

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

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

Definition at line 98 of file MixingModule.h.

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

bool edm::MixingModule::wrapLongTimes_
private

Definition at line 101 of file MixingModule.h.

Referenced by MixingModule().