CMS 3D CMS Logo

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

#include <PileUp.h>

Public Member Functions

double averageNumber () const
 
void beginLuminosityBlock (const edm::LuminosityBlock &lumi, const edm::EventSetup &setup)
 
void beginRun (const edm::Run &run, const edm::EventSetup &setup)
 
void beginStream (edm::StreamID)
 
void CalculatePileup (int MinBunch, int MaxBunch, std::vector< int > &PileupSelection, std::vector< float > &TrueNumInteractions, StreamID const &)
 
bool doPileUp (int BX)
 
void dropUnwantedBranches (std::vector< std::string > const &wantedBranches)
 
void endLuminosityBlock (const edm::LuminosityBlock &lumi, const edm::EventSetup &setup)
 
void endRun (const edm::Run &run, const edm::EventSetup &setup)
 
void endStream ()
 
const unsigned int & input () const
 
void input (unsigned int s)
 
 PileUp (ParameterSet const &pset, const std::shared_ptr< PileUpConfig > &config)
 
template<typename T >
void playOldFormatPileUp (std::vector< edm::EventID >::const_iterator begin, std::vector< edm::EventID >::const_iterator end, std::vector< edm::SecondaryEventIDAndFileInfo > &ids, T eventOperator)
 
template<typename T >
void playPileUp (std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator begin, std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator end, std::vector< edm::SecondaryEventIDAndFileInfo > &ids, T eventOperator)
 
bool poisson () const
 
template<typename T >
void readPileUp (edm::EventID const &signal, std::vector< edm::SecondaryEventIDAndFileInfo > &ids, T eventOperator, int const NumPU, StreamID const &)
 
void reload (const edm::EventSetup &setup)
 
void setupPileUpEvent (const edm::EventSetup &setup)
 
 ~PileUp ()
 

Private Member Functions

std::unique_ptr< CLHEP::RandPoisson > const & poissonDistr_OOT (StreamID const &streamID)
 
std::unique_ptr< CLHEP::RandPoissonQ > const & poissonDistribution (StreamID const &streamID)
 
CLHEP::HepRandomEngine * randomEngine (StreamID const &streamID)
 

Private Attributes

double averageNumber_
 
std::unique_ptr< EventPrincipaleventPrincipal_
 
size_t fileNameHash_
 
bool fixed_
 
bool fixed_OOT_
 
std::shared_ptr< TH1F > histo_
 
bool histoDistribution_
 
const std::unique_ptr< VectorInputSourceinput_
 
unsigned int inputType_
 
const int intAverage_
 
int intFixed_ITPU_
 
int intFixed_OOT_
 
std::shared_ptr< LuminosityBlockPrincipallumiPrincipal_
 
bool manage_OOT_
 
int maxBunch_cosmics_
 
int minBunch_cosmics_
 
bool none_
 
bool playback_
 
bool poisson_
 
bool poisson_OOT_
 
std::unique_ptr< CLHEP::RandPoisson > PoissonDistr_OOT_
 
std::unique_ptr< CLHEP::RandPoissonQ > PoissonDistribution_
 
bool probFunctionDistribution_
 
std::shared_ptr< ProcessConfigurationprocessConfiguration_
 
std::shared_ptr< ProcessContextprocessContext_
 
std::shared_ptr< ProductRegistryproductRegistry_
 
std::unique_ptr< SecondaryEventProviderprovider_
 
bool PU_Study_
 
CLHEP::HepRandomEngine * randomEngine_
 
std::shared_ptr< RunPrincipalrunPrincipal_
 
bool sequential_
 
std::string Source_type_
 
std::shared_ptr< StreamContextstreamContext_
 
std::string Study_type_
 
std::string type_
 

Detailed Description

Definition at line 40 of file PileUp.h.

Constructor & Destructor Documentation

◆ PileUp()

edm::PileUp::PileUp ( ParameterSet const &  pset,
const std::shared_ptr< PileUpConfig > &  config 
)
explicit

Definition at line 66 of file PileUp.cc.

