CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MillePedeFileReader.h
Go to the documentation of this file.
1 #ifndef ALIGNMENT_MILLEPEDEALIGNMENTALGORITHM_INTERFACE_MILLEPEDEFILEREADER_H_
2 #define ALIGNMENT_MILLEPEDEALIGNMENTALGORITHM_INTERFACE_MILLEPEDEFILEREADER_H_
3 
4 /*** system includes ***/
5 #include <array>
6 #include <string>
7 #include <iostream>
8 
9 /*** core framework functionality ***/
12 
13 /*** Alignment ***/
17 
18 struct mpPCLresults {
19 private:
25  std::bitset<4> m_updateBits;
26 
27 public:
28  mpPCLresults(bool isDBUpdated,
29  bool isDBUpdateVetoed,
30  int nRecords,
31  int exitCode,
32  std::string exitMessage,
33  std::bitset<4> updateBits)
34  : m_isDBUpdated(isDBUpdated),
35  m_isDBUpdateVetoed(isDBUpdateVetoed),
36  m_nRecords(nRecords),
37  m_exitCode(exitCode),
38  m_exitMessage(exitMessage),
40 
41  const bool getDBUpdated() { return m_isDBUpdated; }
42  const bool getDBVetoed() { return m_isDBUpdateVetoed; }
43  const bool exceedsThresholds() { return m_updateBits.test(0); }
44  const bool exceedsCutoffs() { return m_updateBits.test(1); }
45  const bool exceedsMaxError() { return m_updateBits.test(2); }
46  const bool belowSignificance() { return m_updateBits.test(3); }
47  const int getNRecords() { return m_nRecords; }
48  const int getExitCode() { return m_exitCode; }
50 
51  void print() {
52  edm::LogInfo("MillePedeFileReader") << " is DB updated: " << m_isDBUpdated
53  << " is DB update vetoed: " << m_isDBUpdateVetoed << " nRecords: " << m_nRecords
54  << " exitCode: " << m_exitCode << " (" << m_exitMessage << ")" << std::endl;
55  }
56 };
57 
59  //========================== PUBLIC METHODS ==================================
60 public: //====================================================================
61  explicit MillePedeFileReader(const edm::ParameterSet&,
62  const std::shared_ptr<const PedeLabelerBase>&,
63  const std::shared_ptr<const AlignPCLThresholdsHG>&,
64  const std::shared_ptr<const PixelTopologyMap>&);
65 
66  virtual ~MillePedeFileReader() = default;
67 
68  void read();
69  bool storeAlignments();
70 
71  enum { SIZE_LG_STRUCTS = 6, SIZE_HG_STRUCTS = 820 };
72 
73  const std::array<double, SIZE_LG_STRUCTS>& getXobs() const { return Xobs_; }
74  const std::array<double, SIZE_LG_STRUCTS>& getXobsErr() const { return XobsErr_; }
75  const std::array<double, SIZE_LG_STRUCTS>& getTXobs() const { return tXobs_; }
76  const std::array<double, SIZE_LG_STRUCTS>& getTXobsErr() const { return tXobsErr_; }
77 
78  const std::array<double, SIZE_LG_STRUCTS>& getYobs() const { return Yobs_; }
79  const std::array<double, SIZE_LG_STRUCTS>& getYobsErr() const { return YobsErr_; }
80  const std::array<double, SIZE_LG_STRUCTS>& getTYobs() const { return tYobs_; }
81  const std::array<double, SIZE_LG_STRUCTS>& getTYobsErr() const { return tYobsErr_; }
82 
83  const std::array<double, SIZE_LG_STRUCTS>& getZobs() const { return Zobs_; }
84  const std::array<double, SIZE_LG_STRUCTS>& getZobsErr() const { return ZobsErr_; }
85  const std::array<double, SIZE_LG_STRUCTS>& getTZobs() const { return tZobs_; }
86  const std::array<double, SIZE_LG_STRUCTS>& getTZobsErr() const { return tZobsErr_; }
87 
88  const std::array<double, SIZE_HG_STRUCTS>& getXobs_HG() const { return Xobs_HG_; }
89  const std::array<double, SIZE_HG_STRUCTS>& getXobsErr_HG() const { return XobsErr_HG_; }
90  const std::array<double, SIZE_HG_STRUCTS>& getTXobs_HG() const { return tXobs_HG_; }
91  const std::array<double, SIZE_HG_STRUCTS>& getTXobsErr_HG() const { return tXobsErr_HG_; }
92 
93  const std::array<double, SIZE_HG_STRUCTS>& getYobs_HG() const { return Yobs_HG_; }
94  const std::array<double, SIZE_HG_STRUCTS>& getYobsErr_HG() const { return YobsErr_HG_; }
95  const std::array<double, SIZE_HG_STRUCTS>& getTYobs_HG() const { return tYobs_HG_; }
96  const std::array<double, SIZE_HG_STRUCTS>& getTYobsErr_HG() const { return tYobsErr_HG_; }
97 
98  const std::array<double, SIZE_HG_STRUCTS>& getZobs_HG() const { return Zobs_HG_; }
99  const std::array<double, SIZE_HG_STRUCTS>& getZobsErr_HG() const { return ZobsErr_HG_; }
100  const std::array<double, SIZE_HG_STRUCTS>& getTZobs_HG() const { return tZobs_HG_; }
101  const std::array<double, SIZE_HG_STRUCTS>& getTZobsErr_HG() const { return tZobsErr_HG_; }
102 
103  const AlignPCLThresholdsHG::threshold_map getThresholdMap() const { return theThresholds_.get()->getThreshold_Map(); }
104 
105  const int binariesAmount() const { return binariesAmount_; }
106 
107  const mpPCLresults getResults() const {
109  }
110 
111  const std::map<std::string, std::array<bool, 6>>& getResultsHG() const { return fractionExceeded_; }
112 
113 private:
114  //========================= PRIVATE ENUMS ====================================
115  //============================================================================
116 
117  enum class PclHLS : int {
118  NotInPCL = -1,
121  TPBHalfBarrelXplus = 2,
125  TPBLadderLayer1 = 6,
126  TPBLadderLayer2 = 7,
127  TPBLadderLayer3 = 8,
128  TPBLadderLayer4 = 9,
129  TPEPanelDisk1 = 10,
130  TPEPanelDisk2 = 11,
131  TPEPanelDisk3 = 12,
132  TPEPanelDiskM1 = 13,
133  TPEPanelDiskM2 = 14,
134  TPEPanelDiskM3 = 15,
135  };
136 
137  //========================= PRIVATE METHODS ==================================
138  //============================================================================
139 
140  void readMillePedeEndFile();
141  void readMillePedeLogFile();
143  PclHLS getHLS(const Alignable*);
145  int getIndexForHG(align::ID id, PclHLS HLS);
146  void initializeIndexHelper();
147 
148  //========================== PRIVATE DATA ====================================
149  //============================================================================
150 
151  // pede labeler plugin
152  const std::shared_ptr<const PedeLabelerBase> pedeLabeler_;
153 
154  // thresholds from DB
155  const std::shared_ptr<const AlignPCLThresholdsHG> theThresholds_;
156 
157  // PixelTopologyMap
158  const std::shared_ptr<const PixelTopologyMap> pixelTopologyMap_;
159 
160  // input directory name
162 
163  // file-names
167 
168  // conversion factors: cm to um & rad to urad
169  static constexpr std::array<double, 6> multiplier_ = {{10000., // X
170  10000., // Y
171  10000., // Z
172  1000000., // tX
173  1000000., // tY
174  1000000.}}; // tZ
175 
176  bool updateDB_{false};
177  bool vetoUpdateDB_{false};
178  const bool isHG_;
179 
180  // stores in a compact format the 4 decisions:
181  // 1st bit: exceeds maximum thresholds
182  // 2nd bit: exceeds cutoffs (significant movement)
183  // 3rd bit: exceeds maximum errors
184  // 4th bit: is below the significance
185  std::bitset<4> updateBits_;
186 
187  // pede binaries available
189 
190  // Fraction threshold booleans for HG alignment
191  std::map<std::string, std::array<bool, 6>> fractionExceeded_;
192 
193  int Nrec_{0};
194  int exitCode_{-1};
196 
197  std::array<double, SIZE_LG_STRUCTS> Xobs_ = std::array<double, SIZE_LG_STRUCTS>();
198  std::array<double, SIZE_LG_STRUCTS> XobsErr_ = std::array<double, SIZE_LG_STRUCTS>();
199  std::array<double, SIZE_LG_STRUCTS> tXobs_ = std::array<double, SIZE_LG_STRUCTS>();
200  std::array<double, SIZE_LG_STRUCTS> tXobsErr_ = std::array<double, SIZE_LG_STRUCTS>();
201 
202  std::array<double, SIZE_LG_STRUCTS> Yobs_ = std::array<double, SIZE_LG_STRUCTS>();
203  std::array<double, SIZE_LG_STRUCTS> YobsErr_ = std::array<double, SIZE_LG_STRUCTS>();
204  std::array<double, SIZE_LG_STRUCTS> tYobs_ = std::array<double, SIZE_LG_STRUCTS>();
205  std::array<double, SIZE_LG_STRUCTS> tYobsErr_ = std::array<double, SIZE_LG_STRUCTS>();
206 
207  std::array<double, SIZE_LG_STRUCTS> Zobs_ = std::array<double, SIZE_LG_STRUCTS>();
208  std::array<double, SIZE_LG_STRUCTS> ZobsErr_ = std::array<double, SIZE_LG_STRUCTS>();
209  std::array<double, SIZE_LG_STRUCTS> tZobs_ = std::array<double, SIZE_LG_STRUCTS>();
210  std::array<double, SIZE_LG_STRUCTS> tZobsErr_ = std::array<double, SIZE_LG_STRUCTS>();
211 
212  std::array<double, SIZE_HG_STRUCTS> Xobs_HG_ = std::array<double, SIZE_HG_STRUCTS>();
213  std::array<double, SIZE_HG_STRUCTS> XobsErr_HG_ = std::array<double, SIZE_HG_STRUCTS>();
214  std::array<double, SIZE_HG_STRUCTS> tXobs_HG_ = std::array<double, SIZE_HG_STRUCTS>();
215  std::array<double, SIZE_HG_STRUCTS> tXobsErr_HG_ = std::array<double, SIZE_HG_STRUCTS>();
216 
217  std::array<double, SIZE_HG_STRUCTS> Yobs_HG_ = std::array<double, SIZE_HG_STRUCTS>();
218  std::array<double, SIZE_HG_STRUCTS> YobsErr_HG_ = std::array<double, SIZE_HG_STRUCTS>();
219  std::array<double, SIZE_HG_STRUCTS> tYobs_HG_ = std::array<double, SIZE_HG_STRUCTS>();
220  std::array<double, SIZE_HG_STRUCTS> tYobsErr_HG_ = std::array<double, SIZE_HG_STRUCTS>();
221 
222  std::array<double, SIZE_HG_STRUCTS> Zobs_HG_ = std::array<double, SIZE_HG_STRUCTS>();
223  std::array<double, SIZE_HG_STRUCTS> ZobsErr_HG_ = std::array<double, SIZE_HG_STRUCTS>();
224  std::array<double, SIZE_HG_STRUCTS> tZobs_HG_ = std::array<double, SIZE_HG_STRUCTS>();
225  std::array<double, SIZE_HG_STRUCTS> tZobsErr_HG_ = std::array<double, SIZE_HG_STRUCTS>();
226 
227  std::unordered_map<PclHLS, std::pair<int, int>> indexHelper;
228 };
229 
230 const std::array<std::string, 8> coord_str = {{"X", "Y", "Z", "theta_X", "theta_Y", "theta_Z", "extra_DOF", "none"}};
231 inline std::ostream& operator<<(std::ostream& os, const AlignPCLThresholdsHG::coordType& c) {
233  return os << "unrecongnized coordinate";
234  return os << coord_str[c];
235 }
236 
237 #endif /* ALIGNMENT_MILLEPEDEALIGNMENTALGORITHM_INTERFACE_MILLEPEDEFILEREADER_H_ */
std::array< double, SIZE_LG_STRUCTS > Zobs_
const std::array< double, SIZE_LG_STRUCTS > & getTZobsErr() const
const int getNRecords()
mpPCLresults(bool isDBUpdated, bool isDBUpdateVetoed, int nRecords, int exitCode, std::string exitMessage, std::bitset< 4 > updateBits)
MillePedeFileReader(const edm::ParameterSet &, const std::shared_ptr< const PedeLabelerBase > &, const std::shared_ptr< const AlignPCLThresholdsHG > &, const std::shared_ptr< const PixelTopologyMap > &)
const std::array< double, SIZE_LG_STRUCTS > & getZobs() const
std::array< double, SIZE_HG_STRUCTS > tXobs_HG_
std::array< double, SIZE_LG_STRUCTS > tYobs_
std::array< double, SIZE_LG_STRUCTS > tZobsErr_
std::map< std::string, AlignPCLThreshold > threshold_map
std::array< double, SIZE_LG_STRUCTS > Yobs_
std::ostream & operator<<(std::ostream &os, const AlignPCLThresholdsHG::coordType &c)
const std::shared_ptr< const AlignPCLThresholdsHG > theThresholds_
std::array< double, SIZE_HG_STRUCTS > XobsErr_HG_
uint32_t ID
Definition: Definitions.h:24
std::bitset< 4 > updateBits_
std::array< double, SIZE_LG_STRUCTS > YobsErr_
std::array< double, SIZE_HG_STRUCTS > YobsErr_HG_
const std::array< double, SIZE_HG_STRUCTS > & getTXobs_HG() const
const std::array< double, SIZE_HG_STRUCTS > & getXobs_HG() const
const std::shared_ptr< const PixelTopologyMap > pixelTopologyMap_
const std::array< double, SIZE_HG_STRUCTS > & getTYobsErr_HG() const
const std::array< double, SIZE_HG_STRUCTS > & getZobsErr_HG() const
const std::array< double, SIZE_HG_STRUCTS > & getZobs_HG() const
const std::array< double, SIZE_LG_STRUCTS > & getXobs() const
const int getExitCode()
const std::array< double, SIZE_HG_STRUCTS > & getXobsErr_HG() const
PclHLS getHLS(const Alignable *)
const int binariesAmount() const
virtual ~MillePedeFileReader()=default
const std::array< double, SIZE_HG_STRUCTS > & getTXobsErr_HG() const
std::array< double, SIZE_HG_STRUCTS > Zobs_HG_
std::array< double, SIZE_LG_STRUCTS > Xobs_
static constexpr std::array< double, 6 > multiplier_
std::array< double, SIZE_HG_STRUCTS > Xobs_HG_
const std::array< double, SIZE_LG_STRUCTS > & getYobsErr() const
std::array< double, SIZE_HG_STRUCTS > tYobs_HG_
const std::string millePedeLogFile_
const std::array< double, SIZE_HG_STRUCTS > & getYobsErr_HG() const
const std::array< double, SIZE_LG_STRUCTS > & getTXobsErr() const
const std::map< std::string, std::array< bool, 6 > > & getResultsHG() const
const std::array< double, SIZE_LG_STRUCTS > & getTYobs() const
const std::array< double, SIZE_HG_STRUCTS > & getTYobs_HG() const
const mpPCLresults getResults() const
const bool belowSignificance()
const std::array< double, SIZE_LG_STRUCTS > & getXobsErr() const
std::array< double, SIZE_LG_STRUCTS > tXobs_
const std::array< double, SIZE_HG_STRUCTS > & getTZobs_HG() const
std::array< double, SIZE_LG_STRUCTS > tYobsErr_
std::array< double, SIZE_HG_STRUCTS > ZobsErr_HG_
const bool exceedsCutoffs()
std::array< double, SIZE_HG_STRUCTS > tZobs_HG_
const std::string getExitMessage()
const std::array< double, SIZE_LG_STRUCTS > & getYobs() const
const AlignPCLThresholdsHG::threshold_map getThresholdMap() const
std::bitset< 4 > m_updateBits
std::string getStringFromHLS(PclHLS HLS)
Log< level::Info, false > LogInfo
const std::array< double, SIZE_LG_STRUCTS > & getTYobsErr() const
const std::string millePedeResFile_
std::string m_exitMessage
std::array< double, SIZE_LG_STRUCTS > tXobsErr_
const std::array< std::string, 8 > coord_str
std::unordered_map< PclHLS, std::pair< int, int > > indexHelper
const std::array< double, SIZE_HG_STRUCTS > & getYobs_HG() const
const bool getDBUpdated()
std::array< double, SIZE_HG_STRUCTS > tZobsErr_HG_
std::array< double, SIZE_LG_STRUCTS > XobsErr_
int getIndexForHG(align::ID id, PclHLS HLS)
const bool exceedsThresholds()
const std::shared_ptr< const PedeLabelerBase > pedeLabeler_
const bool getDBVetoed()
const std::array< double, SIZE_LG_STRUCTS > & getTZobs() const
const std::string millePedeEndFile_
std::array< double, SIZE_HG_STRUCTS > tXobsErr_HG_
std::array< double, SIZE_HG_STRUCTS > Yobs_HG_
std::array< double, SIZE_LG_STRUCTS > tZobs_
const bool exceedsMaxError()
const std::array< double, SIZE_LG_STRUCTS > & getZobsErr() const
std::map< std::string, std::array< bool, 6 > > fractionExceeded_
const std::array< double, SIZE_HG_STRUCTS > & getTZobsErr_HG() const
std::array< double, SIZE_LG_STRUCTS > ZobsErr_
std::array< double, SIZE_HG_STRUCTS > tYobsErr_HG_
const std::array< double, SIZE_LG_STRUCTS > & getTXobs() const