#include <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 (const std::string &fFlavor, const std::string &fField1, const std::string &fField2, const std::string &fField3) |
bool | init (DetId fId) |
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 42 of file HcalText2DetIdConverter.cc.
References dtNoiseDBValidation_cfg::cerr, Exception, and init().
{ if (!init (fFlavor, fField1, fField2, fField3)) { std::cerr << "HcalText2DetIdConverter::HcalText2DetIdConverter-> Can not initiate detId from items: " << fFlavor << '/' << fField1 << '/' << fField2 << '/' << fField3 << std::endl; throw cms::Exception("HcalGenDetId initialization error") << " Can not initiate detId from items: " << fFlavor << '/' << fField1 << '/' << fField2 << '/' << fField3 << std::endl; } }
HcalText2DetIdConverter::HcalText2DetIdConverter | ( | DetId | fId | ) |
int HcalText2DetIdConverter::getField | ( | int | i | ) | const |
Definition at line 198 of file HcalText2DetIdConverter.cc.
References dtNoiseDBValidation_cfg::cerr, field1, field2, field3, isHcalCalibDetId(), and query::result.
Referenced by init(), and XMLDocument::makeChId().
{ char* endptr; const char* nptr = i == 1 ? field1.c_str() : i == 2 ? field2.c_str() : field3.c_str(); long result = strtol (nptr, &endptr, 0); if (*nptr != '\0' && *endptr == '\0') { return result; } if (i == 2 && isHcalCalibDetId ()) { int result = calibChannel (field2); if (i) return result; } if (*nptr != '\0') { std::cerr << "HcalText2DetIdConverter::getField-> Can not convert string "<< nptr << " to int. Bad symbol: " << *endptr << std::endl; } return 0; }
const std::string& HcalText2DetIdConverter::getField1 | ( | ) | const [inline] |
const std::string& HcalText2DetIdConverter::getField2 | ( | ) | const [inline] |
Definition at line 37 of file HcalText2DetIdConverter.h.
References field2.
Referenced by XMLDocument::makeChId().
{return field2;}
const std::string& HcalText2DetIdConverter::getField3 | ( | ) | const [inline] |
Definition at line 38 of file HcalText2DetIdConverter.h.
References field3.
Referenced by XMLDocument::makeChId().
{return field3;}
const std::string& HcalText2DetIdConverter::getFlavor | ( | ) | const [inline] |
Definition at line 35 of file HcalText2DetIdConverter.h.
References flavorName.
Referenced by HcalDQMDbInterface::createChannel(), and XMLDocument::makeChId().
{return flavorName;}
DetId HcalText2DetIdConverter::getId | ( | ) | const [inline] |
bool HcalText2DetIdConverter::init | ( | const std::string & | fFlavor, |
const std::string & | fField1, | ||
const std::string & | fField2, | ||
const std::string & | fField3 | ||
) | [private] |
Definition at line 144 of file HcalText2DetIdConverter.cc.
References dtNoiseDBValidation_cfg::cerr, HcalZDCDetId::EM, field1, field2, field3, flavorName, getField(), HcalZDCDetId::HAD, HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, HcalZDCDetId::LUM, mId, query::result, sd, strip(), HcalDetId::Undefined, and Unknown.
Referenced by HcalText2DetIdConverter().
{ bool result = true; flavorName = strip (fFlavor); field1 = strip (fField1); field2 = strip (fField2); field3 = strip (fField3); if (flavorName == "HB" || flavorName == "HE" || flavorName == "HF" || flavorName == "HO") { HcalSubdetector sub = flavorName == "HB" ? HcalBarrel : flavorName == "HE" ? HcalEndcap : flavorName == "HO" ? HcalOuter : HcalForward; mId = HcalDetId (sub, getField (1), getField (2), getField (3)); } else if (flavorName == "HT") { mId = HcalTrigTowerDetId (getField (1), getField (2)); } else if (flavorName.find ("ZDC_") == 0) { HcalZDCDetId::Section section = flavorName == "ZDC_EM" ? HcalZDCDetId::EM : flavorName == "ZDC_HAD" ? HcalZDCDetId::HAD : flavorName == "ZDC_LUM" ? HcalZDCDetId::LUM : HcalZDCDetId::Unknown; mId = HcalZDCDetId (section, getField (1)>0, getField (2)); } else if (flavorName.find ("CALIB_") == 0) { HcalSubdetector sd = HcalOther; if (flavorName.find("HB")!=std::string::npos) sd=HcalBarrel; else if (flavorName.find("HE")!=std::string::npos) sd=HcalEndcap; else if (flavorName.find("HO")!=std::string::npos) sd=HcalOuter; else if (flavorName.find("HF")!=std::string::npos) sd=HcalForward; int ieta=getField(1); int iphi=getField(2); int channel = calibChannel (field3); mId = HcalCalibDetId (sd, ieta,iphi,channel); } else if (flavorName=="HOX") { int ieta=getField(1); int iphi=getField(2); mId = HcalCalibDetId (ieta,iphi); } else if (flavorName == "NA") { mId = HcalDetId::Undefined; } else { std::cerr << "HcalText2DetIdConverter::init-> Unknown HcalDetId flavor: " << flavorName << std::endl; result = false; } return result; }
bool HcalText2DetIdConverter::init | ( | DetId | fId | ) | [private] |
Definition at line 73 of file HcalText2DetIdConverter.cc.
References HcalCalibDetId::calibFlavor(), HcalCalibDetId::CalibrationBox, HcalCalibDetId::cboxChannel(), dtNoiseDBValidation_cfg::cerr, HcalZDCDetId::channel(), HcalDetId::depth(), HcalZDCDetId::EM, 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(), query::result, HcalZDCDetId::section(), setField(), HcalDetId::Undefined, HcalTrigTowerDetId::Undefined, and HcalZDCDetId::zside().
{ bool result = true; flavorName = "UNKNOWN"; mId = fId; HcalGenericDetId genId (mId); if (fId == HcalDetId::Undefined) { flavorName = "NA"; } else if (genId.isHcalDetId ()) { HcalDetId hcalId (mId); flavorName = genId.genericSubdet () == HcalGenericDetId::HcalGenBarrel ? "HB" : genId.genericSubdet () == HcalGenericDetId::HcalGenEndcap ? "HE" : genId.genericSubdet () == HcalGenericDetId::HcalGenOuter ? "HO" : genId.genericSubdet () == HcalGenericDetId::HcalGenForward ? "HF" : "H_UNKNOWN"; setField (1, hcalId.ieta()); setField (2, hcalId.iphi()); setField (3, hcalId.depth()); } else if (genId.isHcalTrigTowerDetId ()) { HcalTrigTowerDetId triggerId (mId); if (triggerId == HcalTrigTowerDetId::Undefined) { flavorName = "NT"; } else { flavorName = "HT"; setField (1, triggerId.ieta()); setField (2, triggerId.iphi()); setField (3, 1); } } else if (genId.isHcalZDCDetId ()) { HcalZDCDetId zdcId (mId); switch (zdcId.section()) { case HcalZDCDetId::EM: flavorName = "ZDC_EM"; break; case HcalZDCDetId::HAD: flavorName = "ZDC_HAD"; break; case HcalZDCDetId::LUM: flavorName = "ZDC_LUM"; break; default: result = false; } setField (1, zdcId.zside()); setField (2, zdcId.channel()); setField (3, -99); } else if (genId.isHcalCalibDetId ()) { HcalCalibDetId calibId (mId); if (calibId.calibFlavor()==HcalCalibDetId::CalibrationBox) { switch (calibId.hcalSubdet()) { case HcalBarrel: flavorName = "CALIB_HB"; break; case HcalEndcap: flavorName = "CALIB_HE"; break; case HcalOuter: flavorName = "CALIB_HO"; break; case HcalForward: flavorName = "CALIB_HF"; break; default: result = false; } setField (1, calibId.ieta()); setField (2, calibId.iphi()); setField (3, calibId.cboxChannel() ); } else if (calibId.calibFlavor()==HcalCalibDetId::HOCrosstalk) { flavorName="HOX"; setField (1, calibId.ieta()); setField (2, calibId.iphi()); setField (3, -999); } } else { flavorName = "UNKNOWN_FLAVOR"; std::cerr << "HcalText2DetIdConverter::init-> Unknown detId: " << std::hex << std::showbase << mId.rawId() << std::endl; result = false; } return result; }
bool HcalText2DetIdConverter::isHcalCalibDetId | ( | ) | const |
Definition at line 61 of file HcalText2DetIdConverter.cc.
References HcalGenericDetId::isHcalCalibDetId(), and mId.
Referenced by getField().
{ return HcalGenericDetId (mId).isHcalCalibDetId (); }
bool HcalText2DetIdConverter::isHcalDetId | ( | ) | const |
Definition at line 57 of file HcalText2DetIdConverter.cc.
References HcalGenericDetId::isHcalDetId(), and mId.
{ return HcalGenericDetId (mId).isHcalDetId (); }
bool HcalText2DetIdConverter::isHcalTrigTowerDetId | ( | ) | const |
Definition at line 65 of file HcalText2DetIdConverter.cc.
References HcalGenericDetId::isHcalTrigTowerDetId(), and mId.
{ return HcalGenericDetId (mId).isHcalTrigTowerDetId (); }
bool HcalText2DetIdConverter::isHcalZDCDetId | ( | ) | const |
Definition at line 69 of file HcalText2DetIdConverter.cc.
References HcalGenericDetId::isHcalZDCDetId(), and mId.
{ return HcalGenericDetId (mId).isHcalZDCDetId (); }
void HcalText2DetIdConverter::setField | ( | int | i, |
int | fValue | ||
) | [private] |
std::string HcalText2DetIdConverter::toString | ( | ) | const |
Definition at line 224 of file HcalText2DetIdConverter.cc.
References field1, field2, field3, and flavorName.
Referenced by HcalDbXml::dumpObject().
{ return flavorName + " " + field1 + " " + field2 + " " + field3; }
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().