|
|
Go to the documentation of this file.
23 std::shared_ptr<edm::PileUpConfig> maybeConfigPileUp(
25 std::shared_ptr<edm::PileUpConfig> pileupconfig;
27 if (ps.
exists(sourceName)) {
33 std::unique_ptr<TH1F>
h(
new TH1F(
"h",
"h", 10, 0, 10));
34 std::vector<int> dataProbFunctionVar;
35 std::vector<double> dataProb;
41 edm::LogError(
"BMixingModule") <<
"Will read from DB: reset to a dummy PileUp object.";
42 std::unique_ptr<TH1F>
h;
46 if (type_ !=
"none") {
47 if (psin.
exists(
"nbPileupEvents")) {
49 if (psin_average.
exists(
"averageNumber")) {
53 }
else if (psin_average.
exists(
"fileName") && psin_average.
exists(
"histoName")) {
66 <<
"Open a root file " <<
histoFileName <<
" containing the probability distribution histogram "
69 <<
"The PileUp number to be added will be chosen randomly from this histogram" << std::endl;
74 throw cms::Exception(
"BadHistoDistribution") <<
"The histogram should be normalized!" << std::endl;
82 }
else if (psin_average.
exists(
"probFunctionVariable") && psin_average.
exists(
"probValue") &&
83 psin_average.
exists(
"histoFileName")) {
84 if (type_ !=
"probFunction") {
86 <<
"type is set to: " << type_ <<
" while parameters implies probFunction; changing.";
87 type_ =
"probFunction";
90 dataProbFunctionVar = psin_average.
getParameter<std::vector<int> >(
"probFunctionVariable");
91 dataProb = psin_average.
getParameter<std::vector<double> >(
"probValue");
94 int varSize = (
int)dataProbFunctionVar.size();
95 int probSize = (
int)dataProb.size();
97 if ((dataProbFunctionVar[0] != 0) || (dataProbFunctionVar[varSize - 1] != (varSize - 1)))
99 <<
"Please, check the variables of the probability function! The first variable should be 0 and the "
100 "difference between two variables should be 1."
105 if (probSize < varSize) {
107 <<
" The probability function data will be completed with " << (varSize - probSize) <<
" values 0.";
109 for (
int i = 0;
i < (varSize - probSize);
i++)
110 dataProb.push_back(0);
112 probSize = dataProb.size();
114 <<
" The number of the P(x) data set after adding the values 0 is " << probSize;
118 int xmin = (
int)dataProbFunctionVar[0];
119 int xmax = (
int)dataProbFunctionVar[varSize - 1] + 1;
120 int numBins = varSize;
122 edm::LogInfo(
"MixingModule") <<
"An histogram will be created with " << numBins <<
" bins in the range ("
123 <<
xmin <<
"," <<
xmax <<
")." << std::endl;
125 std::unique_ptr<TH1F> hprob(
126 new TH1F(
"h",
"Histo from the user's probability function", numBins,
xmin,
xmax));
128 LogDebug(
"MixingModule") <<
"Filling histogram with the following data:" << std::endl;
130 for (
int j = 0;
j < numBins;
j++) {
131 LogDebug(
"MixingModule") <<
" x = " << dataProbFunctionVar[
j] <<
" P(x) = " << dataProb[
j];
132 hprob->Fill(dataProbFunctionVar[
j] + 0.5,
137 if (
std::abs(hprob->Integral() - 1) > 1.0
e-02) {
139 <<
"The probability function should be normalized!!! " << std::endl;
146 <<
" The histogram created from the x, P(x) values will be written into the root file "
159 else if (sourceName ==
"input" && psin_average.
exists(
"Lumi") && psin_average.
exists(
"sigmaInel")) {
161 ps.
getParameter<
int>(
"bunchspace") / 1000 * 3564. / 2808.;
163 edm::LogInfo(
"MixingModule") <<
" Created source " << sourceName <<
" with minBunch,maxBunch " << minb
178 : bunchSpace_(globalConf->bunchSpace_),
180 minBunch_(globalConf->minBunch_),
181 maxBunch_(globalConf->maxBunch_),
182 mixProdStep1_(
pset.getParameter<
bool>(
"mixProdStep1")),
183 mixProdStep2_(
pset.getParameter<
bool>(
"mixProdStep2")),
185 playback_(globalConf->playback_) {
186 if (
pset.exists(
"readDB"))
189 for (
size_t makeIdx = 0; makeIdx <
maxNbSources_; makeIdx++) {
204 namespace MixingCache {
206 : bunchSpace_(
pset.getParameter<
int>(
"bunchspace")),
207 minBunch_((
pset.getParameter<
int>(
"minBunch") * 25) / bunchSpace_),
208 maxBunch_((
pset.getParameter<
int>(
"maxBunch") * 25) / bunchSpace_),
209 playback_(
pset.getUntrackedParameter<
bool>(
"playback",
false)) {
212 LogInfo(
"MixingModule") <<
" ATTENTION:Mixing will be done in playback mode! \n"
213 <<
" ATTENTION:Mixing Configuration must be the same as for the original mixing!";
222 for (
size_t makeIdx = 0; makeIdx < maxNbSources; makeIdx++) {
265 for (
size_t makeIdx = 0; makeIdx <
maxNbSources_; makeIdx++) {
299 for (
size_t dropIdx = 0; dropIdx <
maxNbSources_; ++dropIdx) {
306 for (
size_t dropIdx = 0; dropIdx <
maxNbSources_; ++dropIdx) {
308 inputSources_[dropIdx]->dropUnwantedBranches(wantedBranches);
327 edm::LogWarning(
"MixingModule") <<
"BMixingModule::createnewEDProduct must be overwritten!";
331 edm::LogWarning(
"MixingModule") <<
"BMixingModule::checkSignal must be overwritten!";
335 edm::LogWarning(
"MixingModule") <<
"BMixingModule::setBcrOffset must be overwritten!";
339 edm::LogWarning(
"MixingModule") <<
"BMixingModule::setSourceOffset must be overwritten!";
343 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)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
T getUntrackedParameter(std::string const &, T const &) const
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)
virtual void addSignals(const edm::Event &e, const edm::EventSetup &c)
T getParameter(std::string const &) const
virtual void initializeEvent(const edm::Event &event, const edm::EventSetup &setup)
virtual void createnewEDProduct()
BMixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
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)