Skip to content

Commit 829edeb

Browse files
authored
Update
1 parent 630ef49 commit 829edeb

File tree

5 files changed

+90
-8
lines changed

5 files changed

+90
-8
lines changed

ALICE3/Core/DetLayer.cxx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,41 @@ void DetLayer::addDeadPhiRegion(float phiStart, float phiEnd)
7676
mDeadPhiRegions->Sort();
7777
}
7878

79+
void DetLayer::setDeadPhiRegions(TGraph* graph)
80+
{
81+
LOG(debug) << "Setting dead phi regions for layer " << name << " with graph " << (graph ? graph->GetName() : "nullptr");
82+
if (mDeadPhiRegions != nullptr) {
83+
LOG(warning) << "Overriding existing dead phi regions for layer " << name;
84+
delete mDeadPhiRegions;
85+
}
86+
mDeadPhiRegions = graph;
87+
if (mDeadPhiRegions->GetN() == 0) {
88+
LOG(warning) << "Dead phi regions graph for layer " << name << " is empty, clearing dead regions";
89+
mDeadPhiRegions = nullptr;
90+
return; // cleared the dead regions
91+
}
92+
// Check sanity of the graph
93+
if (mDeadPhiRegions != nullptr) {
94+
for (int i = 0; i < mDeadPhiRegions->GetN(); i++) {
95+
const float x = mDeadPhiRegions->GetX()[i];
96+
const float y = mDeadPhiRegions->GetY()[i];
97+
// First point has to be at 0, last point has to be at 2PI
98+
if ((i == 0 && x != 0.f) || (i == mDeadPhiRegions->GetN() - 1 && x != o2::constants::math::TwoPI)) {
99+
LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid x value " << x << " at point " << i << ", first point should be 0 and last point should be 2PI";
100+
}
101+
LOG(debug) << "Point " << i << ": (" << x << ", " << y << ")";
102+
if (x < 0 || x > o2::constants::math::TwoPI) {
103+
LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid x value " << x << " at point " << i;
104+
}
105+
if (y != 0.f && y != 2.f) {
106+
LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid y value " << y << " at point " << i << ", should be 0 or 2";
107+
}
108+
}
109+
} else {
110+
LOG(info) << "Cleared dead phi regions for layer " << name;
111+
}
112+
}
113+
79114
std::string DetLayer::toString() const
80115
{
81116
std::string out = "";

ALICE3/Core/DetLayer.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,18 @@ struct DetLayer {
4747
void setResolutionZ(float resZ_) { resZ = resZ_; }
4848
void setEfficiency(float eff_) { eff = eff_; }
4949
void setType(int type_) { type = type_; }
50+
51+
// Dead areas
52+
53+
/// @brief Add a dead region in phi for this layer
54+
/// @param phiStart starting angle in radians of the dead region
55+
/// @param phiEnd ending angle in radians of the dead region
5056
void addDeadPhiRegion(float phiStart, float phiEnd);
5157

58+
/// @brief Set the dead regions in phi for this layer with a TGraph containing all regions. The graph should have y=2 for dead regions and y=0 for alive regions.
59+
/// @param graph graph of the dead regions. Can be nullptr to clear the dead regions.
60+
void setDeadPhiRegions(TGraph* graph);
61+
5262
// Getters
5363
float getRadius() const { return r; }
5464
float getZ() const { return z; }

ALICE3/Core/FastTracker.cxx

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace fastsim
3232

3333
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
3434

35-
void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
35+
DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
3636
{
3737
LOG(debug) << "Adding layer " << name << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type;
3838
DetLayer newLayer(name, r, z, x0, xrho, resRPhi, resZ, eff, type);
@@ -52,6 +52,8 @@ void FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho,
5252
}
5353
// Add the new layer to the layers vector
5454
layers.push_back(newLayer);
55+
// Return the last added layer
56+
return &layers.back();
5557
}
5658

5759
void FastTracker::addDeadPhiRegionInLayer(const std::string& layerName, float phiStart, float phiEnd)
@@ -294,12 +296,15 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa
294296
for (const auto& layer : layers) {
295297
LOG(info) << " Reading layer " << layer;
296298

297-
auto getKey = [&layer, &env](const std::string& name) {
299+
auto getKey = [&layer, &env](const std::string& name, const bool required = true) {
298300
std::string key = layer + "." + name;
299301
if (!env.Defined(key.c_str())) {
300-
LOG(warning) << "Key " << key << " not defined in configuration file, getting the default value";
302+
if (required) {
303+
LOG(fatal) << "Key " << key << " not defined in configuration file";
304+
}
305+
LOG(debug) << "Key " << key << " not defined in configuration file, getting the default value";
301306
}
302-
LOG(info) << " Getting key " << key;
307+
LOG(debug) << " Getting key " << key << " from configuration file";
303308
return key;
304309
};
305310
const float r = env.GetValue(getKey("r").c_str(), -1.0f);
@@ -311,9 +316,36 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa
311316
const float resZ = env.GetValue(getKey("resZ").c_str(), 0.0f);
312317
const float eff = env.GetValue(getKey("eff").c_str(), 0.0f);
313318
const int type = env.GetValue(getKey("type").c_str(), 0);
319+
const char* deadPhiRegions = env.GetValue(getKey("deadPhiRegions", false).c_str(), "");
314320

315321
// void AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0);
316-
AddLayer(layer.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type);
322+
LOG(info) << " Adding layer " << layer << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions;
323+
324+
DetLayer* addedLayer = AddLayer(layer.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type);
325+
if (strlen(deadPhiRegions) > 0) { // Taking it as ccdb path or local file
326+
// Check if it begins with ccdb:
327+
if (std::string(deadPhiRegions).rfind("ccdb:", 0) == 0) {
328+
std::string ccdbPath = std::string(deadPhiRegions).substr(5); // remove "ccdb:" prefix
329+
if (ccdbManager == nullptr) {
330+
LOG(fatal) << "CCDB manager is null, cannot retrieve file " << ccdbPath;
331+
return;
332+
}
333+
TGraph* g = ccdbManager->getForTimeStamp<TGraph>(ccdbPath, -1);
334+
addedLayer->setDeadPhiRegions(g);
335+
} else {
336+
// Taking it as local file
337+
TFile infile(deadPhiRegions, "READ");
338+
if (!infile.IsOpen()) {
339+
LOG(fatal) << "Cannot open dead phi regions file " << deadPhiRegions;
340+
return;
341+
}
342+
TGraph* g = (TGraph*)infile.Get(infile.GetListOfKeys()->At(0)->GetName());
343+
infile.Close();
344+
addedLayer->setDeadPhiRegions(g);
345+
}
346+
} else {
347+
LOG(debug) << " No dead phi regions for layer " << layer;
348+
}
317349
}
318350
}
319351

ALICE3/Core/FastTracker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class FastTracker
4141
virtual ~FastTracker() {}
4242

4343
// Layer and layer configuration
44-
void AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0);
44+
DetLayer* AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0);
45+
4546
/// Add a dead region in phi for a specific layer
4647
/// \param layerName Name of the layer to modify
4748
/// \param phiStart Start angle of the dead region (in radians)

ALICE3/macros/testFastTracker.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515

1616
#include "ALICE3/Core/FastTracker.h"
1717

18-
#include "CCDB/BasicCCDBManager.h"
19-
#include "DataFormatsParameters/GRPLHCIFData.h"
18+
#include <CCDB/BasicCCDBManager.h>
19+
#include <DataFormatsParameters/GRPLHCIFData.h>
20+
21+
#include <fairlogger/Logger.h>
2022

2123
void testFastTracker(std::string geometryFile = "a3geo.ini")
2224
{
2325

26+
fair::Logger::SetConsoleSeverity(fair::Severity::debug);
27+
2428
// auto& ccdb = o2::ccdb::BasicCCDBManager::instance();
2529
// ccdb.setURL("http://alice-ccdb.cern.ch");
2630
o2::fastsim::FastTracker fastTracker;

0 commit comments

Comments
 (0)