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.2 by fgolf, Fri Jul 8 09:16:47 2011 UTC vs.
Revision 1.3 by fgolf, Fri Dec 2 11:11:26 2011 UTC

# Line 2 | Line 2
2  
3   #ifndef __CINT__
4  
5 < #include <map>
5 > #include "TMath.h"
6 > #include <set>
7   #include <math.h>
8  
9   struct BabyDorkIdentifier {
10 <    BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float weight, float pfmet, float tcmet);
10 >    BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float pt1 = -999999., float pt2 = -999999., float pt3 = -999999.);
11      unsigned int run_, lumi_, event_;
12 <    float weight_, pfmet_, tcmet_;
12 >    float pt1_, pt2_, pt3_;
13      bool operator < (const BabyDorkIdentifier &) const;
14      bool operator == (const BabyDorkIdentifier &) const;
15   };
16  
17 < BabyDorkIdentifier::BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float weight, float pfmet, float tcmet)
18 <    : run_(run), lumi_(lumi), event_(event), weight_(weight), pfmet_(pfmet), tcmet_(tcmet)
17 > BabyDorkIdentifier::BabyDorkIdentifier (unsigned int run, unsigned int lumi, unsigned int event, float pt1, float pt2, float pt3)
18 >     : run_(run), lumi_(lumi), event_(event), pt1_(pt1), pt2_(pt2), pt3_(pt3)
19   {}
20  
21   bool BabyDorkIdentifier::operator < (const BabyDorkIdentifier &other) const
# Line 25 | Line 26 | bool BabyDorkIdentifier::operator < (con
26          return lumi_ < other.lumi_;
27      if (event_ != other.event_)
28          return event_ < other.event_;
29 <
29 > //    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_;
35      return false;
36   }
37  
# Line 37 | Line 43 | bool BabyDorkIdentifier::operator == (co
43          return false;
44      if (event_ != other.event_)
45          return false;
46 <
47 <    return true;
48 < }
49 <
50 < struct HypIdentifier {
51 <    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 <
46 > //    if (TMath::Abs(pt1_-other.pt1_) > 1e-6*fabs(pt1_))
47 > //        return false;
48 > //    if (TMath::Abs(pt2_-other.pt2_) > 1e-6*fabs(pt2_))
49 > //        return false;
50 > //    if (TMath::Abs(pt3_-other.pt3_) > 1e-6*fabs(pt3_))
51 > //        return false;
52      return true;
53   }
54  
55 < static std::map<BabyDorkIdentifier, HypIdentifier> already_seen_;
56 < bool is_duplicate (const BabyDorkIdentifier &id, const HypIdentifier &hyp)
55 > static std::set<BabyDorkIdentifier> already_seen_;
56 > bool is_duplicate (const BabyDorkIdentifier &id)
57   {
58 <    std::pair<std::map<BabyDorkIdentifier, HypIdentifier>::iterator, bool> ret =
59 <        already_seen_.insert(std::pair<BabyDorkIdentifier, HypIdentifier>(id, hyp));
60 <
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;
58 >    std::pair<std::set<BabyDorkIdentifier>::const_iterator, bool> ret =
59 >        already_seen_.insert(id);
60 >    return !ret.second;
61   }
62  
63 < 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)
63 > bool is_duplicate(unsigned int run, unsigned int lumi, unsigned int event, float pt1, float pt2, float pt3)
64   {
65 <    return is_duplicate(BabyDorkIdentifier(run,lumi,event, weight, pfmet, tcmet), HypIdentifier(fakeRateType, hypType, njets, nbtags, ht, eormu1, lep1isNum, pt1, eta1, eormu2, lep2isNum, pt2, eta2));
65 >    return is_duplicate(BabyDorkIdentifier(run,lumi,event,pt1,pt2,pt3));
66   }
67  
68   void reset_babydorkidentifier()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines