1 |
loizides |
1.1 |
//--------------------------------------------------------------------------------------------------
|
2 |
paus |
1.19 |
// $Id: Vertex.h,v 1.18 2011/10/09 23:27:44 bendavid Exp $
|
3 |
loizides |
1.1 |
//
|
4 |
|
|
// Vertex
|
5 |
|
|
//
|
6 |
loizides |
1.10 |
// Vertex class derived from BaseVertex holding additional fit information.
|
7 |
loizides |
1.1 |
//
|
8 |
paus |
1.19 |
// Authors: J.Bendavid, C.Paus
|
9 |
loizides |
1.1 |
//--------------------------------------------------------------------------------------------------
|
10 |
|
|
|
11 |
loizides |
1.5 |
#ifndef MITANA_DATATREE_VERTEX_H
|
12 |
|
|
#define MITANA_DATATREE_VERTEX_H
|
13 |
loizides |
1.1 |
|
14 |
bendavid |
1.4 |
#include <TMath.h>
|
15 |
bendavid |
1.6 |
#include "MitAna/DataTree/interface/BaseVertex.h"
|
16 |
bendavid |
1.13 |
#include "MitAna/DataCont/interface/RefArray.h"
|
17 |
|
|
#include "MitAna/DataTree/interface/Track.h"
|
18 |
loizides |
1.1 |
|
19 |
|
|
namespace mithep
|
20 |
|
|
{
|
21 |
bendavid |
1.6 |
class Vertex : public BaseVertex
|
22 |
loizides |
1.1 |
{
|
23 |
paus |
1.19 |
public:
|
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 |
|
|
BaseVertex(x,y,z,xErr,yErr,zErr), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0),
|
29 |
|
|
fNTracks(0) {}
|
30 |
|
|
Vertex(const ThreeVector &pos) :
|
31 |
|
|
BaseVertex(pos), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {}
|
32 |
|
|
|
33 |
|
|
void AddTrack(const Track *t,
|
34 |
|
|
Double32_t wgt = -1) { fTracks.Add(t);
|
35 |
|
|
fTrkWeights.Add(wgt); }
|
36 |
|
|
Double_t Chi2() const { return fChi2; }
|
37 |
|
|
Int_t Compare(const TObject *o) const;
|
38 |
|
|
Bool_t HasTrack(const Track *t) const { return fTracks.HasObject(t); }
|
39 |
|
|
Bool_t IsSortable() const { return kTRUE; }
|
40 |
|
|
Bool_t IsValid() const { return fIsValid; }
|
41 |
|
|
Double_t Ndof() const { return (fAdaptiveNdof>0.0 ?
|
42 |
|
|
fAdaptiveNdof:fNdof); }
|
43 |
|
|
UInt_t NTracksFit() const { return fNTracks; }
|
44 |
|
|
UInt_t NTracks() const { return fTracks.Entries(); }
|
45 |
|
|
EObjType ObjType() const { return kVertex; }
|
46 |
|
|
Double_t Prob() const { return TMath::Prob(fChi2,fNdof); }
|
47 |
|
|
void SetChi2(Double_t chi2) { fChi2 = chi2; }
|
48 |
|
|
void SetIsValid(Bool_t b) { fIsValid = b; }
|
49 |
|
|
void SetNdof(Double_t nDof) { fAdaptiveNdof = nDof; }
|
50 |
|
|
void SetNTracksFit(UInt_t n) { fNTracks = n; }
|
51 |
|
|
const Track *Trk(UInt_t i) const { return fTracks.At(i); }
|
52 |
|
|
Double_t TrackWeight(UInt_t i) const { return fTrkWeights.At(i); }
|
53 |
|
|
Double_t TrackWeight(const Track *t) const;
|
54 |
|
|
const FArrDouble32 &GetTrkWeights() const { return fTrkWeights; }
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
// Some structural tools
|
58 |
|
|
void Mark() const;
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
protected:
|
62 |
|
|
Double32_t fChi2; //[0,0,12]chi squared of conversion vertex fit
|
63 |
|
|
Bool_t fIsValid; //is vertex valid
|
64 |
|
|
UShort_t fNdof; //ndeg of freedom of conversion vertex fit
|
65 |
|
|
Double32_t fAdaptiveNdof; //ndeg of freedom of vtx fit (non-integer for wghted comps)
|
66 |
|
|
UShort_t fNTracks; //number of tracks used for the fit
|
67 |
|
|
FArrDouble32 fTrkWeights; //||array of track weights
|
68 |
|
|
RefArray<Track> fTracks; //tracks associated with the PV
|
69 |
|
|
|
70 |
mhchan |
1.16 |
ClassDef(Vertex, 4) // Vertex class
|
71 |
loizides |
1.1 |
};
|
72 |
|
|
}
|
73 |
loizides |
1.11 |
|
74 |
|
|
//--------------------------------------------------------------------------------------------------
|
75 |
paus |
1.19 |
inline void mithep::Vertex::Mark() const
|
76 |
|
|
{
|
77 |
|
|
// mark myself
|
78 |
|
|
mithep::DataObject::Mark();
|
79 |
|
|
// mark my dependencies if they are there
|
80 |
|
|
for (UInt_t i=0; i<NTracks(); i++)
|
81 |
|
|
fTracks.At(i)->Mark();
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
//--------------------------------------------------------------------------------------------------
|
85 |
loizides |
1.11 |
inline Int_t mithep::Vertex::Compare(const TObject *o) const
|
86 |
|
|
{
|
87 |
paus |
1.19 |
// Default compare function for sorting according to transverse momentum. Returns -1 if this
|
88 |
|
|
// object is smaller than given object, 0 if objects are equal and 1 if this is larger than given
|
89 |
|
|
// object.
|
90 |
|
|
|
91 |
loizides |
1.11 |
const mithep::Vertex *v = dynamic_cast<const mithep::Vertex *>(o);
|
92 |
|
|
if (!v)
|
93 |
|
|
return 1;
|
94 |
paus |
1.19 |
|
95 |
loizides |
1.11 |
Int_t myn = NTracks();
|
96 |
|
|
Int_t n = v->NTracks();
|
97 |
|
|
if (myn>n)
|
98 |
|
|
return -1;
|
99 |
|
|
else if (n>myn)
|
100 |
|
|
return +1;
|
101 |
|
|
|
102 |
|
|
Double_t myd = Chi2();
|
103 |
|
|
Double_t d = v->Chi2();
|
104 |
|
|
if (myd<d)
|
105 |
|
|
return -1;
|
106 |
|
|
else if (d<myd)
|
107 |
|
|
return +1;
|
108 |
|
|
|
109 |
|
|
return 0;
|
110 |
|
|
}
|
111 |
mhchan |
1.16 |
|
112 |
|
|
//--------------------------------------------------------------------------------------------------
|
113 |
|
|
inline Double_t mithep::Vertex::TrackWeight(const Track *t) const
|
114 |
|
|
{
|
115 |
paus |
1.19 |
for (UInt_t i = 0; i < fTracks.Entries(); i++) {
|
116 |
|
|
if (t == fTracks.At(i))
|
117 |
mhchan |
1.16 |
return fTrkWeights.At(i);
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
return -1;
|
121 |
|
|
}
|
122 |
loizides |
1.1 |
#endif
|