CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
GlobalObject.cc File Reference
#include "DataFormats/L1TGlobal/interface/GlobalObject.h"
#include <cstring>
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Functions

l1t::GlobalObject l1TGtObjectStringToEnum (const std::string &label)
 

Function Documentation

l1t::GlobalObject l1TGtObjectStringToEnum ( const std::string &  label)

Definition at line 27 of file GlobalObject.cc.

References newFWLiteAna::found, l1t::gtEG, l1t::gtETM, l1t::gtETM2, l1t::gtETT, l1t::gtExternal, l1t::gtHTM, l1t::gtHTT, l1t::gtJet, l1t::gtMinBiasHFM0, l1t::gtMinBiasHFM1, l1t::gtMinBiasHFP0, l1t::gtMinBiasHFP1, l1t::gtMu, l1t::gtTau, i, l1t::L1TGtObjectStringToEnum::label, l1t::ObjNull, l1t::L1TGtObjectStringToEnum::value, and relativeConstraints::value.

27  {
28 
29 
30 
31  static const l1t::L1TGtObjectStringToEnum l1TGtObjectStringToEnumMap[] = {
32  {"Mu", gtMu},
33  {"EG", gtEG},
34  {"Tau", gtTau},
35  {"Jet", gtJet},
36  {"ETM", gtETM},
37  {"ETT", gtETT},
38  {"HTT", gtHTT},
39  {"HTM", gtHTM},
40  {"ETM2", gtETM2},
41  {"MinBiasHFP0", gtMinBiasHFP0},
42  {"MinBiasHFM0", gtMinBiasHFM0},
43  {"MinBiasHFP1", gtMinBiasHFP1},
44  {"MinBiasHFM1", gtMinBiasHFM1},
45  {"External", gtExternal},
46  {"ObjNull", ObjNull},
47  {0, (GlobalObject) - 1}
48  };
49 
51 
52  bool found = false;
53  for (int i = 0; l1TGtObjectStringToEnumMap[i].label && (!found); ++i)
54  if (!std::strcmp(label.c_str(), l1TGtObjectStringToEnumMap[i].label)) {
55  found = true;
56  value = l1TGtObjectStringToEnumMap[i].value;
57  }
58 
59  // in case of unrecognized GlobalObject, returns Mu
60  // and write a warning (to not throw an exception)
61  if (!found) {
62  edm::LogInfo("L1TGlobal") << "\n '" << label
63  << "' is not a recognized GlobalObject. \n Return ObjNull.";
64 
65  value = ObjNull;
66  }
67 
68  if (value == ObjNull) {
69  edm::LogInfo("L1TGlobal")
70  << "\n ObjNull means no valid GlobalObject defined!";
71  }
72 
73  return value;
74 }
int i
Definition: DBlmapReader.cc:9
GlobalObject
Definition: GlobalObject.h:16
the string to enum and enum to string conversions for GlobalObject
Definition: GlobalObject.h:37