diff --git a/PWGLF/Tasks/Resonances/kstarpbpb.cxx b/PWGLF/Tasks/Resonances/kstarpbpb.cxx index 71317b105f2..356def5dedd 100644 --- a/PWGLF/Tasks/Resonances/kstarpbpb.cxx +++ b/PWGLF/Tasks/Resonances/kstarpbpb.cxx @@ -53,6 +53,7 @@ #include "DataFormatsParameters/GRPObject.h" #include "DataFormatsParameters/GRPMagField.h" #include "CCDB/BasicCCDBManager.h" +#include "CCDB/CcdbApi.h" using namespace o2; using namespace o2::framework; @@ -63,15 +64,23 @@ struct kstarpbpb { int mRunNumber; int multEstimator; float d_bz; + + struct : ConfigurableGroup { + Configurable cfgURL{"cfgURL", "http://alice-ccdb.cern.ch", "Address of the CCDB to browse"}; + Configurable nolaterthan{"ccdb-no-later-than", std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(), "Latest acceptable timestamp of creation for the object"}; + } cfgCcdbParam; + + // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables. Service ccdb; + o2::ccdb::CcdbApi ccdbApi; Service pdg; // CCDB options - Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; - Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; - Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; - Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; - Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; + // Configurable ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; + // Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; + // Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; + // Configurable lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; + // Configurable geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"}; // events Configurable cfgCutVertex{"cfgCutVertex", 10.0f, "Accepted z-vertex range"}; @@ -98,7 +107,7 @@ struct kstarpbpb { Configurable removefaketrak{"removefaketrack", true, "Remove fake track from momentum difference"}; Configurable ConfFakeKaonCut{"ConfFakeKaonCut", 0.1, "Cut based on track from momentum difference"}; ConfigurableAxis configThnAxisPhiminusPsi{"configThnAxisPhiminusPsi", {6, 0.0, TMath::Pi()}, "#phi - #psi"}; - ConfigurableAxis configThnAxisV2{"configThnAxisV2", {200, -1, 1}, "V2"}; + ConfigurableAxis configThnAxisV2{"configThnAxisV2", {400, -16, 16}, "V2"}; Configurable additionalEvsel{"additionalEvsel", false, "Additional event selcection"}; Configurable timFrameEvsel{"timFrameEvsel", false, "TPC Time frame boundary cut"}; Configurable additionalEvselITS{"additionalEvselITS", true, "Additional event selcection for ITS"}; @@ -117,7 +126,8 @@ struct kstarpbpb { Configurable mix{"mix", false, "mix"}; Configurable fillOccupancy{"fillOccupancy", false, "fill Occupancy"}; Configurable cfgOccupancyCut{"cfgOccupancyCut", 500, "Occupancy cut"}; - Configurable useSP{"useSP", true, "useSP"}; + Configurable useWeight{"useWeight", false, "use EP dep effi weight"}; + Configurable ConfWeightPath{"ConfWeightPath", "Users/s/skundu/My/Object/PbPb2024/MCWeight2", "Path to gain calibration"}; Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex; Filter centralityFilter = nabs(aod::cent::centFT0C) < cfgCutCentrality; @@ -152,9 +162,8 @@ struct kstarpbpb { AxisSpec centAxis = {8, 0, 80, "V0M (%)"}; AxisSpec occupancyAxis = {occupancyBinning, "Occupancy"}; - if (same) { - histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); - } + histos.add("hSparseV2SASameEvent_V2", "hSparseV2SASameEvent_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); + if (like) { histos.add("hSparseV2SAlikeEventNN_V2", "hSparseV2SAlikeEventNN_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); histos.add("hSparseV2SAlikeEventPP_V2", "hSparseV2SAlikeEventPP_V2", HistType::kTHnSparseF, {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality}); @@ -225,6 +234,11 @@ struct kstarpbpb { fMultMultPVCut = new TF1("fMultMultPVCut", "[0]+[1]*x+[2]*x*x", 0, 5000); fMultMultPVCut->SetParameters(-0.1, 0.785, -4.7e-05); } + ccdb->setURL(cfgCcdbParam.cfgURL); + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); + ccdb->setCreatedNotAfter(std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count()); } double massKa = o2::constants::physics::MassKPlus; @@ -418,7 +432,10 @@ struct kstarpbpb { using BinningTypeVertexContributor = ColumnBinningPolicy; ROOT::Math::PxPyPzMVector KstarMother, daughter1, daughter2, kaonrot, kstarrot; - void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCs const&) + int currentRunNumber = -999; + int lastRunNumber = -999; + TH3D* hweight; + void processSE(EventCandidates::iterator const& collision, TrackCandidates const& tracks, aod::BCsWithTimestamps const&) { if (!collision.sel8() || !collision.triggereventep() || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder) || !collision.selection_bit(aod::evsel::kNoITSROFrameBorder) || !collision.selection_bit(aod::evsel::kNoSameBunchPileup) || !collision.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { return; @@ -456,6 +473,14 @@ struct kstarpbpb { histos.fill(HIST("hOccupancy"), occupancy); histos.fill(HIST("hVtxZ"), collision.posZ()); } + auto bc = collision.bc_as(); + currentRunNumber = collision.bc_as().runNumber(); + if (useWeight && (currentRunNumber != lastRunNumber)) { + hweight = ccdb->getForTimeStamp(ConfWeightPath.value, bc.timestamp()); + } + lastRunNumber = currentRunNumber; + float weight1 = 1.0; + float weight2 = 1.0; for (auto track1 : tracks) { if (!selectionTrack(track1)) { continue; @@ -466,6 +491,13 @@ struct kstarpbpb { continue; } track1kaon = true; + if (useWeight) { + if (track1.pt() < 10.0 && track1.pt() > 0.15) { + weight1 = hweight->GetBinContent(hweight->FindBin(centrality, GetPhiInRange(track1.phi() - psiFT0C), track1.pt() + 0.000005)); + } else { + weight1 = 1; + } + } for (auto track2 : tracks) { if (!selectionTrack(track2)) { continue; @@ -482,6 +514,13 @@ struct kstarpbpb { if (!track1kaon || !track2pion) { continue; } + if (useWeight) { + if (track2.pt() < 10.0 && track2.pt() > 0.15) { + weight2 = hweight->GetBinContent(hweight->FindBin(centrality, GetPhiInRange(track2.phi() - psiFT0C), track2.pt() + 0.000005)); + } else { + weight2 = 1; + } + } daughter1 = ROOT::Math::PxPyPzMVector(track1.px(), track1.py(), track1.pz(), massKa); daughter2 = ROOT::Math::PxPyPzMVector(track2.px(), track2.py(), track2.pz(), massPi); KstarMother = daughter1 + daughter2; @@ -489,51 +528,37 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi); + + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + auto totalweight = weight1 * weight2; + if (totalweight <= 0.0005) { + totalweight = 1.0; } - // unlike sign - if (track1.sign() * track2.sign() < 0) { - if (same) { - histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); - } - if (fillRotation) { - for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { - auto anglestart = confMinRot; - auto angleend = confMaxRot; - auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); - auto rotangle = anglestart + nrotbkg * anglestep; - histos.fill(HIST("hRotation"), rotangle); - auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); - auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); - kaonrot = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); - kstarrot = kaonrot + daughter2; - if (TMath::Abs(kstarrot.Rapidity()) > confRapidity) { - continue; - } - auto phiminuspsiRot = GetPhiInRange(kstarrot.Phi() - psiFT0C); - if (useSP) { - v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; - } - if (!useSP) { - v2Rot = TMath::Cos(2.0 * phiminuspsiRot); - } - histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality); - } - } + + if (useWeight) { + histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality, 1 / totalweight); + } else { + histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } - // like sign - if (track1.sign() * track2.sign() > 0) { - if (like) { - if (track1.sign() > 0 && track2.sign() > 0) { - histos.fill(HIST("hSparseV2SAlikeEventPP_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); - } - if (track1.sign() < 0 && track2.sign() < 0) { - histos.fill(HIST("hSparseV2SAlikeEventNN_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); + if (fillRotation) { + for (int nrotbkg = 0; nrotbkg < nBkgRotations; nrotbkg++) { + auto anglestart = confMinRot; + auto angleend = confMaxRot; + auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1)); + auto rotangle = anglestart + nrotbkg * anglestep; + histos.fill(HIST("hRotation"), rotangle); + auto rotkaonPx = track1.px() * std::cos(rotangle) - track1.py() * std::sin(rotangle); + auto rotkaonPy = track1.px() * std::sin(rotangle) + track1.py() * std::cos(rotangle); + kaonrot = ROOT::Math::PxPyPzMVector(rotkaonPx, rotkaonPy, track1.pz(), massKa); + kstarrot = kaonrot + daughter2; + if (TMath::Abs(kstarrot.Rapidity()) > confRapidity) { + continue; } + auto phiminuspsiRot = GetPhiInRange(kstarrot.Phi() - psiFT0C); + + v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; + + histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality); } } } @@ -541,7 +566,7 @@ struct kstarpbpb { } PROCESS_SWITCH(kstarpbpb, processSE, "Process Same event latest", true); - void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks*/, aod::BCs const&) + void processSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& /*tracks, aod::BCs const&*/, aod::BCsWithTimestamps const&) { if (!collision.sel8()) { return; @@ -697,12 +722,9 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi); - } + + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + histos.fill(HIST("hSparseV2SASameEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } if (fillRotation) { @@ -730,12 +752,9 @@ struct kstarpbpb { continue; } auto phiminuspsiRot = GetPhiInRange(kstarrot.Phi() - psiFT0C); - if (useSP) { - v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; - } - if (!useSP) { - v2Rot = TMath::Cos(2.0 * phiminuspsiRot); - } + + v2Rot = TMath::Cos(2.0 * phiminuspsiRot) * QFT0C; + histos.fill(HIST("hSparseV2SASameEventRotational_V2"), kstarrot.M(), kstarrot.Pt(), v2Rot, centrality); } } @@ -846,12 +865,8 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi); - } + + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; histos.fill(HIST("hSparseV2SAlikeEventNN_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } } else if (track1pion && track2kaon) { @@ -863,12 +878,9 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi); - } + + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + histos.fill(HIST("hSparseV2SAlikeEventPP_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); } } @@ -1000,12 +1012,9 @@ struct kstarpbpb { continue; } auto phiminuspsi = GetPhiInRange(KstarMother.Phi() - psiFT0C); - if (useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; - } - if (!useSP) { - v2 = TMath::Cos(2.0 * phiminuspsi); - } + + v2 = TMath::Cos(2.0 * phiminuspsi) * QFT0C; + if (mix) { histos.fill(HIST("hSparseV2SAMixedEvent_V2"), KstarMother.M(), KstarMother.Pt(), v2, centrality); }