66  {
67  PileUp::PileUp(ParameterSet const& pset, const std::shared_ptr<PileUpConfig>& config)
68  : type_(pset.getParameter<std::string>("type")),
69  Source_type_(config->sourcename_),
71  intAverage_(static_cast<int>(averageNumber_)),
72  histo_(std::make_shared<TH1F>(*config->histo_)),
73  histoDistribution_(type_ == "histo"),
74  probFunctionDistribution_(type_ == "probFunction"),
75  poisson_(type_ == "poisson"),
76  fixed_(type_ == "fixed"),
77  none_(type_ == "none"),
78  fileNameHash_(0U),
80  input_(VectorInputSourceFactory::get()
81  ->makeVectorInputSource(
82  pset, VectorInputSourceDescription(productRegistry_, edm::PreallocationConfiguration()))
83  .release()),
84  processConfiguration_(new ProcessConfiguration(std::string("@MIXING"), getReleaseVersion(), getPassID())),
85  processContext_(new ProcessContext()),
88  runPrincipal_(),
89  provider_(),
92  randomEngine_(),
94  sequential_(pset.getUntrackedParameter<bool>("sequential", false)) {
95  // Use the empty parameter set for the parameter set ID of our "@MIXING" process.
96  processConfiguration_->setParameterSetID(ParameterSet::emptyParameterSetID());
97  processContext_->setProcessConfiguration(processConfiguration_.get());
98 
99  if (pset.existsAs<std::vector<ParameterSet> >("producers", true)) {
100  std::vector<ParameterSet> producers = pset.getParameter<std::vector<ParameterSet> >("producers");
101  provider_.reset(new SecondaryEventProvider(producers, *productRegistry_, processConfiguration_));
102  }
103 
104  productRegistry_->setFrozen();
105 
106  // A modified HistoryAppender must be used for unscheduled processing.
107  eventPrincipal_.reset(new EventPrincipal(input_->productRegistry(),
108  std::make_shared<BranchIDListHelper>(),
109  std::make_shared<ThinnedAssociationsHelper>(),
110  *processConfiguration_,
111  nullptr));
112 
113  bool DB = type_ == "readDB";
114 
115  if (pset.exists("nbPileupEvents")) {
116  if (0 != pset.getParameter<edm::ParameterSet>("nbPileupEvents").getUntrackedParameter<int>("seed", 0)) {
117  edm::LogWarning("MixingModule") << "Parameter nbPileupEvents.seed is not supported";
118  }
119  }
120 
122  if (!rng.isAvailable()) {
123  throw cms::Exception("Configuration")
124  << "PileUp requires the RandomNumberGeneratorService\n"
125  "which is not present in the configuration file. You must add the service\n"
126  "in the configuration file or remove the modules that require it.";
127  }
128 
129  if (!(histoDistribution_ || probFunctionDistribution_ || poisson_ || fixed_ || none_) && !DB) {
130  throw cms::Exception("Illegal parameter value", "PileUp::PileUp(ParameterSet const& pset)")
131  << "'type' parameter (a string) has a value of '" << type_ << "'.\n"
132  << "Legal values are 'poisson', 'fixed', or 'none'\n";
133  }
134 
135  if (!DB) {
136  manage_OOT_ = pset.getUntrackedParameter<bool>("manage_OOT", false);
137 
138  // Check for string describing special processing. Add these here for individual cases
139  PU_Study_ = false;
140  Study_type_ = pset.getUntrackedParameter<std::string>("Special_Pileup_Studies", "");
141 
142  if (Study_type_ == "Fixed_ITPU_Vary_OOTPU") {
143  PU_Study_ = true;
144  intFixed_ITPU_ = pset.getUntrackedParameter<int>("intFixed_ITPU", 0);
145  }
146 
147  if (manage_OOT_) { // figure out what the parameters are
148 
149  // if (playback_) throw cms::Exception("Illegal parameter clash","PileUp::PileUp(ParameterSet const& pset)")
150  // << " manage_OOT option not allowed with playback ";
151 
152  std::string OOT_type = pset.getUntrackedParameter<std::string>("OOT_type");
153 
154  if (OOT_type == "Poisson" || OOT_type == "poisson") {
155  poisson_OOT_ = true;
156  } else if (OOT_type == "Fixed" || OOT_type == "fixed") {
157  fixed_OOT_ = true;
158  // read back the fixed number requested out-of-time
159  intFixed_OOT_ = pset.getUntrackedParameter<int>("intFixed_OOT", -1);
160  if (intFixed_OOT_ < 0) {
161  throw cms::Exception("Illegal parameter value", "PileUp::PileUp(ParameterSet const& pset)")
162  << " Fixed out-of-time pileup requested, but no fixed value given ";
163  }
164  } else {
165  throw cms::Exception("Illegal parameter value", "PileUp::PileUp(ParameterSet const& pset)")
166  << "'OOT_type' parameter (a string) has a value of '" << OOT_type << "'.\n"
167  << "Legal values are 'poisson' or 'fixed'\n";
168  }
169  edm::LogInfo("MixingModule") << " Out-of-time pileup will be generated with a " << OOT_type
170  << " distribution. ";
171  }
172  }
173 
174  if (Source_type_ == "cosmics") { // allow for some extra flexibility for mixing
175  minBunch_cosmics_ = pset.getUntrackedParameter<int>("minBunch_cosmics", -1000);
176  maxBunch_cosmics_ = pset.getUntrackedParameter<int>("maxBunch_cosmics", 1000);
177  }

References dqmPostProcessing_online::DB, edm::ParameterSet::emptyParameterSetID(), Exception, edm::VectorInputSourceFactory::get(), edm::getPassID(), edm::getReleaseVersion(), edm::ParameterSet::getUntrackedParameter(), edm::Service< T >::isAvailable(), mix_2012_lumiLevel_15_20_50ns_PoissonOOTPU_cfi::OOT_type, HLT_2018_cff::producers, muonDTDigis_cfi::pset, fetchall_from_DQM_v2::release, AlCaHLTBitMon_QueryRunRegistry::string, and mitigatedMETSequence_cff::U.

◆ ~PileUp()

edm::PileUp::~PileUp ( )

Definition at line 325 of file PileUp.cc.

Member Function Documentation

◆ averageNumber()

double edm::PileUp::averageNumber ( ) const
inline

Definition at line 64 of file PileUp.h.

64 { return averageNumber_; }

References averageNumber_.

Referenced by reload().

◆ beginLuminosityBlock()

void edm::PileUp::beginLuminosityBlock ( const edm::LuminosityBlock lumi,
const edm::EventSetup setup 
)

Definition at line 205 of file PileUp.cc.

206  {
207  if (provider_.get() != nullptr) {
208  lumiPrincipal_.reset(new LuminosityBlockPrincipal(productRegistry_, *processConfiguration_, nullptr, 0));
209  lumiPrincipal_->setAux(lumi.luminosityBlockAuxiliary());
210  lumiPrincipal_->setRunPrincipal(runPrincipal_);
211  provider_->beginLuminosityBlock(*lumiPrincipal_, setup.impl(), lumi.moduleCallingContext(), *streamContext_);
212  }

◆ beginRun()

void edm::PileUp::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)

Definition at line 198 of file PileUp.cc.

199  {
200  if (provider_.get() != nullptr) {
201  auto aux = std::make_shared<RunAuxiliary>(run.runAuxiliary());
202  runPrincipal_.reset(new RunPrincipal(aux, productRegistry_, *processConfiguration_, nullptr, 0));
203  provider_->beginRun(*runPrincipal_, setup.impl(), run.moduleCallingContext(), *streamContext_);
204  }

References printConversionInfo::aux, processConfiguration_, productRegistry_, provider_, writedatasetfile::run, runPrincipal_, singleTopDQM_cfi::setup, and streamContext_.

◆ beginStream()

void edm::PileUp::beginStream ( edm::StreamID  )

Definition at line 179 of file PileUp.cc.

180  {
181  auto iID = eventPrincipal_->streamID(); // each producer has its own workermanager, so use default streamid
182  streamContext_.reset(new StreamContext(iID, processContext_.get()));
183  input_->doBeginJob();
184  if (provider_.get() != nullptr) {
185  //TODO for now, we do not support consumes from EventSetup
186  provider_->beginJob(*productRegistry_, eventsetup::ESRecordsToProxyIndices{{}});
187  provider_->beginStream(iID, *streamContext_);
188  }

References eventPrincipal_, input_, processContext_, productRegistry_, provider_, and streamContext_.

◆ CalculatePileup()

void edm::PileUp::CalculatePileup ( int  MinBunch,
int  MaxBunch,
std::vector< int > &  PileupSelection,
std::vector< float > &  TrueNumInteractions,
StreamID const &  streamID 
)

Definition at line 351 of file PileUp.cc.

356  {
357  // if we are managing the distribution of out-of-time pileup separately, select the distribution for bunch
358  // crossing zero first, save it for later.
359 
360  int nzero_crossing = -1;
361  double Fnzero_crossing = -1;
362 
363  if (manage_OOT_) {
364  if (none_) {
365  nzero_crossing = 0;
366  } else if (poisson_) {
367  nzero_crossing = poissonDistribution(streamID)->fire();
368  } else if (fixed_) {
369  nzero_crossing = intAverage_;
371  // RANDOM_NUMBER_ERROR
372  // Random number should be generated by the engines from the
373  // RandomNumberGeneratorService. This appears to use the global
374  // engine in ROOT. This is not thread safe unless the module using
375  // it is a one module and declares a shared resource and all
376  // other modules using it also declare the same shared resource.
377  // This also breaks replay.
378  double d = GetRandom(histo_.get(), randomEngine(streamID));
379  //n = (int) floor(d + 0.5); // incorrect for bins with integer edges
380  Fnzero_crossing = d;
381  nzero_crossing = int(d);
382  }
383  }
384 
385  for (int bx = MinBunch; bx < MaxBunch + 1; ++bx) {
386  if (manage_OOT_) {
387  if (bx == 0 && !poisson_OOT_) {
388  PileupSelection.push_back(nzero_crossing);
389  TrueNumInteractions.push_back(nzero_crossing);
390  } else {
391  if (poisson_OOT_) {
392  if (PU_Study_ && (Study_type_ == "Fixed_ITPU_Vary_OOTPU") && bx == 0) {
393  PileupSelection.push_back(intFixed_ITPU_);
394  } else {
395  PileupSelection.push_back(poissonDistr_OOT(streamID)->fire(Fnzero_crossing));
396  }
397  TrueNumInteractions.push_back(Fnzero_crossing);
398  } else {
399  PileupSelection.push_back(intFixed_OOT_);
400  TrueNumInteractions.push_back(intFixed_OOT_);
401  }
402  }
403  } else {
404  if (none_) {
405  PileupSelection.push_back(0);
406  TrueNumInteractions.push_back(0.);
407  } else if (poisson_) {
408  PileupSelection.push_back(poissonDistribution(streamID)->fire());
409  TrueNumInteractions.push_back(averageNumber_);
410  } else if (fixed_) {
411  PileupSelection.push_back(intAverage_);
412  TrueNumInteractions.push_back(intAverage_);
414  // RANDOM_NUMBER_ERROR
415  // Random number should be generated by the engines from the
416  // RandomNumberGeneratorService. This appears to use the global
417  // engine in ROOT. This is not thread safe unless the module using
418  // it is a one module and declares a shared resource and all
419  // other modules using it also declare the same shared resource.
420  // This also breaks replay.
421  double d = GetRandom(histo_.get(), randomEngine(streamID));
422  PileupSelection.push_back(int(d));
423  TrueNumInteractions.push_back(d);
424  }
425  }
426  }

References averageNumber_, l1GtPatternGenerator_cfi::bx, ztail::d, fixed_, GetRandom(), histo_, histoDistribution_, createfilelist::int, intAverage_, intFixed_ITPU_, intFixed_OOT_, manage_OOT_, none_, poisson_, poisson_OOT_, poissonDistr_OOT(), poissonDistribution(), probFunctionDistribution_, PU_Study_, randomEngine(), and Study_type_.

◆ doPileUp()

bool edm::PileUp::doPileUp ( int  BX)
inline

Definition at line 66 of file PileUp.h.

66  {
67  if (Source_type_ != "cosmics") {
68  return none_ ? false : averageNumber_ > 0.;
69  } else {
70  return (BX >= minBunch_cosmics_ && BX <= maxBunch_cosmics_);
71  }
72  }

References averageNumber_, L1TStage2uGTEmulatorClient_cff::BX, funct::false, maxBunch_cosmics_, minBunch_cosmics_, none_, and Source_type_.

◆ dropUnwantedBranches()

void edm::PileUp::dropUnwantedBranches ( std::vector< std::string > const &  wantedBranches)
inline

Definition at line 73 of file PileUp.h.

73  {
74  input_->dropUnwantedBranches(wantedBranches);
75  }

References input_.

◆ endLuminosityBlock()

void edm::PileUp::endLuminosityBlock ( const edm::LuminosityBlock lumi,
const edm::EventSetup setup 
)

Definition at line 219 of file PileUp.cc.

220  {
221  if (provider_.get() != nullptr) {
222  provider_->endLuminosityBlock(*lumiPrincipal_, setup.impl(), lumi.moduleCallingContext(), *streamContext_);
223  }

◆ endRun()

void edm::PileUp::endRun ( const edm::Run run,
const edm::EventSetup setup 
)

Definition at line 214 of file PileUp.cc.

215  {
216  if (provider_.get() != nullptr) {
217  provider_->endRun(*runPrincipal_, setup.impl(), run.moduleCallingContext(), *streamContext_);
218  }

References provider_, writedatasetfile::run, runPrincipal_, singleTopDQM_cfi::setup, and streamContext_.

◆ endStream()

void edm::PileUp::endStream ( )

Definition at line 190 of file PileUp.cc.

191  {
192  if (provider_.get() != nullptr) {
193  provider_->endStream(streamContext_->streamID(), *streamContext_);
194  provider_->endJob();
195  }
196  input_->doEndJob();

References input_, provider_, and streamContext_.

◆ input() [1/2]

const unsigned int& edm::PileUp::input ( ) const
inline

Definition at line 99 of file PileUp.h.

99 { return inputType_; }

References inputType_.

◆ input() [2/2]

void edm::PileUp::input ( unsigned int  s)
inline

Definition at line 100 of file PileUp.h.

100 { inputType_ = s; }

References inputType_, and alignCSCRings::s.

◆ playOldFormatPileUp()

template<typename T >
void edm::PileUp::playOldFormatPileUp ( std::vector< edm::EventID >::const_iterator  begin,
std::vector< edm::EventID >::const_iterator  end,
std::vector< edm::SecondaryEventIDAndFileInfo > &  ids,
T  eventOperator 
)

Definition at line 215 of file PileUp.h.

218  {
219  //TrueNumInteractions.push_back( end - begin ) ;
220  RecordEventID<T> recorder(ids, eventOperator);
221  input_->loopSpecified(*eventPrincipal_, fileNameHash_, begin, end, recorder);
222  }

References begin, end, eventPrincipal_, fileNameHash_, and input_.

◆ playPileUp()

template<typename T >
void edm::PileUp::playPileUp ( std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator  begin,
std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator  end,
std::vector< edm::SecondaryEventIDAndFileInfo > &  ids,
T  eventOperator 
)

Definition at line 205 of file PileUp.h.

208  {
209  //TrueNumInteractions.push_back( end - begin ) ;
210  RecordEventID<T> recorder(ids, eventOperator);
211  input_->loopSpecified(*eventPrincipal_, fileNameHash_, begin, end, recorder);
212  }

References begin, end, eventPrincipal_, fileNameHash_, and input_.

◆ poisson()

bool edm::PileUp::poisson ( ) const
inline

Definition at line 65 of file PileUp.h.

65 { return poisson_; }

References poisson_.

◆ poissonDistr_OOT()

std::unique_ptr< CLHEP::RandPoisson > const & edm::PileUp::poissonDistr_OOT ( StreamID const &  streamID)
private

Definition at line 335 of file PileUp.cc.

336  {
337  if (!PoissonDistr_OOT_) {
338  CLHEP::HepRandomEngine& engine = *randomEngine(streamID);
339  PoissonDistr_OOT_.reset(new CLHEP::RandPoisson(engine));
340  }
341  return PoissonDistr_OOT_;

References PoissonDistr_OOT_, and randomEngine().

Referenced by CalculatePileup().

◆ poissonDistribution()

std::unique_ptr< CLHEP::RandPoissonQ > const & edm::PileUp::poissonDistribution ( StreamID const &  streamID)
private

Definition at line 327 of file PileUp.cc.

328  {
329  if (!PoissonDistribution_) {
330  CLHEP::HepRandomEngine& engine = *randomEngine(streamID);
331  PoissonDistribution_.reset(new CLHEP::RandPoissonQ(engine, averageNumber_));
332  }
333  return PoissonDistribution_;

References averageNumber_, PoissonDistribution_, and randomEngine().

Referenced by CalculatePileup().

◆ randomEngine()

CLHEP::HepRandomEngine * edm::PileUp::randomEngine ( StreamID const &  streamID)
private

Definition at line 343 of file PileUp.cc.

344  {
345  if (!randomEngine_) {
347  randomEngine_ = &rng->getEngine(streamID);
348  }
349  return randomEngine_;

References randomEngine_.

Referenced by CalculatePileup(), poissonDistr_OOT(), poissonDistribution(), and readPileUp().

◆ readPileUp()

template<typename T >
void edm::PileUp::readPileUp ( edm::EventID const &  signal,
std::vector< edm::SecondaryEventIDAndFileInfo > &  ids,
T  eventOperator,
int const  pileEventCnt,
StreamID const &  streamID 
)

Generates events from a VectorInputSource. This function decides which method of VectorInputSource to call: sequential, random, or pre-specified. The ids are either ids to read or ids to store while reading. eventOperator has a type that matches the eventOperator in VectorInputSource::loopRandom.

The "signal" event is optionally used to restrict the secondary events used for pileup and mixing.

Definition at line 187 of file PileUp.h.

191  {
192  // One reason PileUp is responsible for recording event IDs is
193  // that it is the one that knows how many events will be read.
194  ids.reserve(pileEventCnt);
195  RecordEventID<T> recorder(ids, eventOperator);
196  int read = 0;
197  CLHEP::HepRandomEngine* engine = (sequential_ ? nullptr : randomEngine(streamID));
198  read = input_->loopOverEvents(*eventPrincipal_, fileNameHash_, pileEventCnt, recorder, engine, &signal);
199  if (read != pileEventCnt)
200  edm::LogWarning("PileUp") << "Could not read enough pileup events: only " << read << " out of " << pileEventCnt
201  << " requested.";
202  }

References eventPrincipal_, fileNameHash_, input_, randomEngine(), readEcalDQMStatus::read, and sequential_.

◆ reload()

void edm::PileUp::reload ( const edm::EventSetup setup)

Definition at line 234 of file PileUp.cc.

235  {
236  //get the required parameters from DB.
238  setup.get<MixingRcd>().get(configM);
239 
240  const MixingInputConfig& config = configM->config(inputType_);
241 
242  //get the type
243  type_ = config.type();
244  //set booleans
245  histoDistribution_ = type_ == "histo";
246  probFunctionDistribution_ = type_ == "probFunction";
247  poisson_ = type_ == "poisson";
248  fixed_ = type_ == "fixed";
249  none_ = type_ == "none";
250 
251  if (histoDistribution_)
252  edm::LogError("MisConfiguration") << "type histo cannot be reloaded from DB, yet";
253 
254  if (fixed_) {
256  } else if (poisson_) {
257  averageNumber_ = config.averageNumber();
258  if (PoissonDistribution_) {
259  PoissonDistribution_.reset(new CLHEP::RandPoissonQ(PoissonDistribution_->engine(), averageNumber_));
260  }
261  } else if (probFunctionDistribution_) {
262  //need to reload the histogram from DB
263  const std::vector<int>& dataProbFunctionVar = config.probFunctionVariable();
264  std::vector<double> dataProb = config.probValue();
265 
266  int varSize = (int)dataProbFunctionVar.size();
267  int probSize = (int)dataProb.size();
268 
269  if ((dataProbFunctionVar[0] != 0) || (dataProbFunctionVar[varSize - 1] != (varSize - 1)))
270  throw cms::Exception("BadProbFunction")
271  << "Please, check the variables of the probability function! The first variable should be 0 and the "
272  "difference between two variables should be 1."
273  << std::endl;
274 
275  // Complete the vector containing the probability function data
276  // with the values "0"
277  if (probSize < varSize) {
278  edm::LogWarning("MixingModule") << " The probability function data will be completed with "
279  << (varSize - probSize) << " values 0.";
280 
281  for (int i = 0; i < (varSize - probSize); i++)
282  dataProb.push_back(0);
283 
284  probSize = dataProb.size();
285  edm::LogInfo("MixingModule") << " The number of the P(x) data set after adding the values 0 is " << probSize;
286  }
287 
288  // Create an histogram with the data from the probability function provided by the user
289  int xmin = (int)dataProbFunctionVar[0];
290  int xmax = (int)dataProbFunctionVar[varSize - 1] + 1; // need upper edge to be one beyond last value
291  int numBins = varSize;
292 
293  edm::LogInfo("MixingModule") << "An histogram will be created with " << numBins << " bins in the range (" << xmin
294  << "," << xmax << ")." << std::endl;
295 
296  histo_.reset(new TH1F("h", "Histo from the user's probability function", numBins, xmin, xmax));
297 
298  LogDebug("MixingModule") << "Filling histogram with the following data:" << std::endl;
299 
300  for (int j = 0; j < numBins; j++) {
301  LogDebug("MixingModule") << " x = " << dataProbFunctionVar[j] << " P(x) = " << dataProb[j];
302  histo_->Fill(dataProbFunctionVar[j] + 0.5,
303  dataProb[j]); // assuming integer values for the bins, fill bin centers, not edges
304  }
305 
306  // Check if the histogram is normalized
307  if (std::abs(histo_->Integral() - 1) > 1.0e-02) {
308  throw cms::Exception("BadProbFunction") << "The probability function should be normalized!!! " << std::endl;
309  }
310  averageNumber_ = histo_->GetMean();
311  }
312 
313  int oot = config.outOfTime();
314  manage_OOT_ = false;
315  if (oot == 1) {
316  manage_OOT_ = true;
317  poisson_OOT_ = false;
318  fixed_OOT_ = true;
319  intFixed_OOT_ = config.fixedOutOfTime();
320  } else if (oot == 2) {
321  manage_OOT_ = true;
322  poisson_OOT_ = true;
323  fixed_OOT_ = false;
324  }

References funct::abs(), averageNumber(), averageNumber_, MixingModuleConfig::config(), MillePedeFileConverter_cfg::e, Exception, fixed_, fixed_OOT_, edm::get(), histo_, histoDistribution_, mps_fire::i, inputType_, createfilelist::int, intFixed_OOT_, dqmiolumiharvest::j, LogDebug, manage_OOT_, none_, poisson_, poisson_OOT_, PoissonDistribution_, probFunctionDistribution_, singleTopDQM_cfi::setup, type_, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

◆ setupPileUpEvent()

void edm::PileUp::setupPileUpEvent ( const edm::EventSetup setup)

Definition at line 225 of file PileUp.cc.

226  {
227  if (provider_.get() != nullptr) {
228  // note: run and lumi numbers must be modified to match lumiPrincipal_
229  eventPrincipal_->setLuminosityBlockPrincipal(lumiPrincipal_.get());
230  eventPrincipal_->setRunAndLumiNumber(lumiPrincipal_->run(), lumiPrincipal_->luminosityBlock());
231  provider_->setupPileUpEvent(*eventPrincipal_, setup.impl(), *streamContext_);
232  }

References eventPrincipal_, lumiPrincipal_, provider_, singleTopDQM_cfi::setup, and streamContext_.

Member Data Documentation

◆ averageNumber_

double edm::PileUp::averageNumber_
private

Definition at line 110 of file PileUp.h.

Referenced by averageNumber(), CalculatePileup(), doPileUp(), poissonDistribution(), and reload().

◆ eventPrincipal_

std::unique_ptr<EventPrincipal> edm::PileUp::eventPrincipal_
private

Definition at line 137 of file PileUp.h.

Referenced by beginStream(), playOldFormatPileUp(), playPileUp(), readPileUp(), and setupPileUpEvent().

◆ fileNameHash_

size_t edm::PileUp::fileNameHash_
private

Definition at line 131 of file PileUp.h.

Referenced by playOldFormatPileUp(), playPileUp(), and readPileUp().

◆ fixed_

bool edm::PileUp::fixed_
private

Definition at line 116 of file PileUp.h.

Referenced by CalculatePileup(), and reload().

◆ fixed_OOT_

bool edm::PileUp::fixed_OOT_
private

Definition at line 120 of file PileUp.h.

Referenced by reload().

◆ histo_

std::shared_ptr<TH1F> edm::PileUp::histo_
private

Definition at line 112 of file PileUp.h.

Referenced by CalculatePileup(), and reload().

◆ histoDistribution_

bool edm::PileUp::histoDistribution_
private

Definition at line 113 of file PileUp.h.

Referenced by CalculatePileup(), and reload().

◆ input_

const std::unique_ptr<VectorInputSource> edm::PileUp::input_
private

◆ inputType_

unsigned int edm::PileUp::inputType_
private

Definition at line 107 of file PileUp.h.

Referenced by input(), and reload().

◆ intAverage_

const int edm::PileUp::intAverage_
private

Definition at line 111 of file PileUp.h.

Referenced by CalculatePileup().

◆ intFixed_ITPU_

int edm::PileUp::intFixed_ITPU_
private

Definition at line 126 of file PileUp.h.

Referenced by CalculatePileup().

◆ intFixed_OOT_

int edm::PileUp::intFixed_OOT_
private

Definition at line 125 of file PileUp.h.

Referenced by CalculatePileup(), and reload().

◆ lumiPrincipal_

std::shared_ptr<LuminosityBlockPrincipal> edm::PileUp::lumiPrincipal_
private

Definition at line 138 of file PileUp.h.

Referenced by setupPileUpEvent().

◆ manage_OOT_

bool edm::PileUp::manage_OOT_
private

Definition at line 118 of file PileUp.h.

Referenced by CalculatePileup(), and reload().

◆ maxBunch_cosmics_

int edm::PileUp::maxBunch_cosmics_
private

Definition at line 129 of file PileUp.h.

Referenced by doPileUp().

◆ minBunch_cosmics_

int edm::PileUp::minBunch_cosmics_
private

Definition at line 128 of file PileUp.h.

Referenced by doPileUp().

◆ none_

bool edm::PileUp::none_
private

Definition at line 117 of file PileUp.h.

Referenced by CalculatePileup(), doPileUp(), and reload().

◆ playback_

bool edm::PileUp::playback_
private

Definition at line 150 of file PileUp.h.

◆ poisson_

bool edm::PileUp::poisson_
private

Definition at line 115 of file PileUp.h.

Referenced by CalculatePileup(), poisson(), and reload().

◆ poisson_OOT_

bool edm::PileUp::poisson_OOT_
private

Definition at line 119 of file PileUp.h.

Referenced by CalculatePileup(), and reload().

◆ PoissonDistr_OOT_

std::unique_ptr<CLHEP::RandPoisson> edm::PileUp::PoissonDistr_OOT_
private

Definition at line 142 of file PileUp.h.

Referenced by poissonDistr_OOT().

◆ PoissonDistribution_

std::unique_ptr<CLHEP::RandPoissonQ> edm::PileUp::PoissonDistribution_
private

Definition at line 141 of file PileUp.h.

Referenced by poissonDistribution(), and reload().

◆ probFunctionDistribution_

bool edm::PileUp::probFunctionDistribution_
private

Definition at line 114 of file PileUp.h.

Referenced by CalculatePileup(), and reload().

◆ processConfiguration_

std::shared_ptr<ProcessConfiguration> edm::PileUp::processConfiguration_
private

Definition at line 134 of file PileUp.h.

Referenced by beginRun().

◆ processContext_

std::shared_ptr<ProcessContext> edm::PileUp::processContext_
private

Definition at line 135 of file PileUp.h.

Referenced by beginStream().

◆ productRegistry_

std::shared_ptr<ProductRegistry> edm::PileUp::productRegistry_
private

Definition at line 132 of file PileUp.h.

Referenced by beginRun(), and beginStream().

◆ provider_

std::unique_ptr<SecondaryEventProvider> edm::PileUp::provider_
private

Definition at line 140 of file PileUp.h.

Referenced by beginRun(), beginStream(), endRun(), endStream(), and setupPileUpEvent().

◆ PU_Study_

bool edm::PileUp::PU_Study_
private

Definition at line 122 of file PileUp.h.

Referenced by CalculatePileup().

◆ randomEngine_

CLHEP::HepRandomEngine* edm::PileUp::randomEngine_
private

Definition at line 143 of file PileUp.h.

Referenced by randomEngine().

◆ runPrincipal_

std::shared_ptr<RunPrincipal> edm::PileUp::runPrincipal_
private

Definition at line 139 of file PileUp.h.

Referenced by beginRun(), and endRun().

◆ sequential_

bool edm::PileUp::sequential_
private

Definition at line 153 of file PileUp.h.

Referenced by readPileUp().

◆ Source_type_

std::string edm::PileUp::Source_type_
private

Definition at line 109 of file PileUp.h.

Referenced by doPileUp().

◆ streamContext_

std::shared_ptr<StreamContext> edm::PileUp::streamContext_
private

Definition at line 136 of file PileUp.h.

Referenced by beginRun(), beginStream(), endRun(), endStream(), and setupPileUpEvent().

◆ Study_type_

std::string edm::PileUp::Study_type_
private

Definition at line 123 of file PileUp.h.

Referenced by CalculatePileup().

◆ type_

std::string edm::PileUp::type_
private
edm::PileUp::minBunch_cosmics_
int minBunch_cosmics_
Definition: PileUp.h:128
edm::PileUp::processContext_
std::shared_ptr< ProcessContext > processContext_
Definition: PileUp.h:135
electrons_cff.bool
bool
Definition: electrons_cff.py:372
MixingRcd
Definition: MixingRcd.h:24
mps_fire.i
i
Definition: mps_fire.py:355
GetRandom
static Double_t GetRandom(TH1 *th1, CLHEP::HepRandomEngine *rng)
Definition: PileUp.cc:48
funct::false
false
Definition: Factorize.h:34
edm::PileUp::intAverage_
const int intAverage_
Definition: PileUp.h:111
edm::PileUp::randomEngine
CLHEP::HepRandomEngine * randomEngine(StreamID const &streamID)
Definition: PileUp.cc:343
edm::PileUp::fixed_OOT_
bool fixed_OOT_
Definition: PileUp.h:120
dqmPostProcessing_online.DB
DB
Definition: dqmPostProcessing_online.py:11
edm::PileUp::PileUp
PileUp(ParameterSet const &pset, const std::shared_ptr< PileUpConfig > &config)
Definition: PileUp.cc:66
edm::PileUp::streamContext_
std::shared_ptr< StreamContext > streamContext_
Definition: PileUp.h:136
edm::PileUp::poissonDistr_OOT
std::unique_ptr< CLHEP::RandPoisson > const & poissonDistr_OOT(StreamID const &streamID)
Definition: PileUp.cc:335
edm::PileUp::probFunctionDistribution_
bool probFunctionDistribution_
Definition: PileUp.h:114
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::PileUp::poisson_
bool poisson_
Definition: PileUp.h:115
edm::LogInfo
Definition: MessageLogger.h:254
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
edm::PileUp::processConfiguration_
std::shared_ptr< ProcessConfiguration > processConfiguration_
Definition: PileUp.h:134
edm::PileUp::inputType_
unsigned int inputType_
Definition: PileUp.h:107
edm::PileUp::fixed_
bool fixed_
Definition: PileUp.h:116
edm::PileUp::maxBunch_cosmics_
int maxBunch_cosmics_
Definition: PileUp.h:129
edm::PileUp::randomEngine_
CLHEP::HepRandomEngine * randomEngine_
Definition: PileUp.h:143
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::PileUp::PU_Study_
bool PU_Study_
Definition: PileUp.h:122
edm::getPassID
std::string getPassID()
Definition: GetPassID.h:7
edm::PileUp::intFixed_OOT_
int intFixed_OOT_
Definition: PileUp.h:125
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
end
#define end
Definition: vmac.h:39
MixingModuleConfig::config
const MixingInputConfig & config(unsigned int i=0) const
Definition: MixingModuleConfig.h:76
mix_2012_lumiLevel_15_20_50ns_PoissonOOTPU_cfi.OOT_type
OOT_type
manage out-of-time pileup setting this to True means that the out-of-time pileup will have a differen...
Definition: mix_2012_lumiLevel_15_20_50ns_PoissonOOTPU_cfi.py:59
config
Definition: config.py:1
HLT_2018_cff.producers
producers
Definition: HLT_2018_cff.py:11702
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::PileUp::sequential_
bool sequential_
Definition: PileUp.h:153
edm::PileUp::none_
bool none_
Definition: PileUp.h:117
edm::ESHandle
Definition: DTSurvey.h:22
edm::PileUp::poisson_OOT_
bool poisson_OOT_
Definition: PileUp.h:119
Service
edm::PileUp::fileNameHash_
size_t fileNameHash_
Definition: PileUp.h:131
edm::PileUp::averageNumber_
double averageNumber_
Definition: PileUp.h:110
edm::PileUp::averageNumber
double averageNumber() const
Definition: PileUp.h:64
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
edm::PileUp::runPrincipal_
std::shared_ptr< RunPrincipal > runPrincipal_
Definition: PileUp.h:139
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
ParameterSet
Definition: Functions.h:16
edm::PileUp::eventPrincipal_
std::unique_ptr< EventPrincipal > eventPrincipal_
Definition: PileUp.h:137
edm::PileUp::PoissonDistr_OOT_
std::unique_ptr< CLHEP::RandPoisson > PoissonDistr_OOT_
Definition: PileUp.h:142
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
printConversionInfo.aux
aux
Definition: printConversionInfo.py:19
edm::Service< edm::RandomNumberGenerator >
createfilelist.int
int
Definition: createfilelist.py:10
edm::PileUp::type_
std::string type_
Definition: PileUp.h:108
edm::PileUp::productRegistry_
std::shared_ptr< ProductRegistry > productRegistry_
Definition: PileUp.h:132
edm::PileUp::Source_type_
std::string Source_type_
Definition: PileUp.h:109
edm::PileUp::histo_
std::shared_ptr< TH1F > histo_
Definition: PileUp.h:112
edm::PileUp::manage_OOT_
bool manage_OOT_
Definition: PileUp.h:118
edm::PileUp::input_
const std::unique_ptr< VectorInputSource > input_
Definition: PileUp.h:133
readEcalDQMStatus.read
read
Definition: readEcalDQMStatus.py:38
SignallingProductRegistry
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
edm::getReleaseVersion
std::string getReleaseVersion()
Definition: GetReleaseVersion.cc:7
Exception
Definition: hltDiff.cc:246
edm::PileUp::poissonDistribution
std::unique_ptr< CLHEP::RandPoissonQ > const & poissonDistribution(StreamID const &streamID)
Definition: PileUp.cc:327
edm::PileUp::intFixed_ITPU_
int intFixed_ITPU_
Definition: PileUp.h:126
L1TStage2uGTEmulatorClient_cff.BX
BX
Definition: L1TStage2uGTEmulatorClient_cff.py:9
edm::PileUp::provider_
std::unique_ptr< SecondaryEventProvider > provider_
Definition: PileUp.h:140
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::PileUp::PoissonDistribution_
std::unique_ptr< CLHEP::RandPoissonQ > PoissonDistribution_
Definition: PileUp.h:141
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
MixingInputConfig
Definition: MixingModuleConfig.h:14
lumi
Definition: LumiSectionData.h:20
begin
#define begin
Definition: vmac.h:32
edm::PileUp::Study_type_
std::string Study_type_
Definition: PileUp.h:123
edm::PileUp::histoDistribution_
bool histoDistribution_
Definition: PileUp.h:113
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::PileUp::playback_
bool playback_
Definition: PileUp.h:150
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::PileUp::lumiPrincipal_
std::shared_ptr< LuminosityBlockPrincipal > lumiPrincipal_
Definition: PileUp.h:138