16 const std::shared_ptr<const PedeLabelerBase>&
pedeLabeler,
17 const std::shared_ptr<const AlignPCLThresholds>& theThresholds)
18 : pedeLabeler_(pedeLabeler),
19 theThresholds_(theThresholds),
20 millePedeEndFile_(config.getParameter<
std::
string>(
"millePedeEndFile")),
21 millePedeLogFile_(config.getParameter<
std::
string>(
"millePedeLogFile")),
22 millePedeResFile_(config.getParameter<
std::
string>(
"millePedeResFile")) {}
36 std::ifstream endFile;
39 if (endFile.is_open()) {
40 edm::LogInfo(
"MillePedeFileReader") <<
"Reading millepede end-file";
42 getline(endFile, line);
44 if (line.find(
"-1") != std::string::npos) {
45 getline(endFile, line);
47 std::istringstream iss(line);
53 std::istringstream iss(line);
59 edm::LogError(
"MillePedeFileReader") <<
"Could not read millepede end-file.";
68 if (logFile.is_open()) {
69 edm::LogInfo(
"MillePedeFileReader") <<
"Reading millepede log-file";
72 while (getline(logFile, line)) {
76 if (line.find(Nrec_string) != std::string::npos) {
77 std::istringstream iss(line);
79 iss >> trash >> trash >>
Nrec_;
81 if (Nrec_ < theThresholds_->getNrecords()) {
83 <<
"Number of records used " <<
theThresholds_->getNrecords() << std::endl;
88 if (line.find(Binaries_string) != std::string::npos) {
93 edm::LogError(
"MillePedeFileReader") <<
"Could not read millepede log-file.";
102 std::map<std::string, std::array<float, 6> > cutoffs_;
103 std::map<std::string, std::array<float, 6> > significances_;
104 std::map<std::string, std::array<float, 6> > thresholds_;
105 std::map<std::string, std::array<float, 6> > errors_;
107 std::vector<std::string> alignables_ =
theThresholds_->getAlignableList();
108 for (
auto& ali : alignables_) {
117 std::ifstream resFile;
120 if (resFile.is_open()) {
121 edm::LogInfo(
"MillePedeFileReader") <<
"Reading millepede result-file";
124 getline(resFile, line);
126 while (getline(resFile, line)) {
127 std::istringstream iss(line);
129 std::vector<std::string> tokens;
131 while (iss >> token) {
132 tokens.push_back(token);
135 if (tokens.size() > 4 ) {
136 auto alignableLabel = std::stoul(tokens[0]);
137 auto alignableIndex = alignableLabel % 10 - 1;
138 const auto alignable =
pedeLabeler_->alignableFromLabel(alignableLabel);
140 double ObsMove = std::stof(tokens[3]) *
multiplier_[alignableIndex];
141 double ObsErr = std::stof(tokens[4]) *
multiplier_[alignableIndex];
143 auto det =
getHLS(alignable);
144 int detIndex =
static_cast<int>(det);
151 Xobs_[detIndex] = ObsMove;
155 Yobs_[detIndex] = ObsMove;
159 Zobs_[detIndex] = ObsMove;
163 tXobs_[detIndex] = ObsMove;
167 tYobs_[detIndex] = ObsMove;
171 tZobs_[detIndex] = ObsMove;
175 edm::LogError(
"MillePedeFileReader") <<
"Currently not able to handle DOF " << coord << std::endl;
183 <<
" alignableLabel: " << alignableLabel <<
" with alignableIndex " << alignableIndex <<
" detIndex" 185 <<
" i.e. detLabel: " << detLabel <<
" (" << coord <<
")\n" 186 <<
" has movement: " << ObsMove <<
" +/- " << ObsErr <<
"\n" 187 <<
" cutoff (cutoffs_[" << detLabel <<
"][" << coord <<
"]): " << cutoffs_[
detLabel][alignableIndex] <<
"\n" 188 <<
" significance (significances_[" << detLabel <<
"][" << coord
189 <<
"]): " << significances_[
detLabel][alignableIndex] <<
"\n" 190 <<
" error thresolds (errors_[" << detLabel <<
"][" << coord <<
"]): " << errors_[
detLabel][alignableIndex]
192 <<
" max movement (thresholds_[" << detLabel <<
"][" << coord
193 <<
"]): " << thresholds_[
detLabel][alignableIndex] <<
"\n" 194 <<
"=============" << std::endl;
196 if (
std::abs(ObsMove) > thresholds_[detLabel][alignableIndex]) {
198 <<
" Exceeding maximum thresholds for movement: " <<
std::abs(ObsMove)
199 <<
" for" << detLabel <<
"(" << coord <<
")";
204 }
else if (
std::abs(ObsMove) > cutoffs_[detLabel][alignableIndex]) {
207 if (
std::abs(ObsErr) > errors_[detLabel][alignableIndex]) {
209 <<
" Exceeding maximum thresholds for error: " <<
std::abs(ObsErr)
210 <<
" for" << detLabel <<
"(" << coord <<
")";
215 if (
std::abs(ObsMove / ObsErr) < significances_[detLabel][alignableIndex]) {
222 <<
"This correction: " << ObsMove <<
"+/-" << ObsErr <<
" for " << detLabel <<
"(" << coord
223 <<
") will trigger a new Tracker Alignment payload!";
228 edm::LogError(
"MillePedeFileReader") <<
"Could not read millepede result-file.";
239 const auto& tns =
pedeLabeler_->alignableTracker()->trackerNameSpace();
243 switch (tns.tpb().halfBarrelNumber(alignable->
id())) {
249 throw cms::Exception(
"LogicError") <<
"@SUB=MillePedeFileReader::getHLS\n" 250 <<
"Found a pixel half-barrel number that should not exist: " 251 << tns.tpb().halfBarrelNumber(alignable->
id());
254 switch (tns.tpe().endcapNumber(alignable->
id())) {
256 switch (tns.tpe().halfCylinderNumber(alignable->
id())) {
262 throw cms::Exception(
"LogicError") <<
"@SUB=MillePedeFileReader::getHLS\n" 263 <<
"Found a pixel half-cylinder number that should not exist: " 264 << tns.tpe().halfCylinderNumber(alignable->
id());
267 switch (tns.tpe().halfCylinderNumber(alignable->
id())) {
273 throw cms::Exception(
"LogicError") <<
"@SUB=MillePedeFileReader::getHLS\n" 274 <<
"Found a pixel half-cylinder number that should not exist: " 275 << tns.tpe().halfCylinderNumber(alignable->
id());
279 <<
"@SUB=MillePedeFileReader::getHLS\n" 280 <<
"Found a pixel endcap number that should not exist: " << tns.tpe().endcapNumber(alignable->
id());
290 return "TPBHalfBarrelXminus";
292 return "TPBHalfBarrelXplus";
294 return "TPEHalfCylinderXminusZminus";
296 return "TPEHalfCylinderXplusZminus";
298 return "TPEHalfCylinderXminusZplus";
300 return "TPEHalfCylinderXplusZplus";
303 <<
"@SUB=MillePedeFileReader::getStringFromHLS\n" 304 <<
"Found an alignable structure not possible to map in the default AlignPCLThresholds partitions";
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
std::array< double, 6 > tYobs_
std::array< double, 6 > tXobs_
std::bitset< 4 > updateBits_
std::array< double, 6 > YobsErr_
PclHLS getHLS(const Alignable *)
void readMillePedeLogFile()
const std::shared_ptr< const AlignPCLThresholds > theThresholds_
std::array< double, 6 > tZobs_
const std::string millePedeLogFile_
std::array< double, 6 > tXobsErr_
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
std::array< double, 6 > tYobsErr_
void readMillePedeResultFile()
std::array< double, 6 > Yobs_
Abs< T >::type abs(const T &t)
MillePedeFileReader(const edm::ParameterSet &, const std::shared_ptr< const PedeLabelerBase > &, const std::shared_ptr< const AlignPCLThresholds > &)
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_
const std::string millePedeEndFile_
void readMillePedeEndFile()
std::array< double, 6 > XobsErr_
static std::array< double, 6 > multiplier_