Skip to content
Merged
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
40 changes: 29 additions & 11 deletions PWGEM/Dilepton/Tasks/smearing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,30 @@
MomentumSmearer smearer_StandaloneMuon;
MomentumSmearer smearer_GlobalMuon;
Service<ccdb::BasicCCDBManager> ccdb;
int mRunNumber{0};

void init(InitContext&)
{
mRunNumber = 0;
if (fTimestamp < 0) {
LOG(fatal) << "Don't use time stamp = -1";
}
if (doprocessCocktail) {
initResolutionMap(fTimestamp);
}
}

template <typename TBC>
void initCCDB(TBC const& bc)
{
if (mRunNumber == bc.runNumber()) {
return;
}
initResolutionMap(bc.timestamp());
mRunNumber = bc.runNumber();
}

void initResolutionMap(const int64_t timestamp)
{
smearer_Electron.setNDSmearing(electron_filenames.fConfigNDSmearing.value);
smearer_Electron.setResFileName(TString(electron_filenames.fConfigResFileName));
Expand Down Expand Up @@ -180,19 +202,19 @@
smearer_Electron.setCcdbPathRes(TString(electron_filenames.fConfigCcdbPathRes));
smearer_Electron.setCcdbPathEff(TString(electron_filenames.fConfigCcdbPathEff));
smearer_Electron.setCcdbPathDCA(TString(electron_filenames.fConfigCcdbPathDCA));
smearer_Electron.setTimestamp(fTimestamp);
smearer_Electron.setTimestamp(timestamp);
smearer_Electron.setCcdb(ccdb);

smearer_StandaloneMuon.setCcdbPathRes(TString(sa_muon_filenames.fConfigCcdbPathRes));
smearer_StandaloneMuon.setCcdbPathEff(TString(sa_muon_filenames.fConfigCcdbPathEff));
smearer_StandaloneMuon.setCcdbPathDCA(TString(sa_muon_filenames.fConfigCcdbPathDCA));
smearer_StandaloneMuon.setTimestamp(fTimestamp);
smearer_StandaloneMuon.setTimestamp(timestamp);
smearer_StandaloneMuon.setCcdb(ccdb);

smearer_GlobalMuon.setCcdbPathRes(TString(gl_muon_filenames.fConfigCcdbPathRes));
smearer_GlobalMuon.setCcdbPathEff(TString(gl_muon_filenames.fConfigCcdbPathEff));
smearer_GlobalMuon.setCcdbPathDCA(TString(gl_muon_filenames.fConfigCcdbPathDCA));
smearer_GlobalMuon.setTimestamp(fTimestamp);
smearer_GlobalMuon.setTimestamp(timestamp);
smearer_GlobalMuon.setCcdb(ccdb);
}
smearer_Electron.init();
Expand All @@ -203,7 +225,7 @@
template <o2::aod::pwgem::dilepton::smearing::EMAnaType type, typename TTracksMC, typename TCollisions, typename TMCCollisions>
void applySmearing(TTracksMC const& tracksMC, TCollisions const& collisions, TMCCollisions const&)
{
for (auto& mctrack : tracksMC) {
for (const auto& mctrack : tracksMC) {
float ptgen = mctrack.pt();
float etagen = mctrack.eta();
float phigen = mctrack.phi();
Expand All @@ -227,7 +249,7 @@
}

int pdgCode = mctrack.pdgCode();
if (std::abs(pdgCode) == 11) {

Check failure on line 252 in PWGEM/Dilepton/Tasks/smearing.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.

Check failure on line 252 in PWGEM/Dilepton/Tasks/smearing.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
int ch = -1;
if (pdgCode < 0) {
ch = 1;
Expand All @@ -241,7 +263,7 @@
// fill the table
smearedelectron(ptsmeared, etasmeared, phismeared, efficiency, dca);
smearedmuon(ptgen, etagen, phigen, 1.f, 0.f, ptgen, etagen, phigen, 1.f, 0.f);
} else if (std::abs(pdgCode) == 13) {

Check failure on line 266 in PWGEM/Dilepton/Tasks/smearing.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.

Check failure on line 266 in PWGEM/Dilepton/Tasks/smearing.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
int ch = -1;
if (pdgCode < 0) {
ch = 1;
Expand Down Expand Up @@ -269,14 +291,10 @@

void processMCanalysisEM(aod::EMMCParticles const& tracksMC, MyCollisions const& collisions, MyMCCollisions const& mccollisions)
{
initCCDB(collisions.iteratorAt(0));
applySmearing<o2::aod::pwgem::dilepton::smearing::EMAnaType::kEfficiency>(tracksMC, collisions, mccollisions);
}

// void processMCanalysisDQ(ReducedMCTracks const& tracksMC)
// {
// applySmearing<EMAnaType::kEfficiency>(tracksMC);
// }

void processCocktail(aod::McParticles const& tracksMC)
{
applySmearing<o2::aod::pwgem::dilepton::smearing::EMAnaType::kCocktail>(tracksMC, nullptr, nullptr);
Expand All @@ -285,12 +303,12 @@
void processDummyCocktail(aod::McParticles const& tracksMC)
{
// don't apply smearing
for (auto& mctrack : tracksMC) {
for (const auto& mctrack : tracksMC) {
int pdgCode = mctrack.pdgCode();
if (std::abs(pdgCode) == 11) {

Check failure on line 308 in PWGEM/Dilepton/Tasks/smearing.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.

Check failure on line 308 in PWGEM/Dilepton/Tasks/smearing.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
smearedelectron(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0);
smearedmuon(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0, mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0);
} else if (std::abs(pdgCode) == 13) {

Check failure on line 311 in PWGEM/Dilepton/Tasks/smearing.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.

Check failure on line 311 in PWGEM/Dilepton/Tasks/smearing.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
smearedelectron(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0);
smearedmuon(mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0, mctrack.pt(), mctrack.eta(), mctrack.phi(), 1.0, 0.0);
} else {
Expand Down Expand Up @@ -356,7 +374,7 @@
template <o2::aod::pwgem::dilepton::smearing::EMAnaType type, typename TTracksMC, typename TMCCollisions>
void Check(TTracksMC const& tracksMC, TMCCollisions const&)
{
for (auto& mctrack : tracksMC) {
for (const auto& mctrack : tracksMC) {
if (std::abs(mctrack.pdgCode()) != fPdgCode) {
continue;
}
Expand All @@ -368,7 +386,7 @@
}
}

if (std::abs(mctrack.pdgCode()) == 11) { // for electrons

Check failure on line 389 in PWGEM/Dilepton/Tasks/smearing.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
float deltaptoverpt = -1000.f;
if (mctrack.pt() > 0.f) {
deltaptoverpt = (mctrack.pt() - mctrack.ptSmeared()) / mctrack.pt();
Expand All @@ -385,7 +403,7 @@
registry.fill(HIST("Electron/hCorrelation_Pt"), mctrack.pt(), mctrack.ptSmeared());
registry.fill(HIST("Electron/hCorrelation_Eta"), mctrack.eta(), mctrack.etaSmeared());
registry.fill(HIST("Electron/hCorrelation_Phi"), mctrack.phi(), mctrack.phiSmeared());
} else if (std::abs(mctrack.pdgCode()) == 13) { // for muons

Check failure on line 406 in PWGEM/Dilepton/Tasks/smearing.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[pdg/explicit-code]

Avoid hard-coded PDG codes. Use named values from PDG_t or o2::constants::physics::Pdg instead.
float deltaptoverpt = -1000.f;
// for standalone muons
if (mctrack.pt() > 0.f) {
Expand Down
Loading