Skip to content
Open
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
76 changes: 40 additions & 36 deletions PWGDQ/Tasks/dqEfficiency_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include <TString.h>

#include <algorithm>
#include <iostream>

Check failure on line 50 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[include-iostream]

Do not include iostream. Use O2 logging instead.
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -253,7 +253,7 @@
void PrintBitMap(TMap map, int nbits)
{
for (int i = 0; i < nbits; i++) {
cout << ((map & (TMap(1) << i)) > 0 ? "1" : "0");

Check failure on line 256 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}

Expand Down Expand Up @@ -1325,6 +1325,7 @@
Produces<aod::DileptonsInfo> dileptonInfoList;
Produces<aod::JPsieeCandidates> PromptNonPromptSepTable;
Produces<aod::OniaMCTruth> MCTruthTableEffi;
Produces<aod::DileptonPolarization> dileptonPolarList;

o2::base::MatLayerCylSet* fLUT = nullptr;
int fCurrentRun; // needed to detect if the run changed and trigger update of calibrations etc.
Expand All @@ -1335,7 +1336,7 @@
Configurable<std::string> track{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"};
Configurable<std::string> muon{"cfgMuonCuts", "", "Comma separated list of muon cuts"};
Configurable<std::string> pair{"cfgPairCuts", "", "Comma separated list of pair cuts, !!! Use only if you know what you are doing, otherwise leave empty"};
Configurable<std::string> MCgenAcc{"cfgMCGenAccCut", "", "cut for MC generated particles acceptance"};
Configurable<std::string> MCgenAcc{"cfgMCGenAccCuts", "", "Comma separated list of MC generated particles acceptance cuts, !!! Use only if you know what you are doing, otherwise leave empty"};
// TODO: Add pair cuts via JSON
} fConfigCuts;

Expand All @@ -1354,6 +1355,7 @@
Configurable<bool> useRemoteField{"cfgUseRemoteField", false, "Chose whether to fetch the magnetic field from ccdb or set it manually"};
Configurable<float> magField{"cfgMagField", 5.0f, "Manually set magnetic field"};
Configurable<bool> flatTables{"cfgFlatTables", false, "Produce a single flat tables with all relevant information of the pairs and single tracks"};
Configurable<bool> polarTables{"cfgPolarTables", false, "Produce tables with dilepton polarization information"};
Configurable<bool> useKFVertexing{"cfgUseKFVertexing", false, "Use KF Particle for secondary vertex reconstruction (DCAFitter is used by default)"};
Configurable<bool> useAbsDCA{"cfgUseAbsDCA", false, "Use absolute DCA minimization instead of chi^2 minimization in secondary vertexing"};
Configurable<bool> propToPCA{"cfgPropToPCA", false, "Propagate tracks to secondary vertex"};
Expand Down Expand Up @@ -1396,7 +1398,7 @@
std::vector<MCSignal*> fGenMCSignals;

std::vector<AnalysisCompositeCut> fPairCuts;
AnalysisCompositeCut fMCGenAccCut;
std::vector<AnalysisCut*> fMCGenAccCuts;
bool fUseMCGenAccCut = false;

uint32_t fTrackFilterMask; // mask for the track cuts required in this task to be applied on the barrel cuts produced upstream
Expand Down Expand Up @@ -1485,16 +1487,6 @@
}
}

// get the mc generated acceptance cut
TString mcGenAccCutStr = fConfigCuts.MCgenAcc.value;
if (mcGenAccCutStr != "") {
AnalysisCut* cut = dqcuts::GetAnalysisCut(mcGenAccCutStr.Data());
if (cut != nullptr) {
fMCGenAccCut.AddCut(cut);
}
fUseMCGenAccCut = true;
}

// check that the barrel track cuts array required in this task is not empty
if (!trackCutsStr.IsNull()) {
// tokenize and loop over the barrel cuts produced by the barrel track selection task
Expand Down Expand Up @@ -1663,6 +1655,19 @@
} // end loop over cuts
} // end if (muonCutsStr)

// get the mc generated acceptance cuts
TString mcgenCutsStr = fConfigCuts.MCgenAcc.value;
if (!mcgenCutsStr.IsNull()) {
std::unique_ptr<TObjArray> objArray(mcgenCutsStr.Tokenize(","));
for (int icut = 0; icut < objArray->GetEntries(); ++icut) {
AnalysisCut* cut = dqcuts::GetAnalysisCut(objArray->At(icut)->GetName());
if (cut != nullptr) {
fMCGenAccCuts.push_back(cut);
}
}
fUseMCGenAccCut = true;
}

