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 (FSIZE + ISIZE + SSIZE) {
110  case 6:
111  return 1;
112  default:
113  throw cms::Exception("AlignPCLThresholdsHG")
114  << "Payload version with parameter size equal to " << FSIZE + ISIZE + SSIZE << " is not defined.\n";
115  }
116 }
117 
118 //****************************************************************************//
120  edm::LogVerbatim out("AlignPCLThresholdsHG");
121 
122  out << "AlignPCLThresholdsHG::printAll()\n";
123  out << "============================================================================================================="
124  "======\n";
125  out << "N records cut: " << this->getNrecords() << "\n";
126  for (auto it = m_thresholds.begin(); it != m_thresholds.end(); ++it) {
127  out << "==========================================================================================================="
128  "========\n";
129 
130  std::stringstream ss;
131 
132  ss << "key : " << it->first << " \n"
133  << "- Xcut : " << std::setw(4) << (it->second).getXcut() << std::setw(5) << " um"
134  << "| sigXcut : " << std::setw(4) << (it->second).getSigXcut() << std::setw(1) << " "
135  << "| maxMoveXcut : " << std::setw(4) << (it->second).getMaxMoveXcut() << std::setw(5) << " um"
136  << "| ErrorXcut : " << std::setw(4) << (it->second).getErrorXcut() << std::setw(5) << " um";
137 
138  if (floatMap_.find(it->first) != floatMap_.end()) {
139  ss << "| X_fractionCut : " << std::setw(4) << getFractionCut(it->first, X) << std::setw(5) << "\n";
140  } else {
141  ss << "\n";
142  }
143 
144  ss << "- thetaXcut : " << std::setw(4) << (it->second).getThetaXcut() << std::setw(5) << " urad"
145  << "| sigThetaXcut : " << std::setw(4) << (it->second).getSigThetaXcut() << std::setw(1) << " "
146  << "| maxMoveThetaXcut : " << std::setw(4) << (it->second).getMaxMoveThetaXcut() << std::setw(5) << " urad"
147  << "| ErrorThetaXcut : " << std::setw(4) << (it->second).getErrorThetaXcut() << std::setw(5) << " urad";
148 
149  if (floatMap_.find(it->first) != floatMap_.end()) {
150  ss << "| thetaX_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_X) << std::setw(5) << "\n";
151  } else {
152  ss << "\n";
153  }
154 
155  ss << "- Ycut : " << std::setw(4) << (it->second).getYcut() << std::setw(5) << " um"
156  << "| sigYcut : " << std::setw(4) << (it->second).getSigXcut() << std::setw(1) << " "
157  << "| maxMoveYcut : " << std::setw(4) << (it->second).getMaxMoveYcut() << std::setw(5) << " um"
158  << "| ErrorYcut : " << std::setw(4) << (it->second).getErrorYcut() << std::setw(5) << " um";
159 
160  if (floatMap_.find(it->first) != floatMap_.end()) {
161  ss << "| Y_fractionCut : " << std::setw(4) << getFractionCut(it->first, Y) << std::setw(5) << "\n";
162  } else {
163  ss << "\n";
164  }
165 
166  ss << "- thetaYcut : " << std::setw(4) << (it->second).getThetaYcut() << std::setw(5) << " urad"
167  << "| sigThetaYcut : " << std::setw(4) << (it->second).getSigThetaYcut() << std::setw(1) << " "
168  << "| maxMoveThetaYcut : " << std::setw(4) << (it->second).getMaxMoveThetaYcut() << std::setw(5) << " urad"
169  << "| ErrorThetaYcut : " << std::setw(4) << (it->second).getErrorThetaYcut() << std::setw(5) << " urad";
170 
171  if (floatMap_.find(it->first) != floatMap_.end()) {
172  ss << "| thetaY_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_Y) << std::setw(5) << "\n";
173  } else {
174  ss << "\n";
175  }
176 
177  ss << "- Zcut : " << std::setw(4) << (it->second).getZcut() << std::setw(5) << " um"
178  << "| sigZcut : " << std::setw(4) << (it->second).getSigZcut() << std::setw(1) << " "
179  << "| maxMoveZcut : " << std::setw(4) << (it->second).getMaxMoveZcut() << std::setw(5) << " um"
180  << "| ErrorZcut : " << std::setw(4) << (it->second).getErrorZcut() << std::setw(5) << " um";
181 
182  if (floatMap_.find(it->first) != floatMap_.end()) {
183  ss << "| Z_fractionCut : " << std::setw(4) << getFractionCut(it->first, Z) << std::setw(5) << "\n";
184  } else {
185  ss << "\n";
186  }
187 
188  ss << "- thetaZcut : " << std::setw(4) << (it->second).getThetaZcut() << std::setw(5) << " urad"
189  << "| sigThetaZcut : " << std::setw(4) << (it->second).getSigThetaZcut() << std::setw(1) << " "
190  << "| maxMoveThetaZcut : " << std::setw(4) << (it->second).getMaxMoveThetaZcut() << std::setw(5) << " urad"
191  << "| ErrorThetaZcut : " << std::setw(4) << (it->second).getErrorThetaZcut() << std::setw(5) << " urad";
192 
193  if (floatMap_.find(it->first) != floatMap_.end()) {
194  ss << "| thetaZ_fractionCut : " << std::setw(4) << getFractionCut(it->first, theta_Z) << std::setw(5) << "\n";
195  } else {
196  ss << "\n";
197  }
198 
199  out << ss.str() << std::endl;
200 
201  if ((it->second).hasExtraDOF()) {
202  for (unsigned int j = 0; j < (it->second).extraDOFSize(); j++) {
203  std::array<float, 4> extraDOFCuts = getExtraDOFCutsForAlignable(it->first, j);
204 
205  out << "Extra DOF " << j << " with label: " << getExtraDOFLabelForAlignable(it->first, j);
206  out << "- cut : " << std::setw(4) << extraDOFCuts.at(0) << std::setw(5) << " "
207  << "| sigCut : " << std::setw(4) << extraDOFCuts.at(1) << std::setw(1) << " "
208  << "| maxMoveCut : " << std::setw(4) << extraDOFCuts.at(2) << std::setw(5) << " "
209  << "| maxErrorCut : " << std::setw(4) << extraDOFCuts.at(3) << std::setw(5) << " ";
210  }
211  }
212  }
213 }
void setFloatMap(const param_map &floatMap)
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 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