00001 #include "FastSimulation/PileUpProducer/interface/PileUpSimulator.h"
00002 #include "FastSimulation/Event/interface/FSimEvent.h"
00003 #include "FastSimulation/Particle/interface/RawParticle.h"
00004
00005 #include "HepMC/GenEvent.h"
00006
00007
00008
00009 PileUpSimulator::PileUpSimulator(FSimEvent* aSimEvent)
00010 :
00011 mySimEvent(aSimEvent)
00012 {}
00013
00014 PileUpSimulator::~PileUpSimulator() {}
00015
00016 void PileUpSimulator::produce(const HepMC::GenEvent* myGenEvent)
00017 {
00018
00019
00020 if ( !myGenEvent ) return;
00021
00022
00023 HepMC::GenEvent::vertex_const_iterator viter;
00024 HepMC::GenEvent::vertex_const_iterator vbegin = myGenEvent->vertices_begin();
00025 HepMC::GenEvent::vertex_const_iterator vend = myGenEvent->vertices_end();
00026
00027 int ievt = 0;
00028
00029 for ( viter=vbegin; viter!=vend; ++viter ) {
00030
00031
00032
00033
00034 HepMC::GenVertex* v = *viter;
00035 XYZTLorentzVector smearedVertex =
00036 XYZTLorentzVector(v->position().x()/10.,v->position().y()/10.,
00037 v->position().z()/10.,v->position().t()/10.);
00038
00039
00040
00041
00042 int mainVertex = mySimEvent->addSimVertex(smearedVertex);
00043
00044
00045 HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = v->particles_out_const_begin();
00046 HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = v->particles_out_const_end();
00047
00048
00049 for ( ; firstDaughterIt != lastDaughterIt ; ++firstDaughterIt ) {
00050
00051
00052 HepMC::GenParticle* daugh = *firstDaughterIt;
00053 RawParticle myPart(XYZTLorentzVector(daugh->momentum().px(),
00054 daugh->momentum().py(),
00055 daugh->momentum().pz(),
00056 daugh->momentum().e()),
00057 smearedVertex);
00058
00059
00060 myPart.setID(daugh->pdg_id());
00061
00062
00063
00064
00065 mySimEvent->addSimTrack(&myPart,mainVertex,-ievt-2);
00066
00067
00068 }
00069
00070
00071 ++ievt;
00072
00073 }
00074
00075
00076 }