CMS 3D CMS Logo

Cabling.cc
Go to the documentation of this file.
5 
9 
10 using namespace std;
11 using namespace trklet;
12 
13 Cabling::Cabling(string dtcconfig, string moduleconfig, Settings const& settings) : settings_(settings) {
14  ifstream indtc(dtcconfig.c_str());
15  assert(indtc.good());
16 
17  string dtc;
18  int isec;
19 
20  while (indtc.good()) {
21  indtc >> dtc >> isec;
22 
23  if (!indtc.good())
24  continue;
25 
26  if (dtcs_.find(dtc) == dtcs_.end()) {
27  dtcs_[dtc].setName(dtc);
28  }
29 
30  dtcs_[dtc].addSec(isec);
31 
32  string dtcbase = dtc.substr(2, dtc.size() - 2);
33  if (dtc[0] == 'n') {
34  dtcbase = "neg_" + dtc.substr(6, dtc.size() - 6);
35  }
36  if (dtcranges_.find(dtcbase) == dtcranges_.end()) {
37  dtcranges_[dtcbase].setName(dtcbase);
38  }
39  }
40 
41  ifstream inmodules(moduleconfig.c_str());
42 
43  int layer, ladder, module;
44 
45  while (inmodules.good()) {
46  inmodules >> layer >> ladder >> module >> dtc;
47 
48  // in the cabling module map, module# 300+ is flat part of barrel, 200-299 is tilted z-, 100-199 is tilted z+
49  if (module > 300) {
50  if (layer > 0 && layer <= (int)N_PSLAYER) {
51  module = (module - 300) + N_TILTED_RINGS;
52  } else if (layer > (int)N_PSLAYER) {
53  module = (module - 300);
54  }
55  }
56  if (module > 200) {
57  module = (module - 200);
58  }
59  if ((module > 100) && (layer > 0 && layer <= (int)N_PSLAYER)) {
60  module = (module - 100) + N_TILTED_RINGS + N_MOD_PLANK.at(layer - 1);
61  }
62  if (!inmodules.good())
63  break;
64  modules_[layer][ladder][module] = dtc;
65  }
66 }
67 
68 const string& Cabling::dtc(int layer, int ladder, int module) const {
69  auto it1 = modules_.find(layer);
70  assert(it1 != modules_.end());
71  auto it2 = it1->second.find(ladder);
72  assert(it2 != it1->second.end());
73  auto it3 = it2->second.find(module);
74  if (it3 == it2->second.end()) {
75  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << "Could not find stub " << layer << " "
76  << ladder << " " << module;
77  }
78  return it3->second;
79 }
80 
81 void Cabling::addphi(const string& dtc, double phi, int layer, int module) {
82  unsigned int layerdisk = layer - 1;
83 
84  if (layer > 1000)
85  layerdisk = module + N_DISK;
86 
87  assert(layerdisk < N_LAYER + N_DISK);
88 
89  int isec = dtc[0] - '0';
90 
91  string dtcbase = dtc.substr(2, dtc.size() - 2);
92  if (dtc[0] == 'n') {
93  dtcbase = "neg_" + dtc.substr(6, dtc.size() - 6);
94  isec = dtc[4] - '0';
95  }
96 
97  double phisec = reco::reduceRange(phi - isec * settings_.dphisector());
98 
99  assert(dtcranges_.find(dtcbase) != dtcranges_.end());
100 
101  dtcranges_[dtcbase].addphi(phisec, layerdisk);
102 }
103 
105  ofstream out("dtcphirange.txt");
106 
107  for (auto&& it : dtcranges_) {
108  for (unsigned int i = 0; i < N_LAYER + N_DISK; i++) {
109  double min = it.second.min(i);
110  double max = it.second.max(i);
111  if (min < max) {
112  out << it.first << " " << i + 1 << " " << min << " " << max << endl;
113  }
114  }
115  }
116 }
117 
118 std::vector<string> Cabling::DTCs() const {
119  std::vector<string> tmp;
120 
121  for (const auto& it : dtcs_) {
122  tmp.push_back(it.first);
123  }
124 
125  return tmp;
126 }
trklet::N_PSLAYER
constexpr unsigned int N_PSLAYER
Definition: Settings.h:21
Util.h
trklet::Cabling::writephirange
void writephirange() const
Definition: Cabling.cc:104
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
min
T min(T a, T b)
Definition: MathUtil.h:58
deltaPhi.h
trklet::Settings
Definition: Settings.h:26
trklet::Cabling::settings_
Settings const & settings_
Definition: Cabling.h:31
cms::cuda::assert
assert(be >=bs)
trklet::Cabling::DTCs
std::vector< std::string > DTCs() const
Definition: Cabling.cc:118
trklet::N_DISK
constexpr int N_DISK
Definition: Settings.h:20
trklet::Settings::dphisector
double dphisector() const
Definition: Settings.h:238
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::N_TILTED_RINGS
constexpr unsigned int N_TILTED_RINGS
Definition: Settings.h:727
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:19
trklet::Cabling::dtcs_
std::map< std::string, DTC > dtcs_
Definition: Cabling.h:34
DTC.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
trklet::Cabling::dtc
const std::string & dtc(int layer, int ladder, int module) const
Definition: Cabling.cc:68
createfilelist.int
int
Definition: createfilelist.py:10
trklet
Definition: AllProjectionsMemory.h:9
trklet::Cabling::dtcranges_
std::map< std::string, DTC > dtcranges_
Definition: Cabling.h:33
Cabling.h
trklet::Cabling::addphi
void addphi(const std::string &dtc, double phi, int layer, int module)
Definition: Cabling.cc:81
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:246
trklet::N_MOD_PLANK
constexpr std::array< unsigned int, N_PSLAYER > N_MOD_PLANK
Definition: Settings.h:728
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
Exception.h
trklet::Cabling::modules_
std::map< int, std::map< int, std::map< int, std::string > > > modules_
Definition: Cabling.h:35
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
reco::reduceRange
constexpr T reduceRange(T x)
Definition: deltaPhi.h:18