ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Vertex.h
Revision: 1.18
Committed: Sun Oct 9 23:27:44 2011 UTC (13 years, 6 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_025c_branch2, Mit_025c_branch1, Mit_025c_branch0, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025
Branch point for: Mit_025c_branch
Changes since 1.17: +4 -3 lines
Log Message:
minor cleanup

File Contents

# User Rev Content
1 loizides 1.1 //--------------------------------------------------------------------------------------------------
2 bendavid 1.18 // $Id: Vertex.h,v 1.17 2011/10/07 23:00:04 mhchan 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     // Authors: J.Bendavid
9     //--------------------------------------------------------------------------------------------------
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     public:
24 bendavid 1.15 Vertex() : fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {}
25 loizides 1.5 Vertex(Double_t x, Double_t y, Double_t z) :
26 bendavid 1.14 BaseVertex(x,y,z), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {}
27 bendavid 1.4 Vertex(Double_t x, Double_t y, Double_t z, Double_t xErr, Double_t yErr, Double_t zErr) :
28 bendavid 1.14 BaseVertex(x,y,z,xErr,yErr,zErr), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {}
29 loizides 1.8 Vertex(const ThreeVector &pos) :
30 bendavid 1.18 BaseVertex(pos), fChi2(0), fIsValid(kFALSE), fNdof(0), fAdaptiveNdof(0), fNTracks(0) {}
31 loizides 1.1
32 mhchan 1.16 void AddTrack(const Track *t, Double32_t wgt = -1) { fTracks.Add(t); fTrkWeights.Add(wgt); }
33 bendavid 1.13 Double_t Chi2() const { return fChi2; }
34 loizides 1.11 Int_t Compare(const TObject *o) const;
35 bendavid 1.13 Bool_t HasTrack(const Track *t) const { return fTracks.HasObject(t); }
36 loizides 1.12 Bool_t IsSortable() const { return kTRUE; }
37 bendavid 1.13 Bool_t IsValid() const { return fIsValid; }
38 bendavid 1.14 Double_t Ndof() const { return (fAdaptiveNdof>0.0 ? fAdaptiveNdof:fNdof); }
39 bendavid 1.13 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 bendavid 1.14 void SetNdof(Double_t nDof) { fAdaptiveNdof = nDof; }
46 bendavid 1.13 void SetNTracksFit(UInt_t n) { fNTracks = n; }
47     const Track *Trk(UInt_t i) const { return fTracks.At(i); }
48 bendavid 1.18 Double_t TrackWeight(UInt_t i) const { return fTrkWeights.At(i); }
49     Double_t TrackWeight(const Track *t) const;
50 mhchan 1.17 const FArrDouble32 &GetTrkWeights() const { return fTrkWeights; }
51 loizides 1.1
52     protected:
53 loizides 1.9 Double32_t fChi2; //[0,0,12]chi squared of conversion vertex fit
54 bendavid 1.13 Bool_t fIsValid; //is vertex valid
55 loizides 1.9 UShort_t fNdof; //number of degrees of freedom of conversion vertex fit
56 bendavid 1.14 Double32_t fAdaptiveNdof; //number of degrees of freedom of vertex fit (can be non-integer for weighted components)
57 loizides 1.9 UShort_t fNTracks; //number of tracks used for the fit
58 mhchan 1.17 FArrDouble32 fTrkWeights; //||array of track weights
59 bendavid 1.13 RefArray<Track> fTracks; //tracks associated with the PV
60 loizides 1.1
61 mhchan 1.16 ClassDef(Vertex, 4) // Vertex class
62 loizides 1.1 };
63     }
64 loizides 1.11
65     //--------------------------------------------------------------------------------------------------
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 mhchan 1.16
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 loizides 1.1 #endif