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.4 by loizides, Sun Jun 28 08:03:09 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  
34    //------------------------------------------------------------------------------------------------
# Line 36 | Line 36 | namespace mithep
36    const V2 *MatchingTools::Closest(const V1 *v1, const Collection<V2> &col, Double_t maxR,
37                                     Bool_t self)
38    {
39 <    // Return closest geometrical neighbor in eta-phi within maximum delta R of maxR.
39 >    // Return closest geometrical neighbor in eta-phi within maximum DeltaR of maxR.
40      // If self is kFALSE make sure that identical pointers are excluded.
41      
42      if (!v1)
# Line 64 | Line 64 | namespace mithep
64  
65    //------------------------------------------------------------------------------------------------
66    template<class V1, class V2>
67 <  const V2 *MatchingTools::ClosestRPt(const V1 *v1, const Collection<V2> &col, Double_t max,
68 <                                      Bool_t self)
67 >  const V2 *MatchingTools::Closest(const V1 *v1, const Collection<V2> &col, Double_t maxR,
68 >                                   Double_t maxPtDiff, Bool_t self)
69    {
70 <    // Return closest geometrical neighbor in eta-phi-pt within maximum delta of max.
70 >    // Return closest geometrical neighbor in eta-phi within maximum DeltaR of maxR.
71 >    // Exclude particles where the relative pt differs by more than maxPtDiff.
72      // If self is kFALSE make sure that identical pointers are excluded.
73      
74      if (!v1)
# Line 76 | Line 77 | namespace mithep
77      const V2 *res = 0;
78      const UInt_t ents = col.GetEntries();
79      if (ents>0) {
80 <      Double_t d = 1e30;
80 >      Double_t dR = 1e30;
81        for (UInt_t i = 0; i<ents; ++i) {
82          const V2 *v2 = col.At(i);
83          if (!v2)
84            continue;
85          if (!self && (void*)v1==(void*)v2)
86            continue;
87 <        Double_t diff = MathUtils::DeltaR2(*v1,*v2);
88 <        Double_t ptd = 1-v1->Pt()/v2->Pt();
89 <        diff += ptd*ptd;
90 <        diff = TMath::Sqrt(diff);
91 <        if ((diff<max) && (diff<d)) {
87 >        Double_t ptd = TMath::Abs(1-v2->Pt()/v1->Pt());
88 >        if (ptd>maxPtDiff)
89 >          continue;
90 >        Double_t diff = MathUtils::DeltaR(*v1,*v2);
91 >        if ((diff<maxR) && (diff<dR)) {
92            res = v2;
93 <          d   = diff;
93 >          dR  = diff;
94          }
95        }
96      }
# Line 101 | Line 102 | namespace mithep
102    TObjArray *MatchingTools::Closests(const V1 *v1, const Collection<V2> &col, Double_t maxR,
103                                       Bool_t self)
104    {
105 <    // Return closest geometrical neighbors in eta-phi within maximum delta R of maxR.
105 >    // Return closest geometrical neighbors in eta-phi within maximum DeltaR of maxR.
106      // If self is kFALSE make sure that identical pointers are excluded.
107  
108      if (!v1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines