CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::PreMixingModule Class Reference
Inheritance diagram for edm::PreMixingModule:
edm::BMixingModule edm::stream::EDProducer< GlobalCache< MixingCache::Config > >

Public Member Functions

void addSignals (const edm::Event &e, const edm::EventSetup &ES) override
 
void beginLuminosityBlock (LuminosityBlock const &l1, EventSetup const &c) override
 
void beginRun (edm::Run const &run, edm::EventSetup const &eventSetup) override
 
void checkSignal (const edm::Event &e) override
 
void createnewEDProduct () override
 
void doPileUp (edm::Event &e, const edm::EventSetup &ES) override
 
void endLuminosityBlock (LuminosityBlock const &l1, EventSetup const &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &setup) override
 
void initializeEvent (edm::Event const &e, edm::EventSetup const &eventSetup) override
 
 PreMixingModule (const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
 
void put (edm::Event &e, const edm::EventSetup &ES) override
 
 ~PreMixingModule () override=default
 
- 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 reload (const edm::EventSetup &setup)
 
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 pileWorker (const edm::EventPrincipal &, int bcr, int EventId, const edm::EventSetup &ES, ModuleCallingContext const *)
 

Private Attributes

bool addedPileup_ = false
 
PreMixingPileupCopy puWorker_
 
std::vector< std::unique_ptr< PreMixingWorker > > workers_
 

Additional Inherited Members

- 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
 
- 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 34 of file PreMixingModule.cc.

Constructor & Destructor Documentation

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

Definition at line 61 of file PreMixingModule.cc.

References popcon2dropbox::copy(), beamerCreator::create(), spr::find(), reco::get(), edm::ParameterSet::getParameter(), mps_fire::i, eostools::move(), dataset::name, names, muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, tmp, mixOne_premix_on_sim_cfi::workers, and workers_.

61  :
62  BMixingModule(ps, globalConf),
63  puWorker_(ps.getParameter<edm::ParameterSet>("workers").getParameter<edm::ParameterSet>("pileup"), *this, consumesCollector())
64  {
65  const auto& workers = ps.getParameter<edm::ParameterSet>("workers");
66  std::vector<std::string> names = workers.getParameterNames();
67 
68  // Hack to keep the random number sequence unchanged for migration
69  // from DataMixingModule to PreMixingModule. To be removed in a
70  // subsequent PR doing only that.
71  {
72  std::vector<std::string> tmp;
73  auto hack = [&](const std::string& name) {
74  auto i = std::find(names.begin(), names.end(), name);
75  if(i != names.end()) {
76  tmp.push_back(*i);
77  names.erase(i);
78  }
79  };
80  hack("ecal");
81  hack("hcal");
82  hack("strip");
83  hack("pixel");
84  std::copy(names.begin(), names.end(), std::back_inserter(tmp));
85  names = std::move(tmp);
86  }
87 
88  for(const auto& name: names) {
89  if(name == "pileup") {
90  continue;
91  }
92  const auto& pset = workers.getParameter<edm::ParameterSet>(name);
93  std::string type = pset.getParameter<std::string>("workerType");
94  workers_.emplace_back(PreMixingWorkerFactory::get()->create(type, pset, *this, consumesCollector()));
95  }
96  }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
def copy(args, dbName)
def create(alignables, pedeDump, additionalData, outputFile, config)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
const std::string names[nVars_]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< std::unique_ptr< PreMixingWorker > > workers_
PreMixingPileupCopy puWorker_
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
BMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
edm::PreMixingModule::~PreMixingModule ( )
overridedefault

Member Function Documentation

void PreMixingModule::addSignals ( const edm::Event e,
const edm::EventSetup ES 
)
overridevirtual

Reimplemented from edm::BMixingModule.

Definition at line 120 of file PreMixingModule.cc.

References addedPileup_, edm::EventBase::id(), LogDebug, w, and workers_.

Referenced by createnewEDProduct().

120  {
121  // fill in maps of hits
122 
123  LogDebug("PreMixingModule")<<"===============> adding MC signals for "<<e.id();
124 
125  for(auto& w: workers_) {
126  w->addSignals(e, ES);
127  }
128 
129  addedPileup_ = false;
130  }
#define LogDebug(id)
const double w
Definition: UKUtility.cc:23
edm::EventID id() const
Definition: EventBase.h:60
std::vector< std::unique_ptr< PreMixingWorker > > workers_
void PreMixingModule::beginLuminosityBlock ( LuminosityBlock const &  l1,
EventSetup const &  c 
)
override

Definition at line 220 of file PreMixingModule.cc.

References edm::BMixingModule::beginLuminosityBlock(), w, and workers_.

Referenced by createnewEDProduct().

220  {
222  for(auto& w: workers_) {
223  w->beginLuminosityBlock(l1,c);
224  }
225  }
const double w
Definition: UKUtility.cc:23
std::vector< std::unique_ptr< PreMixingWorker > > workers_
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void PreMixingModule::beginRun ( edm::Run const &  run,
edm::EventSetup const &  eventSetup 
)
override

Definition at line 106 of file PreMixingModule.cc.

References edm::BMixingModule::beginRun(), w, and workers_.

Referenced by createnewEDProduct().

106  {
108  for(auto& w: workers_) {
109  w->beginRun(run, ES);
110  }
111  }
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
const double w
Definition: UKUtility.cc:23
std::vector< std::unique_ptr< PreMixingWorker > > workers_
void edm::PreMixingModule::checkSignal ( const edm::Event e)
inlineoverridevirtual

Reimplemented from edm::BMixingModule.

Definition at line 40 of file PreMixingModule.cc.

40 {};
void edm::PreMixingModule::createnewEDProduct ( )
inlineoverridevirtual
void PreMixingModule::doPileUp ( edm::Event e,
const edm::EventSetup ES 
)
overridevirtual

Reimplemented from edm::BMixingModule.

Definition at line 160 of file PreMixingModule.cc.

References edm::EventBase::id(), edm::BMixingModule::inputSources_, edm::BMixingModule::maxBunch_, edm::BMixingModule::maxNbSources_, edm::BMixingModule::minBunch_, edm::Event::moduleCallingContext(), pileWorker(), edm::source(), edm::Event::streamID(), edm::BMixingModule::TrueNumInteractions_, w, and workers_.

Referenced by createnewEDProduct().

161  {
162  using namespace std::placeholders;
163 
164  std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
165  std::vector<int> PileupList;
166  TrueNumInteractions_.clear();
167 
168  ModuleCallingContext const* mcc = e.moduleCallingContext();
169 
170  for (int bunchCrossing=minBunch_;bunchCrossing<=maxBunch_;++bunchCrossing) {
171  for (unsigned int isource=0;isource<maxNbSources_;++isource) {
172  std::shared_ptr<PileUp> source = inputSources_[isource];
173  if (!source || !(source->doPileUp(bunchCrossing)))
174  continue;
175 
176  if (isource==0)
177  source->CalculatePileup(minBunch_, maxBunch_, PileupList, TrueNumInteractions_, e.streamID());
178 
179  int NumPU_Events = 0;
180  if (isource ==0) {
181  NumPU_Events = PileupList[bunchCrossing - minBunch_];
182  } else {
183  // non-minbias pileup only gets one event for now. Fix later if desired.
184  NumPU_Events = 1;
185  }
186 
187  for(auto& w: workers_) {
188  w->initializeBunchCrossing(e, ES, bunchCrossing);
189  }
190 
191  source->readPileUp(
192  e.id(),
193  recordEventID,
194  std::bind(&PreMixingModule::pileWorker, std::ref(*this),
195  _1, bunchCrossing, _2, std::cref(ES), mcc),
196  NumPU_Events,
197  e.streamID()
198  );
199 
200  for(auto& w: workers_) {
201  w->finalizeBunchCrossing(e, ES, bunchCrossing);
202  }
203  }
204  }
205  }
static std::string const source("source")
const double w
Definition: UKUtility.cc:23
std::vector< float > TrueNumInteractions_
ModuleCallingContext const * moduleCallingContext() const
Definition: Event.h:269
static const unsigned int maxNbSources_
void pileWorker(const edm::EventPrincipal &, int bcr, int EventId, const edm::EventSetup &ES, ModuleCallingContext const *)
edm::EventID id() const
Definition: EventBase.h:60
std::vector< std::shared_ptr< PileUp > > inputSources_
std::vector< std::unique_ptr< PreMixingWorker > > workers_
StreamID streamID() const
Definition: Event.h:96
void PreMixingModule::endLuminosityBlock ( LuminosityBlock const &  l1,
EventSetup const &  c 
)
override

Definition at line 227 of file PreMixingModule.cc.

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

Referenced by createnewEDProduct().

227  {
229  }
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void PreMixingModule::endRun ( const edm::Run r,
const edm::EventSetup setup 
)
override

Definition at line 113 of file PreMixingModule.cc.

References edm::BMixingModule::endRun(), w, and workers_.

Referenced by createnewEDProduct().

113  {
114  for(auto& w: workers_) {
115  w->endRun();
116  }
118  }
const double w
Definition: UKUtility.cc:23
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
std::vector< std::unique_ptr< PreMixingWorker > > workers_
void PreMixingModule::initializeEvent ( edm::Event const &  e,
edm::EventSetup const &  eventSetup 
)
override

Definition at line 99 of file PreMixingModule.cc.

References w, and workers_.

Referenced by createnewEDProduct().

99  {
100  for(auto& w: workers_) {
101  w->initializeEvent(e, ES);
102  }
103  }
const double w
Definition: UKUtility.cc:23
std::vector< std::unique_ptr< PreMixingWorker > > workers_
void PreMixingModule::pileWorker ( const edm::EventPrincipal ep,
int  bcr,
int  EventId,
const edm::EventSetup ES,
edm::ModuleCallingContext const *  mcc 
)
private

Definition at line 132 of file PreMixingModule.cc.

References addedPileup_, edm::PreMixingPileupCopy::addPileupInfo(), edm::EventPrincipal::id(), LogDebug, puWorker_, edm::BMixingModule::setupPileUpEvent(), w, and workers_.

Referenced by createnewEDProduct(), and doPileUp().

132  {
133  InternalContext internalContext(ep.id(), mcc);
134  ParentContext parentContext(&internalContext);
135  ModuleCallingContext moduleCallingContext(&moduleDescription());
136  ModuleContextSentry moduleContextSentry(&moduleCallingContext, parentContext);
137 
138  PileUpEventPrincipal pep(ep, &moduleCallingContext, bcr);
139 
140  LogDebug("PreMixingModule") <<"\n===============> adding pileups from event "<<ep.id()<<" for bunchcrossing "<<bcr;
141 
142  // Note: setupPileUpEvent may modify the run and lumi numbers of the EventPrincipal to match that of the primary event.
143  setupPileUpEvent(ES);
144 
145  // check and see if we need to copy the pileup information from
146  // secondary stream to the output stream
147  // We only have the pileup event here, so pick the first time and store the info
148  if(!addedPileup_) {
150  addedPileup_ = true;
151  }
152 
153  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
154 
155  for(auto& w: workers_) {
156  w->addPileups(pep, ES);
157  }
158  }
#define LogDebug(id)
const double w
Definition: UKUtility.cc:23
EventID const & id() const
void addPileupInfo(PileUpEventPrincipal const &pep)
std::vector< std::unique_ptr< PreMixingWorker > > workers_
PreMixingPileupCopy puWorker_
void setupPileUpEvent(const edm::EventSetup &setup)
void PreMixingModule::put ( edm::Event e,
const edm::EventSetup ES 
)
overridevirtual

Reimplemented from edm::BMixingModule.

Definition at line 207 of file PreMixingModule.cc.

References edm::PreMixingPileupCopy::getBunchSpacing(), edm::PreMixingPileupCopy::getPileupSummaryInfo(), edm::PreMixingPileupCopy::putPileupInfo(), puWorker_, w, and workers_.

Referenced by createnewEDProduct().

207  {
208  // individual workers...
209  // move pileup first so we have access to the information for the put step
210  const auto& ps = puWorker_.getPileupSummaryInfo();
211  int bunchSpacing = puWorker_.getBunchSpacing();
212 
213  for(auto& w: workers_) {
214  w->put(e, ES, ps, bunchSpacing);
215  }
216 
218  }
const double w
Definition: UKUtility.cc:23
void putPileupInfo(edm::Event &e)
std::vector< std::unique_ptr< PreMixingWorker > > workers_
PreMixingPileupCopy puWorker_
const std::vector< PileupSummaryInfo > & getPileupSummaryInfo() const

Member Data Documentation

bool edm::PreMixingModule::addedPileup_ = false
private

Definition at line 56 of file PreMixingModule.cc.

Referenced by addSignals(), and pileWorker().

PreMixingPileupCopy edm::PreMixingModule::puWorker_
private

Definition at line 55 of file PreMixingModule.cc.

Referenced by pileWorker(), and put().

std::vector<std::unique_ptr<PreMixingWorker> > edm::PreMixingModule::workers_
private