Adding class for dealing with systematic uncertainties of D-hadron correlation analyses.
[u/mrichter/AliRoot.git] / PWGHF / correlationHF / AliHFDhadronCorrSystUnc.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16
17 /* $Id: $ */
18
19 /////////////////////////////////////////////////////////////
20 // class for systematic uncertainties on D meson -hadron correlation distribution
21 //
22 // Author: A. Rossi, andrea.rossi@cern.ch
23 /////////////////////////////////////////////////////////////
24 #include <Riostream.h>
25 #include "AliHFDhadronCorrSystUnc.h"
26 #include <TMath.h>
27 #include <TH1D.h>
28 #include <TH2D.h>
29 #include <TCanvas.h>
30 #include <TGraphAsymmErrors.h>
31 #include <TNamed.h>
32
33 using std::cout;
34 using std::endl;
35
36 ClassImp(AliHFDhadronCorrSystUnc)
37
38 AliHFDhadronCorrSystUnc::AliHFDhadronCorrSystUnc() : TNamed(), 
39   fmeson(),
40   fstrmeson(),
41   fstrptAss(),
42   fstrptD(),
43   fhDeltaPhiTemplate(),
44   fhYieldExtraction(),
45   fhBackSubtractionMin(),
46   fhBackSubtractionMax(),
47   fhBeautyFDmin(),
48   fhBeautyFDmax(),
49   fhMCclosureTestMin(),
50   fhMCclosureTestMax(),
51   fhMCcorrectionsMin(),
52   fhMCcorrectionsMax(),
53   fhMCDefficiencyMin(),
54   fhMCDefficiencyMax(),
55   fhSecContaminationMin(),
56   fhSecContaminationMax(),
57   fhTotalMin(),
58   fhTotalMax(),
59   fhTotalNonFDMin(),
60   fhTotalNonFDMax(),
61   fhTotalNonFlatDPhiMin(),
62   fhTotalNonFlatDPhiMax(),
63   fhtotFlatMin(),
64   fhtotFlatMax(),
65   fgrYieldUnc(),         
66   fgrBackSubUnc(),
67   fgrMCcorrections(),   
68   fgrMCDefficiency(),   
69   fgrSecContamination(),   
70   fgrMCclosureTest(),  
71   fgrBeautyFD(),
72   fgrYieldUncRel(),         
73   fgrBackSubUncRel(),
74   fgrMCcorrectionsRel(),   
75   fgrMCDefficiencyRel(),   
76   fgrSecContaminationRel(),   
77   fgrMCclosureTestRel(),  
78   fgrBeautyFDRel(),
79   fgrTotal(),
80   fgrTotalRel(),
81   fgrTotalNonFD(),
82   fgrTotalNonFlatDPhi(),
83   fgrTotalNonFlatDPhiRel(),
84   fgrTotalFlatDPhi(),
85   fgrTotalFlatDPhiRel()
86         
87 {
88   // default constructor
89 }
90
91
92 AliHFDhadronCorrSystUnc::AliHFDhadronCorrSystUnc(const char* name) : 
93   TNamed(name,name),                                               
94   fmeson(),
95   fstrmeson(),
96   fstrptAss(),
97   fstrptD(),
98   fhDeltaPhiTemplate(),
99   fhYieldExtraction(),
100   fhBackSubtractionMin(),
101   fhBackSubtractionMax(),
102   fhBeautyFDmin(),
103   fhBeautyFDmax(),
104   fhMCclosureTestMin(),
105   fhMCclosureTestMax(),
106   fhMCcorrectionsMin(),
107   fhMCcorrectionsMax(),
108   fhMCDefficiencyMin(),
109   fhMCDefficiencyMax(),
110   fhSecContaminationMin(),
111   fhSecContaminationMax(),
112   fhTotalMin(),
113   fhTotalMax(),
114   fhTotalNonFDMin(),
115   fhTotalNonFDMax(),
116   fhTotalNonFlatDPhiMin(),
117   fhTotalNonFlatDPhiMax(),
118   fhtotFlatMin(),
119   fhtotFlatMax(),
120   fgrYieldUnc(),         
121   fgrBackSubUnc(),
122   fgrMCcorrections(),   
123   fgrMCDefficiency(),   
124   fgrSecContamination(),   
125   fgrMCclosureTest(),  
126   fgrBeautyFD(),
127   fgrYieldUncRel(),         
128   fgrBackSubUncRel(),
129   fgrMCcorrectionsRel(),   
130   fgrMCDefficiencyRel(),   
131   fgrSecContaminationRel(),   
132   fgrMCclosureTestRel(),  
133   fgrBeautyFDRel(),
134   fgrTotal(),
135   fgrTotalRel(),
136   fgrTotalNonFD(),
137   fgrTotalNonFlatDPhi(),
138   fgrTotalNonFlatDPhiRel(),
139   fgrTotalFlatDPhi(),
140   fgrTotalFlatDPhiRel()
141 {
142   // default constructor
143 }
144
145
146
147 AliHFDhadronCorrSystUnc::~AliHFDhadronCorrSystUnc(){
148   // destructor
149   
150   delete fhDeltaPhiTemplate;
151   delete fhYieldExtraction;
152   delete fhBackSubtractionMin;
153   delete   fhBackSubtractionMax;
154   delete  fhBeautyFDmin;
155   delete  fhBeautyFDmax;
156   delete  fhMCclosureTestMin;
157   delete  fhMCclosureTestMax;
158   delete  fhMCcorrectionsMin;
159   delete  fhMCcorrectionsMax;
160   delete  fhMCDefficiencyMin;
161   delete  fhMCDefficiencyMax;
162   delete  fhSecContaminationMin;
163   delete  fhSecContaminationMax;
164   delete  fhTotalMin;
165   delete fhTotalMax;
166   delete fhTotalNonFDMin;
167   delete fhTotalNonFDMax;
168   delete fhTotalNonFlatDPhiMin;
169   delete fhTotalNonFlatDPhiMax;
170   delete fhtotFlatMin;
171   delete fhtotFlatMax;
172   delete fgrYieldUnc;
173   delete fgrBackSubUnc;
174   delete fgrMCcorrections;
175   delete fgrMCDefficiency;
176   delete fgrSecContamination;
177   delete fgrMCclosureTest;  
178   delete fgrBeautyFD;   
179   delete fgrYieldUncRel;
180   delete fgrBackSubUncRel;
181   delete fgrMCcorrectionsRel;
182   delete fgrMCDefficiencyRel;
183   delete fgrSecContaminationRel;
184   delete fgrMCclosureTestRel;  
185   delete fgrBeautyFDRel;   
186   delete fgrTotal;
187   delete fgrTotalRel;
188   delete fgrTotalNonFD;
189   delete fgrTotalNonFlatDPhi;
190   delete fgrTotalNonFlatDPhiRel;
191   delete fgrTotalFlatDPhi;
192   delete fgrTotalFlatDPhiRel;
193
194 }
195
196
197 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DzeroLowPtAss03HP(){
198   fmeson=0;
199   fstrmeson="Dzero";
200   fstrptAss="ptAsMore03";
201   fstrptD="Dpt3to5";
202   if(!fhDeltaPhiTemplate){
203     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
204   }
205   Double_t x;
206   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
207   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
208   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
209     fhYieldExtraction->SetBinContent(j,0.1);
210   }
211
212   // Background D MESON candidate subtraction (side-band variations, etc.)
213   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
214   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
215     fhBackSubtractionMin->SetBinContent(j,-0.05);
216   }
217
218   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
219   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
220     fhBackSubtractionMax->SetBinContent(j,0.05);
221   }
222
223   
224   // MC CORRECTIONS ( associatate track efficiency):
225   //  -5%  +10% for assoc track eff 
226   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
227   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
228     fhMCcorrectionsMin->SetBinContent(j,-0.05);
229   }
230
231   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
232   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
233     fhMCcorrectionsMax->SetBinContent(j,0.10);
234   }
235
236   // MC D EFF CORRECTION
237   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
238   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
239     fhMCDefficiencyMin->SetBinContent(j,-0.05);
240   }
241
242   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
243   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
244     fhMCDefficiencyMax->SetBinContent(j,0.05);
245   }
246
247
248   // Contamination from secondary tracks
249   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
250   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
251     fhSecContaminationMin->SetBinContent(j,-0.05);
252   }
253
254   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
255   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
256     fhSecContaminationMax->SetBinContent(j,0.05);
257   }
258
259
260   // MC CLOSURETEST (D meson efficiency)
261   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
262   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
263     x=fhMCclosureTestMin->GetBinLowEdge(j);
264     fhMCclosureTestMin->SetBinContent(j,-0.08);
265     
266     if(-0.4<x&&x<-0.2){    
267       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
268     }
269     else if(-0.2<x&&x<-0.1){    
270       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
271     }
272     else if(-0.1<x&&x<0.1){    
273       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
274     }
275     else if(0.1<x&&x<0.2){    
276       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
277     }
278     if(0.2<x&&x<0.4){    
279       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
280     }
281   }
282
283   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
284   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
285     //    x=fhMCclosureTestMax->GetBinLowEdge(j);
286     fhMCclosureTestMax->SetBinContent(j,0.);
287     
288     //     if(-0.4<x&&x<-0.2){    
289     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
290     //     }
291     //     else if(-0.2<x&&x<-0.1){    
292     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
293     //     }
294     //     else if(-0.2<x&&x<-0.1){    
295     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
296     //     }
297     //     else if(-0.1<x&&x<0.1){    
298     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
299     //     }
300     //     else if(0.1<x&&x<0.2){    
301     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
302     //     }
303     //     if(0.2<x&&x<0.4){    
304     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
305     //     }
306     
307   }
308   
309   // Feed-down 
310
311   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
312   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
313     x=fhBeautyFDmin->GetBinLowEdge(j);
314     fhBeautyFDmin->SetBinContent(j,-0.05);
315     
316   //   if(-0.4<x&&x<-0.2){    
317 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
318 //     }
319 //     else if(-0.2<x&&x<-0.1){    
320 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
321 //     }
322 //     else if(-0.2<x&&x<-0.1){    
323 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
324 //     }
325 //     else if(-0.1<x&&x<0.1){    
326 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
327 //     }
328 //     else if(0.1<x&&x<0.2){    
329 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
330 //     }
331 //     if(0.2<x&&x<0.4){    
332 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
333 //     }
334   }
335
336   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
337   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
338     x=fhBeautyFDmax->GetBinLowEdge(j);
339     fhBeautyFDmax->SetBinContent(j,0.03);
340    
341 //     if(-0.4<x&&x<-0.2){    
342 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
343 //     }
344 //     else if(-0.2<x&&x<-0.1){    
345 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
346 //     }
347 //     else if(-0.2<x&&x<-0.1){    
348 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
349 //     }
350 //     else if(-0.1<x&&x<0.1){    
351 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
352 //     }
353 //     else if(0.1<x&&x<0.2){    
354 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
355 //     }
356 //     if(0.2<x&&x<0.4){    
357 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
358 //     } 
359     
360   }
361   
362 }
363
364 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DzeroMidPtAss03HP(){
365
366   fmeson=0;
367   fstrmeson="Dzero";
368   fstrptAss="ptAsMore03";
369   fstrptD="Dpt5to8";
370   if(!fhDeltaPhiTemplate){
371     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
372   }
373   Double_t x;
374   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
375   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
376   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
377     fhYieldExtraction->SetBinContent(j,0.1);
378   }
379
380   // Background D MESON candidate subtraction (side-band variations, etc.)
381   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
382   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
383     fhBackSubtractionMin->SetBinContent(j,0.05);
384   }
385
386   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
387   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
388     fhBackSubtractionMax->SetBinContent(j,0.05);
389   }
390   
391   // MC CORRECTIONS:  -5%  +10% for assoc track eff
392   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
393   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
394     fhMCcorrectionsMin->SetBinContent(j,-0.05);
395   }
396
397   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
398   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
399     fhMCcorrectionsMax->SetBinContent(j,0.10);
400   }
401
402
403   // MC D EFF CORRECTION
404   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
405   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
406     fhMCDefficiencyMin->SetBinContent(j,-0.05);
407   }
408
409   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
410   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
411     fhMCDefficiencyMax->SetBinContent(j,0.05);
412   }
413
414
415   // Contamination from secondary tracks
416   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
417   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
418     fhSecContaminationMin->SetBinContent(j,-0.05);
419   }
420
421   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
422   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
423     fhSecContaminationMax->SetBinContent(j,0.05);
424   }
425
426   // MC CLOSURETEST (D meson efficiency)
427   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
428   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
429     x=fhMCclosureTestMin->GetBinLowEdge(j);
430     fhMCclosureTestMin->SetBinContent(j,-0.08);
431     
432     if(-0.4<x&&x<-0.2){    
433       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
434     }
435     else if(-0.2<x&&x<-0.1){    
436       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
437     }
438     else if(-0.1<x&&x<0.1){    
439       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
440     }
441     else if(0.1<x&&x<0.2){    
442       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
443     }
444     if(0.2<x&&x<0.4){    
445       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
446     }
447   }
448
449   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
450   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
451     x=fhMCclosureTestMax->GetBinLowEdge(j);
452     fhMCclosureTestMax->SetBinContent(j,0.);
453     
454     //     if(-0.4<x&&x<-0.2){    
455     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
456     //     }
457     //     else if(-0.2<x&&x<-0.1){    
458     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
459     //     }
460     //     else if(-0.2<x&&x<-0.1){    
461     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
462     //     }
463     //     else if(-0.1<x&&x<0.1){    
464     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
465     //     }
466     //     else if(0.1<x&&x<0.2){    
467     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
468     //     }
469     //     if(0.2<x&&x<0.4){    
470     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
471     //     }
472     
473   }
474   
475   // Feed-down 
476
477   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
478   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
479     x=fhBeautyFDmin->GetBinLowEdge(j);
480     fhBeautyFDmin->SetBinContent(j,-0.05);
481     
482   //   if(-0.4<x&&x<-0.2){    
483 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
484 //     }
485 //     else if(-0.2<x&&x<-0.1){    
486 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
487 //     }
488 //     else if(-0.2<x&&x<-0.1){    
489 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
490 //     }
491 //     else if(-0.1<x&&x<0.1){    
492 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
493 //     }
494 //     else if(0.1<x&&x<0.2){    
495 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
496 //     }
497 //     if(0.2<x&&x<0.4){    
498 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
499 //     }
500   }
501
502   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
503   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
504     x=fhBeautyFDmax->GetBinLowEdge(j);
505     fhBeautyFDmax->SetBinContent(j,0.03);
506    
507 //     if(-0.4<x&&x<-0.2){    
508 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
509 //     }
510 //     else if(-0.2<x&&x<-0.1){    
511 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
512 //     }
513 //     else if(-0.2<x&&x<-0.1){    
514 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
515 //     }
516 //     else if(-0.1<x&&x<0.1){    
517 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
518 //     }
519 //     else if(0.1<x&&x<0.2){    
520 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
521 //     }
522 //     if(0.2<x&&x<0.4){    
523 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
524 //     } 
525     
526   }
527   
528 }
529
530
531 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DzeroHighPtAss03HP(){
532   
533   fmeson=0;
534   fstrmeson="Dzero";
535   fstrptAss="ptAsMore03";
536   fstrptD="Dpt8to16";
537   if(!fhDeltaPhiTemplate){
538     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
539   }
540
541   Double_t x;
542   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
543   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
544   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
545     fhYieldExtraction->SetBinContent(j,0.1);
546   }
547
548   // Background D MESON candidate subtraction (side-band variations, etc.)
549   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
550   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
551     fhBackSubtractionMin->SetBinContent(j,0.05);
552   }
553
554   // Background D MESON candidate subtraction (side-band variations, etc.)
555   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
556   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
557     fhBackSubtractionMax->SetBinContent(j,0.05);
558   }
559   
560   // MC CORRECTIONS,  -5% 10% for assoc track eff
561   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
562   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
563     fhMCcorrectionsMin->SetBinContent(j,-0.05);
564   }
565
566   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
567   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
568     fhMCcorrectionsMax->SetBinContent(j,0.10);
569   }
570
571
572   // MC D EFF CORRECTION
573   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
574   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
575     fhMCDefficiencyMin->SetBinContent(j,-0.05);
576   }
577
578   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
579   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
580     fhMCDefficiencyMax->SetBinContent(j,0.05);
581   }
582
583
584   // Contamination from secondary tracks
585   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
586   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
587     fhSecContaminationMin->SetBinContent(j,-0.05);
588   }
589
590   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
591   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
592     fhSecContaminationMax->SetBinContent(j,0.05);
593   }
594
595   // MC CLOSURETEST (D meson efficiency)
596   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
597   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
598     x=fhMCclosureTestMin->GetBinLowEdge(j);
599     fhMCclosureTestMin->SetBinContent(j,-0.08);
600     
601     if(-0.4<x&&x<-0.2){    
602       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
603     }
604     else if(-0.2<x&&x<-0.1){    
605       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
606     }
607     else if(-0.1<x&&x<0.1){    
608       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
609     }
610     else if(0.1<x&&x<0.2){    
611       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
612     }
613     if(0.2<x&&x<0.4){    
614       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
615     }
616   }
617
618   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
619   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
620     x=fhMCclosureTestMax->GetBinLowEdge(j);
621     fhMCclosureTestMax->SetBinContent(j,0.);
622     
623     //     if(-0.4<x&&x<-0.2){    
624     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
625     //     }
626     //     else if(-0.2<x&&x<-0.1){    
627     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
628     //     }
629     //     else if(-0.2<x&&x<-0.1){    
630     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
631     //     }
632     //     else if(-0.1<x&&x<0.1){    
633     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
634     //     }
635     //     else if(0.1<x&&x<0.2){    
636     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
637     //     }
638     //     if(0.2<x&&x<0.4){    
639     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
640     //     }
641     
642   }
643   
644   // Feed-down 
645
646   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
647   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
648     x=fhBeautyFDmin->GetBinLowEdge(j);
649     fhBeautyFDmin->SetBinContent(j,-0.05);
650     
651   //   if(-0.4<x&&x<-0.2){    
652 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
653 //     }
654 //     else if(-0.2<x&&x<-0.1){    
655 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
656 //     }
657 //     else if(-0.2<x&&x<-0.1){    
658 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
659 //     }
660 //     else if(-0.1<x&&x<0.1){    
661 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
662 //     }
663 //     else if(0.1<x&&x<0.2){    
664 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
665 //     }
666 //     if(0.2<x&&x<0.4){    
667 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
668 //     }
669   }
670
671   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
672   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
673     x=fhBeautyFDmax->GetBinLowEdge(j);
674     fhBeautyFDmax->SetBinContent(j,0.03);
675    
676 //     if(-0.4<x&&x<-0.2){    
677 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
678 //     }
679 //     else if(-0.2<x&&x<-0.1){    
680 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
681 //     }
682 //     else if(-0.2<x&&x<-0.1){    
683 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
684 //     }
685 //     else if(-0.1<x&&x<0.1){    
686 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
687 //     }
688 //     else if(0.1<x&&x<0.2){    
689 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
690 //     }
691 //     if(0.2<x&&x<0.4){    
692 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
693 //     } 
694     
695   }
696
697 }
698
699
700
701
702 //--------------------------------------------------
703 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DstarLowPtAss03HP(){
704   fmeson=1;
705   fstrmeson="Dstar";
706   fstrptAss="ptAsMore03";
707   fstrptD="Dpt3to5";
708   if(!fhDeltaPhiTemplate){
709     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
710   }
711   Double_t x;
712   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
713   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
714   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
715     fhYieldExtraction->SetBinContent(j,0.1);
716   }
717
718   // Background D MESON candidate subtraction (side-band variations, etc.)
719   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
720   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
721     fhBackSubtractionMin->SetBinContent(j,0.05);
722   }
723
724   // Background D MESON candidate subtraction (side-band variations, etc.)
725   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
726   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
727     fhBackSubtractionMax->SetBinContent(j,0.05);
728   }
729   
730   // MC CORRECTIONS, -5%  10% for assoc track eff
731   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
732   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
733     fhMCcorrectionsMin->SetBinContent(j,-0.05);
734   }
735
736   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
737   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
738     fhMCcorrectionsMax->SetBinContent(j,0.10);
739   }
740
741
742   // MC D EFF CORRECTION
743   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
744   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
745     fhMCDefficiencyMin->SetBinContent(j,-0.05);
746   }
747
748   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
749   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
750     fhMCDefficiencyMax->SetBinContent(j,0.05);
751   }
752
753
754   // Contamination from secondary tracks
755   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
756   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
757     fhSecContaminationMin->SetBinContent(j,-0.05);
758   }
759
760   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
761   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
762     fhSecContaminationMax->SetBinContent(j,0.05);
763   }
764
765   // MC CLOSURETEST (D meson efficiency)
766   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
767   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
768     x=fhMCclosureTestMin->GetBinLowEdge(j);
769     fhMCclosureTestMin->SetBinContent(j,-0.08);
770     
771     if(-0.4<x&&x<-0.2){    
772       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
773     }
774     else if(-0.2<x&&x<-0.1){    
775       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
776     }
777     else if(-0.1<x&&x<0.1){    
778       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
779     }
780     else if(0.1<x&&x<0.2){    
781       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
782     }
783     if(0.2<x&&x<0.4){    
784       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
785     }
786   }
787
788   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
789   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
790     x=fhMCclosureTestMax->GetBinLowEdge(j);
791     fhMCclosureTestMax->SetBinContent(j,0.);
792     
793     //     if(-0.4<x&&x<-0.2){    
794     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
795     //     }
796     //     else if(-0.2<x&&x<-0.1){    
797     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
798     //     }
799     //     else if(-0.2<x&&x<-0.1){    
800     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
801     //     }
802     //     else if(-0.1<x&&x<0.1){    
803     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
804     //     }
805     //     else if(0.1<x&&x<0.2){    
806     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
807     //     }
808     //     if(0.2<x&&x<0.4){    
809     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
810     //     }
811     
812   }
813   
814   // Feed-down 
815
816   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
817   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
818     x=fhBeautyFDmin->GetBinLowEdge(j);
819     fhBeautyFDmin->SetBinContent(j,-0.05);
820     
821   //   if(-0.4<x&&x<-0.2){    
822 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
823 //     }
824 //     else if(-0.2<x&&x<-0.1){    
825 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
826 //     }
827 //     else if(-0.2<x&&x<-0.1){    
828 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
829 //     }
830 //     else if(-0.1<x&&x<0.1){    
831 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
832 //     }
833 //     else if(0.1<x&&x<0.2){    
834 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
835 //     }
836 //     if(0.2<x&&x<0.4){    
837 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
838 //     }
839   }
840
841   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
842   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
843     x=fhBeautyFDmax->GetBinLowEdge(j);
844     fhBeautyFDmax->SetBinContent(j,0.03);
845    
846 //     if(-0.4<x&&x<-0.2){    
847 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
848 //     }
849 //     else if(-0.2<x&&x<-0.1){    
850 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
851 //     }
852 //     else if(-0.2<x&&x<-0.1){    
853 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
854 //     }
855 //     else if(-0.1<x&&x<0.1){    
856 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
857 //     }
858 //     else if(0.1<x&&x<0.2){    
859 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
860 //     }
861 //     if(0.2<x&&x<0.4){    
862 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
863 //     } 
864     
865   }
866
867
868 }
869
870 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DstarMidPtAss03HP(){
871
872   fmeson=1;
873   fstrmeson="Dstar";
874   fstrptAss="ptAsMore03";
875   fstrptD="Dpt5to8";
876   if(!fhDeltaPhiTemplate){
877     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
878   }
879   Double_t x;
880   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
881   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
882   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
883     fhYieldExtraction->SetBinContent(j,0.1);
884   }
885
886   // Background D MESON candidate subtraction (side-band variations, etc.)
887   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
888   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
889     fhBackSubtractionMin->SetBinContent(j,0.05);
890   }
891
892   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
893   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
894     fhBackSubtractionMax->SetBinContent(j,0.05);
895   }
896   
897   // MC CORRECTIONS/ -5%  10% for assoc track eff
898   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
899   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
900     fhMCcorrectionsMin->SetBinContent(j,-0.05);
901   }
902
903   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
904   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
905     fhMCcorrectionsMax->SetBinContent(j,0.10);
906   }
907
908   // MC D EFF CORRECTION
909   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
910   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
911     fhMCDefficiencyMin->SetBinContent(j,-0.05);
912   }
913
914   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
915   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
916     fhMCDefficiencyMax->SetBinContent(j,0.05);
917   }
918
919
920   // Contamination from secondary tracks
921   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
922   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
923     fhSecContaminationMin->SetBinContent(j,-0.05);
924   }
925
926   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
927   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
928     fhSecContaminationMax->SetBinContent(j,0.05);
929   }
930
931   // MC CLOSURETEST (D meson efficiency)
932   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
933   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
934     x=fhMCclosureTestMin->GetBinLowEdge(j);
935     fhMCclosureTestMin->SetBinContent(j,-0.08);
936     
937     if(-0.4<x&&x<-0.2){    
938       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
939     }
940     else if(-0.2<x&&x<-0.1){    
941       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
942     }
943     else if(-0.1<x&&x<0.1){    
944       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
945     }
946     else if(0.1<x&&x<0.2){    
947       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
948     }
949     if(0.2<x&&x<0.4){    
950       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
951     }
952   }
953
954   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
955   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
956     x=fhMCclosureTestMax->GetBinLowEdge(j);
957     fhMCclosureTestMax->SetBinContent(j,0.);
958     
959     //     if(-0.4<x&&x<-0.2){    
960     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
961     //     }
962     //     else if(-0.2<x&&x<-0.1){    
963     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
964     //     }
965     //     else if(-0.2<x&&x<-0.1){    
966     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
967     //     }
968     //     else if(-0.1<x&&x<0.1){    
969     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
970     //     }
971     //     else if(0.1<x&&x<0.2){    
972     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
973     //     }
974     //     if(0.2<x&&x<0.4){    
975     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
976     //     }
977     
978   }
979   
980   // Feed-down 
981
982   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
983   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
984     x=fhBeautyFDmin->GetBinLowEdge(j);
985     fhBeautyFDmin->SetBinContent(j,-0.05);
986     
987   //   if(-0.4<x&&x<-0.2){    
988 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
989 //     }
990 //     else if(-0.2<x&&x<-0.1){    
991 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
992 //     }
993 //     else if(-0.2<x&&x<-0.1){    
994 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
995 //     }
996 //     else if(-0.1<x&&x<0.1){    
997 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
998 //     }
999 //     else if(0.1<x&&x<0.2){    
1000 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
1001 //     }
1002 //     if(0.2<x&&x<0.4){    
1003 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
1004 //     }
1005   }
1006
1007   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
1008   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
1009     x=fhBeautyFDmax->GetBinLowEdge(j);
1010     fhBeautyFDmax->SetBinContent(j,0.03);
1011    
1012 //     if(-0.4<x&&x<-0.2){    
1013 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
1014 //     }
1015 //     else if(-0.2<x&&x<-0.1){    
1016 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
1017 //     }
1018 //     else if(-0.2<x&&x<-0.1){    
1019 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
1020 //     }
1021 //     else if(-0.1<x&&x<0.1){    
1022 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
1023 //     }
1024 //     else if(0.1<x&&x<0.2){    
1025 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
1026 //     }
1027 //     if(0.2<x&&x<0.4){    
1028 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
1029 //     } 
1030     
1031   }
1032
1033 }
1034
1035
1036
1037 void AliHFDhadronCorrSystUnc::InitEmptyHistosFromTemplate(){
1038   if(!fhDeltaPhiTemplate){
1039     Printf("Template histo not set, using standard binning");
1040     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
1041   }
1042    fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
1043    fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
1044    fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
1045    fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
1046    fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
1047    fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
1048    fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
1049    fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
1050    fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
1051    fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
1052    fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
1053    fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
1054    fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
1055 }
1056
1057
1058
1059
1060 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DstarHighPtAss03HP(){
1061   
1062   fmeson=1;
1063   fstrmeson="Dstar";
1064   fstrptAss="ptAsMore03";
1065   fstrptD="Dpt8to16";
1066   if(!fhDeltaPhiTemplate){
1067     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
1068   }
1069   Double_t x;
1070   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
1071   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
1072   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
1073     fhYieldExtraction->SetBinContent(j,0.1);
1074   }
1075
1076   // Background D MESON candidate subtraction (side-band variations, etc.)
1077   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
1078   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
1079     fhBackSubtractionMin->SetBinContent(j,0.05);
1080   }
1081
1082   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
1083   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
1084     fhBackSubtractionMax->SetBinContent(j,0.05);
1085   }
1086   
1087   // MC CORRECTIONS   -5% +10% for assoc track eff
1088   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
1089   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
1090     fhMCcorrectionsMin->SetBinContent(j,-0.05);
1091   }
1092
1093   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
1094   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
1095     fhMCcorrectionsMax->SetBinContent(j,0.10);
1096   }
1097   // MC D EFF CORRECTION
1098   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
1099   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
1100     fhMCDefficiencyMin->SetBinContent(j,-0.05);
1101   }
1102
1103   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
1104   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
1105     fhMCDefficiencyMax->SetBinContent(j,0.05);
1106   }
1107
1108
1109   // Contamination from secondary tracks
1110   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
1111   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
1112     fhSecContaminationMin->SetBinContent(j,-0.05);
1113   }
1114
1115   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
1116   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
1117     fhSecContaminationMax->SetBinContent(j,0.05);
1118   }
1119
1120   // MC CLOSURETEST (D meson efficiency)
1121   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
1122   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
1123     x=fhMCclosureTestMin->GetBinLowEdge(j);
1124     fhMCclosureTestMin->SetBinContent(j,-0.08);
1125     
1126     if(-0.4<x&&x<-0.2){    
1127       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
1128     }
1129     else if(-0.2<x&&x<-0.1){    
1130       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
1131     }
1132     else if(-0.1<x&&x<0.1){    
1133       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
1134     }
1135     else if(0.1<x&&x<0.2){    
1136       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
1137     }
1138     if(0.2<x&&x<0.4){    
1139       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
1140     }
1141   }
1142
1143   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
1144   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
1145     x=fhMCclosureTestMax->GetBinLowEdge(j);
1146     fhMCclosureTestMax->SetBinContent(j,0.);
1147     
1148     //     if(-0.4<x&&x<-0.2){    
1149     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
1150     //     }
1151     //     else if(-0.2<x&&x<-0.1){    
1152     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
1153     //     }
1154     //     else if(-0.2<x&&x<-0.1){    
1155     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
1156     //     }
1157     //     else if(-0.1<x&&x<0.1){    
1158     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
1159     //     }
1160     //     else if(0.1<x&&x<0.2){    
1161     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
1162     //     }
1163     //     if(0.2<x&&x<0.4){    
1164     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
1165     //     }
1166     
1167   }
1168   
1169   // Feed-down 
1170
1171   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
1172   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
1173     x=fhBeautyFDmin->GetBinLowEdge(j);
1174     fhBeautyFDmin->SetBinContent(j,-0.05);
1175     
1176   //   if(-0.4<x&&x<-0.2){    
1177 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
1178 //     }
1179 //     else if(-0.2<x&&x<-0.1){    
1180 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
1181 //     }
1182 //     else if(-0.2<x&&x<-0.1){    
1183 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
1184 //     }
1185 //     else if(-0.1<x&&x<0.1){    
1186 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
1187 //     }
1188 //     else if(0.1<x&&x<0.2){    
1189 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
1190 //     }
1191 //     if(0.2<x&&x<0.4){    
1192 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
1193 //     }
1194   }
1195
1196   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
1197   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
1198     x=fhBeautyFDmax->GetBinLowEdge(j);
1199     fhBeautyFDmax->SetBinContent(j,0.03);
1200    
1201 //     if(-0.4<x&&x<-0.2){    
1202 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
1203 //     }
1204 //     else if(-0.2<x&&x<-0.1){    
1205 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
1206 //     }
1207 //     else if(-0.2<x&&x<-0.1){    
1208 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
1209 //     }
1210 //     else if(-0.1<x&&x<0.1){    
1211 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
1212 //     }
1213 //     else if(0.1<x&&x<0.2){    
1214 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
1215 //     }
1216 //     if(0.2<x&&x<0.4){    
1217 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
1218 //     } 
1219     
1220   }
1221
1222
1223 }
1224
1225
1226 void AliHFDhadronCorrSystUnc::SetHistoTemplate(TH1D *h,TString strname,Bool_t clone){
1227   if(fhDeltaPhiTemplate)delete fhDeltaPhiTemplate;
1228   if(!clone){
1229     fhDeltaPhiTemplate=h;
1230   }
1231   else{
1232     if(strname.IsNull()){fhDeltaPhiTemplate=(TH1D*)h->Clone("fhDeltaPhiTemplate");
1233     }
1234     else fhDeltaPhiTemplate=(TH1D*)h->Clone(strname.Data());
1235   }
1236 }
1237
1238
1239 void AliHFDhadronCorrSystUnc::SetHistoYieldExtraction(TH1D *h,TString strname,Bool_t clone){
1240   if(fhYieldExtraction)delete fhYieldExtraction;
1241   if(!clone){
1242     fhYieldExtraction=h;
1243   }
1244   else{
1245     if(strname.IsNull()){fhYieldExtraction=(TH1D*)h->Clone("fhYieldExtraction");
1246     }
1247     else fhYieldExtraction=(TH1D*)h->Clone(strname.Data());
1248   }
1249 }
1250
1251 void AliHFDhadronCorrSystUnc::SetHistoBackSubtraction(TH1D *hMax,TString strname,Bool_t clone,TH1D *hMin){
1252   if(!hMax){
1253     Printf("No Input Histo for back uncertainty");
1254     return;
1255   }
1256   if(fhBackSubtractionMax)delete fhBackSubtractionMax;
1257   if(!clone){
1258     fhBackSubtractionMax=hMax;
1259   }
1260   else{
1261     if(strname.IsNull()){fhBackSubtractionMax=(TH1D*)hMax->Clone("fhBackSubtractionMax");
1262     }
1263     else fhBackSubtractionMax=(TH1D*)hMax->Clone(strname.Data());
1264   }
1265   
1266   if(fhBackSubtractionMin)delete fhBackSubtractionMin;
1267   if(hMin){
1268     if(!clone){
1269       fhBackSubtractionMin=hMin;
1270     }
1271     else{
1272       if(strname.IsNull()){fhBackSubtractionMin=(TH1D*)hMin->Clone("fhBackSubtractionMin");
1273       }
1274       else fhBackSubtractionMin=(TH1D*)hMin->Clone(strname.Data());
1275     }
1276   }
1277   else{
1278     if(strname.IsNull()){
1279       fhBackSubtractionMin=(TH1D*)hMin->Clone("fhBackSubtractionMin");
1280     }
1281     else fhBackSubtractionMin=(TH1D*)hMin->Clone(strname.Data());
1282     for(Int_t k=0;k<=fhBackSubtractionMin->GetNbinsX();k++){
1283       fhBackSubtractionMin->SetBinContent(k,-1.*fhBackSubtractionMin->GetBinContent(k));
1284     }
1285   }
1286
1287   
1288
1289
1290 }
1291
1292
1293 void AliHFDhadronCorrSystUnc::SetHistoMCclosureTestMax(TH1D *h,TString strname,Bool_t clone){
1294   if(fhMCclosureTestMax)delete fhMCclosureTestMax;
1295   if(!clone){
1296     fhMCclosureTestMax=h;
1297   }
1298   else{
1299     if(strname.IsNull()){fhMCclosureTestMax=(TH1D*)h->Clone("fhMCclosureTestMax");
1300     }
1301     else fhMCclosureTestMax=(TH1D*)h->Clone(strname.Data());
1302   }
1303 }
1304
1305 void AliHFDhadronCorrSystUnc::SetHistoMCclosureTestMin(TH1D *h,TString strname,Bool_t clone){
1306     if(fhMCclosureTestMin)delete fhMCclosureTestMin;
1307     if(!clone){
1308       fhMCclosureTestMin=h;
1309     }
1310     else{
1311       if(strname.IsNull()){fhMCclosureTestMin=(TH1D*)h->Clone("fhMCclosureTestMin");
1312       }
1313       else fhMCclosureTestMin=(TH1D*)h->Clone(strname.Data());
1314     }
1315 }
1316
1317
1318 void AliHFDhadronCorrSystUnc::SetHistoMCcorrectionsMin(TH1D *h,TString strname,Bool_t clone){
1319     if(fhMCcorrectionsMin)delete fhMCcorrectionsMin;
1320     if(!clone){
1321       fhMCcorrectionsMin=h;
1322     }
1323     else{
1324       if(strname.IsNull()){fhMCcorrectionsMin=(TH1D*)h->Clone("fhMCcorrectionsMin");
1325       }
1326       else fhMCcorrectionsMin=(TH1D*)h->Clone(strname.Data());
1327     }
1328 }
1329
1330
1331 void AliHFDhadronCorrSystUnc::SetHistoMCcorrectionsMax(TH1D *h,TString strname,Bool_t clone){
1332     if(fhMCcorrectionsMax)delete fhMCcorrectionsMax;
1333     if(!clone){
1334       fhMCcorrectionsMax=h;
1335     }
1336     else{
1337       if(strname.IsNull()){fhMCcorrectionsMax=(TH1D*)h->Clone("fhMCcorrectionsMax");
1338       }
1339       else fhMCcorrectionsMax=(TH1D*)h->Clone(strname.Data());
1340     }
1341 }
1342
1343
1344 void AliHFDhadronCorrSystUnc::SetHistoMCDefficiencyMin(TH1D *h,TString strname,Bool_t clone){
1345     if(fhMCDefficiencyMin)delete fhMCDefficiencyMin;
1346     if(!clone){
1347       fhMCDefficiencyMin=h;
1348     }
1349     else{
1350       if(strname.IsNull()){fhMCDefficiencyMin=(TH1D*)h->Clone("fhMCDefficiencyMin");
1351       }
1352       else fhMCDefficiencyMin=(TH1D*)h->Clone(strname.Data());
1353     }
1354 }
1355
1356
1357 void AliHFDhadronCorrSystUnc::SetHistoMCDefficiencyMax(TH1D *h,TString strname,Bool_t clone){
1358     if(fhMCDefficiencyMax)delete fhMCDefficiencyMax;
1359     if(!clone){
1360       fhMCDefficiencyMax=h;
1361     }
1362     else{
1363       if(strname.IsNull()){fhMCDefficiencyMax=(TH1D*)h->Clone("fhMCDefficiencyMax");
1364       }
1365       else fhMCDefficiencyMax=(TH1D*)h->Clone(strname.Data());
1366     }
1367 }
1368
1369
1370 void AliHFDhadronCorrSystUnc::SetHistoSecContaminationMin(TH1D *h,TString strname,Bool_t clone){
1371     if(fhSecContaminationMin)delete fhSecContaminationMin;
1372     if(!clone){
1373       fhSecContaminationMin=h;
1374     }
1375     else{
1376       if(strname.IsNull()){fhSecContaminationMin=(TH1D*)h->Clone("fhSecContaminationMin");
1377       }
1378       else fhSecContaminationMin=(TH1D*)h->Clone(strname.Data());
1379     }
1380 }
1381
1382
1383 void AliHFDhadronCorrSystUnc::SetHistoSecContaminationMax(TH1D *h,TString strname,Bool_t clone){
1384     if(fhSecContaminationMax)delete fhSecContaminationMax;
1385     if(!clone){
1386       fhSecContaminationMax=h;
1387     }
1388     else{
1389       if(strname.IsNull()){fhSecContaminationMax=(TH1D*)h->Clone("fhSecContaminationMax");
1390       }
1391       else fhSecContaminationMax=(TH1D*)h->Clone(strname.Data());
1392     }
1393 }
1394
1395
1396 void AliHFDhadronCorrSystUnc::SetHistoBeautyFDmin(TH1D *h,TString strname,Bool_t clone){
1397     if(fhBeautyFDmin)delete fhBeautyFDmin;
1398     if(!clone){
1399       fhBeautyFDmin=h;
1400     }
1401     else{
1402       if(strname.IsNull()){fhBeautyFDmin=(TH1D*)h->Clone("fhBeautyFDmin");
1403       }
1404       else fhBeautyFDmin=(TH1D*)h->Clone(strname.Data());
1405     }
1406 }
1407
1408
1409 void AliHFDhadronCorrSystUnc::SetHistoBeautyFDmax(TH1D *h,TString strname,Bool_t clone){
1410     if(fhBeautyFDmax)delete fhBeautyFDmax;
1411     if(!clone){
1412       fhBeautyFDmax=h;
1413     }
1414     else{
1415       if(strname.IsNull()){fhBeautyFDmax=(TH1D*)h->Clone("fhBeautyFDmax");
1416       }
1417       else fhBeautyFDmax=(TH1D*)h->Clone(strname.Data());
1418     }
1419 }
1420
1421
1422
1423
1424
1425 void AliHFDhadronCorrSystUnc::BuildTotalUncHisto(){
1426   if(fhTotalMin)delete fhTotalMin;
1427   if(fhTotalMax)delete fhTotalMax;
1428
1429   fhTotalMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhTotalMin");
1430   fhTotalMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhTotalMax");
1431   Double_t errMin,errMax;
1432
1433   for(Int_t j=1;j<=fhTotalMin->GetNbinsX();j++){
1434     errMin=fhMCclosureTestMin->GetBinContent(j)*fhMCclosureTestMin->GetBinContent(j);    
1435     errMin+=fhMCcorrectionsMin->GetBinContent(j)*fhMCcorrectionsMin->GetBinContent(j);
1436     errMin+=fhMCDefficiencyMin->GetBinContent(j)*fhMCDefficiencyMin->GetBinContent(j);
1437     errMin+=fhSecContaminationMin->GetBinContent(j)*fhSecContaminationMin->GetBinContent(j);
1438     errMin+=fhYieldExtraction->GetBinContent(j)*fhYieldExtraction->GetBinContent(j);
1439     errMin+=fhBackSubtractionMin->GetBinContent(j)*fhBackSubtractionMin->GetBinContent(j);
1440     errMin+=fhBeautyFDmin->GetBinContent(j)*fhBeautyFDmin->GetBinContent(j);
1441     
1442     fhTotalMin->SetBinContent(j,-TMath::Sqrt(errMin));
1443
1444     errMax=fhMCclosureTestMax->GetBinContent(j)*fhMCclosureTestMax->GetBinContent(j);    
1445     errMax+=fhMCcorrectionsMax->GetBinContent(j)*fhMCcorrectionsMax->GetBinContent(j);
1446     errMax+=fhMCDefficiencyMax->GetBinContent(j)*fhMCDefficiencyMax->GetBinContent(j);
1447     errMax+=fhSecContaminationMax->GetBinContent(j)*fhSecContaminationMax->GetBinContent(j);
1448     errMax+=fhYieldExtraction->GetBinContent(j)*fhYieldExtraction->GetBinContent(j);
1449     errMax+=fhBackSubtractionMax->GetBinContent(j)*fhBackSubtractionMax->GetBinContent(j);
1450     errMax+=fhBeautyFDmax->GetBinContent(j)*fhBeautyFDmax->GetBinContent(j);
1451     
1452     fhTotalMax->SetBinContent(j,TMath::Sqrt(errMax));
1453     
1454     
1455   }
1456
1457   fhTotalMin->SetLineColor(kBlack);
1458   fhTotalMin->SetLineWidth(2);
1459   fhTotalMin->SetFillStyle(0);
1460   fhTotalMin->SetFillColor(kBlack);
1461   fhTotalMin->SetMarkerColor(kBlack);
1462   fhTotalMin->SetMarkerStyle(20);
1463
1464   fhTotalMax->SetLineColor(kBlack);
1465   fhTotalMax->SetLineWidth(2);
1466   fhTotalMax->SetFillStyle(0);
1467   fhTotalMax->SetFillColor(kBlack);
1468   fhTotalMax->SetMarkerColor(kBlack);
1469   fhTotalMax->SetMarkerStyle(20);
1470   
1471 }
1472
1473 void AliHFDhadronCorrSystUnc::BuildTotalNonFlatUncHisto(){
1474   if(fhTotalNonFlatDPhiMin)delete fhTotalNonFlatDPhiMin;
1475   if(fhTotalNonFlatDPhiMax)delete fhTotalNonFlatDPhiMax;
1476
1477   fhTotalNonFlatDPhiMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhTotalNonFlatDPhiMin");
1478   fhTotalNonFlatDPhiMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhTotalNonFlatDPhiMax");
1479   Double_t errMin,errMax,mcClosureMinmax,mcClosureMaxmin;
1480
1481   mcClosureMinmax=fhMCclosureTestMin->GetBinContent(fhMCclosureTestMin->GetMaximumBin());
1482   Printf("The maximum is :%f", mcClosureMinmax);
1483   mcClosureMaxmin=fhMCclosureTestMax->GetBinContent(fhMCclosureTestMax->GetMinimumBin());
1484
1485   for(Int_t j=1;j<=fhTotalNonFlatDPhiMin->GetNbinsX();j++){
1486     errMin=(fhMCclosureTestMin->GetBinContent(j)*fhMCclosureTestMin->GetBinContent(j)-mcClosureMinmax*mcClosureMinmax);// Forced to this quadrature subtraction, doing: (fhMCclosureTestMin->GetBinContent(j)-mcClosureMinmax)*(fhMCclosureTestMin->GetBinContent(j)-mcClosureMinmax) gives the wrong result.. of course  
1487
1488     errMin+=fhBeautyFDmin->GetBinContent(j)*fhBeautyFDmin->GetBinContent(j);
1489     
1490     fhTotalNonFlatDPhiMin->SetBinContent(j,-TMath::Sqrt(errMin));
1491
1492     errMax=fhMCclosureTestMax->GetBinContent(j)*fhMCclosureTestMax->GetBinContent(j)-mcClosureMaxmin*mcClosureMaxmin; // Forced to this quadrature subtraction, doing:(fhMCclosureTestMax->GetBinContent(j)-mcClosureMaxmin)*(fhMCclosureTestMax->GetBinContent(j)-mcClosureMaxmin) gives the wrong result.. of course  
1493    
1494     errMax+=fhBeautyFDmax->GetBinContent(j)*fhBeautyFDmax->GetBinContent(j);
1495     
1496     fhTotalNonFlatDPhiMax->SetBinContent(j,TMath::Sqrt(errMax));
1497     
1498     
1499   }
1500
1501   fhtotFlatMin=(TH1D*)fhTotalMin->Clone("hTotFlatDPhiMin");
1502   fhtotFlatMin->SetTitle("#Delta#phi indipendent");
1503
1504   fhtotFlatMax=(TH1D*)fhTotalMax->Clone("hTotFlatDPhiMax");
1505   fhtotFlatMax->SetTitle("#Delta#phi indipendent");
1506
1507   for(Int_t jfl=1;jfl<=fhtotFlatMin->GetNbinsX();jfl++){
1508     fhtotFlatMin->SetBinContent(jfl,-TMath::Sqrt(fhTotalMin->GetBinContent(jfl)*fhTotalMin->GetBinContent(jfl)-fhTotalNonFlatDPhiMin->GetBinContent(jfl)*fhTotalNonFlatDPhiMin->GetBinContent(jfl)));
1509     fhtotFlatMax->SetBinContent(jfl,TMath::Sqrt(fhTotalMax->GetBinContent(jfl)*fhTotalMax->GetBinContent(jfl)-fhTotalNonFlatDPhiMax->GetBinContent(jfl)*fhTotalNonFlatDPhiMax->GetBinContent(jfl)));
1510   }
1511
1512   fhtotFlatMin->SetLineStyle(2);
1513   fhtotFlatMax->SetLineStyle(2);
1514
1515
1516
1517
1518   fhTotalNonFlatDPhiMin->SetLineColor(kBlue);
1519   fhTotalNonFlatDPhiMin->SetLineWidth(2);
1520   fhTotalNonFlatDPhiMin->SetFillStyle(0);
1521   fhTotalNonFlatDPhiMin->SetFillColor(kBlue);
1522   fhTotalNonFlatDPhiMin->SetMarkerColor(kBlue);
1523   fhTotalNonFlatDPhiMin->SetMarkerStyle(20);
1524
1525   fhTotalNonFlatDPhiMax->SetLineColor(kBlue);
1526   fhTotalNonFlatDPhiMax->SetLineWidth(2);
1527   fhTotalNonFlatDPhiMax->SetFillStyle(0);
1528   fhTotalNonFlatDPhiMax->SetFillColor(kBlue);
1529   fhTotalNonFlatDPhiMax->SetMarkerColor(kBlue);
1530   fhTotalNonFlatDPhiMax->SetMarkerStyle(20);
1531   
1532 }
1533
1534
1535 void AliHFDhadronCorrSystUnc::BuildTotalNonFDUncHisto(){
1536   if(fhTotalNonFDMin)delete fhTotalNonFDMin;
1537   if(fhTotalNonFDMax)delete fhTotalNonFDMax;
1538
1539   fhTotalNonFDMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhTotalNonFDMin");
1540   fhTotalNonFDMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhTotalNonFDMax");
1541   Double_t errMin,errMax;
1542
1543   for(Int_t j=1;j<=fhTotalNonFDMin->GetNbinsX();j++){
1544     errMin=fhMCclosureTestMin->GetBinContent(j)*fhMCclosureTestMin->GetBinContent(j);    
1545     errMin+=fhMCcorrectionsMin->GetBinContent(j)*fhMCcorrectionsMin->GetBinContent(j);
1546     errMin+=fhMCDefficiencyMin->GetBinContent(j)*fhMCDefficiencyMin->GetBinContent(j);
1547     errMin+=fhSecContaminationMin->GetBinContent(j)*fhSecContaminationMin->GetBinContent(j);
1548     errMin+=fhYieldExtraction->GetBinContent(j)*fhYieldExtraction->GetBinContent(j);
1549     errMin+=fhBackSubtractionMin->GetBinContent(j)*fhBackSubtractionMin->GetBinContent(j);
1550
1551     fhTotalNonFDMin->SetBinContent(j,-TMath::Sqrt(errMin));
1552
1553     errMax=fhMCclosureTestMax->GetBinContent(j)*fhMCclosureTestMax->GetBinContent(j);    
1554     errMax+=fhMCcorrectionsMax->GetBinContent(j)*fhMCcorrectionsMax->GetBinContent(j);
1555     errMax+=fhMCDefficiencyMax->GetBinContent(j)*fhMCDefficiencyMax->GetBinContent(j);
1556     errMax+=fhSecContaminationMax->GetBinContent(j)*fhSecContaminationMax->GetBinContent(j);
1557     errMax+=fhYieldExtraction->GetBinContent(j)*fhYieldExtraction->GetBinContent(j);
1558     errMax+=fhBackSubtractionMax->GetBinContent(j)*fhBackSubtractionMax->GetBinContent(j);
1559     
1560     fhTotalNonFDMax->SetBinContent(j,TMath::Sqrt(errMax));
1561     
1562     
1563   }
1564
1565 }
1566
1567 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010(Int_t meson,Double_t ptD,Double_t minptAss){
1568   if(meson==0){
1569     if(TMath::Abs(minptAss-0.3)<0.0001){
1570       if(ptD>2&&ptD<5){
1571         InitStandardUncertaintiesPP2010DzeroLowPtAss03HP();    
1572       }
1573       else if(ptD>5&&ptD<8){
1574         InitStandardUncertaintiesPP2010DzeroMidPtAss03HP();    
1575       }
1576       else InitStandardUncertaintiesPP2010DzeroHighPtAss03HP();    
1577     }
1578     else {
1579       printf("Methods for syst unc not ready yet for this pt(ass) bin \n");
1580     }
1581   }
1582   else if(meson==1){
1583     if(TMath::Abs(minptAss-0.3)<0.0001){
1584       if(ptD>2&&ptD<5){
1585         InitStandardUncertaintiesPP2010DstarLowPtAss03HP();    
1586       }
1587       else if(ptD>5&&ptD<8){
1588         InitStandardUncertaintiesPP2010DstarMidPtAss03HP();    
1589       }
1590       else InitStandardUncertaintiesPP2010DstarHighPtAss03HP();    
1591     }
1592     else {
1593       printf("Methods for syst unc not ready yet for this pt(ass) bin \n");
1594     }
1595   }
1596   else if(meson==2){
1597     if(TMath::Abs(minptAss-0.3)<0.0001){
1598       if(ptD>2&&ptD<5){
1599         InitStandardUncertaintiesPP2010DplusLowPtAss03();    
1600       }
1601       else if(ptD>5&&ptD<8){
1602         InitStandardUncertaintiesPP2010DplusMidPtAss03();    
1603       }
1604       else InitStandardUncertaintiesPP2010DplusHighPtAss03();    
1605     }
1606     else {
1607       printf("Methods for syst unc not ready yet for this pt(ass) bin \n");
1608     }
1609   }
1610 }
1611
1612
1613 TGraphAsymmErrors* AliHFDhadronCorrSystUnc::GetUncGraphFromHistos(TH1D *hRef,TH1D *hMin,TH1D *hMax){
1614   
1615   //  Int_t npoints=hMin->GetNbinsX();
1616   Double_t ew=hMin->GetBinWidth(1)/2.;
1617   Double_t value,eyl,eym;
1618   
1619   TGraphAsymmErrors *gr=new TGraphAsymmErrors();
1620   for(Int_t j=1;j<=hMin->GetNbinsX();j++){
1621     if(hRef){
1622       value=hRef->GetBinContent(j);
1623       eyl=hMin->GetBinContent(j)*value;
1624       if(eyl<0.)eyl*=-1.;
1625       if(hMax)eym=hMax->GetBinContent(j)*value;
1626       else eym=eyl;
1627     }
1628     else {
1629       value=0.;
1630       eyl=hMin->GetBinContent(j);
1631       if(eyl<0.)eyl*=-1.;
1632       if(hMax)eym=hMax->GetBinContent(j);
1633       else eym=eyl;
1634     }
1635     
1636     gr->SetPoint(j-1,hMin->GetBinCenter(j),value);
1637     gr->SetPointError(j-1,ew,ew,eyl,eym);
1638   }
1639   
1640   return gr;
1641 }
1642
1643 void AliHFDhadronCorrSystUnc::BuildGraphsRelUnc(){
1644   if(fgrYieldUncRel)delete fgrYieldUncRel;
1645   if(fgrBackSubUncRel)delete fgrBackSubUncRel;
1646   if(fgrMCcorrectionsRel)delete fgrMCcorrectionsRel;
1647   if(fgrMCDefficiencyRel)delete fgrMCDefficiencyRel;
1648   if(fgrSecContaminationRel)delete fgrSecContaminationRel;
1649   if(fgrMCclosureTestRel)delete fgrMCclosureTestRel;  
1650   if(fgrBeautyFDRel)delete fgrBeautyFDRel;   
1651   
1652   fgrYieldUncRel=GetUncGraphFromHistos(0x0,fhYieldExtraction,0x0);
1653   fgrYieldUncRel->SetName("fgrYieldUncRel");
1654   fgrYieldUncRel->SetTitle("D meson yield");
1655
1656
1657   fgrBackSubUncRel=GetUncGraphFromHistos(0x0,fhBackSubtractionMin,fhBackSubtractionMax);
1658   fgrBackSubUncRel->SetName("fgrBackSubUncRel");
1659   fgrBackSubUncRel->SetTitle("Background D correlation subtraction");
1660
1661
1662
1663   fgrMCcorrectionsRel=GetUncGraphFromHistos(0x0,fhMCcorrectionsMin,fhMCcorrectionsMax);
1664   fgrMCcorrectionsRel->SetName("fgrMCcorrectionsRel");
1665   fgrMCcorrectionsRel->SetTitle("Associated track efficiency");
1666
1667   fgrMCDefficiencyRel=GetUncGraphFromHistos(0x0,fhMCDefficiencyMin,fhMCDefficiencyMax);
1668   fgrMCDefficiencyRel->SetName("fgrMCDefficiencyRel");
1669   fgrMCDefficiencyRel->SetTitle("D meson efficiency");
1670
1671   fgrSecContaminationRel=GetUncGraphFromHistos(0x0,fhSecContaminationMin,fhSecContaminationMax);
1672   fgrSecContaminationRel->SetName("fgrSecContaminationRel");
1673   fgrSecContaminationRel->SetTitle("Secondary contamination");
1674
1675   fgrMCclosureTestRel=GetUncGraphFromHistos(0x0,fhMCclosureTestMin,fhMCclosureTestMax);
1676   fgrMCclosureTestRel->SetName("fgrMCclosureTestRel");
1677   fgrMCclosureTestRel->SetTitle("MC closure test");
1678
1679   fgrBeautyFDRel=GetUncGraphFromHistos(0x0,fhBeautyFDmin,fhBeautyFDmax);
1680   fgrBeautyFDRel->SetName("fgrBeautyFDRel");
1681   fgrBeautyFDRel->SetTitle("Feed-down");
1682
1683   fgrYieldUncRel->SetLineColor(kBlue);
1684   fgrYieldUncRel->SetLineWidth(2);
1685   fgrYieldUncRel->SetFillStyle(3002);
1686   fgrYieldUncRel->SetFillColor(kBlue);
1687   fgrYieldUncRel->SetMarkerColor(kBlue);
1688   fgrYieldUncRel->SetMarkerStyle(20);
1689
1690
1691   fgrBackSubUncRel->SetLineColor(kMagenta);
1692   fgrBackSubUncRel->SetLineWidth(2);
1693   fgrBackSubUncRel->SetFillStyle(3008);
1694   fgrBackSubUncRel->SetFillColor(kMagenta);
1695   fgrBackSubUncRel->SetMarkerColor(kBlue);
1696   fgrBackSubUncRel->SetMarkerStyle(20);
1697
1698
1699   fgrMCcorrectionsRel->SetLineColor(kGreen);
1700   fgrMCcorrectionsRel->SetLineWidth(2);
1701   fgrMCcorrectionsRel->SetFillStyle(3006);
1702   fgrMCcorrectionsRel->SetFillColor(kGreen);
1703   fgrMCcorrectionsRel->SetMarkerColor(kGreen);
1704   fgrMCcorrectionsRel->SetMarkerStyle(22);
1705
1706   fgrMCDefficiencyRel->SetLineColor(kCyan);
1707   fgrMCDefficiencyRel->SetLineWidth(2);
1708   fgrMCDefficiencyRel->SetFillStyle(3004);
1709   fgrMCDefficiencyRel->SetFillColor(kCyan);
1710   fgrMCDefficiencyRel->SetMarkerColor(kCyan);
1711   fgrMCDefficiencyRel->SetMarkerStyle(22);
1712
1713   fgrSecContaminationRel->SetLineColor(kOrange);
1714   fgrSecContaminationRel->SetLineWidth(2);
1715   fgrSecContaminationRel->SetFillStyle(3007);
1716   fgrSecContaminationRel->SetFillColor(kOrange);
1717   fgrSecContaminationRel->SetMarkerColor(kOrange);
1718   fgrSecContaminationRel->SetMarkerStyle(22);
1719
1720   fgrMCclosureTestRel->SetLineColor(kRed);
1721   fgrMCclosureTestRel->SetLineWidth(2);
1722   fgrMCclosureTestRel->SetFillStyle(3005);
1723   fgrMCclosureTestRel->SetFillColor(kRed);
1724   fgrMCclosureTestRel->SetMarkerColor(kRed);
1725   fgrMCclosureTestRel->SetMarkerStyle(26);
1726
1727   fgrBeautyFDRel->SetLineColor(kViolet);
1728   fgrBeautyFDRel->SetLineWidth(2);
1729   fgrBeautyFDRel->SetFillStyle(3021);
1730   fgrBeautyFDRel->SetFillColor(kViolet);
1731   fgrBeautyFDRel->SetMarkerColor(kViolet);
1732   fgrBeautyFDRel->SetMarkerStyle(28);
1733
1734
1735   
1736
1737 }
1738
1739 void AliHFDhadronCorrSystUnc::BuildGraphsUnc(TH1D *hRef){
1740
1741   if(fgrYieldUnc)delete fgrYieldUnc;
1742   if(fgrBackSubUnc)delete fgrBackSubUnc;
1743   if(fgrMCcorrections)delete fgrMCcorrections;
1744   if(fgrMCDefficiency)delete fgrMCDefficiency;
1745   if(fgrSecContamination)delete fgrSecContamination;
1746   if(fgrMCclosureTest)delete fgrMCclosureTest;  
1747   if(fgrBeautyFD)delete fgrBeautyFD;   
1748   if(fgrTotalRel)delete fgrTotalRel;
1749   if(fgrTotal)delete fgrTotal;
1750   if(fgrTotalNonFlatDPhi)delete fgrTotalNonFlatDPhi;
1751   if(fgrTotalNonFlatDPhiRel)delete fgrTotalNonFlatDPhiRel;
1752   if(fgrTotalFlatDPhi)delete fgrTotalFlatDPhi;
1753   if(fgrTotalFlatDPhiRel)delete fgrTotalFlatDPhiRel;
1754
1755   fgrYieldUnc=GetUncGraphFromHistos(hRef,fhYieldExtraction,0x0);
1756   fgrYieldUnc->SetName("fgrYieldUnc");
1757   fgrYieldUnc->SetTitle("D meson yield");
1758
1759   fgrBackSubUnc=GetUncGraphFromHistos(hRef,fhBackSubtractionMin,fhBackSubtractionMax);
1760   fgrBackSubUnc->SetName("fgrBackSubUnc");
1761   fgrBackSubUnc->SetTitle("Background D correlation subtraction");
1762
1763
1764   fgrMCcorrections=GetUncGraphFromHistos(hRef,fhMCcorrectionsMin,fhMCcorrectionsMax);
1765   fgrMCcorrections->SetName("fgrMCcorrections");
1766   fgrMCcorrections->SetTitle("Associated track efficiency");
1767
1768   fgrMCDefficiency=GetUncGraphFromHistos(hRef,fhMCDefficiencyMin,fhMCDefficiencyMax);
1769   fgrMCDefficiency->SetName("fgrMCDefficiency");
1770   fgrMCDefficiency->SetTitle("D meson efficiency");
1771
1772   fgrSecContamination=GetUncGraphFromHistos(hRef,fhSecContaminationMin,fhSecContaminationMax);
1773   fgrSecContamination->SetName("fgrSecContamination");
1774   fgrSecContamination->SetTitle("Secondary contamination");
1775
1776   fgrMCclosureTest=GetUncGraphFromHistos(hRef,fhMCclosureTestMin,fhMCclosureTestMax);
1777   fgrMCclosureTest->SetName("fgrMCclosureTest");
1778   fgrMCclosureTest->SetTitle("MC closure test");
1779
1780   fgrBeautyFD=GetUncGraphFromHistos(hRef,fhBeautyFDmin,fhBeautyFDmax);
1781   fgrBeautyFD->SetName("fgrBeautyFD");
1782   fgrBeautyFD->SetTitle("Feed-down");
1783
1784   fgrYieldUnc->SetLineColor(kBlue);
1785   fgrYieldUnc->SetLineWidth(2);
1786   fgrYieldUnc->SetFillStyle(0);
1787   fgrYieldUnc->SetFillColor(kBlue);
1788   fgrYieldUnc->SetMarkerColor(kBlue);
1789   fgrYieldUnc->SetMarkerStyle(20);
1790
1791
1792   fgrBackSubUnc->SetLineColor(kMagenta);
1793   fgrBackSubUnc->SetLineWidth(2);
1794   fgrBackSubUnc->SetFillStyle(0);
1795   fgrBackSubUnc->SetFillColor(kMagenta);
1796   fgrBackSubUnc->SetMarkerColor(kBlue);
1797   fgrBackSubUnc->SetMarkerStyle(20);
1798
1799
1800   fgrMCcorrections->SetLineColor(kGreen);
1801   fgrMCcorrections->SetLineWidth(2);
1802   fgrMCcorrections->SetFillStyle(0);
1803   fgrMCcorrections->SetFillColor(kGreen);
1804   fgrMCcorrections->SetMarkerColor(kGreen);
1805   fgrMCcorrections->SetMarkerStyle(22);
1806
1807   fgrMCDefficiency->SetLineColor(kCyan);
1808   fgrMCDefficiency->SetLineWidth(2);
1809   fgrMCDefficiency->SetFillStyle(0);
1810   fgrMCDefficiency->SetFillColor(kCyan);
1811   fgrMCDefficiency->SetMarkerColor(kCyan);
1812   fgrMCDefficiency->SetMarkerStyle(22);
1813
1814   fgrSecContamination->SetLineColor(kOrange);
1815   fgrSecContamination->SetLineWidth(2);
1816   fgrSecContamination->SetFillStyle(0);
1817   fgrSecContamination->SetFillColor(kOrange);
1818   fgrSecContamination->SetMarkerColor(kOrange);
1819   fgrSecContamination->SetMarkerStyle(22);
1820
1821   fgrMCclosureTest->SetLineColor(kRed);
1822   fgrMCclosureTest->SetLineWidth(2);
1823   fgrMCclosureTest->SetFillStyle(0);
1824   fgrMCclosureTest->SetFillColor(kRed);
1825   fgrMCclosureTest->SetMarkerColor(kRed);
1826   fgrMCclosureTest->SetMarkerStyle(26);
1827
1828   fgrBeautyFD->SetLineColor(kViolet);
1829   fgrBeautyFD->SetLineWidth(2);
1830   fgrBeautyFD->SetFillStyle(0);
1831   fgrBeautyFD->SetFillColor(kViolet);
1832   fgrBeautyFD->SetMarkerColor(kViolet);
1833   fgrBeautyFD->SetMarkerStyle(28);
1834
1835   //  fgrTotalRel=GetUncGraphFromHistos(0x0,fhTotalMin,fhTotalMax);
1836   if(fhTotalMin){
1837     fgrTotalRel=GetUncGraphFromHistos(0x0,fhTotalMin,fhTotalMax);
1838     fgrTotalRel->SetLineColor(kBlack);
1839     fgrTotalRel->SetLineWidth(2);
1840     fgrTotalRel->SetFillStyle(0);
1841     //    fgrTotalRel->SetFillColor(kRed);
1842     fgrTotalRel->SetMarkerColor(kBlack);
1843     fgrTotalRel->SetMarkerStyle(26);
1844
1845     fgrTotal=GetUncGraphFromHistos(hRef,fhTotalMin,fhTotalMax);
1846     fgrTotal->SetLineColor(kBlack);
1847     fgrTotal->SetLineWidth(2);
1848     fgrTotal->SetFillStyle(0);
1849     fgrTotal->SetFillColor(kRed);
1850     fgrTotal->SetMarkerColor(kBlack);
1851     fgrTotal->SetMarkerStyle(26);
1852   }
1853   
1854   if(fhTotalNonFDMin){
1855     fgrTotalNonFD=GetUncGraphFromHistos(hRef,fhTotalNonFDMin,fhTotalNonFDMax);
1856     fgrTotalNonFD->SetLineColor(kBlue);
1857     fgrTotalNonFD->SetLineWidth(2);
1858     fgrTotalNonFD->SetFillStyle(3005);
1859     fgrTotalNonFD->SetFillColor(kBlue);
1860     fgrTotalNonFD->SetMarkerColor(kBlue);
1861     fgrTotalNonFD->SetMarkerStyle(26);  
1862   }
1863
1864   if(fhTotalNonFlatDPhiMin){
1865     fgrTotalNonFlatDPhiRel=GetUncGraphFromHistos(0x0,fhTotalNonFlatDPhiMin,fhTotalNonFlatDPhiMax);
1866     fgrTotalNonFlatDPhiRel->SetLineColor(kBlack);
1867     fgrTotalNonFlatDPhiRel->SetLineWidth(2);
1868     fgrTotalNonFlatDPhiRel->SetFillStyle(0);
1869     //    fgrTotalRel->SetFillColor(kRed);
1870     fgrTotalNonFlatDPhiRel->SetMarkerColor(kBlack);
1871     fgrTotalNonFlatDPhiRel->SetMarkerStyle(26);
1872
1873     fgrTotalNonFlatDPhi=GetUncGraphFromHistos(hRef,fhTotalNonFlatDPhiMin,fhTotalNonFlatDPhiMax);
1874     fgrTotalNonFlatDPhi->SetLineColor(kBlack);
1875     fgrTotalNonFlatDPhi->SetLineWidth(2);
1876     fgrTotalNonFlatDPhi->SetFillStyle(3005);
1877     fgrTotalNonFlatDPhi->SetFillColor(kRed);
1878     fgrTotalNonFlatDPhi->SetMarkerColor(kBlack);
1879     fgrTotalNonFlatDPhi->SetMarkerStyle(26);  
1880
1881     fgrTotalFlatDPhiRel=GetUncGraphFromHistos(0x0,fhtotFlatMin,fhtotFlatMax);
1882     fgrTotalFlatDPhiRel->SetLineColor(kBlack);
1883     fgrTotalFlatDPhiRel->SetLineWidth(2);
1884     fgrTotalFlatDPhiRel->SetFillStyle(0);
1885     //    fgrTotalRel->SetFillColor(kRed);
1886     fgrTotalFlatDPhiRel->SetMarkerColor(kBlack);
1887     fgrTotalFlatDPhiRel->SetMarkerStyle(26);
1888
1889     fgrTotalFlatDPhi=GetUncGraphFromHistos(hRef,fhtotFlatMin,fhtotFlatMax);
1890     fgrTotalFlatDPhi->SetLineColor(kBlack);
1891     fgrTotalFlatDPhi->SetLineWidth(2);
1892     fgrTotalFlatDPhi->SetFillStyle(3005);
1893     fgrTotalFlatDPhi->SetFillColor(kBlack);
1894     fgrTotalFlatDPhi->SetMarkerColor(kBlack);
1895     fgrTotalFlatDPhi->SetMarkerStyle(26);  
1896   }
1897
1898 }
1899
1900
1901 TCanvas* AliHFDhadronCorrSystUnc::BuildSystUncertaintyPlotVsDeltaPhi(TH1D *hCorrPlot,Int_t doInit){
1902
1903   if(doInit!=0){
1904     BuildTotalUncHisto();
1905     BuildTotalNonFDUncHisto();
1906     BuildTotalNonFlatUncHisto();
1907     BuildGraphsUnc(hCorrPlot);
1908     BuildGraphsRelUnc();
1909
1910   }
1911
1912   // Easy canva with relative uncertainties
1913   TCanvas *cCanvaRelUnc=new TCanvas("cCanvaRelUnc","cCanvaRelUnc",700,700);
1914   cCanvaRelUnc->cd();
1915   TH2D *hDraw=new TH2D("hDraw","hDraw",32,-TMath::Pi()/2.,3./2.*TMath::Pi(),200,-2.,2.);
1916   hDraw->SetXTitle("#Delta#phi (rad)");
1917   hDraw->SetYTitle("Relative uncertainty");
1918   hDraw->Draw();
1919   
1920   
1921   fgrYieldUncRel->Draw("E2");
1922   fgrBackSubUncRel->Draw("E2");
1923   fgrMCcorrectionsRel->Draw("E2");
1924   fgrMCDefficiencyRel->Draw("E2");
1925   fgrSecContaminationRel->Draw("E2");
1926   fgrMCclosureTestRel->Draw("E2");
1927   fgrBeautyFDRel->Draw("E2");
1928   //  fgrTotalRel->Draw("E2");
1929
1930   fhtotFlatMin->Draw("same");
1931   fhtotFlatMax->Draw("same");
1932
1933   fhTotalMin->Draw("same");
1934   fhTotalMax->Draw("same");
1935
1936   TCanvas *cCanvaFinalPlot=new TCanvas("cCanvaFinalPlot","cCanvaFinalPlot",700,700);
1937   cCanvaFinalPlot->cd();
1938   hCorrPlot->Draw();
1939   //  fgrYieldUnc->Draw("pE2");
1940   //  fgrBackSubUnc->Draw("pE2");
1941   //  fgrMCcorrections->Draw("pE2");
1942   //  fgrMCclosureTest->Draw("pE2");
1943   //  fgrBeautyFD->Draw("pE2");
1944   fgrTotal->Draw("E2");
1945
1946
1947   TCanvas *cCanvaFinalPlotFD=new TCanvas("cCanvaFinalPlotFD","cCanvaFinalPlotFD",700,700);
1948   cCanvaFinalPlotFD->cd();
1949   hCorrPlot->Draw();
1950   //  fgrYieldUnc->Draw("pE2");
1951   //  fgrBackSubUnc->Draw("pE2");
1952   //  fgrMCcorrections->Draw("pE2");
1953   //  fgrMCclosureTest->Draw("pE2");
1954   //  fgrBeautyFD->Draw("pE2");
1955   fgrBeautyFD->Draw("E2");
1956   fgrTotalNonFD->Draw("E2");
1957   fgrTotalNonFlatDPhi->Draw("E2");
1958   fgrTotalFlatDPhi->Draw("E2");
1959
1960   return cCanvaFinalPlot;
1961 }
1962   
1963   
1964 TH1D* AliHFDhadronCorrSystUnc::GetVariedHisto(const TH1D *hIn,const TGraphAsymmErrors *gr,Int_t minmax){
1965
1966   TH1D *hOut;
1967   if(minmax==0){
1968     hOut=(TH1D*)hIn->Clone(Form("%sVariedMin",hIn->GetName()));
1969   }
1970   else if(minmax==1){
1971     hOut=(TH1D*)hIn->Clone(Form("%sVariedMax",hIn->GetName()));
1972   }
1973   //  Int_t np=gr->GetN();
1974   Double_t *x,*y,*ely,*ehy;//*elx,*ehx,
1975   x=gr->GetX();
1976   y=gr->GetY();
1977   //  elx=gr->GetEXlow();
1978   // ehx=gr->GetEXhigh();
1979    ely=gr->GetEYlow();
1980   ehy=gr->GetEYhigh();
1981
1982   for(Int_t jp=1;jp<=hIn->GetNbinsX();jp++){
1983     if(TMath::Abs(x[jp-1]-hIn->GetBinCenter(jp))>0.0001){
1984       Printf("Bin Mismatch: this method assumes that the graph has the points in the center of the histo bin centers");
1985       return 0x0;
1986     }
1987     if(TMath::Abs(y[jp-1]-hIn->GetBinContent(jp))>0.0001){
1988       Printf("Value Mismatch: this method relies on the fact that the graph central values are the same as those of the histo");
1989       return 0x0;
1990     }
1991     if(minmax==0){
1992       hOut->SetBinContent(jp,y[jp-1]-ely[jp-1]);
1993     }
1994     else if(minmax==1){
1995       hOut->SetBinContent(jp,y[jp-1]+ehy[jp-1]);
1996     }
1997     hOut->SetBinError(jp,hIn->GetBinError(jp));
1998   }
1999
2000   return hOut;
2001 }
2002
2003
2004
2005 ////////////////////////////////////////////////////////////////////////////////////////////////////////
2006 /////
2007 ///// METHODS WITH UNCERTAINTIES: PP 2010, for kinematic cases approved after HP2013
2008 /////
2009 ////////////////////////////////////////////////////////////////////////////////////////////////////////
2010
2011
2012 // START FROM DPLUS FOR PT(ASSOC)>0.3
2013 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DplusLowPtAss03(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
2014   fmeson=0;
2015   fstrmeson="Dplus";
2016   fstrptAss="ptAsMore03";
2017   fstrptD="Dpt3to5";
2018   if(!fhDeltaPhiTemplate){
2019     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
2020   }
2021   Double_t x;
2022   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
2023   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
2024   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
2025     fhYieldExtraction->SetBinContent(j,0.1);
2026   }
2027
2028   // Background D MESON candidate subtraction (side-band variations, etc.)
2029   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
2030   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
2031     fhBackSubtractionMin->SetBinContent(j,-0.05);
2032   }
2033
2034   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
2035   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
2036     fhBackSubtractionMax->SetBinContent(j,0.05);
2037   }
2038
2039   
2040   // MC CORRECTIONS ( associatate track efficiency):
2041   //  -5%  +10% for assoc track eff 
2042   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
2043   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
2044     fhMCcorrectionsMin->SetBinContent(j,-0.05);
2045   }
2046
2047   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
2048   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
2049     fhMCcorrectionsMax->SetBinContent(j,0.10);
2050   }
2051
2052   // MC D EFF CORRECTION
2053   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
2054   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
2055     fhMCDefficiencyMin->SetBinContent(j,-0.05);
2056   }
2057
2058   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
2059   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
2060     fhMCDefficiencyMax->SetBinContent(j,0.05);
2061   }
2062
2063
2064   // Contamination from secondary tracks
2065   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
2066   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
2067     fhSecContaminationMin->SetBinContent(j,-0.05);
2068   }
2069
2070   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
2071   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
2072     fhSecContaminationMax->SetBinContent(j,0.05);
2073   }
2074
2075
2076   // MC CLOSURETEST (D meson efficiency)
2077   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
2078   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
2079     x=fhMCclosureTestMin->GetBinLowEdge(j);
2080     fhMCclosureTestMin->SetBinContent(j,-0.08);
2081     
2082     if(-0.4<x&&x<-0.2){    
2083       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2084     }
2085     else if(-0.2<x&&x<-0.1){    
2086       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2087     }
2088     else if(-0.1<x&&x<0.1){    
2089       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
2090     }
2091     else if(0.1<x&&x<0.2){    
2092       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2093     }
2094     if(0.2<x&&x<0.4){    
2095       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2096     }
2097   }
2098
2099   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
2100   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
2101     //    x=fhMCclosureTestMax->GetBinLowEdge(j);
2102     fhMCclosureTestMax->SetBinContent(j,0.);
2103     
2104     //     if(-0.4<x&&x<-0.2){    
2105     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2106     //     }
2107     //     else if(-0.2<x&&x<-0.1){    
2108     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2109     //     }
2110     //     else if(-0.2<x&&x<-0.1){    
2111     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2112     //     }
2113     //     else if(-0.1<x&&x<0.1){    
2114     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
2115     //     }
2116     //     else if(0.1<x&&x<0.2){    
2117     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2118     //     }
2119     //     if(0.2<x&&x<0.4){    
2120     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2121     //     }
2122     
2123   }
2124   
2125   // Feed-down 
2126
2127   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
2128   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
2129     x=fhBeautyFDmin->GetBinLowEdge(j);
2130     fhBeautyFDmin->SetBinContent(j,-0.05);
2131     
2132   //   if(-0.4<x&&x<-0.2){    
2133 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2134 //     }
2135 //     else if(-0.2<x&&x<-0.1){    
2136 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2137 //     }
2138 //     else if(-0.2<x&&x<-0.1){    
2139 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2140 //     }
2141 //     else if(-0.1<x&&x<0.1){    
2142 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
2143 //     }
2144 //     else if(0.1<x&&x<0.2){    
2145 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2146 //     }
2147 //     if(0.2<x&&x<0.4){    
2148 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2149 //     }
2150   }
2151
2152   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
2153   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
2154     x=fhBeautyFDmax->GetBinLowEdge(j);
2155     fhBeautyFDmax->SetBinContent(j,0.03);
2156    
2157 //     if(-0.4<x&&x<-0.2){    
2158 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2159 //     }
2160 //     else if(-0.2<x&&x<-0.1){    
2161 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2162 //     }
2163 //     else if(-0.2<x&&x<-0.1){    
2164 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2165 //     }
2166 //     else if(-0.1<x&&x<0.1){    
2167 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
2168 //     }
2169 //     else if(0.1<x&&x<0.2){    
2170 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2171 //     }
2172 //     if(0.2<x&&x<0.4){    
2173 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2174 //     } 
2175     
2176   }
2177   
2178 }
2179
2180 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DplusMidPtAss03(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
2181
2182   fmeson=0;
2183   fstrmeson="Dplus";
2184   fstrptAss="ptAsMore03";
2185   fstrptD="Dpt5to8";
2186   if(!fhDeltaPhiTemplate){
2187     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
2188   }
2189   Double_t x;
2190   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
2191   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
2192   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
2193     fhYieldExtraction->SetBinContent(j,0.1);
2194   }
2195
2196   // Background D MESON candidate subtraction (side-band variations, etc.)
2197   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
2198   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
2199     fhBackSubtractionMin->SetBinContent(j,0.05);
2200   }
2201
2202   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
2203   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
2204     fhBackSubtractionMax->SetBinContent(j,0.05);
2205   }
2206   
2207   // MC CORRECTIONS:  -5%  +10% for assoc track eff
2208   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
2209   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
2210     fhMCcorrectionsMin->SetBinContent(j,-0.05);
2211   }
2212
2213   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
2214   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
2215     fhMCcorrectionsMax->SetBinContent(j,0.10);
2216   }
2217
2218
2219   // MC D EFF CORRECTION
2220   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
2221   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
2222     fhMCDefficiencyMin->SetBinContent(j,-0.05);
2223   }
2224
2225   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
2226   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
2227     fhMCDefficiencyMax->SetBinContent(j,0.05);
2228   }
2229
2230
2231   // Contamination from secondary tracks
2232   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
2233   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
2234     fhSecContaminationMin->SetBinContent(j,-0.05);
2235   }
2236
2237   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
2238   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
2239     fhSecContaminationMax->SetBinContent(j,0.05);
2240   }
2241
2242   // MC CLOSURETEST (D meson efficiency)
2243   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
2244   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
2245     x=fhMCclosureTestMin->GetBinLowEdge(j);
2246     fhMCclosureTestMin->SetBinContent(j,-0.08);
2247     
2248     if(-0.4<x&&x<-0.2){    
2249       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2250     }
2251     else if(-0.2<x&&x<-0.1){    
2252       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2253     }
2254     else if(-0.1<x&&x<0.1){    
2255       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
2256     }
2257     else if(0.1<x&&x<0.2){    
2258       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2259     }
2260     if(0.2<x&&x<0.4){    
2261       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2262     }
2263   }
2264
2265   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
2266   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
2267     x=fhMCclosureTestMax->GetBinLowEdge(j);
2268     fhMCclosureTestMax->SetBinContent(j,0.);
2269     
2270     //     if(-0.4<x&&x<-0.2){    
2271     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2272     //     }
2273     //     else if(-0.2<x&&x<-0.1){    
2274     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2275     //     }
2276     //     else if(-0.2<x&&x<-0.1){    
2277     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2278     //     }
2279     //     else if(-0.1<x&&x<0.1){    
2280     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
2281     //     }
2282     //     else if(0.1<x&&x<0.2){    
2283     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2284     //     }
2285     //     if(0.2<x&&x<0.4){    
2286     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2287     //     }
2288     
2289   }
2290   
2291   // Feed-down 
2292
2293   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
2294   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
2295     x=fhBeautyFDmin->GetBinLowEdge(j);
2296     fhBeautyFDmin->SetBinContent(j,-0.05);
2297     
2298   //   if(-0.4<x&&x<-0.2){    
2299 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2300 //     }
2301 //     else if(-0.2<x&&x<-0.1){    
2302 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2303 //     }
2304 //     else if(-0.2<x&&x<-0.1){    
2305 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2306 //     }
2307 //     else if(-0.1<x&&x<0.1){    
2308 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
2309 //     }
2310 //     else if(0.1<x&&x<0.2){    
2311 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2312 //     }
2313 //     if(0.2<x&&x<0.4){    
2314 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2315 //     }
2316   }
2317
2318   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
2319   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
2320     x=fhBeautyFDmax->GetBinLowEdge(j);
2321     fhBeautyFDmax->SetBinContent(j,0.03);
2322    
2323 //     if(-0.4<x&&x<-0.2){    
2324 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2325 //     }
2326 //     else if(-0.2<x&&x<-0.1){    
2327 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2328 //     }
2329 //     else if(-0.2<x&&x<-0.1){    
2330 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2331 //     }
2332 //     else if(-0.1<x&&x<0.1){    
2333 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
2334 //     }
2335 //     else if(0.1<x&&x<0.2){    
2336 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2337 //     }
2338 //     if(0.2<x&&x<0.4){    
2339 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2340 //     } 
2341     
2342   }
2343   
2344 }
2345
2346
2347 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DplusHighPtAss03(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
2348   
2349   fmeson=0;
2350   fstrmeson="Dplus";
2351   fstrptAss="ptAsMore03";
2352   fstrptD="Dpt8to16";
2353   if(!fhDeltaPhiTemplate){
2354     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
2355   }
2356
2357   Double_t x;
2358   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
2359   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
2360   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
2361     fhYieldExtraction->SetBinContent(j,0.1);
2362   }
2363
2364   // Background D MESON candidate subtraction (side-band variations, etc.)
2365   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
2366   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
2367     fhBackSubtractionMin->SetBinContent(j,0.05);
2368   }
2369
2370   // Background D MESON candidate subtraction (side-band variations, etc.)
2371   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
2372   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
2373     fhBackSubtractionMax->SetBinContent(j,0.05);
2374   }
2375   
2376   // MC CORRECTIONS,  -5% 10% for assoc track eff
2377   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
2378   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
2379     fhMCcorrectionsMin->SetBinContent(j,-0.05);
2380   }
2381
2382   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
2383   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
2384     fhMCcorrectionsMax->SetBinContent(j,0.10);
2385   }
2386
2387
2388   // MC D EFF CORRECTION
2389   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
2390   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
2391     fhMCDefficiencyMin->SetBinContent(j,-0.05);
2392   }
2393
2394   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
2395   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
2396     fhMCDefficiencyMax->SetBinContent(j,0.05);
2397   }
2398
2399
2400   // Contamination from secondary tracks
2401   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
2402   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
2403     fhSecContaminationMin->SetBinContent(j,-0.05);
2404   }
2405
2406   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
2407   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
2408     fhSecContaminationMax->SetBinContent(j,0.05);
2409   }
2410
2411   // MC CLOSURETEST (D meson efficiency)
2412   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
2413   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
2414     x=fhMCclosureTestMin->GetBinLowEdge(j);
2415     fhMCclosureTestMin->SetBinContent(j,-0.08);
2416     
2417     if(-0.4<x&&x<-0.2){    
2418       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2419     }
2420     else if(-0.2<x&&x<-0.1){    
2421       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2422     }
2423     else if(-0.1<x&&x<0.1){    
2424       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
2425     }
2426     else if(0.1<x&&x<0.2){    
2427       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2428     }
2429     if(0.2<x&&x<0.4){    
2430       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2431     }
2432   }
2433
2434   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
2435   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
2436     x=fhMCclosureTestMax->GetBinLowEdge(j);
2437     fhMCclosureTestMax->SetBinContent(j,0.);
2438     
2439     //     if(-0.4<x&&x<-0.2){    
2440     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2441     //     }
2442     //     else if(-0.2<x&&x<-0.1){    
2443     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2444     //     }
2445     //     else if(-0.2<x&&x<-0.1){    
2446     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2447     //     }
2448     //     else if(-0.1<x&&x<0.1){    
2449     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
2450     //     }
2451     //     else if(0.1<x&&x<0.2){    
2452     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2453     //     }
2454     //     if(0.2<x&&x<0.4){    
2455     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2456     //     }
2457     
2458   }
2459   
2460   // Feed-down 
2461
2462   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
2463   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
2464     x=fhBeautyFDmin->GetBinLowEdge(j);
2465     fhBeautyFDmin->SetBinContent(j,-0.05);
2466     
2467   //   if(-0.4<x&&x<-0.2){    
2468 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2469 //     }
2470 //     else if(-0.2<x&&x<-0.1){    
2471 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2472 //     }
2473 //     else if(-0.2<x&&x<-0.1){    
2474 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2475 //     }
2476 //     else if(-0.1<x&&x<0.1){    
2477 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
2478 //     }
2479 //     else if(0.1<x&&x<0.2){    
2480 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2481 //     }
2482 //     if(0.2<x&&x<0.4){    
2483 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2484 //     }
2485   }
2486
2487   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
2488   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
2489     x=fhBeautyFDmax->GetBinLowEdge(j);
2490     fhBeautyFDmax->SetBinContent(j,0.03);
2491    
2492 //     if(-0.4<x&&x<-0.2){    
2493 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2494 //     }
2495 //     else if(-0.2<x&&x<-0.1){    
2496 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2497 //     }
2498 //     else if(-0.2<x&&x<-0.1){    
2499 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2500 //     }
2501 //     else if(-0.1<x&&x<0.1){    
2502 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
2503 //     }
2504 //     else if(0.1<x&&x<0.2){    
2505 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2506 //     }
2507 //     if(0.2<x&&x<0.4){    
2508 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2509 //     } 
2510     
2511   }
2512
2513 }
2514
2515
2516
2517 //////// HIGHER PT ASS THRESHOLDS
2518
2519 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DzeroLowPtAss05(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
2520   fmeson=0;
2521   fstrmeson="Dzero";
2522   fstrptAss="ptAsMore05";
2523   fstrptD="Dpt3to5";
2524   if(!fhDeltaPhiTemplate){
2525     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
2526   }
2527   Double_t x;
2528   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
2529   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
2530   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
2531     fhYieldExtraction->SetBinContent(j,0.1);
2532   }
2533
2534   // Background D MESON candidate subtraction (side-band variations, etc.)
2535   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
2536   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
2537     fhBackSubtractionMin->SetBinContent(j,-0.05);
2538   }
2539
2540   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
2541   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
2542     fhBackSubtractionMax->SetBinContent(j,0.05);
2543   }
2544
2545   
2546   // MC CORRECTIONS ( associatate track efficiency):
2547   //  -5%  +10% for assoc track eff 
2548   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
2549   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
2550     fhMCcorrectionsMin->SetBinContent(j,-0.05);
2551   }
2552
2553   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
2554   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
2555     fhMCcorrectionsMax->SetBinContent(j,0.10);
2556   }
2557
2558   // MC D EFF CORRECTION
2559   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
2560   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
2561     fhMCDefficiencyMin->SetBinContent(j,-0.05);
2562   }
2563
2564   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
2565   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
2566     fhMCDefficiencyMax->SetBinContent(j,0.05);
2567   }
2568
2569
2570   // Contamination from secondary tracks
2571   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
2572   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
2573     fhSecContaminationMin->SetBinContent(j,-0.05);
2574   }
2575
2576   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
2577   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
2578     fhSecContaminationMax->SetBinContent(j,0.05);
2579   }
2580
2581
2582   // MC CLOSURETEST (D meson efficiency)
2583   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
2584   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
2585     x=fhMCclosureTestMin->GetBinLowEdge(j);
2586     fhMCclosureTestMin->SetBinContent(j,-0.08);
2587     
2588     if(-0.4<x&&x<-0.2){    
2589       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2590     }
2591     else if(-0.2<x&&x<-0.1){    
2592       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2593     }
2594     else if(-0.1<x&&x<0.1){    
2595       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
2596     }
2597     else if(0.1<x&&x<0.2){    
2598       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2599     }
2600     if(0.2<x&&x<0.4){    
2601       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2602     }
2603   }
2604
2605   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
2606   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
2607     //    x=fhMCclosureTestMax->GetBinLowEdge(j);
2608     fhMCclosureTestMax->SetBinContent(j,0.);
2609     
2610     //     if(-0.4<x&&x<-0.2){    
2611     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2612     //     }
2613     //     else if(-0.2<x&&x<-0.1){    
2614     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2615     //     }
2616     //     else if(-0.2<x&&x<-0.1){    
2617     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2618     //     }
2619     //     else if(-0.1<x&&x<0.1){    
2620     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
2621     //     }
2622     //     else if(0.1<x&&x<0.2){    
2623     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2624     //     }
2625     //     if(0.2<x&&x<0.4){    
2626     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2627     //     }
2628     
2629   }
2630   
2631   // Feed-down 
2632
2633   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
2634   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
2635     x=fhBeautyFDmin->GetBinLowEdge(j);
2636     fhBeautyFDmin->SetBinContent(j,-0.05);
2637     
2638   //   if(-0.4<x&&x<-0.2){    
2639 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2640 //     }
2641 //     else if(-0.2<x&&x<-0.1){    
2642 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2643 //     }
2644 //     else if(-0.2<x&&x<-0.1){    
2645 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2646 //     }
2647 //     else if(-0.1<x&&x<0.1){    
2648 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
2649 //     }
2650 //     else if(0.1<x&&x<0.2){    
2651 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2652 //     }
2653 //     if(0.2<x&&x<0.4){    
2654 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2655 //     }
2656   }
2657
2658   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
2659   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
2660     x=fhBeautyFDmax->GetBinLowEdge(j);
2661     fhBeautyFDmax->SetBinContent(j,0.03);
2662    
2663 //     if(-0.4<x&&x<-0.2){    
2664 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2665 //     }
2666 //     else if(-0.2<x&&x<-0.1){    
2667 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2668 //     }
2669 //     else if(-0.2<x&&x<-0.1){    
2670 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2671 //     }
2672 //     else if(-0.1<x&&x<0.1){    
2673 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
2674 //     }
2675 //     else if(0.1<x&&x<0.2){    
2676 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2677 //     }
2678 //     if(0.2<x&&x<0.4){    
2679 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2680 //     } 
2681     
2682   }
2683   
2684 }
2685
2686 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DzeroMidPtAss05(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
2687
2688   fmeson=0;
2689   fstrmeson="Dzero";
2690   fstrptAss="ptAsMore05";
2691   fstrptD="Dpt5to8";
2692   if(!fhDeltaPhiTemplate){
2693     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
2694   }
2695   Double_t x;
2696   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
2697   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
2698   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
2699     fhYieldExtraction->SetBinContent(j,0.1);
2700   }
2701
2702   // Background D MESON candidate subtraction (side-band variations, etc.)
2703   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
2704   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
2705     fhBackSubtractionMin->SetBinContent(j,0.05);
2706   }
2707
2708   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
2709   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
2710     fhBackSubtractionMax->SetBinContent(j,0.05);
2711   }
2712   
2713   // MC CORRECTIONS:  -5%  +10% for assoc track eff
2714   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
2715   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
2716     fhMCcorrectionsMin->SetBinContent(j,-0.05);
2717   }
2718
2719   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
2720   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
2721     fhMCcorrectionsMax->SetBinContent(j,0.10);
2722   }
2723
2724
2725   // MC D EFF CORRECTION
2726   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
2727   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
2728     fhMCDefficiencyMin->SetBinContent(j,-0.05);
2729   }
2730
2731   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
2732   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
2733     fhMCDefficiencyMax->SetBinContent(j,0.05);
2734   }
2735
2736
2737   // Contamination from secondary tracks
2738   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
2739   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
2740     fhSecContaminationMin->SetBinContent(j,-0.05);
2741   }
2742
2743   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
2744   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
2745     fhSecContaminationMax->SetBinContent(j,0.05);
2746   }
2747
2748   // MC CLOSURETEST (D meson efficiency)
2749   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
2750   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
2751     x=fhMCclosureTestMin->GetBinLowEdge(j);
2752     fhMCclosureTestMin->SetBinContent(j,-0.08);
2753     
2754     if(-0.4<x&&x<-0.2){    
2755       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2756     }
2757     else if(-0.2<x&&x<-0.1){    
2758       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2759     }
2760     else if(-0.1<x&&x<0.1){    
2761       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
2762     }
2763     else if(0.1<x&&x<0.2){    
2764       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2765     }
2766     if(0.2<x&&x<0.4){    
2767       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2768     }
2769   }
2770
2771   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
2772   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
2773     x=fhMCclosureTestMax->GetBinLowEdge(j);
2774     fhMCclosureTestMax->SetBinContent(j,0.);
2775     
2776     //     if(-0.4<x&&x<-0.2){    
2777     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2778     //     }
2779     //     else if(-0.2<x&&x<-0.1){    
2780     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2781     //     }
2782     //     else if(-0.2<x&&x<-0.1){    
2783     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2784     //     }
2785     //     else if(-0.1<x&&x<0.1){    
2786     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
2787     //     }
2788     //     else if(0.1<x&&x<0.2){    
2789     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2790     //     }
2791     //     if(0.2<x&&x<0.4){    
2792     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2793     //     }
2794     
2795   }
2796   
2797   // Feed-down 
2798
2799   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
2800   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
2801     x=fhBeautyFDmin->GetBinLowEdge(j);
2802     fhBeautyFDmin->SetBinContent(j,-0.05);
2803     
2804   //   if(-0.4<x&&x<-0.2){    
2805 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2806 //     }
2807 //     else if(-0.2<x&&x<-0.1){    
2808 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2809 //     }
2810 //     else if(-0.2<x&&x<-0.1){    
2811 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2812 //     }
2813 //     else if(-0.1<x&&x<0.1){    
2814 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
2815 //     }
2816 //     else if(0.1<x&&x<0.2){    
2817 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2818 //     }
2819 //     if(0.2<x&&x<0.4){    
2820 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2821 //     }
2822   }
2823
2824   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
2825   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
2826     x=fhBeautyFDmax->GetBinLowEdge(j);
2827     fhBeautyFDmax->SetBinContent(j,0.03);
2828    
2829 //     if(-0.4<x&&x<-0.2){    
2830 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2831 //     }
2832 //     else if(-0.2<x&&x<-0.1){    
2833 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2834 //     }
2835 //     else if(-0.2<x&&x<-0.1){    
2836 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2837 //     }
2838 //     else if(-0.1<x&&x<0.1){    
2839 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
2840 //     }
2841 //     else if(0.1<x&&x<0.2){    
2842 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
2843 //     }
2844 //     if(0.2<x&&x<0.4){    
2845 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
2846 //     } 
2847     
2848   }
2849   
2850 }
2851
2852
2853 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DzeroHighPtAss05(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
2854   
2855   fmeson=0;
2856   fstrmeson="Dzero";
2857   fstrptAss="ptAsMore05";
2858   fstrptD="Dpt8to16";
2859   if(!fhDeltaPhiTemplate){
2860     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
2861   }
2862
2863   Double_t x;
2864   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
2865   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
2866   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
2867     fhYieldExtraction->SetBinContent(j,0.1);
2868   }
2869
2870   // Background D MESON candidate subtraction (side-band variations, etc.)
2871   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
2872   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
2873     fhBackSubtractionMin->SetBinContent(j,0.05);
2874   }
2875
2876   // Background D MESON candidate subtraction (side-band variations, etc.)
2877   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
2878   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
2879     fhBackSubtractionMax->SetBinContent(j,0.05);
2880   }
2881   
2882   // MC CORRECTIONS,  -5% 10% for assoc track eff
2883   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
2884   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
2885     fhMCcorrectionsMin->SetBinContent(j,-0.05);
2886   }
2887
2888   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
2889   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
2890     fhMCcorrectionsMax->SetBinContent(j,0.10);
2891   }
2892
2893
2894   // MC D EFF CORRECTION
2895   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
2896   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
2897     fhMCDefficiencyMin->SetBinContent(j,-0.05);
2898   }
2899
2900   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
2901   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
2902     fhMCDefficiencyMax->SetBinContent(j,0.05);
2903   }
2904
2905
2906   // Contamination from secondary tracks
2907   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
2908   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
2909     fhSecContaminationMin->SetBinContent(j,-0.05);
2910   }
2911
2912   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
2913   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
2914     fhSecContaminationMax->SetBinContent(j,0.05);
2915   }
2916
2917   // MC CLOSURETEST (D meson efficiency)
2918   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
2919   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
2920     x=fhMCclosureTestMin->GetBinLowEdge(j);
2921     fhMCclosureTestMin->SetBinContent(j,-0.08);
2922     
2923     if(-0.4<x&&x<-0.2){    
2924       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2925     }
2926     else if(-0.2<x&&x<-0.1){    
2927       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2928     }
2929     else if(-0.1<x&&x<0.1){    
2930       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
2931     }
2932     else if(0.1<x&&x<0.2){    
2933       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
2934     }
2935     if(0.2<x&&x<0.4){    
2936       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
2937     }
2938   }
2939
2940   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
2941   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
2942     x=fhMCclosureTestMax->GetBinLowEdge(j);
2943     fhMCclosureTestMax->SetBinContent(j,0.);
2944     
2945     //     if(-0.4<x&&x<-0.2){    
2946     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2947     //     }
2948     //     else if(-0.2<x&&x<-0.1){    
2949     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2950     //     }
2951     //     else if(-0.2<x&&x<-0.1){    
2952     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2953     //     }
2954     //     else if(-0.1<x&&x<0.1){    
2955     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
2956     //     }
2957     //     else if(0.1<x&&x<0.2){    
2958     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
2959     //     }
2960     //     if(0.2<x&&x<0.4){    
2961     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
2962     //     }
2963     
2964   }
2965   
2966   // Feed-down 
2967
2968   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
2969   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
2970     x=fhBeautyFDmin->GetBinLowEdge(j);
2971     fhBeautyFDmin->SetBinContent(j,-0.05);
2972     
2973   //   if(-0.4<x&&x<-0.2){    
2974 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2975 //     }
2976 //     else if(-0.2<x&&x<-0.1){    
2977 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2978 //     }
2979 //     else if(-0.2<x&&x<-0.1){    
2980 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2981 //     }
2982 //     else if(-0.1<x&&x<0.1){    
2983 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
2984 //     }
2985 //     else if(0.1<x&&x<0.2){    
2986 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
2987 //     }
2988 //     if(0.2<x&&x<0.4){    
2989 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
2990 //     }
2991   }
2992
2993   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
2994   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
2995     x=fhBeautyFDmax->GetBinLowEdge(j);
2996     fhBeautyFDmax->SetBinContent(j,0.03);
2997    
2998 //     if(-0.4<x&&x<-0.2){    
2999 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
3000 //     }
3001 //     else if(-0.2<x&&x<-0.1){    
3002 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
3003 //     }
3004 //     else if(-0.2<x&&x<-0.1){    
3005 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
3006 //     }
3007 //     else if(-0.1<x&&x<0.1){    
3008 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
3009 //     }
3010 //     else if(0.1<x&&x<0.2){    
3011 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
3012 //     }
3013 //     if(0.2<x&&x<0.4){    
3014 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
3015 //     } 
3016     
3017   }
3018
3019 }
3020
3021
3022
3023
3024 //--------------------------------------------------
3025 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DstarLowPtAss05(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
3026   fmeson=1;
3027   fstrmeson="Dstar";
3028   fstrptAss="ptAsMore05";
3029   fstrptD="Dpt3to5";
3030   if(!fhDeltaPhiTemplate){
3031     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
3032   }
3033   Double_t x;
3034   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
3035   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
3036   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
3037     fhYieldExtraction->SetBinContent(j,0.1);
3038   }
3039
3040   // Background D MESON candidate subtraction (side-band variations, etc.)
3041   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
3042   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
3043     fhBackSubtractionMin->SetBinContent(j,0.05);
3044   }
3045
3046   // Background D MESON candidate subtraction (side-band variations, etc.)
3047   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
3048   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
3049     fhBackSubtractionMax->SetBinContent(j,0.05);
3050   }
3051   
3052   // MC CORRECTIONS, -5%  10% for assoc track eff
3053   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
3054   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
3055     fhMCcorrectionsMin->SetBinContent(j,-0.05);
3056   }
3057
3058   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
3059   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
3060     fhMCcorrectionsMax->SetBinContent(j,0.10);
3061   }
3062
3063
3064   // MC D EFF CORRECTION
3065   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
3066   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
3067     fhMCDefficiencyMin->SetBinContent(j,-0.05);
3068   }
3069
3070   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
3071   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
3072     fhMCDefficiencyMax->SetBinContent(j,0.05);
3073   }
3074
3075
3076   // Contamination from secondary tracks
3077   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
3078   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
3079     fhSecContaminationMin->SetBinContent(j,-0.05);
3080   }
3081
3082   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
3083   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
3084     fhSecContaminationMax->SetBinContent(j,0.05);
3085   }
3086
3087   // MC CLOSURETEST (D meson efficiency)
3088   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
3089   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
3090     x=fhMCclosureTestMin->GetBinLowEdge(j);
3091     fhMCclosureTestMin->SetBinContent(j,-0.08);
3092     
3093     if(-0.4<x&&x<-0.2){    
3094       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
3095     }
3096     else if(-0.2<x&&x<-0.1){    
3097       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
3098     }
3099     else if(-0.1<x&&x<0.1){    
3100       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
3101     }
3102     else if(0.1<x&&x<0.2){    
3103       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
3104     }
3105     if(0.2<x&&x<0.4){    
3106       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
3107     }
3108   }
3109
3110   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
3111   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
3112     x=fhMCclosureTestMax->GetBinLowEdge(j);
3113     fhMCclosureTestMax->SetBinContent(j,0.);
3114     
3115     //     if(-0.4<x&&x<-0.2){    
3116     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
3117     //     }
3118     //     else if(-0.2<x&&x<-0.1){    
3119     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
3120     //     }
3121     //     else if(-0.2<x&&x<-0.1){    
3122     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
3123     //     }
3124     //     else if(-0.1<x&&x<0.1){    
3125     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
3126     //     }
3127     //     else if(0.1<x&&x<0.2){    
3128     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
3129     //     }
3130     //     if(0.2<x&&x<0.4){    
3131     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
3132     //     }
3133     
3134   }
3135   
3136   // Feed-down 
3137
3138   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
3139   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
3140     x=fhBeautyFDmin->GetBinLowEdge(j);
3141     fhBeautyFDmin->SetBinContent(j,-0.05);
3142     
3143   //   if(-0.4<x&&x<-0.2){    
3144 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
3145 //     }
3146 //     else if(-0.2<x&&x<-0.1){    
3147 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
3148 //     }
3149 //     else if(-0.2<x&&x<-0.1){    
3150 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
3151 //     }
3152 //     else if(-0.1<x&&x<0.1){    
3153 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.08);      
3154 //     }
3155 //     else if(0.1<x&&x<0.2){    
3156 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
3157 //     }
3158 //     if(0.2<x&&x<0.4){    
3159 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
3160 //     }
3161   }
3162
3163   fhBeautyFDmax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmax");
3164   for(Int_t j=1;j<=fhBeautyFDmax->GetNbinsX();j++){
3165     x=fhBeautyFDmax->GetBinLowEdge(j);
3166     fhBeautyFDmax->SetBinContent(j,0.03);
3167    
3168 //     if(-0.4<x&&x<-0.2){    
3169 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
3170 //     }
3171 //     else if(-0.2<x&&x<-0.1){    
3172 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
3173 //     }
3174 //     else if(-0.2<x&&x<-0.1){    
3175 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
3176 //     }
3177 //     else if(-0.1<x&&x<0.1){    
3178 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.08);      
3179 //     }
3180 //     else if(0.1<x&&x<0.2){    
3181 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.06);      
3182 //     }
3183 //     if(0.2<x&&x<0.4){    
3184 //       fhBeautyFDmax->SetBinContent(j,fhBeautyFDmax->GetBinContent(j)+0.04);      
3185 //     } 
3186     
3187   }
3188
3189
3190 }
3191
3192 void AliHFDhadronCorrSystUnc::InitStandardUncertaintiesPP2010DstarMidPtAss05(){ Printf("TEMPORARY VALUES (PP 2010 ass 03)");
3193
3194   fmeson=1;
3195   fstrmeson="Dstar";
3196   fstrptAss="ptAsMore05";
3197   fstrptD="Dpt5to8";
3198   if(!fhDeltaPhiTemplate){
3199     fhDeltaPhiTemplate=new TH1D("fhDeltaPhiTemplate","fhDeltaPhiTemplate",32,-TMath::Pi()/2.,3./2.*TMath::Pi());
3200   }
3201   Double_t x;
3202   // D MESON YIELD EXTRACTION (->NORMALIZATION): relative uncertainty is constant
3203   fhYieldExtraction=(TH1D*)fhDeltaPhiTemplate->Clone("fhYieldExtraction");
3204   for(Int_t j=1;j<=fhYieldExtraction->GetNbinsX();j++){
3205     fhYieldExtraction->SetBinContent(j,0.1);
3206   }
3207
3208   // Background D MESON candidate subtraction (side-band variations, etc.)
3209   fhBackSubtractionMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMin");
3210   for(Int_t j=1;j<=fhBackSubtractionMin->GetNbinsX();j++){
3211     fhBackSubtractionMin->SetBinContent(j,0.05);
3212   }
3213
3214   fhBackSubtractionMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhBackSubtractionMax");
3215   for(Int_t j=1;j<=fhBackSubtractionMax->GetNbinsX();j++){
3216     fhBackSubtractionMax->SetBinContent(j,0.05);
3217   }
3218   
3219   // MC CORRECTIONS/ -5%  10% for assoc track eff
3220   fhMCcorrectionsMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMin");
3221   for(Int_t j=1;j<=fhMCcorrectionsMin->GetNbinsX();j++){
3222     fhMCcorrectionsMin->SetBinContent(j,-0.05);
3223   }
3224
3225   fhMCcorrectionsMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCcorrectionsMax");
3226   for(Int_t j=1;j<=fhMCcorrectionsMax->GetNbinsX();j++){
3227     fhMCcorrectionsMax->SetBinContent(j,0.10);
3228   }
3229
3230   // MC D EFF CORRECTION
3231   fhMCDefficiencyMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMin");
3232   for(Int_t j=1;j<=fhMCDefficiencyMin->GetNbinsX();j++){
3233     fhMCDefficiencyMin->SetBinContent(j,-0.05);
3234   }
3235
3236   fhMCDefficiencyMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCDefficiencyMax");
3237   for(Int_t j=1;j<=fhMCDefficiencyMax->GetNbinsX();j++){
3238     fhMCDefficiencyMax->SetBinContent(j,0.05);
3239   }
3240
3241
3242   // Contamination from secondary tracks
3243   fhSecContaminationMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMin");
3244   for(Int_t j=1;j<=fhSecContaminationMin->GetNbinsX();j++){
3245     fhSecContaminationMin->SetBinContent(j,-0.05);
3246   }
3247
3248   fhSecContaminationMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhSecContaminationMax");
3249   for(Int_t j=1;j<=fhSecContaminationMax->GetNbinsX();j++){
3250     fhSecContaminationMax->SetBinContent(j,0.05);
3251   }
3252
3253   // MC CLOSURETEST (D meson efficiency)
3254   fhMCclosureTestMin=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMin");
3255   for(Int_t j=1;j<=fhMCclosureTestMin->GetNbinsX();j++){
3256     x=fhMCclosureTestMin->GetBinLowEdge(j);
3257     fhMCclosureTestMin->SetBinContent(j,-0.08);
3258     
3259     if(-0.4<x&&x<-0.2){    
3260       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
3261     }
3262     else if(-0.2<x&&x<-0.1){    
3263       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
3264     }
3265     else if(-0.1<x&&x<0.1){    
3266       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.02);      
3267     }
3268     else if(0.1<x&&x<0.2){    
3269       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.015);      
3270     }
3271     if(0.2<x&&x<0.4){    
3272       fhMCclosureTestMin->SetBinContent(j,fhMCclosureTestMin->GetBinContent(j)-0.01);      
3273     }
3274   }
3275
3276   fhMCclosureTestMax=(TH1D*)fhDeltaPhiTemplate->Clone("fhMCclosureTestMax");
3277   for(Int_t j=1;j<=fhMCclosureTestMax->GetNbinsX();j++){
3278     x=fhMCclosureTestMax->GetBinLowEdge(j);
3279     fhMCclosureTestMax->SetBinContent(j,0.);
3280     
3281     //     if(-0.4<x&&x<-0.2){    
3282     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
3283     //     }
3284     //     else if(-0.2<x&&x<-0.1){    
3285     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
3286     //     }
3287     //     else if(-0.2<x&&x<-0.1){    
3288     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
3289     //     }
3290     //     else if(-0.1<x&&x<0.1){    
3291     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.08);      
3292     //     }
3293     //     else if(0.1<x&&x<0.2){    
3294     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.06);      
3295     //     }
3296     //     if(0.2<x&&x<0.4){    
3297     //       fhMCclosureTestMax->SetBinContent(j,fhMCclosureTestMax->GetBinContent(j)-0.04);      
3298     //     }
3299     
3300   }
3301   
3302   // Feed-down 
3303
3304   fhBeautyFDmin=(TH1D*)fhDeltaPhiTemplate->Clone("fhBeautyFDmin");
3305   for(Int_t j=1;j<=fhBeautyFDmin->GetNbinsX();j++){
3306     x=fhBeautyFDmin->GetBinLowEdge(j);
3307     fhBeautyFDmin->SetBinContent(j,-0.05);
3308     
3309   //   if(-0.4<x&&x<-0.2){    
3310 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.04);      
3311 //     }
3312 //     else if(-0.2<x&&x<-0.1){    
3313 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
3314 //     }
3315 //     else if(-0.2<x&&x<-0.1){    
3316 //       fhBeautyFDmin->SetBinContent(j,fhBeautyFDmin->GetBinContent(j)-0.06);      
3317 //     }
3318 //     else if(-0.1<x&&x<0.1){    
3319 //   &nb