CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalText2DetIdConverter Class Reference

#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 (const std::string &fFlavor="NA", const std::string &fField1="0", const std::string &fField2="0", const std::string &fField3="0")
 
 HcalText2DetIdConverter (DetId fId)
 
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
 

Detailed Description

Author
F.Ratnikov, UMd Converts any flavour of HcalDetId to/from ascii strings

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)

Author
F.Ratnikov, UMd

Definition at line 21 of file HcalText2DetIdConverter.h.

Constructor & Destructor Documentation

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 44 of file HcalText2DetIdConverter.cc.

References beam_dqm_sourceclient-live_cfg::cerr, Exception, and init().

47  {
48  if (!init(fFlavor, fField1, fField2, fField3)) {
49  std::cerr << "HcalText2DetIdConverter::HcalText2DetIdConverter-> Can not initiate detId from items: " << fFlavor
50  << '/' << fField1 << '/' << fField2 << '/' << fField3 << std::endl;
51  throw cms::Exception("HcalGenDetId initialization error")
52  << " Can not initiate detId from items: " << fFlavor << '/' << fField1 << '/' << fField2 << '/' << fField3
53  << std::endl;
54  }
55 }
bool init(const std::string &fFlavor, const std::string &fField1, const std::string &fField2, const std::string &fField3)
HcalText2DetIdConverter::HcalText2DetIdConverter ( DetId  fId)

Definition at line 57 of file HcalText2DetIdConverter.cc.

References init().

57 { init(fId); }
bool init(const std::string &fFlavor, const std::string &fField1, const std::string &fField2, const std::string &fField3)

Member Function Documentation

int HcalText2DetIdConverter::getField ( int  i) const

Definition at line 282 of file HcalText2DetIdConverter.cc.

References beam_dqm_sourceclient-live_cfg::cerr, field1, field2, field3, isHcalCalibDetId(), and mps_fire::result.

Referenced by getId(), init(), and XMLDocument::makeChId().

282  {
283  char* endptr;
284  const char* nptr = i == 1 ? field1.c_str() : i == 2 ? field2.c_str() : field3.c_str();
285  long result = strtol(nptr, &endptr, 0);
286  if (*nptr != '\0' && *endptr == '\0') {
287  return result;
288  }
289  if (i == 2 && isHcalCalibDetId()) {
290  int result = calibChannel(field2);
291  if (i)
292  return result;
293  }
294  if (*nptr != '\0') {
295  std::cerr << "HcalText2DetIdConverter::getField-> Can not convert string " << nptr
296  << " to int. Bad symbol: " << *endptr << std::endl;
297  }
298  return 0;
299 }
const std::string& HcalText2DetIdConverter::getField1 ( ) const
inline
const std::string& HcalText2DetIdConverter::getField2 ( ) const
inline
const std::string& HcalText2DetIdConverter::getField3 ( ) const
inline
const std::string& HcalText2DetIdConverter::getFlavor ( ) const
inline
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 192 of file HcalText2DetIdConverter.cc.

References HcalCalibDetId::CastorRadFacility, beam_dqm_sourceclient-live_cfg::cerr, HcalZDCDetId::EM, field1, field2, field3, flavorName, getField(), HcalZDCDetId::HAD, HcalCalibDetId::HBX, HcalBarrel, HcalEndcap, HcalForward, HcalOther, HcalOuter, HcalCalibDetId::HEX, HcalCalibDetId::HOCrosstalk, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, HcalCalibDetId::LASERMON, HcalZDCDetId::LUM, mId, mps_fire::result, submit::rm, HcalZDCDetId::RPD, sd, trackingPlots::section, digitizers_cfi::strip, HcalCalibDetId::uMNqie, HcalDetId::Undefined, and HcalZDCDetId::Unknown.

Referenced by getId(), and HcalText2DetIdConverter().

