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 
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:55
TrackingVertexRefVector decayVertices_
math::XYZTLorentzVectorD LorentzVector
Lorentz vector.
Definition: ParticleBase.h:25
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:242
void setMatchedHit(const int &)
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:237
math::XYZPointD Point
point in the space
Definition: ParticleBase.h:29
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:75
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:129
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:61
size_type size() const
Size of the RefVector.
Definition: RefVector.h:85
void addG4Track(const SimTrack &)
std::vector< PSimHit > trackPSimHit_
string s
Definition: asciidump.py:422
tuple status
Definition: ntuplemaker.py:245
void setVertex(const Point &vertex)
set vertex
Definition: ParticleBase.h:249
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
const Point & vertex() const
vertex position
Definition: ParticleBase.h:229
g4t_iterator g4Track_end() const
const TrackingVertexRefVector & decayVertices() const
void setParentVertex(const TrackingVertexRef &)
TrackingVertexRef parentVertex_