CMS 3D CMS Logo

AlignPCLThresholdsHG.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 #include <iomanip> // std::setw
7 
8 //****************************************************************************//
10  template <typename T>
11  const T &getParam(const std::vector<T> &params, size_t index) {
12  if (index >= params.size())
13  throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
14  return params[index];
15  }
16 
17  template <typename T>
18  void setParam(std::vector<T> &params, size_t index, const T &value) {
19  if (index >= params.size())
20  throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
21  params[index] = value;
22  }
23 
24 } //namespace AlignPCLThresholdsHGImpl
25 
26 //****************************************************************************//
27 void AlignPCLThresholdsHG::setFloatMap(const std::unordered_map<std::string, std::vector<float>> &floatMap) {
28  floatMap_ = floatMap;
29 }
30 
31 //****************************************************************************//
32 const std::vector<float> &AlignPCLThresholdsHG::getFloatVec(const std::string &AlignableId) const {
33  const auto &it = floatMap_.find(AlignableId);
34 
35  if (it != floatMap_.end()) {
36  return it->second;
37  } else {
38  throw cms::Exception("AlignPCLThresholdsHG") << "No float vector defined for Alignable id " << AlignableId << "\n";
39  }
40 }
41 
42 //****************************************************************************//
43 void AlignPCLThresholdsHG::setFractionCut(const std::string &AlignableId, const coordType &type, const float &cut) {
44  // Set entry in map if not yet available
45  const auto &it = floatMap_.find(AlignableId);
46  if (it == floatMap_.end())
47  floatMap_[AlignableId] = std::vector<float>(FSIZE, -1.);
48 
49  switch (type) {
50  case X:
52  case Y:
54  case Z:
56  case theta_X:
58  case theta_Y:
60  case theta_Z:
62  default:
63  throw cms::Exception("AlignPCLThresholdsHG")
64  << "Requested setting fraction threshold for undefined coordinate" << type << "\n";
65  }
66 }
67 
68 //****************************************************************************//
69 std::array<float, 6> AlignPCLThresholdsHG::getFractionCut(const std::string &AlignableId) const {
70  const std::vector<float> vec = getFloatVec(AlignableId);
77 }
78 
79 //****************************************************************************//
80 float AlignPCLThresholdsHG::getFractionCut(const std::string &AlignableId, const coordType &type) const {
81  const std::vector<float> vec = getFloatVec(AlignableId);
82  switch (type) {
83  case X:
85  case Y:
87  case Z:
89  case theta_X:
91  case theta_Y:
93  case theta_Z:
95  default:
96  throw cms::Exception("AlignPCLThresholdsHG")
97  << "Requested fraction threshold for undefined coordinate" << type << "\n";
98  }
99 }
100 
101 //****************************************************************************//
102 const bool AlignPCLThresholdsHG::hasFloatMap(const std::string &AlignableId) const {
103  const auto &it = floatMap_.find(AlignableId);
104  return (it != floatMap_.end());
105 }
106 
107 //****************************************************************************//
109  switch (static_cast<int>(FSIZE) + static_cast<int>(ISIZE) + static_cast<int>(SSIZE)) {
110  case 6:
111  return 1;
112  default:
113  throw cms::Exception("AlignPCLThresholdsHG")
114  << "Payload version with parameter size equal to "
115  << static_cast<int>(FSIZE) + static_cast<int>(ISIZE) + static_cast<int>(SSIZE) << " is not defined.\n";
116  }
117 }
118 
119 //****************************************************************************//
121  edm::LogVerbatim out("AlignPCLThresholdsHG");
122 
123  out << "AlignPCLThresholdsHG::printAll()\n";
124  out << "============================================================================================================="
125  "======\n";
126  out << "N records cut: " << this->getNrecords() << "\n";
127  for (auto it = m_thresholds.begin(); it != m_thresholds.end(); ++it) {
128  out << "==========================================================================================================="
129  "========\n";
130 
131  std::stringstream ss;
132 
133  ss << "key : " << it->first << " \n"
134  << "- Xcut : " << std::setw(4) << (it->second).getXcut() << std::setw(5) << " um"
135  << "| sigXcut : " << std::setw(4) << (it->second).getSigXcut() << std::setw(1) << " "
136  << "| maxMoveXcut : " << std::setw(4) << (it->second).getMaxMoveXcut() << std::setw(5) << " um"
137  << "| ErrorXcut : " << std::setw(4) << (it->second).getErrorXcut() << std::setw(5) << " um";
138 
139  if (floatMap_.find(it->first) != floatMap_.end()) {
140  ss << "| X_fractionCut : " << std::setw(4) << getFractionCut(it->first, X) << std::setw(5) << "\n";
141  } else {
142  ss << "\n";
143  }
144 
145  ss << "- thetaXcut : " << std::setw(4) << (it->second).getThetaXcut() << std::setw(5) << " urad"
146  << "| sigThetaXcut : " << std::setw(4) << (it->second).getSigThetaXcut() << std::setw(1) << " "
147  << "| maxMoveThetaXcut : " << std::setw(4) << (it->second).getMaxMoveThetaXcut() << std::setw(5) << " urad"
148  << "| ErrorThetaXcut : " << std::setw(4) << (it->second).getErrorThetaXcut() << std::setw(5) << " urad";
149 
150  if (floatMap_.find(it->first) != floatMap_.end()) {
151  ss << "| thetaX_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_X) << std::setw(5) << "\n";
152  } else {
153  ss << "\n";
154  }
155 
156  ss << "- Ycut : " << std::setw(4) << (it->second).getYcut() << std::setw(5) << " um"
157  << "| sigYcut : " << std::setw(4) << (it->second).getSigXcut() << std::setw(1) << " "
158  << "| maxMoveYcut : " << std::setw(4) << (it->second).getMaxMoveYcut() << std::setw(5) << " um"
159  << "| ErrorYcut : " << std::setw(4) << (it->second).getErrorYcut() << std::setw(5) << " um";
160 
161  if (floatMap_.find(it->first) != floatMap_.end()) {
162  ss << "| Y_fractionCut : " << std::setw(4) << getFractionCut(it->first, Y) << std::setw(5) << "\n";
163  } else {
164  ss << "\n";
165  }
166 
167  ss << "- thetaYcut : " << std::setw(4) << (it->second).getThetaYcut() << std::setw(5) << " urad"
168  << "| sigThetaYcut : " << std::setw(4) << (it->second).getSigThetaYcut() << std::setw(1) << " "
169  << "| maxMoveThetaYcut : " << std::setw(4) << (it->second).getMaxMoveThetaYcut() << std::setw(5) << " urad"
170  << "| ErrorThetaYcut : " << std::setw(4) << (it->second).getErrorThetaYcut() << std::setw(5) << " urad";
171 
172  if (floatMap_.find(it->first) != floatMap_.end()) {
173  ss << "| thetaY_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_Y) << std::setw(5) << "\n";
174  } else {
175  ss << "\n";
176  }
177 
178  ss << "- Zcut : " << std::setw(4) << (it->second).getZcut() << std::setw(5) << " um"
179  << "| sigZcut : " << std::setw(4) << (it->second).getSigZcut() << std::setw(1) << " "
180  << "| maxMoveZcut : " << std::setw(4) << (it->second).getMaxMoveZcut() << std::setw(5) << " um"
181  << "| ErrorZcut : " << std::setw(4) << (it->second).getErrorZcut() << std::setw(5) << " um";
182 
183  if (floatMap_.find(it->first) != floatMap_.end()) {
184  ss << "| Z_fractionCut : " << std::setw(4) << getFractionCut(it->first, Z) << std::setw(5) << "\n";
185  } else {
186  ss << "\n";
187  }
188 
189  ss << "- thetaZcut : " << std::setw(4) << (it->second).getThetaZcut() << std::setw(5) << " urad"
190  << "| sigThetaZcut : " << std::setw(4) << (it->second).getSigThetaZcut() << std::setw(1) << " "
191  << "| maxMoveThetaZcut : " << std::setw(4) << (it->second).getMaxMoveThetaZcut() << std::setw(5) << " urad"
192  << "| ErrorThetaZcut : " << std::setw(4) << (it->second).getErrorThetaZcut() << std::setw(5) << " urad";
193 
194  if (floatMap_.find(it->first) != floatMap_.end()) {
195  ss << "| thetaZ_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_Z) << std::setw(5) << "\n";
196  } else {
197  ss << "\n";
198  }
199 
200  out << ss.str() << std::endl;
201 
202  if ((it->second).hasExtraDOF()) {
203  for (unsigned int j = 0; j < (it->second).extraDOFSize(); j++) {
204  std::array<float, 4> extraDOFCuts = getExtraDOFCutsForAlignable(it->first, j);
205 
206  out << "Extra DOF " << j << " with label: " << getExtraDOFLabelForAlignable(it->first, j);
207  out << "- cut : " << std::setw(4) << extraDOFCuts.at(0) << std::setw(5) << " "
208  << "| sigCut : " << std::setw(4) << extraDOFCuts.at(1) << std::setw(1) << " "
209  << "| maxMoveCut : " << std::setw(4) << extraDOFCuts.at(2) << std::setw(5) << " "
210  << "| maxErrorCut : " << std::setw(4) << extraDOFCuts.at(3) << std::setw(5) << " ";
211  }
212  }
213  }
214 }
void setFloatMap(const param_map &floatMap)
std::string getExtraDOFLabelForAlignable(const std::string &AlignableId, const unsigned int i) const
static std::string to_string(const XMLCh *ch)
void setParam(std::vector< T > &params, size_t index, const T &value)
const std::vector< float > & getFloatVec(const std::string &AlignableId) const
const int & getNrecords() const
std::array< float, 4 > getExtraDOFCutsForAlignable(const std::string &AlignableId, const unsigned int i) const
const bool hasFloatMap(const std::string &AlignableId) const
const T & getParam(const std::vector< T > &params, size_t index)
Definition: value.py:1
const int payloadVersion() const
threshold_map m_thresholds
float getFractionCut(const std::string &AlignableId, const coordType &type) const
void setFractionCut(const std::string &AlignableId, const coordType &type, const float &cut)
long double T