ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/FGolf/Tools/BabyDorkIdentifier.cc
(Generate patch)

Comparing UserCode/FGolf/Tools/BabyDorkIdentifier.cc (file contents):
Revision 1.1 by fgolf, Sun May 22 21:49:44 2011 UTC vs.
Revision 1.2 by fgolf, Fri Jul 8 09:16:47 2011 UTC

# Line 2 | Line 2
2  
3   #ifndef __CINT__
4  
5 < #include "TMath.h"
6 < #include <set>
5 > #include <map>
6   #include <math.h>
7  
8   struct BabyDorkIdentifier {
9 <    BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float pt1, float pt2 = -999999., float pt3 = -999999.);
9 >    BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float weight, float pfmet, float tcmet);
10      unsigned int run_, lumi_, event_;
11 <    float pt1_, pt2_, pt3_;
11 >    float weight_, pfmet_, tcmet_;
12      bool operator < (const BabyDorkIdentifier &) const;
13      bool operator == (const BabyDorkIdentifier &) const;
14   };
15  
16 < BabyDorkIdentifier::BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float pt1, float pt2, float pt3)
17 <     : run_(run), lumi_(lumi), event_(event), pt1_(pt1), pt2_(pt2), pt3_(pt3)
16 > BabyDorkIdentifier::BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float weight, float pfmet, float tcmet)
17 >    : run_(run), lumi_(lumi), event_(event), weight_(weight), pfmet_(pfmet), tcmet_(tcmet)
18   {}
19  
20   bool BabyDorkIdentifier::operator < (const BabyDorkIdentifier &other) const
# Line 26 | Line 25 | bool BabyDorkIdentifier::operator < (con
25          return lumi_ < other.lumi_;
26      if (event_ != other.event_)
27          return event_ < other.event_;
28 < //    if (TMath::Abs(pt1_-other.pt1_) > 1e-6*fabs(pt1_))
30 < //      return pt1_ < other.pt1_;
31 < //    if (TMath::Abs(pt2_-other.pt2_) > 1e-6*fabs(pt2_))
32 < //      return pt2_ < other.pt2_;
33 < //    if (TMath::Abs(pt3_-other.pt3_) > 1e-6*fabs(pt3_))
34 < //      return pt3_ < other.pt3_;
28 >
29      return false;
30   }
31  
# Line 43 | Line 37 | bool BabyDorkIdentifier::operator == (co
37          return false;
38      if (event_ != other.event_)
39          return false;
40 < //    if (TMath::Abs(pt1_-other.pt1_) > 1e-6*fabs(pt1_))
41 < //        return false;
42 < //    if (TMath::Abs(pt2_-other.pt2_) > 1e-6*fabs(pt2_))
43 < //        return false;
44 < //    if (TMath::Abs(pt3_-other.pt3_) > 1e-6*fabs(pt3_))
45 < //        return false;
40 >
41 >    return true;
42 > }
43 >
44 > struct HypIdentifier {
45 >    HypIdentifier (enum FakeRateType fakeRateType, enum DileptonHypType hypType, unsigned int njets, unsigned int nbtags, float ht,
46 >                   int eormu1, bool lep1isNum, float pt1, float eta1, int eormu2=-1, bool lep2isNum=false, float pt2=-999999., float eta2=-999999.);
47 >    FakeRateType fakeRateType_;
48 >    DileptonHypType hypType_;
49 >    unsigned int njets_, nbtags_;
50 >    float ht_;
51 >    int eormu1_;
52 >    bool lep1isNum_;
53 >    float pt1_, eta1_;
54 >    int eormu2_;
55 >    bool lep2isNum_;
56 >    float pt2_, eta2_;
57 >    bool operator < (const HypIdentifier &) const;
58 >    bool operator == (const HypIdentifier &) const;
59 > };
60 >
61 > HypIdentifier::HypIdentifier (enum FakeRateType fakeRateType, enum DileptonHypType hypType, unsigned int njets, unsigned int nbtags, float ht,
62 >                              int eormu1, bool lep1isNum, float pt1, float eta1, int eormu2, bool lep2isNum, float pt2, float eta2)    
63 >    : fakeRateType_(fakeRateType), hypType_(hypType), njets_(njets), nbtags_(nbtags), ht_(ht), eormu1_(eormu1), lep1isNum_(lep1isNum), pt1_(pt1), eta1_(eta1), eormu2_(eormu2), lep2isNum_(lep2isNum), pt2_(pt2), eta2_(eta2)
64 > {}
65 >
66 > bool HypIdentifier::operator < (const HypIdentifier &other) const
67 > {
68 >    if (fakeRateType_ != other.fakeRateType_)
69 >        return fakeRateType_ < other.fakeRateType_;
70 >    if (hypType_ != other.hypType_)
71 >        return hypType_ > other.hypType_;
72 >    if (fabs((pt1_+pt2_)-(other.pt1_+other.pt2_)) > 1e-6*fabs(pt1_))
73 >        return (pt1_+pt2_) < (other.pt1_+other.pt2_);
74 >
75 >    return false;
76 > }
77 >
78 > bool HypIdentifier::operator == (const HypIdentifier& other) const
79 > {
80 >    if (fakeRateType_ != other.fakeRateType_)
81 >        return false;
82 >    if (hypType_ != other.hypType_)
83 >        return false;
84 >    if (fabs((pt1_+pt2_)-(other.pt1_+other.pt2_)) > 1e-6*fabs(pt1_))
85 >        return false;
86 >
87      return true;
88   }
89  
90 < static std::set<BabyDorkIdentifier> already_seen_;
91 < bool is_duplicate (const BabyDorkIdentifier &id)
90 > static std::map<BabyDorkIdentifier, HypIdentifier> already_seen_;
91 > bool is_duplicate (const BabyDorkIdentifier &id, const HypIdentifier &hyp)
92   {
93 <    std::pair<std::set<BabyDorkIdentifier>::const_iterator, bool> ret =
94 <        already_seen_.insert(id);
95 <    return !ret.second;
93 >    std::pair<std::map<BabyDorkIdentifier, HypIdentifier>::iterator, bool> ret =
94 >        already_seen_.insert(std::pair<BabyDorkIdentifier, HypIdentifier>(id, hyp));
95 >
96 >    if (ret.second)
97 >        return !ret.second;
98 >    
99 >    HypIdentifier tmp_hyp = ret.first->second;
100 >    if (hyp < tmp_hyp || hyp == tmp_hyp)
101 >        return true;
102 >    else {
103 >        already_seen_.erase(ret.first);
104 >        already_seen_.insert(std::pair<BabyDorkIdentifier, HypIdentifier>(id, hyp));
105 >        return false;
106 >    }
107 >    
108 >    return false;
109   }
110  
111 < bool is_duplicate(unsigned int run, unsigned int lumi, unsigned int event, float pt1, float pt2, float pt3)
111 > bool is_duplicate(unsigned int run, unsigned int lumi, unsigned int event, enum FakeRateType fakeRateType, enum DileptonHypType hypType,
112 >                  unsigned int njets, unsigned int nbtags, float ht, float pfmet, float tcmet, float weight, int eormu1, bool lep1isNum, float pt1, float eta1,
113 >                  int eormu2, bool lep2isNum, float pt2, float eta2)
114   {
115 <    return is_duplicate(BabyDorkIdentifier(run,lumi,event,pt1,pt2,pt3));
115 >    return is_duplicate(BabyDorkIdentifier(run,lumi,event, weight, pfmet, tcmet), HypIdentifier(fakeRateType, hypType, njets, nbtags, ht, eormu1, lep1isNum, pt1, eta1, eormu2, lep2isNum, pt2, eta2));
116   }
117  
118   void reset_babydorkidentifier()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines