CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/SimDataFormats/CrossingFrame/src/CrossingFrame.cc

Go to the documentation of this file.
00001 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00002 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
00003 #include "DataFormats/Math/interface/Vector3D.h"
00004 
00005 using namespace edm;
00006 
00007 template <> 
00008 void CrossingFrame<SimTrack>::addPileups(const int bcr, std::vector<SimTrack> *simtracks, unsigned int evtNr, int vertexoffset) { 
00009 
00010   EncodedEventId id(bcr,evtNr);
00011   for (unsigned int i=0;i<simtracks->size();++i){
00012     (*simtracks)[i].setEventId(id);
00013     if (!(*simtracks)[i].noVertex()) 
00014       (*simtracks)[i].setVertexIndex((*simtracks)[i].vertIndex()+vertexoffset);
00015     pileups_.push_back(&((*simtracks)[i]));
00016   }
00017 }
00018 
00019 template <> 
00020 void CrossingFrame<SimVertex>::addPileups(const int bcr, std::vector<SimVertex> *simvertices, unsigned int evtNr, int vertexoffset) { 
00021 
00022   EncodedEventId id(bcr,evtNr);
00023   for (unsigned int i=0;i<simvertices->size();++i) {
00024     (*simvertices)[i].setEventId(id);
00025     (*simvertices)[i].setTof((*simvertices)[i].position().t()+bcr*bunchSpace_);
00026     pileups_.push_back(&((*simvertices)[i]));
00027   }
00028 }
00029 
00030 template <> 
00031 void CrossingFrame<PSimHit>::addPileups(const int bcr, std::vector<PSimHit> *simhits, unsigned int evtNr, int vertexoffset) { 
00032 
00033   EncodedEventId id(bcr,evtNr);
00034 
00035   for (unsigned int i=0;i<simhits->size();++i) {
00036     (*simhits)[i].setEventId(id);
00037     (*simhits)[i].setTof((*simhits)[i].timeOfFlight() + bcr*bunchSpace_);
00038     pileups_.push_back(&((*simhits)[i]));
00039   }
00040 }
00041 
00042 template <> 
00043 void CrossingFrame<PCaloHit>::addPileups(const int bcr, std::vector<PCaloHit> *calohits, unsigned int evtNr, int vertexoffset) { 
00044 
00045   EncodedEventId id(bcr,evtNr);
00046   for (unsigned int i=0;i<calohits->size();++i) {
00047     PCaloHit hit((*calohits)[i].id(),(*calohits)[i].energyEM(),(*calohits)[i].energyHad(),(*calohits)[i].time()+bcr*bunchSpace_,(*calohits)[i].geantTrackId());
00048     (*calohits)[i].setEventId(id);
00049     (*calohits)[i].setTime((*calohits)[i].time()+bcr*bunchSpace_);
00050     pileups_.push_back(&((*calohits)[i]));
00051   }
00052 }