Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions ALICE3/Core/FastTracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
{
LOG(debug) << "Adding layer " << name << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type;
DetLayer newLayer(name, r, z, x0, xrho, resRPhi, resZ, eff, type);
// Check that efficient layers are not inert layers
if (newLayer.getEfficiency() > 0.0f && newLayer.isInert()) {
Expand Down Expand Up @@ -219,8 +220,8 @@
for (int i = 0; i < kNPassiveBound; i++) {
AddLayer(Form("tpc_boundary%d", i), rBoundary[i], zLength, radLBoundary[i], xrhoBoundary[i], 0); // dummy errors
}
for (Int_t k = 0; k < tpcRows; k++) {

Check failure on line 223 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
Float_t rowRadius = 0;

Check failure on line 224 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
if (k < innerRows)
rowRadius = rowOneRadius + k * tpcInnerRadialPitch;
else if (k >= innerRows && k < (innerRows + middleRows))
Expand All @@ -232,6 +233,56 @@
}
}

void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager)
{
LOG(info) << " Adding generic detector from file " << filename;
// If the filename starts with ccdb: then take the file from the ccdb
if (filename.rfind("ccdb:", 0) == 0) {
std::string ccdbPath = filename.substr(5); // remove "ccdb:" prefix
if (ccdbManager == nullptr) {
LOG(fatal) << "CCDB manager is null, cannot retrieve file " << ccdbPath;
return;
}
const std::string outPath = "/tmp/DetGeo/";
filename = Form("%s/%s/snapshot.root", outPath.c_str(), ccdbPath.c_str());
std::ifstream checkFile(filename); // Check if file already exists
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
LOG(info) << " --- CCDB source detected for detector geometry " << filename;
std::map<std::string, std::string> metadata;
ccdbManager->getCCDBAccessor().retrieveBlob(ccdbPath, outPath, metadata, 1);
// Add CCDB handling logic here if needed
LOG(info) << " --- Now retrieving geometry configuration from CCDB to: " << filename;
} else { // File exists, proceed to load
LOG(info) << " --- Geometry configuration file already exists: " << filename << ". Skipping download.";
checkFile.close();
}
AddGenericDetector(filename, nullptr);
return;
}

std::ifstream infile(filename);
if (!infile.is_open()) {
LOG(fatal) << "Could not open detector configuration file: " << filename;
return;
}

std::string line;
while (std::getline(infile, line)) {
if (line.empty() || line[0] == '#')
continue; // skip comments and empty lines
std::istringstream iss(line);
std::string name;
float r, z, x0, xrho, resRPhi, resZ, eff;
int type;
if (!(iss >> name >> r >> z >> x0 >> xrho >> resRPhi >> resZ >> eff >> type)) {
LOG(error) << "Malformed line in detector config: " << line;
continue;
}
AddLayer(name.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type);
}
infile.close();
}

float FastTracker::Dist(float z, float r)
{
// porting of DetektorK::Dist
Expand All @@ -247,7 +298,7 @@
index = 1;
z0 = -4 * sigmaD + i * dz0;
dist += index * (dz0 / 3.) * (1 / o2::math_utils::sqrt(o2::constants::math::TwoPI) / sigmaD) * std::exp(-z0 * z0 / 2. / sigmaD / sigmaD) * (1 / o2::math_utils::sqrt((z - z0) * (z - z0) + r * r));
if (index != 4)

Check failure on line 301 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
index = 4;
else
index = 2;
Expand Down Expand Up @@ -377,7 +428,7 @@
// check if layer is reached
float targetX = 1e+3;
inputTrack.getXatLabR(layers[il].getRadius(), targetX, magneticField);
if (targetX > 999.f) {

Check failure on line 431 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOGF(debug, "Failed to find intercept for layer %d at radius %.2f cm", il, layers[il].getRadius());
break; // failed to find intercept
}
Expand Down Expand Up @@ -454,7 +505,7 @@

float targetX = 1e+3;
inputTrack.getXatLabR(layers[il].getRadius(), targetX, magneticField);
if (targetX > 999)

Check failure on line 508 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
continue; // failed to find intercept

if (!inputTrack.propagateTo(targetX, magneticField)) {
Expand Down Expand Up @@ -526,7 +577,7 @@
// backpropagate to original radius
float finalX = 1e+3;
bool inPropStatus = inwardTrack.getXatLabR(initialRadius, finalX, magneticField);
if (finalX > 999) {

Check failure on line 580 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
LOG(debug) << "Failed to find intercept for initial radius " << initialRadius << " cm, x = " << finalX << " and status " << inPropStatus << " and sn = " << inwardTrack.getSnp() << " r = " << inwardTrack.getY() * inwardTrack.getY();
return -3; // failed to find intercept
}
Expand All @@ -536,7 +587,7 @@
}

// only attempt to continue if intercepts are at least four
if (nIntercepts < 4)

Check failure on line 590 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
return nIntercepts;

// generate efficiency
Expand Down Expand Up @@ -580,7 +631,7 @@
if (fcovm[ii][jj] * fcovm[ii][jj] > std::abs(fcovm[ii][ii] * fcovm[jj][jj])) {
rubenConditional = true;
if (makePositiveDefinite) {
fcovm[ii][jj] = TMath::Sign(1, fcovm[ii][jj]) * covMatFactor * sqrt(std::abs(fcovm[ii][ii] * fcovm[jj][jj]));

Check failure on line 634 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
}
}
}
Expand Down Expand Up @@ -618,7 +669,7 @@
for (int j = 0; j < 5; ++j)
val += eigVec[j][ii] * outputTrack.getParam(j);
// smear parameters according to eigenvalues
params_[ii] = gRandom->Gaus(val, sqrt(eigVal[ii]));

Check failure on line 672 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
}

// invert eigenvector matrix
Expand All @@ -631,7 +682,7 @@
outputTrack.setParam(val, ii);
}
// should make a sanity check that par[2] sin(phi) is in [-1, 1]
if (fabs(outputTrack.getParam(2)) > 1.) {

Check failure on line 685 in ALICE3/Core/FastTracker.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
LOG(info) << " --- smearTrack failed sin(phi) sanity check: " << outputTrack.getParam(2);
return -2;
}
Expand Down
16 changes: 14 additions & 2 deletions ALICE3/Core/FastTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

#include "DetLayer.h"

#include "ReconstructionDataFormats/Track.h"
#include <CCDB/BasicCCDBManager.h>
#include <ReconstructionDataFormats/Track.h>

#include <fairlogger/Logger.h> // not a system header but megalinter thinks so
#include <fairlogger/Logger.h>

#include <string>
#include <vector>
Expand Down Expand Up @@ -61,6 +62,17 @@ class FastTracker
void AddSiliconALICE3v2(std::vector<float> pixelResolution);
void AddSiliconALICE3(float scaleX0VD, std::vector<float> pixelResolution);
void AddTPC(float phiResMean, float zResMean);
/**
* @brief Adds a generic detector configuration from the specified file.
*
* This function loads and integrates a detector configuration into the tracker
* using the provided filename. The file should contain the necessary parameters
* and settings for the detector to be added.
*
* @param filename Path to the configuration file describing the detector.
* @param ccdbManager Pointer to a BasicCCDBManager instance for database access (if needed).
*/
void AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager = nullptr);

void Print();

Expand Down
Loading