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.3 by bendavid, Mon Jul 7 15:32:28 2008 UTC vs.
Revision 1.20 by paus, Thu Mar 29 23:41:55 2012 UTC

# Line 3 | Line 3
3   //
4   // Vertex
5   //
6 < // Vertex class implemented as holding a 3d vector as a point in space.
6 > // Vertex class derived from BaseVertex holding additional fit information.
7   //
8 < // Authors: J.Bendavid
8 > // Authors: J.Bendavid, C.Paus
9   //--------------------------------------------------------------------------------------------------
10  
11 < #ifndef DATATREE_VERTEX_H
12 < #define DATATREE_VERTEX_H
11 > #ifndef MITANA_DATATREE_VERTEX_H
12 > #define MITANA_DATATREE_VERTEX_H
13  
14 < #include "MitAna/DataTree/interface/DataObject.h"
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 DataObject
21 >  class Vertex : public BaseVertex
22    {
23 <    public:
24 <      Vertex() : fPoint(0,0,0) {}
25 <      Vertex(Double_t x, Double_t y, Double_t z) : fPoint(x,y,z) {}
26 <      ~Vertex() {}
27 <      
28 <      Double_t          Phi()   const { return fPoint.Phi(); }
29 <      Double_t          Rho()   const { return fPoint.Rho(); }
30 <      void              SetXYZ(Double_t x, Double_t y, Double_t z) { fPoint.SetXYZ(x,y,z); }
31 <      Double_t          X()     const { return fPoint.X();   }
32 <      Double_t          Y()     const { return fPoint.Y();   }
33 <      Double_t          Z()     const { return fPoint.Z();   }
34 <            
35 <    protected:
36 <      ThreeVector       fPoint; //point in space
37 <        
38 <    ClassDef(Vertex, 1) // Vertex class
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines