3 |
|
// |
4 |
|
// Vertex |
5 |
|
// |
6 |
< |
// Vertex class implemented as holding a 3d vector as a point in space with fit information |
6 |
> |
// Vertex class derived from BaseVertex holding additional fit information. |
7 |
|
// |
8 |
|
// Authors: J.Bendavid |
9 |
|
//-------------------------------------------------------------------------------------------------- |
10 |
|
|
11 |
< |
#ifndef DATATREE_VERTEX_H |
12 |
< |
#define DATATREE_VERTEX_H |
11 |
> |
#ifndef MITANA_DATATREE_VERTEX_H |
12 |
> |
#define MITANA_DATATREE_VERTEX_H |
13 |
|
|
14 |
|
#include <TMath.h> |
15 |
< |
#include "MitAna/DataTree/interface/DataObject.h" |
15 |
> |
#include "MitAna/DataTree/interface/BaseVertex.h" |
16 |
> |
#include "MitAna/DataCont/interface/RefArray.h" |
17 |
> |
#include "MitAna/DataTree/interface/Track.h" |
18 |
|
|
19 |
|
namespace mithep |
20 |
|
{ |
21 |
< |
class Vertex : public DataObject |
21 |
> |
class Vertex : public BaseVertex |
22 |
|
{ |
23 |
|
public: |
24 |
< |
Vertex() : |
25 |
< |
fPosition(0,0,0), |
26 |
< |
fXErr(0.0), |
25 |
< |
fYErr(0.0), |
26 |
< |
fZErr(0.0), |
27 |
< |
fChi2(0.0), |
28 |
< |
fNdof(0), |
29 |
< |
fNTracks(0) {} |
30 |
< |
Vertex(Double_t x, Double_t y, Double_t z) : |
31 |
< |
fPosition(x,y,z), |
32 |
< |
fXErr(0.0), |
33 |
< |
fYErr(0.0), |
34 |
< |
fZErr(0.0), |
35 |
< |
fChi2(0.0), |
36 |
< |
fNdof(0), |
37 |
< |
fNTracks(0) {} |
24 |
> |
Vertex() : fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {} |
25 |
> |
Vertex(Double_t x, Double_t y, Double_t z) : |
26 |
> |
BaseVertex(x,y,z), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {} |
27 |
|
Vertex(Double_t x, Double_t y, Double_t z, Double_t xErr, Double_t yErr, Double_t zErr) : |
28 |
< |
fPosition(x,y,z), |
29 |
< |
fXErr(xErr), |
30 |
< |
fYErr(yErr), |
42 |
< |
fZErr(zErr), |
43 |
< |
fChi2(0.0), |
44 |
< |
fNdof(0), |
45 |
< |
fNTracks(0) {} |
46 |
< |
Vertex(const ThreeVector &pos) : |
47 |
< |
fPosition(pos), |
48 |
< |
fXErr(0.0), |
49 |
< |
fYErr(0.0), |
50 |
< |
fZErr(0.0), |
51 |
< |
fChi2(0.0), |
52 |
< |
fNdof(0), |
53 |
< |
fNTracks(0) {} |
54 |
< |
~Vertex() {} |
28 |
> |
BaseVertex(x,y,z,xErr,yErr,zErr), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {} |
29 |
> |
Vertex(const ThreeVector &pos) : |
30 |
> |
BaseVertex(pos), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {} |
31 |
|
|
32 |
< |
Double_t Phi() const { return fPosition.Phi(); } |
33 |
< |
Double_t Rho() const { return fPosition.Rho(); } |
34 |
< |
const ThreeVector &Position() const { return fPosition; } |
35 |
< |
void SetPosition(const ThreeVector &pos) { fPosition = pos; } |
36 |
< |
void SetPosition(Double_t x, Double_t y, Double_t z) { fPosition.SetXYZ(x,y,z); } |
37 |
< |
Double_t X() const { return fPosition.X(); } |
38 |
< |
Double_t Y() const { return fPosition.Y(); } |
39 |
< |
Double_t Z() const { return fPosition.Z(); } |
40 |
< |
Double_t Chi2() const { return fChi2; } |
41 |
< |
UInt_t Ndof() const { return fNdof; } |
66 |
< |
Double_t XErr() const { return fXErr; } |
67 |
< |
Double_t YErr() const { return fYErr; } |
68 |
< |
Double_t ZErr() const { return fZErr; } |
32 |
> |
void AddTrack(const Track *t, Double32_t wgt = -1) { fTracks.Add(t); fTrkWeights.Add(wgt); } |
33 |
> |
Double_t Chi2() const { return fChi2; } |
34 |
> |
Int_t Compare(const TObject *o) const; |
35 |
> |
Bool_t HasTrack(const Track *t) const { return fTracks.HasObject(t); } |
36 |
> |
Bool_t IsSortable() const { return kTRUE; } |
37 |
> |
Bool_t IsValid() const { return fIsValid; } |
38 |
> |
Double_t Ndof() const { return (fAdaptiveNdof>0.0 ? fAdaptiveNdof:fNdof); } |
39 |
> |
UInt_t NTracksFit() const { return fNTracks; } |
40 |
> |
UInt_t NTracks() const { return fTracks.Entries(); } |
41 |
> |
EObjType ObjType() const { return kVertex; } |
42 |
|
Double_t Prob() const { return TMath::Prob(fChi2,fNdof); } |
43 |
< |
void SetChi2(Double_t chi2) { fChi2 = chi2; } |
44 |
< |
void SetErrors(Double_t xErr, Double_t yErr, Double_t zErr); |
45 |
< |
void SetNdof(UInt_t nDof) { fNdof = nDof; } |
46 |
< |
UInt_t NTracks() const { return fNTracks; } |
47 |
< |
void SetNTracks(UInt_t ntrks) { fNTracks = ntrks; } |
43 |
> |
void SetChi2(Double_t chi2) { fChi2 = chi2; } |
44 |
> |
void SetIsValid(Bool_t b) { fIsValid = b; } |
45 |
> |
void SetNdof(Double_t nDof) { fAdaptiveNdof = nDof; } |
46 |
> |
void SetNTracksFit(UInt_t n) { fNTracks = n; } |
47 |
> |
const Track *Trk(UInt_t i) const { return fTracks.At(i); } |
48 |
> |
Double_t TrackWeight(UInt_t i) const { return fTrkWeights.At(i); } |
49 |
> |
Double_t TrackWeight(const Track *t) const; |
50 |
> |
const FArrDouble32 &GetTrkWeights() const { return fTrkWeights; } |
51 |
|
|
52 |
|
protected: |
53 |
< |
ThreeVector fPosition; //point in space |
54 |
< |
Double32_t fXErr; //error in x |
55 |
< |
Double32_t fYErr; //error in y |
56 |
< |
Double32_t fZErr; //error in z |
57 |
< |
Double32_t fChi2; //chi squared of conversion vertex fit |
58 |
< |
UInt_t fNdof; //number of degrees of freedom of conversion vertex fit |
59 |
< |
UInt_t fNTracks; //number of tracks used for the fit |
53 |
> |
Double32_t fChi2; //[0,0,12]chi squared of conversion vertex fit |
54 |
> |
Bool_t fIsValid; //is vertex valid |
55 |
> |
UShort_t fNdof; //number of degrees of freedom of conversion vertex fit |
56 |
> |
Double32_t fAdaptiveNdof; //number of degrees of freedom of vertex fit (can be non-integer for weighted components) |
57 |
> |
UShort_t fNTracks; //number of tracks used for the fit |
58 |
> |
FArrDouble32 fTrkWeights; //||array of track weights |
59 |
> |
RefArray<Track> fTracks; //tracks associated with the PV |
60 |
|
|
61 |
< |
ClassDef(Vertex, 1) // Vertex class |
61 |
> |
ClassDef(Vertex, 4) // Vertex class |
62 |
|
}; |
63 |
|
} |
64 |
|
|
65 |
|
//-------------------------------------------------------------------------------------------------- |
66 |
< |
inline void mithep::Vertex::SetErrors(Double_t xErr, Double_t yErr, Double_t zErr) |
67 |
< |
{ |
68 |
< |
// set uncertainties on vertex position |
69 |
< |
|
70 |
< |
fXErr = xErr; |
71 |
< |
fYErr = yErr; |
72 |
< |
fZErr = zErr; |
66 |
> |
inline Int_t mithep::Vertex::Compare(const TObject *o) const |
67 |
> |
{ |
68 |
> |
// Default compare function for sorting according to transverse momentum. |
69 |
> |
// Returns -1 if this object is smaller than given object, 0 if objects are |
70 |
> |
// equal and 1 if this is larger than given object. |
71 |
> |
|
72 |
> |
const mithep::Vertex *v = dynamic_cast<const mithep::Vertex *>(o); |
73 |
> |
if (!v) |
74 |
> |
return 1; |
75 |
> |
|
76 |
> |
Int_t myn = NTracks(); |
77 |
> |
Int_t n = v->NTracks(); |
78 |
> |
if (myn>n) |
79 |
> |
return -1; |
80 |
> |
else if (n>myn) |
81 |
> |
return +1; |
82 |
> |
|
83 |
> |
Double_t myd = Chi2(); |
84 |
> |
Double_t d = v->Chi2(); |
85 |
> |
if (myd<d) |
86 |
> |
return -1; |
87 |
> |
else if (d<myd) |
88 |
> |
return +1; |
89 |
> |
|
90 |
> |
return 0; |
91 |
> |
} |
92 |
> |
|
93 |
> |
//-------------------------------------------------------------------------------------------------- |
94 |
> |
inline Double_t mithep::Vertex::TrackWeight(const Track *t) const |
95 |
> |
{ |
96 |
> |
for(UInt_t i = 0; i < fTracks.Entries(); i++) |
97 |
> |
{ |
98 |
> |
if(t == fTracks.At(i)) |
99 |
> |
return fTrkWeights.At(i); |
100 |
> |
} |
101 |
> |
|
102 |
> |
return -1; |
103 |
|
} |
104 |
|
#endif |