CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 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 > &)
 
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 *)
 
void readMillePedeLogFile ()
 
void readMillePedeResultFile ()
 

Private Attributes

const std::array< double, 6 > cutoffs_
 
const double maxErrorCut_
 
const double maxMoveCut_
 
const std::string millePedeLogFile_
 
const std::string millePedeResFile_
 
int Nrec_ {0}
 
const std::shared_ptr< const
PedeLabelerBase
pedeLabeler_
 
const double sigCut_
 
const double tXcut_
 
std::array< double, 6 > tXobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > tXobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
const double tYcut_
 
std::array< double, 6 > tYobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > tYobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
const double tZcut_
 
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}
 
const double Xcut_
 
std::array< double, 6 > Xobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > XobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
const double Ycut_
 
std::array< double, 6 > Yobs_ = {{0.,0.,0.,0.,0.,0.}}
 
std::array< double, 6 > YobsErr_ = {{0.,0.,0.,0.,0.,0.}}
 
const double Zcut_
 
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 15 of file MillePedeFileReader.h.

Member Enumeration Documentation

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

Definition at line 46 of file MillePedeFileReader.h.

46  : int { NotInPCL = -1,
47  TPBHalfBarrelXplus = 2,
48  TPBHalfBarrelXminus = 3,
49  TPEHalfCylinderXplusZplus = 4,
50  TPEHalfCylinderXminusZplus = 5,
51  TPEHalfCylinderXplusZminus = 0,
52  TPEHalfCylinderXminusZminus = 1};

Constructor & Destructor Documentation

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

Definition at line 20 of file MillePedeFileReader.cc.

21  :
22  pedeLabeler_(pedeLabeler),
23  millePedeLogFile_(config.getParameter<std::string>("millePedeLogFile")),
24  millePedeResFile_(config.getParameter<std::string>("millePedeResFile")),
25 
26  sigCut_ (config.getParameter<double>("sigCut")),
27  Xcut_ (config.getParameter<double>("Xcut")),
28  tXcut_ (config.getParameter<double>("tXcut")),
29  Ycut_ (config.getParameter<double>("Ycut")),
30  tYcut_ (config.getParameter<double>("tYcut")),
31  Zcut_ (config.getParameter<double>("Zcut")),
32  tZcut_ (config.getParameter<double>("tZcut")),
33  maxMoveCut_ (config.getParameter<double>("maxMoveCut")),
34  maxErrorCut_(config.getParameter<double>("maxErrorCut"))
35 {
36 }
T getParameter(std::string const &) const
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 179 of file MillePedeFileReader.cc.

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

179  {
180  if (!alignable) return PclHLS::NotInPCL;
181 
182  const auto& tns = pedeLabeler_->alignableTracker()->trackerNameSpace();
183 
184  switch (alignable->alignableObjectId()) {
186  switch (tns.tpb().halfBarrelNumber(alignable->id())) {
187  case 1: return PclHLS::TPBHalfBarrelXminus;
188  case 2: return PclHLS::TPBHalfBarrelXplus;
189  default:
190  throw cms::Exception("LogicError")
191  << "@SUB=MillePedeFileReader::getHLS\n"
192  << "Found a pixel half-barrel number that should not exist: "
193  << tns.tpb().halfBarrelNumber(alignable->id());
194  }
196  switch (tns.tpe().endcapNumber(alignable->id())) {
197  case 1:
198  switch (tns.tpe().halfCylinderNumber(alignable->id())) {
200  case 2: return PclHLS::TPEHalfCylinderXplusZminus;
201  default:
202  throw cms::Exception("LogicError")
203  << "@SUB=MillePedeFileReader::getHLS\n"
204  << "Found a pixel half-cylinder number that should not exist: "
205  << tns.tpe().halfCylinderNumber(alignable->id());
206  }
207  case 2:
208  switch (tns.tpe().halfCylinderNumber(alignable->id())) {
209  case 1: return PclHLS::TPEHalfCylinderXminusZplus;
210  case 2: return PclHLS::TPEHalfCylinderXplusZplus;
211  default:
212  throw cms::Exception("LogicError")
213  << "@SUB=MillePedeFileReader::getHLS\n"
214  << "Found a pixel half-cylinder number that should not exist: "
215  << tns.tpe().halfCylinderNumber(alignable->id());
216  }
217  default:
218  throw cms::Exception("LogicError")
219  << "@SUB=MillePedeFileReader::getHLS\n"
220  << "Found a pixel endcap number that should not exist: "
221  << tns.tpe().endcapNumber(alignable->id());
222  }
223  default: return PclHLS::NotInPCL;
224  }
225 }
align::ID id() const
Return the ID of Alignable, i.e. DetId of &#39;first&#39; component GeomDet(Unit).
Definition: Alignable.h:185
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
const std::shared_ptr< const PedeLabelerBase > pedeLabeler_
const std::array<double, 6>& MillePedeFileReader::getTXobs ( ) const
inline

