AliPhysics  master (3d17d9d)
AliAnalysisTaskSEImproveITS.cxx
Go to the documentation of this file.
1 /*************************************************************************
2 * Copyright(c) 1998-2011, 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 #include <TObjArray.h>
17 #include <TClonesArray.h>
18 #include <TGraph.h>
19 #include <TFile.h>
20 #include <TList.h>
21 #include <TNtuple.h>
22 
23 #include "AliVertex.h"
24 #include "AliVVertex.h"
25 #include "AliESDVertex.h"
26 #include "AliESDEvent.h"
27 #include "AliVertexerTracks.h"
28 #include "AliAODEvent.h"
29 #include "AliAODTrack.h"
30 #include "AliMCEvent.h"
31 #include "AliAODMCParticle.h"
32 #include "AliExternalTrackParam.h"
35 #include "AliAODRecoCascadeHF.h"
36 #include "AliAODMCHeader.h"
37 #include "AliAnalysisVertexingHF.h"
38 #include "AliNeutralTrackParam.h"
40 #include "AliVertexingHFUtils.h"
41 //
42 // Implementation of the "hybrid-approach" for ITS upgrade studies.
43 // The tastk smears the track parameters according to estimations
44 // from single-track upgrade studies. Afterwards it recalculates
45 // the parameters of the reconstructed decays.
46 //
47 // WARNING: This will affect all tasks in a train after this one
48 // (which is typically desired, though).
49 //
50 
53  fD0ZResPCur (0),
54  fD0ZResKCur (0),
55  fD0ZResPiCur (0),
56  fD0ZResECur (0),
57  fD0RPResPCur (0),
58  fD0RPResKCur (0),
59  fD0RPResPiCur(0),
60  fD0RPResECur(0),
61  fD0RPSigmaPullRatioP(0),
62  fD0RPSigmaPullRatioK(0),
63  fD0RPSigmaPullRatioPi(0),
64  fD0RPSigmaPullRatioE(0),
65  fPt1ResPCur (0),
66  fPt1ResKCur (0),
67  fPt1ResPiCur (0),
68  fPt1ResECur (0),
69  fD0ZResPUpg (0),
70  fD0ZResKUpg (0),
71  fD0ZResPiUpg (0),
72  fD0ZResEUpg (0),
73  fD0RPResPUpg (0),
74  fD0RPResKUpg (0),
75  fD0RPResPiUpg(0),
76  fD0RPResEUpg(0),
77  fPt1ResPUpg (0),
78  fPt1ResKUpg (0),
79  fPt1ResPiUpg (0),
80  fPt1ResEUpg (0),
81  fD0ZResPCurSA (0),
82  fD0ZResKCurSA (0),
83  fD0ZResPiCurSA (0),
84  fD0ZResECurSA (0),
85  fD0RPResPCurSA (0),
86  fD0RPResKCurSA (0),
87  fD0RPResPiCurSA(0),
88  fD0RPResECurSA(0),
89  fPt1ResPCurSA (0),
90  fPt1ResKCurSA (0),
91  fPt1ResPiCurSA (0),
92  fPt1ResECurSA (0),
93  fD0ZResPUpgSA (0),
94  fD0ZResKUpgSA (0),
95  fD0ZResPiUpgSA (0),
96  fD0ZResEUpgSA (0),
97  fD0RPResPUpgSA (0),
98  fD0RPResKUpgSA (0),
99  fD0RPResPiUpgSA(0),
100  fD0RPResEUpgSA(0),
101  fPt1ResPUpgSA (0),
102  fPt1ResKUpgSA (0),
103  fPt1ResPiUpgSA (0),
104  fPt1ResEUpgSA (0),
105  // specific stuff for PbPb 2018
106  fIsPbPb2018(kFALSE)
107  // kFirst
108  ,fD0ZResPCur_PbPb2018_kFirst(0)
109  ,fD0ZResKCur_PbPb2018_kFirst(0)
110  ,fD0ZResPiCur_PbPb2018_kFirst(0)
111  ,fD0ZResECur_PbPb2018_kFirst(0)
112  ,fD0RPResPCur_PbPb2018_kFirst(0)
113  ,fD0RPResKCur_PbPb2018_kFirst(0)
114  ,fD0RPResPiCur_PbPb2018_kFirst(0)
115  ,fD0RPResECur_PbPb2018_kFirst(0)
116  ,fD0RPSigmaPullRatioP_PbPb2018_kFirst(0)
117  ,fD0RPSigmaPullRatioK_PbPb2018_kFirst(0)
118  ,fD0RPSigmaPullRatioPi_PbPb2018_kFirst(0)
119  ,fD0RPSigmaPullRatioE_PbPb2018_kFirst(0)
120  ,fPt1ResPCur_PbPb2018_kFirst(0)
121  ,fPt1ResKCur_PbPb2018_kFirst(0)
122  ,fPt1ResPiCur_PbPb2018_kFirst(0)
123  ,fPt1ResECur_PbPb2018_kFirst(0)
124  ,fD0ZResPUpg_PbPb2018_kFirst(0)
125  ,fD0ZResKUpg_PbPb2018_kFirst(0)
126  ,fD0ZResPiUpg_PbPb2018_kFirst(0)
127  ,fD0ZResEUpg_PbPb2018_kFirst(0)
128  ,fD0RPResPUpg_PbPb2018_kFirst(0)
129  ,fD0RPResKUpg_PbPb2018_kFirst(0)
130  ,fD0RPResPiUpg_PbPb2018_kFirst(0)
131  ,fD0RPResEUpg_PbPb2018_kFirst(0)
132  ,fPt1ResPUpg_PbPb2018_kFirst(0)
133  ,fPt1ResKUpg_PbPb2018_kFirst(0)
134  ,fPt1ResPiUpg_PbPb2018_kFirst(0)
135  ,fPt1ResEUpg_PbPb2018_kFirst(0)
136  ,fD0ZResPCurSA_PbPb2018_kFirst(0)
137  ,fD0ZResKCurSA_PbPb2018_kFirst(0)
138  ,fD0ZResPiCurSA_PbPb2018_kFirst(0)
139  ,fD0ZResECurSA_PbPb2018_kFirst(0)
140  ,fD0RPResPCurSA_PbPb2018_kFirst(0)
141  ,fD0RPResKCurSA_PbPb2018_kFirst(0)
142  ,fD0RPResPiCurSA_PbPb2018_kFirst(0)
143  ,fD0RPResECurSA_PbPb2018_kFirst(0)
144  ,fPt1ResPCurSA_PbPb2018_kFirst(0)
145  ,fPt1ResKCurSA_PbPb2018_kFirst(0)
146  ,fPt1ResPiCurSA_PbPb2018_kFirst(0)
147  ,fPt1ResECurSA_PbPb2018_kFirst(0)
148  ,fD0ZResPUpgSA_PbPb2018_kFirst(0)
149  ,fD0ZResKUpgSA_PbPb2018_kFirst(0)
150  ,fD0ZResPiUpgSA_PbPb2018_kFirst(0)
151  ,fD0ZResEUpgSA_PbPb2018_kFirst(0)
152  ,fD0RPResPUpgSA_PbPb2018_kFirst(0)
153  ,fD0RPResKUpgSA_PbPb2018_kFirst(0)
154  ,fD0RPResPiUpgSA_PbPb2018_kFirst(0)
155  ,fD0RPResEUpgSA_PbPb2018_kFirst(0)
156  ,fPt1ResPUpgSA_PbPb2018_kFirst(0)
157  ,fPt1ResKUpgSA_PbPb2018_kFirst(0)
158  ,fPt1ResPiUpgSA_PbPb2018_kFirst(0)
159  ,fPt1ResEUpgSA_PbPb2018_kFirst(0)
160  // kOnlySecond
161  ,fD0ZResPCur_PbPb2018_kOnlySecond(0)
162  ,fD0ZResKCur_PbPb2018_kOnlySecond(0)
163  ,fD0ZResPiCur_PbPb2018_kOnlySecond(0)
164  ,fD0ZResECur_PbPb2018_kOnlySecond(0)
165  ,fD0RPResPCur_PbPb2018_kOnlySecond(0)
166  ,fD0RPResKCur_PbPb2018_kOnlySecond(0)
167  ,fD0RPResPiCur_PbPb2018_kOnlySecond(0)
168  ,fD0RPResECur_PbPb2018_kOnlySecond(0)
169  ,fD0RPSigmaPullRatioP_PbPb2018_kOnlySecond(0)
170  ,fD0RPSigmaPullRatioK_PbPb2018_kOnlySecond(0)
171  ,fD0RPSigmaPullRatioPi_PbPb2018_kOnlySecond(0)
172  ,fD0RPSigmaPullRatioE_PbPb2018_kOnlySecond(0)
173  ,fPt1ResPCur_PbPb2018_kOnlySecond(0)
174  ,fPt1ResKCur_PbPb2018_kOnlySecond(0)
175  ,fPt1ResPiCur_PbPb2018_kOnlySecond(0)
176  ,fPt1ResECur_PbPb2018_kOnlySecond(0)
177  ,fD0ZResPUpg_PbPb2018_kOnlySecond(0)
178  ,fD0ZResKUpg_PbPb2018_kOnlySecond(0)
179  ,fD0ZResPiUpg_PbPb2018_kOnlySecond(0)
180  ,fD0ZResEUpg_PbPb2018_kOnlySecond(0)
181  ,fD0RPResPUpg_PbPb2018_kOnlySecond(0)
182  ,fD0RPResKUpg_PbPb2018_kOnlySecond(0)
183  ,fD0RPResPiUpg_PbPb2018_kOnlySecond(0)
184  ,fD0RPResEUpg_PbPb2018_kOnlySecond(0)
185  ,fPt1ResPUpg_PbPb2018_kOnlySecond(0)
186  ,fPt1ResKUpg_PbPb2018_kOnlySecond(0)
187  ,fPt1ResPiUpg_PbPb2018_kOnlySecond(0)
188  ,fPt1ResEUpg_PbPb2018_kOnlySecond(0)
189  ,fD0ZResPCurSA_PbPb2018_kOnlySecond(0)
190  ,fD0ZResKCurSA_PbPb2018_kOnlySecond(0)
191  ,fD0ZResPiCurSA_PbPb2018_kOnlySecond(0)
192  ,fD0ZResECurSA_PbPb2018_kOnlySecond(0)
193  ,fD0RPResPCurSA_PbPb2018_kOnlySecond(0)
194  ,fD0RPResKCurSA_PbPb2018_kOnlySecond(0)
195  ,fD0RPResPiCurSA_PbPb2018_kOnlySecond(0)
196  ,fD0RPResECurSA_PbPb2018_kOnlySecond(0)
197  ,fPt1ResPCurSA_PbPb2018_kOnlySecond(0)
198  ,fPt1ResKCurSA_PbPb2018_kOnlySecond(0)
199  ,fPt1ResPiCurSA_PbPb2018_kOnlySecond(0)
200  ,fPt1ResECurSA_PbPb2018_kOnlySecond(0)
201  ,fD0ZResPUpgSA_PbPb2018_kOnlySecond(0)
202  ,fD0ZResKUpgSA_PbPb2018_kOnlySecond(0)
203  ,fD0ZResPiUpgSA_PbPb2018_kOnlySecond(0)
204  ,fD0ZResEUpgSA_PbPb2018_kOnlySecond(0)
205  ,fD0RPResPUpgSA_PbPb2018_kOnlySecond(0)
206  ,fD0RPResKUpgSA_PbPb2018_kOnlySecond(0)
207  ,fD0RPResPiUpgSA_PbPb2018_kOnlySecond(0)
208  ,fD0RPResEUpgSA_PbPb2018_kOnlySecond(0)
209  ,fPt1ResPUpgSA_PbPb2018_kOnlySecond(0)
210  ,fPt1ResKUpgSA_PbPb2018_kOnlySecond(0)
211  ,fPt1ResPiUpgSA_PbPb2018_kOnlySecond(0)
212  ,fPt1ResEUpgSA_PbPb2018_kOnlySecond(0),
213  fRunInVertexing(kFALSE),
214  fImproveTracks(kTRUE),
215  fUpdateSecVertCovMat(kTRUE),
216  fUpdateSTCovMatrix(kTRUE),
217  fUpdatePulls(kTRUE),
218  fMimicData(kFALSE),
219  fIsAOD (kTRUE),
220  fSmearOnlySignal(kFALSE),
221  fMCs (0),
222  fDebugOutput (0),
223  fDebugNtuple (0),
224  fDebugVars (0),
225  fNDebug (0)
226 {
227  //
228  // Default constructor.
229  for(Int_t jh=0; jh<2; jh++){
230  // templates of mean (original)
231  for(Int_t ih=0; ih<4; ih++){
232  fD0RPMeanPCur[jh][ih]=0x0;
233  fD0RPMeanKCur[jh][ih]=0x0;
234  fD0RPMeanPiCur[jh][ih]=0x0;
235  fD0RPMeanECur[jh][ih]=0x0;
236  fD0RPMeanPUpg[jh][ih]=0x0;
237  fD0RPMeanKUpg[jh][ih]=0x0;
238  fD0RPMeanPiUpg[jh][ih]=0x0;
239  fD0RPMeanEUpg[jh][ih]=0x0;
240  }
241  // templates of mean for Pb-Pb 2018
242  for(UInt_t ih = 0; ih < 24; ih++)
243  {
244  fD0RPMeanPCur_PbPb2018_kFirst[jh][ih]=0x0;
245  fD0RPMeanKCur_PbPb2018_kFirst[jh][ih]=0x0;
246  fD0RPMeanPiCur_PbPb2018_kFirst[jh][ih]=0x0;
247  fD0RPMeanECur_PbPb2018_kFirst[jh][ih]=0x0;
248  fD0RPMeanPUpg_PbPb2018_kFirst[jh][ih]=0x0;
249  fD0RPMeanKUpg_PbPb2018_kFirst[jh][ih]=0x0;
250  fD0RPMeanPiUpg_PbPb2018_kFirst[jh][ih]=0x0;
251  fD0RPMeanEUpg_PbPb2018_kFirst[jh][ih]=0x0;
260  }
261 
262  }
263  //
264 }
265 
267  const char *period,
268  const char *systematic,
269  Bool_t isRunInVertexing,
270  Int_t ndebug)
271  :AliAnalysisTaskSE(name),
272  fD0ZResPCur (0),
273  fD0ZResKCur (0),
274  fD0ZResPiCur (0),
275  fD0ZResECur (0),
276  fD0RPResPCur (0),
277  fD0RPResKCur (0),
278  fD0RPResPiCur(0),
279  fD0RPResECur(0),
284  fPt1ResPCur (0),
285  fPt1ResKCur (0),
286  fPt1ResPiCur (0),
287  fPt1ResECur (0),
288  fD0ZResPUpg (0),
289  fD0ZResKUpg (0),
290  fD0ZResPiUpg (0),
291  fD0ZResEUpg (0),
292  fD0RPResPUpg (0),
293  fD0RPResKUpg (0),
294  fD0RPResPiUpg(0),
295  fD0RPResEUpg(0),
296  fPt1ResPUpg (0),
297  fPt1ResKUpg (0),
298  fPt1ResPiUpg (0),
299  fPt1ResEUpg (0),
300  fD0ZResPCurSA (0),
301  fD0ZResKCurSA (0),
302  fD0ZResPiCurSA (0),
303  fD0ZResECurSA (0),
304  fD0RPResPCurSA (0),
305  fD0RPResKCurSA (0),
306  fD0RPResPiCurSA(0),
307  fD0RPResECurSA(0),
308  fPt1ResPCurSA (0),
309  fPt1ResKCurSA (0),
310  fPt1ResPiCurSA (0),
311  fPt1ResECurSA (0),
312  fD0ZResPUpgSA (0),
313  fD0ZResKUpgSA (0),
314  fD0ZResPiUpgSA (0),
315  fD0ZResEUpgSA (0),
316  fD0RPResPUpgSA (0),
317  fD0RPResKUpgSA (0),
318  fD0RPResPiUpgSA(0),
319  fD0RPResEUpgSA(0),
320  fPt1ResPUpgSA (0),
321  fPt1ResKUpgSA (0),
322  fPt1ResPiUpgSA (0),
323  fPt1ResEUpgSA (0),
324  // specific stuff for PbPb 2018
325  fIsPbPb2018(kFALSE)
326  // kFirst
379  // kOnlySecond
432  fRunInVertexing(isRunInVertexing),
433  fImproveTracks(kTRUE),
434  fUpdateSecVertCovMat(kTRUE),
435  fUpdateSTCovMatrix(kTRUE),
436  fUpdatePulls(kTRUE),
437  fMimicData(kFALSE),
438  fIsAOD (kTRUE),
439  fSmearOnlySignal(kFALSE),
440  fMCs (0),
441  fDebugOutput (0),
442  fDebugNtuple (0),
443  fDebugVars (0),
444  fNDebug (ndebug)
445 {
446  //
447  // Constructor to be used to create the task.
448  // The the URIs specify the resolution files to be used.
449  // They are expected to contain TGraphs with the resolutions
450  // for the current and the upgraded ITS (see code for details).
451  // One may also specify for how many tracks debug information
452  // is written to the output.
453  //
454  for(Int_t jh=0; jh<2; jh++){
455  // templates of mean (original)
456  for(Int_t ih=0; ih<4; ih++){
457  fD0RPMeanPCur[jh][ih]=0x0;
458  fD0RPMeanKCur[jh][ih]=0x0;
459  fD0RPMeanPiCur[jh][ih]=0x0;
460  fD0RPMeanECur[jh][ih]=0x0;
461  fD0RPMeanPUpg[jh][ih]=0x0;
462  fD0RPMeanKUpg[jh][ih]=0x0;
463  fD0RPMeanPiUpg[jh][ih]=0x0;
464  fD0RPMeanEUpg[jh][ih]=0x0;
465  }
466  // templates of mean for Pb-Pb 2018
467  for(UInt_t ih = 0; ih < 24; ih++)
468  {
469  fD0RPMeanPCur_PbPb2018_kFirst[jh][ih]=0x0;
470  fD0RPMeanKCur_PbPb2018_kFirst[jh][ih]=0x0;
471  fD0RPMeanPiCur_PbPb2018_kFirst[jh][ih]=0x0;
472  fD0RPMeanECur_PbPb2018_kFirst[jh][ih]=0x0;
473  fD0RPMeanPUpg_PbPb2018_kFirst[jh][ih]=0x0;
474  fD0RPMeanKUpg_PbPb2018_kFirst[jh][ih]=0x0;
475  fD0RPMeanPiUpg_PbPb2018_kFirst[jh][ih]=0x0;
476  fD0RPMeanEUpg_PbPb2018_kFirst[jh][ih]=0x0;
485  }
486  }
487 
488  TString resfileCurURI = Form("alien:///alice/cern.ch/user/p/pwg_hf/common/Improver/%s/%s/ITSgraphs_Current.root",period,systematic);
489  TString resfileUpgURI = Form("alien:///alice/cern.ch/user/p/pwg_hf/common/Improver/%s/%s/ITSgraphs_NewAll-X0.3-Res4um.root",period,systematic);
490 
491  printf("\n### reading file %s ...\n",resfileCurURI.Data());
492  TFile *resfileCur=TFile::Open(resfileCurURI.Data());
493  if(resfileCur) printf("... READ ###\n");
494  if( (resfileCurURI.Contains("LHC18r") || resfileCurURI.Contains("LHC18q")) &&
495  (resfileUpgURI.Contains("LHC18r") || resfileUpgURI.Contains("LHC18q"))) fIsPbPb2018=kTRUE;
496  printf("\n\n===\n=== fIsPbPb2018: %s\n===\n\n",fIsPbPb2018?"kTRUE":"kFALSE");
497  if(resfileCur) {
498  if(!fIsPbPb2018){
499  if(resfileCur->Get("D0RPResP" )) {
500  fD0RPResPCur =(TGraph*)(resfileCur->Get("D0RPResP" )->Clone("D0RPResPCur" ));
501  }
502  if(resfileCur->Get("D0RPResK" )) {
503  fD0RPResKCur =(TGraph*)(resfileCur->Get("D0RPResK" )->Clone("D0RPResKCur" ));
504  }
505  if(resfileCur->Get("D0RPResPi")) {
506  fD0RPResPiCur=(TGraph*)(resfileCur->Get("D0RPResPi")->Clone("D0RPResPiCur"));
507  }
508  if(resfileCur->Get("D0RPResE")) {
509  fD0RPResECur=(TGraph*)(resfileCur->Get("D0RPResE")->Clone("D0RPResECur"));
510  }
511  if(resfileCur->Get("D0RPSigmaPullRatioP" )) {
512  fD0RPSigmaPullRatioP =(TGraph*)(resfileCur->Get("D0RPSigmaPullRatioP" ));
513  }
514  if(resfileCur->Get("D0RPSigmaPullRatioK" )) {
515  fD0RPSigmaPullRatioK =(TGraph*)(resfileCur->Get("D0RPSigmaPullRatioK" ));
516  }
517  if(resfileCur->Get("D0RPSigmaPullRatioPi")) {
518  fD0RPSigmaPullRatioPi=(TGraph*)(resfileCur->Get("D0RPSigmaPullRatioPi"));
519  }
520  if(resfileCur->Get("D0RPSigmaPullRatioE")) {
521  fD0RPSigmaPullRatioE=(TGraph*)(resfileCur->Get("D0RPSigmaPullRatioE"));
522  }
523  for(Int_t j=0; j<2; j++){
524  for(Int_t i=0; i<4; i++){
525  if(resfileCur->Get(Form("D0RPMeanP_B%d_phi%d",j,i))) {
526  fD0RPMeanPCur[j][i]=(TGraph*)(resfileCur->Get(Form("D0RPMeanP_B%d_phi%d",j,i))->Clone(Form("D0RPMeanPCur_B%d_phi%d",j,i)));
527  }
528  if(resfileCur->Get(Form("D0RPMeanK_B%d_phi%d",j,i))) {
529  fD0RPMeanKCur[j][i]=(TGraph*)(resfileCur->Get(Form("D0RPMeanK_B%d_phi%d",j,i))->Clone(Form("D0RPMeanKCur_B%d_phi%d",j,i)));
530  }
531  if(resfileCur->Get(Form("D0RPMeanPi_B%d_phi%d",j,i))) {
532  fD0RPMeanPiCur[j][i]=(TGraph*)(resfileCur->Get(Form("D0RPMeanPi_B%d_phi%d",j,i))->Clone(Form("D0RPMeanPiCur_B%d_phi%d",j,i)));
533  }
534  if(resfileCur->Get(Form("D0RPMeanE_B%d_phi%d",j,i))) {
535  fD0RPMeanECur[j][i]=(TGraph*)(resfileCur->Get(Form("D0RPMeanE_B%d_phi%d",j,i))->Clone(Form("D0RPMeanECur_B%d_phi%d",j,i)));
536  }
537  }
538  }
539  if(resfileCur->Get("D0ZResP" )) {
540  fD0ZResPCur =(TGraph*)(resfileCur->Get("D0ZResP" )->Clone("D0ZResPCur" ));
541  }
542  if(resfileCur->Get("D0ZResK" )) {
543  fD0ZResKCur =(TGraph*)(resfileCur->Get("D0ZResK" )->Clone("D0ZResKCur" ));
544  }
545  if(resfileCur->Get("D0ZResPi" )) {
546  fD0ZResPiCur =(TGraph*)(resfileCur->Get("D0ZResPi" )->Clone("D0ZResPiCur" ));
547  }
548  if(resfileCur->Get("D0ZResE" )) {
549  fD0ZResECur =(TGraph*)(resfileCur->Get("D0ZResE" )->Clone("D0ZResECur" ));
550  }
551  if(resfileCur->Get("Pt1ResP" )) {
552  fPt1ResPCur =(TGraph*)(resfileCur->Get("Pt1ResP" )->Clone("Pt1ResPCur" ));
553  }
554  if(resfileCur->Get("Pt1ResK" )) {
555  fPt1ResKCur =(TGraph*)(resfileCur->Get("Pt1ResK" )->Clone("Pt1ResKCur" ));
556  }
557  if(resfileCur->Get("Pt1ResPi" )) {
558  fPt1ResPiCur =(TGraph*)(resfileCur->Get("Pt1ResPi" )->Clone("Pt1ResPiCur" ));
559  }
560  if(resfileCur->Get("Pt1ResE" )) {
561  fPt1ResECur =(TGraph*)(resfileCur->Get("Pt1ResE" )->Clone("Pt1ResECur" ));
562  }
563  if(resfileCur->Get("D0RPResPSA" )) {
564  fD0RPResPCurSA =(TGraph*)(resfileCur->Get("D0RPResPSA" )->Clone("D0RPResPCurSA" ));
565  }
566  if(resfileCur->Get("D0RPResKSA" )) {
567  fD0RPResKCurSA =(TGraph*)(resfileCur->Get("D0RPResKSA" )->Clone("D0RPResKCurSA" ));
568  }
569  if(resfileCur->Get("D0RPResPiSA")) {
570  fD0RPResPiCurSA=(TGraph*)(resfileCur->Get("D0RPResPiSA")->Clone("D0RPResPiCurSA"));
571  }
572  if(resfileCur->Get("D0RPResESA")) {
573  fD0RPResECurSA=(TGraph*)(resfileCur->Get("D0RPResESA")->Clone("D0RPResECurSA"));
574  }
575  if(resfileCur->Get("D0ZResPSA" )) {
576  fD0ZResPCurSA =(TGraph*)(resfileCur->Get("D0ZResPSA" )->Clone("D0ZResPCurSA" ));
577  }
578  if(resfileCur->Get("D0ZResKSA" )) {
579  fD0ZResKCurSA =(TGraph*)(resfileCur->Get("D0ZResKSA" )->Clone("D0ZResKCurSA" ));
580  }
581  if(resfileCur->Get("D0ZResPiSA" )) {
582  fD0ZResPiCurSA =(TGraph*)(resfileCur->Get("D0ZResPiSA" )->Clone("D0ZResPiCurSA" ));
583  }
584  if(resfileCur->Get("D0ZResESA" )) {
585  fD0ZResECurSA =(TGraph*)(resfileCur->Get("D0ZResESA" )->Clone("D0ZResECurSA" ));
586  }
587  if(resfileCur->Get("Pt1ResPSA" )) {
588  fPt1ResPCurSA =(TGraph*)(resfileCur->Get("Pt1ResPSA" )->Clone("Pt1ResPCurSA" ));
589  }
590  if(resfileCur->Get("Pt1ResKSA" )) {
591  fPt1ResKCurSA =(TGraph*)(resfileCur->Get("Pt1ResKSA" )->Clone("Pt1ResKCurSA" ));
592  }
593  if(resfileCur->Get("Pt1ResPiSA" )) {
594  fPt1ResPiCurSA =(TGraph*)(resfileCur->Get("Pt1ResPiSA" )->Clone("Pt1ResPiCurSA" ));
595  }
596  if(resfileCur->Get("Pt1ResESA" )) {
597  fPt1ResECurSA =(TGraph*)(resfileCur->Get("Pt1ResESA" )->Clone("Pt1ResECurSA" ));
598  }
599  delete resfileCur;
600  }
601  else // analysing PbPb 2018 periods
602  {
603  if(resfileCur->Get("kFirst_D0RPResP") && resfileCur->Get("kOnlySecond_D0RPResP")){
604  fD0RPResPCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResP")->Clone("kFirst_D0RPResPCur"));
605  fD0RPResPCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResP")->Clone("kOnlySecond_D0RPResPCur"));
606  }
607  if(resfileCur->Get("kFirst_D0RPResK") && resfileCur->Get("kOnlySecond_D0RPResK")){
608  fD0RPResKCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResK")->Clone("kFirst_D0RPResKCur"));
609  fD0RPResKCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResK")->Clone("kOnlySecond_D0RPResKCur"));
610  }
611  if(resfileCur->Get("kFirst_D0RPResPi") && resfileCur->Get("kOnlySecond_D0RPResPi")){
612  fD0RPResPiCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResPi")->Clone("kFirst_D0RPResPiCur"));
613  fD0RPResPiCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResPi")->Clone("kOnlySecond_D0RPResPiCur"));
614  }
615  if(resfileCur->Get("kFirst_D0RPResE") && resfileCur->Get("kOnlySecond_D0RPResE")){
616  fD0RPResECur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResE")->Clone("kFirst_D0RPResECur"));
617  fD0RPResECur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResE")->Clone("kOnlySecond_D0RPResECur"));
618  }
619  if(resfileCur->Get("kFirst_D0RPSigmaPullRatioP") && resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioP")){
620  fD0RPSigmaPullRatioP_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPSigmaPullRatioP"));
621  fD0RPSigmaPullRatioP_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioP"));
622  }
623  if(resfileCur->Get("kFirst_D0RPSigmaPullRatioK") && resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioK")){
624  fD0RPSigmaPullRatioK_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPSigmaPullRatioK"));
625  fD0RPSigmaPullRatioK_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioK"));
626  }
627  if(resfileCur->Get("kFirst_D0RPSigmaPullRatioPi") && resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioPi")){
628  fD0RPSigmaPullRatioPi_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPSigmaPullRatioPi"));
629  fD0RPSigmaPullRatioPi_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioPi"));
630  }
631  if(resfileCur->Get("kFirst_D0RPSigmaPullRatioE") && resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioE")){
632  fD0RPSigmaPullRatioE_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPSigmaPullRatioE"));
633  fD0RPSigmaPullRatioE_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPSigmaPullRatioE"));
634  }
635  for(UInt_t j = 0; j < 2; j++)
636  {
637  for(Int_t i=0; i<24; i++){
638  if(resfileCur->Get(Form("kFirst_D0RPMeanP_B%d_phi%d",j,i)) && resfileCur->Get(Form("kOnlySecond_D0RPMeanP_B%d_phi%d",j,i))){
639  fD0RPMeanPCur_PbPb2018_kFirst[j][i]=(TGraph*)resfileCur->Get(Form("kFirst_D0RPMeanP_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanPCur_B%d_phi%d",j,i));
640  fD0RPMeanPCur_PbPb2018_kOnlySecond[j][i]=(TGraph*)resfileCur->Get(Form("kOnlySecond_D0RPMeanP_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanPCur_B%d_phi%d",j,i));
641  }
642  if(resfileCur->Get(Form("kFirst_D0RPMeanK_B%d_phi%d",j,i)) && resfileCur->Get(Form("kOnlySecond_D0RPMeanK_B%d_phi%d",j,i))){
643  fD0RPMeanKCur_PbPb2018_kFirst[j][i]=(TGraph*)resfileCur->Get(Form("kFirst_D0RPMeanK_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanKCur_B%d_phi%d",j,i));
644  fD0RPMeanKCur_PbPb2018_kOnlySecond[j][i]=(TGraph*)resfileCur->Get(Form("kOnlySecond_D0RPMeanK_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanKCur_B%d_phi%d",j,i));
645  }
646  if(resfileCur->Get(Form("kFirst_D0RPMeanPi_B%d_phi%d",j,i)) && resfileCur->Get(Form("kOnlySecond_D0RPMeanPi_B%d_phi%d",j,i))){
647  fD0RPMeanPiCur_PbPb2018_kFirst[j][i]=(TGraph*)resfileCur->Get(Form("kFirst_D0RPMeanPi_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanPiCur_B%d_phi%d",j,i));
648  fD0RPMeanPiCur_PbPb2018_kOnlySecond[j][i]=(TGraph*)resfileCur->Get(Form("kOnlySecond_D0RPMeanPi_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanPiCur_B%d_phi%d",j,i));
649  }
650  if(resfileCur->Get(Form("kFirst_D0RPMeanE_B%d_phi%d",j,i)) && resfileCur->Get(Form("kOnlySecond_D0RPMeanE_B%d_phi%d",j,i))){
651  fD0RPMeanECur_PbPb2018_kFirst[j][i]=(TGraph*)resfileCur->Get(Form("kFirst_D0RPMeanE_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanECur_B%d_phi%d",j,i));
652  fD0RPMeanECur_PbPb2018_kOnlySecond[j][i]=(TGraph*)resfileCur->Get(Form("kOnlySecond_D0RPMeanE_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanECur_B%d_phi%d",j,i));
653  }
654  }
655  }
656  if(resfileCur->Get("kFirst_D0ZResP") && resfileCur->Get("kOnlySecond_D0ZResP")){
657  fD0ZResPCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResP")->Clone("kFirst_D0ZResPCur"));
658  fD0ZResPCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResP")->Clone("kOnlySecond_D0ZResPCur"));
659  }
660  if(resfileCur->Get("kFirst_D0ZResK") && resfileCur->Get("kOnlySecond_D0ZResK")){
661  fD0ZResKCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResK")->Clone("kFirst_D0ZResKCur"));
662  fD0ZResKCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResK")->Clone("kOnlySecond_D0ZResKCur"));
663  }
664  if(resfileCur->Get("kFirst_D0ZResPi") && resfileCur->Get("kOnlySecond_D0ZResPi")){
665  fD0ZResPiCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResPi")->Clone("kFirst_D0ZResPiCur"));
666  fD0ZResPiCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResPi")->Clone("kOnlySecond_D0ZResPiCur"));
667  }
668  if(resfileCur->Get("kFirst_D0ZResE") && resfileCur->Get("kOnlySecond_D0ZResE")){
669  fD0ZResECur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResE")->Clone("kFirst_D0ZResECur"));
670  fD0ZResECur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResE")->Clone("kOnlySecond_D0ZResECur"));
671  }
672  if(resfileCur->Get("kFirst_Pt1ResP") && resfileCur->Get("kOnlySecond_Pt1ResP")){
673  fPt1ResPCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_Pt1ResP")->Clone("kFirst_Pt1ResPCur"));
674  fPt1ResPCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_Pt1ResP")->Clone("kOnlySecond_Pt1ResPCur"));
675  }
676  if(resfileCur->Get("kFirst_Pt1ResK") && resfileCur->Get("kOnlySecond_Pt1ResK")){
677  fPt1ResKCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_Pt1ResK")->Clone("kFirst_Pt1ResKCur"));
678  fPt1ResKCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_Pt1ResK")->Clone("kOnlySecond_Pt1ResKCur"));
679  }
680  if(resfileCur->Get("kFirst_Pt1ResPi") && resfileCur->Get("kOnlySecond_Pt1ResPi")){
681  fPt1ResPiCur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_Pt1ResPi")->Clone("kFirst_Pt1ResPiCur"));
682  fPt1ResPiCur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_Pt1ResPi")->Clone("kOnlySecond_Pt1ResPiCur"));
683  }
684  if(resfileCur->Get("kFirst_Pt1ResE") && resfileCur->Get("kOnlySecond_Pt1ResE")){
685  fPt1ResECur_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_Pt1ResE")->Clone("kFirst_Pt1ResECur"));
686  fPt1ResECur_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_Pt1ResE")->Clone("kOnlySecond_Pt1ResECur"));
687  }
688  if(resfileCur->Get("kFirst_D0RPResPSA") && resfileCur->Get("kOnlySecond_D0RPResPSA")){
689  fD0RPResPCurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResPSA")->Clone("kFirst_D0RPResPCurSA"));
690  fD0RPResPCurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResPSA")->Clone("kOnlySecond_D0RPResPCurSA"));
691  }
692  if(resfileCur->Get("kFirst_D0RPResKSA") && resfileCur->Get("kOnlySecond_D0RKResPSA")){
693  fD0RPResKCurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResKSA")->Clone("kFirst_D0RPResKCurSA"));
694  fD0RPResKCurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResKSA")->Clone("kOnlySecond_D0RPResKCurSA"));
695  }
696  if(resfileCur->Get("kFirst_D0RPResPiSA") && resfileCur->Get("kOnlySecond_D0RPResPiSA")){
697  fD0RPResPiCurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResPiSA")->Clone("kFirst_D0RPResPiCurSA"));
698  fD0RPResPiCurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResPiSA")->Clone("kOnlySecond_D0RPResPiCurSA"));
699  }
700  if(resfileCur->Get("kFirst_D0RPResESA") && resfileCur->Get("kOnlySecond_D0RPResESA")){
701  fD0RPResECurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0RPResESA")->Clone("kFirst_D0RPResECurSA"));
702  fD0RPResECurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0RPResESA")->Clone("kOnlySecond_D0RPResECurSA"));
703  }
704  if(resfileCur->Get("kFirst_D0ZResPSA") && resfileCur->Get("kOnlySecond_D0ZResPSA")){
705  fD0ZResPCurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResPSA")->Clone("kFirst_D0ZResPCurSA"));
706  fD0ZResPCurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResPSA")->Clone("kOnlySecond_D0ZResPCurSA"));
707  }
708  if(resfileCur->Get("kFirst_D0ZResKSA") && resfileCur->Get("kOnlySecond_D0ZResKSA")){
709  fD0ZResKCurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResKSA")->Clone("kFirst_D0ZResKCurSA"));
710  fD0ZResKCurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResKSA")->Clone("kOnlySecond_D0ZResKCurSA"));
711  }
712  if(resfileCur->Get("kFirst_D0ZResPiSA") && resfileCur->Get("kOnlySecond_D0ZResPiSA")){
713  fD0ZResPiCurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResPiSA")->Clone("kFirst_D0ZResPiCurSA"));
714  fD0ZResPiCurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResPiSA")->Clone("kOnlySecond_D0ZResPiCurSA"));
715  }
716  if(resfileCur->Get("kFirst_D0ZResESA") && resfileCur->Get("kOnlySecond_D0ZResESA")){
717  fD0ZResECurSA_PbPb2018_kFirst=(TGraph*)(resfileCur->Get("kFirst_D0ZResESA")->Clone("kFirst_D0ZResECurSA"));
718  fD0ZResECurSA_PbPb2018_kOnlySecond=(TGraph*)(resfileCur->Get("kOnlySecond_D0ZResESA")->Clone("kOnlySecond_D0ZResECurSA"));
719  }
720  if(resfileCur->Get("kFirst_Pt1ResPSA") && resfileCur->Get("kOnlySecond_Pt1ResPSA")){
721  fPt1ResPCurSA_PbPb2018_kFirst=(TGraph*) (resfileCur->Get("kFirst_Pt1ResPSA")->Clone("kFirst_Pt1ResPCurSA"));
722  fPt1ResPCurSA_PbPb2018_kOnlySecond=(TGraph*) (resfileCur->Get("kOnlySecond_Pt1ResPSA")->Clone("kOnlySecond_Pt1ResPCurSA"));
723  }
724  if(resfileCur->Get("kFirst_Pt1ResKSA") && resfileCur->Get("kOnlySecond_Pt1ResKSA")){
725  fPt1ResKCurSA_PbPb2018_kFirst=(TGraph*) (resfileCur->Get("kFirst_Pt1ResKSA")->Clone("kFirst_Pt1ResKCurSA"));
726  fPt1ResKCurSA_PbPb2018_kOnlySecond=(TGraph*) (resfileCur->Get("kOnlySecond_Pt1ResKSA")->Clone("kOnlySecond_Pt1ResKCurSA"));
727  }
728  if(resfileCur->Get("kFirst_Pt1ResPiSA") && resfileCur->Get("kOnlySecond_Pt1ResPiSA")){
729  fPt1ResPiCurSA_PbPb2018_kFirst=(TGraph*) (resfileCur->Get("kFirst_Pt1ResPiSA")->Clone("kFirst_Pt1ResPiCurSA"));
730  fPt1ResPiCurSA_PbPb2018_kOnlySecond=(TGraph*) (resfileCur->Get("kOnlySecond_Pt1ResPiSA")->Clone("kOnlySecond_Pt1ResPiCurSA"));
731  }
732  if(resfileCur->Get("kFirst_Pt1ResESA") && resfileCur->Get("kOnlySecond_Pt1ResESA")){
733  fPt1ResECurSA_PbPb2018_kFirst=(TGraph*) (resfileCur->Get("kFirst_Pt1ResESA")->Clone("kFirst_Pt1ResECurSA"));
734  fPt1ResECurSA_PbPb2018_kOnlySecond=(TGraph*) (resfileCur->Get("kOnlySecond_Pt1ResESA")->Clone("kOnlySecond_Pt1ResECurSA"));
735  }
736  delete resfileCur;
737  }
738  }
739 
740  //TString resfileUpgURI = Form("alien:///alice/cern.ch/user/p/pwg_hf/common/Improver/%s/%s/ITSgraphs_NewAll-X0.3-Res4um.root",period,systematic);
741  printf("\n### reading file %s ...\n",resfileUpgURI.Data());
742  TFile *resfileUpg=TFile::Open(resfileUpgURI.Data());
743  if(resfileUpg) printf("... READ ###\n");
744  if(resfileUpg) {
745  if(!fIsPbPb2018){
746  if(resfileUpg->Get("D0RPResP" )) {
747  fD0RPResPUpg =(TGraph*)(resfileUpg->Get("D0RPResP" )->Clone("D0RPResPUpg" ));
748  }
749  if(resfileUpg->Get("D0RPResK" )) {
750  fD0RPResKUpg =(TGraph*)(resfileUpg->Get("D0RPResK" )->Clone("D0RPResKUpg" ));
751  }
752  if(resfileUpg->Get("D0RPResPi")) {
753  fD0RPResPiUpg=(TGraph*)(resfileUpg->Get("D0RPResPi")->Clone("D0RPResPiUpg"));
754  }
755  if(resfileUpg->Get("D0RPResE")) {
756  fD0RPResEUpg=(TGraph*)(resfileUpg->Get("D0RPResE")->Clone("D0RPResEUpg"));
757  }
758  for(Int_t j=0; j<2; j++){
759  for(Int_t i=0; i<4; i++){
760  if(resfileUpg->Get(Form("D0RPMeanP_B%d_phi%d",j,i))) {
761  fD0RPMeanPUpg[j][i]=(TGraph*)(resfileUpg->Get(Form("D0RPMeanP_B%d_phi%d",j,i))->Clone(Form("D0RPMeanPUpg_B%d_phi%d",j,i)));
762  }
763  if(resfileUpg->Get(Form("D0RPMeanK_B%d_phi%d",j,i))) {
764  fD0RPMeanKUpg[j][i]=(TGraph*)(resfileUpg->Get(Form("D0RPMeanK_B%d_phi%d",j,i))->Clone(Form("D0RPMeanKUpg_B%d_phi%d",j,i)));
765  }
766  if(resfileUpg->Get(Form("D0RPMeanPi_B%d_phi%d",j,i))) {
767  fD0RPMeanPiUpg[j][i]=(TGraph*)(resfileUpg->Get(Form("D0RPMeanPi_B%d_phi%d",j,i))->Clone(Form("D0RPMeanPiUpg_B%d_phi%d",j,i)));
768  }
769  if(resfileUpg->Get(Form("D0RPMeanE_B%d_phi%d",j,i))) {
770  fD0RPMeanEUpg[j][i]=(TGraph*)(resfileUpg->Get(Form("D0RPMeanE_B%d_phi%d",j,i))->Clone(Form("D0RPMeanEUpg_B%d_phi%d",j,i)));
771  }
772  }
773  }
774  if(resfileUpg->Get("D0ZResP" )) {
775  fD0ZResPUpg =(TGraph*)(resfileUpg->Get("D0ZResP" )->Clone("D0ZResPUpg" ));
776  }
777  if(resfileUpg->Get("D0ZResK" )) {
778  fD0ZResKUpg =(TGraph*)(resfileUpg->Get("D0ZResK" )->Clone("D0ZResKUpg" ));
779  }
780  if(resfileUpg->Get("D0ZResPi" )) {
781  fD0ZResPiUpg =(TGraph*)(resfileUpg->Get("D0ZResPi" )->Clone("D0ZResPiUpg" ));
782  }
783  if(resfileUpg->Get("D0ZResE" )) {
784  fD0ZResEUpg =(TGraph*)(resfileUpg->Get("D0ZResE" )->Clone("D0ZResEUpg" ));
785  }
786  if(resfileUpg->Get("Pt1ResP" )) {
787  fPt1ResPUpg =(TGraph*)(resfileUpg->Get("Pt1ResP" )->Clone("Pt1ResPUpg" ));
788  }
789  if(resfileUpg->Get("Pt1ResK" )) {
790  fPt1ResKUpg =(TGraph*)(resfileUpg->Get("Pt1ResK" )->Clone("Pt1ResKUpg" ));
791  }
792  if(resfileUpg->Get("Pt1ResPi" )) {
793  fPt1ResPiUpg =(TGraph*)(resfileUpg->Get("Pt1ResPi" )->Clone("Pt1ResPiUpg" ));
794  }
795  if(resfileUpg->Get("Pt1ResE" )) {
796  fPt1ResEUpg =(TGraph*)(resfileUpg->Get("Pt1ResE" )->Clone("Pt1ResEUpg" ));
797  }
798  if(resfileUpg->Get("D0RPResPSA" )) {
799  fD0RPResPUpgSA =(TGraph*)(resfileUpg->Get("D0RPResPSA" )->Clone("D0RPResPUpgSA" ));
800  }
801  if(resfileUpg->Get("D0RPResKSA" )) {
802  fD0RPResKUpgSA =(TGraph*)(resfileUpg->Get("D0RPResKSA" )->Clone("D0RPResKUpgSA" ));
803  }
804  if(resfileUpg->Get("D0RPResPiSA")) {
805  fD0RPResPiUpgSA=(TGraph*)(resfileUpg->Get("D0RPResPiSA")->Clone("D0RPResPiUpgSA"));
806  }
807  if(resfileUpg->Get("D0RPResESA")) {
808  fD0RPResEUpgSA=(TGraph*)(resfileUpg->Get("D0RPResESA")->Clone("D0RPResEUpgSA"));
809  }
810  if(resfileUpg->Get("D0ZResPSA" )) {
811  fD0ZResPUpgSA =(TGraph*)(resfileUpg->Get("D0ZResPSA" )->Clone("D0ZResPUpgSA" ));
812  }
813  if(resfileUpg->Get("D0ZResKSA" )) {
814  fD0ZResKUpgSA =(TGraph*)(resfileUpg->Get("D0ZResKSA" )->Clone("D0ZResKUpgSA" ));
815  }
816  if(resfileUpg->Get("D0ZResPiSA" )) {
817  fD0ZResPiUpgSA =(TGraph*)(resfileUpg->Get("D0ZResPiSA" )->Clone("D0ZResPiUpgSA" ));
818  }
819  if(resfileUpg->Get("D0ZResESA" )) {
820  fD0ZResEUpgSA =(TGraph*)(resfileUpg->Get("D0ZResESA" )->Clone("D0ZResEUpgSA" ));
821  }
822  if(resfileUpg->Get("Pt1ResPSA" )) {
823  fPt1ResPUpgSA =(TGraph*)(resfileUpg->Get("Pt1ResPSA" )->Clone("Pt1ResPUpgSA" ));
824  }
825  if(resfileUpg->Get("Pt1ResKSA" )) {
826  fPt1ResKUpgSA =(TGraph*)(resfileUpg->Get("Pt1ResKSA" )->Clone("Pt1ResKUpgSA" ));
827  }
828  if(resfileUpg->Get("Pt1ResPiSA" )) {
829  fPt1ResPiUpgSA =(TGraph*)(resfileUpg->Get("Pt1ResPiSA" )->Clone("Pt1ResPiUpgSA" ));
830  }
831  if(resfileUpg->Get("Pt1ResESA" )) {
832  fPt1ResEUpgSA =(TGraph*)(resfileUpg->Get("Pt1ResESA" )->Clone("Pt1ResEUpgSA" ));
833  }
834  delete resfileUpg;
835  }
836  else // analysing PbPb 2018 periods
837  {
838  if(resfileUpg->Get("kFirst_D0RPResP") && resfileUpg->Get("kOnlySecond_D0RPResP")){
839  fD0RPResPUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0RPResP")->Clone("kFirst_D0RPResPUpg"));
840  fD0RPResPUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0RPResP")->Clone("kOnlySecond_D0RPResPUpg"));
841  }
842  if(resfileUpg->Get("kFirst_D0RPResK") && resfileUpg->Get("kOnlySecond_D0RPResK")){
843  fD0RPResKUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0RPResK")->Clone("kFirst_D0RPResKUpg"));
844  fD0RPResKUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0RPResK")->Clone("kOnlySecond_D0RPResKUpg"));
845  }
846  if(resfileUpg->Get("kFirst_D0RPResPi") && resfileUpg->Get("kOnlySecond_D0RPResPi")){
847  fD0RPResPiUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0RPResPi")->Clone("kFirst_D0RPResPiUpg"));
848  fD0RPResPiUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0RPResPi")->Clone("kOnlySecond_D0RPResPiUpg"));
849  }
850  if(resfileUpg->Get("kFirst_D0RPResE") && resfileUpg->Get("kOnlySecond_D0RPResE")){
851  fD0RPResEUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0RPResE")->Clone("kFirst_D0RPResEUpg"));
852  fD0RPResEUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0RPResE")->Clone("kOnlySecond_D0RPResEUpg"));
853  }
854  for(UInt_t j = 0; j < 2; j++){
855  for(UInt_t i = 0; i < 24; i++){
856  if(resfileUpg->Get(Form("kFirst_D0RPMeanP_B%d_phi%d",j,i)) && resfileUpg->Get(Form("kOnlySecond_D0RPMeanP_B%d_phi%d",j,i))){
857  fD0RPMeanPUpg_PbPb2018_kFirst[j][i]=(TGraph*)(resfileUpg->Get(Form("kFirst_D0RPMeanP_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanP_B%d_phi%d",j,i)));
858  fD0RPMeanPUpg_PbPb2018_kOnlySecond[j][i]=(TGraph*)(resfileUpg->Get(Form("kOnlySecond_D0RPMeanP_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanP_B%d_phi%d",j,i)));
859  }
860  if(resfileUpg->Get(Form("kFirst_D0RPMeanK_B%d_phi%d",j,i)) && resfileUpg->Get(Form("kOnlySecond_D0RPMeanK_B%d_phi%d",j,i))){
861  fD0RPMeanKUpg_PbPb2018_kFirst[j][i]=(TGraph*)(resfileUpg->Get(Form("kFirst_D0RPMeanK_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanK_B%d_phi%d",j,i)));
862  fD0RPMeanKUpg_PbPb2018_kOnlySecond[j][i]=(TGraph*)(resfileUpg->Get(Form("kOnlySecond_D0RPMeanK_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanK_B%d_phi%d",j,i)));
863  }
864  if(resfileUpg->Get(Form("kFirst_D0RPMeanPi_B%d_phi%d",j,i)) && resfileUpg->Get(Form("kOnlySecond_D0RPMeanPi_B%d_phi%d",j,i))){
865  fD0RPMeanPiUpg_PbPb2018_kFirst[j][i]=(TGraph*)(resfileUpg->Get(Form("kFirst_D0RPMeanPi_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanPi_B%d_phi%d",j,i)));
866  fD0RPMeanPiUpg_PbPb2018_kOnlySecond[j][i]=(TGraph*)(resfileUpg->Get(Form("kOnlySecond_D0RPMeanPi_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanPi_B%d_phi%d",j,i)));
867  }
868  if(resfileUpg->Get(Form("kFirst_D0RPMeanE_B%d_phi%d",j,i)) && resfileUpg->Get(Form("kOnlySecond_D0RPMeanE_B%d_phi%d",j,i))){
869  fD0RPMeanEUpg_PbPb2018_kFirst[j][i]=(TGraph*)(resfileUpg->Get(Form("kFirst_D0RPMeanE_B%d_phi%d",j,i))->Clone(Form("kFirst_D0RPMeanE_B%d_phi%d",j,i)));
870  fD0RPMeanEUpg_PbPb2018_kOnlySecond[j][i]=(TGraph*)(resfileUpg->Get(Form("kOnlySecond_D0RPMeanE_B%d_phi%d",j,i))->Clone(Form("kOnlySecond_D0RPMeanE_B%d_phi%d",j,i)));
871  }
872  }
873  }
874  if(resfileUpg->Get("kFirst_D0ZResP") && resfileUpg->Get("kOnlySecond_D0ZResP")){
875  fD0ZResPUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0ZResP")->Clone("kFirst_D0ZResPUpg"));
876  fD0ZResPUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0ZResP")->Clone("kOnlySecond_D0ZResPUpg"));
877  }
878  if(resfileUpg->Get("kFirst_D0ZResK") && resfileUpg->Get("kOnlySecond_D0ZResK")){
879  fD0ZResKUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0ZResK")->Clone("kFirst_D0ZResKUpg"));
880  fD0ZResKUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0ZResK")->Clone("kOnlySecond_D0ZResKUpg"));
881  }
882  if(resfileUpg->Get("kFirst_D0ZResPi") && resfileUpg->Get("kOnlySecond_D0ZResPi")){
883  fD0ZResPiUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0ZResPi")->Clone("kFirst_D0ZResPiUpg"));
884  fD0ZResPiUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0ZResPi")->Clone("kOnlySecond_D0ZResPiUpg"));
885  }
886  if(resfileUpg->Get("kFirst_D0ZResE") && resfileUpg->Get("kOnlySecond_D0ZResE")){
887  fD0ZResEUpg_PbPb2018_kFirst=(TGraph*)(resfileUpg->Get("kFirst_D0ZResE")->Clone("kFirst_D0ZResEUpg"));
888  fD0ZResEUpg_PbPb2018_kOnlySecond=(TGraph*)(resfileUpg->Get("kOnlySecond_D0ZResE")->Clone("kOnlySecond_D0ZResEUpg"));
889  }
890  if(resfileUpg->Get("kFirst_Pt1ResP") && resfileUpg->Get("kOnlySecond_Pt1ResP")){
891  fPt1ResPUpg_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResP")->Clone("kFirst_Pt1ResPUpg"));
892  fPt1ResPUpg_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResP")->Clone("kOnlySecond_Pt1ResPUpg"));
893  }
894  if(resfileUpg->Get("kFirst_Pt1ResK") && resfileUpg->Get("kOnlySecond_Pt1ResK")){
895  fPt1ResKUpg_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResK")->Clone("kFirst_Pt1ResKUpg"));
896  fPt1ResKUpg_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResK")->Clone("kOnlySecond_Pt1ResKUpg"));
897  }
898  if(resfileUpg->Get("kFirst_Pt1ResPi") && resfileUpg->Get("kOnlySecond_Pt1ResPi")){
899  fPt1ResPiUpg_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResPi")->Clone("kFirst_Pt1ResPiUpg"));
900  fPt1ResPiUpg_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResPi")->Clone("kOnlySecond_Pt1ResPiUpg"));
901  }
902  if(resfileUpg->Get("kFirst_Pt1ResE") && resfileUpg->Get("kOnlySecond_Pt1ResE")){
903  fPt1ResEUpg_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResE")->Clone("kFirst_Pt1ResEUpg"));
904  fPt1ResEUpg_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResE")->Clone("kOnlySecond_Pt1ResEUpg"));
905  }
906  if(resfileUpg->Get("kFirst_D0RPResPSA") && resfileUpg->Get("kOnlySecond_D0RPResPSA")){
907  fD0RPResPUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0RPResPSA")->Clone("kFirst_D0RPResPUpgSA"));
908  fD0RPResPUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0RPResPSA")->Clone("kOnlySecond_D0RPResPUpgSA"));
909  }
910  if(resfileUpg->Get("kFirst_D0RPResKSA") && resfileUpg->Get("kOnlySecond_D0RPResKSA")){
911  fD0RPResKUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0RPResKSA")->Clone("kFirst_D0RPResKUpgSA"));
912  fD0RPResKUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0RPResKSA")->Clone("kOnlySecond_D0RPResKUpgSA"));
913  }
914  if(resfileUpg->Get("kFirst_D0RPResPiSA") && resfileUpg->Get("kOnlySecond_D0RPResPiSA")){
915  fD0RPResPiUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0RPResPiSA")->Clone("kFirst_D0RPResPiUpgSA"));
916  fD0RPResPiUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0RPResPiSA")->Clone("kOnlySecond_D0RPResPiUpgSA"));
917  }
918  if(resfileUpg->Get("kFirst_D0RPResESA") && resfileUpg->Get("kOnlySecond_D0RPResESA")){
919  fD0RPResEUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0RPResESA")->Clone("kFirst_D0RPResEUpgSA"));
920  fD0RPResEUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0RPResESA")->Clone("kOnlySecond_D0RPResEUpgSA"));
921  }
922  if(resfileUpg->Get("kFirst_D0ZResPSA") && resfileUpg->Get("kOnlyFirst_D0ZResPSA")){
923  fD0ZResPUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0ZResPSA")->Clone("kFirst_D0ZResPUpgSA"));
924  fD0ZResPUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0ZResPSA")->Clone("kOnlySecond_D0ZResPUpgSA"));
925  }
926  if(resfileUpg->Get("kFirst_D0ZResKSA") && resfileUpg->Get("kOnlyFirst_D0ZResKSA")){
927  fD0ZResKUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0ZResKSA")->Clone("kFirst_D0ZResKUpgSA"));
928  fD0ZResKUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0ZResKSA")->Clone("kOnlySecond_D0ZResKUpgSA"));
929  }
930  if(resfileUpg->Get("kFirst_D0ZResPiSA") && resfileUpg->Get("kOnlyFirst_D0ZResPiSA")){
931  fD0ZResPiUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0ZResPiSA")->Clone("kFirst_D0ZResPiUpgSA"));
932  fD0ZResPiUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0ZResPiSA")->Clone("kOnlySecond_D0ZResPiUpgSA"));
933  }
934  if(resfileUpg->Get("kFirst_D0ZResESA") && resfileUpg->Get("kOnlyFirst_D0ZResESA")){
935  fD0ZResEUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_D0ZResESA")->Clone("kFirst_D0ZResEUpgSA"));
936  fD0ZResEUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_D0ZResESA")->Clone("kOnlySecond_D0ZResEUpgSA"));
937  }
938  if(resfileUpg->Get("kFirst_Pt1ResPSA") && resfileUpg->Get("kOnlySecond_Pt1ResPSA")){
939  fPt1ResPUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResPSA")->Clone("kFirst_Pt1ResPUpgSA"));
940  fPt1ResPUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResPSA")->Clone("kOnlySecond_Pt1ResPUpgSA"));
941  }
942  if(resfileUpg->Get("kFirst_Pt1ResKSA") && resfileUpg->Get("kOnlySecond_Pt1ResKSA")){
943  fPt1ResKUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResKSA")->Clone("kFirst_Pt1ResKUpgSA"));
944  fPt1ResKUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResKSA")->Clone("kOnlySecond_Pt1ResKUpgSA"));
945  }
946  if(resfileUpg->Get("kFirst_Pt1ResPiSA") && resfileUpg->Get("kOnlySecond_Pt1ResPiSA")){
947  fPt1ResPiUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResPiSA")->Clone("kFirst_Pt1ResPiUpgSA"));
948  fPt1ResPiUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResPiSA")->Clone("kOnlySecond_Pt1ResPiUpgSA"));
949  }
950  if(resfileUpg->Get("kFirst_Pt1ResESA") && resfileUpg->Get("kOnlySecond_Pt1ResESA")){
951  fPt1ResEUpgSA_PbPb2018_kFirst=(TGraph*) (resfileUpg->Get("kFirst_Pt1ResESA")->Clone("kFirst_Pt1ResEUpgSA"));
952  fPt1ResEUpgSA_PbPb2018_kOnlySecond=(TGraph*) (resfileUpg->Get("kOnlySecond_Pt1ResESA")->Clone("kOnlySecond_Pt1ResEUpgSA"));
953  }
954  delete resfileUpg;
955  }
956 
957  }
958 
959  DefineOutput(1,TList::Class());
960 }
961 
963  //
964  // Destructor.
965  //
966  if (fDebugOutput) delete fDebugOutput;
967 }
968 
970  //
971  // Creation of user output objects.
972  //
973  fDebugOutput=new TList();
974  fDebugOutput->SetOwner();
975  fDebugOutput->SetName("debug");
976  fDebugNtuple=new TNtuple("fDebugNtuple","Smearing","pdg:ptmc:d0rpo:d0zo:pt1o:sd0rpo:sd0zo:spt1o:d0rpn:d0zn:pt1n:sd0rpn:sd0zn:spt1n:d0rpmc:d0zmc:pt1mc:pullcorr:d0zoinsigma:d0zninsigma:d0rpoinsigma:d0rpninsigma");
977  fDebugVars=new Float_t[fDebugNtuple->GetNvar()];
978 
979  fDebugOutput->Add(fDebugNtuple );
980 
989  for(Int_t j=0; j<2; j++){
990  for(Int_t i=0; i<4; i++){
991  if(fD0RPMeanPCur[j][i]) fDebugOutput->Add(fD0RPMeanPCur[j][i]);
992  if(fD0RPMeanKCur[j][i]) fDebugOutput->Add(fD0RPMeanKCur[j][i]);
993  if(fD0RPMeanPiCur[j][i]) fDebugOutput->Add(fD0RPMeanPiCur[j][i]);
994  if(fD0RPMeanECur[j][i]) fDebugOutput->Add(fD0RPMeanECur[j][i]);
995  if(fD0RPMeanPUpg[j][i]) fDebugOutput->Add(fD0RPMeanPUpg[j][i]);
996  if(fD0RPMeanKUpg[j][i]) fDebugOutput->Add(fD0RPMeanKUpg[j][i]);
997  if(fD0RPMeanPiUpg[j][i]) fDebugOutput->Add(fD0RPMeanPiUpg[j][i]);
998  if(fD0RPMeanEUpg[j][i]) fDebugOutput->Add(fD0RPMeanEUpg[j][i]);
999  }
1000  }
1001  if(fD0ZResPCur) fDebugOutput->Add(fD0ZResPCur );
1021 
1022  // stuff for PbPb 2018 periods
1023  // Cur
1040  for(UInt_t j = 0; j < 2; j++){
1041  for(Int_t i=0; i<24; i++){
1050  }
1051  }
1092  // New
1101  for(UInt_t j = 0; j < 2; j++){
1102  for(Int_t i=0; i<24; i++){
1111  }
1112  }
1153 
1154 
1155  PostData(1,fDebugOutput);
1156 }
1157 
1159  //
1160  // The event loop
1161  //
1162  AliAODEvent *ev=0x0;
1163  AliESDEvent *evesd=0x0;
1164  Double_t bz=0.;
1165 
1166  if(fIsAOD) {
1167  if(!fRunInVertexing) {
1168  ev=dynamic_cast<AliAODEvent*>(InputEvent());
1169  } else {
1170  if(AODEvent() && IsStandardAOD()) ev = dynamic_cast<AliAODEvent*> (AODEvent());
1171  }
1172  if(!ev) return;
1173  bz=ev->GetMagneticField();
1174  }
1175  else {
1176  evesd = dynamic_cast<AliESDEvent*>(InputEvent());
1177  if (!evesd) {
1178  AliError("event not found. Nothing done!");
1179  return;
1180  }
1181  bz=evesd->GetMagneticField();
1182  }
1183 
1184  if(fIsAOD) {
1185 
1186  fMCs=static_cast<TClonesArray*>(ev->GetList()->FindObject(AliAODMCParticle::StdBranchName()));
1187  AliAODMCHeader *mcHeader = (AliAODMCHeader*)ev->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1188  if (!fMCs || !mcHeader) return;
1189 
1190  // first loop on candidates to fill them in case of reduced AODs
1191  // this is done to have the same behaviour of the improver with full (pp, p-Pb) and recuced (Pb-Pb) candidates
1193 
1194  // D0->Kpi
1195  TClonesArray *array2Prong=static_cast<TClonesArray*>(ev->GetList()->FindObject("D0toKpi"));
1196  if (array2Prong) {
1197  for (Int_t icand=0;icand<array2Prong->GetEntriesFast();++icand) {
1198  AliAODRecoDecayHF2Prong *decay=static_cast<AliAODRecoDecayHF2Prong*>(array2Prong->At(icand));
1199  vHF->GetProng(ev,decay,0); // needed to fill fAODMap in AliAnalysisVertexingHF
1200  if(fSmearOnlySignal && AliVertexingHFUtils::IsCandidateInjected(decay,ev,mcHeader,fMCs)==kFALSE) continue;
1201  vHF->FillRecoCand(ev,(AliAODRecoDecayHF2Prong*)decay);
1202  }
1203  }
1204  // Dstar->Kpipi
1205  TClonesArray *arrayCascade=static_cast<TClonesArray*>(ev->GetList()->FindObject("Dstar"));
1206  if (arrayCascade) {
1207  for (Int_t icand=0;icand<arrayCascade->GetEntriesFast();++icand) {
1208  AliAODRecoCascadeHF *decayDstar=static_cast<AliAODRecoCascadeHF*>(arrayCascade->At(icand));
1209  vHF->GetProng(ev,decayDstar,0); // needed to fill fAODMap in AliAnalysisVertexingHF
1210  if(fSmearOnlySignal && AliVertexingHFUtils::IsCandidateInjected(decayDstar,ev,mcHeader,fMCs)==kFALSE) continue;
1211  vHF->FillRecoCasc(ev,((AliAODRecoCascadeHF*)decayDstar),kTRUE);
1212  }
1213  }
1214  // Three prong
1215  TClonesArray *array3Prong=static_cast<TClonesArray*>(ev->GetList()->FindObject("Charm3Prong"));
1216  if (array3Prong) {
1217  for (Int_t icand=0;icand<array3Prong->GetEntriesFast();++icand) {
1218  AliAODRecoDecayHF3Prong *decay=static_cast<AliAODRecoDecayHF3Prong*>(array3Prong->At(icand));
1219  vHF->GetProng(ev,decay,0); // needed to fill fAODMap in AliAnalysisVertexingHF
1220  if(fSmearOnlySignal && AliVertexingHFUtils::IsCandidateInjected(decay,ev,mcHeader,fMCs)==kFALSE) continue;
1221  vHF->FillRecoCand(ev,(AliAODRecoDecayHF3Prong*)decay);
1222  }
1223  }
1224 
1225 
1226  // Smear all tracks
1227  if (fImproveTracks) {
1228  for(Int_t itrack=0;itrack<ev->GetNumberOfTracks();++itrack) {
1229  AliAODTrack * trk = static_cast<AliAODTrack*>(ev->GetTrack(itrack));
1230  if(!trk) AliFatal("Not a standard AOD");
1231  if(fSmearOnlySignal && AliVertexingHFUtils::IsTrackInjected(trk,mcHeader,fMCs)==kFALSE) continue;
1232  SmearTrack(trk,bz);
1233  }
1234  }
1235 
1236  // TODO: recalculated primary vertex
1237  AliVVertex *primaryVertex=ev->GetPrimaryVertex();
1238 
1239  // Recalculate all candidates
1240  // D0->Kpi
1241  if (array2Prong) {
1242  for (Int_t icand=0;icand<array2Prong->GetEntriesFast();++icand) {
1243  AliAODRecoDecayHF2Prong *decay=static_cast<AliAODRecoDecayHF2Prong*>(array2Prong->At(icand));
1244 
1245  if(fSmearOnlySignal && AliVertexingHFUtils::IsCandidateInjected(decay,ev,mcHeader,fMCs)==kFALSE) continue;
1246  if(!vHF->FillRecoCand(ev,(AliAODRecoDecayHF2Prong*)decay))continue;
1247 
1248  // recalculate vertices
1249  AliVVertex *oldSecondaryVertex=decay->GetSecondaryVtx();
1250 
1251  AliExternalTrackParam et1; et1.CopyFromVTrack(static_cast<AliAODTrack*>(decay->GetDaughter(0)));
1252  AliExternalTrackParam et2; et2.CopyFromVTrack(static_cast<AliAODTrack*>(decay->GetDaughter(1)));
1253 
1254  TObjArray ta12;
1255 
1256  ta12.Add(&et1); ta12.Add(&et2);
1257  AliESDVertex *v12 =RecalculateVertex(oldSecondaryVertex,&ta12 ,bz);
1258 
1259 
1260  // update secondary vertex
1261  Double_t pos[3];
1262  Double_t covpos[6];
1263  v12->GetXYZ(pos);
1264  v12->GetCovMatrix(covpos);
1265  decay->GetSecondaryVtx()->SetPosition(pos[0],pos[1],pos[2]);
1266  if(fUpdateSecVertCovMat) decay->GetSecondaryVtx()->SetCovMatrix(covpos);
1267  decay->GetSecondaryVtx()->SetChi2perNDF(v12->GetChi2toNDF());
1268 
1269  // update d0
1270  Double_t d0z0[2],covd0z0[3];
1271  Double_t d0[2],d0err[2];
1272  et1.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1273  d0[0]=d0z0[0];
1274  d0err[0] = TMath::Sqrt(covd0z0[0]);
1275  et2.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1276  d0[1]=d0z0[0];
1277  d0err[1] = TMath::Sqrt(covd0z0[0]);
1278  decay->Setd0Prongs(2,d0);
1279  decay->Setd0errProngs(2,d0err);
1280  //
1281 
1282 
1283  Double_t xdummy=0.,ydummy=0.;
1284  Double_t dca;
1285  dca=et1.GetDCA(&et2,bz,xdummy,ydummy);
1286  decay->SetDCA(dca);
1287 
1288 
1289 
1290  Double_t px[2],py[2],pz[2];
1291  for (Int_t i=0;i<2;++i) {
1292  AliExternalTrackParam et;
1293  et.CopyFromVTrack(static_cast<AliAODTrack*>(decay->GetDaughter(i)));
1294  et.PropagateToDCA(v12,bz,100.,d0z0,covd0z0);
1295  px[i]=et.Px();
1296  py[i]=et.Py();
1297  pz[i]=et.Pz();
1298  }
1299  decay->SetPxPyPzProngs(2,px,py,pz);
1300  delete v12;
1301  }
1302  }
1303 
1304 
1305  // Dstar->Kpipi
1306  if (arrayCascade) {
1307  for (Int_t icand=0;icand<arrayCascade->GetEntriesFast();++icand) {
1308  AliAODRecoCascadeHF *decayDstar=static_cast<AliAODRecoCascadeHF*>(arrayCascade->At(icand));
1309  if(fSmearOnlySignal && AliVertexingHFUtils::IsCandidateInjected(decayDstar,ev,mcHeader,fMCs)==kFALSE) continue;
1310  if(!vHF->FillRecoCasc(ev,((AliAODRecoCascadeHF*)decayDstar),kTRUE))continue;
1311  //Get D0 from D*
1313 
1314  // recalculate vertices
1315  //AliVVertex *oldSecondaryVertex=decay->GetSecondaryVtx();
1316 
1317  //soft pion
1318  AliExternalTrackParam et3; et3.CopyFromVTrack(static_cast<AliAODTrack*>(decayDstar->GetBachelor()));
1319 
1320  //track D0
1321  AliNeutralTrackParam *trackD0 = new AliNeutralTrackParam(decay);
1322 
1324 
1325  // update d0
1326  Double_t d0z0[2],covd0z0[3];
1327  Double_t d01[2],d01err[2];
1328 
1329  //the D*
1330  et3.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1331  d01[0]=d0z0[0];
1332  d01err[0] = TMath::Sqrt(covd0z0[0]);
1333  trackD0->PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1334  d01[1]=d0z0[0];
1335  d01err[1] = TMath::Sqrt(covd0z0[0]);
1336  decayDstar->Setd0Prongs(2,d01);
1337  decayDstar->Setd0errProngs(2,d01err);
1338 
1339  // delete v12;
1340  delete trackD0; trackD0=NULL;
1341 
1342  // a run for D*
1343  Double_t px1[2],py1[2],pz1[2];
1344  for (Int_t i=0;i<2;++i) {
1345  const AliAODTrack *t1=static_cast<AliAODTrack*>(decayDstar->GetDaughter(i));
1346  px1[i]=t1->Px();
1347  py1[i]=t1->Py();
1348  pz1[i]=t1->Pz();
1349  }
1350  decayDstar->SetPxPyPzProngs(2,px1,py1,pz1);
1351 
1352  }
1353  }
1354 
1355 
1356  // Three prong
1357  if (array3Prong) {
1358  for (Int_t icand=0;icand<array3Prong->GetEntriesFast();++icand) {
1359  AliAODRecoDecayHF3Prong *decay=static_cast<AliAODRecoDecayHF3Prong*>(array3Prong->At(icand));
1360  if(fSmearOnlySignal && AliVertexingHFUtils::IsCandidateInjected(decay,ev,mcHeader,fMCs)==kFALSE) continue;
1361  if(!vHF->FillRecoCand(ev,(AliAODRecoDecayHF3Prong*)decay))continue;
1362 
1363  // recalculate vertices
1364  AliVVertex *oldSecondaryVertex=decay->GetSecondaryVtx();
1365  AliExternalTrackParam et1; et1.CopyFromVTrack(static_cast<AliAODTrack*>(decay->GetDaughter(0)));
1366  AliExternalTrackParam et2; et2.CopyFromVTrack(static_cast<AliAODTrack*>(decay->GetDaughter(1)));
1367  AliExternalTrackParam et3; et3.CopyFromVTrack(static_cast<AliAODTrack*>(decay->GetDaughter(2)));
1368  TObjArray ta123,ta12,ta23;
1369  ta123.Add(&et1);ta123.Add(&et2);ta123.Add(&et3);
1370  ta12. Add(&et1);ta12 .Add(&et2);
1371  ta23 .Add(&et2);ta23 .Add(&et3);
1372  AliESDVertex *v123=RecalculateVertex(oldSecondaryVertex,&ta123,bz);
1373  AliESDVertex *v12 =RecalculateVertex(oldSecondaryVertex,&ta12 ,bz);
1374  AliESDVertex *v23 =RecalculateVertex(oldSecondaryVertex,&ta23 ,bz);
1375 
1376  // update secondary vertex
1377  Double_t pos[3];
1378  Double_t covpos[6];
1379  v123->GetXYZ(pos);
1380  v123->GetCovMatrix(covpos);
1381  decay->GetSecondaryVtx()->SetPosition(pos[0],pos[1],pos[2]);
1382  if(fUpdateSecVertCovMat) decay->GetSecondaryVtx()->SetCovMatrix(covpos);
1383  decay->GetSecondaryVtx()->SetChi2perNDF(v123->GetChi2toNDF());
1384 
1385  // update d0 for all progs
1386  Double_t d0z0[2],covd0z0[3];
1387  Double_t d0[3],d0err[3];
1388  et1.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1389  d0[0]=d0z0[0];
1390  d0err[0] = TMath::Sqrt(covd0z0[0]);
1391  et2.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1392  d0[1]=d0z0[0];
1393  d0err[1] = TMath::Sqrt(covd0z0[0]);
1394  et3.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1395  d0[2]=d0z0[0];
1396  d0err[2] = TMath::Sqrt(covd0z0[0]);
1397  decay->Setd0Prongs (3,d0 );
1398  decay->Setd0errProngs(3,d0err);
1399  // TODO: setter missing
1400 
1401  // update dca for prong combinations
1402  Double_t xdummy=0.,ydummy=0.;
1403  Double_t dca[3];
1404  dca[0]=et1.GetDCA(&et2,bz,xdummy,ydummy);
1405  dca[1]=et3.GetDCA(&et2,bz,xdummy,ydummy);
1406  dca[2]=et1.GetDCA(&et3,bz,xdummy,ydummy);
1407  decay->SetDCAs(3,dca);
1408 
1409  // update sigmavertex = dispersion
1410  Float_t sigmaV=v123->GetDispersion();
1411  decay->SetSigmaVert(sigmaV);
1412  // update dist12 and dist23
1413  primaryVertex->GetXYZ(pos);
1414  decay->SetDist12toPrim(TMath::Sqrt((v12->GetX()-pos[0])*(v12->GetX()-pos[0])
1415  +(v12->GetY()-pos[1])*(v12->GetY()-pos[1])
1416  +(v12->GetZ()-pos[2])*(v12->GetZ()-pos[2])));
1417  decay->SetDist23toPrim(TMath::Sqrt((v23->GetX()-pos[0])*(v23->GetX()-pos[0])
1418  +(v23->GetY()-pos[1])*(v23->GetY()-pos[1])
1419  +(v23->GetZ()-pos[2])*(v23->GetZ()-pos[2])));
1420 
1421 
1422  Double_t px[3],py[3],pz[3];
1423  for (Int_t i=0;i<3;++i) {
1424  AliExternalTrackParam et;
1425  et.CopyFromVTrack(static_cast<AliAODTrack*>(decay->GetDaughter(i)));
1426  et.PropagateToDCA(v123,bz,100.,d0z0,covd0z0);
1427  px[i]=et.Px();
1428  py[i]=et.Py();
1429  pz[i]=et.Pz();
1430  }
1431  decay->SetPxPyPzProngs(3,px,py,pz);
1432 
1433  delete v123;delete v12;delete v23;
1434  }
1435  }
1436  delete vHF;
1437 
1438  } // end AOD
1439  else {
1440  //
1441  // In case of ESD: only smear all tracks
1442  //
1443  if (!fMCEvent) return;
1444  if (fImproveTracks) {
1445  for(Int_t itrack=0;itrack<evesd->GetNumberOfTracks();++itrack) {
1446  AliESDtrack * trk = static_cast<AliESDtrack*>(evesd->GetTrack(itrack));
1447  if(!trk) AliFatal("No a standard ESD");
1448  SmearTrack(trk,bz);
1449  }
1450  }
1451  }// end ESD
1452 
1453 }
1454 
1456 
1457  // flags for PbPb 2018
1458  Bool_t is_kFirst_Trk = kFALSE;
1459  Bool_t is_kOnlySecond_Trk = kFALSE;
1460 
1461  // Early exit, if this track has nothing in common with the ITS
1462  if(!fIsPbPb2018){
1463  if (!(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1))) return;
1464  }
1465  else{ // PbPb 2018 analysed
1466  // kFirst tracks
1467  if(track->HasPointOnITSLayer(0)) is_kFirst_Trk = kTRUE;
1468  // kOnlySecond tracks
1469  else if( !(track->HasPointOnITSLayer(0)) && track->HasPointOnITSLayer(1) ) is_kOnlySecond_Trk = kTRUE;
1470  if( !is_kFirst_Trk && !is_kOnlySecond_Trk ) return;
1471  }
1472 
1473 
1474  // Check if the track was already "improved" (this is done with a trick using layer 7 (ie the 8th))
1475  if (TESTBIT(track->GetITSClusterMap(),7)) return;
1476  //
1477 
1478  // Get reconstructed track parameters
1479  AliExternalTrackParam et; et.CopyFromVTrack(track);
1480  Double_t *param=const_cast<Double_t*>(et.GetParameter());
1481 
1482 
1483  Double_t *covar=const_cast<Double_t*>(et.GetCovariance());
1484 
1485  // Get MC info
1486  Int_t imc=track->GetLabel();
1487  if (imc<=0) return;
1488  Double_t mcx[3];
1489  Double_t mcp[3];
1490  Double_t mccv[36]={0.};
1491  Short_t mcc;
1492  const AliVParticle *mc= 0x0;
1493  if(fIsAOD) {
1494  mc = static_cast<AliVParticle*>(fMCs->At(imc));
1495  }
1496  else {
1497  mc = static_cast<AliVParticle*>(fMCEvent->GetTrack(imc));
1498  }
1499  if(!mc) return;
1500  mc->XvYvZv(mcx);
1501  mc->PxPyPz(mcp);
1502  mcc=mc->Charge();
1503  AliExternalTrackParam mct(mcx,mcp,mccv,mcc);
1504  const Double_t *parammc=mct.GetParameter();
1505 //TODO: const Double_t *covermc=mct.GetCovariance();
1506  AliVertex vtx(mcx,1.,1);
1507 
1508  // Correct reference points and frames according to MC
1509  // TODO: B-Field correct?
1510  // TODO: failing propagation....
1511  et.PropagateToDCA(&vtx,bz,10.);
1512  et.Rotate(mct.GetAlpha());
1513 
1514  // Select appropriate smearing functions
1515  Double_t ptmc=TMath::Abs(mc->Pt());
1516  Double_t phimc=mc->Phi();
1517  Int_t phiBin=PhiBin(phimc);
1518  Int_t magfield=0;
1519  if(bz<0.) magfield=0;
1520  else if(bz>0.)magfield=1;
1521  Double_t sd0rpn=0.;
1522  Double_t sd0mrpn=0.;
1523  Double_t sd0zn =0.;
1524  Double_t spt1n =0.;
1525  Double_t sd0rpo=0.;
1526  Double_t sd0mrpo=0.;
1527  Double_t sd0zo =0.;
1528  Double_t spt1o =0.;
1529  Double_t pullcorr=1.;
1530  Int_t pdgcode = 0;
1531  if(fIsAOD){
1532  const AliAODMCParticle *amcpart = static_cast<const AliAODMCParticle *>(mc);
1533  if(!amcpart) return;
1534  pdgcode = amcpart->GetPdgCode();
1535  } else {
1536  const AliMCParticle *emcpart = static_cast<const AliMCParticle *>(mc);
1537  if(!emcpart) return;
1538  pdgcode = emcpart->PdgCode();
1539  }
1540 
1541  if(!fIsPbPb2018){
1542  switch (pdgcode) {
1543  case 2212: case -2212:
1544  sd0rpo=EvalGraph(ptmc,fD0RPResPCur,fD0RPResPCurSA);
1545  sd0zo =EvalGraph(ptmc,fD0ZResPCur,fD0ZResPCurSA);
1546  spt1o =EvalGraph(ptmc,fPt1ResPCur,fPt1ResPCurSA);
1547  sd0rpn=EvalGraph(ptmc,fD0RPResPUpg,fD0RPResPUpgSA);
1548  sd0zn =EvalGraph(ptmc,fD0ZResPUpg,fD0ZResPUpgSA);
1549  spt1n =EvalGraph(ptmc,fPt1ResPUpg,fPt1ResPUpgSA);
1550  sd0mrpo=EvalGraph(ptmc,fD0RPMeanPCur[magfield][phiBin],fD0RPMeanPCur[magfield][phiBin]);
1551  sd0mrpn=EvalGraph(ptmc,fD0RPMeanPUpg[magfield][phiBin],fD0RPMeanPUpg[magfield][phiBin]);
1553  break;
1554  case 321: case -321:
1555  sd0rpo=EvalGraph(ptmc,fD0RPResKCur,fD0RPResKCurSA);
1556  sd0zo =EvalGraph(ptmc,fD0ZResKCur,fD0ZResKCurSA);
1557  spt1o =EvalGraph(ptmc,fPt1ResKCur,fPt1ResKCurSA);
1558  sd0rpn=EvalGraph(ptmc,fD0RPResKUpg,fD0RPResKUpgSA);
1559  sd0zn =EvalGraph(ptmc,fD0ZResKUpg,fD0ZResKUpgSA);
1560  spt1n =EvalGraph(ptmc,fPt1ResKUpg,fPt1ResKUpgSA);
1561  sd0mrpo=EvalGraph(ptmc,fD0RPMeanKCur[magfield][phiBin],fD0RPMeanKCur[magfield][phiBin]);
1562  sd0mrpn=EvalGraph(ptmc,fD0RPMeanKUpg[magfield][phiBin],fD0RPMeanKUpg[magfield][phiBin]);
1564  break;
1565  case 211: case -211:
1567  sd0zo =EvalGraph(ptmc,fD0ZResPiCur,fD0ZResPiCurSA);
1568  spt1o =EvalGraph(ptmc,fPt1ResPiCur,fPt1ResPiCurSA);
1570  sd0zn =EvalGraph(ptmc,fD0ZResPiUpg,fD0ZResPiUpgSA);
1571  spt1n =EvalGraph(ptmc,fPt1ResPiUpg,fPt1ResPiUpgSA);
1572  sd0mrpo=EvalGraph(ptmc,fD0RPMeanPiCur[magfield][phiBin],fD0RPMeanPiCur[magfield][phiBin]);
1573  sd0mrpn=EvalGraph(ptmc,fD0RPMeanPiUpg[magfield][phiBin],fD0RPMeanPiUpg[magfield][phiBin]);
1575  break;
1576  case 11: case -11:
1577  sd0rpo=EvalGraph(ptmc,fD0RPResECur,fD0RPResECurSA);
1578  sd0zo =EvalGraph(ptmc,fD0ZResECur,fD0ZResECurSA);
1579  spt1o =EvalGraph(ptmc,fPt1ResECur,fPt1ResECurSA);
1580  sd0rpn=EvalGraph(ptmc,fD0RPResEUpg,fD0RPResEUpgSA);
1581  sd0zn =EvalGraph(ptmc,fD0ZResEUpg,fD0ZResEUpgSA);
1582  spt1n =EvalGraph(ptmc,fPt1ResEUpg,fPt1ResEUpgSA);
1583  sd0mrpo=EvalGraph(ptmc,fD0RPMeanECur[magfield][phiBin],fD0RPMeanECur[magfield][phiBin]);
1584  sd0mrpn=EvalGraph(ptmc,fD0RPMeanEUpg[magfield][phiBin],fD0RPMeanEUpg[magfield][phiBin]);
1586  break;
1587  default:
1588  return;
1589  }
1590  }
1591  else{ // PbPb 2018 periods templates
1592  // kFirst tracks
1593  if(is_kFirst_Trk){
1594  switch (pdgcode) {
1595  case 2212: case -2212:
1602  sd0mrpo=EvalGraph(ptmc,fD0RPMeanKCur_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanKCur_PbPb2018_kFirst[magfield][phiBin]);
1603  sd0mrpn=EvalGraph(ptmc,fD0RPMeanKUpg_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanKUpg_PbPb2018_kFirst[magfield][phiBin]);
1605  break;
1606  case 321: case -321:
1613  sd0mrpo=EvalGraph(ptmc,fD0RPMeanKCur_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanKCur_PbPb2018_kFirst[magfield][phiBin]);
1614  sd0mrpn=EvalGraph(ptmc,fD0RPMeanKUpg_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanKUpg_PbPb2018_kFirst[magfield][phiBin]);
1616  break;
1617  case 211: case -211:
1624  sd0mrpo=EvalGraph(ptmc,fD0RPMeanPiCur_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanPiCur_PbPb2018_kFirst[magfield][phiBin]);
1625  sd0mrpn=EvalGraph(ptmc,fD0RPMeanPiUpg_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanPiUpg_PbPb2018_kFirst[magfield][phiBin]);
1627  break;
1628  case 11: case -11:
1635  sd0mrpo=EvalGraph(ptmc,fD0RPMeanECur_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanECur_PbPb2018_kFirst[magfield][phiBin]);
1636  sd0mrpn=EvalGraph(ptmc,fD0RPMeanEUpg_PbPb2018_kFirst[magfield][phiBin],fD0RPMeanEUpg_PbPb2018_kFirst[magfield][phiBin]);
1638  break;
1639  default:
1640  return;
1641  }
1642  }
1643  // kOnlySecond tracks
1644  else if(is_kOnlySecond_Trk){
1645  switch (pdgcode) {
1646  case 2212: case -2212:
1653  sd0mrpo=EvalGraph(ptmc,fD0RPMeanKCur_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanKCur_PbPb2018_kOnlySecond[magfield][phiBin]);
1654  sd0mrpn=EvalGraph(ptmc,fD0RPMeanKUpg_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanKUpg_PbPb2018_kOnlySecond[magfield][phiBin]);
1656  break;
1657  case 321: case -321:
1664  sd0mrpo=EvalGraph(ptmc,fD0RPMeanKCur_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanKCur_PbPb2018_kOnlySecond[magfield][phiBin]);
1665  sd0mrpn=EvalGraph(ptmc,fD0RPMeanKUpg_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanKUpg_PbPb2018_kOnlySecond[magfield][phiBin]);
1667  break;
1668  case 211: case -211:
1675  sd0mrpo=EvalGraph(ptmc,fD0RPMeanPiCur_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanPiCur_PbPb2018_kOnlySecond[magfield][phiBin]);
1676  sd0mrpn=EvalGraph(ptmc,fD0RPMeanPiUpg_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanPiUpg_PbPb2018_kOnlySecond[magfield][phiBin]);
1678  break;
1679  case 11: case -11:
1686  sd0mrpo=EvalGraph(ptmc,fD0RPMeanECur_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanECur_PbPb2018_kOnlySecond[magfield][phiBin]);
1687  sd0mrpn=EvalGraph(ptmc,fD0RPMeanEUpg_PbPb2018_kOnlySecond[magfield][phiBin],fD0RPMeanEUpg_PbPb2018_kOnlySecond[magfield][phiBin]);
1689  break;
1690  default:
1691  return;
1692  }
1693  }
1694  }
1695 
1696 
1697  // Use the same units (i.e. cm and GeV/c)! TODO: pt!
1698  sd0rpo*=1.e-4;
1699  sd0zo *=1.e-4;
1700  sd0rpn*=1.e-4;
1701  sd0zn *=1.e-4;
1702  sd0mrpo*=1.e-4;
1703  sd0mrpn*=1.e-4;
1704 
1705  // Apply the smearing
1706  Double_t d0zo =param [1];
1707  Double_t d0zmc =parammc[1];
1708  Double_t d0rpo =param [0];
1709  Double_t d0rpmc=parammc[0];
1710  Double_t pt1o =param [4];
1711  Double_t pt1mc =parammc[4];
1712  Double_t dd0zo =d0zo-d0zmc;
1713  Double_t dd0zn =dd0zo *(sd0zo >0. ? (sd0zn /sd0zo ) : 1.);
1714  Double_t d0zn =d0zmc+dd0zn;
1715  Double_t dd0rpo=d0rpo-d0rpmc;
1716  Double_t dd0rpn=dd0rpo*(sd0rpo>0. ? (sd0rpn/sd0rpo) : 1.);
1717  Double_t dd0mrpn=TMath::Abs(sd0mrpn)-TMath::Abs(sd0mrpo);
1718  Double_t d0rpn =d0rpmc+dd0rpn-dd0mrpn;
1719  Double_t d0zoinsigma = 0.;
1720  if(covar[0] > 0.) d0zoinsigma = d0zo/TMath::Sqrt(covar[2]);
1721  Double_t d0rpoinsigma = 0.;
1722  if(covar[2] > 0.) d0rpoinsigma = d0rpo/TMath::Sqrt(covar[0]);
1723 
1724  if(fMimicData){
1725  dd0mrpn=sd0mrpn-sd0mrpo;
1726  d0rpn =d0rpmc+dd0rpn+dd0mrpn;
1727  }
1728 
1729  Double_t dpt1o =pt1o-pt1mc;
1730  Double_t dpt1n =dpt1o *(spt1o >0. ? (spt1n /spt1o ) : 1.);
1731  Double_t pt1n =pt1mc+dpt1n;
1732  param[0]=d0rpn;
1733  param[1]=d0zn ;
1734  param[4]=pt1n ;
1735 
1736  //cov matrix update
1737  if(fUpdateSTCovMatrix){
1738  if(sd0rpo>0.) covar[0]*=(sd0rpn/sd0rpo)*(sd0rpn/sd0rpo);//yy
1739  if(sd0zo>0. && sd0rpo>0.)covar[1]*=(sd0rpn/sd0rpo)*(sd0zn/sd0zo);//yz
1740  if(sd0zo>0.) covar[2]*=(sd0zn/sd0zo)*(sd0zn/sd0zo);//zz
1741  if(sd0rpo>0.) covar[3]*=(sd0rpn/sd0rpo);//yl
1742  if(sd0zo>0.) covar[4]*=(sd0zn/sd0zo);//zl
1743  if(sd0rpo>0.) covar[6]*=(sd0rpn/sd0rpo);//ysenT
1744  if(sd0zo>0.) covar[7]*=(sd0zn/sd0zo);//zsenT
1745  if(sd0rpo>0. && spt1o>0.)covar[10]*=(sd0rpn/sd0rpo)*(spt1n/spt1o);//ypt
1746  if(sd0zo>0. && spt1o>0.) covar[11]*=(sd0zn/sd0zo)*(spt1n/spt1o);//zpt
1747  if(spt1o>0.) covar[12]*=(spt1n/spt1o);//sinPhipt
1748  if(spt1o>0.) covar[13]*=(spt1n/spt1o);//tanTpt
1749  if(spt1o>0.) covar[14]*=(spt1n/spt1o)*(spt1n/spt1o);//ptpt
1750  }
1751  if(fUpdatePulls){
1752 
1753  covar[0]*=pullcorr*pullcorr;//yy
1754  covar[1]*=pullcorr;//yz
1755  covar[3]*=pullcorr;//yl
1756  covar[6]*=pullcorr;//ysenT
1757  covar[10]*=pullcorr;//ypt
1758 
1759  }
1760 
1761  Double_t d0zninsigma = 0.;
1762  if(covar[0] > 0.) d0zninsigma = d0zn/TMath::Sqrt(covar[2]);
1763  Double_t d0rpninsigma = 0.;
1764  if(covar[2] > 0.) d0rpninsigma = d0rpn/TMath::Sqrt(covar[0]);
1765 
1766  // Copy the smeared parameters to the AOD track
1767  Double_t x[3];
1768  Double_t p[3];
1769  et.GetXYZ(x);
1770  et.GetPxPyPz(p);
1771  Double_t cv[21];
1772  et.GetCovarianceXYZPxPyPz(cv);
1773 
1774  //if(fIsPbPb2018){
1775  // printf("--- is_kFirst_Trk: %d\n", is_kFirst_Trk);
1776  // printf("--- is_kOnlySecond_Trk: %d\n", is_kOnlySecond_Trk);
1777  // for(UInt_t ibin=0; ibin<21; ibin++) printf("%f\n",cv[ibin]);
1778  // printf("\n");
1779  //}
1780 
1781  if(fIsAOD) {
1782  AliAODTrack *aodtrack = static_cast<AliAODTrack *>(track);
1783  aodtrack->SetPosition(x,kFALSE);
1784  aodtrack->SetP(p,kTRUE);
1785  aodtrack->SetCovMatrix(cv);
1786  // Mark the track as "improved" with a trick (this is done with a trick using layer 7 (ie the 8th))
1787  UChar_t itsClusterMap = aodtrack->GetITSClusterMap();
1788  SETBIT(itsClusterMap,7);
1789  aodtrack->SetITSClusterMap(itsClusterMap);
1790  //
1791 
1792  } else {
1793  AliESDtrack *esdtrack = static_cast<AliESDtrack *>(track);
1794  Short_t sign = esdtrack->Charge();
1795  esdtrack->Set(x,p,cv,sign);
1796  esdtrack->RelateToVVertex(InputEvent()->GetPrimaryVertex(), bz,100.);
1797  // Mark the track as "improved" with a trick (this is done with a trick using layer 7 (ie the 8th))
1798  UChar_t itsClusterMap = esdtrack->GetITSClusterMap();
1799  SETBIT(itsClusterMap,7);
1800  esdtrack->SetITSClusterMap(itsClusterMap);
1801  }
1802 
1803 
1804  // write out debug infos
1805  if (fDebugNtuple->GetEntriesFast()<fNDebug) {
1806  Int_t idbg=0;
1807  fDebugVars[idbg++]=pdgcode;
1808  fDebugVars[idbg++]=ptmc ;
1809  fDebugVars[idbg++]=d0rpo ;
1810  fDebugVars[idbg++]=d0zo ;
1811  fDebugVars[idbg++]=pt1o ;
1812  fDebugVars[idbg++]=sd0rpo;
1813  fDebugVars[idbg++]=sd0zo ;
1814  fDebugVars[idbg++]=spt1o ;
1815  fDebugVars[idbg++]=d0rpn ;
1816  fDebugVars[idbg++]=d0zn ;
1817  fDebugVars[idbg++]=pt1n ;
1818  fDebugVars[idbg++]=sd0rpn;
1819  fDebugVars[idbg++]=sd0zn ;
1820  fDebugVars[idbg++]=spt1n ;
1821  fDebugVars[idbg++]=d0rpmc;
1822  fDebugVars[idbg++]=d0zmc ;
1823  fDebugVars[idbg++]=pt1mc ;
1824  fDebugVars[idbg++]=pullcorr ;
1825  fDebugVars[idbg++]=d0zoinsigma ;
1826  fDebugVars[idbg++]=d0zninsigma ;
1827  fDebugVars[idbg++]=d0rpoinsigma ;
1828  fDebugVars[idbg++]=d0rpninsigma ;
1829  fDebugNtuple->Fill(fDebugVars);
1830  PostData(1,fDebugOutput);
1831  }
1832 }
1833 
1834 AliESDVertex* AliAnalysisTaskSEImproveITS::RecalculateVertex(const AliVVertex *old,TObjArray *tracks,Double_t bField) {
1835  //
1836  // Helper function to recalculate a vertex.
1837  //
1838 
1839  static UShort_t ids[]={1,2,3}; //TODO: unsave...
1840  AliVertexerTracks vertexer(bField);
1841  vertexer.SetVtxStart(old->GetX(),old->GetY(),old->GetZ());
1842  AliESDVertex *vertex=vertexer.VertexForSelectedTracks(tracks,ids);
1843  return vertex;
1844 }
1845 
1847  //
1848  // Evaluates a TGraph without linear extrapolation. Instead the last
1849  // valid point of the graph is used when out of range.
1850  // The function assumes an ascending order of X.
1851  //
1852 
1853  if(!graph){
1854  printf("\tEvalGraph fails !\n");
1855  return 0.;
1856  }
1857 
1858  // TODO: find a pretty solution for this:
1859  Int_t n =graph->GetN();
1860  Double_t xmin=graph->GetX()[0 ];
1861  Double_t xmax=graph->GetX()[n-1];
1862  if (x<xmin) {
1863  if(!graphSA) return graph->Eval(xmin);
1864  Double_t xminSA=graphSA->GetX()[0];
1865  if(x<xminSA) return graphSA->Eval(xminSA);
1866  return graphSA->Eval(x);
1867  }
1868  if (x>xmax) return graph->Eval(xmax);
1869  return graph->Eval(x);
1870 }
1871 
1872 //________________________________________________________________________
1873 
1875  Double_t pi=TMath::Pi();
1876  if(phi>2.*pi || phi<0.) return -1;
1877 
1878  if(!fIsPbPb2018){
1879  if((phi<=(pi/4.)) || (phi>7.*(pi/4.))) return 0;
1880  if((phi>(pi/4.)) && (phi<=3.*(pi/4.))) return 1;
1881  if((phi>3.*(pi/4.)) && (phi<=5.*(pi/4.))) return 2;
1882  if((phi>(5.*pi/4.)) && (phi<=7.*(pi/4.))) return 3;
1883  }
1884  else{ // correction performed in 24 φ bins for PbPb 2018 periods
1885  Double_t width = 2.*pi/24;
1886  Int_t jBin=TMath::Floor(phi/width);
1887  return jBin; // by construction is 0<=jBin<23 since phi is in 0-2pi
1888  }
1889 
1890  return -1;
1891 }
1892 
1893 ClassImp(AliAnalysisTaskSEImproveITS);
1894 
TGraph * fD0RPMeanEUpg[2][4]
new pt dep. d0 mean in rphi for pions in 4 phi regions
AliAODTrack * GetProng(AliVEvent *event, AliAODRecoDecayHF *rd, Int_t iprong)
TGraph * fPt1ResPiCur
old pt dep. 1/pt res. for kaons
TGraph * fD0RPMeanPUpg[2][4]
new pt dep. d0 res. in rphi for electrons
TGraph * fD0ZResPUpg
old pt dep. 1/pt res. for electrons
TGraph * fD0RPResKCur
old pt dep. d0 res. in rphi for protons
Bool_t fMimicData
flag to switch on/off the correction of the pulls
TGraph * fD0RPResPiUpgSA
new standalone pt dep. d0 res. in rphi for kaons
double Double_t
Definition: External.C:58
TGraph * fD0ZResKUpgSA
new standalone pt dep. d0 res. in z for protons
TGraph * fD0RPResPCurSA
old standalone pt dep. d0 res. in z for electrons
virtual void UserCreateOutputObjects()
Implementation of interface methods.
TGraph * fD0RPResPiCur
old pt dep. d0 res. in rphi for kaons
TGraph * fPt1ResKUpgSA
new standalone pt dep. 1/pt res. for protons
TGraph * fD0ZResPUpgSA
old standalone pt dep. 1/pt res. for electrons
TGraph * fD0RPMeanPiCur[2][4]
old pt dep. d0 mean. in rphi for kaons in 4 phi regions
Double_t EvalGraph(Double_t x, const TGraph *graph, const TGraph *graphSA=0) const
Helper functions.
TGraph * fD0RPMeanPiUpg[2][4]
new pt dep. d0 mean in rphi for kaons in 4 phi regions
Double_t bz
Bool_t fUpdateSecVertCovMat
this is always kTRUE. kFALSE only if re-running on already improved AODs
TGraph * fD0ZResPiCurSA
old standalone pt dep. d0 res. in z for kaons
virtual void UserExec(Option_t *option)
TGraph * fD0RPMeanPCur[2][4]
pt dep. d0 sigma pull MC/data in rphi for electrons
Bool_t FillRecoCand(AliVEvent *event, AliAODRecoDecayHF3Prong *rd3)
TList * fDebugOutput
! collection of debug output
TGraph * fPt1ResPiUpg
new pt dep. 1/pt res. for kaons
TGraph * fPt1ResPCurSA
old standalone pt dep. d0 res. in rphi for electrons
TGraph * fPt1ResPiCurSA
old standalone pt dep. 1/pt res. for kaons
TGraph * fD0RPSigmaPullRatioE
pt dep. d0 sigma pull MC/data in rphi for pions
TGraph * fD0RPResECur
old pt dep. d0 res. in rphi for pions
Bool_t FillRecoCasc(AliVEvent *event, AliAODRecoCascadeHF *rc, Bool_t isDStar, Bool_t recoSecVtx=kFALSE)
TGraph * fPt1ResPUpg
new pt dep. d0 mean in rphi for electrons in 4 phi regions
TGraph * fD0RPResKCurSA
old standalone pt dep. d0 res. in rphi for protons
TGraph * fPt1ResECurSA
old standalone pt dep. 1/pt res. for pions
TGraph * fPt1ResKUpg
new pt dep. 1/pt res. for protons
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
TGraph * fPt1ResKCur
old pt dep. 1/pt res. for protons
TGraph * fD0RPResKUpgSA
new standalone pt dep. d0 res. in rphi for protons
float Float_t
Definition: External.C:68
TGraph * fPt1ResPUpgSA
new standalone pt dep. d0 res. in rphi for electrons
TGraph * fPt1ResECur
old pt dep. 1/pt res. for pions
AliAODTrack * GetBachelor() const
TGraph * fD0RPSigmaPullRatioK
pt dep. d0 sigma pull MC/data in rphi for protons
TClonesArray * fMCs
flag to control whether to smear only injected signal
TGraph * fD0RPResPiCurSA
old standalone pt dep. d0 res. in rphi for kaons
TGraph * fD0RPSigmaPullRatioP
old pt dep. d0 res. in rphi for electrons
TGraph * fD0ZResKCurSA
old standalone pt dep. d0 res. in z for protons
TGraph * fD0ZResPCurSA
new pt dep. 1/pt res. for electrons
void SmearTrack(AliVTrack *track, Double_t bz)
Float_t * fDebugVars
! variables to store as degug info
static Bool_t IsCandidateInjected(AliAODRecoDecayHF *cand, AliAODMCHeader *header, TClonesArray *arrayMC)
TGraph * fD0RPResPCur
old pt dep. d0 res. in z for electrons
short Short_t
Definition: External.C:23
TGraph * fD0ZResEUpg
new pt dep. d0 res. in z for pions
TGraph * fPt1ResPiUpgSA
new standalone pt dep. 1/pt res. for kaons
TGraph * fPt1ResEUpgSA
new standalone pt dep. 1/pt res. for pions
TGraph * fD0RPResPUpgSA
new standalone pt dep. d0 res. in z for electrons
TGraph * fPt1ResKCurSA
old standalone pt dep. 1/pt res. for protons
decay
Definition: HFPtSpectrum.C:42
TGraph * fD0ZResECurSA
old standalone pt dep. d0 res. in z for pions
TGraph * fPt1ResEUpg
new pt dep. 1/pt res. for pions
TGraph * fD0RPSigmaPullRatioPi
pt dep. d0 sigma pull MC/data in rphi for kaons
Bool_t fImproveTracks
flag to run hybrid task before the vertexingHF task or in standard mode
static Bool_t IsTrackInjected(Int_t label, AliAODMCHeader *header, TClonesArray *arrayMC)
Bool_t fSmearOnlySignal
flag to run on AOD
TGraph * fD0RPResECurSA
old standalone pt dep. d0 res. in rphi for pions
TGraph * fD0ZResKCur
old pt dep. d0 res. in z for protons
TGraph * fD0ZResEUpgSA
new standalone pt dep. d0 res. in z for pions
void Setd0errProngs(Int_t nprongs, Double_t *d0)
TGraph * fPt1ResPCur
old pt dep. d0 mean. in rphi for electrons in 4 phi regions
TGraph * fD0RPResPUpg
new pt dep. d0 res. in z for electrons
TGraph * fD0ZResECur
old pt dep. d0 res. in z for pions
Bool_t fUpdateSTCovMatrix
flag to swicth on/off the modification of the sec vert cov matrix
TGraph * fD0ZResPiUpg
new pt dep. d0 res. in z for kaons
unsigned short UShort_t
Definition: External.C:28
const char Option_t
Definition: External.C:48
TGraph * fD0ZResPiCur
old pt dep. d0 res. in z for kaons
Bool_t fUpdatePulls
flag to switch on/off the update of the single track covariance matrix
const Double_t pi
TGraph * fD0RPResEUpgSA
new standalone pt dep. d0 res. in rphi for pions
bool Bool_t
Definition: External.C:53
void SetSigmaVert(Double_t sigmaVert)
TGraph * fD0RPResEUpg
new pt dep. d0 res. in rphi for pions
AliAODRecoDecayHF2Prong * Get2Prong() const
TGraph * fD0ZResPiUpgSA
new standalone pt dep. d0 res. in z for kaons
Bool_t fIsPbPb2018
new standalone pt dep. 1/pt res. for electrons
TGraph * fD0RPResPiUpg
new pt dep. d0 res. in rphi for kaons
TGraph * fD0RPMeanKUpg[2][4]
new pt dep. d0 mean in rphi for protons in 4 phi regions
AliESDVertex * RecalculateVertex(const AliVVertex *old, TObjArray *tracks, Double_t bField)
TGraph * fD0RPMeanKCur[2][4]
old pt dep. d0 mean. in rphi for protons in 4 phi regions
TNtuple * fDebugNtuple
! debug send on output slot 1
TGraph * fD0RPMeanECur[2][4]
old pt dep. d0 mean. in rphi for pions in 4 phi regions
TGraph * fD0RPResKUpg
new pt dep. d0 res. in rphi for protons
TGraph * fD0ZResKUpg
new pt dep. d0 res. in z for protons