CMS 3D CMS Logo

List of all members | Static Public Member Functions
RPCLBLinkNameParser Class Reference

#include <RPCLBLinkNameParser.h>

Static Public Member Functions

static void parse (std::string const &name, RPCLBLink &lb_link)
 
static RPCLBLink parse (std::string const &name)
 

Detailed Description

Definition at line 8 of file RPCLBLinkNameParser.h.

Member Function Documentation

◆ parse() [1/2]

void RPCLBLinkNameParser::parse ( std::string const &  name,
RPCLBLink lb_link 
)
static

Definition at line 7 of file RPCLBLinkNameParser.cc.

References conv, Exception, spr::find(), Skims_PA_cff::name, GetRecoTauVFromDQM_MC_cff::next, RPCLBLink::reset(), RPCLBLink::setFibre(), RPCLBLink::setLinkBoard(), RPCLBLink::setRadial(), RPCLBLink::setRegion(), RPCLBLink::setSector(), RPCLBLink::setSide(), RPCLBLink::setWheelOrDisk(), RPCLBLink::setYoke(), findQualityFiles::size, AlCaHLTBitMon_QueryRunRegistry::string, and createJobs::tmp.

Referenced by RPCAMCLinkMapHandler::getNewObjects(), RPCDCCLinkMapHandler::getNewObjects(), RPCLBLinkMapHandler::getNewObjects(), and parse().

7  {
8  lb_link.reset();
11  int tmp;
12 
13  std::istringstream conv;
14 
15  // region
16  pos = name.find("_R", pos);
17  if (pos == std::string::npos || (pos += 2) >= size)
18  throw cms::Exception("InvalidLinkBoardName") << "Expected _R[region], got " << name;
19  switch (name.at(pos)) {
20  case 'B':
21  lb_link.setRegion(0);
22  break;
23  case 'E':
24  lb_link.setRegion(1);
25  break;
26  default:
27  throw cms::Exception("InvalidLinkBoardName") << "Expected Region B or E, got " << name.at(pos) << " in " << name;
28  break;
29  }
30  if ((++pos) >= size)
31  throw cms::Exception("InvalidLinkBoardName") << "Name too short: " << name;
32 
33  // yoke
34  next = name.find_first_not_of("+-0123456789", pos);
35  conv.clear();
36  conv.str(name.substr(pos, next - pos));
37  conv >> tmp;
38  lb_link.setYoke(tmp);
39  pos = next;
40 
41  // sector
42  pos = name.find("_S", pos);
43  if (pos == std::string::npos || (pos += 2) >= size)
44  throw cms::Exception("InvalidLinkBoardName") << "Expected _S[sector], got " << name;
45  next = name.find_first_not_of("+-0123456789", pos);
46  conv.clear();
47  conv.str(name.substr(pos, next - pos));
48  conv >> tmp;
49  lb_link.setSector(tmp);
50  pos = next;
51 
52  // (region) side
53  pos = name.find('_', pos);
54  if (pos == std::string::npos || (pos += 2) >= size)
55  throw cms::Exception("InvalidLinkBoardName") << "Name too short: " << name;
56  switch (name.at(pos)) {
57  case 'N':
58  lb_link.setSide(0);
59  break;
60  case 'M':
61  lb_link.setSide(1);
62  break;
63  case 'P':
64  lb_link.setSide(2);
65  break;
66  default:
67  throw cms::Exception("InvalidLinkBoardName") << "Expected Side N, M or P, got " << name.at(pos) << " in " << name;
68  break;
69  }
70  if ((++pos) >= size)
71  throw cms::Exception("InvalidLinkBoardName") << "Name too short: " << name;
72 
73  // wheelordisk
74  conv.clear();
75  conv.str(name.substr(pos, 1));
76  conv >> tmp;
77  lb_link.setWheelOrDisk(tmp);
78  if ((++pos) >= size)
79  throw cms::Exception("InvalidLinkBoardName") << "Name too short: " << name;
80 
81  // fibre
82  {
83  std::string fibre("123ABCDE");
84  char const* tmpchar = std::find(&(fibre[0]), &(fibre[0]) + 8, name.at(pos));
85  lb_link.setFibre(tmpchar - &(fibre[0]));
86  }
87  if ((++pos) >= size)
88  return;
89 
90  // radial
91  next = name.find("_CH", pos);
92  if (next == std::string::npos)
93  next = size;
94  if (next - pos == 2) {
95  std::string radial = name.substr(pos, 2);
96  if (radial == "ab")
97  lb_link.setRadial(0);
98  else if (radial == "cd")
99  lb_link.setRadial(1);
100  }
101 
102  if (next == size)
103  return;
104 
105  // linkboard
106  pos = next;
107  if (pos + 3 >= size)
108  throw cms::Exception("InvalidLinkBoardName") << "Name too short: " << name;
109  pos += 3;
110  next = name.find_first_not_of("+-0123456789", pos);
111  conv.clear();
112  conv.str(name.substr(pos, next - pos));
113  conv >> tmp;
114  lb_link.setLinkBoard(tmp);
115 }
size
Write out results.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
uint16_t size_type
EPOS::IO_EPOS conv
tmp
align.sh
Definition: createJobs.py:716

◆ parse() [2/2]

RPCLBLink RPCLBLinkNameParser::parse ( std::string const &  name)
static

Definition at line 117 of file RPCLBLinkNameParser.cc.

References Skims_PA_cff::name, and parse().

117  {
118  RPCLBLink lb_link;
119  parse(name, lb_link);
120  return lb_link;
121 }
static void parse(std::string const &name, RPCLBLink &lb_link)