34 #include <CLHEP/Random/RandomEngine.h> 67 if(p < 0. or p > 1.) {
68 throw cms::Exception(
"Configuration") <<
"Invalid probability value " <<
p <<
" for firstRun " <<
firstRun_ <<
". The probability must be >= 0. and <= 1.";
75 unsigned int bin =
static_cast<unsigned int>(
pileup);
95 std::vector<std::unique_ptr<PreMixingWorker> >
workers_;
105 [](
const auto&
a,
const auto&
b) {
106 return a.firstRun() <
b.firstRun();
110 std::vector<std::string>
names = workers.getParameterNames();
116 std::vector<std::string>
tmp;
119 if(
i != names.end()) {
128 std::copy(names.begin(), names.end(), std::back_inserter(tmp));
132 for(
const auto&
name: names) {
133 if(
name ==
"pileup") {
145 w->initializeEvent(e, ES);
153 w->beginRun(run, ES);
167 LogDebug(
"PreMixingModule")<<
"===============> adding MC signals for "<<e.
id();
170 w->addSignals(e, ES);
187 double prob = pileupAdjuster->
probability(static_cast<unsigned int>(trueNumInteractions));
190 if(engine.flat() >
prob) {
198 LogDebug(
"PreMixingModule") <<
"\n===============> adding pileups from event "<<ep.
id()<<
" for bunchcrossing "<<bcr;
214 w->addPileups(pep, ES);
224 std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
225 std::vector<int> PileupList;
237 return elem.firstRun() <= iRun;
240 throw cms::Exception(
"LogicError") <<
"Encountered run " << e.
id().
run() <<
", but the first run available in the pileup adjustment configuration is " 241 <<
pileupAdjusters_.front().firstRun() <<
". Please fix the configuration.";
243 pileupAdjuster = &*it;
247 for (
unsigned int isource=0;isource<
maxNbSources_;++isource) {
249 if (!source || !(source->doPileUp(bunchCrossing)))
255 int NumPU_Events = 0;
257 NumPU_Events = PileupList[bunchCrossing -
minBunch_];
264 w->initializeBunchCrossing(e, ES, bunchCrossing);
271 _1, bunchCrossing, _2, std::cref(ES), mcc, pileupAdjuster),
276 for(
auto&
w: workers_) {
277 w->finalizeBunchCrossing(e, ES, bunchCrossing);
290 w->put(e, ES, ps, bunchSpacing);
299 w->beginLuminosityBlock(l1,c);
void createnewEDProduct() override
std::vector< double > pileupProbabilities_
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
static std::string const source("source")
def create(alignables, pedeDump, additionalData, outputFile, config)
edm::RunNumber_t firstRun() const
std::vector< float > TrueNumInteractions_
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
EventID const & id() const
def setup(process, global_tag, zero_tesla=False)
void beginRun(edm::Run const &run, edm::EventSetup const &eventSetup) override
void putPileupInfo(edm::Event &e)
edm::RunNumber_t firstRun_
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)
ModuleCallingContext const * moduleCallingContext() const
#define DEFINE_FWK_MODULE(type)
AdjustPileupDistribution(const edm::ParameterSet &ps)
StreamID streamID() const
void put(edm::Event &e, const edm::EventSetup &ES) override
double probability(float pileup) const
static const unsigned int maxNbSources_
def elem(elemtype, innerHTML='', html_class='', kwargs)
bin
set the eta bin as selection string.
void beginLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
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 >
float getTrueNumInteractions(PileUpEventPrincipal const &pep) const
std::vector< std::vector< double > > tmp
int getBunchSpacing() 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
StreamID streamID() const
std::vector< AdjustPileupDistribution > pileupAdjusters_
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
PreMixingPileupCopy puWorker_
const std::vector< PileupSummaryInfo > & getPileupSummaryInfo() const
void setupPileUpEvent(const edm::EventSetup &setup)
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
T get(const Candidate &c)
PreMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
void doPileUp(edm::Event &e, const edm::EventSetup &ES) override