]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/macros/configs/PbPb/ConfigWeightFactors.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / configs / PbPb / ConfigWeightFactors.C
1 void ConfigWeightFactors(AliAnalysisTaskHFE *task, Bool_t syst = kFALSE, Int_t collType = 1, TString filename = "nonHFEcorrect.root"){
2   //
3   // Set weighting factors for nonHFE backgrounds
4   // Option "collType": 0 for pp 2.76 TeV; 1 for pp 7 TeV; 2 for PbPb; 3 for DPMJET pPb; 4 for HIJING pPb; 5 for DPMJET/HIJING pPb: 6 Pb-Pb LHC11a10abis; 7 Pb-Pb LHC11a10b_plus; 8 Pb-Pb LHC11a10b_plus for LHC11a10abis ; 9 Pb-Pb LHC11a10b_plus for LHC11a10bbis; 10 for pp LHC106; 11 for pp LHC106a; 12 for pp LHC107a_d
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   printf("Take the weights from %s\n",Form("$ALICE_ROOT/PWGHF/hfe/macros/%s",filename.Data()));
19   printf("collType %d\n",collType);
20   TFile *weightFile = TFile::Open(Form("$ALICE_ROOT/PWGHF/hfe/macros/%s",filename.Data()));
21   if(weightFile){
22     if(syst){
23       TH1F *hRelErr[2][2];//errors for pion yields, which form the correlated component of the relative error for all other decaying mesons, except for eta, which are parameterized independently
24       if(collType == 1){
25         hRelErr[0][0] = (TH1F*)weightFile->Get("hErrorspionLower");
26         hRelErr[0][1] = (TH1F*)weightFile->Get("hErrorspionUpper");
27         hRelErr[1][0] = (TH1F*)weightFile->Get("hErrorsetaLower");
28         hRelErr[1][1] = (TH1F*)weightFile->Get("hErrorsetaUpper");
29       }
30       else if(collType == 0){
31         hRelErr[0][0] = (TH1F*)weightFile->Get("hErrors_2.76TeV_pionLower");
32         hRelErr[0][1] = (TH1F*)weightFile->Get("hErrors_2.76TeV_pionUpper");
33         //hRelErr[1][0] = (TH1F*)weightFile->Get("hErrors_2.76TeV_etaLower");
34         //hRelErr[1][1] = (TH1F*)weightFile->Get("hErrors_2.76TeV_etaUpper");
35       }
36       else if(collType == 3 || collType == 4 || collType == 5){
37         hRelErr[0][0] = (TH1F*)weightFile->Get("hErrors_pPb_5.023TeV_pionLower");
38         hRelErr[0][1] = (TH1F*)weightFile->Get("hErrors_pPb_5.023TeV_pionUpper");
39         for(int i=0; i<hRelErr[0][0]->GetNbinsX(); i++){ //assign 7% systematic uncertainties for pPb
40           hRelErr[0][0]->SetBinContent(i+1, -0.07);
41           hRelErr[0][1]->SetBinContent(i+1, 0.07);
42         }
43       }
44     }
45     for(Int_t iCent = 0; iCent < 11; iCent++){//centrality bins
46       for(Int_t iSpecies = 0; iSpecies < 6; iSpecies++){//species of decaying mesons
47         TH1F *hRatio = 0x0;
48         if(collType == 1){
49           hRatio = (TH1F*)weightFile->Get(Form("hRatio%s",backNameMC[iSpecies]));
50         }
51         else if(collType == 0){
52           hRatio = (TH1F*)weightFile->Get(Form("hRatio_2.76TeV_%s",backNameMC[iSpecies]));
53         }
54         else if(collType == 3){
55           hRatio = (TH1F*)weightFile->Get(Form("hRatio_pPb_5.023TeV_DPMJET_%s",backNameMC[iSpecies]));
56         }
57         else if(collType == 4){
58           hRatio = (TH1F*)weightFile->Get(Form("hRatio_pPb_5.023TeV_HIJING_%s",backNameMC[iSpecies]));
59         }
60         else if(collType == 5){
61           hRatio = (TH1F*)weightFile->Get(Form("hRatio_pPb_5.023TeV_DvsH_%s",backNameMC[iSpecies]));
62         }
63         else if(collType == 10){
64           hRatio = (TH1F*)weightFile->Get(Form("hRatio_10f6_%s",backNameMC[iSpecies]));
65         }
66         else if(collType == 11){
67           hRatio = (TH1F*)weightFile->Get(Form("hRatio_10f6a_%s",backNameMC[iSpecies]));
68         }
69         else if(collType == 12){
70           hRatio = (TH1F*)weightFile->Get(Form("hRatio_10f7a_d_%s",backNameMC[iSpecies]));
71         }
72         else if(collType == 2){
73           if((iCent == 1)||(iCent == 4)){ 
74             hRatio = (TH1F*)weightFile->Get(Form("hRatio%s%d",backNameMC[iSpecies],iCent-1));
75           }
76           else if(iCent > 7){
77             hRatio = (TH1F*)weightFile->Get(Form("hRatio%s7",backNameMC[iSpecies]));
78           }
79           else{
80             hRatio = (TH1F*)weightFile->Get(Form("hRatio%s%d",backNameMC[iSpecies],iCent));
81           }
82         }
83         else if(collType == 6){
84           if((iCent == 1)||(iCent == 4)){ 
85             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10abis_%s%d",backNameMC[iSpecies],iCent-1));
86           }
87           else if(iCent > 7){
88             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10abis_%s7",backNameMC[iSpecies]));
89           }
90           else{
91             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10abis_%s%d",backNameMC[iSpecies],iCent));
92           }
93         }
94         else if(collType == 7){
95           if((iCent == 1)||(iCent == 4)){ 
96             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10bplus_%s%d",backNameMC[iSpecies],iCent-1));
97           }
98           else if(iCent > 7){
99             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10bplus_%s7",backNameMC[iSpecies]));
100           }
101           else{
102             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10bplus_%s%d",backNameMC[iSpecies],iCent));
103           }
104         }
105         else if(collType == 8){
106           if((iCent == 1)||(iCent == 4)){ 
107             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_bplusvasabis_%s%d",backNameMC[iSpecies],iCent-1));
108           }
109           else if(iCent > 7){
110             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_bplusvasabis_%s7",backNameMC[iSpecies]));
111           }
112           else{
113             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_bplusvasabis_%s%d",backNameMC[iSpecies],iCent));
114           }
115         }
116         else {
117           if((iCent == 1)||(iCent == 4)){ 
118             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10bbis_%s%d",backNameMC[iSpecies],iCent-1));
119           }
120           else if(iCent > 7){
121             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10bbis_%s7",backNameMC[iSpecies]));
122           }
123           else{
124             hRatio = (TH1F*)weightFile->Get(Form("hRatio_PbPb_2.76TeV_LHC11a10bbis_%s%d",backNameMC[iSpecies],iCent));
125           }
126         }
127         for(Int_t iBin = 1; iBin < 45; iBin++){//momentum bin of mother meson
128           if(iCent == 0){
129             elecBackGroundWeight[iCent][iSpecies][iBin-1][0] = hRatio->GetBinContent(iBin);
130             if(syst && (collType != 2)){
131               for(Int_t iError = 0; iError < 2; iError++){//0: best estimate, 1,2: lower, upper uncertainty level
132                 if((iSpecies == 1) && (collType == 1))
133                   elecBackGroundWeight[iCent][iSpecies][iBin-1][iError+1]=elecBackGroundWeight[iCent][iSpecies][iBin-1][0]*(1+hRelErr[1][iError]->GetBinContent(iBin));
134                 else
135                   elecBackGroundWeight[iCent][iSpecies][iBin-1][iError+1]=elecBackGroundWeight[iCent][iSpecies][iBin-1][0]*(1+hRelErr[0][iError]->GetBinContent(iBin));//Addition of relative errors from histograms with "+", because lower errors are defined as negative numbers in the reference histograms!
136               }
137             }
138           }
139           else{
140             if((collType == 2) || (collType > 5)){
141               elecBackGroundWeight[iCent][iSpecies][iBin-1][0] = hRatio->GetBinContent(iBin);    
142             } 
143           }
144         }
145       }
146     }
147     weightFile->Close();
148   }
149   else{
150     printf("No reference file for background electron weighting found!\n");   
151   }
152   
153   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
154   
155   for(Int_t iCent = 0; iCent < 11; iCent++){//centrality bins
156     for(Int_t iBin = 1; iBin < 45; iBin++){//for all centralities, pt bins and all meson decays, set weighting factors for daughter electrons
157       task->SetBinLimits(iBin-1,binLimit[iBin-1]);
158       for(Int_t iSpecies = 0; iSpecies < 6; iSpecies++){
159         for(Int_t iError = 0; iError < 3; iError++)
160           task->SetElecBackGroundFactors(iBin-1, iSpecies, iCent, iError, elecBackGroundWeight[iCent][iSpecies][iBin-1][iError]);
161       }
162     }
163   }
164 }