Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:51

0001 /**
0002  * \class L1GtObject
0003  *
0004  *
0005  * Description: define an enumeration of L1 GT objects.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  *
0012  *
0013  */
0014 
0015 // this class header
0016 #include "DataFormats/L1GlobalTrigger/interface/L1GtObject.h"
0017 
0018 // system include files
0019 #include <cstring>
0020 
0021 // user include files
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 
0024 L1GtObject l1GtObjectStringToEnum(const std::string& label) {
0025   static const L1GtObjectStringToEnum l1GtObjectStringToEnumMap[] = {{"Mu", Mu},
0026                                                                      {"NoIsoEG", NoIsoEG},
0027                                                                      {"IsoEG", IsoEG},
0028                                                                      {"CenJet", CenJet},
0029                                                                      {"ForJet", ForJet},
0030                                                                      {"TauJet", TauJet},
0031                                                                      {"ETM", ETM},
0032                                                                      {"ETT", ETT},
0033                                                                      {"HTT", HTT},
0034                                                                      {"HTM", HTM},
0035                                                                      {"JetCounts", JetCounts},
0036                                                                      {"HfBitCounts", HfBitCounts},
0037                                                                      {"HfRingEtSums", HfRingEtSums},
0038                                                                      {"TechTrig", TechTrig},
0039                                                                      {"Castor", Castor},
0040                                                                      {"BPTX", BPTX},
0041                                                                      {"GtExternal", GtExternal},
0042                                                                      {"ObjNull", ObjNull},
0043                                                                      {nullptr, (L1GtObject)-1}};
0044 
0045   L1GtObject value = (L1GtObject)-1;
0046 
0047   bool found = false;
0048   for (int i = 0; l1GtObjectStringToEnumMap[i].label && (!found); ++i)
0049     if (!std::strcmp(label.c_str(), l1GtObjectStringToEnumMap[i].label)) {
0050       found = true;
0051       value = l1GtObjectStringToEnumMap[i].value;
0052     }
0053 
0054   // in case of unrecognized L1GtObject, returns Mu
0055   // and write a warning (to not throw an exception)
0056   if (!found) {
0057     edm::LogInfo("L1GtObject") << "\n  '" << label << "' is not a recognized L1GtObject. \n  Return ObjNull.";
0058 
0059     value = ObjNull;
0060   }
0061 
0062   if (value == ObjNull) {
0063     edm::LogInfo("L1GtObject") << "\n  ObjNull means no valid L1GtObject defined!";
0064   }
0065 
0066   return value;
0067 }
0068 
0069 std::string l1GtObjectEnumToString(const L1GtObject& gtObject) {
0070   std::string gtObjectString;
0071 
0072   switch (gtObject) {
0073     case Mu: {
0074       gtObjectString = "Mu";
0075     } break;
0076 
0077     case NoIsoEG: {
0078       gtObjectString = "NoIsoEG";
0079     } break;
0080 
0081     case IsoEG: {
0082       gtObjectString = "IsoEG";
0083     } break;
0084 
0085     case CenJet: {
0086       gtObjectString = "CenJet";
0087     } break;
0088 
0089     case ForJet: {
0090       gtObjectString = "ForJet";
0091     } break;
0092 
0093     case TauJet: {
0094       gtObjectString = "TauJet";
0095     } break;
0096 
0097     case ETM: {
0098       gtObjectString = "ETM";
0099     } break;
0100 
0101     case ETT: {
0102       gtObjectString = "ETT";
0103     } break;
0104 
0105     case HTT: {
0106       gtObjectString = "HTT";
0107     } break;
0108 
0109     case HTM: {
0110       gtObjectString = "HTM";
0111     } break;
0112 
0113     case JetCounts: {
0114       gtObjectString = "JetCounts";
0115     } break;
0116 
0117     case HfBitCounts: {
0118       gtObjectString = "HfBitCounts";
0119     } break;
0120 
0121     case HfRingEtSums: {
0122       gtObjectString = "HfRingEtSums";
0123     } break;
0124 
0125     case TechTrig: {
0126       gtObjectString = "TechTrig";
0127     } break;
0128 
0129     case Castor: {
0130       gtObjectString = "Castor";
0131     } break;
0132 
0133     case BPTX: {
0134       gtObjectString = "BPTX";
0135     } break;
0136 
0137     case GtExternal: {
0138       gtObjectString = "GtExternal";
0139     } break;
0140 
0141     case ObjNull: {
0142       gtObjectString = "ObjNull";
0143       edm::LogInfo("L1GtObject") << "\n  ObjNull means no valid L1GtObject defined!";
0144     } break;
0145 
0146     default: {
0147       edm::LogInfo("L1GtObject") << "\n  '" << gtObject << "' is not a recognized L1GtObject. "
0148                                  << "\n  Return ObjNull, which means no valid L1GtObject defined!";
0149 
0150       gtObjectString = "ObjNull";
0151 
0152     } break;
0153   }
0154 
0155   return gtObjectString;
0156 }