12 #include "CLHEP/Random/RandPoissonQ.h"
13 #include "CLHEP/Random/RandFlat.h"
23 type_(pset.getParameter<std::string>(
"type")),
26 averageNumber_(averageNumber),
27 intAverage_(static_cast<int>(averageNumber)),
29 histoDistribution_(type_ ==
"histo"),
30 probFunctionDistribution_(type_ ==
"probFunction"),
31 poisson_(type_ ==
"poisson"),
32 fixed_(type_ ==
"fixed"),
33 none_(type_ ==
"none"),
35 poissonDistribution_(0),
37 sequential_(pset.getUntrackedParameter<bool>(
"sequential",
false)),
38 seed_(pset.getParameter<edm::
ParameterSet>(
"nbPileupEvents").getUntrackedParameter<int>(
"seed",1234))
45 <<
"PileUp requires the RandomNumberGeneratorService\n"
46 "which is not present in the configuration file. You must add the service\n"
47 "in the configuration file or remove the modules that require it.";
50 CLHEP::HepRandomEngine& engine = rng->
getEngine();
55 gRandom->SetSeed(
seed_);
56 LogInfo(
"MixingModule") <<
" Change seed for " <<
type_ <<
" mode. The seed is set to " <<
seed_;
61 throw cms::Exception(
"Illegal parameter value",
"PileUp::PileUp(ParameterSet const& pset)")
62 <<
"'type' parameter (a string) has a value of '" <<
type_ <<
"'.\n"
63 <<
"Legal values are 'poisson', 'fixed', or 'none'\n";
71 <<
" manage_OOT option not allowed with playback ";
75 if(OOT_type ==
"Poisson" || OOT_type ==
"poisson") {
79 else if(OOT_type ==
"Fixed" || OOT_type ==
"fixed") {
84 throw cms::Exception(
"Illegal parameter value",
"PileUp::PileUp(ParameterSet const& pset)")
85 <<
" Fixed out-of-time pileup requested, but no fixed value given ";
89 throw cms::Exception(
"Illegal parameter value",
"PileUp::PileUp(ParameterSet const& pset)")
90 <<
"'OOT_type' parameter (a string) has a value of '" << OOT_type <<
"'.\n"
91 <<
"Legal values are 'poisson' or 'fixed'\n";
93 edm::LogInfo(
"MixingModule") <<
" Out-of-time pileup will be generated with a " << OOT_type <<
" distribution. " ;
108 std::vector<int>
nint;
113 int nzero_crossing = -1;
123 double d =
histo_->GetRandom();
125 nzero_crossing = int(d);
156 double d =
histo_->GetRandom();
158 nint.push_back(
int(d) );
171 eventVector.reserve(n);
174 oneResult.reserve(n);
175 std::vector<edm::EventID> oneResultPlayback;
176 oneResultPlayback.reserve(n);
182 for (
int j=0;
j<(int)oneResult.size();
j++){
183 oneResultPlayback.push_back(oneResult[
j]->
id());
189 for (
int j=0;
j<(int)oneResult.size();
j++){
190 oneResultPlayback.push_back(oneResult[
j]->
id());
194 LogDebug(
"readPileup") <<
"READ: " << oneResult.size();
195 std::copy(oneResult.begin(), oneResult.end(), std::back_inserter(eventVector));
196 n -= oneResult.size();
198 result.push_back(eventVector);
T getUntrackedParameter(std::string const &, T const &) const
bool const histoDistribution_
VectorInputSource *const input_
bool const probFunctionDistribution_
VectorInputSource::EventPrincipalVector EventPrincipalVector
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
CLHEP::RandPoisson * poissonDistr_OOT_
int nint(float a)
Return the nearest integer - analogous to the FORTRAN intrinsic NINT.
void readPileUp(std::vector< EventPrincipalVector > &result, std::vector< std::vector< edm::EventID > > &ids)
double const averageNumber_
PileUp(ParameterSet const &pset, int const minb, int const maxb, double averageNumber, TH1F *const histo, const bool playback)
CLHEP::RandPoissonQ * poissonDistribution_
tuple size
Write out results.
T get(const Candidate &c)