Skip to content

Commit d7afc2e

Browse files
authored
Update DvsMult preliminary files for HP2020 (#704)
* Update DvsMult preliminary files to avoid wrong comparisons * Remove files that contain final results, keeping macros as examples
1 parent f385ca6 commit d7afc2e

File tree

56 files changed

+792
-2641
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+792
-2641
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
2+
#include <iostream>
3+
#include <fstream>
4+
#include <sstream>
5+
#include <string>
6+
#include <vector>
7+
using std::cout;
8+
using std::endl;
9+
10+
#include "TCanvas.h"
11+
#include "TDirectoryFile.h"
12+
#include "TF1.h"
13+
#include "TFile.h"
14+
#include "TGraphErrors.h"
15+
#include "TH1F.h"
16+
#include "THnSparse.h"
17+
#include "TLatex.h"
18+
#include "TLegend.h"
19+
#include "TList.h"
20+
#include "TPad.h"
21+
#include "TROOT.h"
22+
#include "TSystem.h"
23+
#include "AliHFSystErr.h"
24+
25+
26+
void AliHFSystErrToYaml(TString inputrootfile, TString outputyamlfile, Bool_t isLc = kFALSE){
27+
28+
/*
29+
const Int_t nPtBins = 5;
30+
Float_t PtBins[nPtBins+1] = {2., 4., 6., 8., 12., 24.};
31+
Float_t midPtBins[nPtBins] = {3., 5., 7., 10., 18.};
32+
*/
33+
const Int_t nPtBins = 6;
34+
Float_t PtBins[nPtBins+1] = {1., 2., 4., 6., 8., 12., 24.};
35+
Float_t midPtBins[nPtBins] = {1.5, 2.9, 5., 7., 10., 18.};
36+
37+
TFile* fInput = new TFile(inputrootfile.Data(),"read");
38+
39+
AliHFSystErr* oSystErr = (AliHFSystErr*)fInput->Get("AliHFSystErr");
40+
41+
ofstream fOutYaml (outputyamlfile.Data());
42+
43+
fOutYaml <<endl <<endl;
44+
fOutYaml << "#Extracted automatically from AliHFSystErrObject of file: " << inputrootfile << endl;
45+
46+
// yield
47+
fOutYaml <<"names: [\"yield\", \"cut\", \"track\", \"ptshape\", \"feeddown_mult\", \"trigger\", \"multiplicity_weights\", \"multiplicity_interval\", \"branching_ratio\", \"sigmav0\"]" <<endl <<endl;
48+
49+
50+
fOutYaml <<"yield:" <<endl;
51+
for(int ipt=0; ipt<nPtBins; ipt++){
52+
fOutYaml <<" - [0., 0., " <<oSystErr->GetRawYieldErr(midPtBins[ipt]) <<", " <<oSystErr->GetRawYieldErr(midPtBins[ipt]) <<"]" <<endl;
53+
}
54+
fOutYaml <<endl;
55+
56+
57+
fOutYaml <<"cut:" <<endl;
58+
for(int ipt=0; ipt<nPtBins; ipt++){
59+
//fOutYaml <<" - [0., 0., " <<oSystErr->GetCutsEffErr(midPtBins[ipt]) <<", " <<oSystErr->GetCutsEffErr(midPtBins[ipt]) <<"]" <<endl;
60+
fOutYaml <<" - [0., 0., " << TMath::Sqrt( oSystErr->GetCutsEffErr(midPtBins[ipt]) * oSystErr->GetCutsEffErr(midPtBins[ipt]) + oSystErr->GetPIDEffErr(midPtBins[ipt]) * oSystErr->GetPIDEffErr(midPtBins[ipt])) <<", " << TMath::Sqrt( oSystErr->GetCutsEffErr(midPtBins[ipt]) * oSystErr->GetCutsEffErr(midPtBins[ipt]) + oSystErr->GetPIDEffErr(midPtBins[ipt]) * oSystErr->GetPIDEffErr(midPtBins[ipt])) <<"]" <<endl;
61+
}
62+
fOutYaml <<endl;
63+
64+
65+
/*
66+
// PID ---> Included in cut as for ML!
67+
fOutYaml <<"PID:" <<endl;
68+
for(int ipt=0; ipt<nPtBins; ipt++){
69+
fOutYaml <<" - [0., 0., " <<oSystErr->GetPIDEffErr(midPtBins[ipt]) <<", " <<oSystErr->GetPIDEffErr(midPtBins[ipt]) <<"]" <<endl;
70+
}
71+
fOutYaml <<endl;
72+
*/
73+
74+
75+
fOutYaml <<"track:" <<endl;
76+
for(int ipt=0; ipt<nPtBins; ipt++){
77+
fOutYaml <<" - [0., 0., " <<oSystErr->GetTrackingEffErr(midPtBins[ipt]) <<", " <<oSystErr->GetTrackingEffErr(midPtBins[ipt]) <<"]" <<endl;
78+
}
79+
fOutYaml <<endl;
80+
81+
82+
fOutYaml <<"ptshape:" <<endl;
83+
for(int ipt=0; ipt<nPtBins; ipt++){
84+
fOutYaml <<" - [0., 0., " <<oSystErr->GetMCPtShapeErr(midPtBins[ipt]) <<", " <<oSystErr->GetMCPtShapeErr(midPtBins[ipt]) <<"]" <<endl;
85+
}
86+
fOutYaml <<endl;
87+
88+
89+
fOutYaml <<"feeddown_mult:" <<endl;
90+
//TString fpromptname = "gFcConservative";
91+
//if(isLc) fpromptname = "gFcCorrConservative";
92+
//TGraphAsymmErrors* fPrompt = (TGraphAsymmErrors*)fInput->Get(fpromptname.Data());
93+
for(int ipt=0; ipt<nPtBins; ipt++){
94+
//double errYhigh = fPrompt->GetErrorYhigh(ipt+1);
95+
//double errYlow = fPrompt->GetErrorYlow(ipt+1);
96+
//NOT PART OF ALIHFSYSTERR, TO BE FILLED IN BY HAND
97+
fOutYaml <<" - [0., 0., " <<0. <<", " <<0. <<"]" <<endl;
98+
}
99+
fOutYaml <<endl;
100+
101+
102+
fOutYaml <<"trigger:" <<endl;
103+
for(int ipt=0; ipt<nPtBins; ipt++){
104+
//NOT PART OF ALIHFSYSTERR, TO BE FILLED IN BY HAND
105+
fOutYaml <<" - [0., 0., " <<0. <<", " <<0. <<"]" <<endl;
106+
}
107+
fOutYaml <<endl;
108+
109+
110+
fOutYaml <<"multiplicity_weights:" <<endl;
111+
for(int ipt=0; ipt<nPtBins; ipt++){
112+
//NOT PART OF ALIHFSYSTERR, TO BE FILLED IN BY HAND
113+
fOutYaml <<" - [0., 0., " <<0. <<", " <<0. <<"]" <<endl;
114+
}
115+
fOutYaml <<endl;
116+
117+
118+
fOutYaml <<"multiplicity_interval:" <<endl;
119+
for(int ipt=0; ipt<nPtBins; ipt++){
120+
//NOT PART OF ALIHFSYSTERR, TO BE FILLED IN BY HAND
121+
fOutYaml <<" - [0., 0., " <<0. <<", " <<0. <<"]" <<endl;
122+
}
123+
fOutYaml <<endl;
124+
125+
126+
fOutYaml <<"branching_ratio:" <<endl;
127+
for(int ipt=0; ipt<nPtBins; ipt++){
128+
if(!isLc) fOutYaml <<" - [0., 0., " <<0.0129 <<", " <<0.0129 <<"]" <<endl;
129+
else fOutYaml <<" - [0., 0., " <<0.053 <<", " <<0.053 <<"]" <<endl;
130+
//fOutYaml <<" - [0., 0., " <<oSystErr->GetBRErr() <<", " <<oSystErr->GetBRErr() <<"]" <<endl;
131+
}
132+
fOutYaml <<endl;
133+
134+
135+
fOutYaml <<"sigmav0:" <<endl;
136+
for(int ipt=0; ipt<nPtBins; ipt++){
137+
fOutYaml <<" - [0., 0., " <<0.05 <<", " <<0.05 <<"]" <<endl;
138+
//fOutYaml <<" - [0., 0., " <<oSystErr->GetNormErr() <<", " <<oSystErr->GetNormErr() <<"]" <<endl;
139+
}
140+
fOutYaml <<endl;
141+
142+
143+
fOutYaml.close();
144+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# For files with final results, see [AN repo](https://gitlab.cern.ch/D_meson_analyses/d2h-vs-mult-pp13/-/tree/master/)
2+
3+
## NB: plot_final_results_*.py will only work in AN note repository. Shown here as example
4+
5+
Since this analysis ended up being combined with a non-MLHEP D0 and Lc -> pKpi analysis, the final macros were developed + maintained in the Analysis Note repository. The working versions of these macros can be found [here](https://gitlab.cern.ch/D_meson_analyses/d2h-vs-mult-pp13/-/tree/master/macros_final) (calculation of the observables, systematic propagation, Lc averaging, ...), and [here](https://gitlab.cern.ch/D_meson_analyses/d2h-vs-mult-pp13/-/tree/master/HP20Preliminaries) (plotting in ALICE Preliminary layout).
6+
7+
**The functions used are the same as in MachineLearningHEP/machine_learning_hep/utilities_plot.py**
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#############################################################################
2+
## © Copyright CERN 2018. All rights not expressly granted are reserved. ##
3+
## Author: [email protected] ##
4+
## This program is free software: you can redistribute it and/or modify it ##
5+
## under the terms of the GNU General Public License as published by the ##
6+
## Free Software Foundation, either version 3 of the License, or (at your ##
7+
## option) any later version. This program is distributed in the hope that ##
8+
## it will be useful, but WITHOUT ANY WARRANTY; without even the implied ##
9+
## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ##
10+
## See the GNU General Public License for more details. ##
11+
## You should have received a copy of the GNU General Public License ##
12+
## along with this program. if not, see <https://www.gnu.org/licenses/>. ##
13+
#############################################################################
14+
15+
"""
16+
main script for doing final stage analysis
17+
18+
NB: Duplicate of macro in AN Note repository. Will not work here!
19+
Just as an example how functions can be used
20+
"""
21+
import os
22+
# pylint: disable=import-error, no-name-in-module, unused-import
23+
import yaml
24+
from ROOT import TFile, gStyle, gROOT, TH1F, TGraphAsymmErrors, TH1
25+
from ROOT import kBlue, kAzure, kOrange, kGreen, kBlack, kRed, kWhite
26+
from ROOT import Double, TCanvas, gPad
27+
from machine_learning_hep.utilities_plot import Errors
28+
from machine_learning_hep.utilities_plot import average_pkpi_pk0s
29+
30+
def extract_histo(histo_name, path):
31+
32+
in_file = TFile.Open(path, "READ")
33+
histo = in_file.Get(histo_name)
34+
if isinstance(histo, TH1):
35+
histo.SetDirectory(0)
36+
return histo
37+
38+
def make_standard_save_path(prefix, filepath):
39+
40+
folder_plots = f"{filepath}"
41+
if not os.path.exists(folder_plots):
42+
print("creating folder ", folder_plots)
43+
os.makedirs(folder_plots)
44+
return f"{folder_plots}/{prefix}.eps"
45+
46+
47+
#############################################################################
48+
############################# Input arguments ##############################
49+
#############################################################################
50+
51+
SIGMAV0 = 57.8e9
52+
BRPKPI = 0.0623
53+
BRPK0S = 0.0109
54+
PTBINS = 6
55+
56+
FILE_PKPI = "inputfiles_HP20/finalcrossLcpKpippMBvspt_ntrklmult4.root"
57+
FILE_PK0S = "inputfiles_HP20/finalcrossLcpK0sppMBvspt_ntrklmult4.root"
58+
FILE_PK0S2 = "inputfiles_HP20/FeeddownSyst_NbNbx2_LcpK0sppMBvspt_ntrkl.root"
59+
FILE_OUT = "inputfiles_HP20/finalcrossLcAverageMBvspt_ntrklmult4.root"
60+
61+
ERROR_PKPI = "syst_HP20/syst_forLcaverage/LcpKpipp/errors_histoSigmaCorr_4.yaml"
62+
ERROR_PK0S = "syst_HP20/syst_forLcaverage/LcpK0spp/errors_histoSigmaCorr_4.yaml"
63+
ERROR_OUT = "syst_HP20/syst_forLcaverage/errors_avg_histoSigmaCorr_4.yaml"
64+
65+
gROOT.SetBatch(True)
66+
67+
68+
#############################################################################
69+
################################# Average ###################################
70+
#############################################################################
71+
72+
HISTO_PKPI = extract_histo("histoSigmaCorr_rebin", FILE_PKPI)
73+
HISTO_PKPI.SetName(f"histoSigmaCorr_pKpi")
74+
HISTO_PKPI.Scale(1./BRPKPI)
75+
HISTO_PK0S = extract_histo("histoSigmaCorr", FILE_PK0S)
76+
HISTO_PK0S.SetName(f"histoSigmaCorr_pK0s")
77+
HISTO_PK0S.Scale(1./BRPK0S)
78+
HISTO_PK0S.Scale(1./SIGMAV0)
79+
80+
GRFD_PKPI = extract_histo("gFcCorrConservative", FILE_PKPI)
81+
GRFD_PK0S = extract_histo("gNbCorrConservative", FILE_PK0S2)
82+
83+
DICTEXTRA_PKPI = {}
84+
HISTOEFF_PKPI = extract_histo("hDirectEffpt", FILE_PKPI)
85+
ERROREFF_PKPI = []
86+
for i in range(HISTOEFF_PKPI.GetNbinsX()):
87+
print(HISTOEFF_PKPI.GetBinCenter(i+1))
88+
RELERREFF = HISTOEFF_PKPI.GetBinError(i+1) / HISTOEFF_PKPI.GetBinContent(i+1)
89+
if i == 0:
90+
ERROREFF_PKPI.append([0, 0, 99, 99])
91+
else:
92+
ERROREFF_PKPI.append([0, 0, RELERREFF, RELERREFF])
93+
DICTEXTRA_PKPI["statunceff"] = ERROREFF_PKPI
94+
ERRSPKPI = Errors(PTBINS)
95+
ERRSPKPI.read(ERROR_PKPI, DICTEXTRA_PKPI)
96+
97+
DICTEXTRA_PK0S = {}
98+
HISTOEFF_PK0S = extract_histo("hDirectEffpt", FILE_PK0S)
99+
ERROREFF_PK0S = []
100+
for i in range(HISTOEFF_PK0S.GetNbinsX()):
101+
RELERREFF = HISTOEFF_PK0S.GetBinError(i+1) / HISTOEFF_PK0S.GetBinContent(i+1)
102+
ERROREFF_PK0S.append([0, 0, RELERREFF, RELERREFF])
103+
DICTEXTRA_PK0S["statunceff"] = ERROREFF_PK0S
104+
ERRSPK0S = Errors(PTBINS)
105+
ERRSPK0S.read(ERROR_PK0S, DICTEXTRA_PK0S)
106+
107+
MATCHPKPI = [-99, 1, 2, 3, 4, 5]
108+
MATCHPK0S = [1, 2, 3, 4, 5, 6]
109+
MATCHPKPIGR = [-99, 2, 3, 4, 5, 6] #Empty bin 0-1 still in fprompt tgraph
110+
MATCHPK0SGR = [1, 2, 3, 4, 5, 6]
111+
112+
AVGCORRYIELD, AVGSTATUNC, AVGFPROMPT, \
113+
AVGFPROMPTLOW, AVGFPROMPTHIGH, AVGERROR = average_pkpi_pk0s(HISTO_PKPI, HISTO_PK0S,
114+
GRFD_PKPI, GRFD_PK0S,
115+
ERRSPKPI, ERRSPK0S,
116+
MATCHPKPI, MATCHPK0S,
117+
MATCHPKPIGR, MATCHPK0SGR)
118+
119+
HISTAVG = HISTO_PK0S.Clone("histoSigmaCorr_average")
120+
GRFDAVG = TGraphAsymmErrors(PTBINS)
121+
for ipt in range(PTBINS):
122+
HISTAVG.SetBinContent(ipt+1, AVGCORRYIELD[ipt])
123+
HISTAVG.SetBinError(ipt+1, AVGSTATUNC[ipt])
124+
GRFDAVG.SetPoint(ipt+1, GRFD_PK0S.GetX()[ipt+1], AVGFPROMPT[ipt])
125+
GRFDAVG.SetPointError(ipt+1, GRFD_PK0S.GetEXlow()[ipt+1], GRFD_PK0S.GetEXhigh()[ipt+1], \
126+
AVGFPROMPTLOW[ipt], AVGFPROMPTHIGH[ipt])
127+
128+
AVGERROR.print()
129+
print("\n\n Store above in", ERROR_OUT)
130+
131+
print("\n\n\nStoring ROOT objects in", FILE_OUT)
132+
FOUT = TFile(FILE_OUT, "RECREATE")
133+
FOUT.cd()
134+
HISTAVG.Write("histoSigmaCorr_average")
135+
HISTO_PKPI.Write("histoSigmaCorr_pKpi")
136+
HISTO_PK0S.Write("histoSigmaCorr_pK0s")
137+
138+
GRFDAVG.Write("gFcCorrConservative_average")
139+
GRFD_PKPI.Write("gFcCorrConservative_pKpi")
140+
GRFD_PK0S.Write("gNbCorrConservative_pK0s")
141+
FOUT.Close()

Analyses/ALICE_D2H_vs_mult_pp13/data/errors/Dspp/MBvspt_ntrkl/errors_histoSigmaCorr_1.yaml renamed to Analyses/ALICE_D2H_vs_mult_pp13/data/EXAMPLE_errors_histoSigmaCorr_0.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# Taken from https://indico.cern.ch/event/855807/contributions/3601563/attachments/1928380/3193129/HF_171019_Ds_MLHEP.pdf
2-
# Updated by Luuk on 20/10 after discussion after HF approval
3-
# MULTIPLICITY 0 < ntrkl < inf
4-
#
51

6-
#Systematics in this dictionary. feeddown_Nb will be read from inputfile
2+
3+
#Example file for storing systematic errors
74
names: ["yield", "cut", "pid", "track", "ptshape", "feeddown_mult", "feeddown_mult_spectra", "trigger", "multiplicity_weights", "multiplicity_interval", "branching_ratio", "sigmav0"]
85

96
yield:
@@ -83,10 +80,11 @@ branching_ratio:
8380
- [0., 0., 0.035, 0.035]
8481
- [0., 0., 0.035, 0.035]
8582

86-
#Conservative guess from trigger experts
8783
sigmav0:
8884
- [0., 0., 0.05, 0.05]
8985
- [0., 0., 0.05, 0.05]
9086
- [0., 0., 0.05, 0.05]
9187
- [0., 0., 0.05, 0.05]
9288
- [0., 0., 0.05, 0.05]
89+
90+
#StatUncEff and Feeddown_NB are added automatically in final_results_* macros
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)