Skip to content

Commit

Permalink
Merge f82d575 into sapling-pr-archive-ktf
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf authored Feb 16, 2025
2 parents b3ad5bc + f82d575 commit 7d37a20
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 112 deletions.
48 changes: 24 additions & 24 deletions Detectors/MUON/MCH/Align/src/AlignmentSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ class AlignmentTask
}

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

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

auto geoIdealFile = ic.options().get<string>("geo-file-ideal");
if (std::filesystem::exists(geoIdealFile)) {
base::GeometryManager::loadGeometry(geoIdealFile.c_str());
IdealGeoFileName = ic.options().get<string>("geo-file-ideal");
if (std::filesystem::exists(IdealGeoFileName)) {
base::GeometryManager::loadGeometry(IdealGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
Expand All @@ -193,9 +190,9 @@ class AlignmentTask
LOG(fatal) << "No ideal geometry";
}

auto geoRefFile = ic.options().get<string>("geo-file-ref");
if (std::filesystem::exists(geoRefFile)) {
base::GeometryManager::loadGeometry(geoRefFile.c_str());
RefGeoFileName = ic.options().get<string>("geo-file-ref");
if (std::filesystem::exists(RefGeoFileName)) {
base::GeometryManager::loadGeometry(RefGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
Expand All @@ -204,6 +201,22 @@ class AlignmentTask
} else {
LOG(fatal) << "No reference geometry";
}

if (doReAlign) {
LOG(info) << "Re-alignment mode";
LOG(info) << "Loading re-alignment geometry";
NewGeoFileName = ic.options().get<string>("geo-file-new");
if (std::filesystem::exists(NewGeoFileName)) {
base::GeometryManager::loadGeometry(NewGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
transformNew[iDEN] = transformation(iDEN);
}
} else {
LOG(fatal) << "No re-alignment geometry";
}
}
}

auto doEvaluation = ic.options().get<bool>("do-evaluation");
Expand Down Expand Up @@ -387,21 +400,6 @@ class AlignmentTask
}
}

// Load new geometry if we need to do re-align
if (doReAlign) {
if (NewGeoFileName != "") {
LOG(info) << "Loading re-alignment geometry";
base::GeometryManager::loadGeometry(NewGeoFileName.c_str());
transformation = geo::transformationFromTGeoManager(*gGeoManager);
for (int i = 0; i < 156; i++) {
int iDEN = GetDetElemId(i);
transformNew[iDEN] = transformation(iDEN);
}
} else {
LOG(fatal) << "No re-alignment geometry";
}
}

if (!readFromRec) {
// Loading input data
LOG(info) << "Loading MCH tracks";
Expand Down Expand Up @@ -875,6 +873,7 @@ class AlignmentTask
const string mchFileName{"mchtracks.root"};
const string muonFileName{"muontracks.root"};
string outFileName{"Alignment"};
string IdealGeoFileName{""};
string RefGeoFileName{""};
string NewGeoFileName{""};
bool doAlign{false};
Expand Down Expand Up @@ -918,6 +917,7 @@ o2::framework::DataProcessorSpec getAlignmentSpec(bool disableCCDB)
outputSpecs,
AlgorithmSpec{o2::framework::adaptFromTask<AlignmentTask>(ccdbRequest)},
Options{{"geo-file-ref", VariantType::String, o2::base::NameConf::getAlignedGeomFileName(), {"Name of the reference geometry file"}},
{"geo-file-new", VariantType::String, "", {"Name of the new geometry file"}},
{"geo-file-ideal", VariantType::String, o2::base::NameConf::getGeomFileName(), {"Name of the ideal geometry file"}},
{"grp-file", VariantType::String, o2::base::NameConf::getGRPFileName(), {"Name of the grp file"}},
{"do-align", VariantType::Bool, false, {"Switch for alignment, otherwise only residuals will be stored"}},
Expand Down
16 changes: 12 additions & 4 deletions Framework/AnalysisSupport/src/AODJAlienReaderHelpers.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
// or submit itself to any jurisdiction.

#include "AODJAlienReaderHelpers.h"
#include <memory>
#include "Framework/TableTreeHelpers.h"
#include "Framework/AnalysisHelpers.h"
#include "Framework/DataProcessingStats.h"
#include "Framework/RootTableBuilderHelpers.h"
#include "Framework/RootArrowFilesystem.h"
#include "Framework/AlgorithmSpec.h"
#include "Framework/ConfigParamRegistry.h"
#include "Framework/ControlService.h"
Expand Down Expand Up @@ -41,6 +43,8 @@
#include <arrow/io/interfaces.h>
#include <arrow/table.h>
#include <arrow/util/key_value_metadata.h>
#include <arrow/dataset/dataset.h>
#include <arrow/dataset/file_base.h>

using namespace o2;
using namespace o2::aod;
Expand Down Expand Up @@ -272,11 +276,13 @@ AlgorithmSpec AODJAlienReaderHelpers::rootFileReaderCallback(ConfigContext const
// Origin file name for derived output map
auto o2 = Output(TFFileNameHeader);
auto fileAndFolder = didir->getFileFolder(dh, fcnt, ntf);
std::string currentFilename(fileAndFolder.file->GetName());
if (strcmp(fileAndFolder.file->GetEndpointUrl()->GetProtocol(), "file") == 0 && fileAndFolder.file->GetEndpointUrl()->GetFile()[0] != '/') {
auto rootFS = std::dynamic_pointer_cast<TFileFileSystem>(fileAndFolder.filesystem());
auto* f = dynamic_cast<TFile*>(rootFS->GetFile());
std::string currentFilename(f->GetFile()->GetName());
if (strcmp(f->GetEndpointUrl()->GetProtocol(), "file") == 0 && f->GetEndpointUrl()->GetFile()[0] != '/') {
// This is not an absolute local path. Make it absolute.
static std::string pwd = gSystem->pwd() + std::string("/");
currentFilename = pwd + std::string(fileAndFolder.file->GetName());
currentFilename = pwd + std::string(f->GetName());
}
outputs.make<std::string>(o2) = currentFilename;
}
Expand Down Expand Up @@ -312,7 +318,9 @@ AlgorithmSpec AODJAlienReaderHelpers::rootFileReaderCallback(ConfigContext const
auto concrete = DataSpecUtils::asConcreteDataMatcher(firstRoute.matcher);
auto dh = header::DataHeader(concrete.description, concrete.origin, concrete.subSpec);
auto fileAndFolder = didir->getFileFolder(dh, fcnt, ntf);
if (!fileAndFolder.file) {

// In case the filesource is empty, move to the next one.
if (fileAndFolder.path().empty()) {
fcnt += 1;
ntf = 0;
if (didir->atEnd(fcnt)) {
Expand Down
Loading

0 comments on commit 7d37a20

Please sign in to comment.