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.14 by bendavid, Wed Oct 20 20:33:39 2010 UTC vs.
Revision 1.20 by paus, Thu Mar 29 23:41:55 2012 UTC

# Line 5 | Line 5
5   //
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 MITANA_DATATREE_VERTEX_H
# Line 20 | Line 20 | namespace mithep
20   {
21    class Vertex : public BaseVertex
22    {
23 <    public:
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), 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) { fTracks.Add(t);           }
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 <            
49 <    protected:
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 <      Double32_t          fAdaptiveNdof; //number of degrees of freedom of vertex fit (can be non-integer for weighted components)
54 <      UShort_t            fNTracks;  //number of tracks used for the fit
55 <      RefArray<Track>     fTracks;   //tracks associated with the PV
56 <        
57 <    ClassDef(Vertex, 3) // 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 Int_t mithep::Vertex::Compare(const TObject *o) const
75 > inline void mithep::Vertex::Mark(UInt_t ib) const
76   {
77 <  // Default compare function for sorting according to transverse momentum.
78 <  // Returns -1 if this object is smaller than given object, 0 if objects are
79 <  // equal and 1 if this is larger than given object.
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 <
93 >  
94    Int_t myn = NTracks();
95    Int_t n   = v->NTracks();
96    if (myn>n)
# Line 85 | Line 107 | inline Int_t mithep::Vertex::Compare(con
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