// Add histogram classes for each specified MCsignal at the generator level
// TODO: create a std::vector of hist classes to be used at Fill time, to avoid using Form in the process function
TString sigGenNamesStr = fConfigMC.genSignals.value;
Expand Down Expand Up @@ -1695,6 +1700,12 @@
histNames += Form("MCTruthGenPair_%s;", sig->GetName());
histNames += Form("MCTruthGenPairSel_%s;", sig->GetName());
fHasTwoProngGenMCsignals = true;
// for these pair level signals, also add histograms for each MCgenAcc cut if specified
if (fUseMCGenAccCut) {
for (auto& cut : fMCGenAccCuts) {
histNames += Form("MCTruthGenPairSel_%s_%s;", sig->GetName(), cut->GetName());
}
}
}
}
}
Expand Down Expand Up @@ -1806,6 +1817,9 @@
dileptonMiniTreeGen.reserve(1);
dileptonMiniTreeRec.reserve(1);
}
if (fConfigOptions.polarTables.value) {
dileptonPolarList.reserve(1);
}
constexpr bool eventHasQvector = ((TEventFillMap & VarManager::ObjTypes::ReducedEventQvector) > 0);
constexpr bool trackHasCov = ((TTrackFillMap & VarManager::ObjTypes::ReducedTrackBarrelCov) > 0);

Expand Down Expand Up @@ -1900,6 +1914,13 @@
VarManager::fgValues[VarManager::kVertexingTauzProjected], VarManager::fgValues[VarManager::kVertexingTauxyProjected],
VarManager::fgValues[VarManager::kVertexingLzProjected], VarManager::fgValues[VarManager::kVertexingLxyProjected]);
}
if (fConfigOptions.polarTables.value && t1.has_reducedMCTrack() && t2.has_reducedMCTrack()) {
dileptonPolarList(VarManager::fgValues[VarManager::kCosThetaHE], VarManager::fgValues[VarManager::kPhiHE], VarManager::fgValues[VarManager::kPhiTildeHE],
VarManager::fgValues[VarManager::kCosThetaCS], VarManager::fgValues[VarManager::kPhiCS], VarManager::fgValues[VarManager::kPhiTildeCS],
VarManager::fgValues[VarManager::kCosThetaPP], VarManager::fgValues[VarManager::kPhiPP], VarManager::fgValues[VarManager::kPhiTildePP],
VarManager::fgValues[VarManager::kCosThetaRM],
VarManager::fgValues[VarManager::kCosThetaStarTPC], VarManager::fgValues[VarManager::kCosThetaStarFT0A], VarManager::fgValues[VarManager::kCosThetaStarFT0C]);
}
}
}
}
Expand Down Expand Up @@ -2147,12 +2168,6 @@

