Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DChargedTrack.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DChargedTrack.h
4 // Created: Mon Dec 7 14:29:24 EST 2009
5 // Creator: staylor (on Linux ifarml6 2.6.18-128.el5 x86_64)
6 //
7 
8 #ifndef _DChargedTrack_
9 #define _DChargedTrack_
10 
11 #include <vector>
12 
13 #include "TMath.h"
14 
15 #include <JANA/JObject.h>
16 
17 #include <particleType.h>
19 
20 using namespace std;
21 
22 class DChargedTrack : public jana::JObject
23 {
24  public:
25  JOBJECT_PUBLIC(DChargedTrack);
26 
27  oid_t candidateid; // unique id for this track //same as for DTrackCandidate
28  vector<const DChargedTrackHypothesis*> dChargedTrackHypotheses;
29 
30  int Get_Charge(void) const;
31  bool Contains_Charge(int locCharge) const;
32 
33  const DChargedTrackHypothesis* Get_Hypothesis(Particle_t locPID) const;
34  const DChargedTrackHypothesis* Get_BestFOM(void) const;
35  const DChargedTrackHypothesis* Get_BestTrackingFOM(void) const;
36 
37  void toStrings(vector<pair<string,string> > &items) const
38  {
39  AddString(items, "Nhypotheses", "%d", dChargedTrackHypotheses.size());
40  }
41 };
42 
43 inline bool DChargedTrack::Contains_Charge(int locCharge) const
44 {
45  for(unsigned int loc_i = 0; loc_i < dChargedTrackHypotheses.size(); ++loc_i)
46  {
47  if(ParticleCharge(dChargedTrackHypotheses[loc_i]->PID()) == locCharge)
48  return true;
49  }
50  return false;
51 }
52 
53 inline int DChargedTrack::Get_Charge(void) const
54 {
55  const DChargedTrackHypothesis* locChargedTrackHypothesis = Get_BestFOM();
56  return ((locChargedTrackHypothesis == NULL) ? 0 : ParticleCharge(locChargedTrackHypothesis->PID()));
57 }
58 
60 {
61  for(unsigned int loc_i = 0; loc_i < dChargedTrackHypotheses.size(); ++loc_i)
62  {
63  if(dChargedTrackHypotheses[loc_i]->PID() == locPID)
64  return dChargedTrackHypotheses[loc_i];
65  }
66  return NULL;
67 }
68 
70 {
71  if(dChargedTrackHypotheses.empty())
72  return NULL;
73  double locBestFOM = -2.0;
74  const DChargedTrackHypothesis* locBestChargedTrackHypothesis = dChargedTrackHypotheses[0];
75  for(size_t loc_i = 0; loc_i < dChargedTrackHypotheses.size(); ++loc_i)
76  {
77  if(dChargedTrackHypotheses[loc_i]->Get_FOM() > locBestFOM)
78  {
79  locBestChargedTrackHypothesis = dChargedTrackHypotheses[loc_i];
80  locBestFOM = locBestChargedTrackHypothesis->Get_FOM();
81  }
82  }
83  return locBestChargedTrackHypothesis;
84 }
85 
87 {
88  if(dChargedTrackHypotheses.empty())
89  return NULL;
90  double locBestFOM = -2.0;
91  const DChargedTrackHypothesis* locBestChargedTrackHypothesis = dChargedTrackHypotheses[0];
92  for(size_t loc_i = 0; loc_i < dChargedTrackHypotheses.size(); ++loc_i)
93  {
94  auto locTimeBasedTrack = dChargedTrackHypotheses[loc_i]->Get_TrackTimeBased();
95  unsigned int locNDF = locTimeBasedTrack->Ndof;
96  double locFOM = (locNDF > 0) ? TMath::Prob(locTimeBasedTrack->chisq, locNDF) : numeric_limits<double>::quiet_NaN();
97  if(locFOM > locBestFOM)
98  {
99  locBestChargedTrackHypothesis = dChargedTrackHypotheses[loc_i];
100  locBestFOM = locFOM;
101  }
102  }
103  return locBestChargedTrackHypothesis;
104 }
105 
106 #endif // _DChargedTrack_
107 
const DChargedTrackHypothesis * Get_BestTrackingFOM(void) const
Definition: DChargedTrack.h:86
const DTrackTimeBased * Get_TrackTimeBased(void) const
static int ParticleCharge(Particle_t p)
const DChargedTrackHypothesis * Get_Hypothesis(Particle_t locPID) const
Definition: DChargedTrack.h:59
int Get_Charge(void) const
Definition: DChargedTrack.h:53
bool Contains_Charge(int locCharge) const
Definition: DChargedTrack.h:43
void toStrings(vector< pair< string, string > > &items) const
Definition: DChargedTrack.h:37
int Ndof
Number of degrees of freedom in the fit.
const DChargedTrackHypothesis * Get_BestFOM(void) const
Definition: DChargedTrack.h:69
vector< const DChargedTrackHypothesis * > dChargedTrackHypotheses
Definition: DChargedTrack.h:28
Particle_t PID(void) const
Particle_t
Definition: particleType.h:12