test
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.
3 
5 
7 
8 const unsigned int TrackingParticle::longLivedTag = 65536;
9 
11 {
12  // No operation
13 }
14 
15 TrackingParticle::TrackingParticle( const SimTrack& simtrk, const TrackingVertexRef& parentVertex )
16 {
17  addG4Track( simtrk );
18  setParentVertex( parentVertex );
19 }
20 
22 {
23 }
24 
26 {
27  if( genParticles_.empty() ) return g4Tracks_.at( 0 ).type();
28  else return (*genParticles_.begin())->pdgId();
29 }
30 
32 {
33  return g4Tracks_.at( 0 ).eventId();
34 }
35 
37 {
38  genParticles_.push_back( ref );
39 }
40 
42 {
43  g4Tracks_.push_back( t );
44 }
45 
47 {
48  return genParticles_.begin();
49 }
50 
52 {
53  return genParticles_.end();
54 }
55 
57 {
58  return g4Tracks_.begin();
59 }
60 
62 {
63  return g4Tracks_.end();
64 }
65 
67 {
68  parentVertex_=ref;
69 }
70 
72 {
74 }
75 
77 {
79 }
80 
82 {
84 }
85 
87 {
88  return genParticles_;
89 }
90 
91 const std::vector<SimTrack>& TrackingParticle::g4Tracks() const
92 {
93  return g4Tracks_;
94 }
95 
97 {
98  return parentVertex_;
99 }
100 
102 {
103  return decayVertices_;
104 }
105 
107 {
108  return decayVertices_.begin();
109 }
110 
112 {
113  return decayVertices_.end();
114 }
115 
117 {
118  return g4Tracks_.at( 0 ).charge();
119 }
120 
122 {
123  return g4Tracks_.at( 0 ).charge()*3;
124 }
125 
127 {
128  return g4Tracks_.at( 0 ).momentum();
129 }
130 
132 {
133  return p4().Vect();
134 }
135 
137 {
138  return p4().BoostToCM();
139 }
140 
141 double TrackingParticle::p() const
142 {
143  return p4().P();
144 }
145 
147 {
148  return p4().E();
149 }
150 
151 double TrackingParticle::et() const
152 {
153  return p4().Et();
154 }
155 
157 {
158  return p4().M();
159 }
160 
162 {
163  return pow( mass(), 2 );
164 }
165 
166 double TrackingParticle::mt() const
167 {
168  return p4().Mt();
169 }
170 
172 {
173  return p4().Mt2();
174 }
175 
176 double TrackingParticle::px() const
177 {
178  return p4().Px();
179 }
180 
181 double TrackingParticle::py() const
182 {
183  return p4().Py();
184 }
185 
186 double TrackingParticle::pz() const
187 {
188  return p4().Pz();
189 }
190 
191 double TrackingParticle::pt() const
192 {
193  return p4().Pt();
194 }
195 
196 double TrackingParticle::phi() const
197 {
198  return p4().Phi();
199 }
200 
202 {
203  return p4().Theta();
204 }
205 
206 double TrackingParticle::eta() const
207 {
208  return p4().Eta();
209 }
210 
212 {
213  return p4().Rapidity();
214 }
215 
216 double TrackingParticle::y() const
217 {
218  return rapidity();
219 }
220 
222 {
223  return Point( vx(), vy(), vz() );
224 }
225 
226 double TrackingParticle::vx() const
227 {
228  const TrackingVertex& r=( *parentVertex_);
229  return r.position().X();
230 }
231 
232 double TrackingParticle::vy() const
233 {
234  const TrackingVertex& r=( *parentVertex_);
235  return r.position().Y();
236 }
237 
238 double TrackingParticle::vz() const
239 {
240  const TrackingVertex& r=( *parentVertex_);
241  return r.position().Z();
242 }
243 
245 {
246  if( genParticles_.empty() ) return -99; // Use the old invalid status flag that used to be set by TrackingTruthProducer.
247  else return (*genParticles_.begin())->status();
248 }
249 
251 {
252  return status()&longLivedTag;
253 }
254 
256 {
257  return numberOfHits_;
258 }
259 
261 {
262  return numberOfTrackerHits_;
263 }
264 
266 {
267  edm::LogWarning("TrackingParticle") << "The method matchedHit() has been deprecated. Use numberOfTrackerLayers() instead.";
268  return numberOfTrackerLayers_;
269 }
270 
272 {
273  return numberOfTrackerLayers_;
274 }
275 
276 void TrackingParticle::setNumberOfHits( int numberOfHits )
277 {
279 }
280 
281 void TrackingParticle::setNumberOfTrackerHits( int numberOfTrackerHits )
282 {
284 }
285 
286 void TrackingParticle::setNumberOfTrackerLayers( const int numberOfTrackerLayers )
287 {
289 }
290 
291 std::ostream& operator<< (std::ostream& s, TrackingParticle const & tp)
292 {
293  s << "TP momentum, q, ID, & Event #: "
294  << tp.p4() << " " << tp.charge() << " " << tp.pdgId() << " "
295  << tp.eventId().bunchCrossing() << "." << tp.eventId().event() << std::endl;
296 
297  for (TrackingParticle::genp_iterator hepT = tp.genParticle_begin(); hepT != tp.genParticle_end(); ++hepT)
298  {
299  s << " HepMC Track Momentum " << (*hepT)->momentum().rho() << std::endl;
300  }
301 
302  for (TrackingParticle::g4t_iterator g4T = tp.g4Track_begin(); g4T != tp.g4Track_end(); ++g4T)
303  {
304  s << " Geant Track Momentum " << g4T->momentum() << std::endl;
305  s << " Geant Track ID & type " << g4T->trackId() << " " << g4T->type() << std::endl;
306  if (g4T->type() != tp.pdgId())
307  {
308  s << " Mismatch b/t TrackingParticle and Geant types" << std::endl;
309  }
310  }
311  // Loop over decay vertices
312  s << " TP Vertex " << tp.vertex() << std::endl;
313  s << " Source vertex: " << tp.parentVertex()->position() << std::endl;
314  s << " " << tp.decayVertices().size() << " Decay vertices" << std::endl;
315  for (tv_iterator iTV = tp.decayVertices_begin(); iTV != tp.decayVertices_end(); ++iTV)
316  {
317  s << " Decay vertices: " << (**iTV).position() << std::endl;
318  }
319 
320  return s;
321 }
math::XYZTLorentzVectorD LorentzVector
Lorentz vector.
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
TrackingVertexRefVector decayVertices_
g4t_iterator g4Track_begin() const
int pdgId() const
PDG ID.
Point vertex() const
Parent vertex position.
TrackingParticle()
Default constructor. Note that the object will be useless until it is provided with a SimTrack and pa...
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
Vector boostToCM() const
Vector to boost to the particle centre of mass frame.
double py() const
y coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
int matchedHit() const
int numberOfTrackerHits_
The number of tracker only hits.
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:86
int status() const
Status word.
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
void setParentVertex(const TrackingVertexRef &ref)
math::XYZPointD Point
point in the space
void addGenParticle(const reco::GenParticleRef &ref)
reco::GenParticleRefVector genParticles_
double pz() const
z coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
const reco::GenParticleRefVector & genParticles() const
double mtSqr() const
Transverse mass squared. Note this is taken from the first SimTrack only.
bool longLived() const
is long lived?
double vy() const
y coordinate of parent vertex position
double y() const
Same as rapidity().
int bunchCrossing() const
get the detector field from this detid
double massSqr() const
Mass squared. Note this is taken from the first SimTrack only.
void addG4Track(const SimTrack &t)
int numberOfTrackerLayers() const
The number of tracker layers with a hit.
int numberOfHits_
The total number of hits.
double mt() const
Transverse mass. Note this is taken from the first SimTrack only.
std::vector< SimTrack > g4Tracks_
references to G4 and reco::GenParticle tracks
double p() const
Magnitude of momentum vector. Note this is taken from the first SimTrack only.
const TrackingVertexRefVector & decayVertices() const
std::vector< SimTrack >::const_iterator g4t_iterator
edm::Ref< TrackingVertexCollection > TrackingVertexRef
double mass() const
Mass. Note this is taken from the first SimTrack only.
genp_iterator genParticle_end() const
void clear()
Clear the vector.
Definition: RefVector.h:133
void addDecayVertex(const TrackingVertexRef &ref)
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
const std::vector< SimTrack > & g4Tracks() const
double vx() const
x coordinate of parent vertex position
int numberOfHits() const
Gives the total number of hits, including muon hits. Hits on overlaps in the same layer count separat...
double eta() const
Momentum pseudorapidity. Note this is taken from the first SimTrack only.
double rapidity() const
Rapidity. Note this is taken from the first SimTrack only.
EncodedEventId eventId() const
Signal source, crossing number.
void setNumberOfTrackerHits(int numberOfTrackerHits)
const TrackingVertexRef & parentVertex() const
Vector momentum() const
spatial momentum vector
int numberOfTrackerLayers_
The number of tracker layers with hits. Equivalent to the old matchedHit.
static const unsigned int longLivedTag
long lived flag
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
Monte Carlo truth information used for tracking validation.
int charge() const
Electric charge. Note this is taken from the first SimTrack only.
double px() const
x coordinate of momentum vector. Note this is taken from the first SimTrack only. ...
int numberOfTrackerHits() const
The number of hits in the tracker. Hits on overlaps in the same layer count separately.
void setNumberOfTrackerLayers(const int numberOfTrackerLayers)
math::XYZVectorD Vector
point in the space
int threeCharge() const
Kept for backwards compatibility. Gives 3*charge(), don&#39;t know why.
g4t_iterator g4Track_end() const
double et() const
Transverse energy. Note this is taken from the first SimTrack only.
TrackingVertexRef parentVertex_
double energy() const
Energy. Note this is taken from the first SimTrack only.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double phi() const
Momentum azimuthal angle. Note this is taken from the first SimTrack only.
double theta() const
Momentum polar angle. Note this is taken from the first SimTrack only.
void setNumberOfHits(int numberOfHits)
double vz() const
z coordinate of parent vertex position
const LorentzVector & position() const