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
86 changes: 46 additions & 40 deletions ALICE3/Core/DetLayer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,29 @@
{

// Parametric constructor
DetLayer::DetLayer(const TString& name_,
float r_,
float z_,
float x0_,
float xrho_,
float resRPhi_,
float resZ_,
float eff_,
int type_)
: name(name_),
r(r_),
z(z_),
x0(x0_),
xrho(xrho_),
resRPhi(resRPhi_),
resZ(resZ_),
eff(eff_),
type(type_)
DetLayer::DetLayer(const TString& name,
float r,
float z,
float x0,
float xrho,
float resRPhi,
float resZ,
float eff,
int type)
: mName(name),
mR(r),
mZ(z),
mX0(x0),
mXrho(xrho),
mResRPhi(resRPhi),
mResZ(resZ),
mEff(eff),
mType(type)
{
}

DetLayer::DetLayer(const DetLayer& other)
: name(other.name), r(other.r), z(other.z), x0(other.x0), xrho(other.xrho), resRPhi(other.resRPhi), resZ(other.resZ), eff(other.eff), type(other.type)
: mName(other.mName), mR(other.mR), mZ(other.mZ), mX0(other.mX0), mXrho(other.mXrho), mResRPhi(other.mResRPhi), mResZ(other.mResZ), mEff(other.mEff), mType(other.mType)
{
}

Expand All @@ -60,12 +60,12 @@
static constexpr float kPhiTolerance = 1e-4f;
if (mDeadPhiRegions == nullptr) {
mDeadPhiRegions = new TGraph();
mDeadPhiRegions->SetNameTitle(Form("deadPhiRegions_%s", name.Data()), Form("Dead phi regions for layer %s", name.Data()));
mDeadPhiRegions->SetNameTitle(Form("deadPhiRegions_%s", mName.Data()), Form("Dead phi regions for layer %s", mName.Data()));
mDeadPhiRegions->AddPoint(0, kDefaultValue);
mDeadPhiRegions->AddPoint(o2::constants::math::TwoPI, kDefaultValue);
}
if (phiStart < 0 || phiStart >= o2::constants::math::TwoPI || phiEnd < 0 || phiEnd >= o2::constants::math::TwoPI) {
LOG(fatal) << "Cannot add dead phi region with invalid range [" << phiStart << ", " << phiEnd << "] to layer " << name;
LOG(fatal) << "Cannot add dead phi region with invalid range [" << phiStart << ", " << phiEnd << "] to layer " << mName;
return;
}
mDeadPhiRegions->AddPoint(phiStart, kDefaultValue);
Expand All @@ -77,14 +77,14 @@

void DetLayer::setDeadPhiRegions(TGraph* graph)
{
LOG(debug) << "Setting dead phi regions for layer " << name << " with graph " << (graph ? graph->GetName() : "nullptr");
LOG(debug) << "Setting dead phi regions for layer " << mName << " with graph " << (graph ? graph->GetName() : "nullptr");
if (mDeadPhiRegions != nullptr) {
LOG(warning) << "Overriding existing dead phi regions for layer " << name;
LOG(warning) << "Overriding existing dead phi regions for layer " << mName;
delete mDeadPhiRegions;
}
mDeadPhiRegions = graph;
if (mDeadPhiRegions->GetN() == 0) {
LOG(warning) << "Dead phi regions graph for layer " << name << " is empty, clearing dead regions";
LOG(warning) << "Dead phi regions graph for layer " << mName << " is empty, clearing dead regions";
mDeadPhiRegions = nullptr;
return; // cleared the dead regions
}
Expand All @@ -95,51 +95,57 @@
const float y = mDeadPhiRegions->GetY()[i];
// First point has to be at 0, last point has to be at 2PI
if ((i == 0 && x != 0.f) || (i == mDeadPhiRegions->GetN() - 1 && x != o2::constants::math::TwoPI)) {
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";
LOG(fatal) << "Dead phi regions graph for layer " << mName << " has invalid x value " << x << " at point " << i << ", first point should be 0 and last point should be 2PI";
}
LOG(debug) << "Point " << i << ": (" << x << ", " << y << ")";
if (x < 0 || x > o2::constants::math::TwoPI) {
LOG(fatal) << "Dead phi regions graph for layer " << name << " has invalid x value " << x << " at point " << i;
LOG(fatal) << "Dead phi regions graph for layer " << mName << " has invalid x value " << x << " at point " << i;
}
if (y != 0.f && y != 2.f) {

Check failure on line 104 in ALICE3/Core/DetLayer.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(fatal) << "Dead phi regions graph for layer " << name << " has invalid y value " << y << " at point " << i << ", should be 0 or 2";
LOG(fatal) << "Dead phi regions graph for layer " << mName << " has invalid y value " << y << " at point " << i << ", should be 0 or 2";
}
}
} else {
LOG(info) << "Cleared dead phi regions for layer " << name;
LOG(info) << "Cleared dead phi regions for layer " << mName;
}
}

