ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/FGolf/Tools/BabyDorkIdentifier.cc
Revision: 1.1
Committed: Sun May 22 21:49:44 2011 UTC (13 years, 11 months ago) by fgolf
Content type: text/plain
Branch: MAIN
CVS Tags: synchMay2011v1, ss20May2011
Log Message:
some additional tools

File Contents

# User Rev Content
1 fgolf 1.1 #include "BabyDorkIdentifier.h"
2    
3     #ifndef __CINT__
4    
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 pt1, float pt2 = -999999., float pt3 = -999999.);
11     unsigned int run_, lumi_, event_;
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 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
22     {
23     if (run_ != other.run_)
24     return run_ < other.run_;
25     if (lumi_ != other.lumi_)
26     return lumi_ < other.lumi_;
27     if (event_ != other.event_)
28     return event_ < other.event_;
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    
38     bool BabyDorkIdentifier::operator == (const BabyDorkIdentifier &other) const
39     {
40     if (run_ != other.run_)
41     return false;
42     if (lumi_ != other.lumi_)
43     return false;
44     if (event_ != other.event_)
45     return false;
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::set<BabyDorkIdentifier> already_seen_;
56     bool is_duplicate (const BabyDorkIdentifier &id)
57     {
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, float pt1, float pt2, float pt3)
64     {
65     return is_duplicate(BabyDorkIdentifier(run,lumi,event,pt1,pt2,pt3));
66     }
67    
68     void reset_babydorkidentifier()
69     {
70     already_seen_.clear();
71     }
72    
73     #endif
74