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 const std::vector<float> &AlignPCLThresholdsHG::getFloatVec(const std::string &AlignableId) const {
28  const auto &it = floatMap_.find(AlignableId);
29 
30  if (it != floatMap_.end()) {
31  return it->second;
32  } else {
33  throw cms::Exception("AlignPCLThresholdsHG") << "No float vector defined for Alignable id " << AlignableId << "\n";
34  }
35 }
36 
37 //****************************************************************************//
38 void AlignPCLThresholdsHG::setFractionCut(const std::string &AlignableId, const coordType &type, const float &cut) {
39  // Set entry in map if not yet available
40  const auto &it = floatMap_.find(AlignableId);
41  if (it == floatMap_.end())
42  floatMap_[AlignableId] = std::vector<float>(FSIZE, -1.);
43 
44  switch (type) {
45  case X:
47  case Y:
49  case Z:
51  case theta_X:
53  case theta_Y:
55  case theta_Z:
57  default:
58  throw cms::Exception("AlignPCLThresholdsHG")
59  << "Requested setting fraction threshold for undefined coordinate" << type << "\n";
60  }
61 }
62 
63 //****************************************************************************//
64 std::array<float, 6> AlignPCLThresholdsHG::getFractionCut(const std::string &AlignableId) const {
65  const std::vector<float> vec = getFloatVec(AlignableId);
72 }
73 
74 //****************************************************************************//
75 float AlignPCLThresholdsHG::getFractionCut(const std::string &AlignableId, const coordType &type) const {
76  const std::vector<float> vec = getFloatVec(AlignableId);
77  switch (type) {
78  case X:
80  case Y:
82  case Z:
84  case theta_X:
86  case theta_Y:
88  case theta_Z:
90  default:
91  throw cms::Exception("AlignPCLThresholdsHG")
92  << "Requested fraction threshold for undefined coordinate" << type << "\n";
93  }
94 }
95 
96 //****************************************************************************//
98  switch (FSIZE + ISIZE + SSIZE) {
99  case 6:
100  return 1;
101  default:
102  throw cms::Exception("AlignPCLThresholdsHG")
103  << "Payload version with parameter size equal to " << FSIZE + ISIZE + SSIZE << " is not defined.\n";
104  }
105 }
106 
107 //****************************************************************************//
109  edm::LogVerbatim out("AlignPCLThresholdsHG");
110 
111  out << "AlignPCLThresholdsHG::printAll()\n";
112  out << "============================================================================================================="
113  "======\n";
114  out << "N records cut: " << this->getNrecords() << "\n";
115  for (auto it = m_thresholds.begin(); it != m_thresholds.end(); ++it) {
116  out << "==========================================================================================================="
117  "========\n";
118 
119  std::stringstream ss;
120 
121  ss << "key : " << it->first << " \n"
122  << "- Xcut : " << std::setw(4) << (it->second).getXcut() << std::setw(5) << " um"
123  << "| sigXcut : " << std::setw(4) << (it->second).getSigXcut() << std::setw(1) << " "
124  << "| maxMoveXcut : " << std::setw(4) << (it->second).getMaxMoveXcut() << std::setw(5) << " um"
125  << "| ErrorXcut : " << std::setw(4) << (it->second).getErrorXcut() << std::setw(5) << " um";
126 
127  if (floatMap_.find(it->first) != floatMap_.end()) {
128  ss << "| X_fractionCut : " << std::setw(4) << getFractionCut(it->first, X) << std::setw(5) << "\n";
129  } else {
130  ss << "\n";
131  }
132 
133  ss << "- thetaXcut : " << std::setw(4) << (it->second).getThetaXcut() << std::setw(5) << " urad"
134  << "| sigThetaXcut : " << std::setw(4) << (it->second).getSigThetaXcut() << std::setw(1) << " "
135  << "| maxMoveThetaXcut : " << std::setw(4) << (it->second).getMaxMoveThetaXcut() << std::setw(5) << " urad"
136  << "| ErrorThetaXcut : " << std::setw(4) << (it->second).getErrorThetaXcut() << std::setw(5) << " urad";
137 
138  if (floatMap_.find(it->first) != floatMap_.end()) {
139  ss << "| thetaX_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_X) << std::setw(5) << "\n";
140  } else {
141  ss << "\n";
142  }
143 
144  ss << "- Ycut : " << std::setw(4) << (it->second).getYcut() << std::setw(5) << " um"
145  << "| sigYcut : " << std::setw(4) << (it->second).getSigXcut() << std::setw(1) << " "
146  << "| maxMoveYcut : " << std::setw(4) << (it->second).getMaxMoveYcut() << std::setw(5) << " um"
147  << "| ErrorYcut : " << std::setw(4) << (it->second).getErrorYcut() << std::setw(5) << " um";
148 
149  if (floatMap_.find(it->first) != floatMap_.end()) {
150  ss << "| Y_fractionCut : " << std::setw(4) << getFractionCut(it->first, Y) << std::setw(5) << "\n";
151  } else {
152  ss << "\n";
153  }
154 
155  ss << "- thetaYcut : " << std::setw(4) << (it->second).getThetaYcut() << std::setw(5) << " urad"
156  << "| sigThetaYcut : " << std::setw(4) << (it->second).getSigThetaYcut() << std::setw(1) << " "
157  << "| maxMoveThetaYcut : " << std::setw(4) << (it->second).getMaxMoveThetaYcut() << std::setw(5) << " urad"
158  << "| ErrorThetaYcut : " << std::setw(4) << (it->second).getErrorThetaYcut() << std::setw(5) << " urad";
159 
160  if (floatMap_.find(it->first) != floatMap_.end()) {
161  ss << "| thetaY_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_Y) << std::setw(5) << "\n";
162  } else {
163  ss << "\n";
164  }
165 
166  ss << "- Zcut : " << std::setw(4) << (it->second).getZcut() << std::setw(5) << " um"
167  << "| sigZcut : " << std::setw(4) << (it->second).getSigZcut() << std::setw(1) << " "
168  << "| maxMoveZcut : " << std::setw(4) << (it->second).getMaxMoveZcut() << std::setw(5) << " um"
169  << "| ErrorZcut : " << std::setw(4) << (it->second).getErrorZcut() << std::setw(5) << " um";
170 
171  if (floatMap_.find(it->first) != floatMap_.end()) {
172  ss << "| Z_fractionCut : " << std::setw(4) << getFractionCut(it->first, Z) << std::setw(5) << "\n";
173  } else {
174  ss << "\n";
175  }
176 
177  ss << "- thetaZcut : " << std::setw(4) << (it->second).getThetaZcut() << std::setw(5) << " urad"
178  << "| sigThetaZcut : " << std::setw(4) << (it->second).getSigThetaZcut() << std::setw(1) << " "
179  << "| maxMoveThetaZcut : " << std::setw(4) << (it->second).getMaxMoveThetaZcut() << std::setw(5) << " urad"
180  << "| ErrorThetaZcut : " << std::setw(4) << (it->second).getErrorThetaZcut() << std::setw(5) << " urad";
181 
182  if (floatMap_.find(it->first) != floatMap_.end()) {
183  ss << "| thetaZ_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_Z) << std::setw(5) << "\n";
184  } else {
185  ss << "\n";
186  }
187 
188  out << ss.str() << std::endl;
189 
190  if ((it->second).hasExtraDOF()) {
191  for (unsigned int j = 0; j < (it->second).extraDOFSize(); j++) {
192  std::array<float, 4> extraDOFCuts = getExtraDOFCutsForAlignable(it->first, j);
193 
194  out << "Extra DOF " << j << " with label: " << getExtraDOFLabelForAlignable(it->first, j);
195  out << "- cut : " << std::setw(4) << extraDOFCuts.at(0) << std::setw(5) << " "
196  << "| sigCut : " << std::setw(4) << extraDOFCuts.at(1) << std::setw(1) << " "
197  << "| maxMoveCut : " << std::setw(4) << extraDOFCuts.at(2) << std::setw(5) << " "
198  << "| maxErrorCut : " << std::setw(4) << extraDOFCuts.at(3) << std::setw(5) << " ";
199  }
200  }
201  }
202 }
std::string getExtraDOFLabelForAlignable(const std::string &AlignableId, const unsigned int i) const
std::string to_string(const V &value)
Definition: OMSAccess.h:71
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 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