CMS 3D CMS Logo

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 "SimDataFormats/Track/interface/SimTrack.h"
00004 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00005 #include "DataFormats/Math/interface/Vector3D.h"
00006 
00007 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00008 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
00009 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00010 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00011 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00012 
00013 //using namespace std;
00014 using namespace edm;
00015 
00016 template <> const int  CrossingFrame<PSimHit>::limHighLowTof = 36;
00017 
00018 template <> 
00019 void CrossingFrame<SimTrack>::addPileups(const int bcr, const std::vector<SimTrack> *simtracks, unsigned int evtNr, int vertexoffset,bool checkTof,bool high) { 
00020 
00021   EncodedEventId id(bcr,evtNr);
00022   for (unsigned int i=0;i<simtracks->size();++i)
00023     if ((*simtracks)[i].noVertex()) {
00024       SimTrack track((*simtracks)[i]);
00025       track.setEventId(id);
00026       pileups_.push_back(track);
00027     }
00028     else {
00029       SimTrack track((*simtracks)[i].type(),(*simtracks)[i].momentum(),(*simtracks)[i].vertIndex()+vertexoffset, (*simtracks)[i].genpartIndex());
00030       track.setEventId(id);
00031       track.setTrackId((*simtracks)[i].trackId());
00032       pileups_.push_back(track);
00033     }
00034 }
00035 
00036 template <> 
00037 void CrossingFrame<SimVertex>::addPileups(const int bcr, const std::vector<SimVertex> *simvertices, unsigned int evtNr, int vertexoffset,bool checkTof,bool high) { 
00038 
00039   EncodedEventId id(bcr,evtNr);
00040   for (unsigned int i=0;i<simvertices->size();++i) {
00041     SimVertex vertex(math::XYZVectorD( (*simvertices)[i].position().x(),
00042                                        (*simvertices)[i].position().y(),
00043                                        (*simvertices)[i].position().z() ),
00044                      ((*simvertices)[i].position()).t()+bcr*bunchSpace_,
00045                      (*simvertices)[i].parentIndex());
00046     
00047     //    SimVertex vertex((*simvertices)[i].position(),((*simvertices)[i].position())[3]+bcr*bunchSpace_,(*simvertices)[i].parentIndex());
00048     vertex.setEventId(EncodedEventId(bcr,evtNr));
00049     pileups_.push_back(vertex);
00050   }
00051 }
00052 
00053 template <> 
00054 void CrossingFrame<PSimHit>::addPileups(const int bcr, const std::vector<PSimHit> *simhits, unsigned int evtNr, int vertexoffset,bool checkTof,bool high) { 
00055 
00056   EncodedEventId id(bcr,evtNr);
00057 
00058   int count=0;
00059   for (unsigned int i=0;i<simhits->size();++i) {
00060     bool accept=true;
00061     float newtof;
00062     if (checkTof) {
00063       newtof=(*simhits)[i].timeOfFlight() + bcr*bunchSpace_;
00064       accept=high ? newtof>= limHighLowTof : newtof < limHighLowTof;
00065     }
00066     if (!checkTof || accept) {
00067       PSimHit hit((*simhits)[i].entryPoint(), (*simhits)[i].exitPoint(),(*simhits)[i].pabs(),
00068                   (*simhits)[i].timeOfFlight() + bcr*bunchSpace_, 
00069                   (*simhits)[i].energyLoss(), (*simhits)[i].particleType(),
00070                   (*simhits)[i].detUnitId(), (*simhits)[i].trackId(),
00071                   (*simhits)[i].thetaAtEntry(),  (*simhits)[i].phiAtEntry(),  (*simhits)[i].processType());
00072       hit.setEventId(id);
00073       pileups_.push_back(hit);
00074       count++;
00075     }  
00076   }
00077 }
00078 
00079 template <> 
00080 void CrossingFrame<PCaloHit>::addPileups(const int bcr, const std::vector<PCaloHit> *calohits, unsigned int evtNr, int vertexoffset,bool checkTof,bool high) { 
00081 
00082   EncodedEventId id(bcr,evtNr);
00083   for (unsigned int i=0;i<calohits->size();++i) {
00084     PCaloHit hit((*calohits)[i].id(),(*calohits)[i].energyEM(),(*calohits)[i].energyHad(),(*calohits)[i].time()+bcr*bunchSpace_,(*calohits)[i].geantTrackId());
00085     hit.setEventId(id);
00086     pileups_.push_back(hit);
00087   }
00088 }
00089 
00090 template <> 
00091 void CrossingFrame<edm::HepMCProduct>::addPileups(const int bcr, const std::vector<edm::HepMCProduct> *mcps, unsigned int evtNr, int vertexoffset,bool checkTof,bool high) { 
00092   for (unsigned int i=0;i<mcps->size();++i) {
00093     pileups_.push_back((*mcps)[i]);
00094   }
00095 }
00096 

Generated on Tue Jun 9 17:46:32 2009 for CMSSW by  doxygen 1.5.4