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