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::gtMinBias, 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  {"MinBias", gtMinBias},
42  {"External", gtExternal},
43  {"ObjNull", ObjNull},
44  {0, (GlobalObject) - 1}
45  };
46 
48 
49  bool found = false;
50  for (int i = 0; l1TGtObjectStringToEnumMap[i].label && (!found); ++i)
51  if (!std::strcmp(label.c_str(), l1TGtObjectStringToEnumMap[i].label)) {
52  found = true;
53  value = l1TGtObjectStringToEnumMap[i].value;
54  }
55 
56  // in case of unrecognized GlobalObject, returns Mu
57  // and write a warning (to not throw an exception)
58  if (!found) {
59  edm::LogInfo("L1TGlobal") << "\n '" << label
60  << "' is not a recognized GlobalObject. \n Return ObjNull.";
61 
62  value = ObjNull;
63  }
64 
65  if (value == ObjNull) {
66  edm::LogInfo("L1TGlobal")
67  << "\n ObjNull means no valid GlobalObject defined!";
68  }
69 
70  return value;
71 }
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:34