CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Flags.cc
Go to the documentation of this file.
2 
3 using pat::Flags;
4 
5 const std::string &
6 Flags::bitToString(uint32_t bit) {
7  static const std::string UNDEFINED_UNDEFINED = "Undefined/Undefined";
8  if (bit & CoreBits ) return Core::bitToString( Core::Bits(bit) );
9  else if (bit & SelectionBits ) return Selection::bitToString( Selection::Bits(bit) );
10  else if (bit & OverlapBits ) return Overlap::bitToString( Overlap::Bits(bit) );
11  else if (bit & IsolationBits ) return Isolation::bitToString( Isolation::Bits(bit) );
12  else return UNDEFINED_UNDEFINED;
13 }
14 
15 std::string Flags::maskToString ( uint32_t mask ) {
17  bool first = false;
18  for (uint32_t i = 1; i != 0; i <<= 1) {
19  if ( mask & i ) {
20  if (first) { first = false; } else { ret += " + "; }
21  ret += bitToString ( mask & i );
22  }
23  }
24  return ret;
25 }
26 
27 uint32_t
28 Flags::get( const std::string & str ) {
29  size_t idx = str.find_first_of("/");
30  if (idx != std::string::npos) {
31  std::string set = str.substr(0, idx);
32  if (set == "Core") return Core::get( str.substr(idx+1));
33  if (set == "Overlap") return Overlap::get( str.substr(idx+1));
34  if (set == "Isolation") return Isolation::get(str.substr(idx+1));
35  if (set == "Selection") return Selection::get(str.substr(idx+1));
36  }
37  return 0;
38 }
39 
40 uint32_t
41 Flags::get( const std::vector<std::string> & strs ) {
42  uint32_t ret = 0;
43  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
44  ret |= get( *it );
45  }
46  return ret;
47 }
48 
49 const std::string &
51  static const std::string STR_All = "Core/All",
52  STR_Duplicate = "Core/Duplicate",
53  STR_Preselection = "Core/Preselection",
54  STR_Vertexing = "Core/Vertexing",
55  STR_Overflow = "Core/Overflow",
56  STR_Undefined = "Core/Undefined";
57 
58  switch (bit) {
59  case All: return STR_All;
60  case Duplicate: return STR_Duplicate;
61  case Preselection: return STR_Preselection;
62  case Vertexing: return STR_Vertexing;
63  case Overflow: return STR_Overflow;
64  default: return STR_Undefined;
65  }
66 }
67 
69 Flags::Core::get ( const std::string & instr ) {
70  size_t idx = instr.find_first_of("/");
71  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx+1);
72  if (str == "All") return All;
73  else if (str == "Duplicate" ) return Duplicate;
74  else if (str == "Preselection" ) return Preselection;
75  else if (str == "Vertexing" ) return Vertexing;
76  else if (str == "Overlfow" ) return Overflow;
77  return Undefined;
78 }
79 
80 uint32_t
81 Flags::Core::get ( const std::vector<std::string> & strs ) {
82  uint32_t ret = 0;
83  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
84  ret |= get( *it );
85  }
86  return ret;
87 }
88 
89 const std::string &
91  static const std::string STR_All = "Selection/All",
92  STR_Bit0 = "Selection/Bit0",
93  STR_Bit1 = "Selection/Bit1",
94  STR_Bit2 = "Selection/Bit2",
95  STR_Bit3 = "Selection/Bit3",
96  STR_Bit4 = "Selection/Bit4",
97  STR_Bit5 = "Selection/Bit5",
98  STR_Bit6 = "Selection/Bit6",
99  STR_Bit7 = "Selection/Bit7",
100  STR_Bit8 = "Selection/Bit8",
101  STR_Bit9 = "Selection/Bit9",
102  STR_Bit10 = "Selection/Bit10",
103  STR_Bit11 = "Selection/Bit11",
104  STR_Undefined = "Selection/Undefined";
105  switch (bit) {
106  case All: return STR_All;
107  case Bit0: return STR_Bit0;
108  case Bit1: return STR_Bit1;
109  case Bit2: return STR_Bit2;
110  case Bit3: return STR_Bit3;
111  case Bit4: return STR_Bit4;
112  case Bit5: return STR_Bit5;
113  case Bit6: return STR_Bit6;
114  case Bit7: return STR_Bit7;
115  case Bit8: return STR_Bit8;
116  case Bit9: return STR_Bit9;
117  case Bit10: return STR_Bit10;
118  case Bit11: return STR_Bit11;
119  default:
120  return STR_Undefined;
121  }
122 }
123 
125 Flags::Selection::get ( int8_t bit) {
126  if (bit == -1) return All;
127  if (bit <= 11) return Bits((1 << bit) << 8);
128  return Undefined;
129 }
130 
132 Flags::Selection::get ( const std::string & instr ) {
133  size_t idx = instr.find_first_of("/");
134  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx+1);
135  if (str == "All" ) return All;
136  else if (str == "Bit0" ) return Bit0;
137  else if (str == "Bit1" ) return Bit1;
138  else if (str == "Bit2" ) return Bit2;
139  else if (str == "Bit3" ) return Bit3;
140  else if (str == "Bit4" ) return Bit4;
141  else if (str == "Bit5" ) return Bit5;
142  else if (str == "Bit6" ) return Bit6;
143  else if (str == "Bit7" ) return Bit7;
144  else if (str == "Bit8" ) return Bit8;
145  else if (str == "Bit9" ) return Bit9;
146  else if (str == "Bit10" ) return Bit10;
147  else if (str == "Bit11" ) return Bit11;
148  return Undefined;
149 }
150 
151 uint32_t
152 Flags::Selection::get ( const std::vector<std::string> & strs ) {
153  uint32_t ret = 0;
154  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
155  ret |= get( *it );
156  }
157  return ret;
158 }
159 
160 const std::string &
162  static const std::string STR_All = "Overlap/All",
163  STR_Jets = "Overlap/Jets",
164  STR_Electrons = "Overlap/Electrons",
165  STR_Muons = "Overlap/Muons",
166  STR_Taus = "Overlap/Taus",
167  STR_Photons = "Overlap/Photons",
168  STR_User = "Overlap/User",
169  STR_User1 = "Overlap/User1",
170  STR_User2 = "Overlap/User2",
171  STR_User3 = "Overlap/User3",
172  STR_Undefined = "Overlap/Undefined";
173  switch (bit) {
174  case All: return STR_All;
175  case Jets: return STR_Jets;
176  case Electrons: return STR_Electrons;
177  case Muons: return STR_Muons;
178  case Taus: return STR_Taus;
179  case Photons: return STR_Photons;
180  case User: return STR_User;
181  case User1: return STR_User1;
182  case User2: return STR_User2;
183  case User3: return STR_User3;
184  default:
185  return STR_Undefined;
186  }
187 }
188 
190 Flags::Overlap::get ( const std::string & instr ) {
191  size_t idx = instr.find_first_of("/");
192  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx+1);
193  if (str == "All" ) return All;
194  else if (str == "Jets" ) return Jets;
195  else if (str == "Electrons") return Electrons;
196  else if (str == "Muons" ) return Muons;
197  else if (str == "Taus" ) return Taus;
198  else if (str == "Photons" ) return Photons;
199  else if (str == "User" ) return User;
200  else if (str == "User1" ) return User1;
201  else if (str == "User2" ) return User2;
202  else if (str == "User3" ) return User3;
203  return Undefined;
204 }
205 
206 uint32_t
207 Flags::Overlap::get ( const std::vector<std::string> & strs ) {
208  uint32_t ret = 0;
209  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
210  ret |= get( *it );
211  }
212  return ret;
213 }
214 
215 const std::string &
217  static const std::string STR_All = "Isolation/All",
218  STR_Tracker = "Isolation/Tracker",
219  STR_ECal = "Isolation/ECal",
220  STR_HCal = "Isolation/HCal",
221  STR_Calo = "Isolation/Calo",
222  STR_User = "Isolation/User",
223  STR_User1 = "Isolation/User1",
224  STR_User2 = "Isolation/User2",
225  STR_User3 = "Isolation/User3",
226  STR_User4 = "Isolation/User4",
227  STR_User5 = "Isolation/User5",
228  STR_Undefined="Isolation/Undefined";
229  switch (bit) {
230  case All: return STR_All;
231  case Tracker: return STR_Tracker;
232  case ECal: return STR_ECal;
233  case HCal: return STR_HCal;
234  case Calo: return STR_Calo;
235  case User: return STR_User;
236  case User1: return STR_User1;
237  case User2: return STR_User2;
238  case User3: return STR_User3;
239  case User4: return STR_User4;
240  case User5: return STR_User5;
241  default:
242  return STR_Undefined;
243  }
244 }
245 
247 Flags::Isolation::get ( const std::string & instr ) {
248  size_t idx = instr.find_first_of("/");
249  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx+1);
250  if (str == "All" ) return All;
251  else if (str == "Tracker" ) return Tracker;
252  else if (str == "ECal" ) return ECal;
253  else if (str == "HCal" ) return HCal;
254  else if (str == "Calo" ) return Calo;
255  else if (str == "User" ) return User1;
256  else if (str == "User1" ) return User1;
257  else if (str == "User2" ) return User2;
258  else if (str == "User3" ) return User3;
259  else if (str == "User4" ) return User4;
260  else if (str == "User5" ) return User5;
261  return Undefined;
262 }
263 
264 uint32_t
265 Flags::Isolation::get ( const std::vector<std::string> & strs ) {
266  uint32_t ret = 0;
267  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
268  ret |= get( *it );
269  }
270  return ret;
271 }
272 
273 
static Bits get(int8_t bit)
Definition: Flags.cc:125
int i
Definition: DBlmapReader.cc:9
static const std::string & bitToString(uint32_t bit)
Definition: Flags.cc:6
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:161
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:216
tuple Jets
Definition: METSkim_cff.py:17
static Bits get(const std::string &str)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static std::string maskToString(uint32_t bit)
Definition: Flags.cc:15
Flags used in PAT, and static translator from flags to strings.
Definition: Flags.h:19
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:90
static uint32_t get(const std::string &str)
Definition: Flags.cc:28
static Bits get(const std::string &str)
static Bits get(const std::string &str)
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:50