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.4 by bendavid, Tue Sep 30 12:51:37 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 with fit information
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 <TMath.h>
15 < #include "MitAna/DataTree/interface/DataObject.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() :
25 <        fPosition(0,0,0),
26 <        fXErr(0.0),
27 <        fYErr(0.0),
28 <        fZErr(0.0),
29 <        fChi2(0.0),
30 <        fNdof(0),
31 <        fNTracks(0) {}
32 <      Vertex(Double_t x, Double_t y, Double_t z) :
33 <        fPosition(x,y,z),
34 <        fXErr(0.0),
35 <        fYErr(0.0),
36 <        fZErr(0.0),
37 <        fChi2(0.0),
38 <        fNdof(0),
39 <        fNTracks(0) {}
40 <      Vertex(Double_t x, Double_t y, Double_t z, Double_t xErr, Double_t yErr, Double_t zErr) :
41 <        fPosition(x,y,z),
42 <        fXErr(xErr),
43 <        fYErr(yErr),
44 <        fZErr(zErr),
45 <        fChi2(0.0),
46 <        fNdof(0),
47 <        fNTracks(0) {}      
48 <      Vertex(const ThreeVector &pos) :
49 <        fPosition(pos),
50 <        fXErr(0.0),
51 <        fYErr(0.0),
52 <        fZErr(0.0),
53 <        fChi2(0.0),
54 <        fNdof(0),
55 <        fNTracks(0) {}
56 <      ~Vertex() {}
57 <      
58 <      Double_t            Phi()       const { return fPosition.Phi(); }
59 <      Double_t            Rho()       const { return fPosition.Rho(); }
60 <      const ThreeVector  &Position()  const { return fPosition; }
61 <      void                SetPosition(const ThreeVector &pos) { fPosition = pos; }
62 <      void                SetPosition(Double_t x, Double_t y, Double_t z) { fPosition.SetXYZ(x,y,z); }
63 <      Double_t            X()         const { return fPosition.X();   }
64 <      Double_t            Y()         const { return fPosition.Y();   }
65 <      Double_t            Z()         const { return fPosition.Z();   }
66 <      Double_t            Chi2()      const { return fChi2; }
67 <      UInt_t              Ndof()      const { return fNdof; }
68 <      Double_t            XErr()      const { return fXErr; }
69 <      Double_t            YErr()      const { return fYErr; }
70 <      Double_t            ZErr()      const { return fZErr; }
69 <      Double_t            Prob()      const { return TMath::Prob(fChi2,fNdof); }
70 <      void                SetChi2(Double_t chi2) { fChi2 = chi2; }
71 <      void                SetErrors(Double_t xErr, Double_t yErr, Double_t zErr);
72 <      void                SetNdof(UInt_t nDof)    { fNdof = nDof; }
73 <      UInt_t              NTracks()   const { return fNTracks; }
74 <      void                SetNTracks(UInt_t ntrks) { fNTracks = ntrks; }
75 <            
76 <    protected:
77 <      ThreeVector         fPosition; //point in space
78 <      Double32_t          fXErr; //error in x
79 <      Double32_t          fYErr; //error in y
80 <      Double32_t          fZErr; //error in z
81 <      Double32_t          fChi2; //chi squared of conversion vertex fit
82 <      UInt_t              fNdof; //number of degrees of freedom of conversion vertex fit
83 <      UInt_t              fNTracks; //number of tracks used for the fit
84 <        
85 <    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::SetErrors(Double_t xErr, Double_t yErr, Double_t zErr)
76 < {
77 <  // set uncertainties on vertex position
78 <
79 <  fXErr = xErr;
80 <  fYErr = yErr;
81 <  fZErr = zErr;
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