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
31 changes: 16 additions & 15 deletions ALICE3/Core/DelphesO2TrackSmearer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,13 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)

/*****************************************************************/

lutEntry_t*
TrackSmearer::getLUTEntry(int pdg, float nch, float radius, float eta, float pt, float& interpolatedEff)
lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, const float radius, const float eta, const float pt, float& interpolatedEff)
{
auto ipdg = getIndexPDG(pdg);
if (!mLUTHeader[ipdg])
const int ipdg = getIndexPDG(pdg);
if (!mLUTHeader[ipdg]) {
LOG(error) << " --- getLUTEntry: LUT header not loaded for pdg=" << pdg << ". Returning nullptr.";
return nullptr;
}
auto inch = mLUTHeader[ipdg]->nchmap.find(nch);
auto irad = mLUTHeader[ipdg]->radmap.find(radius);
auto ieta = mLUTHeader[ipdg]->etamap.find(eta);
Expand Down Expand Up @@ -290,56 +291,56 @@ bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch)
}
auto eta = o2track.getEta();
float interpolatedEff = 0.0f;
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff);
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, interpolatedEff);
if (!lutEntry || !lutEntry->valid)
return false;
return smearTrack(o2track, lutEntry, interpolatedEff);
}

/*****************************************************************/
// relative uncertainty on pt
double TrackSmearer::getPtRes(int pdg, float nch, float eta, float pt)
double TrackSmearer::getPtRes(const int pdg, const float nch, const float eta, const float pt)
{
float dummy = 0.0f;
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt;
return val;
}

/*****************************************************************/
// relative uncertainty on eta
double TrackSmearer::getEtaRes(int pdg, float nch, float eta, float pt)
double TrackSmearer::getEtaRes(const int pdg, const float nch, const float eta, const float pt)
{
float dummy = 0.0f;
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2
auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
etaRes /= lutEntry->eta; // relative uncertainty
return etaRes;
}
/*****************************************************************/
// absolute uncertainty on pt
double TrackSmearer::getAbsPtRes(int pdg, float nch, float eta, float pt)
double TrackSmearer::getAbsPtRes(const int pdg, const float nch, const float eta, const float pt)
{
float dummy = 0.0f;
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
auto val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt * lutEntry->pt;
return val;
}

/*****************************************************************/
// absolute uncertainty on eta
double TrackSmearer::getAbsEtaRes(int pdg, float nch, float eta, float pt)
double TrackSmearer::getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt)
{
float dummy = 0.0f;
auto lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
lutEntry_t* lutEntry = getLUTEntry(pdg, nch, 0., eta, pt, dummy);
auto sigmatgl = std::sqrt(lutEntry->covm[9]); // sigmatgl2
auto etaRes = std::fabs(std::sin(2.0 * std::atan(std::exp(-eta)))) * sigmatgl; // propagate tgl to eta uncertainty
return etaRes;
}
/*****************************************************************/
// efficiency
double TrackSmearer::getEfficiency(int pdg, float nch, float eta, float pt)
double TrackSmearer::getEfficiency(const int pdg, const float nch, const float eta, const float pt)
{
float efficiency = 0.0f;
getLUTEntry(pdg, nch, 0., eta, pt, efficiency);
Expand All @@ -360,7 +361,7 @@ double TrackSmearer::getEfficiency(int pdg, float nch, float eta, float pt)
// return true;

// #if 0
// auto lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
// lutEntry_t* lutEntry = getLUTEntry(track.PID, 0., 0., track.Eta, track.PT);
// if (!lutEntry)
// return;

Expand Down
25 changes: 13 additions & 12 deletions ALICE3/Core/DelphesO2TrackSmearer.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <cstdio>
#include <fstream>
#include <iostream>

Check failure on line 34 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <map>

///////////////////////////////
Expand All @@ -54,7 +54,7 @@
float width = (max - min) / nbins;
float val = min + (bin + 0.5) * width;
if (log)
return pow(10., val);

Check failure on line 57 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
return val;
}
// function needed to interpolate some dimensions
Expand All @@ -64,8 +64,8 @@
int bin;
float returnVal = 0.5f;
if (log) {
bin = static_cast<int>((log10(val) - min) / width);

Check failure on line 67 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
returnVal = ((log10(val) - min) / width) - bin;

Check failure on line 68 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
} else {
bin = static_cast<int>((val - min) / width);
returnVal = val / width - bin;
Expand All @@ -78,7 +78,7 @@
float width = (max - min) / nbins;
int bin;
if (log)
bin = static_cast<int>((log10(val) - min) / width); // Changed due to MegaLinter error.

Check failure on line 81 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
// bin = (int)((log10(val) - min) / width); // Original line.
else
bin = static_cast<int>((val - min) / width); // Changed due to MegaLinter error.
Expand Down Expand Up @@ -107,9 +107,9 @@
} //;
void print()
{
printf(" version: %d \n", version);

Check failure on line 110 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
printf(" pdg: %d \n", pdg);

Check failure on line 111 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
printf(" field: %f \n", field);

Check failure on line 112 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
printf(" nchmap: ");
nchmap.print();
printf(" radmap: ");
Expand Down Expand Up @@ -180,25 +180,26 @@

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

bool smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float interpolatedEff);
bool smearTrack(O2Track& o2track, int pdg, float nch);
// bool smearTrack(Track& track, bool atDCA = true); // Only in DelphesO2
double getPtRes(int pdg, float nch, float eta, float pt);
double getEtaRes(int pdg, float nch, float eta, float pt);
double getAbsPtRes(int pdg, float nch, float eta, float pt);
double getAbsEtaRes(int pdg, float nch, float eta, float pt);
double getEfficiency(int pdg, float nch, float eta, float pt);
double getPtRes(const int pdg, const float nch, const float eta, const float pt);
double getEtaRes(const int pdg, const float nch, const float eta, const float pt);
double getAbsPtRes(const int pdg, const float nch, const float eta, const float pt);
double getAbsEtaRes(const int pdg, const float nch, const float eta, const float pt);
double getEfficiency(const int pdg, const float nch, const float eta, const float pt);

int getIndexPDG(int pdg)
int getIndexPDG(const int pdg)
{
switch (abs(pdg)) {

Check failure on line 202 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
case 11:
return 0; // Electron
case 13:
Expand All @@ -224,7 +225,7 @@

const char* getParticleName(int pdg)
{
switch (abs(pdg)) {

Check failure on line 228 in ALICE3/Core/DelphesO2TrackSmearer.h

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
case 11:
return "electron";
case 13:
Expand Down
Loading
Loading