17 #include "HepMC/GenEvent.h"
31 produces<PileupMixingContent>();
33 produces<edm::HepMCProduct>(
"PileUpEvents");
37 if ( ! rng.isAvailable() ) {
39 <<
"PileUpProducer requires the RandomGeneratorService\n"
40 "which is not present in the configuration file.\n"
41 "You must add the service in the configuration file\n"
42 "or remove the module that requires it";
51 std::cout <<
" FastSimulation/PileUpProducer -> poissonian distribution" << std::endl;
52 averageNumber_ = pu.
getParameter<
double>(
"averageNumber");
61 std::cout <<
" FastSimulation/PileUpProducer -> distribution from configuration file " << std::endl;
63 for (
int i=0;
i<(varSize -
probSize);
i++) dataProb.push_back(0);
64 edm::LogWarning(
"") <<
" The probability function data will be completed with "
65 << (varSize -
probSize) <<
" values `0';"
66 <<
" the number of the P(x) data set after adding those 0's is " << dataProb.size();
73 std::cout <<
" FastSimulation/PileUpProducer -> An histogram will be created with " << numBins
74 <<
" bins in the range ("<< xmin <<
"," << xmax <<
")." << std::endl;
75 hprob =
new TH1F(
"h",
"Histo from the user's probability function",numBins,xmin,xmax);
76 LogDebug(
"") <<
" FastSimulation/PileUpProducer -> Filling histogram with the following data:";
77 for (
int j=0;
j < numBins ;
j++){
83 if (((
hprob->Integral() - 1) > 1.0e-02) && ((
hprob->Integral() - 1) < -1.0e-02))
throw cms::Exception(
"BadHistoDistribution") <<
"The histogram should be normalized!" << std::endl;
86 averageNumber_ =
hprob->GetMean();
102 std::string vtxType = vtx.
getParameter<std::string>(
"type");
103 if ( vtxType ==
"Gaussian" )
105 else if ( vtxType ==
"Flat" )
107 else if ( vtxType ==
"BetaFunc" )
114 if (averageNumber_ > 0.)
116 std::cout <<
" FastSimulation/PileUpProducer -> MinBias events taken from " <<
theFileNames[0] <<
" et al., " ;
117 std::cout <<
" with an average number of events of " << averageNumber_ << std::endl;
119 else std::cout <<
" FastSimulation/PileUpProducer -> No pileup " << std::endl;
136 std::string fullPath;
141 std::cout <<
"***WARNING*** You are reading pile-up information from the file "
142 <<
inputFile <<
" created in an earlier run."
228 HepMC::GenEvent* evt =
new HepMC::GenEvent();
236 std::auto_ptr< PileupMixingContent > PileupMixing_;
238 std::vector<int> bunchCrossingList;
239 bunchCrossingList.push_back(0);
241 std::vector<int> numInteractionList;
242 numInteractionList.push_back(PUevts);
244 std::vector<float> trueInteractionList;
247 PileupMixing_ = std::auto_ptr< PileupMixingContent >(
new PileupMixingContent(bunchCrossingList,numInteractionList,trueInteractionList));
248 iEvent.
put(PileupMixing_);
251 for (
int ievt=0; ievt<PUevts; ++ievt ) {
263 HepMC::FourVector smearedVertex =
268 HepMC::GenVertex* aVertex =
new HepMC::GenVertex(smearedVertex);
269 evt->add_vertex(aVertex);
318 unsigned firstTrack = aMinBiasEvt.
first;
319 unsigned trackSize = firstTrack + aMinBiasEvt.
size;
326 for (
unsigned iTrack=firstTrack; iTrack<trackSize; ++iTrack ) {
343 + aParticle.
py*aParticle.
py
344 + aParticle.
pz*aParticle.
pz
347 HepMC::FourVector myPart(cAngle * aParticle.
px + sAngle * aParticle.
py,
348 -sAngle * aParticle.
px + cAngle * aParticle.
py,
349 aParticle.
pz, energy);
353 aVertex->add_particle_out(aGenParticle);
368 pu_product->addHepMCData( evt );
371 if ( boost ) pu_product->boostToLab(boost,
"momentum");
375 iEvent.
put(pu_product,
"PileUpEvents");
408 ifstream myInputFile;
416 myInputFile.open (inputFile.c_str());
417 if ( myInputFile.is_open() ) {
420 if ( stat(inputFile.c_str(), &
results) == 0 ) size = results.st_size;
424 myInputFile.seekg(size-size1-size2);
PileUpProducer(edm::ParameterSet const &p)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< unsigned > theNumberOfMinBiasEvts
std::vector< std::string > theFileNames
#define DEFINE_FWK_MODULE(type)
Sin< T >::type sin(const T &t)
bool read(std::string inputFile)
Read former minbias configuration (from previous run)
std::vector< int > dataProbFunctionVar
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< unsigned > theNumberOfEntries
PrimaryVertexGenerator * theVertexGenerator
std::ofstream myOutputFile
virtual void produce(edm::Event &e, const edm::EventSetup &c)
virtual void beginRun(edm::Run &, edm::EventSetup const &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
unsigned int poissonShoot(double mean) const
const RandomEngine * random
Cos< T >::type cos(const T &t)
std::vector< unsigned > theCurrentMinBiasEvt
std::vector< PUEvent * > thePUEvents
virtual void generate()=0
Generation process (to be implemented)
std::vector< double > dataProb
double flatShoot(double xmin=0.0, double xmax=1.0) const
std::vector< unsigned > theCurrentEntry
std::vector< TTree * > theTrees
virtual ~PileUpProducer()
std::string fullPath() const
unsigned theNumberOfFiles
tuple size
Write out results.
std::vector< TFile * > theFiles
void save()
Save current minbias configuration (for later use)
std::vector< TBranch * > theBranches