CMS 3D CMS Logo

Functions | Variables
parseHcalDetId.cc File Reference
#include <cstdlib>
#include <cerrno>
#include <cassert>
#include <vector>
#include <sstream>
#include <cstring>
#include <iterator>
#include "CondTools/Hcal/interface/parseHcalDetId.h"

Go to the source code of this file.

Functions

const char * hcalSubdetectorName (HcalSubdetector subdet)
 
static bool parse_int (const char *c, int *result)
 
HcalDetId parseHcalDetId (const std::string &s)
 
static bool parseSubdetector (const char *c, HcalSubdetector *result)
 

Variables

static const unsigned nSsubdetNames = sizeof(subdetNames) / sizeof(subdetNames[0])
 
static const char * subdetNames []
 

Function Documentation

◆ hcalSubdetectorName()

const char* hcalSubdetectorName ( HcalSubdetector  subdet)

Definition at line 40 of file parseHcalDetId.cc.

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

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

◆ parse_int()

static bool parse_int ( const char *  c,
int *  result 
)
static

Definition at line 31 of file parseHcalDetId.cc.

31  {
32  assert(c);
33  assert(result);
34  char* endptr;
35  errno = 0;
36  *result = strtol(c, &endptr, 0);
37  return !errno && *endptr == '\0';
38 }

References cms::cuda::assert(), c, and mps_fire::result.

Referenced by parseHcalDetId().

◆ parseHcalDetId()

HcalDetId parseHcalDetId ( const std::string &  s)

Definition at line 46 of file parseHcalDetId.cc.

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 }

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

◆ parseSubdetector()

static bool parseSubdetector ( const char *  c,
HcalSubdetector result 
)
static

Definition at line 20 of file parseHcalDetId.cc.

20  {
21  assert(c);
22  assert(result);
23  for (unsigned i = 1; i < nSsubdetNames; ++i)
24  if (strcmp(c, subdetNames[i]) == 0) {
25  *result = static_cast<HcalSubdetector>(i);
26  return true;
27  }
28  return false;
29 }

References cms::cuda::assert(), c, mps_fire::i, nSsubdetNames, mps_fire::result, and subdetNames.

Referenced by parseHcalDetId().

Variable Documentation

◆ nSsubdetNames

const unsigned nSsubdetNames = sizeof(subdetNames) / sizeof(subdetNames[0])
static

Definition at line 18 of file parseHcalDetId.cc.

Referenced by hcalSubdetectorName(), and parseSubdetector().

◆ subdetNames

const char* subdetNames[]
static
Initial value:
= {
"",
"HB",
"HE",
"HO",
"HF",
}

Definition at line 11 of file parseHcalDetId.cc.

Referenced by LASBarrelAlgorithm::Dump(), hcalSubdetectorName(), parseSubdetector(), and LASBarrelAlignmentParameterSet::Print().

mps_fire.i
i
Definition: mps_fire.py:428
parse_int
static bool parse_int(const char *c, int *result)
Definition: parseHcalDetId.cc:31
cms::cuda::assert
assert(be >=bs)
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
alignCSCRings.s
s
Definition: alignCSCRings.py:92
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
subdetNames
static const char * subdetNames[]
Definition: parseHcalDetId.cc:11
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalDetId
Definition: HcalDetId.h:12
nSsubdetNames
static const unsigned nSsubdetNames
Definition: parseHcalDetId.cc:18
HcalSubdetector
HcalSubdetector
Definition: HcalAssistant.h:31
std
Definition: JetResolutionObject.h:76
parseSubdetector
static bool parseSubdetector(const char *c, HcalSubdetector *result)
Definition: parseHcalDetId.cc:20
mps_fire.result
result
Definition: mps_fire.py:311
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56