for (auto& mctrack : mcTracks) {
VarManager::FillTrackMC(mcTracks, mctrack);
// if we have a mc generated acceptance cut, apply it here
if (fUseMCGenAccCut) {
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
continue;
}
}
// NOTE: Signals are checked here mostly based on the skimmed MC stack, so depending on the requested signal, the stack could be incomplete.
// NOTE: However, the working model is that the decisions on MC signals are precomputed during skimming and are stored in the mcReducedFlags member.
// TODO: Use the mcReducedFlags to select signals
Expand All @@ -2176,12 +2191,6 @@
continue;
}
VarManager::FillTrackMC(mcTracks, track);
// if we have a mc generated acceptance cut, apply it here
if (fUseMCGenAccCut) {
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
continue;
}
}
auto track_raw = mcTracks.rawIteratorAt(track.globalIndex());
mcDecision = 0;
isig = 0;
Expand Down Expand Up @@ -2212,11 +2221,6 @@
}
if (sig->CheckSignal(true, t1_raw, t2_raw)) {
VarManager::FillPairMC<TPairType>(t1, t2);
if (fUseMCGenAccCut) {
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
continue;
}
}
fHistMan->FillHistClass(Form("MCTruthGenPair_%s", sig->GetName()), VarManager::fgValues);
}
}
Expand Down Expand Up @@ -2247,12 +2251,15 @@
if (sig->CheckSignal(true, t1_raw, t2_raw)) {
mcDecision |= (static_cast<uint32_t>(1) << isig);
VarManager::FillPairMC<TPairType>(t1, t2);
fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s", sig->GetName()), VarManager::fgValues);
// Fill also acceptance cut histograms if requested
if (fUseMCGenAccCut) {
if (!fMCGenAccCut.IsSelected(VarManager::fgValues)) {
continue;
for (auto& cut : fMCGenAccCuts) {
if (cut->IsSelected(VarManager::fgValues)) {
fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s_%s", sig->GetName(), cut->GetName()), VarManager::fgValues);
}
}
}
fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s", sig->GetName()), VarManager::fgValues);
if (useMiniTree.fConfigMiniTree) {
// WARNING! To be checked
dileptonMiniTreeGen(mcDecision, -999, t1.pt(), t1.eta(), t1.phi(), t2.pt(), t2.eta(), t2.phi());
Expand Down Expand Up @@ -2293,10 +2300,7 @@
MyBarrelTracksWithCovWithAmbiguitiesWithColl const& barrelTracks, ReducedMCEvents const& mcEvents, ReducedMCTracks const& mcTracks)
{
runSameEventPairing<true, VarManager::kDecayToEE, gkEventFillMapWithCov, gkTrackFillMapWithCovWithColl>(events, trackAssocsPerCollision, barrelAssocs, barrelTracks, mcEvents, mcTracks);
// Feature replaced by processMCGen
/* if (fConfigMC.runMCGenPair) {
runMCGen<VarManager::kDecayToEE>(mcEvents, mcTracks);
}*/
runMCGenWithGrouping<VarManager::kDecayToEE>(events, mcEvents, mcTracks);
}

void processMuonOnlySkimmed(MyEventsVtxCovSelected const& events,
Expand Down Expand Up @@ -3994,7 +3998,7 @@
}
// dilepton rap cut
float rap = dilepton.rap();
if (fConfigUseMCRapcut && abs(rap) > fConfigDileptonRapCutAbs)

Check failure on line 4001 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
continue;

VarManager::FillTrack<fgDileptonFillMap>(dilepton, fValuesDilepton);
Expand Down Expand Up @@ -4302,12 +4306,12 @@
mctrack.mcReducedFlags() > 0) {
/*cout << ">>>>>>>>>>>>>>>>>>>>>>> track idx / pdg / selections: " << mctrack.globalIndex() << " / " << mctrack.pdgCode() << " / ";
PrintBitMap(mctrack.mcReducedFlags(), 16);
cout << endl;

Check failure on line 4309 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
if (mctrack.has_mothers()) {
for (auto& m : mctrack.mothersIds()) {
if (m < mcTracks.size()) { // protect against bad mother indices
auto aMother = mcTracks.rawIteratorAt(m);
cout << "<<<<<< mother idx / pdg: " << m << " / " << aMother.pdgCode() << endl;

Check failure on line 4314 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}
}
Expand All @@ -4316,7 +4320,7 @@
for (int d = mctrack.daughtersIds()[0]; d <= mctrack.daughtersIds()[1]; ++d) {
if (d < mcTracks.size()) { // protect against bad daughter indices
auto aDaughter = mcTracks.rawIteratorAt(d);
cout << "<<<<<< daughter idx / pdg: " << d << " / " << aDaughter.pdgCode() << endl;

Check failure on line 4323 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[logging]

Use O2 logging (LOG, LOGF, LOGP).
}
}
}*/
Expand Down Expand Up @@ -4418,12 +4422,12 @@
// apply kinematic cuts for signal
if ((t1_raw.pt() < fConfigDileptonLowpTCut || t1_raw.pt() > fConfigDileptonHighpTCut))
continue;
if (abs(t1_raw.y()) > fConfigDileptonRapCutAbs)

Check failure on line 4425 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
continue;
// for the energy correlators
for (auto& t2 : groupedMCTracks) {
auto t2_raw = groupedMCTracks.rawIteratorAt(t2.globalIndex());
if (TMath::Abs(t2_raw.pdgCode()) == 443 || TMath::Abs(t2_raw.pdgCode()) == 11 || TMath::Abs(t2_raw.pdgCode()) == 22)

Check failure on line 4430 in PWGDQ/Tasks/dqEfficiency_withAssoc.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.
continue;
if (t2_raw.pt() < fConfigMCGenHadronPtMin.value || std::abs(t2_raw.eta()) > fConfigMCGenHadronEtaAbs.value)
continue;
Expand Down Expand Up @@ -4486,12 +4490,12 @@
// apply kinematic cuts for signal
if ((t1_raw.pt() < fConfigDileptonLowpTCut || t1_raw.pt() > fConfigDileptonHighpTCut))
continue;
if (abs(t1_raw.y()) > fConfigDileptonRapCutAbs)

Check failure on line 4493 in PWGDQ/Tasks/dqEfficiency_withAssoc.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[std-prefix]

Use std:: prefix for names from the std namespace.
continue;
// for the energy correlators
for (auto& t2 : groupedMCTracks2) {
auto t2_raw = groupedMCTracks2.rawIteratorAt(t2.globalIndex());
if (TMath::Abs(t2_raw.pdgCode()) == 443 || TMath::Abs(t2_raw.pdgCode()) == 11 || TMath::Abs(t2_raw.pdgCode()) == 22)

Check failure on line 4498 in PWGDQ/Tasks/dqEfficiency_withAssoc.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.
continue;
if (t2_raw.pt() < fConfigMCGenHadronPtMin.value || std::abs(t2_raw.eta()) > fConfigMCGenHadronEtaAbs.value)
continue;
Expand Down
Loading