ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Vertex.h
Revision: 1.16
Committed: Fri Sep 23 15:38:32 2011 UTC (13 years, 7 months ago) by mhchan
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025pre2
Changes since 1.15: +17 -3 lines
Log Message:
Added track weights

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: Vertex.h,v 1.15 2010/10/22 00:05:25 bendavid Exp $
3 //
4 // Vertex
5 //
6 // Vertex class derived from BaseVertex holding additional fit information.
7 //
8 // Authors: J.Bendavid
9 //--------------------------------------------------------------------------------------------------
10
11 #ifndef MITANA_DATATREE_VERTEX_H
12 #define MITANA_DATATREE_VERTEX_H
13
14 #include <TMath.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 BaseVertex
22 {
23 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), fNTracks(0) {}
29 Vertex(const ThreeVector &pos) :
30 BaseVertex(pos), fChi2(0), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {}
31
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 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 Double32_t TrackWeight(const Track *t) const;
49
50 protected:
51 Double32_t fChi2; //[0,0,12]chi squared of conversion vertex fit
52 Bool_t fIsValid; //is vertex valid
53 UShort_t fNdof; //number of degrees of freedom of conversion vertex fit
54 Double32_t fAdaptiveNdof; //number of degrees of freedom of vertex fit (can be non-integer for weighted components)
55 UShort_t fNTracks; //number of tracks used for the fit
56 FArrDouble32 fTrkWeights; //track weights
57 RefArray<Track> fTracks; //tracks associated with the PV
58
59 ClassDef(Vertex, 4) // Vertex class
60 };
61 }
62
63 //--------------------------------------------------------------------------------------------------
64 inline Int_t mithep::Vertex::Compare(const TObject *o) const
65 {
66 // Default compare function for sorting according to transverse momentum.
67 // Returns -1 if this object is smaller than given object, 0 if objects are
68 // equal and 1 if this is larger than given object.
69
70 const mithep::Vertex *v = dynamic_cast<const mithep::Vertex *>(o);
71 if (!v)
72 return 1;
73
74 Int_t myn = NTracks();
75 Int_t n = v->NTracks();
76 if (myn>n)
77 return -1;
78 else if (n>myn)
79 return +1;
80
81 Double_t myd = Chi2();
82 Double_t d = v->Chi2();
83 if (myd<d)
84 return -1;
85 else if (d<myd)
86 return +1;
87
88 return 0;
89 }
90
91 //--------------------------------------------------------------------------------------------------
92 inline Double_t mithep::Vertex::TrackWeight(const Track *t) const
93 {
94 for(UInt_t i = 0; i < fTracks.Entries(); i++)
95 {
96 if(t == fTracks.At(i))
97 return fTrkWeights.At(i);
98 }
99
100 return -1;
101 }
102 #endif