CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PileUpSimulator Class Reference

#include <PileUpSimulator.h>

Public Member Functions

 PileUpSimulator (FSimEvent *aSimEvent)
 Constructor. More...
 
void produce (const HepMC::GenEvent *pu)
 Produce N minimum bias events, and add them to the FSimEvent. More...
 
 ~PileUpSimulator ()
 Default Destructor. More...
 

Private Attributes

double averageNumber_
 
std::string inputFile
 
unsigned myOutputBuffer
 
std::ofstream myOutputFile
 
FSimEventmySimEvent
 
std::vector< TBranch * > theBranches
 
std::vector< unsigned > theCurrentEntry
 
std::vector< unsigned > theCurrentMinBiasEvt
 
std::vector< std::string > theFileNames
 
std::vector< TFile * > theFiles
 
std::vector< unsigned > theNumberOfEntries
 
unsigned theNumberOfFiles
 
std::vector< unsigned > theNumberOfMinBiasEvts
 
std::vector< PUEvent * > thePUEvents
 
std::vector< TTree * > theTrees
 

Detailed Description

Definition at line 33 of file PileUpSimulator.h.

Constructor & Destructor Documentation

PileUpSimulator::PileUpSimulator ( FSimEvent aSimEvent)

Constructor.

Definition at line 9 of file PileUpSimulator.cc.

10  :
11  mySimEvent(aSimEvent)
12 {}
FSimEvent * mySimEvent
PileUpSimulator::~PileUpSimulator ( )

Default Destructor.

Definition at line 14 of file PileUpSimulator.cc.

14 {}

Member Function Documentation

void PileUpSimulator::produce ( const HepMC::GenEvent *  pu)

Produce N minimum bias events, and add them to the FSimEvent.

Definition at line 16 of file PileUpSimulator.cc.

References FBaseSimEvent::addSimTrack(), FBaseSimEvent::addSimVertex(), GenParticle::GenParticle, mySimEvent, FSimVertexType::PILEUP_VERTEX, RawParticle::setID(), findQualityFiles::v, vbegin, and vend.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), HTMLExport.HTMLExportStatic::export(), and FamosManager::reconstruct().

17 {
18 
19  // There might be no pile-up event to process (Poisson and/or flag)
20  if ( !myGenEvent ) return;
21 
22  // Pile-up event iterator
23  HepMC::GenEvent::vertex_const_iterator viter;
24  HepMC::GenEvent::vertex_const_iterator vbegin = myGenEvent->vertices_begin();
25  HepMC::GenEvent::vertex_const_iterator vend = myGenEvent->vertices_end();
26 
27  int ievt = 0;
28  // Loop on all pile-up events
29  for ( viter=vbegin; viter!=vend; ++viter ) {
30 
31  // The origin vertex (turn it to cm's from GenEvent mm's)
32  HepMC::GenVertex* v = *viter;
33  XYZTLorentzVector smearedVertex =
34  XYZTLorentzVector(v->position().x()/10.,v->position().y()/10.,
35  v->position().z()/10.,v->position().t()/10.);
36 
37  //std::cout << "Vertex position " << smearedVertex << std::endl;
38 
39  // Add it to the FBaseSimEvent
40  int mainVertex = mySimEvent->addSimVertex(smearedVertex, -1, FSimVertexType::PILEUP_VERTEX);
41 
42  // Particles iterator
43  HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = v->particles_out_const_begin();
44  HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = v->particles_out_const_end();
45 
46  // Loop on particles
47  for ( ; firstDaughterIt != lastDaughterIt ; ++firstDaughterIt ) {
48 
49  // A particle
50  HepMC::GenParticle* daugh = *firstDaughterIt;
51  RawParticle myPart(XYZTLorentzVector(daugh->momentum().px(),
52  daugh->momentum().py(),
53  daugh->momentum().pz(),
54  daugh->momentum().e()),
55  smearedVertex);
56 
57  // Add it to the FBaseSimEvent
58  myPart.setID(daugh->pdg_id());
59  // myPart.print();
60 
61  // Add the particle to the event (with a genpartIndex
62  // indicating the pileup event index)
63  mySimEvent->addSimTrack(&myPart,mainVertex,-ievt-2);
64 
65  // End particle loop
66  }
67 
68  // Increment the number of pile-up events
69  ++ievt;
70  // End vertex loop
71  }
72  // Pile-up events now inserted
73 
74 }
int addSimVertex(const XYZTLorentzVector &decayVertex, int im=-1, FSimVertexType::VertexType type=FSimVertexType::ANY)
Add a new vertex to the Event and to the various lists.
int addSimTrack(const RawParticle *p, int iv, int ig=-1, const HepMC::GenVertex *ev=0)
Add a new track to the Event and to the various lists.
FSimEvent * mySimEvent
#define vend()
Definition: vmac.h:41
#define vbegin()
Definition: vmac.h:34
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:15

Member Data Documentation

double PileUpSimulator::averageNumber_
private

Definition at line 48 of file PileUpSimulator.h.

std::string PileUpSimulator::inputFile
private

Definition at line 51 of file PileUpSimulator.h.

unsigned PileUpSimulator::myOutputBuffer
private

Definition at line 64 of file PileUpSimulator.h.

std::ofstream PileUpSimulator::myOutputFile
private

Definition at line 63 of file PileUpSimulator.h.

FSimEvent* PileUpSimulator::mySimEvent
private

Definition at line 49 of file PileUpSimulator.h.

Referenced by produce().

std::vector<TBranch*> PileUpSimulator::theBranches
private

Definition at line 56 of file PileUpSimulator.h.

std::vector<unsigned> PileUpSimulator::theCurrentEntry
private

Definition at line 58 of file PileUpSimulator.h.

std::vector<unsigned> PileUpSimulator::theCurrentMinBiasEvt
private

Definition at line 59 of file PileUpSimulator.h.

std::vector<std::string> PileUpSimulator::theFileNames
private

Definition at line 50 of file PileUpSimulator.h.

std::vector<TFile*> PileUpSimulator::theFiles
private

Definition at line 54 of file PileUpSimulator.h.

std::vector<unsigned> PileUpSimulator::theNumberOfEntries
private

Definition at line 60 of file PileUpSimulator.h.

unsigned PileUpSimulator::theNumberOfFiles
private

Definition at line 52 of file PileUpSimulator.h.

std::vector<unsigned> PileUpSimulator::theNumberOfMinBiasEvts
private

Definition at line 61 of file PileUpSimulator.h.

std::vector<PUEvent*> PileUpSimulator::thePUEvents
private

Definition at line 57 of file PileUpSimulator.h.

std::vector<TTree*> PileUpSimulator::theTrees
private

Definition at line 55 of file PileUpSimulator.h.