CMS 3D CMS Logo

Functions
parseHcalDetId.h File Reference
#include <string>
#include "DataFormats/HcalDetId/interface/HcalDetId.h"

Go to the source code of this file.

Functions

const char * hcalSubdetectorName (HcalSubdetector subdet)
 
HcalDetId parseHcalDetId (const std::string &s)
 

Function Documentation

◆ hcalSubdetectorName()

const char* hcalSubdetectorName ( HcalSubdetector  subdet)

Definition at line 40 of file parseHcalDetId.cc.

References cms::cuda::assert(), nSsubdetNames, and subdetNames.

40  {
41  const unsigned ind = static_cast<unsigned>(subdet);
42  assert(ind < nSsubdetNames);
43  return subdetNames[ind];
44 }
assert(be >=bs)
static const unsigned nSsubdetNames
static const char * subdetNames[]

◆ parseHcalDetId()

HcalDetId parseHcalDetId ( const std::string &  s)

Definition at line 46 of file parseHcalDetId.cc.

References LEDCalibrationChannels::depth, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, parse_int(), parseSubdetector(), mps_fire::result, and alignCSCRings::s.

46  {
47  using namespace std;
48 
49  // Expected string contents:
50  //
51  // ieta iphi depth subdetector
52  //
53  // subdetector is one of "HB", "HE", "HF", or "HO"
54  //
56  istringstream iss(s);
57  vector<string> tokens(istream_iterator<string>{iss}, istream_iterator<string>{});
58  if (tokens.size() == 4) {
59  HcalSubdetector subdet;
60  int ieta, iphi, depth;
61  if (parse_int(tokens[0].c_str(), &ieta) && parse_int(tokens[1].c_str(), &iphi) &&
62  parse_int(tokens[2].c_str(), &depth) && parseSubdetector(tokens[3].c_str(), &subdet))
63  result = HcalDetId(subdet, ieta, iphi, depth);
64  }
65  return result;
66 }
static bool parseSubdetector(const char *c, HcalSubdetector *result)
HcalSubdetector
Definition: HcalAssistant.h:31
static bool parse_int(const char *c, int *result)