195  {
196  bool result = true;
197  flavorName = strip(fFlavor);
198  field1 = strip(fField1);
199  field2 = strip(fField2);
200  field3 = strip(fField3);
201  if (flavorName == "HB" || flavorName == "HE" || flavorName == "HF" || flavorName == "HO") {
202  HcalSubdetector sub = flavorName == "HB"
203  ? HcalBarrel
204  : flavorName == "HE" ? HcalEndcap : flavorName == "HO" ? HcalOuter : HcalForward;
205  mId = HcalDetId(sub, getField(1), getField(2), getField(3));
206  } else if (flavorName == "HT") {
207  // We use the depth to signal the "version" being used (RCT or 1x1 HF). RCT
208  // has a 0 in the 10s digit, whereas 1x1 has a 1. The ones digit is still
209  // used to indicate depth, although in the 1x1 case this must be 0, so we
210  // set it as such.
212  /*
213  const int depth_field = getField(3);
214  const int ones = depth_field % 10;
215  const int tens = (depth_field - ones) / 10;
216  if (tens == 0) {
217  const int depth = ones;
218  const int version = 0;
219  mId = HcalTrigTowerDetId (getField (1), getField (2), depth, version);
220  } else if (tens == 1) {
221  const int depth = 0;
222  const int version = 1;
223  mId = HcalTrigTowerDetId(getField(1), getField(2), depth, version);
224  } else {
225  // Undefined version!
226  }
227 */
228  } else if (flavorName.find("ZDC_") == 0) {
230  if (flavorName == "ZDC_EM")
231  section = HcalZDCDetId::EM;
232  else if (flavorName == "ZDC_HAD")
233  section = HcalZDCDetId::HAD;
234  else if (flavorName == "ZDC_LUM")
235  section = HcalZDCDetId::LUM;
236  else if (flavorName == "ZDC_RPD")
237  section = HcalZDCDetId::RPD;
238  mId = HcalZDCDetId(section, getField(1) > 0, getField(2));
239  } else if (flavorName.find("CALIB_") == 0) {
241  if (flavorName.find("HB") != std::string::npos)
242  sd = HcalBarrel;
243  else if (flavorName.find("HE") != std::string::npos)
244  sd = HcalEndcap;
245  else if (flavorName.find("HO") != std::string::npos)
246  sd = HcalOuter;
247  else if (flavorName.find("HF") != std::string::npos)
248  sd = HcalForward;
249 
250  int ieta = getField(1);
251  int iphi = getField(2);
252  int channel = calibChannel(field3);
253  mId = HcalCalibDetId(sd, ieta, iphi, channel);
254  } else if (flavorName == "HOX" || flavorName == "HBX" || flavorName == "HEX") {
255  int ieta = getField(1);
256  int iphi = getField(2);
257  mId = (flavorName == "HOX") ? (HcalCalibDetId(HcalCalibDetId::HOCrosstalk, ieta, iphi))
258  : ((flavorName == "HBX") ? (HcalCalibDetId(HcalCalibDetId::HBX, ieta, iphi))
259  : (HcalCalibDetId(HcalCalibDetId::HEX, ieta, iphi)));
260  } else if (flavorName == "UMNQIE") {
261  int channel = getField(1);
263  } else if (flavorName == "LASMON") {
264  int ieta = getField(1);
265  int iphi = getField(2);
266  int channel = getField(3);
267  mId = HcalCalibDetId(HcalCalibDetId::LASERMON, ieta, iphi, channel);
268  } else if (flavorName == "CRF") {
269  int rm = getField(1);
270  int fiber = getField(2);
271  int channel = getField(3);
273  } else if (flavorName == "NA") {
275  } else {
276  std::cerr << "HcalText2DetIdConverter::init-> Unknown HcalDetId flavor: " << flavorName << std::endl;
277  result = false;
278  }
279  return result;
280 }
static const HcalDetId Undefined
Definition: HcalDetId.h:273
HcalSubdetector
Definition: HcalAssistant.h:31
double sd
rm
Definition: submit.py:77
bool HcalText2DetIdConverter::init ( DetId  fId)
private

Definition at line 67 of file HcalText2DetIdConverter.cc.

