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}
 
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 208 of file MillePedeFileReader.cc.

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

Referenced by readMillePedeResultFile().

208  {
209  if (!alignable) return PclHLS::NotInPCL;
210 
211  const auto& tns = pedeLabeler_->alignableTracker()->trackerNameSpace();
212 
213  switch (alignable->alignableObjectId()) {
215  switch (tns.tpb().halfBarrelNumber(alignable->id())) {
216  case 1: return PclHLS::TPBHalfBarrelXminus;
217  case 2: return PclHLS::TPBHalfBarrelXplus;
218  default:
219  throw cms::Exception("LogicError")
220  << "@SUB=MillePedeFileReader::getHLS\n"
221  << "Found a pixel half-barrel number that should not exist: "
222  << tns.tpb().halfBarrelNumber(alignable->id());
223  }
225  switch (tns.tpe().endcapNumber(alignable->id())) {
226  case 1:
227  switch (tns.tpe().halfCylinderNumber(alignable->id())) {
229  case 2: return PclHLS::TPEHalfCylinderXplusZminus;
230  default:
231  throw cms::Exception("LogicError")
232  << "@SUB=MillePedeFileReader::getHLS\n"
233  << "Found a pixel half-cylinder number that should not exist: "
234  << tns.tpe().halfCylinderNumber(alignable->id());
235  }
236  case 2:
237  switch (tns.tpe().halfCylinderNumber(alignable->id())) {
238  case 1: return PclHLS::TPEHalfCylinderXminusZplus;
239  case 2: return PclHLS::TPEHalfCylinderXplusZplus;
240  default:
241  throw cms::Exception("LogicError")
242  << "@SUB=MillePedeFileReader::getHLS\n"
243  << "Found a pixel half-cylinder number that should not exist: "
244  << tns.tpe().halfCylinderNumber(alignable->id());
245  }
246  default:
247  throw cms::Exception("LogicError")
248  << "@SUB=MillePedeFileReader::getHLS\n"
249  << "Found a pixel endcap number that should not exist: "
250  << tns.tpe().endcapNumber(alignable->id());
251  }
252  default: return PclHLS::NotInPCL;
253  }
254 }
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 257 of file MillePedeFileReader.cc.

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

