33 #include <CLHEP/Random/RandomEngine.h> 65 if (p < 0. or p > 1.) {
67 <<
". The probability must be >= 0. and <= 1.";
74 unsigned int bin =
static_cast<unsigned int>(
pileup);
77 <<
"Got pileup event with true pileup " <<
pileup 78 <<
" that is outside of the configured pileup adjustment bounds [" <<
firstBinPileup_ <<
", " 102 std::vector<std::unique_ptr<PreMixingWorker>>
workers_;
109 consumesCollector()),
114 return a.firstRun() <
b.firstRun();
118 std::vector<std::string>
names =
workers.getParameterNames();
124 std::vector<std::string>
tmp;
141 if (
name ==
"pileup") {
153 w->initializeEvent(
e, ES);
160 w->beginRun(
run, ES);
174 LogDebug(
"PreMixingModule") <<
"===============> adding MC signals for " <<
e.id();
177 w->addSignals(
e, ES);
196 if (pileupAdjuster) {
198 double prob = pileupAdjuster->
probability(static_cast<unsigned int>(trueNumInteractions));
200 CLHEP::HepRandomEngine& engine = rng->
getEngine(
ep.streamID());
201 if (engine.flat() >
prob) {
208 LogDebug(
"PreMixingModule") <<
"\n===============> adding pileups from event " <<
ep.id() <<
" for bunchcrossing " 225 w->addPileups(pep, ES);
234 std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
235 std::vector<int> PileupList;
247 [iRun =
e.id().run()](
const auto& elem) {
return elem.firstRun() <= iRun; });
249 throw cms::Exception(
"LogicError") <<
"Encountered run " <<
e.id().run()
250 <<
", but the first run available in the pileup adjustment configuration is " 251 <<
pileupAdjusters_.front().firstRun() <<
". Please fix the configuration.";
253 pileupAdjuster = &*it;
257 for (
unsigned int isource = 0; isource <
maxNbSources_; ++isource) {
265 int NumPU_Events = 0;
267 NumPU_Events = PileupList[bunchCrossing -
minBunch_];
274 w->initializeBunchCrossing(
e, ES, bunchCrossing);
286 w->finalizeBunchCrossing(
e, ES, bunchCrossing);
308 w->beginLuminosityBlock(l1,
c);
void createnewEDProduct() override
std::vector< double > pileupProbabilities_
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
int getBunchSpacing() const
static std::string const source("source")
def create(alignables, pedeDump, additionalData, outputFile, config)
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
void beginRun(edm::Run const &run, edm::EventSetup const &eventSetup) override
void putPileupInfo(edm::Event &e)
edm::RunNumber_t firstRun_
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const std::string names[nVars_]
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
bool pileWorker(const edm::EventPrincipal &, int bcr, int EventId, const edm::EventSetup &ES, ModuleCallingContext const *, AdjustPileupDistribution const *pileupAdjuster)
unsigned int firstBinPileup_
void initializeEvent(edm::Event const &e, edm::EventSetup const &eventSetup) override
void endLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
void addPileupInfo(PileUpEventPrincipal const &pep)
const std::vector< PileupSummaryInfo > & getPileupSummaryInfo() const
AdjustPileupDistribution(const edm::ParameterSet &ps)
void put(edm::Event &e, const edm::EventSetup &ES) override
static const unsigned int maxNbSources_
#define DEFINE_FWK_MODULE(type)
std::vector< float > TrueNumInteractions_
double probability(float pileup) const
void beginLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
float getTrueNumInteractions(PileUpEventPrincipal const &pep) const
edm::RunNumber_t firstRun() const
~PreMixingModule() override=default
std::vector< std::shared_ptr< PileUp > > inputSources_
std::vector< std::unique_ptr< PreMixingWorker > > workers_
void checkSignal(const edm::Event &e) override
void addSignals(const edm::Event &e, const edm::EventSetup &ES) override
std::tuple< uint32_t, uint32_t, uint32_t > EventId
Event index (L1A/BX/orbit)
std::vector< AdjustPileupDistribution > pileupAdjusters_
Log< level::Warning, false > LogWarning
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
PreMixingPileupCopy puWorker_
void setupPileUpEvent(const edm::EventSetup &setup)
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
PreMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
void doPileUp(edm::Event &e, const edm::EventSetup &ES) override