References HcalCalibDetId::calibFlavor(), HcalCalibDetId::CalibrationBox, HcalCalibDetId::CastorRadFacility, HcalCalibDetId::cboxChannel(), beam_dqm_sourceclient-live_cfg::cerr, HcalZDCDetId::channel(), HcalCalibDetId::channel(), HcalTrigTowerDetId::depth(), HcalDetId::depth(), HcalZDCDetId::EM, HcalCalibDetId::fiber(), flavorName, HcalGenericDetId::genericSubdet(), HcalZDCDetId::HAD, HcalCalibDetId::HBX, HcalBarrel, HcalEndcap, HcalForward, HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenEndcap, HcalGenericDetId::HcalGenForward, HcalGenericDetId::HcalGenOuter, HcalOuter, HcalCalibDetId::hcalSubdet(), HcalCalibDetId::HEX, HcalCalibDetId::HOCrosstalk, HcalTrigTowerDetId::ieta(), HcalCalibDetId::ieta(), HcalDetId::ieta(), HcalTrigTowerDetId::iphi(), HcalCalibDetId::iphi(), HcalDetId::iphi(), HcalGenericDetId::isHcalCalibDetId(), HcalGenericDetId::isHcalDetId(), HcalGenericDetId::isHcalTrigTowerDetId(), HcalGenericDetId::isHcalZDCDetId(), HcalCalibDetId::LASERMON, HcalZDCDetId::LUM, mId, DetId::rawId(), mps_fire::result, HcalCalibDetId::rm(), HcalZDCDetId::RPD, HcalZDCDetId::section(), setField(), HcalCalibDetId::uMNqie, HcalTrigTowerDetId::Undefined, HcalDetId::Undefined, HcalTrigTowerDetId::version(), and HcalZDCDetId::zside().

67  {
68  bool result = true;
69  flavorName = "UNKNOWN";
70  mId = fId;
71  HcalGenericDetId genId(mId);
72  if (fId == HcalDetId::Undefined) {
73  flavorName = "NA";
74  } else if (genId.isHcalDetId()) {
75  HcalDetId hcalId(mId);
76  flavorName = genId.genericSubdet() == HcalGenericDetId::HcalGenBarrel
77  ? "HB"
78  : genId.genericSubdet() == HcalGenericDetId::HcalGenEndcap
79  ? "HE"
80  : genId.genericSubdet() == HcalGenericDetId::HcalGenOuter
81  ? "HO"
82  : genId.genericSubdet() == HcalGenericDetId::HcalGenForward ? "HF" : "H_UNKNOWN";
83  setField(1, hcalId.ieta());
84  setField(2, hcalId.iphi());
85  setField(3, hcalId.depth());
86  } else if (genId.isHcalTrigTowerDetId()) {
87  HcalTrigTowerDetId triggerId(mId);
88  if (triggerId == HcalTrigTowerDetId::Undefined) {
89  flavorName = "NT";
90  } else {
91  flavorName = "HT";
92  setField(1, triggerId.ieta());
93  setField(2, triggerId.iphi());
94  setField(3, triggerId.version() * 10 + triggerId.depth());
95  /*
96  if (triggerId.version() == 0) {
97  setField (1, triggerId.ieta());
98  setField (2, triggerId.iphi());
99  setField (3, 1);
100  } else if (triggerId.version() == 1) {
101  setField (1, triggerId.ieta());
102  setField (2, triggerId.iphi());
103  setField (3, 10); // We use the tens digit to indicate version
104  } else {
105  // Unknown version
106  }
107 */
108  }
109  } else if (genId.isHcalZDCDetId()) {
110  HcalZDCDetId zdcId(mId);
111  switch (zdcId.section()) {
112  case HcalZDCDetId::EM:
113  flavorName = "ZDC_EM";
114  break;
115  case HcalZDCDetId::HAD:
116  flavorName = "ZDC_HAD";
117  break;
118  case HcalZDCDetId::LUM:
119  flavorName = "ZDC_LUM";
120  break;
121  case HcalZDCDetId::RPD:
122  flavorName = "ZDC_RPD";
123  break;
124  default:
125  result = false;
126  }
127  setField(1, zdcId.zside());
128  setField(2, zdcId.channel());
129  setField(3, -99);
130  } else if (genId.isHcalCalibDetId()) {
131  HcalCalibDetId calibId(mId);
132  if (calibId.calibFlavor() == HcalCalibDetId::CalibrationBox) {
133  switch (calibId.hcalSubdet()) {
134  case HcalBarrel:
135  flavorName = "CALIB_HB";
136  break;
137  case HcalEndcap:
138  flavorName = "CALIB_HE";
139  break;
140  case HcalOuter:
141  flavorName = "CALIB_HO";
142  break;
143  case HcalForward:
144  flavorName = "CALIB_HF";
145  break;
146  default:
147  result = false;
148  }
149  setField(1, calibId.ieta());
150  setField(2, calibId.iphi());
151  setField(3, calibId.cboxChannel());
152  } else if (calibId.calibFlavor() == HcalCalibDetId::HOCrosstalk) {
153  flavorName = "HOX";
154  setField(1, calibId.ieta());
155  setField(2, calibId.iphi());
156  setField(3, -999);
157  } else if (calibId.calibFlavor() == HcalCalibDetId::uMNqie) {
158  flavorName = "UMNQIE";
159  setField(1, calibId.channel());
160  setField(2, -999);
161  setField(3, -999);
162  } else if (calibId.calibFlavor() == HcalCalibDetId::LASERMON) {
163  flavorName = "LASMON";
164  setField(1, calibId.ieta());
165  setField(2, calibId.iphi());
166  setField(3, calibId.cboxChannel());
167  } else if (calibId.calibFlavor() == HcalCalibDetId::CastorRadFacility) {
168  flavorName = "CRF";
169  setField(1, calibId.rm());
170  setField(2, calibId.fiber());
171  setField(3, calibId.channel());
172  } else if (calibId.calibFlavor() == HcalCalibDetId::HBX) {
173  flavorName = "HBX";
174  setField(1, calibId.ieta());
175  setField(2, calibId.iphi());
176  setField(3, -999);
177  } else if (calibId.calibFlavor() == HcalCalibDetId::HEX) {
178  flavorName = "HEX";
179  setField(1, calibId.ieta());
180  setField(2, calibId.iphi());
181  setField(3, -999);
182  }
183  } else {
184  flavorName = "UNKNOWN_FLAVOR";
185  std::cerr << "HcalText2DetIdConverter::init-> Unknown detId: " << std::hex << std::showbase << mId.rawId()
186  << std::endl;
187  result = false;
188  }
189  return result;
190 }
static const HcalDetId Undefined
Definition: HcalDetId.h:273
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void setField(int i, int fValue)
static const HcalTrigTowerDetId Undefined
bool HcalText2DetIdConverter::isHcalCalibDetId ( ) const
bool HcalText2DetIdConverter::isHcalDetId ( ) const
bool HcalText2DetIdConverter::isHcalTrigTowerDetId ( ) const
bool HcalText2DetIdConverter::isHcalZDCDetId ( ) const
void HcalText2DetIdConverter::setField ( int  i,
int  fValue 
)
private

