CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
MillePedeFileReader Class Reference

#include <MillePedeFileReader.h>

Public Member Functions

const AlignPCLThresholds::threshold_map getThresholdMap () const
 
const std::array< double, 6 > & getTXobs () const
 
const std::array< double, 6 > & getTXobsErr () const
 
const std::array< double, 6 > & getTYobs () const
 
const std::array< double, 6 > & getTYobsErr () const
 
const std::array< double, 6 > & getTZobs () const
 
const std::array< double, 6 > & getTZobsErr () const
 
const std::array< double, 6 > & getXobs () const
 
const std::array< double, 6 > & getXobsErr () const
 
const std::array< double, 6 > & getYobs () const
 
const std::array< double, 6 > & getYobsErr () const
 
const std::array< double, 6 > & getZobs () const
 
const std::array< double, 6 > & getZobsErr () const
 
 MillePedeFileReader (const edm::ParameterSet &, const std::shared_ptr< const PedeLabelerBase > &, const std::shared_ptr< const AlignPCLThresholds > &)
 
void read ()
 
bool storeAlignments ()
 
virtual ~MillePedeFileReader ()=default
 

Private Types

enum  PclHLS : int {
  PclHLS::NotInPCL = -1, PclHLS::TPBHalfBarrelXplus = 2, PclHLS::TPBHalfBarrelXminus = 3, PclHLS::TPEHalfCylinderXplusZplus = 4,
  PclHLS::TPEHalfCylinderXminusZplus = 5, PclHLS::TPEHalfCylinderXplusZminus = 0, PclHLS::TPEHalfCylinderXminusZminus = 1
}
 

Private Member Functions

PclHLS getHLS (const Alignable *)
 
std::string getStringFromHLS (PclHLS HLS)
 
void readMillePedeLogFile ()
 
void readMillePedeResultFile ()
 

Private Attributes

const std::string millePedeLogFile_
 
const std::string millePedeResFile_
 
int Nrec_ {0}
 
const std::shared_ptr< const PedeLabelerBasepedeLabeler_
 
const std::shared_ptr< const AlignPCLThresholdstheThresholds_
 
std::array< double, 6 > tXobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > tXobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > tYobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > tYobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > tZobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > tZobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
bool updateDB_ {false}
 
bool vetoUpdateDB_ {false}
 
std::array< double, 6 > Xobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > XobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > Yobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > YobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > Zobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > ZobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 

Static Private Attributes

static std::array< double, 6 > multiplier_
 

Detailed Description

Definition at line 16 of file MillePedeFileReader.h.

Member Enumeration Documentation

enum MillePedeFileReader::PclHLS : int
strongprivate
Enumerator
NotInPCL 
TPBHalfBarrelXplus 
TPBHalfBarrelXminus 
TPEHalfCylinderXplusZplus 
TPEHalfCylinderXminusZplus 
TPEHalfCylinderXplusZminus 
TPEHalfCylinderXminusZminus 

Definition at line 51 of file MillePedeFileReader.h.

51  : int { NotInPCL = -1,
52  TPBHalfBarrelXplus = 2,
53  TPBHalfBarrelXminus = 3,
54  TPEHalfCylinderXplusZplus = 4,
55  TPEHalfCylinderXminusZplus = 5,
56  TPEHalfCylinderXplusZminus = 0,
57  TPEHalfCylinderXminusZminus = 1};

Constructor & Destructor Documentation

MillePedeFileReader::MillePedeFileReader ( const edm::ParameterSet config,
const std::shared_ptr< const PedeLabelerBase > &  pedeLabeler,
const std::shared_ptr< const AlignPCLThresholds > &  theThresholds 
)
explicit

Definition at line 20 of file MillePedeFileReader.cc.

References read().

