21 const std::shared_ptr<const PedeLabelerBase>& pedeLabeler) :
22 pedeLabeler_(pedeLabeler),
23 millePedeLogFile_(config.getParameter<std::
string>(
"millePedeLogFile")),
24 millePedeResFile_(config.getParameter<std::
string>(
"millePedeResFile")),
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"))
40 readMillePedeLogFile();
41 readMillePedeResultFile();
59 logFile.open(millePedeLogFile_.c_str());
61 if (logFile.is_open()) {
62 edm::LogInfo(
"MillePedeFileReader") <<
"Reading millepede log-file";
65 while (getline(logFile, line)) {
68 if (line.find(Nrec_string) != std::string::npos) {
69 std::istringstream iss(line);
71 iss >> trash >> trash >> Nrec_;
80 edm::LogError(
"MillePedeFileReader") <<
"Could not read millepede log-file.";
91 std::ifstream resFile;
92 resFile.open(millePedeResFile_.c_str());
94 if (resFile.is_open()) {
95 edm::LogInfo(
"MillePedeFileReader") <<
"Reading millepede result-file";
98 getline(resFile, line);
100 while (getline(resFile, line)) {
101 std::istringstream iss(line);
103 std::vector<std::string> tokens;
105 while (iss >> token) {
106 tokens.push_back(token);
109 if (tokens.size() > 4 ) {
111 auto alignableLabel = std::stoul(tokens[0]);
112 auto alignableIndex = alignableLabel % 10 - 1;
113 const auto alignable = pedeLabeler_->alignableFromLabel(alignableLabel);
115 double ObsMove = std::stof(tokens[3]) * multiplier_[alignableIndex];
116 double ObsErr = std::stof(tokens[4]) * multiplier_[alignableIndex];
118 auto det = getHLS(alignable);
120 if (det != PclHLS::NotInPCL) {
121 switch (alignableIndex) {
123 Xobs_[
static_cast<int>(det)] = ObsMove;
124 XobsErr_[
static_cast<int>(det)] = ObsErr;
127 Yobs_[
static_cast<int>(det)] = ObsMove;
128 YobsErr_[
static_cast<int>(det)] = ObsErr;
131 Zobs_[
static_cast<int>(det)] = ObsMove;
132 ZobsErr_[
static_cast<int>(det)] = ObsErr;
135 tXobs_[
static_cast<int>(det)] = ObsMove;
136 tXobsErr_[
static_cast<int>(det)] = ObsErr;
139 tYobs_[
static_cast<int>(det)] = ObsMove;
140 tYobsErr_[
static_cast<int>(det)] = ObsErr;
143 tZobs_[
static_cast<int>(det)] = ObsMove;
144 tZobsErr_[
static_cast<int>(det)] = ObsErr;
151 if (
std::abs(ObsMove) > maxMoveCut_) {
155 }
else if (
std::abs(ObsMove) > cutoffs_[alignableIndex]) {
157 if (
std::abs(ObsErr) > maxErrorCut_) {
161 if (
std::abs(ObsMove/ObsErr) < sigCut_) {
170 edm::LogError(
"MillePedeFileReader") <<
"Could not read millepede result-file.";
180 if (!alignable)
return PclHLS::NotInPCL;
182 const auto& tns = pedeLabeler_->alignableTracker()->trackerNameSpace();
186 switch (tns.tpb().halfBarrelNumber(alignable->
id())) {
187 case 1:
return PclHLS::TPBHalfBarrelXminus;
188 case 2:
return PclHLS::TPBHalfBarrelXplus;
191 <<
"@SUB=MillePedeFileReader::getHLS\n"
192 <<
"Found a pixel half-barrel number that should not exist: "
193 << tns.tpb().halfBarrelNumber(alignable->
id());
196 switch (tns.tpe().endcapNumber(alignable->
id())) {
198 switch (tns.tpe().halfCylinderNumber(alignable->
id())) {
199 case 1:
return PclHLS::TPEHalfCylinderXminusZminus;
200 case 2:
return PclHLS::TPEHalfCylinderXplusZminus;
203 <<
"@SUB=MillePedeFileReader::getHLS\n"
204 <<
"Found a pixel half-cylinder number that should not exist: "
205 << tns.tpe().halfCylinderNumber(alignable->
id());
208 switch (tns.tpe().halfCylinderNumber(alignable->
id())) {
209 case 1:
return PclHLS::TPEHalfCylinderXminusZplus;
210 case 2:
return PclHLS::TPEHalfCylinderXplusZplus;
213 <<
"@SUB=MillePedeFileReader::getHLS\n"
214 <<
"Found a pixel half-cylinder number that should not exist: "
215 << tns.tpe().halfCylinderNumber(alignable->
id());
219 <<
"@SUB=MillePedeFileReader::getHLS\n"
220 <<
"Found a pixel endcap number that should not exist: "
221 << tns.tpe().endcapNumber(alignable->
id());
223 default:
return PclHLS::NotInPCL;
align::ID id() const
Return the ID of Alignable, i.e. DetId of 'first' component GeomDet(Unit).
PclHLS getHLS(const Alignable *)
void readMillePedeLogFile()
void readMillePedeResultFile()
virtual StructureType alignableObjectId() const =0
Return the alignable type identifier.
Abs< T >::type abs(const T &t)
MillePedeFileReader(const edm::ParameterSet &, const std::shared_ptr< const PedeLabelerBase > &)
static std::array< double, 6 > multiplier_