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

const char* hcalSubdetectorName ( HcalSubdetector  subdet)

Definition at line 43 of file parseHcalDetId.cc.

References nSsubdetNames, and subdetNames.

44 {
45  const unsigned ind = static_cast<unsigned>(subdet);
46  assert(ind < nSsubdetNames);
47  return subdetNames[ind];
48 }
static const unsigned nSsubdetNames
static const char * subdetNames[]
HcalDetId parseHcalDetId ( const std::string &  s)

Definition at line 50 of file parseHcalDetId.cc.

References particleFlowClusterECALTimeSelected_cfi::depth, parse_int(), parseSubdetector(), and mps_fire::result.

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