]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/macros/configs/pp/ConfigWeightFactors.C
add extra namings
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / configs / pp / ConfigWeightFactors.C
CommitLineData
d84c68e9 1void ConfigWeightFactors(AliAnalysisTaskHFE *task, Bool_t syst = kFALSE, Bool_t ispp = 1){
2 //
3 // Set weighting factors for nonHFE backgrounds
4 //
5
6 //Get the correction factors for Non-HF electron yields from a root-file
7 Double_t elecBackGroundWeight[11][6][44][3];//centrality, species, momentum, background level
8 for(Int_t iCent = 0; iCent < 11; iCent++){
9 for(Int_t iSpecies = 0; iSpecies < 6; iSpecies++){
10 for(Int_t iBin = 0; iBin < 44; iBin++){
11 for(Int_t iError = 0; iError < 3; iError++){
12 elecBackGroundWeight[iCent][iSpecies][iBin][iError] = 0;
13 }
14 }
15 }
16 }
17 const Char_t *backNameMC[6] = {"pion","eta","omega","phi","etap","rho"};
18 TFile *weightFile = TFile::Open(Form("%s/util/hfe/rootfiles/nonHFEcorrect.root", gSystem->Getenv("TRAIN_ROOT")));
19 if(weightFile){
20 if(syst){
21 TH1F *hRelErr[2];//errors for pion yields, which form the correlated component of the relative error for all other decaying mesons
22 hRelErr[0] = (TH1F*)weightFile->Get("hErrorspionLower");
23 hRelErr[1] = (TH1F*)weightFile->Get("hErrorspionUpper");
24 }
25 for(Int_t iCent = 0; iCent < 11; iCent++){//centrality bins
26 for(Int_t iSpecies = 0; iSpecies < 6; iSpecies++){//species of decaying mesons
27 TH1F *hRatio = 0x0;
28 if(ispp){
29 hRatio = (TH1F*)weightFile->Get(Form("hRatio%s",backNameMC[iSpecies]));
30 }
31 else{
32 if((iCent == 1)||(iCent == 4)){
33 hRatio = (TH1F*)weightFile->Get(Form("hRatio%s%d",backNameMC[iSpecies],iCent-1));
34 }
35 else if(iCent > 7){
36 hRatio = weightFile->Get(Form("hRatio%s7",backNameMC[iSpecies]));
37 }
38 else{
39 hRatio = (TH1F*)weightFile->Get(Form("hRatio%s%d",backNameMC[iSpecies],iCent));
40 }
41 }
42 for(Int_t iBin = 1; iBin < 45; iBin++){//momentum bin of mother meson
43 if(iCent == 0){
44 elecBackGroundWeight[iCent][iSpecies][iBin-1][0] = hRatio->GetBinContent(iBin);
45 if(syst && ispp){
46 for(Int_t iError = 0; iError < 2; iError++){//0: best estimate, 1,2: lower, upper uncertainty level
47 elecBackGroundWeight[iCent][iSpecies][iBin-1][iError+1]=elecBackGroundWeight[iCent][iSpecies][iBin-1][0]*(1+hRelErr[iError]->GetBinContent(iBin));//Addition of relative errors from histograms with "+", because lower errors are defined as negative numbers in the reference histograms!
48 }
49 }
50 }
51 else{
52 if(!ispp){
53 elecBackGroundWeight[iCent][iSpecies][iBin-1][0] = hRatio->GetBinContent(iBin);
54 }
55 }
56 }
57 }
58 }
59 weightFile->Close();
60 }
61 else{
62 printf("No reference file for weighting found!\n");
63 }
64
65 const Double_t binLimit[45] = {0.1,0.112797,0.127231,0.143512,0.161877,0.182592,0.205957,0.232313,0.262041,0.295573,0.333397,0.37606,0.424183,0.478465,0.539692,0.608754,0.686654,0.774523,0.873636,0.985432,1.11153,1.25377,1.41421,1.59519,1.79932,2.02957,2.28928,2.58223,2.91267,3.2854,3.70582,4.18004,4.71494,5.3183,5.99886,6.76651,7.6324,8.60909,9.71076,10.9534,12.3551,13.9361,15.7195,17.731,20};//bin limits from the measured pi0 spectrum - possibly we won't need the last bin
66
67 for(Int_t iBin = 1; iBin < 45; iBin++){//for all pt bins and all meson decays, set weighting factors for daughter electrons
68 task->SetBinLimits(iBin,binLimit[iBin-1]);
69 for(Int_t iSpecies = 0; iSpecies < 6; iSpecies++){
70 for(Int_t iError = 0; iError < 3; iError++)
71 task->SetElecBackGroundFactors(iBin, iSpecies, 0, iError, elecBackGroundWeight[0][iSpecies][iBin-1][iError]);
72 }
73 }
74}