CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/L1GlobalTrigger/src/L1GtObject.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "DataFormats/L1GlobalTrigger/interface/L1GtObject.h"
00019 
00020 // system include files
00021 #include <cstring>
00022 
00023 // user include files
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 
00026 L1GtObject l1GtObjectStringToEnum(const std::string& label) {
00027 
00028     static L1GtObjectStringToEnum l1GtObjectStringToEnumMap[] = {
00029             {"Mu", Mu},
00030             {"NoIsoEG", NoIsoEG},
00031             {"IsoEG", IsoEG},
00032             {"CenJet", CenJet},
00033             {"ForJet", ForJet},
00034             {"TauJet", TauJet},
00035             {"ETM", ETM},
00036             {"ETT", ETT},
00037             {"HTT", HTT},
00038             {"HTM", HTM},
00039             {"JetCounts", JetCounts},
00040             {"HfBitCounts", HfBitCounts},
00041             {"HfRingEtSums", HfRingEtSums},
00042             {"TechTrig", TechTrig},
00043             {"Castor", Castor},
00044             {"BPTX", BPTX},
00045             {"GtExternal", GtExternal},
00046             {"ObjNull", ObjNull},
00047             {0, (L1GtObject) - 1}
00048     };
00049 
00050     L1GtObject value = (L1GtObject) - 1;
00051 
00052     bool found = false;
00053     for (int i = 0; l1GtObjectStringToEnumMap[i].label && (!found); ++i)
00054         if (!std::strcmp(label.c_str(), l1GtObjectStringToEnumMap[i].label)) {
00055             found = true;
00056             value = l1GtObjectStringToEnumMap[i].value;
00057         }
00058 
00059     // in case of unrecognized L1GtObject, returns Mu
00060     // and write a warning (to not throw an exception)
00061     if (!found) {
00062         edm::LogInfo("L1GtObject") << "\n  '" << label
00063                 << "' is not a recognized L1GtObject. \n  Return ObjNull.";
00064 
00065         value = ObjNull;
00066     }
00067 
00068     if (value == ObjNull) {
00069         edm::LogInfo("L1GtObject")
00070                 << "\n  ObjNull means no valid L1GtObject defined!";
00071     }
00072 
00073     return value;
00074 }
00075 
00076 std::string l1GtObjectEnumToString(const L1GtObject& gtObject) {
00077 
00078     std::string gtObjectString;
00079 
00080     switch (gtObject) {
00081 
00082         case Mu: {
00083             gtObjectString = "Mu";
00084         }
00085             break;
00086 
00087         case NoIsoEG: {
00088             gtObjectString = "NoIsoEG";
00089         }
00090             break;
00091 
00092         case IsoEG: {
00093             gtObjectString = "IsoEG";
00094         }
00095             break;
00096 
00097         case CenJet: {
00098             gtObjectString = "CenJet";
00099         }
00100             break;
00101 
00102         case ForJet: {
00103             gtObjectString = "ForJet";
00104         }
00105             break;
00106 
00107         case TauJet: {
00108             gtObjectString = "TauJet";
00109         }
00110             break;
00111 
00112         case ETM: {
00113             gtObjectString = "ETM";
00114         }
00115             break;
00116 
00117         case ETT: {
00118             gtObjectString = "ETT";
00119         }
00120             break;
00121 
00122         case HTT: {
00123             gtObjectString = "HTT";
00124         }
00125             break;
00126 
00127         case HTM: {
00128             gtObjectString = "HTM";
00129         }
00130             break;
00131 
00132         case JetCounts: {
00133             gtObjectString = "JetCounts";
00134         }
00135             break;
00136 
00137         case HfBitCounts: {
00138             gtObjectString = "HfBitCounts";
00139         }
00140             break;
00141 
00142         case HfRingEtSums: {
00143             gtObjectString = "HfRingEtSums";
00144         }
00145             break;
00146 
00147         case TechTrig: {
00148             gtObjectString = "TechTrig";
00149         }
00150             break;
00151 
00152         case Castor: {
00153             gtObjectString = "Castor";
00154         }
00155             break;
00156 
00157         case BPTX: {
00158             gtObjectString = "BPTX";
00159         }
00160             break;
00161 
00162         case GtExternal: {
00163             gtObjectString = "GtExternal";
00164         }
00165             break;
00166 
00167         case ObjNull: {
00168             gtObjectString = "ObjNull";
00169             edm::LogInfo("L1GtObject")
00170                     << "\n  ObjNull means no valid L1GtObject defined!";
00171         }
00172             break;
00173 
00174         default: {
00175             edm::LogInfo("L1GtObject") << "\n  '" << gtObject
00176                     << "' is not a recognized L1GtObject. "
00177                     << "\n  Return ObjNull, which means no valid L1GtObject defined!";
00178 
00179             gtObjectString = "ObjNull";
00180 
00181         }
00182             break;
00183     }
00184 
00185     return gtObjectString;
00186 
00187 }
00188