Skip to content

Commit 66e56fe

Browse files
authored
MCH: add re-alignment option in workflow (#13969)
* MCH: add re-alignment option in workflow * Move new geometry reading to init
1 parent 28e9bf1 commit 66e56fe

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

Detectors/MUON/MCH/Align/src/AlignmentSpec.cxx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,6 @@ class AlignmentTask
159159
}
160160

161161
doReAlign = ic.options().get<bool>("do-realign");
162-
if (doReAlign) {
163-
LOG(info) << "Re-alignment mode";
164-
}
165162

166163
if (mCCDBRequest) {
167164
LOG(info) << "Loading magnetic field and reference geometry from CCDB";
@@ -181,9 +178,9 @@ class AlignmentTask
181178
LOG(fatal) << "No GRP file";
182179
}
183180

184-
auto geoIdealFile = ic.options().get<string>("geo-file-ideal");
185-
if (std::filesystem::exists(geoIdealFile)) {
186-
base::GeometryManager::loadGeometry(geoIdealFile.c_str());
181+
IdealGeoFileName = ic.options().get<string>("geo-file-ideal");
182+
if (std::filesystem::exists(IdealGeoFileName)) {
183+
base::GeometryManager::loadGeometry(IdealGeoFileName.c_str());
187184
transformation = geo::transformationFromTGeoManager(*gGeoManager);
188185
for (int i = 0; i < 156; i++) {
189186
int iDEN = GetDetElemId(i);
@@ -193,9 +190,9 @@ class AlignmentTask
193190
LOG(fatal) << "No ideal geometry";
194191
}
195192

196-
auto geoRefFile = ic.options().get<string>("geo-file-ref");
197-
if (std::filesystem::exists(geoRefFile)) {
198-
base::GeometryManager::loadGeometry(geoRefFile.c_str());
193+
RefGeoFileName = ic.options().get<string>("geo-file-ref");
194+
if (std::filesystem::exists(RefGeoFileName)) {
195+
base::GeometryManager::loadGeometry(RefGeoFileName.c_str());
199196
transformation = geo::transformationFromTGeoManager(*gGeoManager);
200197
for (int i = 0; i < 156; i++) {
201198
int iDEN = GetDetElemId(i);
@@ -204,6 +201,22 @@ class AlignmentTask
204201
} else {
205202
LOG(fatal) << "No reference geometry";
206203
}
204+
205+
if (doReAlign) {
206+
LOG(info) << "Re-alignment mode";
207+
LOG(info) << "Loading re-alignment geometry";
208+
NewGeoFileName = ic.options().get<string>("geo-file-new");
209+
if (std::filesystem::exists(NewGeoFileName)) {
210+
base::GeometryManager::loadGeometry(NewGeoFileName.c_str());
211+
transformation = geo::transformationFromTGeoManager(*gGeoManager);
212+
for (int i = 0; i < 156; i++) {
213+
int iDEN = GetDetElemId(i);
214+
transformNew[iDEN] = transformation(iDEN);
215+
}
216+
} else {
217+
LOG(fatal) << "No re-alignment geometry";
218+
}
219+
}
207220
}
208221

209222
auto doEvaluation = ic.options().get<bool>("do-evaluation");
@@ -387,21 +400,6 @@ class AlignmentTask
387400
}
388401
}
389402

390-
// Load new geometry if we need to do re-align
391-
if (doReAlign) {
392-
if (NewGeoFileName != "") {
393-
LOG(info) << "Loading re-alignment geometry";
394-
base::GeometryManager::loadGeometry(NewGeoFileName.c_str());
395-
transformation = geo::transformationFromTGeoManager(*gGeoManager);
396-
for (int i = 0; i < 156; i++) {
397-
int iDEN = GetDetElemId(i);
398-
transformNew[iDEN] = transformation(iDEN);
399-
}
400-
} else {
401-
LOG(fatal) << "No re-alignment geometry";
402-
}
403-
}
404-
405403
if (!readFromRec) {
406404
// Loading input data
407405
LOG(info) << "Loading MCH tracks";
@@ -875,6 +873,7 @@ class AlignmentTask
875873
const string mchFileName{"mchtracks.root"};
876874
const string muonFileName{"muontracks.root"};
877875
string outFileName{"Alignment"};
876+
string IdealGeoFileName{""};
878877
string RefGeoFileName{""};
879878
string NewGeoFileName{""};
880879
bool doAlign{false};
@@ -918,6 +917,7 @@ o2::framework::DataProcessorSpec getAlignmentSpec(bool disableCCDB)
918917
outputSpecs,
919918
AlgorithmSpec{o2::framework::adaptFromTask<AlignmentTask>(ccdbRequest)},
920919
Options{{"geo-file-ref", VariantType::String, o2::base::NameConf::getAlignedGeomFileName(), {"Name of the reference geometry file"}},
920+
{"geo-file-new", VariantType::String, "", {"Name of the new geometry file"}},
921921
{"geo-file-ideal", VariantType::String, o2::base::NameConf::getGeomFileName(), {"Name of the ideal geometry file"}},
922922
{"grp-file", VariantType::String, o2::base::NameConf::getGRPFileName(), {"Name of the grp file"}},
923923
{"do-align", VariantType::Bool, false, {"Switch for alignment, otherwise only residuals will be stored"}},

0 commit comments

Comments
 (0)