257  {
258  switch (HLS)
259  {
260  case PclHLS::TPBHalfBarrelXminus : return "TPBHalfBarrelXminus";
261  case PclHLS::TPBHalfBarrelXplus : return "TPBHalfBarrelXplus";
262  case PclHLS::TPEHalfCylinderXminusZminus : return "TPEHalfCylinderXminusZminus";
263  case PclHLS::TPEHalfCylinderXplusZminus : return "TPEHalfCylinderXplusZminus";
264  case PclHLS::TPEHalfCylinderXminusZplus : return "TPEHalfCylinderXminusZplus";
265  case PclHLS::TPEHalfCylinderXplusZplus : return "TPEHalfCylinderXplusZplus";
266  default:
267  throw cms::Exception("LogicError")
268  << "@SUB=MillePedeFileReader::getStringFromHLS\n"
269  << "Found an alignable structure not possible to map in the default AlignPCLThresholds partitions";
270  }
271 }
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  std::ifstream resFile;
100  resFile.open(millePedeResFile_.c_str());
101 
102  if (resFile.is_open()) {
103  edm::LogInfo("MillePedeFileReader") << "Reading millepede result-file";
104 
106  getline(resFile, line); // drop first line
107 
108  while (getline(resFile, line)) {
109  std::istringstream iss(line);
110 
111  std::vector<std::string> tokens;
112  std::string token;
113  while (iss >> token) {
114  tokens.push_back(token);
115  }
116 
117  if (tokens.size() > 4 /*3*/) {
118 
119  auto alignableLabel = std::stoul(tokens[0]);
120  auto alignableIndex = alignableLabel % 10 - 1;
121  const auto alignable = pedeLabeler_->alignableFromLabel(alignableLabel);
122 
123  double ObsMove = std::stof(tokens[3]) * multiplier_[alignableIndex];
124  double ObsErr = std::stof(tokens[4]) * multiplier_[alignableIndex];
125 
126  auto det = getHLS(alignable);
127  int detIndex = static_cast<int>(det);
128  auto coord = static_cast<AlignPCLThresholds::coordType>(alignableIndex);
129  std::string detLabel = getStringFromHLS(det);
130 
131  if (det != PclHLS::NotInPCL) {
132  switch (coord) {
134  Xobs_[detIndex] = ObsMove;
135  XobsErr_[detIndex] = ObsErr;
136  break;
138  Yobs_[detIndex] = ObsMove;
139  YobsErr_[detIndex] = ObsErr;
140  break;
142  Zobs_[detIndex] = ObsMove;
143  ZobsErr_[detIndex] = ObsErr;
144  break;
146  tXobs_[detIndex] = ObsMove;
147  tXobsErr_[detIndex] = ObsErr;
148  break;
150  tYobs_[detIndex] = ObsMove;
151  tYobsErr_[detIndex] = ObsErr;
152  break;
154  tZobs_[detIndex] = ObsMove;
155  tZobsErr_[detIndex] = ObsErr;
156  break;
157  default:
158  edm::LogError("MillePedeFileReader") << "Currently not able to handle DOF " << coord
159  << std::endl;
160  break;
161  }
162  } else {
163  continue;
164  }
165 
166  edm::LogVerbatim("MillePedeFileReader")<<" alignableLabel: "<< alignableLabel <<" with alignableIndex "<<alignableIndex <<" detIndex"<< detIndex <<"\n"
167  <<" i.e. detLabel: "<< detLabel <<" ("<< coord <<")\n"
168  <<" has movement: "<< ObsMove <<" +/- "<< ObsErr <<"\n"
169  <<" cutoff (cutoffs_["<< detLabel <<"]["<< coord <<"]): "<< cutoffs_[detLabel][alignableIndex] <<"\n"
170  <<" significance (significances_["<< detLabel <<"]["<< coord <<"]): "<< significances_[detLabel][alignableIndex] <<"\n"
171  <<" error thresolds (errors_["<< detLabel <<"]["<< coord <<"]): "<< errors_[detLabel][alignableIndex] <<"\n"
172  <<" max movement (thresholds_["<< detLabel <<"]["<< coord <<"]): "<< thresholds_[detLabel][alignableIndex] <<"\n"
173  <<"============="<< std::endl;
174 
175  if (std::abs(ObsMove) > thresholds_[detLabel][alignableIndex]) {
176  edm::LogWarning("MillePedeFileReader")<<"Aborting payload creation."
177  <<" Exceeding maximum thresholds for movement: "<<std::abs(ObsMove)<<" for"<< detLabel <<"("<<coord<<")" ;
178  updateDB_ = false;
179  break;
180 
181  } else if (std::abs(ObsMove) > cutoffs_[detLabel][alignableIndex]) {
182 
183  if (std::abs(ObsErr) > errors_[detLabel][alignableIndex]) {
184  edm::LogWarning("MillePedeFileReader")<<"Aborting payload creation."
185  <<" Exceeding maximum thresholds for error: "<<std::abs(ObsErr)<<" for"<< detLabel <<"("<<coord<<")" ;
186  updateDB_ = false;
187  break;
188  } else {
189  if (std::abs(ObsMove/ObsErr) < significances_[detLabel][alignableIndex]) {
190  continue;
191  }
192  }
193  updateDB_ = true;
194  edm::LogInfo("MillePedeFileReader")<<"This correction: "<<ObsMove<<"+/-" <<ObsErr<<" for "<< detLabel <<"("<<coord<<") will trigger a new Tracker Alignment payload!";
195  }
196  }
197  }
198  } else {
199  edm::LogError("MillePedeFileReader") << "Could not read millepede result-file.";
200 
201  updateDB_ = false;
202  Nrec_ = 0;
203  }
204 }
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_;
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 89 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 93 of file MillePedeFileReader.h.

Referenced by getTXobs().

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

Definition at line 94 of file MillePedeFileReader.h.

Referenced by getTXobsErr().

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

Definition at line 98 of file MillePedeFileReader.h.

Referenced by getTYobs().

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

Definition at line 99 of file MillePedeFileReader.h.

Referenced by getTYobsErr().

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

Definition at line 103 of file MillePedeFileReader.h.

Referenced by getTZobs().

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

Definition at line 104 of file MillePedeFileReader.h.

Referenced by getTZobsErr().

bool MillePedeFileReader::updateDB_ {false}
private

Definition at line 88 of file MillePedeFileReader.h.

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

Definition at line 91 of file MillePedeFileReader.h.

Referenced by getXobs().

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

Definition at line 92 of file MillePedeFileReader.h.

Referenced by getXobsErr().

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

Definition at line 96 of file MillePedeFileReader.h.

Referenced by getYobs().

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

Definition at line 97 of file MillePedeFileReader.h.

Referenced by getYobsErr().

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

Definition at line 101 of file MillePedeFileReader.h.

Referenced by getZobs().

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

Definition at line 102 of file MillePedeFileReader.h.

Referenced by getZobsErr().