CMS 3D CMS Logo

Flags.cc
Go to the documentation of this file.
2 
3 using pat::Flags;
4 
5 const std::string &Flags::bitToString(uint32_t bit) {
6  static const std::string UNDEFINED_UNDEFINED = "Undefined/Undefined";
7  if (bit & CoreBits)
8  return Core::bitToString(Core::Bits(bit));
9  else if (bit & SelectionBits)
11  else if (bit & OverlapBits)
13  else if (bit & IsolationBits)
15  else
16  return UNDEFINED_UNDEFINED;
17 }
18 
21  bool first = false;
22  for (uint32_t i = 1; i != 0; i <<= 1) {
23  if (mask & i) {
24  if (first) {
25  first = false;
26  } else {
27  ret += " + ";
28  }
29  ret += bitToString(mask & i);
30  }
31  }
32  return ret;
33 }
34 
35 uint32_t Flags::get(const std::string &str) {
36  size_t idx = str.find_first_of('/');
37  if (idx != std::string::npos) {
38  std::string set = str.substr(0, idx);
39  if (set == "Core")
40  return Core::get(str.substr(idx + 1));
41  if (set == "Overlap")
42  return Overlap::get(str.substr(idx + 1));
43  if (set == "Isolation")
44  return Isolation::get(str.substr(idx + 1));
45  if (set == "Selection")
46  return Selection::get(str.substr(idx + 1));
47  }
48  return 0;
49 }
50 
51 uint32_t Flags::get(const std::vector<std::string> &strs) {
52  uint32_t ret = 0;
53  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
54  ret |= get(*it);
55  }
56  return ret;
57 }
58 
60  static const std::string STR_All = "Core/All", STR_Duplicate = "Core/Duplicate",
61  STR_Preselection = "Core/Preselection", STR_Vertexing = "Core/Vertexing",
62  STR_Overflow = "Core/Overflow", STR_Undefined = "Core/Undefined";
63 
64  switch (bit) {
65  case All:
66  return STR_All;
67  case Duplicate:
68  return STR_Duplicate;
69  case Preselection:
70  return STR_Preselection;
71  case Vertexing:
72  return STR_Vertexing;
73  case Overflow:
74  return STR_Overflow;
75  default:
76  return STR_Undefined;
77  }
78 }
79 
81  size_t idx = instr.find_first_of('/');
82  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
83  if (str == "All")
84  return All;
85  else if (str == "Duplicate")
86  return Duplicate;
87  else if (str == "Preselection")
88  return Preselection;
89  else if (str == "Vertexing")
90  return Vertexing;
91  else if (str == "Overlfow")
92  return Overflow;
93  return Undefined;
94 }
95 
96 uint32_t Flags::Core::get(const std::vector<std::string> &strs) {
97  uint32_t ret = 0;
98  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
99  ret |= get(*it);
100  }
101  return ret;
102 }
103 
105  static const std::string STR_All = "Selection/All", STR_Bit0 = "Selection/Bit0", STR_Bit1 = "Selection/Bit1",
106  STR_Bit2 = "Selection/Bit2", STR_Bit3 = "Selection/Bit3", STR_Bit4 = "Selection/Bit4",
107  STR_Bit5 = "Selection/Bit5", STR_Bit6 = "Selection/Bit6", STR_Bit7 = "Selection/Bit7",
108  STR_Bit8 = "Selection/Bit8", STR_Bit9 = "Selection/Bit9", STR_Bit10 = "Selection/Bit10",
109  STR_Bit11 = "Selection/Bit11", STR_Undefined = "Selection/Undefined";
110  switch (bit) {
111  case All:
112  return STR_All;
113  case Bit0:
114  return STR_Bit0;
115  case Bit1:
116  return STR_Bit1;
117  case Bit2:
118  return STR_Bit2;
119  case Bit3:
120  return STR_Bit3;
121  case Bit4:
122  return STR_Bit4;
123  case Bit5:
124  return STR_Bit5;
125  case Bit6:
126  return STR_Bit6;
127  case Bit7:
128  return STR_Bit7;
129  case Bit8:
130  return STR_Bit8;
131  case Bit9:
132  return STR_Bit9;
133  case Bit10:
134  return STR_Bit10;
135  case Bit11:
136  return STR_Bit11;
137  default:
138  return STR_Undefined;
139  }
140 }
141 
143  if (bit == -1)
144  return All;
145  if (bit <= 11)
146  return Bits((1 << bit) << 8);
147  return Undefined;
148 }
149 
151  size_t idx = instr.find_first_of('/');
152  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
153  if (str == "All")
154  return All;
155  else if (str == "Bit0")
156  return Bit0;
157  else if (str == "Bit1")
158  return Bit1;
159  else if (str == "Bit2")
160  return Bit2;
161  else if (str == "Bit3")
162  return Bit3;
163  else if (str == "Bit4")
164  return Bit4;
165  else if (str == "Bit5")
166  return Bit5;
167  else if (str == "Bit6")
168  return Bit6;
169  else if (str == "Bit7")
170  return Bit7;
171  else if (str == "Bit8")
172  return Bit8;
173  else if (str == "Bit9")
174  return Bit9;
175  else if (str == "Bit10")
176  return Bit10;
177  else if (str == "Bit11")
178  return Bit11;
179  return Undefined;
180 }
181 
182 uint32_t Flags::Selection::get(const std::vector<std::string> &strs) {
183  uint32_t ret = 0;
184  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
185  ret |= get(*it);
186  }
187  return ret;
188 }
189 
191  static const std::string STR_All = "Overlap/All", STR_Jets = "Overlap/Jets", STR_Electrons = "Overlap/Electrons",
192  STR_Muons = "Overlap/Muons", STR_Taus = "Overlap/Taus", STR_Photons = "Overlap/Photons",
193  STR_User = "Overlap/User", STR_User1 = "Overlap/User1", STR_User2 = "Overlap/User2",
194  STR_User3 = "Overlap/User3", STR_Undefined = "Overlap/Undefined";
195  switch (bit) {
196  case All:
197  return STR_All;
198  case Jets:
199  return STR_Jets;
200  case Electrons:
201  return STR_Electrons;
202  case Muons:
203  return STR_Muons;
204  case Taus:
205  return STR_Taus;
206  case Photons:
207  return STR_Photons;
208  case User:
209  return STR_User;
210  case User1:
211  return STR_User1;
212  case User2:
213  return STR_User2;
214  case User3:
215  return STR_User3;
216  default:
217  return STR_Undefined;
218  }
219 }
220 
222  size_t idx = instr.find_first_of('/');
223  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
224  if (str == "All")
225  return All;
226  else if (str == "Jets")
227  return Jets;
228  else if (str == "Electrons")
229  return Electrons;
230  else if (str == "Muons")
231  return Muons;
232  else if (str == "Taus")
233  return Taus;
234  else if (str == "Photons")
235  return Photons;
236  else if (str == "User")
237  return User;
238  else if (str == "User1")
239  return User1;
240  else if (str == "User2")
241  return User2;
242  else if (str == "User3")
243  return User3;
244  return Undefined;
245 }
246 
247 uint32_t Flags::Overlap::get(const std::vector<std::string> &strs) {
248  uint32_t ret = 0;
249  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
250  ret |= get(*it);
251  }
252  return ret;
253 }
254 
256  static const std::string STR_All = "Isolation/All", STR_Tracker = "Isolation/Tracker", STR_ECal = "Isolation/ECal",
257  STR_HCal = "Isolation/HCal", STR_Calo = "Isolation/Calo", STR_User = "Isolation/User",
258  STR_User1 = "Isolation/User1", STR_User2 = "Isolation/User2", STR_User3 = "Isolation/User3",
259  STR_User4 = "Isolation/User4", STR_User5 = "Isolation/User5",
260  STR_Undefined = "Isolation/Undefined";
261  switch (bit) {
262  case All:
263  return STR_All;
264  case Tracker:
265  return STR_Tracker;
266  case ECal:
267  return STR_ECal;
268  case HCal:
269  return STR_HCal;
270  case Calo:
271  return STR_Calo;
272  case User:
273  return STR_User;
274  case User1:
275  return STR_User1;
276  case User2:
277  return STR_User2;
278  case User3:
279  return STR_User3;
280  case User4:
281  return STR_User4;
282  case User5:
283  return STR_User5;
284  default:
285  return STR_Undefined;
286  }
287 }
288 
290  size_t idx = instr.find_first_of('/');
291  const std::string &str = (idx == std::string::npos) ? instr : instr.substr(idx + 1);
292  if (str == "All")
293  return All;
294  else if (str == "Tracker")
295  return Tracker;
296  else if (str == "ECal")
297  return ECal;
298  else if (str == "HCal")
299  return HCal;
300  else if (str == "Calo")
301  return Calo;
302  else if (str == "User")
303  return User1;
304  else if (str == "User1")
305  return User1;
306  else if (str == "User2")
307  return User2;
308  else if (str == "User3")
309  return User3;
310  else if (str == "User4")
311  return User4;
312  else if (str == "User5")
313  return User5;
314  return Undefined;
315 }
316 
317 uint32_t Flags::Isolation::get(const std::vector<std::string> &strs) {
318  uint32_t ret = 0;
319  for (std::vector<std::string>::const_iterator it = strs.begin(), ed = strs.end(); it != ed; ++it) {
320  ret |= get(*it);
321  }
322  return ret;
323 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
edm::module::AbilityBits::Bits
Bits
Definition: moduleAbilityEnums.h:54
pat::Flags::Overlap::Bits
Bits
Definition: Flags.h:54
mps_fire.i
i
Definition: mps_fire.py:428
pat::Flags::Isolation::bitToString
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:255
pat::Flags::Core::Preselection
Definition: Flags.h:41
pat::Flags
Flags used in PAT, and static translator from flags to strings.
Definition: Flags.h:19
pat::Flags::Core::get
static Bits get(const std::string &str)
pat::Flags::Core::Vertexing
Definition: Flags.h:42
JetHTJetPlusHOFilter_cff.Photons
Photons
Definition: JetHTJetPlusHOFilter_cff.py:4
dqmdumpme.first
first
Definition: dqmdumpme.py:55
pat::Flags::Isolation::Bits
Bits
Definition: Flags.h:97
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
align::Tracker
Definition: StructureType.h:70
pat::Flags::Core::bitToString
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:59
pat::Flags::bitToString
static const std::string & bitToString(uint32_t bit)
Definition: Flags.cc:5
pat::Flags::Core::Duplicate
Definition: Flags.h:40
str
#define str(s)
Definition: TestProcessor.cc:51
pat::Flags::CoreBits
Definition: Flags.h:22
pat::Flags::Core::Bits
Bits
Definition: Flags.h:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTTauDQMOffline_cfi.Muons
Muons
Definition: HLTTauDQMOffline_cfi.py:51
pat::Flags::SelectionBits
Definition: Flags.h:23
pat::Flags::Selection::bitToString
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:104
dumpRecoGeometry_cfg.Calo
Calo
Definition: dumpRecoGeometry_cfg.py:191
pat::Flags::Isolation::get
static Bits get(const std::string &str)
pat::Flags::IsolationBits
Definition: Flags.h:25
pat::Flags::Core::Overflow
Definition: Flags.h:43
METSkim_cff.Jets
Jets
Definition: METSkim_cff.py:17
pat::Flags::Selection::Bits
Bits
Definition: Flags.h:74
pat::Flags::Overlap::bitToString
static const std::string & bitToString(Bits bit)
Definition: Flags.cc:190
pat::Flags::OverlapBits
Definition: Flags.h:24
muon::All
Definition: MuonSelectors.h:19
pat::Flags::Selection::get
static Bits get(int8_t bit)
Definition: Flags.cc:142
pat::Flags::Overlap::get
static Bits get(const std::string &str)
pat::Flags::Core::All
Definition: Flags.h:39
pat::Flags::maskToString
static std::string maskToString(uint32_t bit)
Definition: Flags.cc:19
Flags.h
Selector::set
void set(std::string const &s, bool val=true)
Set a given selection cut, on or off.
Definition: Selector.h:93
HLTTauDQMOffline_cfi.Electrons
Electrons
Definition: HLTTauDQMOffline_cfi.py:25
pat::Flags::get
static uint32_t get(const std::string &str)
Definition: Flags.cc:35