Definition at line 29 of file MillePedeFileReader.h.

References tXobs_.

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

Definition at line 30 of file MillePedeFileReader.h.

References tXobsErr_.

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

Definition at line 34 of file MillePedeFileReader.h.

References tYobs_.

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

Definition at line 35 of file MillePedeFileReader.h.

References tYobsErr_.

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

Definition at line 39 of file MillePedeFileReader.h.

References tZobs_.

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

Definition at line 40 of file MillePedeFileReader.h.

References tZobsErr_.

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

Definition at line 27 of file MillePedeFileReader.h.

References Xobs_.

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

Definition at line 28 of file MillePedeFileReader.h.

References XobsErr_.

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

Definition at line 32 of file MillePedeFileReader.h.

References Yobs_.

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

Definition at line 33 of file MillePedeFileReader.h.

References YobsErr_.

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

Definition at line 37 of file MillePedeFileReader.h.

References Zobs_.

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

Definition at line 38 of file MillePedeFileReader.h.

References ZobsErr_.

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

Definition at line 56 of file MillePedeFileReader.cc.

References geometryCSVtoXML::line, heppy_check::logFile, and AlCaHLTBitMon_QueryRunRegistry::string.

57 {
58  std::ifstream logFile;
59  logFile.open(millePedeLogFile_.c_str());
60 
61  if (logFile.is_open()) {
62  edm::LogInfo("MillePedeFileReader") << "Reading millepede log-file";
64 
65  while (getline(logFile, line)) {
66  std::string Nrec_string = "NREC =";
67 
68  if (line.find(Nrec_string) != std::string::npos) {
69  std::istringstream iss(line);
70  std::string trash;
71  iss >> trash >> trash >> Nrec_;
72 
73  if (Nrec_ < 25000) {
74  updateDB_ = false;
75  }
76  }
77  }
78 
79  } else {
80  edm::LogError("MillePedeFileReader") << "Could not read millepede log-file.";
81 
82  updateDB_ = false;
83  Nrec_ = 0;
84  }
85 }
const std::string millePedeLogFile_
tuple logFile
Definition: heppy_check.py:39
void MillePedeFileReader::readMillePedeResultFile ( )
private

Definition at line 88 of file MillePedeFileReader.cc.

References funct::abs(), geometryCSVtoXML::line, AlCaHLTBitMon_QueryRunRegistry::string, and unpackBuffers-CaloStage2::token.

89 {
90  updateDB_ = false;
91  std::ifstream resFile;
92  resFile.open(millePedeResFile_.c_str());
93 
94  if (resFile.is_open()) {
95  edm::LogInfo("MillePedeFileReader") << "Reading millepede result-file";
96 
98  getline(resFile, line); // drop first line
99 
100  while (getline(resFile, line)) {
101  std::istringstream iss(line);
102 
103  std::vector<std::string> tokens;
105  while (iss >> token) {
106  tokens.push_back(token);
107  }
108 
109  if (tokens.size() > 4 /*3*/) {
110 
111  auto alignableLabel = std::stoul(tokens[0]);
112  auto alignableIndex = alignableLabel % 10 - 1;
113  const auto alignable = pedeLabeler_->alignableFromLabel(alignableLabel);
114 
115  double ObsMove = std::stof(tokens[3]) * multiplier_[alignableIndex];
116  double ObsErr = std::stof(tokens[4]) * multiplier_[alignableIndex];
117 
118  auto det = getHLS(alignable);
119 
120  if (det != PclHLS::NotInPCL) {
121  switch (alignableIndex) {
122  case 0:
123  Xobs_[static_cast<int>(det)] = ObsMove;
124  XobsErr_[static_cast<int>(det)] = ObsErr;
125  break;
126  case 1:
127  Yobs_[static_cast<int>(det)] = ObsMove;
128  YobsErr_[static_cast<int>(det)] = ObsErr;
129  break;
130  case 2:
131  Zobs_[static_cast<int>(det)] = ObsMove;
132  ZobsErr_[static_cast<int>(det)] = ObsErr;
133  break;
134  case 3:
135  tXobs_[static_cast<int>(det)] = ObsMove;
136  tXobsErr_[static_cast<int>(det)] = ObsErr;
137  break;
138  case 4:
139  tYobs_[static_cast<int>(det)] = ObsMove;
140  tYobsErr_[static_cast<int>(det)] = ObsErr;
141  break;
142  case 5:
143  tZobs_[static_cast<int>(det)] = ObsMove;
144  tZobsErr_[static_cast<int>(det)] = ObsErr;
145  break;
146  }
147  } else {
148  continue;
149  }
150 
151  if (std::abs(ObsMove) > maxMoveCut_) {
152  updateDB_ = false;
153  break;
154 
155  } else if (std::abs(ObsMove) > cutoffs_[alignableIndex]) {
156 
157  if (std::abs(ObsErr) > maxErrorCut_) {
158  updateDB_ = false;
159  break;
160  } else {
161  if (std::abs(ObsMove/ObsErr) < sigCut_) {
162  continue;
163  }
164  }
165  updateDB_ = true;
166  }
167  }
168  }
169  } else {
170  edm::LogError("MillePedeFileReader") << "Could not read millepede result-file.";
171 
172  updateDB_ = false;
173  Nrec_ = 0;
174  }
175 }
std::array< double, 6 > tYobs_
std::array< double, 6 > tXobs_
std::array< double, 6 > YobsErr_
PclHLS getHLS(const Alignable *)
std::array< double, 6 > tZobs_
std::array< double, 6 > tXobsErr_
const std::array< double, 6 > cutoffs_
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_
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 45 of file MillePedeFileReader.cc.

