CMS 3D CMS Logo

Public Member Functions | Private Attributes

PileUpSimulator Class Reference

#include <PileUpSimulator.h>

List of all members.

Public Member Functions

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

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.

  : 
  mySimEvent(aSimEvent)  
{}
PileUpSimulator::~PileUpSimulator ( )

Default Destructor.

Definition at line 14 of file PileUpSimulator.cc.

{}

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(), configurableAnalysis::GenParticle, mySimEvent, FSimVertexType::PILEUP_VERTEX, RawParticle::setID(), v, vbegin, and vend.

Referenced by FamosManager::reconstruct().

{

  // There might be no pile-up event to process (Poisson and/or flag)
  if ( !myGenEvent ) return;

  // Pile-up event iterator
  HepMC::GenEvent::vertex_const_iterator viter;
  HepMC::GenEvent::vertex_const_iterator vbegin = myGenEvent->vertices_begin();
  HepMC::GenEvent::vertex_const_iterator vend = myGenEvent->vertices_end();
  
  int ievt = 0;
  // Loop on all pile-up events
  for ( viter=vbegin; viter!=vend; ++viter ) { 

    // std::cout << "Vertex n0 " << ievt << std::endl;

    // The origin vertex (turn it to cm's from GenEvent mm's)
    HepMC::GenVertex* v = *viter;    
    XYZTLorentzVector smearedVertex =  
      XYZTLorentzVector(v->position().x()/10.,v->position().y()/10.,
                        v->position().z()/10.,v->position().t()/10.);

    // std::cout << "Vertex position " << smearedVertex << std::endl;

    // Add it to the FBaseSimEvent
    int mainVertex = mySimEvent->addSimVertex(smearedVertex, -1, FSimVertexType::PILEUP_VERTEX);

    // Particles iterator
    HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = v->particles_out_const_begin();
    HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = v->particles_out_const_end();

    // Loop on particles
    for ( ; firstDaughterIt != lastDaughterIt ; ++firstDaughterIt ) {

      // A particle
      HepMC::GenParticle* daugh = *firstDaughterIt;
      RawParticle myPart(XYZTLorentzVector(daugh->momentum().px(),
                                           daugh->momentum().py(),
                                           daugh->momentum().pz(),
                                           daugh->momentum().e()),
                         smearedVertex);
      
      // Add it to the FBaseSimEvent
      myPart.setID(daugh->pdg_id());
      // myPart.print();

      // Add the particle to the event (with a genpartIndex 
      // indicating the pileup event index)
      mySimEvent->addSimTrack(&myPart,mainVertex,-ievt-2);

      // End particle loop  
    }

    // Increment the number of pile-up events
    ++ievt;
    // End vertex loop
  }
  // Pile-up events now inserted

}

Member Data Documentation

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.

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.

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.