@@ -3333,6 +3333,10 @@ struct AnalysisDileptonTrack {
33333333 Configurable<std::vector<float >> fConfigFitmassEC {" cfgTFitmassEC" , std::vector<float >{-0.541438 , 2.8 , 3.2 }, " parameter from the fit fuction and fit range" };
33343334 Configurable<std::vector<float >> fConfigTransRange {" cfgTransRange" , std::vector<float >{0.333333 , 0.666667 }, " Transverse region for the energy correlstor analysis" };
33353335
3336+ Configurable<bool > fConfigApplyEfficiency {" cfgApplyEfficiency" , false , " If true, apply efficiency correction for the energy correlator study" };
3337+ Configurable<bool > fConfigApplyEfficiencyME {" cfgApplyEfficiencyME" , false , " If true, apply efficiency correction for the energy correlator study" };
3338+ Configurable<std::string> fConfigAccCCDBPath {" AccCCDBPath" , " Users/y/yalin/pptest/test2" , " Path of the efficiency corrections" };
3339+
33363340 int fCurrentRun ; // needed to detect if the run changed and trigger update of calibrations etc.
33373341 int fNCuts ; // number of dilepton leg cuts
33383342 int fNLegCuts ;
@@ -3366,6 +3370,12 @@ struct AnalysisDileptonTrack {
33663370
33673371 TF1* fMassBkg = nullptr ;
33683372
3373+ TH2F* hAcceptance_rec;
3374+ TH2F* hAcceptance_gen;
3375+ TH1F* hEfficiency_dilepton;
3376+ TH1F* hEfficiency_hadron;
3377+ TH1F* hMasswindow;
3378+
33693379 void init (o2::framework::InitContext& context)
33703380 {
33713381 bool isBarrel = context.mOptions .get <bool >(" processBarrelSkimmed" );
@@ -3623,6 +3633,22 @@ struct AnalysisDileptonTrack {
36233633 }
36243634 }
36253635
3636+ void initAccFromCCDB (uint64_t timestamp)
3637+ {
3638+ TList* listAccs = fCCDB ->getForTimeStamp <TList>(fConfigAccCCDBPath , timestamp);
3639+ if (!listAccs) {
3640+ LOG (fatal) << " Problem getting TList object with efficiencies!" ;
3641+ }
3642+ hEfficiency_dilepton = static_cast <TH1F*>(listAccs->FindObject (" hEfficiency_dilepton" ));
3643+ hEfficiency_hadron = static_cast <TH1F*>(listAccs->FindObject (" hEfficiency_hadron" ));
3644+ hAcceptance_rec = static_cast <TH2F*>(listAccs->FindObject (" hAcceptance_rec" ));
3645+ hAcceptance_gen = static_cast <TH2F*>(listAccs->FindObject (" hAcceptance_gen" ));
3646+ hMasswindow = static_cast <TH1F*>(listAccs->FindObject (" hMasswindow" ));
3647+ if (!hAcceptance_rec || !hAcceptance_gen || !hEfficiency_dilepton || !hEfficiency_hadron || !hMasswindow) {
3648+ LOG (fatal) << " Problem getting histograms from the TList object with efficiencies!" ;
3649+ }
3650+ }
3651+
36263652 // Template function to run pair - hadron combinations
36273653 template <int TCandidateType, uint32_t TEventFillMap, uint32_t TTrackFillMap, typename TEvent, typename TTracks, typename TTrackAssocs, typename TDileptons>
36283654 void runDileptonHadron (TEvent const & event, TTrackAssocs const & assocs, TTracks const & tracks, TDileptons const & dileptons)
@@ -3699,8 +3725,21 @@ struct AnalysisDileptonTrack {
36993725 VarManager::FillDileptonTrackVertexing<TCandidateType, TEventFillMap, TTrackFillMap>(event, lepton1, lepton2, track, fValuesHadron );
37003726
37013727 // for the energy correlator analysis
3728+ float Effweight_rec = 1 .0f ;
3729+ if (fConfigApplyEfficiency ) {
3730+ float dilepton_eta = dilepton.eta ();
3731+ float dilepton_phi = dilepton.phi ();
3732+ float hadron_eta = track.eta ();
3733+ float hadron_phi = track.phi ();
3734+ float deltaphi = RecoDecay::constrainAngle (dilepton_phi - hadron_phi, -0.5 * o2::constants::math::PI);
3735+ Effweight_rec = hAcceptance_rec->Interpolate (dilepton_eta - hadron_eta, deltaphi);
3736+ float Effdilepton = hEfficiency_dilepton->Interpolate (dilepton.pt ());
3737+ float Masswindow = hMasswindow->Interpolate (dilepton.pt ());
3738+ float Effhadron = hEfficiency_hadron->Interpolate (track.pt ());
3739+ Effweight_rec = Effweight_rec * Effdilepton * Effhadron * Masswindow;
3740+ }
37023741 std::vector<float > fTransRange = fConfigTransRange ;
3703- VarManager::FillEnergyCorrelatorTriple (lepton1, lepton2, track, fValuesHadron , fTransRange [0 ], fTransRange [1 ], fConfigApplyMassEC , fMassBkg ->GetRandom ());
3742+ VarManager::FillEnergyCorrelatorTriple (lepton1, lepton2, track, fValuesHadron , fTransRange [0 ], fTransRange [1 ], fConfigApplyMassEC , fMassBkg ->GetRandom (), 1 . / Effweight_rec );
37043743
37053744 // table to be written out for ML analysis
37063745 BmesonsTable (event.runNumber (), event.globalIndex (), event.timestamp (), fValuesHadron [VarManager::kPairMass ], dilepton.mass (), fValuesHadron [VarManager::kDeltaMass ], fValuesHadron [VarManager::kPairPt ], fValuesHadron [VarManager::kPairEta ], fValuesHadron [VarManager::kPairPhi ], fValuesHadron [VarManager::kPairRap ],
@@ -3805,6 +3844,9 @@ struct AnalysisDileptonTrack {
38053844 }
38063845 if (fCurrentRun != events.begin ().runNumber ()) { // start: runNumber
38073846 initParamsFromCCDB (events.begin ().timestamp ());
3847+ if (fConfigApplyEfficiency ) {
3848+ initAccFromCCDB (events.begin ().timestamp ());
3849+ }
38083850 fCurrentRun = events.begin ().runNumber ();
38093851 } // end: runNumber
38103852 for (auto & event : events) {
@@ -3862,6 +3904,14 @@ struct AnalysisDileptonTrack {
38623904 if (events.size () == 0 ) {
38633905 return ;
38643906 }
3907+
3908+ if (fCurrentRun != events.begin ().runNumber ()) { // start: runNumber
3909+ if (fConfigApplyEfficiency ) {
3910+ initAccFromCCDB (events.begin ().timestamp ());
3911+ }
3912+ fCurrentRun = events.begin ().runNumber ();
3913+ } // end: runNumber
3914+
38653915 events.bindExternalIndices (&dileptons);
38663916 events.bindExternalIndices (&assocs);
38673917
@@ -3909,8 +3959,25 @@ struct AnalysisDileptonTrack {
39093959 VarManager::FillDileptonHadron (dilepton, track, VarManager::fgValues);
39103960
39113961 // for the energy correlator analysis
3962+ float Effweight_rec = 1 .0f ;
3963+ if (fConfigApplyEfficiency ) {
3964+ float dilepton_eta = dilepton.eta ();
3965+ float dilepton_phi = dilepton.phi ();
3966+ float hadron_eta = track.eta ();
3967+ float hadron_phi = track.phi ();
3968+ float deltaphi = RecoDecay::constrainAngle (dilepton_phi - hadron_phi, -0.5 * o2::constants::math::PI);
3969+ Effweight_rec = hAcceptance_rec->Interpolate (dilepton_eta - hadron_eta, deltaphi);
3970+ float Effdilepton = hEfficiency_dilepton->Interpolate (dilepton.pt ());
3971+ float Masswindow = hMasswindow->Interpolate (dilepton.pt ());
3972+ float Effhadron = hEfficiency_hadron->Interpolate (track.pt ());
3973+ if (fConfigApplyEfficiencyME ) {
3974+ Effweight_rec = Effdilepton * Effhadron * Masswindow; // for the moment, apply the efficiency correction also for the mixed event pairs, but this can be changed in case we want to apply it only for the same event pairs
3975+ } else {
3976+ Effweight_rec = Effweight_rec * Effdilepton * Effhadron * Masswindow; // apply acceptance and efficiency correction for the real pairs
3977+ }
3978+ }
39123979 std::vector<float > fTransRange = fConfigTransRange ;
3913- VarManager::FillEnergyCorrelatorTriple (lepton1, lepton2, track, fValuesHadron , fTransRange [0 ], fTransRange [1 ], fConfigApplyMassEC , fMassBkg ->GetRandom ());
3980+ VarManager::FillEnergyCorrelatorTriple (lepton1, lepton2, track, fValuesHadron , fTransRange [0 ], fTransRange [1 ], fConfigApplyMassEC , fMassBkg ->GetRandom (), 1 . / Effweight_rec );
39143981
39153982 // loop over dilepton leg cuts and track cuts and fill histograms separately for each combination
39163983 for (int icut = 0 ; icut < fNCuts ; icut++) {
0 commit comments