CMS 3D CMS Logo

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