CMS 3D CMS Logo

ProcessBase.cc
Go to the documentation of this file.
5 
8 
9 #include <unordered_map>
10 
11 using namespace trklet;
12 using namespace std;
13 
14 ProcessBase::ProcessBase(string name, Settings const& settings, Globals* global)
15  : name_(name), settings_(settings), globals_(global) {}
16 
17 unsigned int ProcessBase::nbits(unsigned int power) {
18  if (power == 2)
19  return 1;
20  if (power == 4)
21  return 2;
22  if (power == 8)
23  return 3;
24  if (power == 16)
25  return 4;
26  if (power == 32)
27  return 5;
28 
29  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << "nbits: power = " << power;
30  return 0;
31 }
32 
33 void ProcessBase::initLayerDisk(unsigned int pos, int& layer, int& disk) {
34  string subname = name_.substr(pos, 2);
35  layer = 0;
36  disk = 0;
37  if (subname.substr(0, 1) == "L")
38  layer = stoi(subname.substr(1, 1));
39  else if (subname.substr(0, 1) == "D")
40  disk = stoi(subname.substr(1, 1));
41  else
42  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " " << name_ << " subname = " << subname << " "
43  << layer << " " << disk;
44 }
45 
46 void ProcessBase::initLayerDisk(unsigned int pos, int& layer, int& disk, int& layerdisk) {
47  initLayerDisk(pos, layer, disk);
48 
49  layerdisk = layer - 1;
50  if (disk > 0)
51  layerdisk = N_LAYER + disk - 1;
52 }
53 
54 unsigned int ProcessBase::initLayerDisk(unsigned int pos) {
55  int layer, disk;
56  initLayerDisk(pos, layer, disk);
57 
58  if (disk > 0)
59  return N_LAYER + disk - 1;
60  return layer - 1;
61 }
62 
63 void ProcessBase::initLayerDisksandISeed(unsigned int& layerdisk1, unsigned int& layerdisk2, unsigned int& iSeed) {
64  layerdisk1 = 99;
65  layerdisk2 = 99;
66 
67  if (name_.substr(0, 3) == "TE_") {
68  if (name_[3] == 'L') {
69  layerdisk1 = name_[4] - '1';
70  } else if (name_[3] == 'D') {
71  layerdisk1 = N_LAYER + name_[4] - '1';
72  }
73  if (name_[11] == 'L') {
74  layerdisk2 = name_[12] - '1';
75  } else if (name_[11] == 'D') {
76  layerdisk2 = N_LAYER + name_[12] - '1';
77  } else if (name_[12] == 'L') {
78  layerdisk2 = name_[13] - '1';
79  } else if (name_[12] == 'D') {
80  layerdisk2 = N_LAYER + name_[13] - '1';
81  }
82  }
83 
84  if ((name_.substr(0, 3) == "TC_") || (name_.substr(0, 3) == "TP_")) {
85  if (name_[3] == 'L') {
86  layerdisk1 = name_[4] - '1';
87  } else if (name_[3] == 'D') {
88  layerdisk1 = N_LAYER + name_[4] - '1';
89  }
90  if (name_[5] == 'L') {
91  layerdisk2 = name_[6] - '1';
92  } else if (name_[5] == 'D') {
93  layerdisk2 = N_LAYER + name_[6] - '1';
94  }
95  }
96 
97  if (layerdisk1 == LayerDisk::L1 && layerdisk2 == LayerDisk::L2)
98  iSeed = Seed::L1L2;
99  else if (layerdisk1 == LayerDisk::L2 && layerdisk2 == LayerDisk::L3)
100  iSeed = Seed::L2L3;
101  else if (layerdisk1 == LayerDisk::L3 && layerdisk2 == LayerDisk::L4)
102  iSeed = Seed::L3L4;
103  else if (layerdisk1 == LayerDisk::L5 && layerdisk2 == LayerDisk::L6)
104  iSeed = Seed::L5L6;
105  else if (layerdisk1 == LayerDisk::D1 && layerdisk2 == LayerDisk::D2)
106  iSeed = Seed::D1D2;
107  else if (layerdisk1 == LayerDisk::D3 && layerdisk2 == LayerDisk::D4)
108  iSeed = Seed::D3D4;
109  else if (layerdisk1 == LayerDisk::L1 && layerdisk2 == LayerDisk::D1)
110  iSeed = Seed::L1D1;
111  else if (layerdisk1 == LayerDisk::L2 && layerdisk2 == LayerDisk::D1)
112  iSeed = Seed::L2D1;
113  else {
114  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " layerdisk1 " << layerdisk1 << " layerdisk2 "
115  << layerdisk2;
116  }
117 }
118 
119 unsigned int ProcessBase::getISeed(const std::string& name) {
120  std::size_t pos = name.find('_');
121  std::string name1 = name.substr(pos + 1);
122  pos = name1.find('_');
123  std::string name2 = name1.substr(0, pos);
124 
125  unordered_map<string, unsigned int> seedmap = {
126  {"L1L2", 0}, {"L2L3", 1}, {"L3L4", 2}, {"L5L6", 3}, {"D1D2", 4}, {"D3D4", 5}, {"L1D1", 6},
127  {"L2D1", 7}, {"L1L2XX", 0}, {"L2L3XX", 1}, {"L3L4XX", 2}, {"L5L6XX", 3}, {"D1D2XX", 4}, {"D3D4XX", 5},
128  {"L1D1XX", 6}, {"L2D1XX", 7}, {"L3L4L2", 8}, {"L5L6L4", 9}, {"L2L3D1", 10}, {"D1D2L2", 11}};
129  auto found = seedmap.find(name2);
130  if (found != seedmap.end())
131  return found->second;
132 
133  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " " << getName() << " name name1 name2 " << name
134  << " - " << name1 << " - " << name2;
135  return 0;
136 }
Divides< B, C > D2
Definition: Factorize.h:137
std::string name_
Definition: ProcessBase.h:38
void initLayerDisksandISeed(unsigned int &layerdisk1, unsigned int &layerdisk2, unsigned int &iSeed)
Definition: ProcessBase.cc:63
ProcessBase(std::string name, Settings const &settings, Globals *global)
Definition: ProcessBase.cc:14
constexpr std::array< uint8_t, layerIndexSize > layer
unsigned int nbits(unsigned int power)
Definition: ProcessBase.cc:17
Divides< A, C > D1
Definition: Factorize.h:136
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: ProcessBase.cc:33
unsigned int getISeed(const std::string &name)
Definition: ProcessBase.cc:119
std::string const & getName() const
Definition: ProcessBase.h:22
constexpr int N_LAYER
Definition: Settings.h:21