#include <CalibFormats/HcalObjects/interface/HcalText2DetIdConverter.h>
Public Member Functions | |
int | getField (int i) const |
const std::string & | getField1 () const |
const std::string & | getField2 () const |
const std::string & | getField3 () const |
const std::string & | getFlavor () const |
DetId | getId () const |
HcalText2DetIdConverter (DetId fId) | |
HcalText2DetIdConverter (const std::string &fFlavor="NA", const std::string &fField1="0", const std::string &fField2="0", const std::string &fField3="0") | |
bool | isHcalCalibDetId () const |
bool | isHcalDetId () const |
bool | isHcalTrigTowerDetId () const |
bool | isHcalZDCDetId () const |
std::string | toString () const |
Private Member Functions | |
bool | init (DetId fId) |
bool | init (const std::string &fFlavor, const std::string &fField1, const std::string &fField2, const std::string &fField3) |
void | setField (int i, int fValue) |
Private Attributes | |
std::string | field1 |
std::string | field2 |
std::string | field3 |
std::string | flavorName |
DetId | mId |
For Calibration DetIds:
Flavor = "CALIB_[HB|HE|HO|HF]" or "HOX"
fField1 is ieta (-2:2 for CALIB) fField2 is iphi fField3 is ctype (CALIB only)
Definition at line 22 of file HcalText2DetIdConverter.h.
HcalText2DetIdConverter::HcalText2DetIdConverter | ( | const std::string & | fFlavor = "NA" , |
|
const std::string & | fField1 = "0" , |
|||
const std::string & | fField2 = "0" , |
|||
const std::string & | fField3 = "0" | |||
) |
Definition at line 41 of file HcalText2DetIdConverter.cc.
References TestMuL1L2Filter_cff::cerr, lat::endl(), Exception, and init().
00042 { 00043 if (!init (fFlavor, fField1, fField2, fField3)) { 00044 std::cerr << "HcalText2DetIdConverter::HcalText2DetIdConverter-> Can not initiate detId from items: " 00045 << fFlavor << '/' << fField1 << '/' << fField2 << '/' << fField3 << std::endl; 00046 throw cms::Exception("HcalGenDetId initialization error") 00047 << " Can not initiate detId from items: " 00048 << fFlavor << '/' << fField1 << '/' << fField2 << '/' << fField3 << std::endl; 00049 } 00050 }
HcalText2DetIdConverter::HcalText2DetIdConverter | ( | DetId | fId | ) |
Definition at line 52 of file HcalText2DetIdConverter.cc.
References init().
00052 { 00053 init (fId); 00054 }
Definition at line 197 of file HcalText2DetIdConverter.cc.
References calibChannel(), TestMuL1L2Filter_cff::cerr, lat::endl(), field1, field2, field3, isHcalCalibDetId(), and HLT_VtxMuL3::result.
Referenced by dumpChannelId(), init(), and XMLDocument::makeChId().
00197 { 00198 char* endptr; 00199 const char* nptr = i == 1 ? field1.c_str() : 00200 i == 2 ? field2.c_str() : field3.c_str(); 00201 long result = strtol (nptr, &endptr, 0); 00202 if (*nptr != '\0' && *endptr == '\0') { 00203 return result; 00204 } 00205 if (i == 2 && isHcalCalibDetId ()) { 00206 int result = calibChannel (field2); 00207 if (i) return result; 00208 } 00209 if (*nptr != '\0') { 00210 std::cerr << "HcalText2DetIdConverter::getField-> Can not convert string "<< nptr << " to int. Bad symbol: " << *endptr << std::endl; 00211 } 00212 return 0; 00213 }
const std::string& HcalText2DetIdConverter::getField1 | ( | ) | const [inline] |
Definition at line 36 of file HcalText2DetIdConverter.h.
References field1.
Referenced by dumpId().
00036 {return field1;}
const std::string& HcalText2DetIdConverter::getField2 | ( | ) | const [inline] |
Definition at line 37 of file HcalText2DetIdConverter.h.
References field2.
Referenced by dumpId(), and XMLDocument::makeChId().
00037 {return field2;}
const std::string& HcalText2DetIdConverter::getField3 | ( | ) | const [inline] |
Definition at line 38 of file HcalText2DetIdConverter.h.
References field3.
Referenced by dumpId(), and XMLDocument::makeChId().
00038 {return field3;}
const std::string& HcalText2DetIdConverter::getFlavor | ( | ) | const [inline] |
Definition at line 35 of file HcalText2DetIdConverter.h.
References flavorName.
Referenced by HcalDQMDbInterface::createChannel(), dumpChannelId(), dumpId(), and XMLDocument::makeChId().
00035 {return flavorName;}
DetId HcalText2DetIdConverter::getId | ( | ) | const [inline] |
Definition at line 39 of file HcalText2DetIdConverter.h.
References mId.
Referenced by dumpChannelId(), and getId().
00039 {return mId;}
Definition at line 72 of file HcalText2DetIdConverter.cc.
References HcalCalibDetId::calibFlavor(), HcalCalibDetId::CalibrationBox, HcalCalibDetId::cboxChannel(), TestMuL1L2Filter_cff::cerr, HcalZDCDetId::channel(), HcalDetId::depth(), HcalZDCDetId::EM, lat::endl(), flavorName, HcalGenericDetId::genericSubdet(), HcalZDCDetId::HAD, HcalBarrel, HcalEndcap, HcalForward, HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenEndcap, HcalGenericDetId::HcalGenForward, HcalGenericDetId::HcalGenOuter, HcalOuter, HcalCalibDetId::hcalSubdet(), HcalCalibDetId::HOCrosstalk, HcalTrigTowerDetId::ieta(), HcalCalibDetId::ieta(), HcalDetId::ieta(), HcalCalibDetId::iphi(), HcalTrigTowerDetId::iphi(), HcalDetId::iphi(), HcalGenericDetId::isHcalCalibDetId(), HcalGenericDetId::isHcalDetId(), HcalGenericDetId::isHcalTrigTowerDetId(), HcalGenericDetId::isHcalZDCDetId(), HcalZDCDetId::LUM, mId, DetId::rawId(), HLT_VtxMuL3::result, HcalZDCDetId::section(), setField(), HcalDetId::Undefined, HcalTrigTowerDetId::Undefined, and HcalZDCDetId::zside().
00072 { 00073 bool result = true; 00074 flavorName = "UNKNOWN"; 00075 mId = fId; 00076 HcalGenericDetId genId (mId); 00077 if (fId == HcalDetId::Undefined) { 00078 flavorName = "NA"; 00079 } 00080 else if (genId.isHcalDetId ()) { 00081 HcalDetId hcalId (mId); 00082 flavorName = genId.genericSubdet () == HcalGenericDetId::HcalGenBarrel ? "HB" : 00083 genId.genericSubdet () == HcalGenericDetId::HcalGenEndcap ? "HE" : 00084 genId.genericSubdet () == HcalGenericDetId::HcalGenOuter ? "HO" : 00085 genId.genericSubdet () == HcalGenericDetId::HcalGenForward ? "HF" : "H_UNKNOWN"; 00086 setField (1, hcalId.ieta()); 00087 setField (2, hcalId.iphi()); 00088 setField (3, hcalId.depth()); 00089 } 00090 else if (genId.isHcalTrigTowerDetId ()) { 00091 HcalTrigTowerDetId triggerId (mId); 00092 if (triggerId == HcalTrigTowerDetId::Undefined) { 00093 flavorName = "NT"; 00094 } 00095 else { 00096 flavorName = "HT"; 00097 setField (1, triggerId.ieta()); 00098 setField (2, triggerId.iphi()); 00099 setField (3, 1); 00100 } 00101 } 00102 else if (genId.isHcalZDCDetId ()) { 00103 HcalZDCDetId zdcId (mId); 00104 switch (zdcId.section()) { 00105 case HcalZDCDetId::EM: flavorName = "ZDC_EM"; break; 00106 case HcalZDCDetId::HAD: flavorName = "ZDC_HAD"; break; 00107 case HcalZDCDetId::LUM: flavorName = "ZDC_LUM"; break; 00108 default: result = false; 00109 } 00110 setField (1, zdcId.zside()); 00111 setField (2, zdcId.channel()); 00112 setField (3, -99); 00113 } 00114 else if (genId.isHcalCalibDetId ()) { 00115 HcalCalibDetId calibId (mId); 00116 if (calibId.calibFlavor()==HcalCalibDetId::CalibrationBox) { 00117 switch (calibId.hcalSubdet()) { 00118 case HcalBarrel: flavorName = "CALIB_HB"; break; 00119 case HcalEndcap: flavorName = "CALIB_HE"; break; 00120 case HcalOuter: flavorName = "CALIB_HO"; break; 00121 case HcalForward: flavorName = "CALIB_HF"; break; 00122 default: result = false; 00123 } 00124 setField (1, calibId.ieta()); 00125 setField (2, calibId.iphi()); 00126 setField (3, calibId.cboxChannel() ); 00127 } else if (calibId.calibFlavor()==HcalCalibDetId::HOCrosstalk) { 00128 flavorName="HOX"; 00129 setField (1, calibId.ieta()); 00130 setField (2, calibId.iphi()); 00131 setField (3, -999); 00132 } 00133 } 00134 else { 00135 flavorName = "UNKNOWN_FLAVOR"; 00136 std::cerr << "HcalText2DetIdConverter::init-> Unknown detId: " << std::hex << std::showbase << mId.rawId() << std::endl; 00137 result = false; 00138 } 00139 return result; 00140 }
bool HcalText2DetIdConverter::init | ( | const std::string & | fFlavor, | |
const std::string & | fField1, | |||
const std::string & | fField2, | |||
const std::string & | fField3 | |||
) | [private] |
Definition at line 143 of file HcalText2DetIdConverter.cc.
References calibChannel(), TestMuL1L2Filter_cff::cerr, HcalZDCDetId::EM, lat::endl(), field1, field2, field3, flavorName, getField(), HcalZDCDetId::HAD, HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, HcalZDCDetId::LUM, mId, HLT_VtxMuL3::result, strip(), HcalDetId::Undefined, and HcalZDCDetId::Unknown.
Referenced by HcalText2DetIdConverter().
00144 { 00145 bool result = true; 00146 flavorName = strip (fFlavor); 00147 field1 = strip (fField1); 00148 field2 = strip (fField2); 00149 field3 = strip (fField3); 00150 if (flavorName == "HB" || 00151 flavorName == "HE" || 00152 flavorName == "HF" || 00153 flavorName == "HO") { 00154 HcalSubdetector sub = flavorName == "HB" ? HcalBarrel : 00155 flavorName == "HE" ? HcalEndcap : 00156 flavorName == "HO" ? HcalOuter : 00157 HcalForward; 00158 mId = HcalDetId (sub, getField (1), getField (2), getField (3)); 00159 } 00160 else if (flavorName == "HT") { 00161 mId = HcalTrigTowerDetId (getField (1), getField (2)); 00162 } 00163 else if (flavorName.find ("ZDC_") == 0) { 00164 HcalZDCDetId::Section section = flavorName == "ZDC_EM" ? HcalZDCDetId::EM : 00165 flavorName == "ZDC_HAD" ? HcalZDCDetId::HAD : 00166 flavorName == "ZDC_LUM" ? HcalZDCDetId::LUM : HcalZDCDetId::Unknown; 00167 mId = HcalZDCDetId (section, getField (1)>0, getField (2)); 00168 } 00169 else if (flavorName.find ("CALIB_") == 0) { 00170 HcalSubdetector sd = HcalOther; 00171 if (flavorName.find("HB")!=std::string::npos) sd=HcalBarrel; 00172 else if (flavorName.find("HE")!=std::string::npos) sd=HcalEndcap; 00173 else if (flavorName.find("HO")!=std::string::npos) sd=HcalOuter; 00174 else if (flavorName.find("HF")!=std::string::npos) sd=HcalForward; 00175 00176 int ieta=getField(1); 00177 int iphi=getField(2); 00178 int channel = calibChannel (field3); 00179 mId = HcalCalibDetId (sd, ieta,iphi,channel); 00180 } 00181 else if (flavorName=="HOX") { 00182 int ieta=getField(1); 00183 int iphi=getField(2); 00184 mId = HcalCalibDetId (ieta,iphi); 00185 } 00186 else if (flavorName == "NA") { 00187 mId = HcalDetId::Undefined; 00188 } 00189 else { 00190 std::cerr << "HcalText2DetIdConverter::init-> Unknown HcalDetId flavor: " << flavorName << std::endl; 00191 result = false; 00192 } 00193 return result; 00194 }
bool HcalText2DetIdConverter::isHcalCalibDetId | ( | ) | const |
Definition at line 60 of file HcalText2DetIdConverter.cc.
References mId.
Referenced by getField().
00060 { 00061 return HcalGenericDetId (mId).isHcalCalibDetId (); 00062 }
bool HcalText2DetIdConverter::isHcalDetId | ( | ) | const |
Definition at line 56 of file HcalText2DetIdConverter.cc.
References mId.
00056 { 00057 return HcalGenericDetId (mId).isHcalDetId (); 00058 }
bool HcalText2DetIdConverter::isHcalTrigTowerDetId | ( | ) | const |
Definition at line 64 of file HcalText2DetIdConverter.cc.
References mId.
00064 { 00065 return HcalGenericDetId (mId).isHcalTrigTowerDetId (); 00066 }
bool HcalText2DetIdConverter::isHcalZDCDetId | ( | ) | const |
Definition at line 68 of file HcalText2DetIdConverter.cc.
References mId.
00068 { 00069 return HcalGenericDetId (mId).isHcalZDCDetId (); 00070 }
Definition at line 215 of file HcalText2DetIdConverter.cc.
References field1, field2, and field3.
Referenced by init().
00215 { 00216 char buffer [128]; 00217 sprintf (buffer, "%d", fValue); 00218 if (i == 1) field1 = buffer; 00219 else if (i == 2) field2 = buffer; 00220 else field3 = buffer; 00221 }
std::string HcalText2DetIdConverter::toString | ( | ) | const |
Definition at line 223 of file HcalText2DetIdConverter.cc.
References field1, field2, field3, and flavorName.
00223 { 00224 return flavorName + " " + field1 + " " + field2 + " " + field3; 00225 }
std::string HcalText2DetIdConverter::field1 [private] |
Definition at line 49 of file HcalText2DetIdConverter.h.
Referenced by getField(), getField1(), init(), setField(), and toString().
std::string HcalText2DetIdConverter::field2 [private] |
Definition at line 50 of file HcalText2DetIdConverter.h.
Referenced by getField(), getField2(), init(), setField(), and toString().
std::string HcalText2DetIdConverter::field3 [private] |
Definition at line 51 of file HcalText2DetIdConverter.h.
Referenced by getField(), getField3(), init(), setField(), and toString().
std::string HcalText2DetIdConverter::flavorName [private] |
Definition at line 48 of file HcalText2DetIdConverter.h.
Referenced by getFlavor(), init(), and toString().
DetId HcalText2DetIdConverter::mId [private] |
Definition at line 52 of file HcalText2DetIdConverter.h.
Referenced by getId(), init(), isHcalCalibDetId(), isHcalDetId(), isHcalTrigTowerDetId(), and isHcalZDCDetId().