#include <Mixing/Base/interface/PileUp.h>
Public Types | |
typedef VectorInputSource::EventPrincipalVector | EventPrincipalVector |
Public Member Functions | |
double | averageNumber () const |
bool | doPileup () |
void | dropUnwantedBranches (std::vector< std::string > const &wantedBranches) |
void | endJob () |
PileUp (ParameterSet const &pset, int const minb, int const maxb, double averageNumber, const bool playback) | |
bool | poisson () const |
void | readPileUp (std::vector< EventPrincipalVector > &result, std::vector< edm::EventID > &ids, std::vector< int > &fileNrs, std::vector< unsigned int > &nrEvents) |
~PileUp () | |
Private Attributes | |
double const | averageNumber_ |
bool const | fixed_ |
VectorInputSource *const | input_ |
int const | intAverage_ |
int const | maxBunch_ |
int const | minBunch_ |
bool const | none_ |
bool | playback_ |
bool const | poisson_ |
CLHEP::RandPoissonQ * | poissonDistribution_ |
std::string const | type_ |
Definition at line 15 of file PileUp.h.
edm::PileUp::PileUp | ( | ParameterSet const & | pset, | |
int const | minb, | |||
int const | maxb, | |||
double | averageNumber, | |||
const bool | playback | |||
) | [explicit] |
Definition at line 17 of file PileUp.cc.
References averageNumber_, Exception, fixed_, edm::Service< T >::isAvailable(), none_, poisson_, poissonDistribution_, and type_.
00017 : 00018 type_(pset.getParameter<std::string>("type")), 00019 minBunch_(minb), 00020 maxBunch_(maxb), 00021 averageNumber_(averageNumber), 00022 intAverage_(static_cast<int>(averageNumber)), 00023 poisson_(type_ == "poisson"), 00024 fixed_(type_ == "fixed"), 00025 none_(type_ == "none"), 00026 input_(VectorInputSourceFactory::get()->makeVectorInputSource(pset, InputSourceDescription()).release()), 00027 poissonDistribution_(0), 00028 playback_(playback) 00029 { 00030 00031 edm::Service<edm::RandomNumberGenerator> rng; 00032 if (!rng.isAvailable()) { 00033 throw cms::Exception("Configuration") 00034 << "PileUp requires the RandomNumberGeneratorService\n" 00035 "which is not present in the configuration file. You must add the service\n" 00036 "in the configuration file or remove the modules that require it."; 00037 } 00038 00039 CLHEP::HepRandomEngine& engine = rng->getEngine(); 00040 00041 poissonDistribution_ = new CLHEP::RandPoissonQ(engine, averageNumber_); 00042 00043 if (!(poisson_ || fixed_ || none_)) { 00044 throw cms::Exception("Illegal parameter value","PileUp::PileUp(ParameterSet const& pset)") 00045 << "'type' parameter (a string) has a value of '" << type_ << "'.\n" 00046 << "Legal values are 'poisson', 'fixed', or 'none'\n"; 00047 } 00048 }
edm::PileUp::~PileUp | ( | ) |
Definition at line 50 of file PileUp.cc.
References poissonDistribution_.
00050 { 00051 delete poissonDistribution_; 00052 }
double edm::PileUp::averageNumber | ( | ) | const [inline] |
bool edm::PileUp::doPileup | ( | ) | [inline] |
Definition at line 25 of file PileUp.h.
References averageNumber_, and none_.
00025 {return none_ ? false : averageNumber_>0.;}
void edm::PileUp::dropUnwantedBranches | ( | std::vector< std::string > const & | wantedBranches | ) | [inline] |
Definition at line 26 of file PileUp.h.
References edm::VectorInputSource::dropUnwantedBranches(), and input_.
00026 { 00027 input_->dropUnwantedBranches(wantedBranches); 00028 }
Definition at line 29 of file PileUp.h.
References edm::InputSource::doEndJob(), and input_.
00029 { 00030 input_->doEndJob(); 00031 }
bool edm::PileUp::poisson | ( | ) | const [inline] |
void edm::PileUp::readPileUp | ( | std::vector< EventPrincipalVector > & | result, | |
std::vector< edm::EventID > & | ids, | |||
std::vector< int > & | fileNrs, | |||
std::vector< unsigned int > & | nrEvents | |||
) |
Definition at line 55 of file PileUp.cc.
References edmNew::copy(), file, i, input_, intAverage_, LogDebug, maxBunch_, minBunch_, n, none_, playback_, poisson_, poissonDistribution_, edm::VectorInputSource::readMany(), and edm::VectorInputSource::readManyRandom().
00055 { 00056 for (int i = minBunch_; i <= maxBunch_; ++i) { 00057 EventPrincipalVector eventVector; 00058 int n; 00059 00060 if (!playback_){ 00061 n = (none_ ? 0 : (poisson_ ? poissonDistribution_->fire() : intAverage_)); 00062 nrEvents[i-minBunch_]=n; 00063 }else { 00064 n=nrEvents[i-minBunch_]; 00065 } 00066 eventVector.reserve(n); 00067 while (n > 0) { 00068 EventPrincipalVector oneResult; 00069 oneResult.reserve(n); 00070 if (!playback_) { 00071 unsigned int file; //FIXME: need unsigned filenr? 00072 input_->readManyRandom(n, oneResult,file); //no playback 00073 ids[i-minBunch_]=oneResult[0]->id(); 00074 fileNrs[i-minBunch_]=file; 00075 } else { 00076 input_->readMany(n, oneResult,ids[i-minBunch_],fileNrs[i-minBunch_]); // playback 00077 } 00078 LogDebug("readPileup") << "READ: " << oneResult.size(); 00079 std::copy(oneResult.begin(), oneResult.end(), std::back_inserter(eventVector)); 00080 n -= oneResult.size(); 00081 } 00082 result.push_back(eventVector); 00083 } 00084 }
double const edm::PileUp::averageNumber_ [private] |
bool const edm::PileUp::fixed_ [private] |
VectorInputSource* const edm::PileUp::input_ [private] |
Definition at line 42 of file PileUp.h.
Referenced by dropUnwantedBranches(), endJob(), and readPileUp().
int const edm::PileUp::intAverage_ [private] |
int const edm::PileUp::maxBunch_ [private] |
int const edm::PileUp::minBunch_ [private] |
bool const edm::PileUp::none_ [private] |
bool edm::PileUp::playback_ [private] |
bool const edm::PileUp::poisson_ [private] |
CLHEP::RandPoissonQ* edm::PileUp::poissonDistribution_ [private] |
std::string const edm::PileUp::type_ [private] |