ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Vertex.h
Revision: 1.20
Committed: Thu Mar 29 23:41:55 2012 UTC (13 years, 1 month ago) by paus
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, HEAD
Changes since 1.19: +5 -6 lines
Log Message:
Version with working skimming and last 4.4 tag.

File Contents

# Content
1 //--------------------------------------------------------------------------------------------------
2 // $Id: Vertex.h,v 1.19 2012/03/28 12:15:35 paus Exp $
3 //
4 // Vertex
5 //
6 // Vertex class derived from BaseVertex holding additional fit information.
7 //
8 // Authors: J.Bendavid, C.Paus
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),
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(UInt_t i=1) 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 ClassDef(Vertex, 4) // Vertex class
71 };
72 }
73
74 //--------------------------------------------------------------------------------------------------
75 inline void mithep::Vertex::Mark(UInt_t ib) const
76 {
77 // mark myself
78 mithep::DataObject::Mark(ib);
79 // mark my dependencies if they are there
80 fTracks.Mark(ib);
81 }
82
83 //--------------------------------------------------------------------------------------------------
84 inline Int_t mithep::Vertex::Compare(const TObject *o) const
85 {
86 // Default compare function for sorting according to transverse momentum. Returns -1 if this
87 // object is smaller than given object, 0 if objects are equal and 1 if this is larger than given
88 // object.
89
90 const mithep::Vertex *v = dynamic_cast<const mithep::Vertex *>(o);
91 if (!v)
92 return 1;
93
94 Int_t myn = NTracks();
95 Int_t n = v->NTracks();
96 if (myn>n)
97 return -1;
98 else if (n>myn)
99 return +1;
100
101 Double_t myd = Chi2();
102 Double_t d = v->Chi2();
103 if (myd<d)
104 return -1;
105 else if (d<myd)
106 return +1;
107
108 return 0;
109 }
110
111 //--------------------------------------------------------------------------------------------------
112 inline Double_t mithep::Vertex::TrackWeight(const Track *t) const
113 {
114 for (UInt_t i = 0; i < fTracks.Entries(); i++) {
115 if (t == fTracks.At(i))
116 return fTrkWeights.At(i);
117 }
118
119 return -1;
120 }
121 #endif