25 std::shared_ptr<edm::PileUpConfig> maybeConfigPileUp(
27 std::shared_ptr<edm::PileUpConfig> pileupconfig;
29 if (ps.
exists(sourceName)) {
35 std::unique_ptr<TH1F>
h(
new TH1F(
"h",
"h", 10, 0, 10));
36 std::vector<int> dataProbFunctionVar;
37 std::vector<double> dataProb;
43 edm::LogError(
"BMixingModule") <<
"Will read from DB: reset to a dummy PileUp object.";
44 std::unique_ptr<TH1F>
h;
48 if (type_ !=
"none") {
49 if (psin.
exists(
"nbPileupEvents")) {
51 if (psin_average.
exists(
"averageNumber")) {
55 }
else if (psin_average.
exists(
"fileName") && psin_average.
exists(
"histoName")) {
68 <<
"Open a root file " <<
histoFileName <<
" containing the probability distribution histogram " 71 <<
"The PileUp number to be added will be chosen randomly from this histogram" << std::endl;
76 throw cms::Exception(
"BadHistoDistribution") <<
"The histogram should be normalized!" << std::endl;
84 }
else if (psin_average.
exists(
"probFunctionVariable") && psin_average.
exists(
"probValue") &&
85 psin_average.
exists(
"histoFileName")) {
86 if (type_ !=
"probFunction") {
88 <<
"type is set to: " << type_ <<
" while parameters implies probFunction; changing.";
89 type_ =
"probFunction";
92 dataProbFunctionVar = psin_average.
getParameter<std::vector<int> >(
"probFunctionVariable");
93 dataProb = psin_average.
getParameter<std::vector<double> >(
"probValue");
96 int varSize = (
int)dataProbFunctionVar.size();
97 int probSize = (
int)dataProb.size();
99 if ((dataProbFunctionVar[0] != 0) || (dataProbFunctionVar[varSize - 1] != (varSize - 1)))
101 <<
"Please, check the variables of the probability function! The first variable should be 0 and the " 102 "difference between two variables should be 1." 107 if (probSize < varSize) {
109 <<
" The probability function data will be completed with " << (varSize - probSize) <<
" values 0.";
111 for (
int i = 0;
i < (varSize - probSize);
i++)
112 dataProb.push_back(0);
114 probSize = dataProb.size();
116 <<
" The number of the P(x) data set after adding the values 0 is " << probSize;
120 int xmin = (
int)dataProbFunctionVar[0];
121 int xmax = (
int)dataProbFunctionVar[varSize - 1] + 1;
122 int numBins = varSize;
124 edm::LogInfo(
"MixingModule") <<
"An histogram will be created with " << numBins <<
" bins in the range (" 125 <<
xmin <<
"," <<
xmax <<
")." << std::endl;
127 std::unique_ptr<TH1F> hprob(
128 new TH1F(
"h",
"Histo from the user's probability function", numBins,
xmin,
xmax));
130 LogDebug(
"MixingModule") <<
"Filling histogram with the following data:" << std::endl;
132 for (
int j = 0;
j < numBins;
j++) {
133 LogDebug(
"MixingModule") <<
" x = " << dataProbFunctionVar[
j] <<
" P(x) = " << dataProb[
j];
134 hprob->Fill(dataProbFunctionVar[
j] + 0.5,
139 if (
std::abs(hprob->Integral() - 1) > 1.0
e-02) {
141 <<
"The probability function should be normalized!!! " << std::endl;
148 <<
" The histogram created from the x, P(x) values will be written into the root file " 161 else if (sourceName ==
"input" && psin_average.
exists(
"Lumi") && psin_average.
exists(
"sigmaInel")) {
163 ps.
getParameter<
int>(
"bunchspace") / 1000 * 3564. / 2808.;
165 edm::LogInfo(
"MixingModule") <<
" Created source " << sourceName <<
" with minBunch,maxBunch " << minb
180 : bunchSpace_(globalConf->bunchSpace_),
182 minBunch_(globalConf->minBunch_),
183 maxBunch_(globalConf->maxBunch_),
184 mixProdStep1_(
pset.getParameter<
bool>(
"mixProdStep1")),
185 mixProdStep2_(
pset.getParameter<
bool>(
"mixProdStep2")),
186 readDB_(globalConf->configFromDB_),
187 playback_(globalConf->playback_) {
188 for (
size_t makeIdx = 0; makeIdx <
maxNbSources_; makeIdx++) {
193 std::make_shared<PileUp>(psin, globalConf->
inputConfigs_[makeIdx], consumesCollector(),
readDB_));
211 namespace MixingCache {
213 : bunchSpace_(
pset.getParameter<
int>(
"bunchspace")),
214 minBunch_((
pset.getParameter<
int>(
"minBunch") * 25) / bunchSpace_),
215 maxBunch_((
pset.getParameter<
int>(
"maxBunch") * 25) / bunchSpace_),
216 playback_(
pset.getUntrackedParameter<
bool>(
"playback",
false)) {
219 LogInfo(
"MixingModule") <<
" ATTENTION:Mixing will be done in playback mode! \n" 220 <<
" ATTENTION:Mixing Configuration must be the same as for the original mixing!";
229 for (
size_t makeIdx = 0; makeIdx < maxNbSources; makeIdx++) {
233 if (
pset.exists(
"readDB"))
274 for (
size_t makeIdx = 0; makeIdx <
maxNbSources_; makeIdx++) {
308 for (
size_t dropIdx = 0; dropIdx <
maxNbSources_; ++dropIdx) {
315 for (
size_t dropIdx = 0; dropIdx <
maxNbSources_; ++dropIdx) {
317 inputSources_[dropIdx]->dropUnwantedBranches(wantedBranches);
336 edm::LogWarning(
"MixingModule") <<
"BMixingModule::createnewEDProduct must be overwritten!";
340 edm::LogWarning(
"MixingModule") <<
"BMixingModule::checkSignal must be overwritten!";
344 edm::LogWarning(
"MixingModule") <<
"BMixingModule::setBcrOffset must be overwritten!";
348 edm::LogWarning(
"MixingModule") <<
"BMixingModule::setSourceOffset must be overwritten!";
352 edm::LogWarning(
"MixingModule") <<
"BMixingModule::doPileUp must be overwritten!";
edm::ESWatcher< MixingRcd > parameterWatcher_
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
T getParameter(std::string const &) const
static std::unique_ptr< MixingCache::Config > initializeGlobalCache(edm::ParameterSet const &)
virtual void addSignals(const edm::Event &e, const edm::EventSetup &c)
void produce(edm::Event &e1, const edm::EventSetup &c) override
virtual void finalizeEvent(edm::Event &event, const edm::EventSetup &setup)
std::vector< std::string > sourceNames_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual void checkSignal(const edm::Event &e)
void endStream() override
Log< level::Error, false > LogError
virtual void put(edm::Event &e, const edm::EventSetup &c)
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
virtual void setBcrOffset()
T getUntrackedParameter(std::string const &, T const &) const
virtual void createnewEDProduct()
virtual void setSourceOffset(const unsigned int s)
virtual void doPileUp(edm::Event &e, const edm::EventSetup &c)
virtual void initializeEvent(const edm::Event &event, const edm::EventSetup &setup)
Config(edm::ParameterSet const &pset, unsigned int maxNbSources)
void beginStream(edm::StreamID) override
Abs< T >::type abs(const T &t)
static const unsigned int maxNbSources_
virtual void reload(const edm::EventSetup &setup)
Log< level::Info, false > LogInfo
~BMixingModule() override
bool check(const edm::EventSetup &iSetup)
std::vector< std::shared_ptr< PileUp > > inputSources_
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
Log< level::Warning, false > LogWarning
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void update(edm::EventSetup const &)
std::vector< std::shared_ptr< PileUpConfig > > inputConfigs_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void setupPileUpEvent(const edm::EventSetup &setup)
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void registerLateConsumes(eventsetup::ESRecordsToProxyIndices const &) override
BMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)