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() [1/2]

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.

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 }

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

◆ HcalText2DetIdConverter() [2/2]

HcalText2DetIdConverter::HcalText2DetIdConverter ( DetId  fId)

Definition at line 57 of file HcalText2DetIdConverter.cc.

57 { init(fId); }

References init().

Member Function Documentation

◆ getField()

int HcalText2DetIdConverter::getField ( int  i) const

Definition at line 282 of file HcalText2DetIdConverter.cc.

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 }

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

Referenced by init().

◆ getField1()

const std::string& HcalText2DetIdConverter::getField1 ( ) const
inline

Definition at line 36 of file HcalText2DetIdConverter.h.

36 { return field1; }

References field1.

◆ getField2()

const std::string& HcalText2DetIdConverter::getField2 ( ) const
inline

Definition at line 37 of file HcalText2DetIdConverter.h.

37 { return field2; }

References field2.

◆ getField3()

const std::string& HcalText2DetIdConverter::getField3 ( ) const
inline

Definition at line 38 of file HcalText2DetIdConverter.h.

38 { return field3; }

References field3.

◆ getFlavor()

const std::string& HcalText2DetIdConverter::getFlavor ( ) const
inline

Definition at line 35 of file HcalText2DetIdConverter.h.

35 { return flavorName; }

References flavorName.

◆ getId()

DetId HcalText2DetIdConverter::getId ( ) const
inline

Definition at line 39 of file HcalText2DetIdConverter.h.

39 { return mId; }

References mId.

◆ init() [1/2]

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.

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")
232  else if (flavorName == "ZDC_HAD")
234  else if (flavorName == "ZDC_LUM")
236  else if (flavorName == "ZDC_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);
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);
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 }

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 HcalText2DetIdConverter().

◆ init() [2/2]

bool HcalText2DetIdConverter::init ( DetId  fId)
private

Definition at line 67 of file HcalText2DetIdConverter.cc.

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 }

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().

◆ isHcalCalibDetId()

bool HcalText2DetIdConverter::isHcalCalibDetId ( ) const

Definition at line 61 of file HcalText2DetIdConverter.cc.

References HcalGenericDetId::isHcalCalibDetId(), and mId.

Referenced by getField().

◆ isHcalDetId()

bool HcalText2DetIdConverter::isHcalDetId ( ) const

Definition at line 59 of file HcalText2DetIdConverter.cc.

59 { return HcalGenericDetId(mId).isHcalDetId(); }

References HcalGenericDetId::isHcalDetId(), and mId.

◆ isHcalTrigTowerDetId()

bool HcalText2DetIdConverter::isHcalTrigTowerDetId ( ) const

◆ isHcalZDCDetId()

bool HcalText2DetIdConverter::isHcalZDCDetId ( ) const

Definition at line 65 of file HcalText2DetIdConverter.cc.

65 { return HcalGenericDetId(mId).isHcalZDCDetId(); }

References HcalGenericDetId::isHcalZDCDetId(), and mId.

◆ setField()

void HcalText2DetIdConverter::setField ( int  i,
int  fValue 
)
private

Definition at line 301 of file HcalText2DetIdConverter.cc.

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 }

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

Referenced by init().

◆ toString()

std::string HcalText2DetIdConverter::toString ( ) const

Definition at line 312 of file HcalText2DetIdConverter.cc.

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

References field1, field2, field3, and flavorName.

Referenced by HcalDbXml::dumpObject().

Member Data Documentation

◆ field1

std::string HcalText2DetIdConverter::field1
private

Definition at line 51 of file HcalText2DetIdConverter.h.

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

◆ field2

std::string HcalText2DetIdConverter::field2
private

Definition at line 52 of file HcalText2DetIdConverter.h.

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

◆ field3

std::string HcalText2DetIdConverter::field3
private

Definition at line 53 of file HcalText2DetIdConverter.h.

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

◆ flavorName

std::string HcalText2DetIdConverter::flavorName
private

Definition at line 50 of file HcalText2DetIdConverter.h.

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

◆ mId

