Skip to content

Commit 380cc54

Browse files
committed
A3: update protection of DetLayer
- add minor utilities
1 parent f6732b5 commit 380cc54

File tree

7 files changed

+250
-46
lines changed

7 files changed

+250
-46
lines changed

ALICE3/Core/DelphesO2LutWriter.cxx

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "iostream"
2727
#include "TMatrixD.h"
2828
#include "TVectorD.h"
29+
#include "TAxis.h"
2930
#include "TMatrixDSymEigen.h"
3031
#include "TDatabasePDG.h"
3132
#include "TLorentzVector.h"
@@ -55,17 +56,18 @@ bool DelphesO2LutWriter::fatSolve(lutEntry_t& lutEntry,
5556
const float mass,
5657
int itof,
5758
int otof,
58-
int q)
59+
int q,
60+
const float nch)
5961
{
6062
lutEntry.valid = false;
6163

6264
static TLorentzVector tlv;
6365
tlv.SetPtEtaPhiM(pt, eta, 0., mass);
6466
o2::track::TrackParCov trkIn;
6567
o2::upgrade::convertTLorentzVectorToO2Track(q, tlv, {0., 0., 0.}, trkIn);
66-
6768
o2::track::TrackParCov trkOut;
68-
if (fat.FastTrack(trkIn, trkOut, 1) < 0) {
69+
const int status = fat.FastTrack(trkIn, trkOut, nch);
70+
if (status <= 0) {
6971
Printf(" --- fatSolve: FastTrack failed --- \n");
7072
tlv.Print();
7173
return false;
@@ -234,6 +236,9 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, in
234236
lutEntry_t lutEntry;
235237

236238
// write entries
239+
int nCalls = 0;
240+
int successfullCalls = 0;
241+
int failedCalls = 0;
237242
for (int inch = 0; inch < nnch; ++inch) {
238243
Printf(" --- writing nch = %d/%d", inch, nnch);
239244
auto nch = lutHeader.nchmap.eval(inch);
@@ -242,6 +247,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, in
242247
for (int irad = 0; irad < nrad; ++irad) {
243248
Printf(" --- writing irad = %d/%d", irad, nrad);
244249
for (int ieta = 0; ieta < neta; ++ieta) {
250+
nCalls++;
245251
Printf(" --- writing ieta = %d/%d", ieta, neta);
246252
auto eta = lutHeader.etamap.eval(ieta);
247253
lutEntry.eta = lutHeader.etamap.eval(ieta);
@@ -252,6 +258,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, in
252258
if (std::fabs(eta) <= etaMaxBarrel) { // full lever arm ends at etaMaxBarrel
253259
Printf("Solving in the barrel");
254260
// printf(" --- fatSolve: pt = %f, eta = %f, mass = %f, field=%f \n", lutEntry.pt, lutEntry.eta, lutHeader.mass, lutHeader.field);
261+
successfullCalls++;
255262
if (!fatSolve(lutEntry, lutEntry.pt, lutEntry.eta, lutHeader.mass, itof, otof, q)) {
256263
// printf(" --- fatSolve: error \n");
257264
lutEntry.valid = false;
@@ -260,13 +267,16 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, in
260267
for (int i = 0; i < 15; ++i) {
261268
lutEntry.covm[i] = 0.;
262269
}
270+
successfullCalls--;
271+
failedCalls++;
263272
}
264273
} else {
265274
Printf("Solving outside the barrel");
266275
// printf(" --- fwdSolve: pt = %f, eta = %f, mass = %f, field=%f \n", lutEntry.pt, lutEntry.eta, lutHeader.mass, lutHeader.field);
267276
lutEntry.eff = 1.;
268277
lutEntry.eff2 = 1.;
269278
bool retval = true;
279+
successfullCalls++;
270280
if (useFlatDipole) { // Using the parametrization at the border of the barrel
271281
retval = fatSolve(lutEntry, lutEntry.pt, etaMaxBarrel, lutHeader.mass, itof, otof, q);
272282
} else if (usePara) {
@@ -288,6 +298,8 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, in
288298
for (int i = 0; i < 15; ++i) {
289299
lutEntry.covm[i] = 0.;
290300
}
301+
successfullCalls--;
302+
failedCalls++;
291303
}
292304
}
293305
Printf("Diagonalizing");
@@ -298,6 +310,8 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, in
298310
}
299311
}
300312
}
313+
Printf(" --- finished writing LUT file %s", filename);
314+
Printf(" --- successfull calls: %d/%d, failed calls: %d/%d", successfullCalls, nCalls, failedCalls, nCalls);
301315
lutFile.close();
302316
}
303317

@@ -331,10 +345,13 @@ void DelphesO2LutWriter::diagonalise(lutEntry_t& lutEntry)
331345

332346
TGraph* DelphesO2LutWriter::lutRead(const char* filename, int pdg, int what, int vs, float nch, float radius, float eta, float pt)
333347
{
348+
Printf(" --- reading LUT file %s", filename);
349+
// vs
334350
static const int kNch = 0;
335351
static const int kEta = 1;
336352
static const int kPt = 2;
337353

354+
// what
338355
static const int kEfficiency = 0;
339356
static const int kEfficiency2 = 1;
340357
static const int kEfficiencyInnerTOF = 2;
@@ -360,6 +377,58 @@ TGraph* DelphesO2LutWriter::lutRead(const char* filename, int pdg, int what, int
360377
}
361378
auto nbins = lutMap.nbins;
362379
auto g = new TGraph();
380+
g->SetName(Form("lut_%s_%d_vs_%d_what_%d", filename, pdg, vs, what));
381+
g->SetTitle(Form("LUT for %s, pdg %d, vs %d, what %d", filename, pdg, vs, what));
382+
switch (vs) {
383+
case kNch:
384+
Printf(" --- vs = kNch");
385+
g->GetXaxis()->SetTitle("Nch");
386+
break;
387+
case kEta:
388+
Printf(" --- vs = kEta");
389+
g->GetXaxis()->SetTitle("#eta");
390+
break;
391+
case kPt:
392+
Printf(" --- vs = kPt");
393+
g->GetXaxis()->SetTitle("p_{T} (GeV/c)");
394+
break;
395+
default:
396+
Printf(" --- error: unknown vs %d", vs);
397+
return nullptr;
398+
}
399+
switch (what) {
400+
case kEfficiency:
401+
Printf(" --- what = kEfficiency");
402+
g->GetYaxis()->SetTitle("Efficiency (%)");
403+
break;
404+
case kEfficiency2:
405+
Printf(" --- what = kEfficiency2");
406+
g->GetYaxis()->SetTitle("Efficiency2 (%)");
407+
break;
408+
case kEfficiencyInnerTOF:
409+
Printf(" --- what = kEfficiencyInnerTOF");
410+
g->GetYaxis()->SetTitle("Inner TOF Efficiency (%)");
411+
break;
412+
case kEfficiencyOuterTOF:
413+
Printf(" --- what = kEfficiencyOuterTOF");
414+
g->GetYaxis()->SetTitle("Outer TOF Efficiency (%)");
415+
break;
416+
case kPtResolution:
417+
Printf(" --- what = kPtResolution");
418+
g->GetYaxis()->SetTitle("p_{T} Resolution (%)");
419+
break;
420+
case kRPhiResolution:
421+
Printf(" --- what = kRPhiResolution");
422+
g->GetYaxis()->SetTitle("R#phi Resolution (#mum)");
423+
break;
424+
case kZResolution:
425+
Printf(" --- what = kZResolution");
426+
g->GetYaxis()->SetTitle("Z Resolution (#mum)");
427+
break;
428+
default:
429+
Printf(" --- error: unknown what %d", what);
430+
return nullptr;
431+
}
363432

364433
bool canBeInvalid = true;
365434
for (int i = 0; i < nbins; ++i) {

ALICE3/Core/DelphesO2LutWriter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class DelphesO2LutWriter
5555
const float mass = 0.13957000,
5656
int itof = 0,
5757
int otof = 0,
58-
int q = 1);
58+
int q = 1,
59+
const float nch = 1);
5960
bool fwdSolve(float* covm, float pt = 0.1, float eta = 0.0, float mass = 0.13957000);
6061
bool fwdPara(lutEntry_t& lutEntry, float pt = 0.1, float eta = 0.0, float mass = 0.13957000, float Bfield = 0.5);
6162
void lutWrite(const char* filename = "lutCovm.dat", int pdg = 211, float field = 0.2, int itof = 0, int otof = 0);

ALICE3/Core/DetLayer.cxx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,76 @@
1616
/// \brief Basic struct to hold information regarding a detector layer to be used in fast simulation
1717
///
1818

19+
#include <vector>
20+
#include <string>
21+
1922
#include "DetLayer.h"
23+
24+
namespace o2::fastsim
25+
{
26+
27+
// Parametric constructor
28+
DetLayer::DetLayer(const TString& name_,
29+
float r_,
30+
float z_,
31+
float x0_,
32+
float xrho_,
33+
float resRPhi_,
34+
float resZ_,
35+
float eff_,
36+
int type_)
37+
: name(name_),
38+
r(r_),
39+
z(z_),
40+
x0(x0_),
41+
xrho(xrho_),
42+
resRPhi(resRPhi_),
43+
resZ(resZ_),
44+
eff(eff_),
45+
type(type_)
46+
{
47+
}
48+
49+
DetLayer::DetLayer(const DetLayer& other)
50+
: 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)
51+
{
52+
}
53+
54+
std::string DetLayer::toString() const
55+
{
56+
std::string out = "";
57+
out.append("DetLayer: ");
58+
out.append(name.Data());
59+
out.append(" | r: ");
60+
out.append(std::to_string(r));
61+
out.append(" cm | z: ");
62+
out.append(std::to_string(z));
63+
out.append(" cm | x0: ");
64+
out.append(std::to_string(x0));
65+
out.append(" cm | xrho: ");
66+
out.append(std::to_string(xrho));
67+
out.append(" g/cm^3 | resRPhi: ");
68+
out.append(std::to_string(resRPhi));
69+
out.append(" cm | resZ: ");
70+
out.append(std::to_string(resZ));
71+
out.append(" cm | eff: ");
72+
out.append(std::to_string(eff));
73+
out.append(" | type: ");
74+
switch (type) {
75+
case layerInert:
76+
out.append("Inert");
77+
break;
78+
case layerSilicon:
79+
out.append("Silicon");
80+
break;
81+
case layerGas:
82+
out.append("Gas/TPC");
83+
break;
84+
default:
85+
out.append("Unknown");
86+
break;
87+
}
88+
return out;
89+
}
90+
91+
} // namespace o2::fastsim

ALICE3/Core/DetLayer.h

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,59 @@
1919
#ifndef ALICE3_CORE_DETLAYER_H_
2020
#define ALICE3_CORE_DETLAYER_H_
2121

22+
#include <string>
23+
2224
#include "TString.h"
2325

2426
namespace o2::fastsim
2527
{
2628

2729
struct DetLayer {
30+
public:
31+
// Default constructor
32+
DetLayer() = default;
33+
// Parametric constructor
34+
DetLayer(const TString& name_, float r_, float z_, float x0_, float xrho_,
35+
float resRPhi_ = 0.0f, float resZ_ = 0.0f, float eff_ = 0.0f, int type_ = layerInert);
36+
// Copy constructor
37+
DetLayer(const DetLayer& other);
38+
39+
// Setters
40+
void setName(const TString& name_) { name = name_; }
41+
void setRadius(float r_) { r = r_; }
42+
void setZ(float z_) { z = z_; }
43+
void setRadiationLength(float x0_) { x0 = x0_; }
44+
void setDensity(float xrho_) { xrho = xrho_; }
45+
void setResolutionRPhi(float resRPhi_) { resRPhi = resRPhi_; }
46+
void setResolutionZ(float resZ_) { resZ = resZ_; }
47+
void setEfficiency(float eff_) { eff = eff_; }
48+
void setType(int type_) { type = type_; }
49+
50+
// Getters
51+
float getRadius() const { return r; }
52+
float getZ() const { return z; }
53+
float getRadiationLength() const { return x0; }
54+
float getDensity() const { return xrho; }
55+
float getResolutionRPhi() const { return resRPhi; }
56+
float getResolutionZ() const { return resZ; }
57+
float getEfficiency() const { return eff; }
58+
int getType() const { return type; }
59+
const TString& getName() const { return name; }
60+
61+
// Check layer type
62+
bool isInert() const { return type == layerInert; }
63+
bool isSilicon() const { return type == layerSilicon; }
64+
bool isGas() const { return type == layerGas; }
65+
66+
// Utilities
67+
std::string toString() const;
68+
friend std::ostream& operator<<(std::ostream& os, const DetLayer& layer)
69+
{
70+
os << layer.toString();
71+
return os;
72+
}
73+
74+
private:
2875
// TString for holding name
2976
TString name;
3077

@@ -44,7 +91,10 @@ struct DetLayer {
4491
float eff; // detection efficiency
4592

4693
// layer type
47-
int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc
94+
int type; // 0: undefined/inert, 1: silicon, 2: gas/tpc
95+
static constexpr int layerInert = 0; // inert/undefined layer
96+
static constexpr int layerSilicon = 1; // silicon layer
97+
static constexpr int layerGas = 2; // gas/tpc layer
4898
};
4999

50100
} // namespace o2::fastsim

0 commit comments

Comments
 (0)