ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/joshmt/MiscUtil.cxx
Revision: 1.2
Committed: Thu Oct 28 15:58:56 2010 UTC (14 years, 6 months ago) by joshmt
Content type: text/plain
Branch: MAIN
Changes since 1.1: +63 -1 lines
Log Message:
add a new class to hold event id info

File Contents

# User Rev Content
1 joshmt 1.1 /*
2     a place for very simple functions that don't depend on anything else
3    
4     can be easily #included into other code
5     */
6    
7     #include "TString.h"
8    
9     namespace jmt {
10    
11     //======misc utilities======
12     //gets rid of = > < from cuts in order to be better included in file names
13     TString fortranize(TString cut) {
14    
15     cut.ReplaceAll("==","eq");
16     cut.ReplaceAll(">=","gte");
17     cut.ReplaceAll("<=","lte");
18    
19     cut.ReplaceAll(">","gt");
20     cut.ReplaceAll("<","lt");
21    
22     return cut;
23     }
24    
25 joshmt 1.2 //======== container for run, lumisection, event number =========
26     class eventID {
27     public:
28     eventID();
29     eventID(ULong64_t RunNumber, ULong64_t LumiSection, ULong64_t EventNumber);
30     ~eventID();
31    
32     bool operator< (const eventID & id) const;
33     bool operator== (const eventID & id) const;
34     bool operator!= (const eventID & id) const;
35    
36     ULong64_t run;
37     ULong64_t ls;
38     ULong64_t ev;
39    
40     };
41    
42     eventID::eventID() : run(0),ls(0),ev(0) {}
43     eventID::eventID(ULong64_t RunNumber, ULong64_t LumiSection, ULong64_t EventNumber) :
44     run(RunNumber),ls(LumiSection),ev(EventNumber) {}
45     eventID::~eventID() {}
46    
47     bool eventID::operator== (const eventID & id) const {
48    
49     if (ev == id.ev &&
50     ls == id.ls &&
51     run == id.run) return true;
52    
53     return false;
54     }
55    
56     bool eventID::operator!= (const eventID & id) const {
57     return !(*this == id);
58     }
59    
60     bool eventID::operator< (const eventID & id) const {
61    
62     if (run < id.run) return true;
63     else if (run > id.run) return false;
64     else { //if run is equal
65    
66     //now compare lumi section
67     if ( ls < id.ls ) return true;
68     else if (ls > id.ls) return false;
69     else { //if ls is equal
70    
71     if ( ev < id.ev ) return true;
72     else if (ev > id.ev) return false;
73    
74     else { //these are the same event!
75     return false;
76     }
77     }
78     }
79    
80     //this shouldn't happen
81     assert(0);
82     return false;
83     }
84    
85     } //end of namespace
86    
87