Skip to content

Commit 5b9b9a3

Browse files
authored
[ALICE3] A3 OTF: Check available LUT before smearing (#13420)
1 parent bc5950b commit 5b9b9a3

File tree

4 files changed

+122
-92
lines changed

4 files changed

+122
-92
lines changed

ALICE3/Core/DelphesO2TrackSmearer.cxx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,13 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
153153

154154
/*****************************************************************/
155155

156-
lutEntry_t*
157-
TrackSmearer::getLUTEntry(int pdg, float nch, float radius, float eta, float pt, float& interpolatedEff)
156+
lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff)
158157
{
159-
auto ipdg = getIndexPDG(pdg);
160-
if (!mLUTHeader[ipdg])
158+
const int ipdg = getIndexPDG(pdg);
159+
if (!mLUTHeader[ipdg]) {
160+
LOG(error) << " --- getLUTEntry: LUT header not loaded for pdg=" << pdg << ". Returning nullptr.";
161161
return nullptr;
162+
}
162163
auto inch = mLUTHeader[ipdg]->nchmap.find(nch);
163164
auto irad = mLUTHeader[ipdg]->radmap.find(radius);
164165
auto ieta = mLUTHeader[ipdg]->etamap.find(eta);
@@ -290,56 +291,56 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch)
290291
}
291292
auto eta = o2track.getEta();
292293
float interpolatedEff = 0.0f;
293-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff);
294+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff);
294295
if (!lutEntry || !lutEntry->valid)
295296
return false;
296297
return smearTrack(o2track, lutEntry, interpolatedEff);
297298
}
298299

299300
/*****************************************************************/
300301
// relative uncertainty on pt
301-
double TrackSmearer::getPtRes(int pdg, float nch, float eta, float pt)
302+
double TrackSmearer::getPtRes(const int pdg, const float nch, const float eta, const float pt)
302303
{
303304
float dummy = 0.0f;
304-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
305+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
305306
auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt;
306307
return val;
307308
}
308309

309310
/*****************************************************************/
310311
// relative uncertainty on eta
311-
double TrackSmearer::getEtaRes(int pdg, float nch, float eta, float pt)
312+
double TrackSmearer::getEtaRes(const int pdg, const float nch, const float eta, const float pt)
312313
{
313314
float dummy = 0.0f;
314-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
315+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
315316
auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2
316317
auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
317318
etaRes /= lutEntry->eta; // relative uncertainty
318319
return etaRes;
319320
}
320321
/*****************************************************************/
321322
// absolute uncertainty on pt
322-
double TrackSmearer::getAbsPtRes(int pdg, float nch, float eta, float pt)
323+
double TrackSmearer::getAbsPtRes(const int pdg, const float nch, const float eta, const float pt)
323324
{
324325
float dummy = 0.0f;
325-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
326+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
326327
auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt * lutEntry->pt;
327328
return val;
328329
}
329330

330331
/*****************************************************************/
331332
// absolute uncertainty on eta
332-
double TrackSmearer::getAbsEtaRes(int pdg, float nch, float eta, float pt)
333+
double TrackSmearer::getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt)
333334
{
334335
float dummy = 0.0f;
335-
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
336+
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
336337
auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2
337338
auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
338339
return etaRes;
339340
}
340341
/*****************************************************************/
341342
// efficiency
342-
double TrackSmearer::getEfficiency(int pdg, float nch, float eta, float pt)
343+
double TrackSmearer::getEfficiency(const int pdg, const float nch, const float eta, const float pt)
343344
{
344345
float efficiency = 0.0f;
345346
getLUTEntry(pdg, nch, 0., eta, pt, efficiency);
@@ -360,7 +361,7 @@ double TrackSmearer::getEfficiency(int pdg, float nch, float eta, float pt)
360361
// return true;
361362

362363
// #if 0
363-
// auto lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
364+
// lutEntry_t* lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
364365
// if (!lutEntry)
365366
// return;
366367

ALICE3/Core/DelphesO2TrackSmearer.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,24 @@ class TrackSmearer
180180

181181
/** LUT methods **/
182182
bool loadTable(int pdg, const char* filename, bool forceReload = false);
183-
void useEfficiency(bool val) { mUseEfficiency = val; } //;
184-
void interpolateEfficiency(bool val) { mInterpolateEfficiency = val; } //;
185-
void skipUnreconstructed(bool val) { mSkipUnreconstructed = val; } //;
186-
void setWhatEfficiency(int val) { mWhatEfficiency = val; } //;
187-
lutHeader_t* getLUTHeader(int pdg) { return mLUTHeader[getIndexPDG(pdg)]; } //;
188-
lutEntry_t* getLUTEntry(int pdg, float nch, float radius, float eta, float pt, float& interpolatedEff);
183+
bool hasTable(int pdg) { return (mLUTHeader[getIndexPDG(pdg)] != nullptr); } //;
184+
void useEfficiency(bool val) { mUseEfficiency = val; } //;
185+
void interpolateEfficiency(bool val) { mInterpolateEfficiency = val; } //;
186+
void skipUnreconstructed(bool val) { mSkipUnreconstructed = val; } //;
187+
void setWhatEfficiency(int val) { mWhatEfficiency = val; } //;
188+
lutHeader_t* getLUTHeader(int pdg) { return mLUTHeader[getIndexPDG(pdg)]; } //;
189+
lutEntry_t* getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff);
189190

190191
bool smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float interpolatedEff);
191192
bool smearTrack(O2Track& o2track, int pdg, float nch);
192193
// bool smearTrack(Track& track, bool atDCA = true); // Only in DelphesO2
193-
double getPtRes(int pdg, float nch, float eta, float pt);
194-
double getEtaRes(int pdg, float nch, float eta, float pt);
195-
double getAbsPtRes(int pdg, float nch, float eta, float pt);
196-
double getAbsEtaRes(int pdg, float nch, float eta, float pt);
197-
double getEfficiency(int pdg, float nch, float eta, float pt);
194+
double getPtRes(const int pdg, const float nch, const float eta, const float pt);
195+
double getEtaRes(const int pdg, const float nch, const float eta, const float pt);
196+
double getAbsPtRes(const int pdg, const float nch, const float eta, const float pt);
197+
double getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt);
198+
double getEfficiency(const int pdg, const float nch, const float eta, const float pt);
198199

199-
int getIndexPDG(int pdg)
200+
int getIndexPDG(const int pdg)
200201
{
201202
switch (abs(pdg)) {
202203
case 11:

0 commit comments

Comments
 (0)