Definition at line 301 of file HcalText2DetIdConverter.cc.

References edmScanValgrind::buffer, field1, field2, and field3.

Referenced by getId(), and init().

301  {
302  char buffer[128];
303  sprintf(buffer, "%d", fValue);
304  if (i == 1)
305  field1 = buffer;
306  else if (i == 2)
307  field2 = buffer;
308  else
309  field3 = buffer;
310 }
std::string HcalText2DetIdConverter::toString ( ) const

Definition at line 312 of file HcalText2DetIdConverter.cc.

References field1, field2, field3, and flavorName.

Referenced by HcalDbXml::dumpObject(), and getId().

312  {
313  return flavorName + " " + field1 + " " + field2 + " " + field3;
314 }

Member Data Documentation

std::string HcalText2DetIdConverter::field1
private

Definition at line 51 of file HcalText2DetIdConverter.h.

Referenced by getField(), getField1(), init(), setField(), and toString().

std::string HcalText2DetIdConverter::field2
private

Definition at line 52 of file HcalText2DetIdConverter.h.

Referenced by getField(), getField2(), init(), setField(), and toString().

std::string HcalText2DetIdConverter::field3
private

Definition at line 53 of file HcalText2DetIdConverter.h.

Referenced by getField(), getField3(), init(), setField(), and toString().

std::string HcalText2DetIdConverter::flavorName
private

Definition at line 50 of file HcalText2DetIdConverter.h.

Referenced by getFlavor(), init(), and toString().

DetId HcalText2DetIdConverter::mId
private