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, unsigned int iSector)
15  : name_(name), settings_(settings), globals_(global) {
16  iSector_ = iSector;
17  double dphi = 2 * M_PI / N_SECTOR;
18  double dphiHG = 0.5 * settings_.dphisectorHG() - M_PI / N_SECTOR;
19  phimin_ = iSector_ * dphi - dphiHG;
20  phimax_ = phimin_ + dphi + 2 * dphiHG;
21  phimin_ -= M_PI / N_SECTOR;
22  phimax_ -= M_PI / N_SECTOR;
23  if (phimin_ > M_PI) {
24  phimin_ -= 2 * M_PI;
25  phimax_ -= 2 * M_PI;
26  }
27 }
28 
29 unsigned int ProcessBase::nbits(unsigned int power) {
30  if (power == 2)
31  return 1;
32  if (power == 4)
33  return 2;
34  if (power == 8)
35  return 3;
36  if (power == 16)
37  return 4;
38  if (power == 32)
39  return 5;
40 
41  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << "nbits: power = " << power;
42  return 0;
43 }
44 
45 void ProcessBase::initLayerDisk(unsigned int pos, int& layer, int& disk) {
46  string subname = name_.substr(pos, 2);
47  layer = 0;
48  disk = 0;
49  if (subname.substr(0, 1) == "L")
50  layer = stoi(subname.substr(1, 1));
51  else if (subname.substr(0, 1) == "D")
52  disk = stoi(subname.substr(1, 1));
53  else
54  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " " << name_ << " subname = " << subname << " "
55  << layer << " " << disk;
56 }
57 
58 void ProcessBase::initLayerDisk(unsigned int pos, int& layer, int& disk, int& layerdisk) {
59  initLayerDisk(pos, layer, disk);
60 
61  layerdisk = layer - 1;
62  if (disk > 0)
63  layerdisk = N_DISK + disk;
64 }
65 
66 unsigned int ProcessBase::initLayerDisk(unsigned int pos) {
67  int layer, disk;
68  initLayerDisk(pos, layer, disk);
69 
70  if (disk > 0)
71  return N_DISK + disk;
72  return layer - 1;
73 }
74 
75 void ProcessBase::initLayerDisksandISeed(unsigned int& layerdisk1, unsigned int& layerdisk2, unsigned int& iSeed) {
76  layerdisk1 = 99;
77  layerdisk2 = 99;
78 
79  if (name_.substr(0, 3) == "TE_") {
80  if (name_[3] == 'L') {
81  layerdisk1 = name_[4] - '1';
82  } else if (name_[3] == 'D') {
83  layerdisk1 = 6 + name_[4] - '1';
84  }
85  if (name_[11] == 'L') {
86  layerdisk2 = name_[12] - '1';
87  } else if (name_[11] == 'D') {
88  layerdisk2 = 6 + name_[12] - '1';
89  } else if (name_[12] == 'L') {
90  layerdisk2 = name_[13] - '1';
91  } else if (name_[12] == 'D') {
92  layerdisk2 = 6 + name_[13] - '1';
93  }
94  }
95 
96  if ((name_.substr(0, 3) == "TC_") || (name_.substr(0, 3) == "TP_")) {
97  if (name_[3] == 'L') {
98  layerdisk1 = name_[4] - '1';
99  } else if (name_[3] == 'D') {
100  layerdisk1 = 6 + name_[4] - '1';
101  }
102  if (name_[5] == 'L') {
103  layerdisk2 = name_[6] - '1';
104  } else if (name_[5] == 'D') {
105  layerdisk2 = 6 + name_[6] - '1';
106  }
107  }
108 
109  if (layerdisk1 == 0 && layerdisk2 == 1)
110  iSeed = 0;
111  else if (layerdisk1 == 1 && layerdisk2 == 2)
112  iSeed = 1;
113  else if (layerdisk1 == 2 && layerdisk2 == 3)
114  iSeed = 2;
115  else if (layerdisk1 == 4 && layerdisk2 == 5)
116  iSeed = 3;
117  else if (layerdisk1 == 6 && layerdisk2 == 7)
118  iSeed = 4;
119  else if (layerdisk1 == 8 && layerdisk2 == 9)
120  iSeed = 5;
121  else if (layerdisk1 == 0 && layerdisk2 == 6)
122  iSeed = 6;
123  else if (layerdisk1 == 1 && layerdisk2 == 6)
124  iSeed = 7;
125  else {
126  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " layerdisk1 " << layerdisk1 << " layerdisk2 "
127  << layerdisk2;
128  }
129 }
130 
132  std::size_t pos = name.find("_");
133  std::string name1 = name.substr(pos + 1);
134  pos = name1.find("_");
135  std::string name2 = name1.substr(0, pos);
136 
137  unordered_map<string, unsigned int> seedmap = {
138  {"L1L2", 0}, {"L2L3", 1}, {"L3L4", 2}, {"L5L6", 3}, {"D1D2", 4}, {"D3D4", 5}, {"L1D1", 6},
139  {"L2D1", 7}, {"L1L2XX", 0}, {"L2L3XX", 1}, {"L3L4XX", 2}, {"L5L6XX", 3}, {"D1D2XX", 4}, {"D3D4XX", 5},
140  {"L1D1XX", 6}, {"L2D1XX", 7}, {"L3L4L2", 8}, {"L5L6L4", 9}, {"L2L3D1", 10}, {"D1D2L2", 11}};
141  auto found = seedmap.find(name2);
142  if (found != seedmap.end())
143  return found->second;
144 
145  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " " << getName() << " name name1 name2 " << name
146  << " - " << name1 << " - " << name2;
147  return 0;
148 }
Settings.h
MessageLogger.h
pos
Definition: PixelAliasList.h:18
trklet::N_SECTOR
constexpr unsigned int N_SECTOR
Definition: Settings.h:17
trklet::Settings
Definition: Settings.h:26
trklet::N_DISK
constexpr int N_DISK
Definition: Settings.h:20
trklet::ProcessBase::nbits
unsigned int nbits(unsigned int power)
Definition: ProcessBase.cc:29
trklet::ProcessBase::settings_
Settings const & settings_
Definition: ProcessBase.h:44
trklet::Globals
Definition: Globals.h:32
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
trklet::Settings::dphisectorHG
double dphisectorHG() const
Definition: Settings.h:228
trklet::ProcessBase::initLayerDisksandISeed
void initLayerDisksandISeed(unsigned int &layerdisk1, unsigned int &layerdisk2, unsigned int &iSeed)
Definition: ProcessBase.cc:75
trklet::ProcessBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: ProcessBase.cc:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Globals.h
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
trklet
Definition: AllProjectionsMemory.h:9
ProcessBase.h
std
Definition: JetResolutionObject.h:76
trklet::ProcessBase::getISeed
unsigned int getISeed(std::string name)
Definition: ProcessBase.cc:131
Exception
Definition: hltDiff.cc:246
trklet::ProcessBase::getName
std::string const & getName() const
Definition: ProcessBase.h:22
trklet::ProcessBase::name_
std::string name_
Definition: ProcessBase.h:38
MemoryBase.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::ProcessBase::iSector_
unsigned int iSector_
Definition: ProcessBase.h:39
Exception.h
cms::Exception
Definition: Exception.h:70
trklet::ProcessBase::phimin_
double phimin_
Definition: ProcessBase.h:41
hfnoseParametersInitialization_cfi.name2
name2
Definition: hfnoseParametersInitialization_cfi.py:8
trklet::ProcessBase::ProcessBase
ProcessBase(std::string name, Settings const &settings, Globals *global, unsigned int iSector)
Definition: ProcessBase.cc:14
trklet::ProcessBase::phimax_
double phimax_
Definition: ProcessBase.h:42