Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaPIDinfo.h
Go to the documentation of this file.
1#ifndef Podd_THaPIDinfo_h_
2#define Podd_THaPIDinfo_h_
3
5//
6// THaPIDinfo
7//
8// Particle ID information. Usually associated with a THaTrack.
9//
11
12#include "TObject.h"
13#include <vector>
14#include <stdexcept>
15
16class THaTrack;
17
18class THaPIDinfo : public TObject {
19public:
20 THaPIDinfo();
21 THaPIDinfo( UInt_t ndet, UInt_t npart );
22 explicit THaPIDinfo( const THaTrack* track );
23 virtual ~THaPIDinfo() = default;
24
25 virtual void Clear( Option_t* opt="" );
26 virtual void CombinePID();
27 UInt_t GetNdet() const { return fNdet; }
28 UInt_t GetNpart() const { return fNpart; }
29 Double_t GetPrior( UInt_t particle ) const;
30 Double_t GetProb( UInt_t detector, UInt_t particle ) const;
31 Double_t GetCombinedProb( UInt_t particle ) const;
32 virtual void Print( Option_t* opt="" ) const;
33 void SetDefaultPriors();
34 void SetPrior( UInt_t particle, Double_t prob );
35 void SetProb( UInt_t detector, UInt_t particle, Double_t prob );
36 void SetSize( UInt_t ndet, UInt_t prob );
37
38protected:
39 // A priori particle probabilities
40 std::vector<Double_t> fPrior;
41 // Probabilities per detector & particle hypothesis
42 std::vector<Double_t> fProb;
43 // Probabilities for the particle hypotheses
44 std::vector<Double_t> fCombinedProb;
45 // Number of detectors
47 // Number of particles
49
50 UInt_t idx( UInt_t detector, UInt_t particle ) const;
51
52 ClassDef(THaPIDinfo,1) //Particle ID information for a track
53};
54
55//---------------- inlines ----------------------------------------------------
56inline UInt_t THaPIDinfo::idx( UInt_t det, UInt_t part ) const
57{
58 // Return index into array (2d array realized as 1d)
59
60 return det*fNpart + part;
61}
62
63//_____________________________________________________________________________
65{
66 if( part >= fNpart )
67 throw std::logic_error("illegal particle index");
68 return fPrior[part];
69}
70
71//_____________________________________________________________________________
72inline Double_t THaPIDinfo::GetProb( UInt_t det, UInt_t part ) const
73{
74 if( det >= fNdet || part >= fNpart )
75 throw std::logic_error("illegal detector or particle index");
76 return fProb[idx(det, part)];
77}
78
79//_____________________________________________________________________________
81{
82 if( part >= fNpart )
83 throw std::logic_error("illegal particle index");
84 return fCombinedProb[part];
85}
86
87//_____________________________________________________________________________
88inline void THaPIDinfo::SetPrior( UInt_t part, Double_t prob )
89{
90 if( part >= fNpart )
91 throw std::logic_error("illegal particle index");
92 fPrior[part] = prob;
93}
94
95//_____________________________________________________________________________
96inline void THaPIDinfo::SetProb( UInt_t det, UInt_t part, Double_t prob )
97{
98 if( det >= fNdet || part >= fNpart )
99 throw std::logic_error("illegal detector or particle index");
100 fProb[idx(det, part)] = prob;
101}
102
103#endif
104
unsigned int UInt_t
double Double_t
const char Option_t
#define ClassDef(name, id)
UInt_t fNpart
Definition THaPIDinfo.h:48
Double_t GetProb(UInt_t detector, UInt_t particle) const
Definition THaPIDinfo.h:72
std::vector< Double_t > fPrior
Definition THaPIDinfo.h:40
void SetDefaultPriors()
void SetSize(UInt_t ndet, UInt_t prob)
virtual void CombinePID()
void SetProb(UInt_t detector, UInt_t particle, Double_t prob)
Definition THaPIDinfo.h:96
UInt_t GetNpart() const
Definition THaPIDinfo.h:28
UInt_t fNdet
Definition THaPIDinfo.h:46
virtual ~THaPIDinfo()=default
std::vector< Double_t > fProb
Definition THaPIDinfo.h:42
Double_t GetCombinedProb(UInt_t particle) const
Definition THaPIDinfo.h:80
virtual void Print(Option_t *opt="") const
void SetPrior(UInt_t particle, Double_t prob)
Definition THaPIDinfo.h:88
virtual void Clear(Option_t *opt="")
Double_t GetPrior(UInt_t particle) const
Definition THaPIDinfo.h:64
std::vector< Double_t > fCombinedProb
Definition THaPIDinfo.h:44
UInt_t idx(UInt_t detector, UInt_t particle) const
Definition THaPIDinfo.h:56
UInt_t GetNdet() const
Definition THaPIDinfo.h:27