5353#include " DataFormatsParameters/GRPObject.h"
5454#include " DataFormatsParameters/GRPMagField.h"
5555#include " CCDB/BasicCCDBManager.h"
56+ #include " CCDB/CcdbApi.h"
5657
5758using namespace o2 ;
5859using namespace o2 ::framework;
@@ -63,15 +64,23 @@ struct kstarpbpb {
6364 int mRunNumber ;
6465 int multEstimator;
6566 float d_bz;
67+
68+ struct : ConfigurableGroup {
69+ Configurable<std::string> cfgURL{" cfgURL" , " http://alice-ccdb.cern.ch" , " Address of the CCDB to browse" };
70+ Configurable<int64_t > nolaterthan{" ccdb-no-later-than" , std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count (), " Latest acceptable timestamp of creation for the object" };
71+ } cfgCcdbParam;
72+
73+ // Enable access to the CCDB for the offset and correction constants and save them in dedicated variables.
6674 Service<o2::ccdb::BasicCCDBManager> ccdb;
75+ o2::ccdb::CcdbApi ccdbApi;
6776 Service<o2::framework::O2DatabasePDG> pdg;
6877
6978 // CCDB options
70- Configurable<std::string> ccdburl{" ccdb-url" , " http://alice-ccdb.cern.ch" , " url of the ccdb repository" };
71- Configurable<std::string> grpPath{" grpPath" , " GLO/GRP/GRP" , " Path of the grp file" };
72- Configurable<std::string> grpmagPath{" grpmagPath" , " GLO/Config/GRPMagField" , " CCDB path of the GRPMagField object" };
73- Configurable<std::string> lutPath{" lutPath" , " GLO/Param/MatLUT" , " Path of the Lut parametrization" };
74- Configurable<std::string> geoPath{" geoPath" , " GLO/Config/GeometryAligned" , " Path of the geometry file" };
79+ // Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
80+ // Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
81+ // Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
82+ // Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"};
83+ // Configurable<std::string> geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
7584
7685 // events
7786 Configurable<float > cfgCutVertex{" cfgCutVertex" , 10 .0f , " Accepted z-vertex range" };
@@ -98,7 +107,7 @@ struct kstarpbpb {
98107 Configurable<bool > removefaketrak{" removefaketrack" , true , " Remove fake track from momentum difference" };
99108 Configurable<float > ConfFakeKaonCut{" ConfFakeKaonCut" , 0.1 , " Cut based on track from momentum difference" };
100109 ConfigurableAxis configThnAxisPhiminusPsi{" configThnAxisPhiminusPsi" , {6 , 0.0 , TMath::Pi ()}, " #phi - #psi" };
101- ConfigurableAxis configThnAxisV2{" configThnAxisV2" , {200 , -1 , 1 }, " V2" };
110+ ConfigurableAxis configThnAxisV2{" configThnAxisV2" , {400 , -16 , 16 }, " V2" };
102111 Configurable<bool > additionalEvsel{" additionalEvsel" , false , " Additional event selcection" };
103112 Configurable<bool > timFrameEvsel{" timFrameEvsel" , false , " TPC Time frame boundary cut" };
104113 Configurable<bool > additionalEvselITS{" additionalEvselITS" , true , " Additional event selcection for ITS" };
@@ -117,7 +126,8 @@ struct kstarpbpb {
117126 Configurable<bool > mix{" mix" , false , " mix" };
118127 Configurable<bool > fillOccupancy{" fillOccupancy" , false , " fill Occupancy" };
119128 Configurable<int > cfgOccupancyCut{" cfgOccupancyCut" , 500 , " Occupancy cut" };
120- Configurable<bool > useSP{" useSP" , true , " useSP" };
129+ Configurable<bool > useWeight{" useWeight" , false , " use EP dep effi weight" };
130+ Configurable<std::string> ConfWeightPath{" ConfWeightPath" , " Users/s/skundu/My/Object/PbPb2024/MCWeight2" , " Path to gain calibration" };
121131
122132 Filter collisionFilter = nabs(aod::collision::posZ) < cfgCutVertex;
123133 Filter centralityFilter = nabs(aod::cent::centFT0C) < cfgCutCentrality;
@@ -152,9 +162,8 @@ struct kstarpbpb {
152162 AxisSpec centAxis = {8 , 0 , 80 , " V0M (%)" };
153163 AxisSpec occupancyAxis = {occupancyBinning, " Occupancy" };
154164
155- if (same) {
156- histos.add (" hSparseV2SASameEvent_V2" , " hSparseV2SASameEvent_V2" , HistType::kTHnSparseF , {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality});
157- }
165+ histos.add (" hSparseV2SASameEvent_V2" , " hSparseV2SASameEvent_V2" , HistType::kTHnSparseF , {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality});
166+
158167 if (like) {
159168 histos.add (" hSparseV2SAlikeEventNN_V2" , " hSparseV2SAlikeEventNN_V2" , HistType::kTHnSparseF , {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality});
160169 histos.add (" hSparseV2SAlikeEventPP_V2" , " hSparseV2SAlikeEventPP_V2" , HistType::kTHnSparseF , {thnAxisInvMass, thnAxisPt, thnAxisV2, thnAxisCentrality});
@@ -225,6 +234,11 @@ struct kstarpbpb {
225234 fMultMultPVCut = new TF1 (" fMultMultPVCut" , " [0]+[1]*x+[2]*x*x" , 0 , 5000 );
226235 fMultMultPVCut ->SetParameters (-0.1 , 0.785 , -4.7e-05 );
227236 }
237+ ccdb->setURL (cfgCcdbParam.cfgURL );
238+ ccdbApi.init (" http://alice-ccdb.cern.ch" );
239+ ccdb->setCaching (true );
240+ ccdb->setLocalObjectValidityChecking ();
241+ ccdb->setCreatedNotAfter (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ());
228242 }
229243
230244 double massKa = o2::constants::physics::MassKPlus;
@@ -418,7 +432,10 @@ struct kstarpbpb {
418432 using BinningTypeVertexContributor = ColumnBinningPolicy<aod::collision::PosZ, aod::cent::CentFT0C, aod::epcalibrationtable::PsiFT0C>;
419433 ROOT::Math::PxPyPzMVector KstarMother, daughter1, daughter2, kaonrot, kstarrot;
420434
421- void processSE (EventCandidates::iterator const & collision, TrackCandidates const & tracks, aod::BCs const &)
435+ int currentRunNumber = -999 ;
436+ int lastRunNumber = -999 ;
437+ TH3D* hweight;
438+ void processSE (EventCandidates::iterator const & collision, TrackCandidates const & tracks, aod::BCsWithTimestamps const &)
422439 {
423440 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 )) {
424441 return ;
@@ -456,6 +473,14 @@ struct kstarpbpb {
456473 histos.fill (HIST (" hOccupancy" ), occupancy);
457474 histos.fill (HIST (" hVtxZ" ), collision.posZ ());
458475 }
476+ auto bc = collision.bc_as <aod::BCsWithTimestamps>();
477+ currentRunNumber = collision.bc_as <aod::BCsWithTimestamps>().runNumber ();
478+ if (useWeight && (currentRunNumber != lastRunNumber)) {
479+ hweight = ccdb->getForTimeStamp <TH3D>(ConfWeightPath.value , bc.timestamp ());
480+ }
481+ lastRunNumber = currentRunNumber;
482+ float weight1 = 1.0 ;
483+ float weight2 = 1.0 ;
459484 for (auto track1 : tracks) {
460485 if (!selectionTrack (track1)) {
461486 continue ;
@@ -466,6 +491,13 @@ struct kstarpbpb {
466491 continue ;
467492 }
468493 track1kaon = true ;
494+ if (useWeight) {
495+ if (track1.pt () < 10.0 && track1.pt () > 0.15 ) {
496+ weight1 = hweight->GetBinContent (hweight->FindBin (centrality, GetPhiInRange (track1.phi () - psiFT0C), track1.pt () + 0.000005 ));
497+ } else {
498+ weight1 = 1 ;
499+ }
500+ }
469501 for (auto track2 : tracks) {
470502 if (!selectionTrack (track2)) {
471503 continue ;
@@ -482,66 +514,59 @@ struct kstarpbpb {
482514 if (!track1kaon || !track2pion) {
483515 continue ;
484516 }
517+ if (useWeight) {
518+ if (track2.pt () < 10.0 && track2.pt () > 0.15 ) {
519+ weight2 = hweight->GetBinContent (hweight->FindBin (centrality, GetPhiInRange (track2.phi () - psiFT0C), track2.pt () + 0.000005 ));
520+ } else {
521+ weight2 = 1 ;
522+ }
523+ }
485524 daughter1 = ROOT::Math::PxPyPzMVector (track1.px (), track1.py (), track1.pz (), massKa);
486525 daughter2 = ROOT::Math::PxPyPzMVector (track2.px (), track2.py (), track2.pz (), massPi);
487526 KstarMother = daughter1 + daughter2;
488527 if (TMath::Abs (KstarMother.Rapidity ()) > confRapidity) {
489528 continue ;
490529 }
491530 auto phiminuspsi = GetPhiInRange (KstarMother.Phi () - psiFT0C);
492- if (useSP) {
493- v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
494- }
495- if (!useSP ) {
496- v2 = TMath::Cos ( 2.0 * phiminuspsi) ;
531+
532+ v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
533+ auto totalweight = weight1 * weight2;
534+ if (totalweight <= 0.0005 ) {
535+ totalweight = 1.0 ;
497536 }
498- // unlike sign
499- if (track1.sign () * track2.sign () < 0 ) {
500- if (same) {
501- histos.fill (HIST (" hSparseV2SASameEvent_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
502- }
503- if (fillRotation) {
504- for (int nrotbkg = 0 ; nrotbkg < nBkgRotations; nrotbkg++) {
505- auto anglestart = confMinRot;
506- auto angleend = confMaxRot;
507- auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1 ));
508- auto rotangle = anglestart + nrotbkg * anglestep;
509- histos.fill (HIST (" hRotation" ), rotangle);
510- auto rotkaonPx = track1.px () * std::cos (rotangle) - track1.py () * std::sin (rotangle);
511- auto rotkaonPy = track1.px () * std::sin (rotangle) + track1.py () * std::cos (rotangle);
512- kaonrot = ROOT::Math::PxPyPzMVector (rotkaonPx, rotkaonPy, track1.pz (), massKa);
513- kstarrot = kaonrot + daughter2;
514- if (TMath::Abs (kstarrot.Rapidity ()) > confRapidity) {
515- continue ;
516- }
517- auto phiminuspsiRot = GetPhiInRange (kstarrot.Phi () - psiFT0C);
518- if (useSP) {
519- v2Rot = TMath::Cos (2.0 * phiminuspsiRot) * QFT0C;
520- }
521- if (!useSP) {
522- v2Rot = TMath::Cos (2.0 * phiminuspsiRot);
523- }
524- histos.fill (HIST (" hSparseV2SASameEventRotational_V2" ), kstarrot.M (), kstarrot.Pt (), v2Rot, centrality);
525- }
526- }
537+
538+ if (useWeight) {
539+ histos.fill (HIST (" hSparseV2SASameEvent_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality, 1 / totalweight);
540+ } else {
541+ histos.fill (HIST (" hSparseV2SASameEvent_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
527542 }
528- // like sign
529- if (track1.sign () * track2.sign () > 0 ) {
530- if (like) {
531- if (track1.sign () > 0 && track2.sign () > 0 ) {
532- histos.fill (HIST (" hSparseV2SAlikeEventPP_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
533- }
534- if (track1.sign () < 0 && track2.sign () < 0 ) {
535- histos.fill (HIST (" hSparseV2SAlikeEventNN_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
543+ if (fillRotation) {
544+ for (int nrotbkg = 0 ; nrotbkg < nBkgRotations; nrotbkg++) {
545+ auto anglestart = confMinRot;
546+ auto angleend = confMaxRot;
547+ auto anglestep = (angleend - anglestart) / (1.0 * (nBkgRotations - 1 ));
548+ auto rotangle = anglestart + nrotbkg * anglestep;
549+ histos.fill (HIST (" hRotation" ), rotangle);
550+ auto rotkaonPx = track1.px () * std::cos (rotangle) - track1.py () * std::sin (rotangle);
551+ auto rotkaonPy = track1.px () * std::sin (rotangle) + track1.py () * std::cos (rotangle);
552+ kaonrot = ROOT::Math::PxPyPzMVector (rotkaonPx, rotkaonPy, track1.pz (), massKa);
553+ kstarrot = kaonrot + daughter2;
554+ if (TMath::Abs (kstarrot.Rapidity ()) > confRapidity) {
555+ continue ;
536556 }
557+ auto phiminuspsiRot = GetPhiInRange (kstarrot.Phi () - psiFT0C);
558+
559+ v2Rot = TMath::Cos (2.0 * phiminuspsiRot) * QFT0C;
560+
561+ histos.fill (HIST (" hSparseV2SASameEventRotational_V2" ), kstarrot.M (), kstarrot.Pt (), v2Rot, centrality);
537562 }
538563 }
539564 }
540565 }
541566 }
542567 PROCESS_SWITCH (kstarpbpb, processSE, " Process Same event latest" , true );
543568
544- void processSameEvent (EventCandidates::iterator const & collision, TrackCandidates const & /* tracks*/ , aod::BCs const &)
569+ void processSameEvent (EventCandidates::iterator const & collision, TrackCandidates const & /* tracks, aod::BCs const& */ , aod::BCsWithTimestamps const &)
545570 {
546571 if (!collision.sel8 ()) {
547572 return ;
@@ -697,12 +722,9 @@ struct kstarpbpb {
697722 continue ;
698723 }
699724 auto phiminuspsi = GetPhiInRange (KstarMother.Phi () - psiFT0C);
700- if (useSP) {
701- v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
702- }
703- if (!useSP) {
704- v2 = TMath::Cos (2.0 * phiminuspsi);
705- }
725+
726+ v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
727+
706728 histos.fill (HIST (" hSparseV2SASameEvent_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
707729 }
708730 if (fillRotation) {
@@ -730,12 +752,9 @@ struct kstarpbpb {
730752 continue ;
731753 }
732754 auto phiminuspsiRot = GetPhiInRange (kstarrot.Phi () - psiFT0C);
733- if (useSP) {
734- v2Rot = TMath::Cos (2.0 * phiminuspsiRot) * QFT0C;
735- }
736- if (!useSP) {
737- v2Rot = TMath::Cos (2.0 * phiminuspsiRot);
738- }
755+
756+ v2Rot = TMath::Cos (2.0 * phiminuspsiRot) * QFT0C;
757+
739758 histos.fill (HIST (" hSparseV2SASameEventRotational_V2" ), kstarrot.M (), kstarrot.Pt (), v2Rot, centrality);
740759 }
741760 }
@@ -846,12 +865,8 @@ struct kstarpbpb {
846865 continue ;
847866 }
848867 auto phiminuspsi = GetPhiInRange (KstarMother.Phi () - psiFT0C);
849- if (useSP) {
850- v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
851- }
852- if (!useSP) {
853- v2 = TMath::Cos (2.0 * phiminuspsi);
854- }
868+
869+ v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
855870 histos.fill (HIST (" hSparseV2SAlikeEventNN_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
856871 }
857872 } else if (track1pion && track2kaon) {
@@ -863,12 +878,9 @@ struct kstarpbpb {
863878 continue ;
864879 }
865880 auto phiminuspsi = GetPhiInRange (KstarMother.Phi () - psiFT0C);
866- if (useSP) {
867- v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
868- }
869- if (!useSP) {
870- v2 = TMath::Cos (2.0 * phiminuspsi);
871- }
881+
882+ v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
883+
872884 histos.fill (HIST (" hSparseV2SAlikeEventPP_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
873885 }
874886 }
@@ -1000,12 +1012,9 @@ struct kstarpbpb {
10001012 continue ;
10011013 }
10021014 auto phiminuspsi = GetPhiInRange (KstarMother.Phi () - psiFT0C);
1003- if (useSP) {
1004- v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
1005- }
1006- if (!useSP) {
1007- v2 = TMath::Cos (2.0 * phiminuspsi);
1008- }
1015+
1016+ v2 = TMath::Cos (2.0 * phiminuspsi) * QFT0C;
1017+
10091018 if (mix) {
10101019 histos.fill (HIST (" hSparseV2SAMixedEvent_V2" ), KstarMother.M (), KstarMother.Pt (), v2, centrality);
10111020 }
0 commit comments