Skip to content

Commit

Permalink
Add new definition for the efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
preghenella committed Aug 1, 2021
1 parent fe461f8 commit bb9b798
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
2 changes: 2 additions & 0 deletions examples/smearing/lutRead.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
enum EWhat {
kEfficiency,
kEfficiency2,
kEfficiencyInnerTOF,
kEfficiencyOuterTOF,
kPtResolution,
Expand Down Expand Up @@ -44,6 +45,7 @@ lutRead(int pdg, const char *filename, int what, int vs, float nch = 0., float r
if (vs == kPt) cen = lutEntry->pt;
double val = 0.;
if (what == kEfficiency) val = lutEntry->eff * 100.; // efficiency (%)
if (what == kEfficiency2) val = lutEntry->eff2 * 100.; // efficiency (%)
if (what == kEfficiencyInnerTOF) val = lutEntry->itof * 100.; // efficiency (%)
if (what == kEfficiencyOuterTOF) val = lutEntry->otof * 100.; // efficiency (%)
if (what == kPtResolution) val = sqrt(lutEntry->covm[14]) * lutEntry->pt * 100.; // pt resolution (%)
Expand Down
9 changes: 7 additions & 2 deletions src/TrackSmearer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ bool
TrackSmearer::smearTrack(O2Track &o2track, lutEntry_t *lutEntry)
{
// generate efficiency
if (mUseEfficiency && (gRandom->Uniform() > lutEntry->eff))
return false;
if (mUseEfficiency) {
auto eff = 0.;
if (mWhatEfficiency == 1) eff = lutEntry->eff;
if (mWhatEfficiency == 2) eff = lutEntry->eff2;
if (gRandom->Uniform() > eff)
return false;
}
// transform params vector and smear
double params_[5];
for (int i = 0; i < 5; ++i) {
Expand Down
2 changes: 2 additions & 0 deletions src/TrackSmearer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public:
/** LUT methods **/
bool loadTable(int pdg, const char *filename, bool forceReload = false);
void useEfficiency(bool val) { mUseEfficiency = 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);

Expand Down Expand Up @@ -53,6 +54,7 @@ protected:
lutHeader_t *mLUTHeader[nLUTs] = {nullptr};
lutEntry_t *****mLUTEntry[nLUTs] = {nullptr};
bool mUseEfficiency = true;
int mWhatEfficiency = 1;
float mdNdEta = 1600.;

};
Expand Down
3 changes: 2 additions & 1 deletion src/lutCovm.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// @email: [email protected]

#pragma once
#define LUTCOVM_VERSION 20210731
#define LUTCOVM_VERSION 20210801

struct map_t {
int nbins = 1;
Expand Down Expand Up @@ -56,6 +56,7 @@ struct lutEntry_t {
float pt = 0.;
bool valid = false;
float eff = 0.;
float eff2 = 0.;
float itof = 0.;
float otof = 0.;
float covm[15] = {0.};
Expand Down
23 changes: 21 additions & 2 deletions src/lutWrite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,28 @@ fatSolve(lutEntry_t &lutEntry, float pt = 0.1, float eta = 0.0, float mass = 0.1
if (!trPtr) return false;

lutEntry.valid = true;
lutEntry.eff = fat.GetGoodHitProb(0);
lutEntry.itof = fat.GetGoodHitProb(itof);
lutEntry.otof = fat.GetGoodHitProb(otof);
for (int i = 0; i < 15; ++i) lutEntry.covm[i] = trPtr->GetCovariance()[i];


// define the efficiency
auto totfake = 0.;
lutEntry.eff = 1.;
for (int i = 1; i < 20; ++i) {
auto igoodhit = fat.GetGoodHitProb(i);
if (igoodhit <= 0. || i == itof || i == otof) continue;
lutEntry.eff *= igoodhit;
auto pairfake = 0.;
for (int j = i + 1; j < 20; ++j) {
auto jgoodhit = fat.GetGoodHitProb(j);
if (jgoodhit <= 0. || j == itof || j == otof) continue;
pairfake = (1. - igoodhit) * (1. - jgoodhit);
break;
}
totfake += pairfake;
}
lutEntry.eff2 = (1. - totfake);

return true;
}

Expand Down Expand Up @@ -164,13 +181,15 @@ lutWrite(const char *filename = "lutCovm.dat", int pdg = 211, float field = 0.2,
// printf(" --- fatSolve: error \n");
lutEntry.valid = false;
lutEntry.eff = 0.;
lutEntry.eff2 = 0.;
for (int i = 0; i < 15; ++i)
lutEntry.covm[i] = 0.;
}
}
else {
// printf(" --- fwdSolve: pt = %f, eta = %f, mass = %f, field=%f \n", lutEntry.pt, lutEntry.eta, lutHeader.mass, lutHeader.field);
lutEntry.eff = 1.;
lutEntry.eff2 = 1.;
bool retval = true;
if (usePara) {
retval = fwdPara(lutEntry, lutEntry.pt, lutEntry.eta, lutHeader.mass, field);
Expand Down

0 comments on commit bb9b798

Please sign in to comment.