|
|
Go to the documentation of this file.
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")),
187 playback_(globalConf->playback_) {
188 if (
pset.exists(
"readDB"))
191 for (
size_t makeIdx = 0; makeIdx <
maxNbSources_; makeIdx++) {
206 namespace MixingCache {
208 : bunchSpace_(
pset.getParameter<
int>(
"bunchspace")),
209 minBunch_((
pset.getParameter<
int>(
"minBunch") * 25) / bunchSpace_),
210 maxBunch_((
pset.getParameter<
int>(
"maxBunch") * 25) / bunchSpace_),
211 playback_(
pset.getUntrackedParameter<
bool>(
"playback",
false)) {
214 LogInfo(
"MixingModule") <<
" ATTENTION:Mixing will be done in playback mode! \n"
215 <<
" ATTENTION:Mixing Configuration must be the same as for the original mixing!";
224 for (
size_t makeIdx = 0; makeIdx < maxNbSources; makeIdx++) {
267 for (
size_t makeIdx = 0; makeIdx <
maxNbSources_; makeIdx++) {
301 for (
size_t dropIdx = 0; dropIdx <
maxNbSources_; ++dropIdx) {
308 for (
size_t dropIdx = 0; dropIdx <
maxNbSources_; ++dropIdx) {
310 inputSources_[dropIdx]->dropUnwantedBranches(wantedBranches);
329 edm::LogWarning(
"MixingModule") <<
"BMixingModule::createnewEDProduct must be overwritten!";
333 edm::LogWarning(
"MixingModule") <<
"BMixingModule::checkSignal must be overwritten!";
337 edm::LogWarning(
"MixingModule") <<
"BMixingModule::setBcrOffset must be overwritten!";
341 edm::LogWarning(
"MixingModule") <<
"BMixingModule::setSourceOffset must be overwritten!";
345 edm::LogWarning(
"MixingModule") <<
"BMixingModule::doPileUp must be overwritten!";
virtual void reload(const edm::EventSetup &setup)
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
bool check(const edm::EventSetup &iSetup)
std::vector< std::shared_ptr< PileUp > > inputSources_
std::vector< std::string > sourceNames_
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void setupPileUpEvent(const edm::EventSetup &setup)
T getUntrackedParameter(std::string const &, T const &) const
Log< level::Info, false > LogInfo
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Log< level::Warning, false > LogWarning
virtual void setSourceOffset(const unsigned int s)
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
Config(edm::ParameterSet const &pset, unsigned int maxNbSources)
void endStream() override
const static unsigned int maxNbSources_
void update(edm::EventSetup const &)
virtual void finalizeEvent(edm::Event &event, const edm::EventSetup &setup)
virtual void checkSignal(const edm::Event &e)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void produce(edm::Event &e1, const edm::EventSetup &c) override
~BMixingModule() override
void beginStream(edm::StreamID) override
virtual void put(edm::Event &e, const edm::EventSetup &c)
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
Log< level::Error, false > LogError
virtual void addSignals(const edm::Event &e, const edm::EventSetup &c)
virtual void initializeEvent(const edm::Event &event, const edm::EventSetup &setup)
virtual void createnewEDProduct()
BMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
T getParameter(std::string const &) const
std::vector< std::shared_ptr< PileUpConfig > > inputConfigs_
edm::ESWatcher< MixingRcd > parameterWatcher_
Abs< T >::type abs(const T &t)
virtual void setBcrOffset()
static std::unique_ptr< MixingCache::Config > initializeGlobalCache(edm::ParameterSet const &)
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
virtual void doPileUp(edm::Event &e, const edm::EventSetup &c)