std::string DetLayer::toString() const
{
std::string out = "";
out.append("DetLayer: ");
out.append(name.Data());
out.append(mName.Data());
out.append(" | r: ");
out.append(std::to_string(r));
out.append(std::to_string(mR));
out.append(" cm | z: ");
out.append(std::to_string(z));
out.append(std::to_string(mZ));
out.append(" cm | x0: ");
out.append(std::to_string(x0));
out.append(std::to_string(mX0));
out.append(" cm | xrho: ");
out.append(std::to_string(xrho));
out.append(std::to_string(mXrho));
out.append(" g/cm^3 | resRPhi: ");
out.append(std::to_string(resRPhi));
out.append(std::to_string(mResRPhi));
out.append(" cm | resZ: ");
out.append(std::to_string(resZ));
out.append(std::to_string(mResZ));
out.append(" cm | eff: ");
out.append(std::to_string(eff));
out.append(std::to_string(mEff));
out.append(" | type: ");
switch (type) {
case layerInert:
switch (mType) {
case kLayerInert:
out.append("Inert");
break;
case layerSilicon:
case kLayerSilicon:
out.append("Silicon");
break;
case layerGas:
case kLayerGas:
out.append("Gas/TPC");
break;
case kLayerTOF:
out.append("TOF");
break;
case kLayerVertex:
out.append("Vertex");
break;
default:
out.append("Unknown");
break;
Expand Down
78 changes: 42 additions & 36 deletions ALICE3/Core/DetLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ struct DetLayer {
// Default constructor
DetLayer() = default;
// Parametric constructor
DetLayer(const TString& name_, float r_, float z_, float x0_, float xrho_,
float resRPhi_ = 0.0f, float resZ_ = 0.0f, float eff_ = 0.0f, int type_ = layerInert);
DetLayer(const TString& name, float r, float z, float x0, float xrho,
float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = kLayerInert);
// Copy constructor
DetLayer(const DetLayer& other);

// Setters
void setName(const TString& name_) { name = name_; }
void setRadius(float r_) { r = r_; }
void setZ(float z_) { z = z_; }
void setRadiationLength(float x0_) { x0 = x0_; }
void setDensity(float xrho_) { xrho = xrho_; }
void setResolutionRPhi(float resRPhi_) { resRPhi = resRPhi_; }
void setResolutionZ(float resZ_) { resZ = resZ_; }
void setEfficiency(float eff_) { eff = eff_; }
void setType(int type_) { type = type_; }
void setName(const TString& name) { mName = name; }
void setRadius(float r) { mR = r; }
void setZ(float z) { mZ = z; }
void setRadiationLength(float x0) { mX0 = x0; }
void setDensity(float xrho) { mXrho = xrho; }
void setResolutionRPhi(float resRPhi) { mResRPhi = resRPhi; }
void setResolutionZ(float resZ) { mResZ = resZ; }
void setEfficiency(float eff) { mEff = eff; }
void setType(int type) { mType = type; }

// Dead areas

Expand All @@ -60,21 +60,24 @@ struct DetLayer {
void setDeadPhiRegions(TGraph* graph);

// Getters
float getRadius() const { return r; }
float getZ() const { return z; }
float getRadiationLength() const { return x0; }
float getDensity() const { return xrho; }
float getResolutionRPhi() const { return resRPhi; }
float getResolutionZ() const { return resZ; }
float getEfficiency() const { return eff; }
int getType() const { return type; }
const TString& getName() const { return name; }
float getRadius() const { return mR; }
float getZ() const { return mZ; }
float getRadiationLength() const { return mX0; }
float getDensity() const { return mXrho; }
float getResolutionRPhi() const { return mResRPhi; }
float getResolutionZ() const { return mResZ; }
float getEfficiency() const { return mEff; }
int getType() const { return mType; }
const TString& getName() const { return mName; }
const TGraph* getDeadPhiRegions() const { return mDeadPhiRegions; }

// Check layer type
bool isInert() const { return type == layerInert; }
bool isSilicon() const { return type == layerSilicon; }
bool isGas() const { return type == layerGas; }
// Check layer mType
bool isInert() const { return mType == kLayerInert; }
bool isSilicon() const { return mType == kLayerSilicon; }
bool isGas() const { return mType == kLayerGas; }
bool isTOF() const { return mType == kLayerTOF; }
bool isVertex() const { return mType == kLayerVertex; }
bool isActive() const { return mType != kLayerInert; } // active layers are not inert

// Utilities
std::string toString() const;
Expand All @@ -93,33 +96,36 @@ struct DetLayer {
return mDeadPhiRegions->Eval(phi) > 1.f;
};

static constexpr int kLayerVertex = -1; // vertex layer type (not used in tracking)
static constexpr int kLayerInert = 0; // inert/undefined layer
static constexpr int kLayerSilicon = 1; // silicon layer
static constexpr int kLayerGas = 2; // gas/tpc layer
static constexpr int kLayerTOF = 3; // TOF layer type (not used in tracking)

private:
// TString for holding name
TString name;
TString mName;

// position variables
float r; // radius in centimeters
float z; // z dimension in centimeters
float mR; // radius in centimeters
float mZ; // mZ dimension in centimeters

// material variables
float x0; // radiation length
float xrho; // density
float mX0; // radiation length
float mXrho; // density

// resolution variables for active layers
float resRPhi; // RPhi resolution in centimeters
float resZ; // Z resolution in centimeters
float mResRPhi; // RPhi resolution in centimeters
float mResZ; // Z resolution in centimeters

// efficiency
float eff; // detection efficiency
float mEff; // detection efficiency

// dead regions in phi (in radians)
TGraph* mDeadPhiRegions = nullptr;

// layer type
int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc
static constexpr int layerInert = 0; // inert/undefined layer
static constexpr int layerSilicon = 1; // silicon layer
static constexpr int layerGas = 2; // gas/tpc layer
int mType; // 0: undefined/inert, 1: silicon, 2: gas/tpc
};

} // namespace o2::fastsim
Expand Down
Loading