CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 ***/
16 
17 struct mpPCLresults {
18 private:
24  std::bitset<4> m_updateBits;
25 
26 public:
27  mpPCLresults(bool isDBUpdated,
28  bool isDBUpdateVetoed,
29  int nRecords,
30  int exitCode,
31  std::string exitMessage,
32  std::bitset<4> updateBits)
33  : m_isDBUpdated(isDBUpdated),
34  m_isDBUpdateVetoed(isDBUpdateVetoed),
35  m_nRecords(nRecords),
36  m_exitCode(exitCode),
37  m_exitMessage(exitMessage),
38  m_updateBits(updateBits) {}
39 
40  const bool getDBUpdated() { return m_isDBUpdated; }
41  const bool getDBVetoed() { return m_isDBUpdateVetoed; }
42  const bool exceedsThresholds() { return m_updateBits.test(0); }
43  const bool exceedsCutoffs() { return m_updateBits.test(1); }
44  const bool exceedsMaxError() { return m_updateBits.test(2); }
45  const bool belowSignificance() { return m_updateBits.test(3); }
46  const int getNRecords() { return m_nRecords; }
47  const int getExitCode() { return m_exitCode; }
49 
50  void print() {
51  edm::LogInfo("MillePedeFileReader") << " is DB updated: " << m_isDBUpdated
52  << " is DB update vetoed: " << m_isDBUpdateVetoed << " nRecords: " << m_nRecords
53  << " exitCode: " << m_exitCode << " (" << m_exitMessage << ")" << std::endl;
54  }
55 };
56 
58  //========================== PUBLIC METHODS ==================================
59 public: //====================================================================
60  explicit MillePedeFileReader(const edm::ParameterSet&,
61  const std::shared_ptr<const PedeLabelerBase>&,
62  const std::shared_ptr<const AlignPCLThresholds>&);
63 
64  virtual ~MillePedeFileReader() = default;
65 
66  void read();
67  bool storeAlignments();
68 
69  const std::array<double, 6>& getXobs() const { return Xobs_; }
70  const std::array<double, 6>& getXobsErr() const { return XobsErr_; }
71  const std::array<double, 6>& getTXobs() const { return tXobs_; }
72  const std::array<double, 6>& getTXobsErr() const { return tXobsErr_; }
73 
74  const std::array<double, 6>& getYobs() const { return Yobs_; }
75  const std::array<double, 6>& getYobsErr() const { return YobsErr_; }
76  const std::array<double, 6>& getTYobs() const { return tYobs_; }
77  const std::array<double, 6>& getTYobsErr() const { return tYobsErr_; }
78 
79  const std::array<double, 6>& getZobs() const { return Zobs_; }
80  const std::array<double, 6>& getZobsErr() const { return ZobsErr_; }
81  const std::array<double, 6>& getTZobs() const { return tZobs_; }
82  const std::array<double, 6>& getTZobsErr() const { return tZobsErr_; }
83 
84  const AlignPCLThresholds::threshold_map getThresholdMap() const { return theThresholds_.get()->getThreshold_Map(); }
85 
86  const int binariesAmount() const { return binariesAmount_; }
87 
88  const mpPCLresults getResults() const {
90  }
91 
92 private:
93  //========================= PRIVATE ENUMS ====================================
94  //============================================================================
95 
96  enum class PclHLS : int {
97  NotInPCL = -1,
104  };
105 
106  //========================= PRIVATE METHODS ==================================
107  //============================================================================
108 
109  void readMillePedeEndFile();
110  void readMillePedeLogFile();
112  PclHLS getHLS(const Alignable*);
114 
115  //========================== PRIVATE DATA ====================================
116  //============================================================================
117 
118  // pede labeler plugin
119  const std::shared_ptr<const PedeLabelerBase> pedeLabeler_;
120 
121  // thresholds from DB
122  const std::shared_ptr<const AlignPCLThresholds> theThresholds_;
123 
124  // file-names
128 
129  // conversion factors: cm to um & rad to urad
130  static constexpr std::array<double, 6> multiplier_ = {{10000., // X
131  10000., // Y
132  10000., // Z
133  1000000., // tX
134  1000000., // tY
135  1000000.}}; // tZ
136 
137  bool updateDB_{false};
138  bool vetoUpdateDB_{false};
139 
140  // stores in a compact format the 4 decisions:
141  // 1st bit: exceeds maximum thresholds
142  // 2nd bit: exceeds cutoffs (significant movement)
143  // 3rd bit: exceeds maximum errors
144  // 4th bit: is below the significance
145  std::bitset<4> updateBits_;
146 
147  // pede binaries available
149 
150  int Nrec_{0};
151  int exitCode_{-1};
153 
154  std::array<double, 6> Xobs_ = {{0., 0., 0., 0., 0., 0.}};
155  std::array<double, 6> XobsErr_ = {{0., 0., 0., 0., 0., 0.}};
156  std::array<double, 6> tXobs_ = {{0., 0., 0., 0., 0., 0.}};
157  std::array<double, 6> tXobsErr_ = {{0., 0., 0., 0., 0., 0.}};
158 
159  std::array<double, 6> Yobs_ = {{0., 0., 0., 0., 0., 0.}};
160  std::array<double, 6> YobsErr_ = {{0., 0., 0., 0., 0., 0.}};
161  std::array<double, 6> tYobs_ = {{0., 0., 0., 0., 0., 0.}};
162  std::array<double, 6> tYobsErr_ = {{0., 0., 0., 0., 0., 0.}};
163 
164  std::array<double, 6> Zobs_ = {{0., 0., 0., 0., 0., 0.}};
165  std::array<double, 6> ZobsErr_ = {{0., 0., 0., 0., 0., 0.}};
166  std::array<double, 6> tZobs_ = {{0., 0., 0., 0., 0., 0.}};
167  std::array<double, 6> tZobsErr_ = {{0., 0., 0., 0., 0., 0.}};
168 };
169 
170 const std::array<std::string, 8> coord_str = {{"X", "Y", "Z", "theta_X", "theta_Y", "theta_Z", "extra_DOF", "none"}};
171 inline std::ostream& operator<<(std::ostream& os, const AlignPCLThresholds::coordType& c) {
173  return os << "unrecongnized coordinate";
174  return os << coord_str[c];
175 }
176 
177 #endif /* ALIGNMENT_MILLEPEDEALIGNMENTALGORITHM_INTERFACE_MILLEPEDEFILEREADER_H_ */
std::array< double, 6 > tYobs_
std::array< double, 6 > tXobs_
const std::array< double, 6 > & getTYobs() const
const edm::EventSetup & c
const int getNRecords()
mpPCLresults(bool isDBUpdated, bool isDBUpdateVetoed, int nRecords, int exitCode, std::string exitMessage, std::bitset< 4 > updateBits)
std::map< std::string, AlignPCLThreshold > threshold_map
const std::array< double, 6 > & getTZobsErr() const
std::bitset< 4 > updateBits_
std::array< double, 6 > YobsErr_
const int getExitCode()
PclHLS getHLS(const Alignable *)
virtual ~MillePedeFileReader()=default
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
const std::array< double, 6 > & getZobs() const
const std::array< double, 6 > & getTXobs() const
static constexpr std::array< double, 6 > multiplier_
const std::shared_ptr< const AlignPCLThresholds > theThresholds_
std::array< double, 6 > tZobs_
const std::string millePedeLogFile_
std::array< double, 6 > tXobsErr_
const std::array< double, 6 > & getTYobsErr() const
const bool belowSignificance()
std::array< double, 6 > tYobsErr_
std::array< double, 6 > Yobs_
const bool exceedsCutoffs()
MillePedeFileReader(const edm::ParameterSet &, const std::shared_ptr< const PedeLabelerBase > &, const std::shared_ptr< const AlignPCLThresholds > &)
std::array< double, 6 > tZobsErr_
const std::string getExitMessage()
const std::array< double, 6 > & getYobs() const
const std::array< double, 6 > & getZobsErr() const
const std::array< double, 6 > & getTXobsErr() const
const std::array< double, 6 > & getXobsErr() const
std::bitset< 4 > m_updateBits
std::string getStringFromHLS(PclHLS HLS)
Log< level::Info, false > LogInfo
const AlignPCLThresholds::threshold_map getThresholdMap() const
const std::string millePedeResFile_
std::string m_exitMessage
const std::array< std::string, 8 > coord_str
std::array< double, 6 > Zobs_
const bool getDBUpdated()
std::array< double, 6 > Xobs_
const bool exceedsThresholds()
const std::shared_ptr< const PedeLabelerBase > pedeLabeler_
const mpPCLresults getResults() const
const bool getDBVetoed()
std::array< double, 6 > ZobsErr_
const std::string millePedeEndFile_
const int binariesAmount() const
const std::array< double, 6 > & getXobs() const
const std::array< double, 6 > & getYobsErr() const
const bool exceedsMaxError()
const std::array< double, 6 > & getTZobs() const
std::array< double, 6 > XobsErr_