Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-08 23:57:45

0001 /**
0002  * \class GlobalObject
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/L1TGlobal/interface/GlobalObject.h"
0017 
0018 // system include files
0019 #include <cstring>
0020 
0021 // user include files
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 
0024 using namespace l1t;
0025 
0026 l1t::GlobalObject l1TGtObjectStringToEnum(const std::string& label) {
0027   static const l1t::L1TGtObjectStringToEnum l1TGtObjectStringToEnumMap[] = {{"Mu", gtMu},
0028                                                                             {"MuShower", gtMuShower},
0029                                                                             {"EG", gtEG},
0030                                                                             {"Tau", gtTau},
0031                                                                             {"Jet", gtJet},
0032                                                                             {"ETM", gtETM},
0033                                                                             {"ETT", gtETT},
0034                                                                             {"HTT", gtHTT},
0035                                                                             {"HTM", gtHTM},
0036                                                                             {"ETMHF", gtETMHF},
0037                                                                             {"TowerCount", gtTowerCount},
0038                                                                             {"MinBiasHFP0", gtMinBiasHFP0},
0039                                                                             {"MinBiasHFM0", gtMinBiasHFM0},
0040                                                                             {"MinBiasHFP1", gtMinBiasHFP1},
0041                                                                             {"MinBiasHFM1", gtMinBiasHFM1},
0042                                                                             {"ETTem", gtETTem},
0043                                                                             {"AsymEt", gtAsymmetryEt},
0044                                                                             {"AsymHt", gtAsymmetryHt},
0045                                                                             {"AsymEtHF", gtAsymmetryEtHF},
0046                                                                             {"AsymEtHF", gtAsymmetryHtHF},
0047                                                                             {"CENT0", gtCentrality0},
0048                                                                             {"CENT1", gtCentrality1},
0049                                                                             {"CENT2", gtCentrality2},
0050                                                                             {"CENT3", gtCentrality3},
0051                                                                             {"CENT4", gtCentrality4},
0052                                                                             {"CENT5", gtCentrality5},
0053                                                                             {"CENT6", gtCentrality6},
0054                                                                             {"CENT7", gtCentrality7},
0055                                                                             {"External", gtExternal},
0056                                                                             {"ObjNull", ObjNull},
0057                                                                             {nullptr, (GlobalObject)-1}};
0058 
0059   l1t::GlobalObject value = (GlobalObject)-1;
0060 
0061   bool found = false;
0062   for (int i = 0; l1TGtObjectStringToEnumMap[i].label && (!found); ++i)
0063     if (!std::strcmp(label.c_str(), l1TGtObjectStringToEnumMap[i].label)) {
0064       found = true;
0065       value = l1TGtObjectStringToEnumMap[i].value;
0066     }
0067 
0068   // in case of unrecognized GlobalObject, returns Mu
0069   // and write a warning (to not throw an exception)
0070   if (!found) {
0071     edm::LogInfo("L1TGlobal") << "\n  '" << label << "' is not a recognized GlobalObject. \n  Return ObjNull.";
0072 
0073     value = ObjNull;
0074   }
0075 
0076   if (value == ObjNull) {
0077     edm::LogInfo("L1TGlobal") << "\n  ObjNull means no valid GlobalObject defined!";
0078   }
0079 
0080   return value;
0081 }
0082 
0083 std::string l1t::l1TGtObjectEnumToString(const GlobalObject& gtObject) {
0084   std::string gtObjectString;
0085 
0086   switch (gtObject) {
0087     case gtMu: {
0088       gtObjectString = "Mu";
0089     } break;
0090 
0091     case gtMuShower: {
0092       gtObjectString = "MuShower";
0093     } break;
0094 
0095     case gtEG: {
0096       gtObjectString = "EG";
0097     } break;
0098 
0099     case gtTau: {
0100       gtObjectString = "Tau";
0101     } break;
0102 
0103     case gtJet: {
0104       gtObjectString = "Jet";
0105     } break;
0106 
0107     case gtETM: {
0108       gtObjectString = "ETM";
0109     } break;
0110 
0111     case gtETT: {
0112       gtObjectString = "ETT";
0113     } break;
0114 
0115     case gtHTT: {
0116       gtObjectString = "HTT";
0117     } break;
0118 
0119     case gtHTM: {
0120       gtObjectString = "HTM";
0121     } break;
0122 
0123     case gtETMHF: {
0124       gtObjectString = "ETMHF";
0125     } break;
0126 
0127     case gtTowerCount: {
0128       gtObjectString = "TowerCount";
0129     } break;
0130 
0131     case gtMinBiasHFP0: {
0132       gtObjectString = "MinBiasHFP0";
0133     } break;
0134 
0135     case gtMinBiasHFM0: {
0136       gtObjectString = "MinBiasHFM0";
0137     } break;
0138 
0139     case gtMinBiasHFP1: {
0140       gtObjectString = "MinBiasHFP1";
0141     } break;
0142 
0143     case gtMinBiasHFM1: {
0144       gtObjectString = "MinBiasHFM1";
0145     } break;
0146 
0147     case gtETTem: {
0148       gtObjectString = "ETTem";
0149     } break;
0150 
0151     case gtAsymmetryEt: {
0152       gtObjectString = "AsymEt";
0153     } break;
0154 
0155     case gtAsymmetryHt: {
0156       gtObjectString = "AsymHt";
0157     } break;
0158 
0159     case gtAsymmetryEtHF: {
0160       gtObjectString = "AsymEtHF";
0161     } break;
0162 
0163     case gtAsymmetryHtHF: {
0164       gtObjectString = "AsymHtHF";
0165     } break;
0166 
0167     case gtCentrality0: {
0168       gtObjectString = "CENT0";
0169     } break;
0170 
0171     case gtCentrality1: {
0172       gtObjectString = "CENT1";
0173     } break;
0174 
0175     case gtCentrality2: {
0176       gtObjectString = "CENT2";
0177     } break;
0178 
0179     case gtCentrality3: {
0180       gtObjectString = "CENT3";
0181     } break;
0182 
0183     case gtCentrality4: {
0184       gtObjectString = "CENT4";
0185     } break;
0186 
0187     case gtCentrality5: {
0188       gtObjectString = "CENT5";
0189     } break;
0190 
0191     case gtCentrality6: {
0192       gtObjectString = "CENT6";
0193     } break;
0194 
0195     case gtCentrality7: {
0196       gtObjectString = "CENT7";
0197     } break;
0198 
0199     case gtExternal: {
0200       gtObjectString = "External";
0201     } break;
0202 
0203     case ObjNull: {
0204       gtObjectString = "ObjNull";
0205       edm::LogInfo("L1TGlobal") << "\n  ObjNull means no valid GlobalObject defined!";
0206     } break;
0207 
0208     default: {
0209       edm::LogInfo("L1TGlobal") << "\n  '" << gtObject << "' is not a recognized GlobalObject. "
0210                                 << "\n  Return ObjNull, which means no valid GlobalObject defined!";
0211 
0212       gtObjectString = "ObjNull";
0213 
0214     } break;
0215   }
0216 
0217   return gtObjectString;
0218 }