ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/DataTree/interface/Vertex.h
(Generate patch)

Comparing UserCode/MitAna/DataTree/interface/Vertex.h (file contents):
Revision 1.7 by loizides, Tue Dec 9 17:47:00 2008 UTC vs.
Revision 1.13 by bendavid, Fri Dec 11 17:44:59 2009 UTC

# Line 3 | Line 3
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   //--------------------------------------------------------------------------------------------------
# Line 13 | Line 13
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() :
23 <        fChi2(0.0), fNdof(0), fNTracks(0) {}
24 >      Vertex() : fChi2(0), fIsValid(kFALSE), fNdof(0), fNTracks(0) {}
25        Vertex(Double_t x, Double_t y, Double_t z) :
26 <        BaseVertex(x,y,z), fChi2(0), fNdof(0), fNTracks(0) {}
26 >        BaseVertex(x,y,z), fChi2(0), fIsValid(kFALSE), fNdof(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.0), fNdof(0), fNTracks(0) {}
29 <      Vertex(const ThreeVector &pos) :
28 >        BaseVertex(x,y,z,xErr,yErr,zErr), fChi2(0), fIsValid(kFALSE), fNdof(0), fNTracks(0) {}
29 >      Vertex(const ThreeVector &pos) :
30          BaseVertex(pos), fChi2(0), fNdof(0), fNTracks(0) {}
30      ~Vertex() {}
31        
32 +      void                AddTrack(const Track *t) { fTracks.Add(t);           }
33        Double_t            Chi2()      const { return fChi2;                    }
34 <      UInt_t              Ndof()      const { return fNdof;                    }
35 <      UInt_t              NTracks()   const { return fNTracks;                 }
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 >      UShort_t            Ndof()      const { return 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                SetNdof(UInt_t nDof)       { fNdof = nDof;     }
45 <      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(UShort_t nDof)     { fNdof = nDof;           }
46 >      void                SetNTracksFit(UInt_t n)    { fNTracks = n;           }
47 >      const Track        *Trk(UInt_t i) const        { return fTracks.At(i);   }
48              
49      protected:
50 <      Double32_t          fChi2;     //chi squared of conversion vertex fit
51 <      UInt_t              fNdof;     //number of degrees of freedom of conversion vertex fit
52 <      UInt_t              fNTracks;  //number of tracks used for the fit
50 >      Double32_t          fChi2;     //[0,0,12]chi squared of conversion vertex fit
51 >      Bool_t              fIsValid;  //is vertex valid
52 >      UShort_t            fNdof;     //number of degrees of freedom of conversion vertex fit
53 >      UShort_t            fNTracks;  //number of tracks used for the fit
54 >      RefArray<Track>     fTracks;   //tracks associated with the PV
55          
56 <    ClassDef(Vertex, 1) // Vertex class
56 >    ClassDef(Vertex, 2) // Vertex class
57    };
58   }
59 +
60 + //--------------------------------------------------------------------------------------------------
61 + inline Int_t mithep::Vertex::Compare(const TObject *o) const
62 + {
63 +  // Default compare function for sorting according to transverse momentum.
64 +  // Returns -1 if this object is smaller than given object, 0 if objects are
65 +  // equal and 1 if this is larger than given object.
66 +
67 +  const mithep::Vertex *v = dynamic_cast<const mithep::Vertex *>(o);
68 +  if (!v)
69 +    return 1;
70 +
71 +  Int_t myn = NTracks();
72 +  Int_t n   = v->NTracks();
73 +  if (myn>n)
74 +    return -1;
75 +  else if (n>myn)
76 +    return +1;
77 +
78 +  Double_t myd = Chi2();
79 +  Double_t d   = v->Chi2();
80 +  if (myd<d)
81 +    return -1;
82 +  else if (d<myd)
83 +    return +1;
84 +  
85 +  return 0;
86 + }
87   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines