|
|
Go to the documentation of this file.
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);
232 using namespace std::placeholders;
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 endRun(const edm::Run &r, const edm::EventSetup &setup) override
std::vector< std::shared_ptr< PileUp > > inputSources_
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
static const std::string source("source")
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int getBunchSpacing() const
void beginLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
void setupPileUpEvent(const edm::EventSetup &setup)
~PreMixingModule() override=default
void put(edm::Event &e, const edm::EventSetup &ES) override
void checkSignal(const edm::Event &e) override
void putPileupInfo(edm::Event &e)
std::vector< float > TrueNumInteractions_
def create(alignables, pedeDump, additionalData, outputFile, config)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< std::unique_ptr< PreMixingWorker > > workers_
Log< level::Warning, false > LogWarning
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
edm::RunNumber_t firstRun() const
std::vector< double > pileupProbabilities_
void createnewEDProduct() override
#define DEFINE_FWK_MODULE(type)
const std::string names[nVars_]
std::vector< AdjustPileupDistribution > pileupAdjusters_
const static unsigned int maxNbSources_
float getTrueNumInteractions(PileUpEventPrincipal const &pep) const
PreMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
void addSignals(const edm::Event &e, const edm::EventSetup &ES) override
const std::vector< PileupSummaryInfo > & getPileupSummaryInfo() const
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 >
double probability(float pileup) const
void addPileupInfo(PileUpEventPrincipal const &pep)
PreMixingPileupCopy puWorker_
void doPileUp(edm::Event &e, const edm::EventSetup &ES) override
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
AdjustPileupDistribution(const edm::ParameterSet &ps)
edm::RunNumber_t firstRun_
void initializeEvent(edm::Event const &e, edm::EventSetup const &eventSetup) override
bool pileWorker(const edm::EventPrincipal &, int bcr, int EventId, const edm::EventSetup &ES, ModuleCallingContext const *, AdjustPileupDistribution const *pileupAdjuster)
void endLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
unsigned int firstBinPileup_
void beginRun(edm::Run const &run, edm::EventSetup const &eventSetup) override
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override