CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingParticle.cc
Go to the documentation of this file.
2 
3 typedef std::vector<TrackingVertex> TrackingVertexCollection;
7 
9  double t, const int pdgId, const int status, const EncodedEventId eventId) :
10  ParticleBase( q, p4, vtx,pdgId,status ), t_( t ), pdgId_( pdgId ), eventId_( eventId )
11 {
12 }
13 
15 {
16 }
17 
19 {
21 }
22 
24 {
25  g4Tracks_.push_back(t);
26 }
27 
29 {
30  trackPSimHit_.push_back(hit);
31 }
32 
34 {
35  return genParticles_.begin();
36 }
37 
39 {
40  return genParticles_.end();
41 }
42 
44 {
45  return g4Tracks_.begin();
46 }
47 
49 {
50  return g4Tracks_.end();
51 }
52 
53 const std::vector<PSimHit>::const_iterator TrackingParticle::pSimHit_begin() const
54 {
55  return trackPSimHit_.begin();
56 }
57 
58 const std::vector<PSimHit>::const_iterator TrackingParticle::pSimHit_end() const
59 {
60  return trackPSimHit_.end();
61 }
62 
63 std::vector<PSimHit> TrackingParticle::trackPSimHit(DetId::Detector detector) const
64 {
65  std::vector<PSimHit> result;
66  for (std::vector<PSimHit>::const_iterator iHit = trackPSimHit_.begin(); iHit != trackPSimHit_.end(); ++iHit)
67  if ( detector == DetId( (uint32_t)((*iHit).detUnitId()) ).det() )
68  result.push_back(*iHit);
69  return result;
70 }
71 
73 {
74  parentVertex_ = ref;
75 }
76 
78 {
80 }
81 
83 {
85 }
86 
88 {
90 }
91 
92 void TrackingParticle::setMatchedHit(const int &hitnumb)
93 {
94  matchedHit_ = hitnumb;
95 }
96 
97 void TrackingParticle::setVertex(const Point & vtx, double t)
98 {
99  t_ = t;
101 }
102 
103 std::ostream& operator<< (std::ostream& s, TrackingParticle const & tp)
104 {
105  s << "TP momentum, q, ID, & Event #: "
106  << tp.p4() << " " << tp.charge() << " " << tp.pdgId() << " "
107  << tp.eventId().bunchCrossing() << "." << tp.eventId().event() << std::endl;
108  s << " Hits for this track: " << tp.trackPSimHit().size() << std::endl;
109 
110  for (int i = 1; i < DetId::Calo + 1; ++i)
111  {
112  int numberOfHits = tp.trackPSimHit((DetId::Detector)i).size();
113  if (numberOfHits)
114  s << "\t sub-detector id : " << i << " -> " << numberOfHits << std::endl;
115  }
116 
117  for (TrackingParticle::genp_iterator hepT = tp.genParticle_begin(); hepT != tp.genParticle_end(); ++hepT)
118  {
119  s << " HepMC Track Momentum " << (*hepT)->momentum().rho() << std::endl;
120  }
121 
122  for (TrackingParticle::g4t_iterator g4T = tp.g4Track_begin(); g4T != tp.g4Track_end(); ++g4T)
123  {
124  s << " Geant Track Momentum " << g4T->momentum() << std::endl;
125  s << " Geant Track ID & type " << g4T->trackId() << " " << g4T->type() << std::endl;
126  if (g4T->type() != tp.pdgId())
127  {
128  s << " Mismatch b/t TrackingParticle and Geant types" << std::endl;
129  }
130  }
131  // Loop over decay vertices
132  s << " TP Vertex " << tp.vertex() << std::endl;
133  s << " Source vertex: " << tp.parentVertex()->position() << std::endl;
134  s << " " << tp.decayVertices().size() << " Decay vertices" << std::endl;
135  for (tv_iterator iTV = tp.decayVertices_begin(); iTV != tp.decayVertices_end(); ++iTV)
136  {
137  s << " Decay vertices: " << (**iTV).position() << std::endl;
138  }
139 
140  return s;
141 }
int i
Definition: DBlmapReader.cc:9
genp_iterator genParticle_begin() const
iterators
tv_iterator decayVertices_end() const
int event() const
get the contents of the subdetector field (should be protected?)
tv_iterator decayVertices_begin() const
int charge() const
electric charge
Definition: ParticleBase.h:54
TrackingVertexRefVector decayVertices_
math::XYZTLorentzVectorD LorentzVector
Lorentz vector.
Definition: ParticleBase.h:24
const std::vector< PSimHit > & trackPSimHit() const
g4t_iterator g4Track_begin() const
int pdgId() const
PDG id, signal source, crossing number.
edm::RefVector< TrackingVertexCollection > TrackingVertexRefVector
float t_
production time
TrackingParticle()
default constructor
const std::vector< PSimHit >::const_iterator pSimHit_begin() const
const std::vector< PSimHit >::const_iterator pSimHit_end() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
void setMatchedHit(const int &)
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
math::XYZPointD Point
point in the space
Definition: ParticleBase.h:28
int matchedHit_
Total Number of Hits belonging to the TrackingParticle.
void addPSimHit(const PSimHit &)
double p4[4]
Definition: TauolaWrapper.h:92
int bunchCrossing() const
get the detector field from this detid
void addDecayVertex(const TrackingVertexRef &)
tuple result
Definition: query.py:137
std::vector< SimTrack > g4Tracks_
references to G4 and HepMC tracks
TrackingVertexRefVector::iterator tv_iterator
const TrackingVertexRef & parentVertex() const
const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: ParticleBase.h:74
void setVertex(const Point &vtx, double t)
std::vector< SimTrack >::const_iterator g4t_iterator
edm::Ref< TrackingVertexCollection > TrackingVertexRef
Definition: DetId.h:20
genp_iterator genParticle_end() const
void clear()
Clear the vector.
Definition: RefVector.h:133
Detector
Definition: DetId.h:26
std::vector< TrackingVertex > TrackingVertexCollection
GenParticleRefVector genParticles_
EncodedEventId eventId() const
edm::Ref< TrackingVertexCollection > TrackingVertexRef
void addGenParticle(const GenParticleRef &)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
void addG4Track(const SimTrack &)
std::vector< PSimHit > trackPSimHit_
tuple status
Definition: ntuplemaker.py:245
void setVertex(const Point &vertex)
set vertex
Definition: ParticleBase.h:248
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
const Point & vertex() const
vertex position
Definition: ParticleBase.h:228
g4t_iterator g4Track_end() const
const TrackingVertexRefVector & decayVertices() const
void setParentVertex(const TrackingVertexRef &)
TrackingVertexRef parentVertex_