Go to the documentation of this file.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 HepMC::GenVertex* v = *viter;
00033 XYZTLorentzVector smearedVertex =
00034 XYZTLorentzVector(v->position().x()/10.,v->position().y()/10.,
00035 v->position().z()/10.,v->position().t()/10.);
00036
00037
00038
00039
00040 int mainVertex = mySimEvent->addSimVertex(smearedVertex, -1, FSimVertexType::PILEUP_VERTEX);
00041
00042
00043 HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = v->particles_out_const_begin();
00044 HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = v->particles_out_const_end();
00045
00046
00047 for ( ; firstDaughterIt != lastDaughterIt ; ++firstDaughterIt ) {
00048
00049
00050 HepMC::GenParticle* daugh = *firstDaughterIt;
00051 RawParticle myPart(XYZTLorentzVector(daugh->momentum().px(),
00052 daugh->momentum().py(),
00053 daugh->momentum().pz(),
00054 daugh->momentum().e()),
00055 smearedVertex);
00056
00057
00058 myPart.setID(daugh->pdg_id());
00059
00060
00061
00062
00063 mySimEvent->addSimTrack(&myPart,mainVertex,-ievt-2);
00064
00065
00066 }
00067
00068
00069 ++ievt;
00070
00071 }
00072
00073
00074 }