22  :
24  theThresholds_(theThresholds),
25  millePedeLogFile_(config.getParameter<std::string>("millePedeLogFile")),
26  millePedeResFile_(config.getParameter<std::string>("millePedeResFile"))
27 {
28 }
T getParameter(std::string const &) const
const std::shared_ptr< const AlignPCLThresholds > theThresholds_
const std::string millePedeLogFile_
const std::string millePedeResFile_
const std::shared_ptr< const PedeLabelerBase > pedeLabeler_
virtual MillePedeFileReader::~MillePedeFileReader ( )
virtualdefault

Member Function Documentation

MillePedeFileReader::PclHLS MillePedeFileReader::getHLS ( const Alignable alignable)
private

Definition at line 209 of file MillePedeFileReader.cc.

References Alignable::alignableObjectId(), Exception, Alignable::id(), AlCaHLTBitMon_QueryRunRegistry::string, align::TPBHalfBarrel, and align::TPEHalfCylinder.

Referenced by readMillePedeResultFile().

209  {
210  if (!alignable) return PclHLS::NotInPCL;
211 
212  const auto& tns = pedeLabeler_->alignableTracker()->trackerNameSpace();
213 
214  switch (alignable->alignableObjectId()) {
216  switch (tns.tpb().halfBarrelNumber(alignable->id())) {
217  case 1: return PclHLS::TPBHalfBarrelXminus;
218  case 2: return PclHLS::TPBHalfBarrelXplus;
219  default:
220  throw cms::Exception("LogicError")
221  << "@SUB=MillePedeFileReader::getHLS\n"
222  << "Found a pixel half-barrel number that should not exist: "
223  << tns.tpb().halfBarrelNumber(alignable->id());
224  }
226  switch (tns.tpe().endcapNumber(alignable->id())) {
227  case 1:
228  switch (tns.tpe().halfCylinderNumber(alignable->id())) {
230  case 2: return PclHLS::TPEHalfCylinderXplusZminus;
231  default:
232  throw cms::Exception("LogicError")
233  << "@SUB=MillePedeFileReader::getHLS\n"
234  << "Found a pixel half-cylinder number that should not exist: "
235  << tns.tpe().halfCylinderNumber(alignable->id());
236  }
237  case 2:
238  switch (tns.tpe().halfCylinderNumber(alignable->id())) {
239  case 1: return PclHLS::TPEHalfCylinderXminusZplus;
240  case 2: return PclHLS::TPEHalfCylinderXplusZplus;
241  default:
242  throw cms::Exception("LogicError")
243  << "@SUB=MillePedeFileReader::getHLS\n"
244  << "Found a pixel half-cylinder number that should not exist: "
245  << tns.tpe().halfCylinderNumber(alignable->id());
246  }
247  default:
248  throw cms::Exception("LogicError")
249  << "@SUB=MillePedeFileReader::getHLS\n"
250  << "Found a pixel endcap number that should not exist: "
251  << tns.tpe().endcapNumber(alignable->id());
252  }
253  default: return PclHLS::NotInPCL;
254  }
255 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:189
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const std::shared_ptr< const PedeLabelerBase > pedeLabeler_
std::string MillePedeFileReader::getStringFromHLS ( MillePedeFileReader::PclHLS  HLS)
private

Definition at line 258 of file MillePedeFileReader.cc.

References constexpr, Exception, multiplier_, TPBHalfBarrelXminus, TPBHalfBarrelXplus, TPEHalfCylinderXminusZminus, TPEHalfCylinderXminusZplus, TPEHalfCylinderXplusZminus, and TPEHalfCylinderXplusZplus.

258  {
259  switch (HLS)
260  {
261  case PclHLS::TPBHalfBarrelXminus : return "TPBHalfBarrelXminus";
262  case PclHLS::TPBHalfBarrelXplus : return "TPBHalfBarrelXplus";
263  case PclHLS::TPEHalfCylinderXminusZminus : return "TPEHalfCylinderXminusZminus";
264  case PclHLS::TPEHalfCylinderXplusZminus : return "TPEHalfCylinderXplusZminus";
265  case PclHLS::TPEHalfCylinderXminusZplus : return "TPEHalfCylinderXminusZplus";
266  case PclHLS::TPEHalfCylinderXplusZplus : return "TPEHalfCylinderXplusZplus";
267  default:
268  throw cms::Exception("LogicError")
269  << "@SUB=MillePedeFileReader::getStringFromHLS\n"
270  << "Found an alignable structure not possible to map in the default AlignPCLThresholds partitions";
271  }
272 }
const AlignPCLThresholds::threshold_map MillePedeFileReader::getThresholdMap ( ) const
inline

Definition at line 45 of file MillePedeFileReader.h.

References theThresholds_.

45 {return theThresholds_.get()->getThreshold_Map (); }
const std::shared_ptr< const AlignPCLThresholds > theThresholds_
const std::array<double, 6>& MillePedeFileReader::getTXobs ( ) const
inline

Definition at line 32 of file MillePedeFileReader.h.

References tXobs_.

32 { return tXobs_; }
std::array< double, 6 > tXobs_
const std::array<double, 6>& MillePedeFileReader::getTXobsErr ( ) const
inline

Definition at line 33 of file MillePedeFileReader.h.

References tXobsErr_.

33 { return tXobsErr_; }
std::array< double, 6 > tXobsErr_
const std::array<double, 6>& MillePedeFileReader::getTYobs ( ) const
inline

Definition at line 37 of file MillePedeFileReader.h.

References tYobs_.

37 { return tYobs_; }
std::array< double, 6 > tYobs_
const std::array<double, 6>& MillePedeFileReader::getTYobsErr ( ) const
inline

Definition at line 38 of file MillePedeFileReader.h.

References tYobsErr_.

38 { return tYobsErr_; }
std::array< double, 6 > tYobsErr_
const std::array<double, 6>& MillePedeFileReader::getTZobs ( ) const
inline

Definition at line 42 of file MillePedeFileReader.h.

References tZobs_.

42 { return tZobs_; }
std::array< double, 6 > tZobs_
const std::array<double, 6>& MillePedeFileReader::getTZobsErr ( ) const
inline

Definition at line 43 of file MillePedeFileReader.h.

References tZobsErr_.

43 { return tZobsErr_; }
std::array< double, 6 > tZobsErr_
const std::array<double, 6>& MillePedeFileReader::getXobs ( ) const
inline

Definition at line 30 of file MillePedeFileReader.h.

References Xobs_.

30 { return Xobs_; }
std::array< double, 6 > Xobs_
const std::array<double, 6>& MillePedeFileReader::getXobsErr ( ) const
inline

Definition at line 31 of file MillePedeFileReader.h.

References XobsErr_.

31 { return XobsErr_; }
std::array< double, 6 > XobsErr_
const std::array<double, 6>& MillePedeFileReader::getYobs ( ) const
inline

Definition at line 35 of file MillePedeFileReader.h.

References Yobs_.

35 { return Yobs_; }
std::array< double, 6 > Yobs_
const std::array<double, 6>& MillePedeFileReader::getYobsErr ( ) const
inline

Definition at line 36 of file MillePedeFileReader.h.

References YobsErr_.

36 { return YobsErr_; }
std::array< double, 6 > YobsErr_
const std::array<double, 6>& MillePedeFileReader::getZobs ( ) const
inline

Definition at line 40 of file MillePedeFileReader.h.

References Zobs_.

40 { return Zobs_; }
std::array< double, 6 > Zobs_
const std::array<double, 6>& MillePedeFileReader::getZobsErr ( ) const
inline

Definition at line 41 of file MillePedeFileReader.h.

References ZobsErr_.

41 { return ZobsErr_; }
std::array< double, 6 > ZobsErr_
void MillePedeFileReader::read ( )
void MillePedeFileReader::readMillePedeLogFile ( )
private

Definition at line 48 of file MillePedeFileReader.cc.

References geometryCSVtoXML::line, heppy_check::logFile, readMillePedeResultFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by storeAlignments().

49 {
50  std::ifstream logFile;
51  logFile.open(millePedeLogFile_.c_str());
52 
53  if (logFile.is_open()) {
54  edm::LogInfo("MillePedeFileReader") << "Reading millepede log-file";
56 
57  while (getline(logFile, line)) {
58  std::string Nrec_string = "NREC =";
59 
60  if (line.find(Nrec_string) != std::string::npos) {
61  std::istringstream iss(line);
62  std::string trash;
63  iss >> trash >> trash >> Nrec_;
64 
65  if (Nrec_ < theThresholds_->getNrecords() ) {
66  edm::LogInfo("MillePedeFileReader")<<"Number of records used "<<theThresholds_->getNrecords()<<std::endl;
67  updateDB_ = false;
68  }
69  }
70  }
71 
72  } else {
73  edm::LogError("MillePedeFileReader") << "Could not read millepede log-file.";
74 
75  updateDB_ = false;
76  Nrec_ = 0;
77  }
78 }
const std::shared_ptr< const AlignPCLThresholds > theThresholds_
const std::string millePedeLogFile_
void MillePedeFileReader::readMillePedeResultFile ( )
private

Definition at line 81 of file MillePedeFileReader.cc.

References funct::abs(), getHLS(), geometryCSVtoXML::line, AlCaHLTBitMon_QueryRunRegistry::string, AlignPCLThresholds::theta_X, AlignPCLThresholds::theta_Y, AlignPCLThresholds::theta_Z, AlignPCLThresholds::X, AlignPCLThresholds::Y, and AlignPCLThresholds::Z.

Referenced by readMillePedeLogFile().

82 {
83 
84  // cutoffs by coordinate and by alignable
85  std::map<std::string,std::array<float, 6 > > cutoffs_;
86  std::map<std::string,std::array<float, 6 > > significances_;
87  std::map<std::string,std::array<float, 6 > > thresholds_;
88  std::map<std::string,std::array<float, 6 > > errors_;
89 
90  std::vector<std::string> alignables_ = theThresholds_->getAlignableList();
91  for (auto &ali : alignables_){
92  cutoffs_[ali] = theThresholds_->getCut(ali);
93  significances_[ali] = theThresholds_->getSigCut(ali);
94  thresholds_[ali] = theThresholds_->getMaxMoveCut(ali);
95  errors_[ali] = theThresholds_->getMaxErrorCut(ali);
96  }
97 
98  updateDB_ = false;
99  vetoUpdateDB_ = false;
100  std::ifstream resFile;
101  resFile.open(millePedeResFile_.c_str());
102 
103  if (resFile.is_open()) {
104  edm::LogInfo("MillePedeFileReader") << "Reading millepede result-file";
105 
107  getline(resFile, line); // drop first line
108 
109  while (getline(resFile, line)) {
110  std::istringstream iss(line);
111 
112  std::vector<std::string> tokens;
113  std::string token;
114  while (iss >> token) {
115  tokens.push_back(token);
116  }
117 
118  if (tokens.size() > 4 /*3*/) {
119 
120  auto alignableLabel = std::stoul(tokens[0]);
121  auto alignableIndex = alignableLabel % 10 - 1;
122  const auto alignable = pedeLabeler_->alignableFromLabel(alignableLabel);
123 
124  double ObsMove = std::stof(tokens[3]) * multiplier_[alignableIndex];
125  double ObsErr = std::stof(tokens[4]) * multiplier_[alignableIndex];
126 
127  auto det = getHLS(alignable);
128  int detIndex = static_cast<int>(det);
129  auto coord = static_cast<AlignPCLThresholds::coordType>(alignableIndex);
130  std::string detLabel = getStringFromHLS(det);
131 
132  if (det != PclHLS::NotInPCL) {
133  switch (coord) {
135  Xobs_[detIndex] = ObsMove;
136  XobsErr_[detIndex] = ObsErr;
137  break;
139  Yobs_[detIndex] = ObsMove;
140  YobsErr_[detIndex] = ObsErr;
141  break;
143  Zobs_[detIndex] = ObsMove;
144  ZobsErr_[detIndex] = ObsErr;
145  break;
147  tXobs_[detIndex] = ObsMove;
148  tXobsErr_[detIndex] = ObsErr;
149  break;
151  tYobs_[detIndex] = ObsMove;
152  tYobsErr_[detIndex] = ObsErr;
153  break;
155  tZobs_[detIndex] = ObsMove;
156  tZobsErr_[detIndex] = ObsErr;
157  break;
158  default:
159  edm::LogError("MillePedeFileReader") << "Currently not able to handle DOF " << coord
160  << std::endl;
161  break;
162  }
163  } else {
164  continue;
165  }
166 
167  edm::LogVerbatim("MillePedeFileReader")<<" alignableLabel: "<< alignableLabel <<" with alignableIndex "<<alignableIndex <<" detIndex"<< detIndex <<"\n"
168  <<" i.e. detLabel: "<< detLabel <<" ("<< coord <<")\n"
169  <<" has movement: "<< ObsMove <<" +/- "<< ObsErr <<"\n"
170  <<" cutoff (cutoffs_["<< detLabel <<"]["<< coord <<"]): "<< cutoffs_[detLabel][alignableIndex] <<"\n"
171  <<" significance (significances_["<< detLabel <<"]["<< coord <<"]): "<< significances_[detLabel][alignableIndex] <<"\n"
172  <<" error thresolds (errors_["<< detLabel <<"]["<< coord <<"]): "<< errors_[detLabel][alignableIndex] <<"\n"
173  <<" max movement (thresholds_["<< detLabel <<"]["<< coord <<"]): "<< thresholds_[detLabel][alignableIndex] <<"\n"
174  <<"============="<< std::endl;
175 
176  if (std::abs(ObsMove) > thresholds_[detLabel][alignableIndex]) {
177  edm::LogWarning("MillePedeFileReader")<<"Aborting payload creation."
178  <<" Exceeding maximum thresholds for movement: "<<std::abs(ObsMove)<<" for"<< detLabel <<"("<<coord<<")" ;
179  vetoUpdateDB_ = true;
180  continue;
181 
182  } else if (std::abs(ObsMove) > cutoffs_[detLabel][alignableIndex]) {
183 
184  if (std::abs(ObsErr) > errors_[detLabel][alignableIndex]) {
185  edm::LogWarning("MillePedeFileReader")<<"Aborting payload creation."
186  <<" Exceeding maximum thresholds for error: "<<std::abs(ObsErr)<<" for"<< detLabel <<"("<<coord<<")" ;
187  vetoUpdateDB_ = true;
188  continue;
189  } else {
190  if (std::abs(ObsMove/ObsErr) < significances_[detLabel][alignableIndex]) {
191  continue;
192  }
193  }
194  updateDB_ = true;
195  edm::LogInfo("MillePedeFileReader")<<"This correction: "<<ObsMove<<"+/-" <<ObsErr<<" for "<< detLabel <<"("<<coord<<") will trigger a new Tracker Alignment payload!";
196  }
197  }
198  }
199  } else {
200  edm::LogError("MillePedeFileReader") << "Could not read millepede result-file.";
201 
202  updateDB_ = false;
203  Nrec_ = 0;
204  }
205 }
std::array< double, 6 > tYobs_
std::array< double, 6 > tXobs_
std::array< double, 6 > YobsErr_
PclHLS getHLS(const Alignable *)
const std::shared_ptr< const AlignPCLThresholds > theThresholds_
std::array< double, 6 > tZobs_
std::array< double, 6 > tXobsErr_
std::array< double, 6 > tYobsErr_
std::array< double, 6 > Yobs_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::array< double, 6 > tZobsErr_
std::string getStringFromHLS(PclHLS HLS)
const std::string millePedeResFile_
std::array< double, 6 > Zobs_
std::array< double, 6 > Xobs_
const std::shared_ptr< const PedeLabelerBase > pedeLabeler_
std::array< double, 6 > ZobsErr_
std::array< double, 6 > XobsErr_
static std::array< double, 6 > multiplier_
bool MillePedeFileReader::storeAlignments ( )

Definition at line 37 of file MillePedeFileReader.cc.

References readMillePedeLogFile().

Referenced by read(), and MillePedeAlignmentAlgorithm::storeAlignments().

37  {
38  return (updateDB_&&!vetoUpdateDB_);
39 }

Member Data Documentation

const std::string MillePedeFileReader::millePedeLogFile_
private

Definition at line 77 of file MillePedeFileReader.h.

const std::string MillePedeFileReader::millePedeResFile_
private

Definition at line 78 of file MillePedeFileReader.h.

std::array< double, 6 > MillePedeFileReader::multiplier_
staticprivate
Initial value:
= {{ 10000.,
10000.,
10000.,
1000000.,
1000000.,
1000000. }}

Definition at line 81 of file MillePedeFileReader.h.

Referenced by getStringFromHLS().

int MillePedeFileReader::Nrec_ {0}
private

Definition at line 90 of file MillePedeFileReader.h.

const std::shared_ptr<const PedeLabelerBase> MillePedeFileReader::pedeLabeler_
private

Definition at line 71 of file MillePedeFileReader.h.

const std::shared_ptr<const AlignPCLThresholds> MillePedeFileReader::theThresholds_
private

Definition at line 74 of file MillePedeFileReader.h.

Referenced by getThresholdMap().

std::array<double, 6> MillePedeFileReader::tXobs_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 94 of file MillePedeFileReader.h.

Referenced by getTXobs().

std::array<double, 6> MillePedeFileReader::tXobsErr_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 95 of file MillePedeFileReader.h.

Referenced by getTXobsErr().

std::array<double, 6> MillePedeFileReader::tYobs_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 99 of file MillePedeFileReader.h.

Referenced by getTYobs().

std::array<double, 6> MillePedeFileReader::tYobsErr_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 100 of file MillePedeFileReader.h.

Referenced by getTYobsErr().

std::array<double, 6> MillePedeFileReader::tZobs_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 104 of file MillePedeFileReader.h.

Referenced by getTZobs().

std::array<double, 6> MillePedeFileReader::tZobsErr_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 105 of file MillePedeFileReader.h.

Referenced by getTZobsErr().

bool MillePedeFileReader::updateDB_ {false}
private

Definition at line 88 of file MillePedeFileReader.h.

bool MillePedeFileReader::vetoUpdateDB_ {false}
private

Definition at line 89 of file MillePedeFileReader.h.

std::array<double, 6> MillePedeFileReader::Xobs_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 92 of file MillePedeFileReader.h.

Referenced by getXobs().

std::array<double, 6> MillePedeFileReader::XobsErr_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 93 of file MillePedeFileReader.h.

Referenced by getXobsErr().

std::array<double, 6> MillePedeFileReader::Yobs_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 97 of file MillePedeFileReader.h.

Referenced by getYobs().

std::array<double, 6> MillePedeFileReader::YobsErr_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 98 of file MillePedeFileReader.h.

Referenced by getYobsErr().

std::array<double, 6> MillePedeFileReader::Zobs_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 102 of file MillePedeFileReader.h.

Referenced by getZobs().

std::array<double, 6> MillePedeFileReader::ZobsErr_ = {{0.,0.,0.,0.,0.,0.}}
private

Definition at line 103 of file MillePedeFileReader.h.

Referenced by getZobsErr().