ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/interface/MatchingTools.h
(Generate patch)

Comparing UserCode/MitPhysics/Utils/interface/MatchingTools.h (file contents):
Revision 1.2 by loizides, Mon May 18 06:31:23 2009 UTC vs.
Revision 1.5 by loizides, Mon Jul 20 04:55:33 2009 UTC

# Line 22 | Line 22 | namespace mithep
22      public:
23        template<class V1, class V2>
24        static const V2 *Closest(const V1 *v1, const Collection<V2> &col, Double_t maxR,
25 <                               Bool_t self=kTRUE);
25 >                               Bool_t self=kFALSE);
26        template<class V1, class V2>
27 <      static const V2 *ClosestRPt(const V1 *v1, const Collection<V2> &col, Double_t max,
28 <                                  Bool_t self=kTRUE);
27 >      static const V2 *Closest(const V1 *v1, const Collection<V2> &col, Double_t maxR,
28 >                               Double_t maxPtDiff, Bool_t self=kFALSE);
29        template<class V1, class V2>
30        static TObjArray *Closests(const V1 *v1, const Collection<V2> &col, Double_t maxR,
31 <                                 Bool_t self=kTRUE);
31 >                                 Bool_t self=kFALSE);
32 >
33 >    ClassDef(MatchingTools, 0) // Geometric matching tools in eta-phi
34    };
35  
36    //------------------------------------------------------------------------------------------------
# Line 36 | Line 38 | namespace mithep
38    const V2 *MatchingTools::Closest(const V1 *v1, const Collection<V2> &col, Double_t maxR,
39                                     Bool_t self)
40    {
41 <    // Return closest geometrical neighbor in eta-phi within maximum delta R of maxR.
41 >    // Return closest geometrical neighbor in eta-phi within maximum DeltaR of maxR.
42      // If self is kFALSE make sure that identical pointers are excluded.
43      
44      if (!v1)
# Line 64 | Line 66 | namespace mithep
66  
67    //------------------------------------------------------------------------------------------------
68    template<class V1, class V2>
69 <  const V2 *MatchingTools::ClosestRPt(const V1 *v1, const Collection<V2> &col, Double_t max,
70 <                                      Bool_t self)
69 >  const V2 *MatchingTools::Closest(const V1 *v1, const Collection<V2> &col, Double_t maxR,
70 >                                   Double_t maxPtDiff, Bool_t self)
71    {
72 <    // Return closest geometrical neighbor in eta-phi-pt within maximum delta of max.
72 >    // Return closest geometrical neighbor in eta-phi within maximum DeltaR of maxR.
73 >    // Exclude particles where the relative pt differs by more than maxPtDiff.
74      // If self is kFALSE make sure that identical pointers are excluded.
75      
76      if (!v1)
# Line 76 | Line 79 | namespace mithep
79      const V2 *res = 0;
80      const UInt_t ents = col.GetEntries();
81      if (ents>0) {
82 <      Double_t d = 1e30;
82 >      Double_t dR = 1e30;
83        for (UInt_t i = 0; i<ents; ++i) {
84          const V2 *v2 = col.At(i);
85          if (!v2)
86            continue;
87          if (!self && (void*)v1==(void*)v2)
88            continue;
89 <        Double_t diff = MathUtils::DeltaR2(*v1,*v2);
90 <        Double_t ptd = 1-v1->Pt()/v2->Pt();
91 <        diff += ptd*ptd;
92 <        diff = TMath::Sqrt(diff);
93 <        if ((diff<max) && (diff<d)) {
89 >        Double_t ptd = TMath::Abs(1-v2->Pt()/v1->Pt());
90 >        if (ptd>maxPtDiff)
91 >          continue;
92 >        Double_t diff = MathUtils::DeltaR(*v1,*v2);
93 >        if ((diff<maxR) && (diff<dR)) {
94            res = v2;
95 <          d   = diff;
95 >          dR  = diff;
96          }
97        }
98      }
# Line 101 | Line 104 | namespace mithep
104    TObjArray *MatchingTools::Closests(const V1 *v1, const Collection<V2> &col, Double_t maxR,
105                                       Bool_t self)
106    {
107 <    // Return closest geometrical neighbors in eta-phi within maximum delta R of maxR.
107 >    // Return closest geometrical neighbors in eta-phi within maximum DeltaR of maxR.
108      // If self is kFALSE make sure that identical pointers are excluded.
109  
110      if (!v1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines