CMS 3D CMS Logo

edm::PileUp Class Reference

#include <Mixing/Base/interface/PileUp.h>

List of all members.

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_


Detailed Description

Definition at line 15 of file PileUp.h.


Member Typedef Documentation

typedef VectorInputSource::EventPrincipalVector edm::PileUp::EventPrincipalVector

Definition at line 17 of file PileUp.h.


Constructor & Destructor Documentation

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   }


Member Function Documentation

double edm::PileUp::averageNumber (  )  const [inline]

Definition at line 23 of file PileUp.h.

References averageNumber_.

00023 {return averageNumber_;}

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     }

void edm::PileUp::endJob ( void   )  [inline]

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]

Definition at line 24 of file PileUp.h.

References poisson_.

00024 {return poisson_;}

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   }


Member Data Documentation

double const edm::PileUp::averageNumber_ [private]

Definition at line 37 of file PileUp.h.

Referenced by averageNumber(), doPileup(), and PileUp().

bool const edm::PileUp::fixed_ [private]

Definition at line 40 of file PileUp.h.

Referenced by PileUp().

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]

Definition at line 38 of file PileUp.h.

Referenced by readPileUp().

int const edm::PileUp::maxBunch_ [private]

Definition at line 36 of file PileUp.h.

Referenced by readPileUp().

int const edm::PileUp::minBunch_ [private]

Definition at line 35 of file PileUp.h.

Referenced by readPileUp().

bool const edm::PileUp::none_ [private]

Definition at line 41 of file PileUp.h.

Referenced by doPileup(), PileUp(), and readPileUp().

bool edm::PileUp::playback_ [private]

Definition at line 46 of file PileUp.h.

Referenced by readPileUp().

bool const edm::PileUp::poisson_ [private]

Definition at line 39 of file PileUp.h.

Referenced by PileUp(), poisson(), and readPileUp().

CLHEP::RandPoissonQ* edm::PileUp::poissonDistribution_ [private]

Definition at line 43 of file PileUp.h.

Referenced by PileUp(), readPileUp(), and ~PileUp().

std::string const edm::PileUp::type_ [private]

Definition at line 34 of file PileUp.h.

Referenced by PileUp().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:42:58 2009 for CMSSW by  doxygen 1.5.4