CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/SimDataFormats/TrackingAnalysis/src/TrackingVertex.cc

Go to the documentation of this file.
00001 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
00002 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h"
00003 
00004 typedef edm::RefVector<edm::HepMCProduct, HepMC::GenVertex > GenVertexRefVector;
00005 typedef edm::Ref<edm::HepMCProduct, HepMC::GenVertex >       GenVertexRef;
00006 
00007 // Constructors
00008 
00009 TrackingVertex::TrackingVertex() : position_(LorentzVector(0,0,0,0)), eId_(0)
00010 {
00011 //  daughterTracks_.clear();
00012 }
00013 
00014 TrackingVertex::TrackingVertex(const LorentzVector &p, const bool inVolume, const EncodedEventId eId) :
00015         position_(p), inVolume_(inVolume), eId_(eId)
00016 {
00017 //  daughterTracks_.clear();
00018 }
00019 
00020 // Add a reference to vertex vectors
00021 
00022 void TrackingVertex::addG4Vertex(const SimVertex& v)
00023 {
00024     g4Vertices_.push_back(v);
00025 }
00026 
00027 void TrackingVertex::addGenVertex(const GenVertexRef &ref)
00028 {
00029     genVertices_.push_back(ref);
00030 }
00031 
00032 // Add a reference to track vectors
00033 
00034 void TrackingVertex::addDaughterTrack(const TrackingParticleRef &ref)
00035 {
00036     daughterTracks_.push_back(ref);
00037 }
00038 
00039 void TrackingVertex::addParentTrack(const TrackingParticleRef &ref)
00040 {
00041     sourceTracks_.push_back(ref);
00042 }
00043 
00044 void TrackingVertex::clearDaughterTracks()
00045 {
00046     daughterTracks_.clear();
00047 }
00048 
00049 void TrackingVertex::clearParentTracks()
00050 {
00051     sourceTracks_.clear();
00052 }
00053 
00054 
00055 // Iterators over vertices and tracks
00056 
00057 TrackingVertex::genv_iterator TrackingVertex::genVertices_begin() const
00058 {
00059     return genVertices_.begin();
00060 }
00061 TrackingVertex::genv_iterator TrackingVertex::genVertices_end()   const
00062 {
00063     return genVertices_.end();
00064 }
00065 TrackingVertex::g4v_iterator  TrackingVertex::g4Vertices_begin()  const
00066 {
00067     return  g4Vertices_.begin();
00068 }
00069 TrackingVertex::g4v_iterator  TrackingVertex::g4Vertices_end()    const
00070 {
00071     return  g4Vertices_.end();
00072 }
00073 
00074 TrackingVertex::tp_iterator TrackingVertex::daughterTracks_begin() const
00075 {
00076     return daughterTracks_.begin();
00077 }
00078 TrackingVertex::tp_iterator TrackingVertex::daughterTracks_end()   const
00079 {
00080     return daughterTracks_.end();
00081 }
00082 TrackingVertex::tp_iterator TrackingVertex::sourceTracks_begin()   const
00083 {
00084     return sourceTracks_.begin();
00085 }
00086 TrackingVertex::tp_iterator TrackingVertex::sourceTracks_end()     const
00087 {
00088     return sourceTracks_.end();
00089 }
00090 
00091 // Accessors for whole vectors
00092 
00093 const std::vector<SimVertex>&    TrackingVertex::g4Vertices()     const
00094 {
00095     return  g4Vertices_;
00096 }
00097 const GenVertexRefVector&        TrackingVertex::genVertices()    const
00098 {
00099     return  genVertices_;
00100 }
00101 const TrackingParticleRefVector& TrackingVertex::sourceTracks()   const
00102 {
00103     return  sourceTracks_;
00104 }
00105 const TrackingParticleRefVector& TrackingVertex::daughterTracks() const
00106 {
00107     return  daughterTracks_;
00108 }
00109 
00110 std::ostream& operator<< (std::ostream& s, const TrackingVertex & v)
00111 {
00112 
00113     using std::endl;
00114     typedef        GenVertexRefVector::iterator                  genv_iterator;
00115     typedef    std::vector<SimVertex>::const_iterator            g4v_iterator;
00116     typedef TrackingParticleRefVector::iterator                  tp_iterator;
00117     typedef       std::vector<SimTrack>::const_iterator             g4t_iterator;
00118 
00119     s << "Vertex Position & Event #" << v.position() << " " << v.eventId().bunchCrossing() << "." << v.eventId().event() << endl;
00120     s << " Associated with " << v.daughterTracks().size() << " tracks" << endl;
00121     for (genv_iterator genV = v.genVertices_begin(); genV != v.genVertices_end(); ++genV)
00122     {
00123         s << " HepMC vertex position " << (*(*genV)).position().x() << ","<< (*(*genV)).position().y() << (*(*genV)).position().z()  << endl;
00124     }
00125 
00126     for (g4v_iterator g4V = v.g4Vertices_begin(); g4V != v.g4Vertices_end(); ++g4V)
00127     {
00128         s << " Geant vertex position " << (*g4V).position() << endl;
00129         // Probably empty all the time, currently
00130     }
00131 
00132     // Loop over daughter track(s)
00133     for (tp_iterator iTP = v.daughterTracks_begin(); iTP != v.daughterTracks_end(); ++iTP)
00134     {
00135         s << " Daughter starts:      " << (*(*iTP)).vertex();
00136         for (g4t_iterator g4T  = (*(*iTP)).g4Track_begin(); g4T != (*(*iTP)).g4Track_end(); ++g4T)
00137         {
00138             s << " p " << g4T->momentum();
00139         }
00140         s << endl;
00141     }
00142 
00143     // Loop over source track(s) (can be multiple since vertices are collapsed)
00144     for (tp_iterator iTP = v.sourceTracks_begin(); iTP != v.sourceTracks_end(); ++iTP)
00145     {
00146         s << " Source   starts: " << (*(*iTP)).vertex();
00147         for (g4t_iterator g4T  = (*iTP)->g4Track_begin(); g4T != (*iTP)->g4Track_end(); ++g4T)
00148         {
00149             s << ", p " <<  g4T ->momentum();
00150         }
00151         s << endl;
00152     }
00153     return s;
00154 }
00155