Referenced by MillePedeAlignmentAlgorithm::storeAlignments().

45  {
46  return updateDB_;
47 }

Member Data Documentation

const std::array<double, 6> MillePedeFileReader::cutoffs_
private
Initial value:

Definition at line 88 of file MillePedeFileReader.h.

const double MillePedeFileReader::maxErrorCut_
private

Definition at line 78 of file MillePedeFileReader.h.

const double MillePedeFileReader::maxMoveCut_
private

Definition at line 78 of file MillePedeFileReader.h.

const std::string MillePedeFileReader::millePedeLogFile_
private

Definition at line 68 of file MillePedeFileReader.h.

const std::string MillePedeFileReader::millePedeResFile_
private

Definition at line 69 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.

int MillePedeFileReader::Nrec_ {0}
private

Definition at line 92 of file MillePedeFileReader.h.

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

Definition at line 65 of file MillePedeFileReader.h.

const double MillePedeFileReader::sigCut_
private

Definition at line 72 of file MillePedeFileReader.h.

const double MillePedeFileReader::tXcut_
private

Definition at line 74 of file MillePedeFileReader.h.

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

Definition at line 96 of file MillePedeFileReader.h.

Referenced by getTXobs().

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

Definition at line 97 of file MillePedeFileReader.h.

Referenced by getTXobsErr().

const double MillePedeFileReader::tYcut_
private

Definition at line 75 of file MillePedeFileReader.h.

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

Definition at line 101 of file MillePedeFileReader.h.

Referenced by getTYobs().

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

Definition at line 102 of file MillePedeFileReader.h.

Referenced by getTYobsErr().

const double MillePedeFileReader::tZcut_
private

Definition at line 76 of file MillePedeFileReader.h.

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

Definition at line 106 of file MillePedeFileReader.h.

Referenced by getTZobs().

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

Definition at line 107 of file MillePedeFileReader.h.

Referenced by getTZobsErr().

bool MillePedeFileReader::updateDB_ {false}
private

Definition at line 91 of file MillePedeFileReader.h.

const double MillePedeFileReader::Xcut_
private

Definition at line 74 of file MillePedeFileReader.h.

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

Definition at line 94 of file MillePedeFileReader.h.

Referenced by getXobs().

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

Definition at line 95 of file MillePedeFileReader.h.

Referenced by getXobsErr().

const double MillePedeFileReader::Ycut_
private

Definition at line 75 of file MillePedeFileReader.h.

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

Definition at line 99 of file MillePedeFileReader.h.

Referenced by getYobs().

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

Definition at line 100 of file MillePedeFileReader.h.

Referenced by getYobsErr().

const double MillePedeFileReader::Zcut_
private

Definition at line 76 of file MillePedeFileReader.h.

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

Definition at line 104 of file MillePedeFileReader.h.

Referenced by getZobs().

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

Definition at line 105 of file MillePedeFileReader.h.

Referenced by getZobsErr().