###############
# MC studies
###############

##################
## Example pp MC
#################

# cp derived data from HF enhanced pp test LHC24k1b produced in the hyperloop train 528735, run 537826 (203.4 MB):
cd MC
alien_cp alien:///alice/cern.ch/user/a/alihyperloop/jobs/0317/hy_3172544/AOD/001/AO2D.root file://.

# run analysis
o2-analysis-em-dielectron-mc --aod-file AO2D.root --workflow-suffix _DCAz -b --configuration json://../config/configuration_mc.json | o2-analysis-em-single-electron-qc-mc --workflow-suffix _Trk_DCA_ITSFirst  -b --configuration json://../config/configuration_mc.json | o2-analysis-em-prefilter-dielectron -b --configuration json://../config/configuration_mc.json | o2-analysis-em-smearing -b --configuration json://../config/configuration_mc.json | o2-analysis-em-associate-mccollision-to-collision -b --configuration json://../config/configuration_mc.json | o2-analysis-em-mcparticle-converter1 -b --configuration json://../config/configuration_mc.json

# ps: note that for  VO_ALICE@O2Physics::daily-20251108-0000-1 you do not need "| o2-analysis-em-mcparticle-converter1 -b --configuration json://../config/configuration_mc.json"

#in case of issue with new em data format, please do:
cd alice
cd O2Physics/Scripts
python find_dependencies.py -t newtable_00X

# plot single electron efficiency
cd ..
cd Macros
root PlotSingleEfficiency.C
root PlotDielectronEfficiency.C

#Then you can try on an output file obtained with the full test of the HF enhanced MC
root "PlotSingleEfficiency.C(\"../OutputFiles/MC/AnalysisResults.root\")"
root "PlotDielectronEfficiency.C(\"../OutputFiles/MC/AnalysisResults.root\")"



################
# Data studies
##################

#####################
## Example from pp
#####################

# cp derived data from MB pp 2023:
cd Datapp
alien_cp alien:///alice/cern.ch/user/a/alihyperloop/jobs/0245/hy_2453998/AOD/001/AO2D.root file://.

#run analysis
o2-analysis-em-dielectron --aod-file AO2D.root --workflow-suffix _DCAz -b --configuration json://../config/configuration_datapp.json | o2-analysis-em-prefilter-dielectron -b --configuration json://../config/configuration_datapp.json | o2-analysis-em-qvector-dummy-otf -b --configuration json://../config/configuration_datapp.json  | o2-analysis-em-single-electron-qc -b --configuration json://../config/configuration_datapp.json  | o2-analysis-em-electron-converter5 -b --configuration json://../config/configuration_datapp.json | o2-analysis-em-event-converter3 -b --configuration json://../config/configuration_datapp.json

# Look at output

#########################
## Example from Pb--Pb
##########################


#cp derived data from Pb--Pb 2023 pass5 hyperloop train 522829 and run 544122:
cd DataPbPb
alien_cp alien:///alice/cern.ch/user/a/alihyperloop/jobs/0311/hy_3117443/AOD/001/AO2D.root file://.


#run analysis
o2-analysis-em-dielectron --aod-file AO2D.root -b --configuration json://../config/configuration_dataPbPb.json | o2-analysis-em-prefilter-dielectron -b --configuration json://../config/configuration_dataPbPb.json | o2-analysis-em-qvector-dummy-otf -b --configuration json://../config/configuration_dataPbPb.json | o2-analysis-em-single-electron-qc -b --configuration json://../config/configuration_dataPbPb.json

# Look at output


#Propose exercise: add pair pt to the histogram dielectron/Pair/same/uls/hMvsPhiV
1. Look at where the histo is defined.
O2Physics/PWGEM/Dilepton/Tasks/dielectron.cxx
O2Physics/PWGEM/Dilepton/Core/Dilepton.h

2. Implement (see slides)
a. Definition
b. Filling

4. Compile with ninja
See also https://aliceo2group.github.io/analysis-framework/docs/gettingstarted/installing.html?highlight=ninja#building-partially-for-development-using-ninja
4.a. You need direnv:
     brew install direnv
     Add this line to ~/.bashrc file: eval "$(direnv hook bash)"
     restart a shell
4.b Go to the build directory:
    cd alice/sw/BUILD/O2Physics-latest/O2Physics
    allow direnv to load the build environment (needed only once):
    direnv allow
4.c Go directly here if you already use ninja to compile
    ninja PWGEM/install > $HOME/Desktop/log

5.Run again
o2-analysis-em-dielectron --aod-file AO2D.root -b --configuration json://../config/configuration_dataPbPb.json | o2-analysis-em-prefilter-dielectron -b --configuration json://../config/configuration_dataPbPb.json | o2-analysis-em-qvector-dummy-otf -b --configuration json://../config/configuration_dataPbPb.json | o2-analysis-em-single-electron-qc -b --configuration json://../config/configuration_dataPbPb.json

# Look at output

# Bring everything back
git restore O2Physics/PWGEM/Dilepton/Core/Dilepton.h
and compile again