DetId HcalText2DetIdConverter::mId
private
HcalOther
Definition: HcalAssistant.h:38
HcalDetId::Undefined
static const HcalDetId Undefined
Definition: HcalDetId.h:273
mps_fire.i
i
Definition: mps_fire.py:355
HcalZDCDetId::HAD
Definition: HcalZDCDetId.h:23
HcalGenericDetId
Definition: HcalGenericDetId.h:15
HcalZDCDetId::Section
Section
Definition: HcalZDCDetId.h:23
HcalCalibDetId
Definition: HcalCalibDetId.h:45
HcalText2DetIdConverter::field3
std::string field3
Definition: HcalText2DetIdConverter.h:53
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
HcalText2DetIdConverter::isHcalCalibDetId
bool isHcalCalibDetId() const
Definition: HcalText2DetIdConverter.cc:61
HcalGenericDetId::HcalGenEndcap
Definition: HcalGenericDetId.h:20
HcalCalibDetId::uMNqie
Definition: HcalCalibDetId.h:51
HcalBarrel
Definition: HcalAssistant.h:33
HcalText2DetIdConverter::mId
DetId mId
Definition: HcalText2DetIdConverter.h:54
HcalText2DetIdConverter::field1
std::string field1
Definition: HcalText2DetIdConverter.h:51
HcalText2DetIdConverter::field2
std::string field2
Definition: HcalText2DetIdConverter.h:52
HcalCalibDetId::HEX
Definition: HcalCalibDetId.h:55
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
HcalGenericDetId::isHcalZDCDetId
bool isHcalZDCDetId() const
Definition: HcalGenericDetId.cc:79
HcalZDCDetId
Definition: HcalZDCDetId.h:16
HcalCalibDetId::HBX
Definition: HcalCalibDetId.h:54
HcalGenericDetId::isHcalCalibDetId
bool isHcalCalibDetId() const
Definition: HcalGenericDetId.cc:69
HcalOuter
Definition: HcalAssistant.h:35
submit.rm
rm
Definition: submit.py:77
HcalGenericDetId::isHcalTrigTowerDetId
bool isHcalTrigTowerDetId() const
Definition: HcalGenericDetId.cc:74
HcalText2DetIdConverter::setField
void setField(int i, int fValue)
Definition: HcalText2DetIdConverter.cc:301
HcalCalibDetId::CastorRadFacility
Definition: HcalCalibDetId.h:52
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalZDCDetId::RPD
Definition: HcalZDCDetId.h:23
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
HcalZDCDetId::Unknown
Definition: HcalZDCDetId.h:23
HcalText2DetIdConverter::flavorName
std::string flavorName
Definition: HcalText2DetIdConverter.h:50
HcalTrigTowerDetId::Undefined
static const HcalTrigTowerDetId Undefined
Definition: HcalTrigTowerDetId.h:62
HcalDetId
Definition: HcalDetId.h:12
HcalGenericDetId::HcalGenBarrel
Definition: HcalGenericDetId.h:19
HcalCalibDetId::LASERMON
Definition: HcalCalibDetId.h:53
HcalText2DetIdConverter::init
bool init(const std::string &fFlavor, const std::string &fField1, const std::string &fField2, const std::string &fField3)
Definition: HcalText2DetIdConverter.cc:192
trackingPlots.section
section
Definition: trackingPlots.py:1380
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
HcalForward
Definition: HcalAssistant.h:36
HcalText2DetIdConverter::getField
int getField(int i) const
Definition: HcalText2DetIdConverter.cc:282
HcalCalibDetId::HOCrosstalk
Definition: HcalCalibDetId.h:50
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HcalGenericDetId::isHcalDetId
bool isHcalDetId() const
Definition: HcalGenericDetId.cc:64
HcalEndcap
Definition: HcalAssistant.h:34
Exception
Definition: hltDiff.cc:246
HcalZDCDetId::LUM
Definition: HcalZDCDetId.h:23
sd
double sd
Definition: CascadeWrapper.h:113
HcalGenericDetId::HcalGenOuter
Definition: HcalGenericDetId.h:21
mps_fire.result
result
Definition: mps_fire.py:303
HcalCalibDetId::CalibrationBox
Definition: HcalCalibDetId.h:49
HcalGenericDetId::HcalGenForward
Definition: HcalGenericDetId.h:22
HcalZDCDetId::EM
Definition: HcalZDCDetId.h:23
HcalTrigTowerDetId
Definition: HcalTrigTowerDetId.h:14