AliPhysics  64f4410 (64f4410)
AliAnalysisTaskZDCGainEq.cxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright(c) 1998-2008, 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 
17 //
18 // Author: Rihan Haque (mhaque@cern.ch)
20 
21 
22 #include "Riostream.h" //needed as include
23 
24 class TFile;
25 class TList;
26 class AliAnalysisTaskSE;
27 
28 #include "TProfile.h" //needed as include
29 #include "TProfile2D.h"
30 #include "TList.h"
31 #include "TH1.h"
32 #include "TH2.h"
33 #include "TH3.h"
34 #include "AliMultSelection.h"
35 #include "AliVVertex.h"
36 
37 #include "AliAnalysisManager.h"
38 #include "AliFlowEvent.h"
39 #include "AliFlowEventSimple.h"
40 #include "AliFlowCommonHist.h"
42 
43 #include "AliAnalysisManager.h"
44 #include "AliInputEventHandler.h"
45 #include "AliVEvent.h"
46 #include "AliESD.h"
47 #include "AliESDEvent.h"
48 #include "AliESDHeader.h"
49 #include "AliESDInputHandler.h"
50 #include "AliESDZDC.h"
51 #include "AliMultiplicity.h"
52 #include "AliAnalysisUtils.h"
53 #include "AliAODHandler.h"
54 #include "AliAODTrack.h"
55 #include "AliAODEvent.h"
56 #include "AliAODHeader.h"
57 #include "AliAODVertex.h"
58 #include "AliAODVZERO.h"
59 #include "AliAODZDC.h"
60 #include "AliAODMCHeader.h"
61 #include "AliMCEventHandler.h"
62 #include "AliMCEvent.h"
63 #include "AliHeader.h"
64 #include "AliVParticle.h"
65 #include "AliStack.h"
66 #include "AliAODMCParticle.h"
67 #include "AliAnalysisTaskSE.h"
68 #include "AliGenEventHeader.h"
69 #include "AliPhysicsSelectionTask.h"
70 #include "AliPhysicsSelection.h"
71 #include "AliBackgroundSelection.h"
72 #include "AliTriggerAnalysis.h"
73 #include "AliCentrality.h"
74 #include "AliLog.h"
76 #include "AliFlowVector.h"
77 
78 using std::endl;
79 using std::cout;
80 
81 
83 
84 //________________________________________________________________________
86  AliAnalysisTaskSE(name),
87  fEvent(NULL),
88  fMultSelection(NULL),
89  fAnalysisUtil(NULL),
90  fListHistos(NULL),
91  fListZDCQxy(NULL),
92  fListZDCWgt(NULL),
93  fListDummy1(NULL),
94  fListHijing(NULL),
95  fListSubRun(NULL),
96  fRejectPileUpTight(kFALSE),
97  fRejectPileUp(kFALSE),
98  bFillCosSin(kFALSE),
99  bFillZDCQAon(kFALSE),
100  bRunAveragedQn(kFALSE),
101  bApplyRecent(kFALSE),
102  bCentCutShift(kFALSE),
103  fHarmonic(2),
104  frunflag(0),
105  fievent(0),
106  vxBin(0),
107  vyBin(0),
108  vzBin(0),
109  fcheckOnce(0),
110  fOldRunNum(0),
111  fHist_Event_count(NULL),
112  fPileUpMultSelCount(NULL),
113  fPileUpCount(NULL),
114  fHist_ChanWgt_ZDCC(NULL),
115  fHist_ChanWgt_ZDCA(NULL),
116  fHist_Vx_ArrayFinder(NULL),
117  fHist_Vy_ArrayFinder(NULL),
118  fHist_Vz_ArrayFinder(NULL),
119  fHist_Task_config(NULL),
120  fHist_Cent_woZDCcut(NULL),
121  fHist_Cent_wiZDCcut(NULL),
122  fHist_CutParameters(NULL),
123  fHist_Psi1_ZDCC_wGainCorr(NULL),
124  fHist_Psi1_ZDCA_wGainCorr(NULL),
125  fHist_Psi1_ZDCC_wRectCorr(NULL),
126  fHist_Psi1_ZDCA_wRectCorr(NULL),
127  fHist_Psi1_ZDCC_wCorrFull(NULL),
128  fHist_Psi1_ZDCA_wCorrFull(NULL),
129  fHist_Psi1_ZDCC_RunByRun(NULL),
130  fHist_Psi1_ZDCA_RunByRun(NULL),
131  fHist_v2xV1_ZDN_Norm_All(NULL),
132  fHist_v2xV1_ZDN_Refm_All(NULL),
133  fHist_v2xV1_ZDN_Cent_All(NULL),
134  fHist_v3xV1_ZDN_Norm_Comb1(NULL),
135  fHist_v3xV1_ZDN_Norm_Comb2(NULL),
136  fHist_v3xV1_ZDN_Cent_Comb1(NULL),
137  fHist_v3xV1_ZDN_Cent_Comb2(NULL),
138  fHist_v4xV1_ZDN_Norm_Comb1(NULL),
139  fHist_v4xV1_ZDN_Cent_Comb1(NULL),
140  fHist_ZDN_resol_Norm_All(NULL),
141  fHist_ZDN_resol_Cent_All(NULL),
142  fHist_ZDN_resol_Refm_All(NULL),
143  fHist_ZDN_resol_Norm_XX(NULL),
144  fHist_ZDN_resol_Norm_YY(NULL),
145  fHist_ZDN_resol_Cent_XX(NULL),
146  fHist_ZDN_resol_Cent_YY(NULL),
147  fHist_Vx_vs_runnum(NULL),
148  fHist_Vy_vs_runnum(NULL),
149  fHist_Vz_vs_runnum(NULL),
150  fWeight_Cent(NULL),
151  fHist_Vxy_RunAveraged(NULL),
152  fHist_Event_counter_vRun(NULL),
153  fHist_PsiSumAC_woCorr(NULL),
154  fHist_PsiSumAC_wiCorr(NULL),
155  fHist_ZeroQnXY_Conter(NULL),
156  fHist_ZDCC_AvgQx_VsRun(NULL),
157  fHist_ZDCC_AvgQy_VsRun(NULL),
158  fHist_ZDCA_AvgQx_VsRun(NULL),
159  fHist_ZDCA_AvgQy_VsRun(NULL),
160  fHist_ZDC_AvgXXminusYY_VsRun(NULL),
161  fHist_ZDC_AvgXYplusXY_VsRun(NULL),
162  fHist_ZDCC_AvgQx_VsCR(NULL),
163  fHist_ZDCC_AvgQy_VsCR(NULL),
164  fHist_ZDCA_AvgQx_VsCR(NULL),
165  fHist_ZDCA_AvgQy_VsCR(NULL),
166  fHist_PsiSumAC_ZeroQn(NULL),
167  fHist_PsiZDCA_ZeroQn(NULL),
168  fHist_PsiZDCC_ZeroQn(NULL),
169  fHist_ZDC_dTermXXYY_VsRun(NULL),
170  fHist_ZDC_dTermXYXY_VsRun(NULL),
171  fHist_Corr3p_ZDN_Norm_PN(NULL),
172  fHist_Corr3p_ZDN_Norm_PP(NULL),
173  fHist_Corr3p_ZDN_Norm_NN(NULL),
174  fHist_Corr3p_ZDN_Cent_PN(NULL),
175  fHist_Corr3p_ZDN_Cent_PP(NULL),
176  fHist_Corr3p_ZDN_Cent_NN(NULL),
177  fHist_Reso2EP_TPC_Norm(NULL),
178  fHist_Reso2EP_TPC_Cent(NULL),
179  fHist_ZDC_dTermXXYY_VsCR(NULL),
180  fHist_ZDC_dTermXYXY_VsCR(NULL),
181  fHist_NormalCentralityBins(NULL),
182  fDataSet("2010"),
183  fAnalysisSet("DoGainEq"),
184  sCentEstimator("V0")
185 {
186  for(int i=0;i<90;i++){
187  runNums[i] = 0;
188  fHist_ZDCA_En_Run[i] = NULL;
189  fHist_ZDCC_En_Run[i] = NULL;
190 
191  for(int j=0;j<10;j++){
192  fHist_znCx_V0_VxVy[i][j] = NULL;
193  fHist_znCy_V0_VxVy[i][j] = NULL;
194  fHist_znAx_V0_VxVy[i][j] = NULL;
195  fHist_znAy_V0_VxVy[i][j] = NULL;
196  }
197  }
198 
199  for(int i=0;i<4;i++){
200  fHist_Qx_wiCorr_RunByRun[i] = NULL;
201  fHist_Qx_Trig_woCorr[i] = NULL;
202  fHist_XX_Trig_woCorr[i] = NULL;
203  fHist_Qx_Trig_wiCorr[i] = NULL;
204  fHist_XX_Trig_wiCorr[i] = NULL;
205  for(int j=0;j<5;j++){
206  fHist_Qx_vs_Obs_woCorr[i][j] = NULL;
207  fHist_XX_vs_Obs_woCorr[i][j] = NULL;
208  fHist_Qx_vs_Obs_wiCorr[i][j] = NULL;
209  fHist_XX_vs_Obs_wiCorr[i][j] = NULL;
210  }
211  }
212  for(int i=0;i<20;i++){
213  fHist_Recenter_ZDCCx[i] = NULL;
214  fHist_Recenter_ZDCCy[i] = NULL;
215  fHist_Recenter_ZDCAx[i] = NULL;
216  fHist_Recenter_ZDCAy[i] = NULL;
217  }
218  for(int i=0;i<20;i++){
219  fHist_ZDCC_En_CommonCh[i] = NULL;
220  fHist_ZDCA_En_CommonCh[i] = NULL;
221  }
222 
223  for(int i=0;i<2;i++){
224  VxCut[i] = 0;
225  VyCut[i] = 0;
226  VzCut[i] = 0;
227  }
228 
229  for(int i=0;i<10;i++){
230  fFB_Efficiency_Cent[i] = NULL;
231  fHist_v2xV1_ZDN_pTDiff_All[i] = NULL;
232  fHist_v4xV1_ZDN_pTDiff_All[i] = NULL;
233  fHist_v3xV1_ZDN_EtaDiff_Comb1[i]= NULL;
234  fHist_v3xV1_ZDN_EtaDiff_Comb2[i]= NULL;
235 
236  for(int j=0;j<4;j++){
237  fHist_v1xV1_ZDN_EtaDiff[j][i] = NULL;
238  fHist_v1xV1_ZDN_pTDiff[j][i] = NULL;
239  }
240  }
241 
242  for(int i=0;i<4;i++){
243  fHist_v2xV1_ZDN_Norm_Sep[i] = NULL;
244  fHist_v2xV1_ZDN_Cent_Sep[i] = NULL;
245  }
246  for(int i=0;i<2;i++){
247  fHist_ZDN_resol_Norm_Sep[i] = NULL;
248  fHist_ZDN_resol_Cent_Sep[i] = NULL;
249  }
250  for(int i=0;i<4;i++){
251  //here
252  fHist_ZDCC_AvgCosNPsi[i] = NULL;
253  fHist_ZDCC_AvgSinNPsi[i] = NULL;
254  fHist_ZDCA_AvgCosNPsi[i] = NULL;
255  fHist_ZDCA_AvgSinNPsi[i] = NULL;
256  fHist_ZDC_AvgCosNPsiAC[i] = NULL;
257  fHist_ZDC_AvgSinNPsiAC[i] = NULL;
258  }
259  for(int i=0;i<4;i++){
260  fHist_ZDCC_AvgCos_VsRun[i] = NULL;
261  fHist_ZDCC_AvgSin_VsRun[i] = NULL;
262  fHist_ZDCA_AvgCos_VsRun[i] = NULL;
263  fHist_ZDCA_AvgSin_VsRun[i] = NULL;
264  fHist_ZDC_AvgCosPsiSum_VsRun[i] = NULL;
265  fHist_ZDC_AvgSinPsiSum_VsRun[i] = NULL;
266  fHist_ZDC_AvgCosPsiDif_VsRun[i] = NULL;
267  fHist_ZDC_AvgSinPsiDif_VsRun[i] = NULL;
268  }
269  for(int i=0;i<2;i++){
270  fHist_XXYY_vs_Cent_woCorr[i] = NULL;
271  fHist_XXYY_vs_Cent_wiCorr[i] = NULL;
272  }
273 
274  for(int i=0;i<4;i++){
275  for(int j=0;j<6;j++){
276  fHist_XX_vs_QnC_2DwoCorr_PosMag[i][j] = NULL;
277  fHist_XX_vs_QnA_2DwoCorr_PosMag[i][j] = NULL;
278  fHist_XX_vs_QnC_2DwoCorr_NegMag[i][j] = NULL;
279  fHist_XX_vs_QnA_2DwoCorr_NegMag[i][j] = NULL;
280  }
281  }
282 
283  for(int i=0;i<90;i++){
284  fHist_VZERO_Mult_vsRun[i] = NULL;
285  }
286 
287 
288  DefineInput(1, AliFlowEventSimple::Class()); // Input slot #1 works with an AliFlowEventSimple
289  DefineInput(2, AliFlowEventSimple::Class()); // Input slot #2 for ZDC flow event
290 
291 
292  DefineOutput(1,TList::Class());
293  DefineOutput(2,TList::Class());
294 
295  //fDataSet="2010";
296  //fAnalysisSet="DoGainEq";
297  //sCentEstimator="V0";
298 
299  //fTotalQvector = new TString("QaQb"); // "QaQb" (means Qa+Qb), "Qa" or "Qb"
300 
301 }//-------------constructor-----------------
302 
303 //________________________________________________
306  fEvent(NULL),
307  fMultSelection(NULL),
308  fAnalysisUtil(NULL),
309  fListHistos(NULL),
310  fListZDCQxy(NULL),
311  fListZDCWgt(NULL),
312  fListDummy1(NULL),
313  fListHijing(NULL),
314  fListSubRun(NULL),
315  fRejectPileUpTight(kFALSE),
316  fRejectPileUp(kFALSE),
317  bFillCosSin(kFALSE),
318  bFillZDCQAon(kFALSE),
319  bRunAveragedQn(kFALSE),
320  bApplyRecent(kFALSE),
321  bCentCutShift(kFALSE),
322  fHarmonic(2),
323  frunflag(0),
324  fievent(0),
325  vxBin(0),
326  vyBin(0),
327  vzBin(0),
328  fcheckOnce(0),
329  fOldRunNum(0),
330  fHist_Event_count(NULL),
331  fPileUpMultSelCount(NULL),
332  fPileUpCount(NULL),
333  fHist_ChanWgt_ZDCC(NULL),
334  fHist_ChanWgt_ZDCA(NULL),
335  fHist_Vx_ArrayFinder(NULL),
336  fHist_Vy_ArrayFinder(NULL),
337  fHist_Vz_ArrayFinder(NULL),
338  fHist_Task_config(NULL),
339  fHist_Cent_woZDCcut(NULL),
340  fHist_Cent_wiZDCcut(NULL),
341  fHist_CutParameters(NULL),
342  fHist_Psi1_ZDCC_wGainCorr(NULL),
343  fHist_Psi1_ZDCA_wGainCorr(NULL),
344  fHist_Psi1_ZDCC_wRectCorr(NULL),
345  fHist_Psi1_ZDCA_wRectCorr(NULL),
346  fHist_Psi1_ZDCC_wCorrFull(NULL),
347  fHist_Psi1_ZDCA_wCorrFull(NULL),
348  fHist_Psi1_ZDCC_RunByRun(NULL),
349  fHist_Psi1_ZDCA_RunByRun(NULL),
350  fHist_v2xV1_ZDN_Norm_All(NULL),
351  fHist_v2xV1_ZDN_Refm_All(NULL),
352  fHist_v2xV1_ZDN_Cent_All(NULL),
353  fHist_v3xV1_ZDN_Norm_Comb1(NULL),
354  fHist_v3xV1_ZDN_Norm_Comb2(NULL),
355  fHist_v3xV1_ZDN_Cent_Comb1(NULL),
356  fHist_v3xV1_ZDN_Cent_Comb2(NULL),
357  fHist_v4xV1_ZDN_Norm_Comb1(NULL),
358  fHist_v4xV1_ZDN_Cent_Comb1(NULL),
359  fHist_ZDN_resol_Norm_All(NULL),
360  fHist_ZDN_resol_Cent_All(NULL),
361  fHist_ZDN_resol_Refm_All(NULL),
362  fHist_ZDN_resol_Norm_XX(NULL),
363  fHist_ZDN_resol_Norm_YY(NULL),
364  fHist_ZDN_resol_Cent_XX(NULL),
365  fHist_ZDN_resol_Cent_YY(NULL),
366  fHist_Vx_vs_runnum(NULL),
367  fHist_Vy_vs_runnum(NULL),
368  fHist_Vz_vs_runnum(NULL),
369  fWeight_Cent(NULL),
370  fHist_Vxy_RunAveraged(NULL),
371  fHist_Event_counter_vRun(NULL),
372  fHist_PsiSumAC_woCorr(NULL),
373  fHist_PsiSumAC_wiCorr(NULL),
374  fHist_ZeroQnXY_Conter(NULL),
375  fHist_ZDCC_AvgQx_VsRun(NULL),
376  fHist_ZDCC_AvgQy_VsRun(NULL),
377  fHist_ZDCA_AvgQx_VsRun(NULL),
378  fHist_ZDCA_AvgQy_VsRun(NULL),
379  fHist_ZDC_AvgXXminusYY_VsRun(NULL),
380  fHist_ZDC_AvgXYplusXY_VsRun(NULL),
381  fHist_ZDCC_AvgQx_VsCR(NULL),
382  fHist_ZDCC_AvgQy_VsCR(NULL),
383  fHist_ZDCA_AvgQx_VsCR(NULL),
384  fHist_ZDCA_AvgQy_VsCR(NULL),
385  fHist_PsiSumAC_ZeroQn(NULL),
386  fHist_PsiZDCA_ZeroQn(NULL),
387  fHist_PsiZDCC_ZeroQn(NULL),
388  fHist_ZDC_dTermXXYY_VsRun(NULL),
389  fHist_ZDC_dTermXYXY_VsRun(NULL),
390  fHist_Corr3p_ZDN_Norm_PN(NULL),
391  fHist_Corr3p_ZDN_Norm_PP(NULL),
392  fHist_Corr3p_ZDN_Norm_NN(NULL),
393  fHist_Corr3p_ZDN_Cent_PN(NULL),
394  fHist_Corr3p_ZDN_Cent_PP(NULL),
395  fHist_Corr3p_ZDN_Cent_NN(NULL),
396  fHist_Reso2EP_TPC_Norm(NULL),
397  fHist_Reso2EP_TPC_Cent(NULL),
398  fHist_ZDC_dTermXXYY_VsCR(NULL),
399  fHist_ZDC_dTermXYXY_VsCR(NULL),
400  fHist_NormalCentralityBins(NULL),
401  fDataSet("2010"),
402  fAnalysisSet("DoGainEq"),
403  sCentEstimator("V0")
404 {
405  for(int i=0;i<90;i++){
406  runNums[i] = 0;
407  fHist_ZDCA_En_Run[i] = NULL;
408  fHist_ZDCC_En_Run[i] = NULL;
409 
410  for(int j=0;j<10;j++){
411  fHist_znCx_V0_VxVy[i][j] = NULL;
412  fHist_znCy_V0_VxVy[i][j] = NULL;
413  fHist_znAx_V0_VxVy[i][j] = NULL;
414  fHist_znAy_V0_VxVy[i][j] = NULL;
415  }
416  }
417 
418  for(int i=0;i<4;i++){
419  fHist_Qx_wiCorr_RunByRun[i] = NULL;
420  fHist_Qx_Trig_woCorr[i] = NULL;
421  fHist_XX_Trig_woCorr[i] = NULL;
422  fHist_Qx_Trig_wiCorr[i] = NULL;
423  fHist_XX_Trig_wiCorr[i] = NULL;
424 
425  for(int j=0;j<5;j++){
426  fHist_Qx_vs_Obs_woCorr[i][j] = NULL;
427  fHist_XX_vs_Obs_woCorr[i][j] = NULL;
428  fHist_Qx_vs_Obs_wiCorr[i][j] = NULL;
429  fHist_XX_vs_Obs_wiCorr[i][j] = NULL;
430  }
431  }
432  for(int i=0;i<20;i++){
433  fHist_Recenter_ZDCCx[i] = NULL;
434  fHist_Recenter_ZDCCy[i] = NULL;
435  fHist_Recenter_ZDCAx[i] = NULL;
436  fHist_Recenter_ZDCAy[i] = NULL;
437  }
438  for(int i=0;i<20;i++){
439  fHist_ZDCC_En_CommonCh[i] = NULL;
440  fHist_ZDCA_En_CommonCh[i] = NULL;
441  }
442 
443  for(int i=0;i<2;i++){
444  VxCut[i] = 0;
445  VyCut[i] = 0;
446  VzCut[i] = 0;
447  }
448 
449  for(int i=0;i<10;i++){
450  fFB_Efficiency_Cent[i] = NULL;
451  fHist_v2xV1_ZDN_pTDiff_All[i] = NULL;
452  fHist_v4xV1_ZDN_pTDiff_All[i] = NULL;
455 
456  for(int j=0;j<4;j++){
457  fHist_v1xV1_ZDN_EtaDiff[j][i] = NULL;
458  fHist_v1xV1_ZDN_pTDiff[j][i] = NULL;
459  }
460  }
461 
462  for(int i=0;i<4;i++){
463  fHist_v2xV1_ZDN_Norm_Sep[i] = NULL;
464  fHist_v2xV1_ZDN_Cent_Sep[i] = NULL;
465  }
466  for(int i=0;i<2;i++){
467  fHist_ZDN_resol_Norm_Sep[i] = NULL;
468  fHist_ZDN_resol_Cent_Sep[i] = NULL;
469  }
470  for(int i=0;i<4;i++){
471  fHist_ZDCC_AvgCosNPsi[i] = NULL;
472  fHist_ZDCC_AvgSinNPsi[i] = NULL;
473  fHist_ZDCA_AvgCosNPsi[i] = NULL;
474  fHist_ZDCA_AvgSinNPsi[i] = NULL;
475  fHist_ZDC_AvgCosNPsiAC[i] = NULL;
476  fHist_ZDC_AvgSinNPsiAC[i] = NULL;
477  }
478  for(int i=0;i<4;i++){
479  fHist_ZDCC_AvgCos_VsRun[i] = NULL;
480  fHist_ZDCC_AvgSin_VsRun[i] = NULL;
481  fHist_ZDCA_AvgCos_VsRun[i] = NULL;
482  fHist_ZDCA_AvgSin_VsRun[i] = NULL;
487  }
488  for(int i=0;i<2;i++){
489  fHist_XXYY_vs_Cent_woCorr[i] = NULL;
490  fHist_XXYY_vs_Cent_wiCorr[i] = NULL;
491  }
492  for(int i=0;i<4;i++){
493  for(int j=0;j<6;j++){
494  fHist_XX_vs_QnC_2DwoCorr_PosMag[i][j] = NULL;
495  fHist_XX_vs_QnA_2DwoCorr_PosMag[i][j] = NULL;
496  fHist_XX_vs_QnC_2DwoCorr_NegMag[i][j] = NULL;
497  fHist_XX_vs_QnA_2DwoCorr_NegMag[i][j] = NULL;
498  }
499  }
500 
501  for(int i=0;i<90;i++){
502  fHist_VZERO_Mult_vsRun[i] = NULL;
503  }
504 
505 
506  //fDataSet="2010";
507  //fAnalysisSet="DoGainEq";
508  //sCentEstimator="V0";
509 }
510 
511 
512 
513 
514 
515 //________________________________________________________________________
517 {
518  delete fListHistos;
519  delete fListZDCQxy;
520  delete fListZDCWgt;
521  delete fListDummy1;
522  delete fListHijing;
523 
524  delete fMultSelection;
525  delete fAnalysisUtil; // it is '= new' !!!
526 
527 
528  //these histograms are not in any list:
529  //therefore, deleted manually.
530  //delete *fHist_ChanWgt_ZDCC; //can't delete, Execption thrown.!! why?
531  //delete *fHist_ChanWgt_ZDCA;
532  //delete *fHist_Vx_ArrayFinder;
533  //delete *fHist_Vy_ArrayFinder;
534  //delete *fHist_Vz_ArrayFinder;
535 
536 
537  //printf("\n\n ~AliAnalysisTaskZDCGainEq::Destructor is called..!!\n\n");
538 }
539 
540 //________________________________________________________________________
542 {
543 
544  Int_t runArray_2010[89] = {139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137243, 137236, 137235, 137232, 137231, 137162, 137161};
545 
546  Int_t runArray_2011[68] = {167915, 168115, 168460, 169035, 169238, 169859, 170228, 167920, 168310, 168464, 169091, 169411, 169923, 170230, 167985, 168311, 168467, 169094, 169415, 170027, 170268, 167987, 168322, 168511, 169138, 169417, 170081, 170269, 167988, 168325, 168512, 169144, 169835, 170155, 170270, 168069, 168341, 168514, 169145, 169837, 170159, 170306, 168076, 168342, 168777, 169148, 169838, 170163, 170308, 168105, 168361, 168826, 169156, 169846, 170193, 170309, 168107, 168362, 168988, 169160, 169855, 170203, 168108, 168458, 168992, 169167, 169858, 170204};
547 
548  Int_t runArray_2015[90] = {246994, 246991, 246989, 246984, 246982, 246980, 246948, 246945, 246928, 246871, 246870, 246867, 246865, 246864, 246859, 246858, 246851, 246847, 246846, 246845, 246844, 246810, 246809, 246808, 246807, 246805, 246804, 246766, 246765, 246763, 246760, 246759, 246758, 246757, 246751, 246750, 246676, 246675, 246540, 246495, 246493, 246488, 246487, 246434, 246431, 246428, 246424, 246276, 246275, 246272, 246271, 246225, 246222, 246217, 246185, 246182, 246181, 246180, 246178, 246153, 246152, 246151, 246148, 246115, 246113, 246089, 246087, 246053, 246052, 246049, 246048, 246042, 246037, 246036, 246012, 246003, 246001, 245963, 245954, 245952, 245949, 245923, 245833, 245831, 245829, 245705, 245702, 245700, 245692, 245683};
549 
550 
551  if(fDataSet=="2010"){
552  frunflag = 89;
553  for(int i=0;i<frunflag;i++)
554  runNums[i] = runArray_2010[i];
555  }
556  if(fDataSet=="2011"){
557  frunflag = 10; //<--------- 2011 runnumbers have to be checked and put...
558  for(int i=0;i<frunflag;i++)
559  runNums[i] = runArray_2011[i];
560  }
561  if(fDataSet=="2015"){
562  frunflag = 90;
563  for(int i=0;i<frunflag;i++)
564  runNums[i] = runArray_2015[i];
565  }
566 
567  fListHistos = new TList();
568  fListHistos->SetOwner(kTRUE);
569 
570  fHist_Event_count = new TH1F("fHist_Event_count"," ",20,0,20);
571  fHist_Event_count->GetXaxis()->SetBinLabel(1,"Called Exec()");
572  fHist_Event_count->GetXaxis()->SetBinLabel(2,"AOD Exist");
573  fHist_Event_count->GetXaxis()->SetBinLabel(3,"Pass VzCut");
574  fHist_Event_count->GetXaxis()->SetBinLabel(4,"Pass VxCut");
575  fHist_Event_count->GetXaxis()->SetBinLabel(5,"Pass VyCut");
576  fHist_Event_count->GetXaxis()->SetBinLabel(6,"NotPileUp");
577  fHist_Event_count->GetXaxis()->SetBinLabel(7,"ZNC Ei>=0");
578  fHist_Event_count->GetXaxis()->SetBinLabel(8,"ZNA Ei>=0");
579  fHist_Event_count->GetXaxis()->SetBinLabel(9,"|QnC| < 1.5");
580  fHist_Event_count->GetXaxis()->SetBinLabel(10,"|QnA| < 1.5");
581  fHist_Event_count->GetXaxis()->SetBinLabel(11,"#Psi_{A}=0 && #Psi_{C}=0");
582  fHist_Event_count->GetXaxis()->SetBinLabel(12,"QyA=0 && QyC=0");
584 
585  fPileUpCount = new TH1F("fPileUpCount", "fPileUpCount", 9, 0., 9.);
586  fPileUpCount->GetXaxis()->SetBinLabel(1,"plpMV");
587  fPileUpCount->GetXaxis()->SetBinLabel(2,"fromSPD");
588  fPileUpCount->GetXaxis()->SetBinLabel(3,"RefMultiplicityComb08");
589  fPileUpCount->GetXaxis()->SetBinLabel(4,"IncompleteDAQ");
590  fPileUpCount->GetXaxis()->SetBinLabel(5,"abs(V0M-CL1)>7.5");
591  fPileUpCount->GetXaxis()->SetBinLabel(6,"missingVtx");
592  fPileUpCount->GetXaxis()->SetBinLabel(7,"inconsistentVtx");
593  fPileUpCount->GetXaxis()->SetBinLabel(8,"multESDTPCDif");
594  fPileUpCount->GetXaxis()->SetBinLabel(9,"extraPileUpMultSel");
596 
597  fPileUpMultSelCount = new TH1F("fPileUpMultSelCount", "fPileUpMultSelCount", 8, 0., 8.);
598  fPileUpMultSelCount->GetXaxis()->SetBinLabel(1,"IsNotPileup");
599  fPileUpMultSelCount->GetXaxis()->SetBinLabel(2,"IsNotPileupMV");
600  fPileUpMultSelCount->GetXaxis()->SetBinLabel(3,"IsNotPileupInMultBins");
601  fPileUpMultSelCount->GetXaxis()->SetBinLabel(4,"InconsistentVertices");
602  fPileUpMultSelCount->GetXaxis()->SetBinLabel(5,"TrackletVsCluster");
603  fPileUpMultSelCount->GetXaxis()->SetBinLabel(6,"AsymmetricInVZERO");
604  fPileUpMultSelCount->GetXaxis()->SetBinLabel(7,"IncompleteDAQ");
605  fPileUpMultSelCount->GetXaxis()->SetBinLabel(8,"GoodVertex2016");
607 
608  fHist_Task_config = new TH1F("fTask_Configuration", "Task Configuration", 20, 0., 20.);
609  fHist_Task_config->GetXaxis()->SetBinLabel(1,"IsZDCQAon");
610  fHist_Task_config->GetXaxis()->SetBinLabel(2,"IsCentV0M");
611  fHist_Task_config->GetXaxis()->SetBinLabel(3,"IsCentTPC");
612  fHist_Task_config->GetXaxis()->SetBinLabel(4,"IsCentCL1");
613  fHist_Task_config->GetXaxis()->SetBinLabel(5,"IsPileUpOn");
614  fHist_Task_config->GetXaxis()->SetBinLabel(6,"IsPileUpTightOn");
615  fHist_Task_config->GetXaxis()->SetBinLabel(7,"IsFillGainEq");
616  fHist_Task_config->GetXaxis()->SetBinLabel(8,"IsDoGainEq");
617  fHist_Task_config->GetXaxis()->SetBinLabel(9,"IsAvailGainFile");
618  fHist_Task_config->GetXaxis()->SetBinLabel(10,"IsFillCosSin");
619  fHist_Task_config->GetXaxis()->SetBinLabel(11,"IsDoRecenter");
620  fHist_Task_config->GetXaxis()->SetBinLabel(12,"IsAvailRecntFile");
621  fHist_Task_config->GetXaxis()->SetBinLabel(13,"IsRunByRun");
622  fHist_Task_config->GetXaxis()->SetBinLabel(14,"IsCentCutforShift");
623  fHist_Task_config->GetXaxis()->SetBinLabel(15,"IsApplyShiftCorr");
624  fHist_Task_config->GetXaxis()->SetBinLabel(16,"IsShiftCorrVsCent");
625  fHist_Task_config->GetXaxis()->SetBinLabel(17,"IsTrigonoMetricQn");
627 
628 
629  fHist_CutParameters = new TH1F("fTask_CutParameters", "Variable Cut Values", 10, 0., 10.);
630  fHist_CutParameters->GetXaxis()->SetBinLabel(1,"VzCutLowValue");
631  fHist_CutParameters->GetXaxis()->SetBinLabel(2,"VzCutHighValue");
632  fHist_CutParameters->GetXaxis()->SetBinLabel(3,"NBins_Vz");
633  fHist_CutParameters->GetXaxis()->SetBinLabel(4,"VxCutHighValue");
634  fHist_CutParameters->GetXaxis()->SetBinLabel(5,"VxCutLowValue");
635  fHist_CutParameters->GetXaxis()->SetBinLabel(6,"NBins_Vx");
636  fHist_CutParameters->GetXaxis()->SetBinLabel(7,"VyCutHighValue");
637  fHist_CutParameters->GetXaxis()->SetBinLabel(8,"VyCutLowValue");
638  fHist_CutParameters->GetXaxis()->SetBinLabel(9,"NBins_Vy");
640 
641  fHist_ZeroQnXY_Conter = new TH1F("fHist_ZeroQnXY_Conter","", 20, 0, 20);
642  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(1,"QxC = 0 (w/o)");
643  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(2,"QxC = 0 (wi)");
644  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(3,"QyC = 0 (w/o)");
645  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(4,"QyC = 0 (wi)");
646  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(5,"QxA = 0 (w/o)");
647  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(6,"QxA = 0 (wi)");
648  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(7,"QyA = 0 (w/o)");
649  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(8,"QyA = 0 (wi)");
650  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(9, "QxC = 0 && QyC = 0 (w/o)");
651  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(10,"QxC = 0 && QyC = 0 (wi)");
652  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(11,"QxA = 0 && QyA = 0 (w/o)");
653  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(12,"QxA = 0 && QyA = 0 (wi)");
654  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(13,"QxA,QyA,QxC,QyC= 0 (w/o)");
655  fHist_ZeroQnXY_Conter->GetXaxis()->SetBinLabel(14,"QxA,QyA,QxC,QyC= 0 (wi)");
657 
658 
659 
660  fHist_Cent_woZDCcut = new TH1F("fHist_Cent_before_ZDCcut"," ",100,0,100);
662  fHist_Cent_wiZDCcut = new TH1F("fHist_Cent_afterr_ZDCcut"," ",100,0,100);
664 
665 
666 
667 
668 
669  //-------- define and add the recenter histograms ----------------
670  if(fDataSet=="2010") {
671  //vxBin = 9;
672  //vyBin = 9;
673  //vzBin = 10;
674 
675  VxCut[0] = -0.030;
676  VxCut[1] = 0.015;
677  VyCut[0] = 0.150;
678  VyCut[1] = 0.204;
679  VzCut[0] = -10.0;
680  VzCut[1] = 9.4;
681  }
682 
683  if(fDataSet=="2015"){
684  //vxBin = 8;
685  //vyBin = 8;
686  //vzBin = 10;
687 
688  VxCut[0] = 0.060;
689  VxCut[1] = 0.086;
690  VyCut[0] = 0.321;
691  VyCut[1] = 0.345;
692  VzCut[0] = -10.0;
693  VzCut[1] = 10.0;
694  }
695 
696  if(fDataSet=="2011"){
697  AliDebug(2,"\n\n !!** WARNING ***!! \n cuts not defined for DATASET: %s\n ...EXIT...\n\n)");
698  exit(1);
699  }
700 
701  const int NbinVt = vyBin*vxBin;
702 
703  fHist_Vx_ArrayFinder = new TH1F("fHist_Vx_ArrayFinder","",vxBin,VxCut[0],VxCut[1]);
704  fHist_Vy_ArrayFinder = new TH1F("fHist_Vy_ArrayFinder","",vyBin,VyCut[0],VyCut[1]);
705  fHist_Vz_ArrayFinder = new TH1F("fHist_Vz_ArrayFinder","",vzBin,VzCut[0],VzCut[1]);
706 
707  fHist_Vxy_RunAveraged = new TH2F("fHist_Vxy_RunAveraged","Vy Vs Vx (RbR)",100,0.050,0.10,100,0.31,0.36);
709 
710 
711  fHist_ZDCC_AvgQx_VsRun = new TProfile2D(Form("fHist_ZDCC_AvgQx_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
713  fHist_ZDCC_AvgQy_VsRun = new TProfile2D(Form("fHist_ZDCC_AvgQy_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
715 
716  fHist_ZDCA_AvgQx_VsRun = new TProfile2D(Form("fHist_ZDCA_AvgQx_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
718  fHist_ZDCA_AvgQy_VsRun = new TProfile2D(Form("fHist_ZDCA_AvgQy_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
720 
721  fHist_ZDC_AvgXXminusYY_VsRun = new TProfile2D(Form("fHist_ZDCC_AvgXXminusYY_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
723  fHist_ZDC_AvgXYplusXY_VsRun = new TProfile2D(Form("fHist_ZDCC_AvgXYplusXY_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
725 
726 
727  fHist_ZDC_dTermXXYY_VsRun = new TProfile2D(Form("fHist_ZDC_dTermXXYY_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
729  fHist_ZDC_dTermXYXY_VsRun = new TProfile2D(Form("fHist_ZDC_dTermXYXY_VsCentRun"),"",60,0,60,90,0,90,""); //cent,run
731 
732 
733  //Shift histograms: Fill Cos(nPsi) Sin(nPsi) vs Cent,Run
734  for(int i=0; i<4; i++){
735  fHist_ZDCC_AvgCos_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgCos%dPsiC_VsCentRun",i+1),"",60,0,60,90,0,90,""); //cent,run
737  fHist_ZDCA_AvgCos_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgCos%dPsiA_VsCentRun",i+1),"",60,0,60,90,0,90,"");
739 
740  fHist_ZDCC_AvgSin_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgSin%dPsiC_VsCentRun",i+1),"",60,0,60,90,0,90,"");
742  fHist_ZDCA_AvgSin_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgSin%dPsiA_VsCentRun",i+1),"",60,0,60,90,0,90,"");
744 
745  fHist_ZDC_AvgCosPsiSum_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgCos%dPsi_AplusC_VsCentRun",i+1),"",60,0,60,90,0,90,"");
747  fHist_ZDC_AvgSinPsiSum_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgSin%dPsi_AplusC_VsCentRun",i+1),"",60,0,60,90,0,90,"");
749 
750  fHist_ZDC_AvgCosPsiDif_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgCos%dPsi_AminusC_VsCentRun",i+1),"",60,0,60,90,0,90,"");
752  fHist_ZDC_AvgSinPsiDif_VsRun[i] = new TProfile2D(Form("fHist_ZDC_AvgSin%dPsi_AminusC_VsCentRun",i+1),"",60,0,60,90,0,90,"");
754  }
755 
756 
757 
758 
759  fHist_XXYY_vs_Cent_woCorr[0] = new TProfile(Form("fHist_XXminusYY_vs_Cent_woCorr"),"XX-YY",90,0,90,"");
761  fHist_XXYY_vs_Cent_woCorr[1] = new TProfile(Form("fHist_XYplusXY_vs_Cent_woCorr"), "XY+XY",90,0,90,"");
763  fHist_XXYY_vs_Cent_wiCorr[0] = new TProfile(Form("fHist_XXminusYY_vs_Cent_wiCorr"),"XX-YY",90,0,90,"");
765  fHist_XXYY_vs_Cent_wiCorr[1] = new TProfile(Form("fHist_XYplusXY_vs_Cent_wiCorr"), "XY+XY",90,0,90,"");
767 
768  fHist_Event_counter_vRun = new TH1F("fHist_Event_counter_vRun","",95,0,95);
770 
771 
772  char name[100];
773 
774 
775  if(fAnalysisSet=="FillGainEq") {
776 
777  fHist_Vx_vs_runnum = new TProfile("fHist_Vx_vs_runnum","<Vx>_vs_runnum",frunflag,0,frunflag,"s");
779  fHist_Vy_vs_runnum = new TProfile("fHist_Vy_vs_runnum","<Vy>_vs_runnum",frunflag,0,frunflag,"s");
781  fHist_Vz_vs_runnum = new TProfile("fHist_Vz_vs_runnum","<Vz>_vs_runnum",frunflag,0,frunflag,"s");
783 
784  for(int i=0;i<vzBin;i++) {
785  fHist_ZDCC_En_CommonCh[i] = new TProfile2D(Form("fHist_ZDCC_En_CommonCh_Vz%d",i+1),"",100,0,100,NbinVt,0,NbinVt,"");
786  fHist_ZDCA_En_CommonCh[i] = new TProfile2D(Form("fHist_ZDCA_En_CommonCh_Vz%d",i+1),"",100,0,100,NbinVt,0,NbinVt,"");
789  }
790  for(int i=0;i<frunflag;i++) {
791  //store: ZDC energy for gain calibration:
792  fHist_ZDCA_En_Run[i] = new TProfile2D(Form("fHist_ZDCA_En_Run%d",runNums[i]),"",100,0,100,5,0,5,"");
794  fHist_ZDCC_En_Run[i] = new TProfile2D(Form("fHist_ZDCC_En_Run%d",runNums[i]),"",100,0,100,5,0,5,"");
796  }
797  }
798 
799 
800  if(bFillZDCQAon){
801 
802  fHist_Task_config->Fill(0.5);
803 
804  if(fAnalysisSet=="FillGainEq"){
805  fHist_Psi1_ZDCC_wGainCorr = new TH1F("fHist_Psi1_ZDCC_woGainCorr","", 200, 0,2.*TMath::Pi());
806  fHist_Psi1_ZDCA_wGainCorr = new TH1F("fHist_Psi1_ZDCA_woGainCorr","", 200, 0,2.*TMath::Pi());
807  }
808  else{
809  fHist_Psi1_ZDCC_wGainCorr = new TH1F("fHist_Psi1_ZDCC_wiGainCorr","", 200, 0,2.*TMath::Pi());
810  fHist_Psi1_ZDCA_wGainCorr = new TH1F("fHist_Psi1_ZDCA_wiGainCorr","", 200, 0,2.*TMath::Pi());
811  }
812 
815 
816  fHist_Psi1_ZDCC_wRectCorr = new TH1F("fHist_Psi1_ZDCC_wiRectCorr","", 200, 0,2.*TMath::Pi());
818  fHist_Psi1_ZDCA_wRectCorr = new TH1F("fHist_Psi1_ZDCA_wiRectCorr","", 200, 0,2.*TMath::Pi());
820 
821  fHist_Psi1_ZDCC_RunByRun = new TH2F("fHist_Psi1_ZDCC_RunByRun","", 100, 0, 100, 200, 0,2.*TMath::Pi());
823  fHist_Psi1_ZDCA_RunByRun = new TH2F("fHist_Psi1_ZDCA_RunByRun","", 100, 0, 100, 200, 0,2.*TMath::Pi());
825 
826  fHist_Psi1_ZDCC_wCorrFull = new TH1F("fHist_Psi1_ZDCC_wCorrFull","", 200, 0,2.*TMath::Pi());
828  fHist_Psi1_ZDCA_wCorrFull = new TH1F("fHist_Psi1_ZDCA_wCorrFull","", 200, 0,2.*TMath::Pi());
830 
831 
832  fHist_PsiSumAC_woCorr = new TH1F("fHist_PsiSumAC_woCorr","", 200, 0,2.*TMath::Pi());
834  fHist_PsiSumAC_wiCorr = new TH1F("fHist_PsiSumAC_wiCorr","", 200, 0,2.*TMath::Pi());
836 
837 
838  fHist_PsiSumAC_ZeroQn = new TH1F("fHist_PsiSumAC_ZeroQn","", 200, 0,2.*TMath::Pi());
840  fHist_PsiZDCA_ZeroQn = new TH1F("fHist_PsiZDCA_ZeroQn"," ", 200, 0,2.*TMath::Pi());
842  fHist_PsiZDCC_ZeroQn = new TH1F("fHist_PsiZDCC_ZeroQn"," ", 200, 0,2.*TMath::Pi());
844 
845 
846  TString sNameQn[4] = {"Xa","Xc","Ya","Yc"};
847  TString sNameQn2[4] = {"XaXc","YaYc","XcYa","YcXa"};
848  TString sNameVs[5] = {"Cent","Mult","Vx","Vy","Vz"};
849  Int_t nBinNumVs[5] = {100, 100, 50, 50, 400}; // number of bins for "Cent", "Mult", "Vx","Vy","Vz"
850  Double_t lBinLowVs[5] = { 0, 0, VxCut[0], VyCut[0], -10}; // bin low value: "Cent", "Mult", "Vx", "Vy", "Vz"
851  Double_t lBinHighVs[5] = {100, 4000, VxCut[1], VyCut[1], 10}; // bin high value: "Cent", "Mult", "Vx", "Vy", "Vz"
852  Double_t fNormCent[11] = {0,5,10,20,30,40,50,60,70,80,90};
853 
854  fHist_NormalCentralityBins = new TH1F("fHist_NormalCentralityBins","",10,fNormCent);
856 
857  //here:
858  for(int i=0;i<6;i++) {
859  for(int j=0;j<4;j++) {
860  sprintf(name,"fHist_%s_vs_Cx_Cy_woCorr_PosMag_Cent%d",static_cast<const char*>(sNameQn2[j]),i);
861  fHist_XX_vs_QnC_2DwoCorr_PosMag[j][i] = new TProfile2D(name,"",100, -1.0, 1.0, 100, -1.0, 1.0, "");
863 
864  sprintf(name,"fHist_%s_vs_Ax_Ay_woCorr_PosMag_Cent%d",static_cast<const char*>(sNameQn2[j]),i);
865  fHist_XX_vs_QnA_2DwoCorr_PosMag[j][i] = new TProfile2D(name,"",100, -1.0, 1.0, 100, -1.0, 1.0, "");
867 
868  sprintf(name,"fHist_%s_vs_Cx_Cy_woCorr_NegMag_Cent%d",static_cast<const char*>(sNameQn2[j]),i);
869  fHist_XX_vs_QnC_2DwoCorr_NegMag[j][i] = new TProfile2D(name,"",100, -1.0, 1.0, 100, -1.0, 1.0, "");
871 
872  sprintf(name,"fHist_%s_vs_Ax_Ay_woCorr_NegMag_Cent%d",static_cast<const char*>(sNameQn2[j]),i);
873  fHist_XX_vs_QnA_2DwoCorr_NegMag[j][i] = new TProfile2D(name,"",100, -1.0, 1.0, 100, -1.0, 1.0, "");
875  }
876  }
877 
878 
879 
880  for(int i=0;i<4;i++) {
881  sprintf(name,"fHist_%s_wiCorr_RunByRun",static_cast<const char*>(sNameQn[i]));
882  fHist_Qx_wiCorr_RunByRun[i] = new TProfile(name,"", 90, 0, 90,"");
884 
885  sprintf(name,"fHist_%s_TrigonoMetric_woCorr",static_cast<const char*>(sNameQn[i]));
886  fHist_Qx_Trig_woCorr[i] = new TProfile(name,"", 90, 0, 90,""); //centrality range
888  sprintf(name,"fHist_%s_TrigonoMetric_woCorr",static_cast<const char*>(sNameQn2[i]));
889  fHist_XX_Trig_woCorr[i] = new TProfile(name,"", 90, 0, 90,""); //centrality range
891 
892  sprintf(name,"fHist_%s_TrigonoMetric_wiCorr",static_cast<const char*>(sNameQn[i]));
893  fHist_Qx_Trig_wiCorr[i] = new TProfile(name,"", 90, 0, 90,""); //centrality range
895  sprintf(name,"fHist_%s_TrigonoMetric_wiCorr",static_cast<const char*>(sNameQn2[i]));
896  fHist_XX_Trig_wiCorr[i] = new TProfile(name,"", 90, 0, 90,""); //centrality range
898 
899  for(int j=0;j<5;j++) {//fHist_Qx_vs_Obs_woCorr
900  //store: X,Y position for recenter:
901  sprintf(name,"fHist_%s_vs_%s_woCorr",static_cast<const char*>(sNameQn[i]),static_cast<const char*>(sNameVs[j]));
902  fHist_Qx_vs_Obs_woCorr[i][j] = new TProfile(name,"", nBinNumVs[j], lBinLowVs[j], lBinHighVs[j],"");
904 
905  sprintf(name,"fHist_%s_vs_%s_woCorr",static_cast<const char*>(sNameQn2[i]),static_cast<const char*>(sNameVs[j]));
906  fHist_XX_vs_Obs_woCorr[i][j] = new TProfile(name,"", nBinNumVs[j], lBinLowVs[j], lBinHighVs[j],"");
908 
909  if(bFillCosSin && fAnalysisSet=="FillGainEq") {
910  sprintf(name,"fHist_%s_vs_%s_woCorrCosSin",static_cast<const char*>(sNameQn[i]),static_cast<const char*>(sNameVs[j]));
911  }
912  else{
913  sprintf(name,"fHist_%s_vs_%s_wiCorr",static_cast<const char*>(sNameQn[i]),static_cast<const char*>(sNameVs[j]));
914  }
915  fHist_Qx_vs_Obs_wiCorr[i][j] = new TProfile(name,"", nBinNumVs[j], lBinLowVs[j], lBinHighVs[j],"");
917 
918  if(bFillCosSin && fAnalysisSet=="FillGainEq") {
919  sprintf(name,"fHist_%s_vs_%s_woCorrCosSin",static_cast<const char*>(sNameQn2[i]),static_cast<const char*>(sNameVs[j]));
920  }
921  else{
922  sprintf(name,"fHist_%s_vs_%s_wiCorr",static_cast<const char*>(sNameQn2[i]),static_cast<const char*>(sNameVs[j]));
923  }
924 
925  fHist_XX_vs_Obs_wiCorr[i][j] = new TProfile(name,"", nBinNumVs[j], lBinLowVs[j], lBinHighVs[j],"");
927  }
928  }
929  }
930 
931 
932  if(vzBin>20){
933  printf("\n\n::UserCreateOutPutObject()\n Vz Binning more than 20 not allowed\n ==> Exit <== \n\n");
934  exit(1);
935  }
936 
937  const int VzBinIter = (const int) vzBin;
938 
939 
940  //filling the Q vectors for recenter:
941  if(fAnalysisSet=="DoGainEq") {
942  if(!bApplyRecent) {
943 
944  fListZDCQxy = new TList();
945  fListZDCQxy->SetOwner(kTRUE);
946 
947  if(!bRunAveragedQn) {
948  for(int i=0;i<frunflag;i++) {
949  for(int j=0;j<VzBinIter;j++) {
950  fHist_znCx_V0_VxVy[i][j] = new TProfile2D(Form("fHist_znCx_V0_Run%d_Vz%d",runNums[i],j+1),"",NbinVt,0,NbinVt,90,0,90);
951  fHist_znCy_V0_VxVy[i][j] = new TProfile2D(Form("fHist_znCy_V0_Run%d_Vz%d",runNums[i],j+1),"",NbinVt,0,NbinVt,90,0,90);
952  fHist_znAx_V0_VxVy[i][j] = new TProfile2D(Form("fHist_znAx_V0_Run%d_Vz%d",runNums[i],j+1),"",NbinVt,0,NbinVt,90,0,90);
953  fHist_znAy_V0_VxVy[i][j] = new TProfile2D(Form("fHist_znAy_V0_Run%d_Vz%d",runNums[i],j+1),"",NbinVt,0,NbinVt,90,0,90);
954 
955  fListZDCQxy->Add(fHist_znCx_V0_VxVy[i][j]);
956  fListZDCQxy->Add(fHist_znCy_V0_VxVy[i][j]);
957  fListZDCQxy->Add(fHist_znAx_V0_VxVy[i][j]);
958  fListZDCQxy->Add(fHist_znAy_V0_VxVy[i][j]);
959  }
960  }
961  }
962  else{
963  for(int j=0;j<VzBinIter;j++) {
964  fHist_znCx_V0_VxVy[0][j] = new TProfile2D(Form("fHist_znCx_V0_Run%d_Vz%d",0,j+1),"",NbinVt,0,NbinVt,90,0,90);
965  fHist_znCy_V0_VxVy[0][j] = new TProfile2D(Form("fHist_znCy_V0_Run%d_Vz%d",0,j+1),"",NbinVt,0,NbinVt,90,0,90);
966  fHist_znAx_V0_VxVy[0][j] = new TProfile2D(Form("fHist_znAx_V0_Run%d_Vz%d",0,j+1),"",NbinVt,0,NbinVt,90,0,90);
967  fHist_znAy_V0_VxVy[0][j] = new TProfile2D(Form("fHist_znAy_V0_Run%d_Vz%d",0,j+1),"",NbinVt,0,NbinVt,90,0,90);
968 
969  fListZDCQxy->Add(fHist_znCx_V0_VxVy[0][j]);
970  fListZDCQxy->Add(fHist_znCy_V0_VxVy[0][j]);
971  fListZDCQxy->Add(fHist_znAx_V0_VxVy[0][j]);
972  fListZDCQxy->Add(fHist_znAy_V0_VxVy[0][j]);
973  }
974  }
975  }
976  }
977 
978  for(int i=0;i<90;i++){
979  fHist_VZERO_Mult_vsRun[i] = new TProfile2D(Form("fHist_V0Mult_vsCent_Run%d",runArray_2015[i]),"",90,0,90,64,0,64,""); //cent,channel
980  //added to second list
981  }
982 
983 
984  Double_t centRange[12] = {0,5,10,20,30,40,50,60,70,80,90,100};
985  //Double_t pTRange[21] = {0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0,2.2,2.4,2.6,2.8,3.0,3.3,3.6,4.0,4.5,5.0};
986  Double_t pTRange[28] = {0,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.,1.2,1.4,1.6,1.8,2.,2.33,2.66,3.,3.5,4.,5.,6.,8.,10.,14.,20.,30.,50.};
987  const int fPtDiffNBins = 27;
988  TString sNameComp[4] = {"uxCx","uyCy","uxAx","uyAy"};
989 
990 
991  fHist_Corr3p_ZDN_Norm_PN = new TProfile("fHist_Corr3p_ZDN_Norm_PosNeg","opposit charge correlator",11,centRange,"");
992  fHist_Corr3p_ZDN_Norm_PN->Sumw2();
994  fHist_Corr3p_ZDN_Norm_PP = new TProfile("fHist_Corr3p_ZDN_Norm_PosPos","pos-pos charge correlator",11,centRange,"");
995  fHist_Corr3p_ZDN_Norm_PP->Sumw2();
997  fHist_Corr3p_ZDN_Norm_NN = new TProfile("fHist_Corr3p_ZDN_Norm_NegNeg","neg-neg charge correlator",11,centRange,"");
998  fHist_Corr3p_ZDN_Norm_NN->Sumw2();
1000 
1001  fHist_Corr3p_ZDN_Cent_PN = new TProfile("fHist_Corr3p_ZDN_Cent_PosNeg","opposit charge correlator",90,0,90,"");
1002  fHist_Corr3p_ZDN_Cent_PN->Sumw2();
1004  fHist_Corr3p_ZDN_Cent_PP = new TProfile("fHist_Corr3p_ZDN_Cent_PosPos","pos-pos charge correlator",90,0,90,"");
1005  fHist_Corr3p_ZDN_Cent_PP->Sumw2();
1007  fHist_Corr3p_ZDN_Cent_NN = new TProfile("fHist_Corr3p_ZDN_Cent_NegNeg","neg-neg charge correlator",90,0,90,"");
1008  fHist_Corr3p_ZDN_Cent_NN->Sumw2();
1010 
1011  fHist_Reso2EP_TPC_Norm = new TProfile("fHist_Reso2EP_TPC_Norm","SubEvent Resolution",11,centRange,"");
1012  fHist_Reso2EP_TPC_Norm->Sumw2();
1014  fHist_Reso2EP_TPC_Cent = new TProfile("fHist_Reso2EP_TPC_Cent","SubEvent Resolution",90,0,90,"");
1015  fHist_Reso2EP_TPC_Cent->Sumw2();
1017 
1018 
1019  if(bApplyRecent) {
1020  //v2 integrated:
1021  fHist_v2xV1_ZDN_Norm_All = new TProfile("fHist_v2xV1_ZDN_Norm_All","v2 X V1^2 (ZDC) all terms",11,centRange,"");
1022  fHist_v2xV1_ZDN_Norm_All->Sumw2();
1024  fHist_v2xV1_ZDN_Cent_All = new TProfile("fHist_v2xV1_ZDN_Cent_All","v2 X V1^2 (ZDC) all terms",90, 0, 90,"");
1025  fHist_v2xV1_ZDN_Cent_All->Sumw2();
1027  fHist_v2xV1_ZDN_Refm_All = new TProfile("fHist_v2xV1_ZDN_Refm_All","v2 X V1^2 (ZDC) all terms", 40, 0, 4000,"");
1028  fHist_v2xV1_ZDN_Refm_All->Sumw2();
1030 
1031  //v3 integrated:
1032  fHist_v3xV1_ZDN_Norm_Comb1 = new TProfile("fHist_v3xV1_ZDN_Norm_Comb1","v3 X V1^2 (ZDC) all terms",11,centRange,"");
1033  fHist_v3xV1_ZDN_Norm_Comb1->Sumw2();
1035  fHist_v3xV1_ZDN_Cent_Comb1 = new TProfile("fHist_v3xV1_ZDN_Cent_Comb1","v3 X V1^2 (ZDC) all terms",90, 0, 90,"");
1036  fHist_v3xV1_ZDN_Cent_Comb1->Sumw2();
1038  fHist_v3xV1_ZDN_Norm_Comb2 = new TProfile("fHist_v3xV1_ZDN_Norm_Comb2","v3 X V1^2 (ZDC) all terms",11,centRange,"");
1039  fHist_v3xV1_ZDN_Norm_Comb2->Sumw2();
1041  fHist_v3xV1_ZDN_Cent_Comb2 = new TProfile("fHist_v3xV1_ZDN_Cent_Comb2","v3 X V1^2 (ZDC) all terms",90, 0, 90,"");
1042  fHist_v3xV1_ZDN_Cent_Comb2->Sumw2();
1044 
1045  //v4 integrated:
1046  fHist_v4xV1_ZDN_Norm_Comb1 = new TProfile("fHist_v4xV1_ZDN_Norm_Comb1","v4 X V1^2 (ZDC) all terms",11,centRange,"");
1047  fHist_v4xV1_ZDN_Norm_Comb1->Sumw2();
1049  fHist_v4xV1_ZDN_Cent_Comb1 = new TProfile("fHist_v4xV1_ZDN_Cent_Comb1","v4 X V1^2 (ZDC) all terms",90, 0, 90,"");
1050  fHist_v4xV1_ZDN_Cent_Comb1->Sumw2();
1052 
1053  //Summed ZDC resolution:
1054  fHist_ZDN_resol_Norm_All = new TProfile("fHist_ZDN_resol_Norm_All","Resol. V1^2(ZDC) All",11,centRange,"");
1055  fHist_ZDN_resol_Norm_All->Sumw2();
1057  fHist_ZDN_resol_Cent_All = new TProfile("fHist_ZDN_resol_Cent_All","Resol. V1^2(ZDC) All",90, 0, 90,"");
1058  fHist_ZDN_resol_Cent_All->Sumw2();
1060  fHist_ZDN_resol_Refm_All = new TProfile("fHist_ZDN_resol_Refm_All","Resol. V1^2(ZDC) All",40, 0, 4000,"");
1061  fHist_ZDN_resol_Refm_All->Sumw2();
1063 
1064  //Individual ZDC resolutions vs cent:
1065  fHist_ZDN_resol_Norm_XX = new TProfile("fHist_ZDN_resol_Norm_XX","Resol. V1^2(ZDC) XX",11,centRange,"");
1066  fHist_ZDN_resol_Norm_XX->Sumw2();
1068  fHist_ZDN_resol_Norm_YY = new TProfile("fHist_ZDN_resol_Norm_YY","Resol. V1^2(ZDC) YY",11,centRange,"");
1069  fHist_ZDN_resol_Norm_YY->Sumw2();
1071  fHist_ZDN_resol_Cent_XX = new TProfile("fHist_ZDN_resol_Cent_XX","Resol. V1^2(ZDC) XX",90, 0, 90,"");
1072  fHist_ZDN_resol_Cent_XX->Sumw2();
1074  fHist_ZDN_resol_Cent_YY = new TProfile("fHist_ZDN_resol_Cent_YY","Resol. V1^2(ZDC) YY",90, 0, 90,"");
1075  fHist_ZDN_resol_Cent_YY->Sumw2();
1077 
1078 
1079 
1080  //v1 integrated, 4 terms, normal bin, fine Centr bin
1081  for(int i=0; i<4; i++) {
1082  sprintf(name,"fHist_v1_%s_ZDN_Norm",static_cast<const char*>(sNameComp[i]));
1083  fHist_v2xV1_ZDN_Norm_Sep[i] = new TProfile(name,"v1 vs Cent",11,centRange,"");
1084  fHist_v2xV1_ZDN_Norm_Sep[i]->Sumw2();
1086 
1087  sprintf(name,"fHist_v1_%s_ZDN_Cent",static_cast<const char*>(sNameComp[i]));
1088  fHist_v2xV1_ZDN_Cent_Sep[i] = new TProfile(name,"v1 vs Cent",100,0,100,"");
1089  fHist_v2xV1_ZDN_Cent_Sep[i]->Sumw2();
1091  }
1092  //v1 resulution, 2 terms, normal bin, fine Centr bin
1093  fHist_ZDN_resol_Norm_Sep[0] = new TProfile("fHist_ZDN_resol_XaXc_Norm"," XaXc vs Cent",11,centRange,"");
1094  fHist_ZDN_resol_Norm_Sep[0]->Sumw2();
1096  fHist_ZDN_resol_Norm_Sep[1] = new TProfile("fHist_ZDN_resol_YaYc_Norm"," YaYc vs Cent",11,centRange,"");
1097  fHist_ZDN_resol_Norm_Sep[1]->Sumw2();
1099 
1100  fHist_ZDN_resol_Cent_Sep[0] = new TProfile("fHist_ZDN_resol_XaXc_Cent"," XaXc vs Cent",100,0,100,"");
1101  fHist_ZDN_resol_Cent_Sep[0]->Sumw2();
1103  fHist_ZDN_resol_Cent_Sep[1] = new TProfile("fHist_ZDN_resol_YaYc_Cent"," YaYc vs Cent",100,0,100,"");
1104  fHist_ZDN_resol_Cent_Sep[1]->Sumw2();
1106 
1107 
1108 
1109  //v2 differential pT:
1110  for(int i=0; i<10; i++) {
1111  sprintf(name,"fHist_v2xV1_ZDN_pTDiff_Cent%d",i);
1112  fHist_v2xV1_ZDN_pTDiff_All[i] = new TProfile(name,"v2 X V1^2 pTdiff",fPtDiffNBins,pTRange);
1113  fHist_v2xV1_ZDN_pTDiff_All[i]->Sumw2();
1115  }
1116 
1117  //v3 differential Eta:
1118  for(int i=0; i<10; i++) {
1119  sprintf(name,"fHist_v3xV1_ZDN_EtaDiff_Comb1_Cent%d",i);
1120  fHist_v3xV1_ZDN_EtaDiff_Comb1[i] = new TProfile(name,"v3 X V1^2 Etadiff",10,-0.8,0.8);
1121  fHist_v3xV1_ZDN_EtaDiff_Comb1[i]->Sumw2();
1123  sprintf(name,"fHist_v3xV1_ZDN_EtaDiff_Comb2_Cent%d",i);
1124  fHist_v3xV1_ZDN_EtaDiff_Comb2[i] = new TProfile(name,"v3 X V1^2 Etadiff",10,-0.8,0.8);
1125  fHist_v3xV1_ZDN_EtaDiff_Comb2[i]->Sumw2();
1127  }
1128 
1129  //v4 differential pT:
1130  for(int i=0; i<10; i++) {
1131  sprintf(name,"fHist_v4xV1_ZDN_pTDiff_Cent%d",i);
1132  fHist_v4xV1_ZDN_pTDiff_All[i] = new TProfile(name,"v4 X V1^2 pTdiff",fPtDiffNBins,pTRange);
1133  fHist_v4xV1_ZDN_pTDiff_All[i]->Sumw2();
1135  }
1136 
1137 
1138  //v1 differential Eta, pT: not needed now.
1139  for(int i=0; i<10; i++) {
1140  for(int j=0; j<4; j++) {
1141  sprintf(name,"fHist_%s_ZDN_EtaDiff_Cent%d",static_cast<const char*>(sNameComp[j]),i);
1142  fHist_v1xV1_ZDN_EtaDiff[j][i] = new TProfile(name,"v1 Eta-diff", 5, -0.8, 0.8);
1143  fHist_v1xV1_ZDN_EtaDiff[j][i]->Sumw2();
1145 
1146  sprintf(name,"fHist_%s_ZDN_pTDiff_Cent%d",static_cast<const char*>(sNameComp[j]),i);
1147  fHist_v1xV1_ZDN_pTDiff[j][i] = new TProfile(name,"v1 Eta-diff", fPtDiffNBins, pTRange);
1148  fHist_v1xV1_ZDN_pTDiff[j][i]->Sumw2();
1149  fListHistos->Add(fHist_v1xV1_ZDN_pTDiff[j][i]);
1150  }
1151  }
1152 
1153  //------------ calculate centrality weight: ------------
1154  TH1F *fCent_fromDATA;
1155 
1156  if(fListZDCQxy) {
1157  fCent_fromDATA = (TH1F *) fListZDCQxy->FindObject("fHist_Cent_afterr_ZDCcut");
1158 
1159  for(int i=0;i<4;i++){
1160  fHist_ZDCC_AvgCosNPsi[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_AvgCos%dPsiC_VsCR",i+1));
1161  fHist_ZDCA_AvgCosNPsi[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_AvgCos%dPsiA_VsCR",i+1));
1162  fHist_ZDCC_AvgSinNPsi[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_AvgSin%dPsiC_VsCR",i+1));
1163  fHist_ZDCA_AvgSinNPsi[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_AvgSin%dPsiA_VsCR",i+1));
1164 
1165  fHist_ZDC_AvgCosNPsiAC[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_AvgCos%dPsiAplusC_VsCR",i+1));
1166  fHist_ZDC_AvgSinNPsiAC[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_AvgSin%dPsiAplusC_VsCR",i+1));
1167  }
1168 
1169  fHist_ZDCC_AvgQx_VsCR = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDCC_AvgQx_VsCR"));
1170  fHist_ZDCC_AvgQy_VsCR = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDCC_AvgQy_VsCR"));
1171  fHist_ZDCA_AvgQx_VsCR = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDCA_AvgQx_VsCR"));
1172  fHist_ZDCA_AvgQy_VsCR = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDCA_AvgQy_VsCR"));
1173 
1174  fHist_ZDC_dTermXXYY_VsCR = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_dTermXXYY_VsCR"));
1175  fHist_ZDC_dTermXYXY_VsCR = (TH2F *) fListZDCQxy->FindObject(Form("fHist_ZDC_dTermXYXY_VsCR"));
1176  }
1177  else{
1178  printf("\n\n ******** Running without Centrality weight, No Shift Correction !!******** \n\n");
1179  fCent_fromDATA = new TH1F("fCent_DATA","Centrality distribution",100,0,100);
1180  for(int i=1;i<=fCent_fromDATA->GetNbinsX();i++){
1181  fCent_fromDATA->SetBinContent(i,100);
1182  }
1183  for(int i=0;i<4;i++){
1184  fHist_ZDCC_AvgCosNPsi[i] = new TH2F(Form("fHist_ZDC_AvgCos%dPsiC_VsCR_dummy",i+1),"",60,0,60,90,0,90); //cent,run
1185  fHist_ZDCA_AvgCosNPsi[i] = new TH2F(Form("fHist_ZDC_AvgCos%dPsiA_VsCR_dummy",i+1),"",60,0,60,90,0,90);
1186  fHist_ZDCC_AvgSinNPsi[i] = new TH2F(Form("fHist_ZDC_AvgSin%dPsiC_VsCR_dummy",i+1),"",60,0,60,90,0,90);
1187  fHist_ZDCA_AvgSinNPsi[i] = new TH2F(Form("fHist_ZDC_AvgSin%dPsiA_VsCR_dummy",i+1),"",60,0,60,90,0,90);
1188 
1189  fHist_ZDC_AvgCosNPsiAC[i] = new TH2F(Form("fHist_ZDC_AvgCos%dPsiAplusC_VsCR_dummy",i+1),"",60,0,60,90,0,90);
1190  fHist_ZDC_AvgSinNPsiAC[i] = new TH2F(Form("fHist_ZDC_AvgSin%dPsiAplusC_VsCR_dummy",i+1),"",60,0,60,90,0,90);
1191  }
1192  fHist_ZDCC_AvgQx_VsCR = new TH2F(Form("fHist_ZDCC_AvgQx_VsCR_dummy"),"",60,0,60,90,0,90); //cent,run
1193  fHist_ZDCC_AvgQy_VsCR = new TH2F(Form("fHist_ZDCC_AvgQy_VsCR_dummy"),"",60,0,60,90,0,90);
1194  fHist_ZDCA_AvgQx_VsCR = new TH2F(Form("fHist_ZDCA_AvgQx_VsCR_dummy"),"",60,0,60,90,0,90);
1195  fHist_ZDCA_AvgQy_VsCR = new TH2F(Form("fHist_ZDCA_AvgQy_VsCR_dummy"),"",60,0,60,90,0,90);
1196  }
1197 
1198  Double_t Content,error;
1199  Double_t maxCount = -1;
1200  Int_t maxCent = -1;
1201  Double_t weight = 0.;
1202 
1203  for(int i=1;i<=fCent_fromDATA->GetNbinsX();i++){
1204  Content = fCent_fromDATA->GetBinContent(i);
1205  if(maxCount < Content){
1206  maxCount = Content;
1207  maxCent = i;
1208  }
1209  }
1210 
1211  fWeight_Cent = new TH1F("fWeight_Cent","Weight for centrality",100,0,100);
1212 
1213  for(int i=1;i<=fWeight_Cent->GetNbinsX();i++)
1214  {
1215  Content = fCent_fromDATA->GetBinContent(i);
1216  error = fCent_fromDATA->GetBinError(i);
1217  if(Content){
1218  weight = maxCount/Content;
1219  }
1220  else{
1221  weight = 0;
1222  }
1223  fWeight_Cent->SetBinContent(i,weight);
1224  fWeight_Cent->SetBinError(i,0.0);
1225  //cout<<"cent "<<i-1<<"-"<<i<<" \t wgt = "<<fWeight_Cent->GetBinContent(i)<<" error = "<<fWeight_Cent->GetBinError(i)<<endl;
1226  }
1227 
1228  fListHistos->Add(fWeight_Cent);
1229  //delete fCent_fromDATA;
1230 
1231 
1232 
1233  //---------Filter bit efficiency----------
1234  if(fListHijing) {
1235  for(int i=0;i<10;i++) {
1236  fFB_Efficiency_Cent[i] = (TH1D *) fListHijing->FindObject(Form("eff_unbiased_%d",i));
1237  //cout<<"cent = "<<i<<" name = "<<fFB_Efficiency_Cent[i]->GetName()<<endl;
1238  }
1239  }
1240  else{ // if MC efficiency not found then use weight = 1. Code won't crash.
1241  printf("\n\n !!***** Warning *****!! \n TList for FilterBit efficiency not found !!\n\n");
1242  for(int i=0;i<10;i++){
1243  fFB_Efficiency_Cent[i] = new TH1D(Form("eff_unbiased_%d",i),"",100,0,20);
1244  for(int j=1;j<=fFB_Efficiency_Cent[i]->GetNbinsX();j++){
1245  fFB_Efficiency_Cent[i]->SetBinContent(j,1.000);
1246  }
1247  }
1248  }
1249 
1250  } //if(bApplyRecent)
1251 
1252 
1253 
1254 
1255 
1256 
1257 
1258 
1259 
1260  if(sCentEstimator=="V0"){
1261  fHist_Task_config->Fill(1.5);
1262  }
1263  if(sCentEstimator=="TPC"){
1264  fHist_Task_config->Fill(2.5);
1265  }
1266  if(sCentEstimator=="CL1"){
1267  fHist_Task_config->Fill(3.5);
1268  }
1269  if(fRejectPileUp){
1270  fHist_Task_config->Fill(4.5);
1271  }
1272  if(fRejectPileUpTight){
1273  fHist_Task_config->Fill(5.5);
1274  }
1275  if(fAnalysisSet=="FillGainEq"){
1276  fHist_Task_config->Fill(6.5);
1277  }
1278  if(fAnalysisSet=="DoGainEq"){
1279  fHist_Task_config->Fill(7.5);
1280  if(fListZDCWgt){
1281  fHist_Task_config->Fill(8.5);
1282  }
1283  }
1284  if(bFillCosSin){
1285  fHist_Task_config->Fill(9.5);
1286  }
1287  if(bApplyRecent){
1288  fHist_Task_config->Fill(10.5);
1289  if(fListZDCQxy){
1290  fHist_Task_config->Fill(11.5);
1291  }
1292  }
1293  if(!bRunAveragedQn){
1294  fHist_Task_config->Fill(12.5);
1295  }
1296  if(bCentCutShift){
1297  fHist_Task_config->Fill(13.5);
1298  }
1299  if(bApplyShiftCorr){
1300  fHist_Task_config->Fill(14.5);
1301  }
1302  if(bShiftCorrOnCent){
1303  fHist_Task_config->Fill(15.5);
1304  }
1305  if(bUseTrigonQn){
1306  fHist_Task_config->Fill(16.5);
1307  }
1308 
1309 
1310  fHist_CutParameters->SetBinContent(1,VzCut[0]);
1311  fHist_CutParameters->SetBinContent(2,VzCut[1]);
1312  fHist_CutParameters->SetBinContent(3,vzBin);
1313  fHist_CutParameters->SetBinContent(4,VxCut[0]);
1314  fHist_CutParameters->SetBinContent(5,VxCut[1]);
1315  fHist_CutParameters->SetBinContent(6,vxBin);
1316  fHist_CutParameters->SetBinContent(7,VyCut[0]);
1317  fHist_CutParameters->SetBinContent(8,VyCut[1]);
1318  fHist_CutParameters->SetBinContent(9,vyBin);
1319 
1320 
1321 
1322 
1323 
1324 
1325  PostData(1,fListHistos);
1326 
1327  if(!bApplyRecent && fAnalysisSet=="DoGainEq") {
1328  PostData(2,fListZDCQxy);
1329  }
1330  else{
1331  fListDummy1 = new TList();
1332  fListDummy1->SetOwner(kTRUE);
1334  for(int i=0;i<90;i++){
1336  }
1337 
1338  PostData(2,fListDummy1);
1339  }
1340 
1341 
1342  fAnalysisUtil = new AliAnalysisUtils();
1343  fAnalysisUtil->SetUseMVPlpSelection(kTRUE);
1344  fAnalysisUtil->SetUseOutOfBunchPileUp(kTRUE);
1345 
1346 
1347  fcheckOnce = 0;
1348  fOldRunNum = 0;
1349  printf("\n\n::UserCreateOutPutObject()\n Runflag= %d, dataset: %s, VxyBin = %d, Analysis= %s\n\n",frunflag,fDataSet.Data(),NbinVt,fAnalysisSet.Data());
1350 
1351 }
1352 
1353 //________________________________________________________________________
1355 {
1356 
1357  float stepCount = 0.5;
1358 
1359  //printf("\n ... ::UserExec() is being called. 1 Step %d... \n",stepCount);
1360 
1361  fHist_Event_count->Fill(stepCount);
1362  stepCount++;
1363 
1364  AliAODEvent *aod = dynamic_cast<AliAODEvent*>(InputEvent());
1365  fEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(1));
1366 
1367  AliFlowEvent* anEvent = dynamic_cast<AliFlowEvent*>(GetInputData(2));
1368 
1369  AliFlowVector vQarray[2];
1370 
1371  if(anEvent) {
1372  // Get Q vectors for the subevents
1373  anEvent->GetZDC2Qsub(vQarray);
1374  }
1375 
1376 
1377 
1378 
1379  if(!aod){
1380  printf("\n ... ::UserExec = no aod found..... \n");
1381  return;
1382  }
1383 
1384  fHist_Event_count->Fill(stepCount);
1385  stepCount++;
1386 
1387 
1388  AliAODVertex *pVertex = aod->GetPrimaryVertex();
1389  Double_t Vxyz[3] = {0,0,0};
1390  Vxyz[0] = pVertex->GetX();
1391  Vxyz[1] = pVertex->GetY();
1392  Vxyz[2] = pVertex->GetZ();
1393 
1394  fHist_Vxy_RunAveraged->Fill(Vxyz[0], Vxyz[1]);
1395 
1396  //------- Apply Necessary event cuts ---------
1397  if(Vxyz[2] >= VzCut[1] || Vxyz[2] <= VzCut[0]) return;
1398 
1399  fHist_Event_count->Fill(stepCount);
1400  stepCount++;
1401 
1402  if(Vxyz[0] >= VxCut[1] || Vxyz[0] <= VxCut[0]) return;
1403 
1404  fHist_Event_count->Fill(stepCount);
1405  stepCount++;
1406 
1407  if(Vxyz[1] >= VyCut[1] || Vxyz[1] <= VyCut[0]) return;
1408 
1409  fHist_Event_count->Fill(stepCount);
1410  stepCount++;
1411 
1412 
1413  Double_t EvtCent = fEvent->GetCentrality();
1414 
1415 
1416  //---------- get runindex: --------------
1417  Int_t runNumber = aod->GetRunNumber();
1418  Int_t runindex = -111;
1419 
1420  for(int i=0;i<frunflag;i++){
1421  if(runNumber==runNums[i])
1422  {
1423  runindex = i;
1424  break;
1425  }
1426  }
1427  if(runindex<0) {
1428  printf("\n ... **WARNING** \n::UserExec() runnumber not listed.\n EXIT..\n");
1429  //exit(1);
1430  }
1431  //-----------------------------------------
1432 
1433  //Get MagneticField:
1434  Double_t fMagField = aod->GetMagneticField();
1435 
1436 
1437 
1438 
1439 
1440 
1441 
1442 
1443 
1444  //--------- starting pileup rejection work: --------
1445  Double_t centrV0M=300;
1446  Double_t centrCL1=300;
1447  Double_t centrCL0=300;
1448  Double_t centrTRK=300;
1449 
1450  if(fDataSet=="2010"||fDataSet=="2011"){
1451  centrV0M = ((AliVAODHeader*)aod->GetHeader())->GetCentralityP()->GetCentralityPercentile("V0M");
1452  centrCL1 = ((AliVAODHeader*)aod->GetHeader())->GetCentralityP()->GetCentralityPercentile("CL1");
1453  centrCL0 = ((AliVAODHeader*)aod->GetHeader())->GetCentralityP()->GetCentralityPercentile("CL0");
1454  centrTRK = ((AliVAODHeader*)aod->GetHeader())->GetCentralityP()->GetCentralityPercentile("TRK");
1455  }
1456  else{
1457  fMultSelection = (AliMultSelection*) InputEvent()->FindListObject("MultSelection");
1458  if(!fMultSelection) {
1459  printf("\n\n **WARNING** ::UserExec() AliMultSelection object not found.\n\n");
1460  exit(1);
1461  }
1462  centrV0M = fMultSelection->GetMultiplicityPercentile("V0M");
1463  centrCL1 = fMultSelection->GetMultiplicityPercentile("CL1");
1464  centrCL0 = fMultSelection->GetMultiplicityPercentile("CL0");
1465  centrTRK = fMultSelection->GetMultiplicityPercentile("TRK");
1466  }// 2015
1467 
1468  Bool_t BisPileup=kFALSE;
1469 
1470  if(fRejectPileUp && InputEvent()) {
1471  //if(!fCutsEvent->IsSelected(InputEvent(),MCEvent())) return;
1472  if(fDataSet!="2015") {
1473  if(plpMV(aod)) {
1474  fPileUpCount->Fill(0.5);
1475  BisPileup=kTRUE;
1476  }
1477  Int_t isPileup = aod->IsPileupFromSPD(3);
1478  if(isPileup != 0) {
1479  fPileUpCount->Fill(1.5);
1480  //BisPileup=kTRUE; // ----- Rihan: pileup from SPD not used for 2010
1481  }
1482  if(((AliAODHeader*)aod->GetHeader())->GetRefMultiplicityComb08() < 0) {
1483  fPileUpCount->Fill(2.5);
1484  BisPileup=kTRUE;
1485  }
1486  if(aod->IsIncompleteDAQ()) {
1487  fPileUpCount->Fill(3.5);
1488  BisPileup=kTRUE;
1489  }
1490 
1491  //check vertex consistency
1492  const AliAODVertex* vtTrc = aod->GetPrimaryVertex();
1493  const AliAODVertex* vtSPD = aod->GetPrimaryVertexSPD();
1494 
1495  if(vtTrc->GetNContributors() < 2 || vtSPD->GetNContributors()<1) {
1496  fPileUpCount->Fill(5.5);
1497  BisPileup=kTRUE;
1498  }
1499 
1500  double covTrc[6], covSPD[6];
1501  vtTrc->GetCovarianceMatrix(covTrc);
1502  vtSPD->GetCovarianceMatrix(covSPD);
1503 
1504  double dz = vtTrc->GetZ() - vtSPD->GetZ();
1505 
1506  double errTot = TMath::Sqrt(covTrc[5]+covSPD[5]);
1507  double errTrc = TMath::Sqrt(covTrc[5]);
1508  double nsigTot = dz/errTot;
1509  double nsigTrc = dz/errTrc;
1510 
1511  if(TMath::Abs(dz)>0.2 || TMath::Abs(nsigTot)>10 || TMath::Abs(nsigTrc)>20) {
1512  fPileUpCount->Fill(6.5);
1513  BisPileup=kTRUE;
1514  }
1515  if(fAnalysisUtil->IsPileUpEvent(InputEvent())) {
1516  fPileUpCount->Fill(7.5);
1517  BisPileup=kTRUE;
1518  }
1519  }
1520 
1521  else {
1522  // pileup from AliMultSelection for 2015
1523  if(!fMultSelection->GetThisEventIsNotPileup())
1524  fPileUpMultSelCount->Fill(0.5);
1525  if(!fMultSelection->GetThisEventIsNotPileupMV())
1526  fPileUpMultSelCount->Fill(1.5);
1527  if(!fMultSelection->GetThisEventIsNotPileupInMultBins())
1528  fPileUpMultSelCount->Fill(2.5);
1529  if(!fMultSelection->GetThisEventHasNoInconsistentVertices())
1530  fPileUpMultSelCount->Fill(3.5);
1531  if(!fMultSelection->GetThisEventPassesTrackletVsCluster())
1532  fPileUpMultSelCount->Fill(4.5);
1533  if(!fMultSelection->GetThisEventIsNotAsymmetricInVZERO())
1534  fPileUpMultSelCount->Fill(5.5);
1535  if(!fMultSelection->GetThisEventIsNotIncompleteDAQ())
1536  fPileUpMultSelCount->Fill(6.5);
1537  if(!fMultSelection->GetThisEventHasGoodVertex2016())
1538  fPileUpMultSelCount->Fill(7.5);
1539 
1540  BisPileup=kFALSE;
1541 
1542  // pile-up a la Dobrin for LHC15o
1543  if(plpMV(aod)) {
1544  fPileUpCount->Fill(0.5);
1545  BisPileup=kTRUE;
1546  }
1547 
1548  Int_t isPileup = aod->IsPileupFromSPD(3);
1549  if(isPileup != 0) {
1550  fPileUpCount->Fill(1.5);
1551  BisPileup=kTRUE;
1552  }
1553 
1554  if(((AliAODHeader*)aod->GetHeader())->GetRefMultiplicityComb08() < 0) {
1555  fPileUpCount->Fill(2.5);
1556  BisPileup=kTRUE;
1557  }
1558 
1559  if(aod->IsIncompleteDAQ()) {
1560  fPileUpCount->Fill(3.5);
1561  BisPileup=kTRUE;
1562  }
1563 
1564  if(fabs(centrV0M-centrCL1)>7.5) {
1565  fPileUpCount->Fill(4.5);
1566  BisPileup=kTRUE;
1567  }
1568 
1569  // check vertex consistency
1570  const AliAODVertex* vtTrc = aod->GetPrimaryVertex();
1571  const AliAODVertex* vtSPD = aod->GetPrimaryVertexSPD();
1572 
1573  if (vtTrc->GetNContributors() < 2 || vtSPD->GetNContributors()<1) {
1574  fPileUpCount->Fill(5.5);
1575  BisPileup=kTRUE;
1576  }
1577 
1578  double covTrc[6], covSPD[6];
1579  vtTrc->GetCovarianceMatrix(covTrc);
1580  vtSPD->GetCovarianceMatrix(covSPD);
1581 
1582  double dz = vtTrc->GetZ() - vtSPD->GetZ();
1583 
1584  double errTot = TMath::Sqrt(covTrc[5]+covSPD[5]);
1585  double errTrc = TMath::Sqrt(covTrc[5]);
1586  double nsigTot = dz/errTot;
1587  double nsigTrc = dz/errTrc;
1588 
1589  if(TMath::Abs(dz)>0.2 || TMath::Abs(nsigTot)>10 || TMath::Abs(nsigTrc)>20) {
1590  fPileUpCount->Fill(6.5);
1591  BisPileup=kTRUE;
1592  }
1593 
1594  // cuts on tracks
1595  const Int_t nTracks = aod->GetNumberOfTracks();
1596  Int_t multEsd = ((AliAODHeader*)aod->GetHeader())->GetNumberOfESDTracks();
1597 
1598  Int_t multTrk = 0;
1599  Int_t multTrkBefC = 0;
1600  Int_t multTrkTOFBefC = 0;
1601  Int_t multTPC = 0;
1602 
1603  for(Int_t it = 0; it < nTracks; it++) {
1604  AliAODTrack* aodTrk = (AliAODTrack*)aod->GetTrack(it);
1605  if(!aodTrk) {
1606  delete aodTrk;
1607  continue;
1608  }
1609 // if(aodTrk->TestFilterBit(32)){
1610 // multTrkBefC++;
1611 // if(TMath::Abs(aodTrk->GetTOFsignalDz()) <= 10. && aodTrk->GetTOFsignal() >= 12000. && aodTrk->GetTOFsignal() <= 25000.)
1612 // multTrkTOFBefC++;
1613 // if((TMath::Abs(aodTrk->Eta()) < 0.8) && (aodTrk->GetTPCNcls() >= 70) && (aodTrk->Pt() >= 0.2) && (aodTrk->Pt() < 20.))
1614 // multTrk++;
1615 // }
1616  if(aodTrk->TestFilterBit(128))
1617  multTPC++;
1618  } // end of for (Int_t it = 0; it < nTracks; it++)
1619 
1620  Double_t multTPCn = multTPC;
1621  Double_t multEsdn = multEsd;
1622  Double_t multESDTPCDif = multEsdn - multTPCn*3.38;
1623 
1624  if(multESDTPCDif > (fRejectPileUpTight?700.:15000.)) {
1625  fPileUpCount->Fill(7.5);
1626  BisPileup=kTRUE;
1627  }
1628 
1629  if(fRejectPileUpTight) {
1630  if(BisPileup==kFALSE) {
1631  if(!fMultSelection->GetThisEventIsNotPileup()) BisPileup=kTRUE;
1632  if(!fMultSelection->GetThisEventIsNotPileupMV()) BisPileup=kTRUE;
1633  if(!fMultSelection->GetThisEventIsNotPileupInMultBins()) BisPileup=kTRUE;
1634  if(!fMultSelection->GetThisEventHasNoInconsistentVertices()) BisPileup=kTRUE;
1635  if(!fMultSelection->GetThisEventPassesTrackletVsCluster()) BisPileup=kTRUE;
1636  if(!fMultSelection->GetThisEventIsNotIncompleteDAQ()) BisPileup=kTRUE;
1637  if(!fMultSelection->GetThisEventHasGoodVertex2016()) BisPileup=kTRUE;
1638  if(BisPileup) fPileUpCount->Fill(8.5);
1639  }
1640  }
1641  }
1642  }
1643 
1644  //----------- pile up rejection done ---------
1645  if(BisPileup) {
1646  return;
1647  }
1648 
1649  fHist_Event_count->Fill(stepCount);
1650  stepCount++;
1651 
1652 
1653 
1654 
1655 
1656 
1657 
1658  if(runNumber!=fOldRunNum){ //if runNumber changed, re-read new list.
1659  fcheckOnce = 0;
1660  }
1661 
1662  if(!fcheckOnce && fAnalysisSet=="DoGainEq") {
1663  fHist_ChanWgt_ZDCC = (TH1F *) fListZDCWgt->FindObject(Form("fHist1F_ZDCC_ChannelWgt_Run%d",runNumber));
1664  fHist_ChanWgt_ZDCA = (TH1F *) fListZDCWgt->FindObject(Form("fHist1F_ZDCA_ChannelWgt_Run%d",runNumber));
1665 
1666  fcheckOnce++;
1667  fOldRunNum = runNumber;
1668  }
1669 
1670 
1671 
1672  /*
1673  if(!fcheckOnce && fAnalysisSet=="DoGainEq") {
1674  fHist_ChanWgt_ZDCC = (TH1F *) fListZDCWgt->FindObject(Form("fHist1F_ZDCC_ChannelWgt_Run%d",runNumber));
1675  fHist_ChanWgt_ZDCA = (TH1F *) fListZDCWgt->FindObject(Form("fHist1F_ZDCA_ChannelWgt_Run%d",runNumber));
1676 
1677  if(bApplyRecent) {
1678  if(!bRunAveragedQn) {
1679  if(fListZDCQxy) {
1680  for(int i=0; i<vzBin; i++) {
1681  fHist_Recenter_ZDCCx[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znCx_V0_Run%d_Vz%d",runNumber,i+1));
1682  fHist_Recenter_ZDCCy[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znCy_V0_Run%d_Vz%d",runNumber,i+1));
1683  fHist_Recenter_ZDCAx[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znAx_V0_Run%d_Vz%d",runNumber,i+1));
1684  fHist_Recenter_ZDCAy[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znAy_V0_Run%d_Vz%d",runNumber,i+1));
1685  }
1686  }
1687  }
1688  else {
1689  if(fListZDCQxy) {
1690  for(int i=0; i<vzBin; i++) {
1691  fHist_Recenter_ZDCCx[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znCx_V0_Run%d_Vz%d",0,i+1));
1692  fHist_Recenter_ZDCCy[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znCy_V0_Run%d_Vz%d",0,i+1));
1693  fHist_Recenter_ZDCAx[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znAx_V0_Run%d_Vz%d",0,i+1));
1694  fHist_Recenter_ZDCAy[i] = (TH2F *) fListZDCQxy->FindObject(Form("fHist2F_znAy_V0_Run%d_Vz%d",0,i+1));
1695  }
1696  }
1697  }
1698  }
1699 
1700  fcheckOnce++;
1701  fOldRunNum = runNumber;
1702  } */
1703 
1704 
1705 
1706 
1707  Double_t ChanWgtZDCC[5] = {1.,1.,1.,1.,1.};
1708  Double_t ChanWgtZDCA[5] = {1.,1.,1.,1.,1.};
1709 
1710  Int_t iCentBin = abs(EvtCent) + 1;
1711  Int_t iWgtBin = -1;
1712  Int_t iCommon = -1;
1713 
1714 
1715  if(fAnalysisSet=="DoGainEq") {
1717 
1718  for(int ich=1; ich<=5; ich++){
1719  iWgtBin = 5*(iCentBin-1) + ich;
1720  ChanWgtZDCC[ich-1] = fHist_ChanWgt_ZDCC->GetBinContent(iWgtBin);
1721  ChanWgtZDCA[ich-1] = fHist_ChanWgt_ZDCA->GetBinContent(iWgtBin);
1722  }
1723  }
1724  else{
1725  //printf("\n\n **WARNING**\n ZDC Channel Weights not found. Using weights = 1.0 \n\n");
1726  //exit(1);
1727  }
1728  }
1729 
1730 
1731 
1732  fHist_Cent_woZDCcut->Fill(EvtCent);
1733 
1734 
1735  //----------- Read ZDC information ----------
1736  AliAODZDC *aodZDC = aod->GetZDCData();
1737  Float_t fZDCGainAlpha = 0.500; // fZDCGainAlpha : Jacopo uses 0.35 ??
1738  Float_t energyZNC = (Float_t) (aodZDC->GetZNCEnergy());
1739  Float_t energyZPC = (Float_t) (aodZDC->GetZPCEnergy());
1740  Float_t energyZNA = (Float_t) (aodZDC->GetZNAEnergy());
1741  Float_t energyZPA = (Float_t) (aodZDC->GetZPAEnergy());
1742  Float_t energyZEM1 = (Float_t) (aodZDC->GetZEM1Energy());
1743  Float_t energyZEM2 = (Float_t) (aodZDC->GetZEM2Energy());
1744 
1745  const Double_t * towZNC = aodZDC->GetZNCTowerEnergy();
1746  const Double_t * towZPC = aodZDC->GetZPCTowerEnergy();
1747  const Double_t * towZNA = aodZDC->GetZNATowerEnergy();
1748  const Double_t * towZPA = aodZDC->GetZPATowerEnergy();
1749 
1750  const Double_t * towZNClg = aodZDC->GetZNCTowerEnergyLR(); // Low gain something, should not be used.
1751  const Double_t * towZNAlg = aodZDC->GetZNATowerEnergyLR();
1752 
1753  Double_t towZPClg[5] = {0.,};
1754  Double_t towZPAlg[5] = {0.,};
1755 
1756  for(Int_t it=0; it<5; it++) {
1757  towZPClg[it] = 8*towZPC[it];
1758  towZPAlg[it] = 8*towZNA[it];
1759  }
1760 
1761  Int_t BadChannel = 0;
1762 
1763  //sanity: remove if any of ZDC_C_A has negetive Energy:
1764  //This was a bad choice of cut. I need to see the Physics effect later..!!
1765  //if(towZNC[1]<0 || towZNC[2]<0 || towZNC[3]<0 || towZNC[4]<0) return;
1766 
1767  for(int i=0; i<4; i++) {
1768  if(towZNC[i] < 0) {
1769  BadChannel++;
1770  }
1771  }
1772 
1773  if(BadChannel>=2) return; // Remove Event if more than one channel has Energy < 0
1774 
1775  fHist_Event_count->Fill(stepCount);
1776  stepCount++;
1777 
1778  //if(towZNA[1]<0 || towZNA[2]<0 || towZNA[3]<0 || towZNA[4]<0) return;
1779  BadChannel = 0;
1780 
1781  for(int i=0; i<4; i++) {
1782  if(towZNA[i] < 0) {
1783  BadChannel++;
1784  }
1785  }
1786 
1787  if(BadChannel>=2) return;
1788 
1789  fHist_Event_count->Fill(stepCount);
1790  stepCount++;
1791 
1792 
1793 
1794 
1795 
1796 
1797 
1798 
1799 
1800 
1801 
1802 
1803 //********** Get centroid from ZDCs **************
1804 
1805  Double_t xyZNC[2]={0.,0.};
1806  Double_t xyZNA[2]={0.,0.};
1807 
1808  Float_t zncEnergy=0., znaEnergy=0.;
1809 
1810 
1811 
1812 /*-----------------------Not used---------------------------------
1813  Int_t CenBin = GetCenBin(centrperc);
1814  Double_t zvtxpos[3]={0.,0.,0.};
1815  fFlowEvent->GetVertexPosition(zvtxpos);
1816  Int_t RunNum=fFlowEvent->GetRun();
1817  if(fTowerEqList) {
1818  if(RunNum!=fCachedRunNum) {
1819  for(Int_t i=0; i<8; i++) {
1820  fTowerGainEq[i] = (TH1D*)(fTowerEqList->FindObject(Form("Run %d",RunNum))->FindObject(Form("fhnTowerGainEqFactor[%d][%d]",RunNum,i)));
1821  }
1822  }
1823  }
1824  Bool_t fUseMCCen = kFALSE; //rihan:hardcoded
1825  if (fUseMCCen) {
1826  if(aod->GetRunNumber() < 209122)
1827  aodZDC->GetZNCentroidInPbPb(1380., xyZNC, xyZNA);
1828  else
1829  aodZDC->GetZNCentroidInPbPb(2510., xyZNC, xyZNA);
1830  }
1831  else {
1832  //set tower gain equalization, if available
1833  if(fTowerEqList) {
1834  for(Int_t i=0; i<8; i++)
1835  {
1836  if(fTowerGainEq[i])
1837  AvTowerGain[i] = fTowerGainEq[i]->GetBinContent(fTowerGainEq[i]->FindBin(centrperc));
1838  }
1839  }//--------------------------------------------------------------- */
1840 
1841 
1842 
1843  Double_t towCalibZNC[5] = {0,};
1844  Double_t towCalibZNA[5] = {0,};
1845 
1846  // towZNC[] is constant; so Need to make a copy
1847  for(int i=0;i<5;i++){
1848  towCalibZNC[i] = towZNC[i];
1849  towCalibZNA[i] = towZNA[i];
1850  }
1851 
1852  // If Ei < 0 , Ei = 0 (Maxim's idea)
1853  for(int i=1;i<5;i++){
1854  if(towCalibZNC[i] < 0) towCalibZNC[i] = 0;
1855  if(towCalibZNA[i] < 0) towCalibZNA[i] = 0;
1856  }
1857 
1858 
1859 
1860  Int_t indexVx = fHist_Vx_ArrayFinder->FindBin(Vxyz[0]);
1861  Int_t indexVy = fHist_Vy_ArrayFinder->FindBin(Vxyz[1]);
1862  Int_t indexVz = fHist_Vz_ArrayFinder->FindBin(Vxyz[2]);
1863 
1864 
1865  Double_t tVertexBin1 = 0;
1866  tVertexBin1 = (Double_t) (indexVy-1)*vxBin + (Double_t)indexVx - 0.5 ;
1867 
1868 
1869  if(fAnalysisSet=="FillGainEq") {
1870  fHist_Vx_vs_runnum->Fill(runindex,Vxyz[0]);
1871  fHist_Vy_vs_runnum->Fill(runindex,Vxyz[1]);
1872  fHist_Vz_vs_runnum->Fill(runindex,Vxyz[2]);
1873 
1874  fHist_ZDCC_En_CommonCh[indexVz-1]->Fill(EvtCent,tVertexBin1,towCalibZNC[0]);
1875  fHist_ZDCA_En_CommonCh[indexVz-1]->Fill(EvtCent,tVertexBin1,towCalibZNA[0]);
1876 
1877  for(int ich=0; ich<5; ich++) {
1878  fHist_ZDCC_En_Run[runindex]->Fill(EvtCent,ich,towCalibZNC[ich]);
1879  fHist_ZDCA_En_Run[runindex]->Fill(EvtCent,ich,towCalibZNA[ich]);
1880  }
1881  }
1882 
1883 
1884 
1885 
1886 
1887 
1888 
1889  // Now calibrate the energy of channel [0-4]:
1890  for(int i=0;i<5;i++){
1891  towCalibZNC[i] = ChanWgtZDCC[i]*towCalibZNC[i];
1892 
1893  if(ChanWgtZDCA[i] < 4.){
1894  towCalibZNA[i] = ChanWgtZDCA[i]*towCalibZNA[i];
1895  }
1896  }
1897 
1898  //manually get Energy in ZDC-A channel [2]:
1899  if(ChanWgtZDCA[2] >= 4.0){
1900  towCalibZNA[2] = towCalibZNA[0] - towCalibZNA[1] - towCalibZNA[3] - towCalibZNA[4];
1901  }
1902 
1903 
1904  for(Int_t i=0; i<5; i++){
1905  zncEnergy += towCalibZNC[i];
1906  znaEnergy += towCalibZNA[i];
1907  }
1908 
1909 
1910  Double_t AvTowerGain[8] = {1., 1., 1., 1., 1., 1., 1., 1.};
1911 
1912  const Float_t x[4] = {-1.75, 1.75,-1.75, 1.75};
1913  const Float_t y[4] = {-1.75, -1.75, 1.75, 1.75};
1914 
1915  Float_t numXZNC=0., numYZNC=0., denZNC=0., wZNC;
1916  Float_t numXZNA=0., numYZNA=0., denZNA=0., wZNA;
1917 
1918  for(Int_t i=0; i<4; i++) {
1919  if(towCalibZNC[i+1]>0.) {
1920  wZNC = TMath::Power(towCalibZNC[i+1], fZDCGainAlpha)*AvTowerGain[i];
1921  numXZNC += x[i]*wZNC;
1922  numYZNC += y[i]*wZNC;
1923  denZNC += wZNC;
1924  }
1925 
1926  if(towCalibZNA[i+1]>0.) {
1927  wZNA = TMath::Power(towCalibZNA[i+1], fZDCGainAlpha)*AvTowerGain[i+4];
1928  numXZNA += x[i]*wZNA;
1929  numYZNA += y[i]*wZNA;
1930  denZNA += wZNA;
1931  }
1932  }
1933 
1934  if(denZNC!=0) {
1935  xyZNC[0] = numXZNC/denZNC;
1936  xyZNC[1] = numYZNC/denZNC;
1937  }
1938  else{
1939  xyZNC[0] = 999.;
1940  xyZNC[1] = 999.;
1941  zncEnergy = 0.;
1942  }
1943  if(denZNA!=0) {
1944  xyZNA[0] = numXZNA/denZNA;
1945  xyZNA[1] = numYZNA/denZNA;
1946  }
1947  else{
1948  xyZNA[0] = 999.;
1949  xyZNA[1] = 999.;
1950  znaEnergy = 0.;
1951  }
1952 
1953 
1954 
1955  xyZNA[0] = -1.*xyZNA[0]; //----- Important: zdcA_X = -zdcA_X ---------
1956 
1957 
1958  /*
1959  if(sqrt(xyZNC[0]*xyZNC[0] + xyZNC[1]*xyZNC[1])>1.5) return;
1960 
1961  fHist_Event_count->Fill(stepCount);
1962  stepCount++;
1963 
1964  if(sqrt(xyZNA[0]*xyZNA[0] + xyZNA[1]*xyZNA[1])>1.5) return;
1965  */
1966 
1967  fHist_Event_count->Fill(stepCount);
1968  stepCount++;
1969 
1970  Double_t psi1C = TMath::ATan2(xyZNC[1],xyZNC[0]);
1971  if(psi1C<0){
1972  psi1C += 2.*TMath::Pi();
1973  }
1974  Double_t psi1A = TMath::ATan2(xyZNA[1],xyZNA[0]);
1975  if(psi1A<0){
1976  psi1A += 2.*TMath::Pi();
1977  }
1978 
1979  /*if(EvtCent>=5 && EvtCent<=45) {
1980  fHist_Psi1_ZDCC_wGainCorr->Fill(psi1C);
1981  fHist_Psi1_ZDCA_wGainCorr->Fill(psi1A);
1982  }*/
1983 
1984  if(fAnalysisSet=="DoGainEq") {
1985 
1986  tVertexBin1 = (Double_t) (indexVy-1)*vxBin + (Double_t)indexVx - 0.5 ;
1987 
1988  if(!bApplyRecent) {
1989  if(bFillCosSin) {
1990  if(!bRunAveragedQn){
1991  fHist_znCx_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Cos(psi1C));
1992  fHist_znCy_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Sin(psi1C));
1993  fHist_znAx_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Cos(psi1A));
1994  fHist_znAy_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Sin(psi1A));
1995  }
1996  else{
1997  fHist_znCx_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Cos(psi1C));
1998  fHist_znCy_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Sin(psi1C));
1999  fHist_znAx_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Cos(psi1A));
2000  fHist_znAy_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,TMath::Sin(psi1A));
2001  }
2002  }
2003  else{
2004  if(!bRunAveragedQn){
2005  fHist_znCx_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNC[0]);
2006  fHist_znCy_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNC[1]);
2007  fHist_znAx_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNA[0]);
2008  fHist_znAy_V0_VxVy[runindex][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNA[1]);
2009  }
2010  else{
2011  fHist_znCx_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNC[0]);
2012  fHist_znCy_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNC[1]);
2013  fHist_znAx_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNA[0]);
2014  fHist_znAy_V0_VxVy[0][indexVz-1]->Fill(tVertexBin1,EvtCent,xyZNA[1]);
2015  }
2016  }
2017  }
2018  }
2019 
2020 
2022 
2023  if(fAnalysisSet!="FillGainEq" && bFillCosSin) {
2024  xyZNC[0] = TMath::Cos(psi1C);
2025  xyZNC[1] = TMath::Sin(psi1C);
2026  xyZNA[0] = TMath::Cos(psi1A);
2027  xyZNA[1] = TMath::Sin(psi1A);
2028  }
2029 
2030 
2031 
2032  /* if(bFillZDCQAon){
2033 
2034  //Double_t FillVsWith[5] = {EvtCent,static_cast<Double_t>(nRefMult), Vxyz[0], Vxyz[1], Vxyz[2]};
2035  Double_t FillVsWith[5] = {EvtCent, fRefMult, Vxyz[0], Vxyz[1], Vxyz[2]};
2036  Double_t FillValueQx[4] = {xyZNA[0],xyZNC[0],xyZNA[1],xyZNC[1]};
2037  Double_t FillValueXX[4] = {xyZNA[0]*xyZNC[0],xyZNA[1]*xyZNC[1],xyZNC[0]*xyZNA[1],xyZNC[1]*xyZNA[0]}; //XaXc,YaYc,XcYa,YcXa
2038 
2039  for(int i=0;i<4;i++){
2040  for(int j=0;j<5;j++){
2041  if(j>0 && (EvtCent<5 || EvtCent>45)) continue;
2042  fHist_Qx_vs_Obs_woCorr[i][j]->Fill(FillVsWith[j],FillValueQx[i]);
2043  fHist_XX_vs_Obs_woCorr[i][j]->Fill(FillVsWith[j],FillValueXX[i]);
2044  }
2045  }
2046  } */
2047 
2048 
2049  if(fAnalysisSet=="FillGainEq" && bFillCosSin) {
2050  xyZNC[0] = TMath::Cos(psi1C);
2051  xyZNC[1] = TMath::Sin(psi1C);
2052  xyZNA[0] = TMath::Cos(psi1A);
2053  xyZNA[1] = TMath::Sin(psi1A);
2054  }
2055 
2056 
2057  Double_t meanCx = 0.;
2058  Double_t meanCy = 0.;
2059  Double_t meanAx = 0.;
2060  Double_t meanAy = 0.;
2061 
2062 
2063  //Apply the recentering:
2064  /*
2065  if(bApplyRecent) {
2066  Int_t tVertexBin2 = (indexVy-1)*vxBin + indexVx;
2067  if(fListZDCQxy) {
2068  meanCx = fHist_Recenter_ZDCCx[indexVz-1]->GetBinContent(tVertexBin2,iCentBin);
2069  meanCy = fHist_Recenter_ZDCCy[indexVz-1]->GetBinContent(tVertexBin2,iCentBin);
2070  meanAx = fHist_Recenter_ZDCAx[indexVz-1]->GetBinContent(tVertexBin2,iCentBin);
2071  meanAy = fHist_Recenter_ZDCAy[indexVz-1]->GetBinContent(tVertexBin2,iCentBin);
2072  }
2073  }
2074 
2075  xyZNC[0] = xyZNC[0] - meanCx;
2076  xyZNC[1] = xyZNC[1] - meanCy;
2077  xyZNA[0] = xyZNA[0] - meanAx;
2078  xyZNA[1] = xyZNA[1] - meanAy;
2079  */
2080 
2081 
2082  const AliAODVZERO *fvzero = aod->GetVZEROData();
2083 
2084  Float_t fV0Mult[64] = {0.,}; //0-31 v0c and 32-63 is v0A
2085 
2086  for(int i=0;i<64;i++){
2087  fV0Mult[i] = fvzero->GetMultiplicity(i);
2088  }
2089 
2090  for(int i=0;i<64;i++){
2091  fHist_VZERO_Mult_vsRun[runindex]->Fill(EvtCent,i+0.5,fV0Mult[i]);
2092  }
2093 
2094 
2095  //use Jacopo's flowEvent ZDC Q-vectors:
2096 
2097  xyZNC[0] = vQarray[0].Px();
2098  xyZNC[1] = vQarray[0].Py();
2099  xyZNA[0] = vQarray[1].Px();
2100  xyZNA[1] = vQarray[1].Py();
2101 
2102 
2103 
2104  Double_t Qvect_ModC = TMath::Sqrt(xyZNC[0]*xyZNC[0] + xyZNC[1]*xyZNC[1]);
2105  Double_t Qvect_ModA = TMath::Sqrt(xyZNA[0]*xyZNA[0] + xyZNA[1]*xyZNA[1]);
2106 
2107  Double_t dTermXXYY = xyZNA[0]*xyZNC[0] - xyZNA[1]*xyZNC[1];
2108  Double_t dTermXYXY = xyZNA[0]*xyZNC[1] + xyZNA[1]*xyZNC[0];
2109 
2110  Double_t Qvect_ModSumAC = TMath::Sqrt(dTermXXYY*dTermXXYY + dTermXYXY*dTermXYXY);
2111 
2112 
2113 
2114  fHist_Event_count->Fill(stepCount);
2115  stepCount++;
2116 
2117  Double_t Psi1C = TMath::ATan2(xyZNC[1],xyZNC[0]);
2118  if(Psi1C<0){
2119  Psi1C += 2.*TMath::Pi();
2120  }
2121 
2122  Double_t Psi1A = TMath::ATan2(xyZNA[1],xyZNA[0]);
2123  if(Psi1A<0){
2124  Psi1A += 2.*TMath::Pi();
2125  }
2126 
2127  Double_t PsiSumAC = Psi1C+Psi1A;
2128 
2129  if(PsiSumAC>2.*TMath::Pi()){
2130  PsiSumAC -= 2.*TMath::Pi();
2131  }
2132 
2133 
2134  fHist_PsiZDCA_ZeroQn->Fill(Psi1A);
2135  fHist_PsiZDCC_ZeroQn->Fill(Psi1C);
2136  fHist_PsiSumAC_ZeroQn->Fill(PsiSumAC);
2137 
2138 
2139  if(Qvect_ModC < 1.e-6 || Qvect_ModA < 1.e-6) return;
2140  //std::cout<<"Cx = "<<xyZNC[0]<<"\tCy = "<<xyZNC[1]<<"\tAx = "<<xyZNA[0]<<"\tAy = "<<xyZNA[1]<<std::endl;
2141 
2142 
2143  fHist_Event_count->Fill(stepCount);
2144  stepCount++;
2145 
2146  //Shift Histograms in Vxy binning:
2147  //if(!bCentCutShift){ }
2148  //else if(bCentCutShift && EvtCent>=0 && EvtCent< 60){
2149 
2150  if(bCentCutShift && EvtCent>=0 && EvtCent< 60){
2151  for(int i=0;i<4;i++){
2152  fHist_ZDCC_AvgCos_VsRun[i]->Fill(EvtCent,runindex,TMath::Cos((i+1)*Psi1C));
2153  fHist_ZDCA_AvgCos_VsRun[i]->Fill(EvtCent,runindex,TMath::Cos((i+1)*Psi1A));
2154  fHist_ZDCC_AvgSin_VsRun[i]->Fill(EvtCent,runindex,TMath::Sin((i+1)*Psi1C));
2155  fHist_ZDCA_AvgSin_VsRun[i]->Fill(EvtCent,runindex,TMath::Sin((i+1)*Psi1A));
2156 
2157  fHist_ZDC_AvgCosPsiSum_VsRun[i]->Fill(EvtCent,runindex,TMath::Cos((i+1)*(Psi1C+Psi1A)));
2158  fHist_ZDC_AvgSinPsiSum_VsRun[i]->Fill(EvtCent,runindex,TMath::Sin((i+1)*(Psi1C+Psi1A)));
2159 
2160  fHist_ZDC_AvgCosPsiDif_VsRun[i]->Fill(EvtCent,runindex,TMath::Cos((i+1)*(Psi1C-Psi1A)));
2161  fHist_ZDC_AvgSinPsiDif_VsRun[i]->Fill(EvtCent,runindex,TMath::Sin((i+1)*(Psi1C-Psi1A)));
2162  }
2163  }
2164 
2165 
2166  if(bFillZDCQAon){
2167 
2168  fHist_XXYY_vs_Cent_woCorr[0]->Fill(EvtCent, (xyZNA[0]*xyZNC[0] - xyZNA[1]*xyZNC[1]));
2169  fHist_XXYY_vs_Cent_woCorr[1]->Fill(EvtCent, (xyZNA[0]*xyZNC[1] + xyZNA[1]*xyZNC[0]));
2170 
2171  //Double_t FillVsWith[5] = {EvtCent,static_cast<Double_t>(nRefMult), Vxyz[0], Vxyz[1], Vxyz[2]};
2172  Double_t FillVsWith[5] = {EvtCent, fRefMult, Vxyz[0], Vxyz[1], Vxyz[2]};
2173  Double_t FillValueQx[4] = {xyZNA[0],xyZNC[0],xyZNA[1],xyZNC[1]};
2174  Double_t FillValueXX[4] = {xyZNA[0]*xyZNC[0],xyZNA[1]*xyZNC[1],xyZNC[0]*xyZNA[1],xyZNC[1]*xyZNA[0]}; //XaXc,YaYc,XcYa,YcXa
2175 
2176  Double_t FillValueQxTrig[4] = {TMath::Cos(Psi1A),TMath::Cos(Psi1C),TMath::Sin(Psi1A),TMath::Sin(Psi1C)};
2177  Double_t FillValueXXTrig[4] = {TMath::Cos(Psi1A)*TMath::Cos(Psi1C),TMath::Sin(Psi1A)*TMath::Sin(Psi1C),TMath::Cos(Psi1C)*TMath::Sin(Psi1A),TMath::Cos(Psi1A)*TMath::Sin(Psi1C)};
2178 
2179  Int_t centIndex = fHist_NormalCentralityBins->FindBin(EvtCent) - 1;
2180  if(centIndex<6) {
2181  for(int i=0;i<4;i++){
2182  if(fMagField>0){
2183  fHist_XX_vs_QnC_2DwoCorr_PosMag[i][centIndex]->Fill(xyZNC[0],xyZNC[1],FillValueXX[i]);
2184  fHist_XX_vs_QnA_2DwoCorr_PosMag[i][centIndex]->Fill(xyZNA[0],xyZNA[1],FillValueXX[i]);
2185  }
2186  else if(fMagField<0){
2187  fHist_XX_vs_QnC_2DwoCorr_NegMag[i][centIndex]->Fill(xyZNC[0],xyZNC[1],FillValueXX[i]);
2188  fHist_XX_vs_QnA_2DwoCorr_NegMag[i][centIndex]->Fill(xyZNA[0],xyZNA[1],FillValueXX[i]);
2189  }
2190  }
2191  }
2192 
2193  for(int i=0;i<4;i++){
2194 
2195  fHist_Qx_Trig_woCorr[i]->Fill(EvtCent,FillValueQxTrig[i]);
2196  fHist_XX_Trig_woCorr[i]->Fill(EvtCent,FillValueXXTrig[i]);
2197 
2198  for(int j=0;j<5;j++){
2199  if(j>0 && (EvtCent<5 || EvtCent>45)) continue;
2200  fHist_Qx_vs_Obs_woCorr[i][j]->Fill(FillVsWith[j],FillValueQx[i]);
2201  fHist_XX_vs_Obs_woCorr[i][j]->Fill(FillVsWith[j],FillValueXX[i]);
2202  }
2203  }
2204  }
2205 
2206 
2207  if(!bCentCutShift){
2208  fHist_Psi1_ZDCC_wGainCorr->Fill(psi1C);
2209  fHist_Psi1_ZDCA_wGainCorr->Fill(psi1A);
2210  fHist_PsiSumAC_woCorr->Fill(PsiSumAC);
2211  }
2212  else if(bCentCutShift && EvtCent>=5 && EvtCent<=45){
2213  fHist_Psi1_ZDCC_wGainCorr->Fill(psi1C);
2214  fHist_Psi1_ZDCA_wGainCorr->Fill(psi1A);
2215  fHist_PsiSumAC_woCorr->Fill(PsiSumAC);
2216  }
2217 
2218  //----------- Apply Shift correction: ----------
2219  Double_t ShiftCosC[4] = {0.,};
2220  Double_t ShiftSinC[4] = {0.,};
2221 
2222  Double_t ShiftCosA[4] = {0.,};
2223  Double_t ShiftSinA[4] = {0.,};
2224 
2225  if(bApplyShiftCorr) {
2226  if(!bShiftCombinedEP) {
2227  //Run dependent Shift Correction:
2228  for(int i=0;i<4;i++) {
2229  ShiftCosC[i] = fHist_ZDCC_AvgCosNPsi[i]->GetBinContent(iCentBin,runindex+1);
2230  ShiftSinC[i] = fHist_ZDCC_AvgSinNPsi[i]->GetBinContent(iCentBin,runindex+1);
2231  ShiftCosA[i] = fHist_ZDCA_AvgCosNPsi[i]->GetBinContent(iCentBin,runindex+1);
2232  ShiftSinA[i] = fHist_ZDCA_AvgSinNPsi[i]->GetBinContent(iCentBin,runindex+1);
2233  }
2234  }
2235  else if(bShiftCombinedEP) {
2236  for(int i=0;i<4;i++) {
2237  ShiftCosC[i] = fHist_ZDC_AvgCosNPsiAC[i]->GetBinContent(iCentBin,runindex+1);
2238  ShiftSinC[i] = fHist_ZDC_AvgSinNPsiAC[i]->GetBinContent(iCentBin,runindex+1);
2239  }
2240  }
2241  }
2242 
2243  Double_t shiftPsiC = 0;
2244  Double_t shiftPsiA = 0;
2245 
2246  PsiSumAC = Psi1C+Psi1A;
2247 
2248  if(bApplyShiftCorr) {
2249  if(!bShiftCombinedEP) {
2250  for(int i=0;i<4;i++) {
2251  shiftPsiC += 2.0/(i+1)*(-1.0*ShiftSinC[i]*TMath::Cos((i+1)*Psi1C) + ShiftCosC[i]*TMath::Sin((i+1)*Psi1C));
2252  shiftPsiA += 2.0/(i+1)*(-1.0*ShiftSinA[i]*TMath::Cos((i+1)*Psi1A) + ShiftCosA[i]*TMath::Sin((i+1)*Psi1A));
2253  }
2254  Psi1C += shiftPsiC;
2255  Psi1A += shiftPsiA;
2256  }
2257  else if(bShiftCombinedEP) {
2258  shiftPsiC = 0;
2259  for(int i=0;i<4;i++) {
2260  shiftPsiC += 2.0/(i+1)*(-1.0*ShiftSinC[i]*TMath::Cos((i+1)*PsiSumAC) + ShiftCosC[i]*TMath::Sin((i+1)*PsiSumAC));
2261  }
2262  PsiSumAC += shiftPsiC;
2263  }
2264  }
2265 
2266 
2267  if(Psi1C<0){
2268  Psi1C += 2.*TMath::Pi();
2269  }
2270  if(Psi1A<0){
2271  Psi1A += 2.*TMath::Pi();
2272  }
2273  if(PsiSumAC<0){
2274  PsiSumAC += 2.*TMath::Pi();
2275  }
2276  else if(PsiSumAC>2.*TMath::Pi()){
2277  PsiSumAC -= 2.*TMath::Pi();
2278  }
2279 
2280 
2281 
2282  //reconstruct the new ZDC-Qvect (with original Modulas).
2283  if(bApplyShiftCorr) {
2284  if(!bUseTrigonQn){
2285  xyZNC[0] = Qvect_ModC*TMath::Cos(Psi1C);
2286  xyZNC[1] = Qvect_ModC*TMath::Sin(Psi1C);
2287  xyZNA[0] = Qvect_ModA*TMath::Cos(Psi1A);
2288  xyZNA[1] = Qvect_ModA*TMath::Sin(Psi1A);
2289  //fill Qn Recentering histograms:
2290  fHist_ZDCC_AvgQx_VsRun->Fill(EvtCent,runindex,xyZNC[0]);
2291  fHist_ZDCC_AvgQy_VsRun->Fill(EvtCent,runindex,xyZNC[1]);
2292  fHist_ZDCA_AvgQx_VsRun->Fill(EvtCent,runindex,xyZNA[0]);
2293  fHist_ZDCA_AvgQy_VsRun->Fill(EvtCent,runindex,xyZNA[1]);
2294  fHist_ZDC_AvgXXminusYY_VsRun->Fill(EvtCent,runindex,(xyZNC[0]*xyZNA[0] - xyZNC[1]*xyZNA[1]));
2295  fHist_ZDC_AvgXYplusXY_VsRun->Fill (EvtCent,runindex,(xyZNC[1]*xyZNA[0] + xyZNC[0]*xyZNA[1]));
2296 
2297  dTermXXYY = Qvect_ModSumAC*TMath::Cos(PsiSumAC);
2298  dTermXYXY = Qvect_ModSumAC*TMath::Sin(PsiSumAC);
2299  fHist_ZDC_dTermXXYY_VsRun->Fill(EvtCent,runindex,dTermXXYY);
2300  fHist_ZDC_dTermXYXY_VsRun->Fill(EvtCent,runindex,dTermXYXY);
2301  }
2302  else if(bUseTrigonQn){//reconstruct the new ZDC-Qvect with Qn:[-1,1]
2303  xyZNC[0] = TMath::Cos(Psi1C);
2304  xyZNC[1] = TMath::Sin(Psi1C);
2305  xyZNA[0] = TMath::Cos(Psi1A);
2306  xyZNA[1] = TMath::Sin(Psi1A);
2307 
2308  fHist_ZDCC_AvgQx_VsRun->Fill(EvtCent,runindex,xyZNC[0]);
2309  fHist_ZDCC_AvgQy_VsRun->Fill(EvtCent,runindex,xyZNC[1]);
2310  fHist_ZDCA_AvgQx_VsRun->Fill(EvtCent,runindex,xyZNA[0]);
2311  fHist_ZDCA_AvgQy_VsRun->Fill(EvtCent,runindex,xyZNA[1]);
2312  fHist_ZDC_AvgXXminusYY_VsRun->Fill(EvtCent,runindex,(xyZNC[0]*xyZNA[0] - xyZNC[1]*xyZNA[1]));
2313  fHist_ZDC_AvgXYplusXY_VsRun->Fill (EvtCent,runindex,(xyZNC[1]*xyZNA[0] + xyZNC[0]*xyZNA[1]));
2314 
2315  dTermXXYY = TMath::Cos(PsiSumAC);
2316  dTermXYXY = TMath::Sin(PsiSumAC);
2317  fHist_ZDC_dTermXXYY_VsRun->Fill(EvtCent,runindex,dTermXXYY);
2318  fHist_ZDC_dTermXYXY_VsRun->Fill (EvtCent,runindex,dTermXYXY);
2319  }
2320  }
2321 
2322  //do recentering after shift:
2323  Double_t CorrC[2] = {0.,};
2324  Double_t CorrA[2] = {0.,};
2325 
2326  if(bApplyShiftCorr) {
2327  if(!bShiftCombinedEP) {
2328  xyZNC[0] -= fHist_ZDCC_AvgQx_VsCR->GetBinContent(iCentBin,runindex+1);
2329  xyZNC[1] -= fHist_ZDCC_AvgQy_VsCR->GetBinContent(iCentBin,runindex+1);
2330  xyZNA[0] -= fHist_ZDCA_AvgQx_VsCR->GetBinContent(iCentBin,runindex+1);
2331  xyZNA[1] -= fHist_ZDCA_AvgQy_VsCR->GetBinContent(iCentBin,runindex+1);
2332  }
2333  if(bShiftCombinedEP){
2334  dTermXXYY -= fHist_ZDC_dTermXXYY_VsCR->GetBinContent(iCentBin,runindex+1);
2335  dTermXYXY -= fHist_ZDC_dTermXYXY_VsCR->GetBinContent(iCentBin,runindex+1);
2336  }
2337  }
2338 
2339 
2340 
2341 
2342  if(bFillZDCQAon){
2343 
2344  //fHist_XXYY_vs_Cent_wiCorr[0]->Fill(EvtCent, xyZNC[0]*xyZNA[0] - xyZNC[1]*xyZNA[1]);
2345  //fHist_XXYY_vs_Cent_wiCorr[1]->Fill(EvtCent, xyZNC[1]*xyZNA[0] + xyZNC[0]*xyZNA[1]);
2346  fHist_XXYY_vs_Cent_wiCorr[0]->Fill(EvtCent, dTermXXYY);
2347  fHist_XXYY_vs_Cent_wiCorr[1]->Fill(EvtCent, dTermXYXY);
2348 
2349  Double_t FillVsWithNew[5] = {EvtCent, fRefMult, Vxyz[0], Vxyz[1], Vxyz[2]};
2350  Double_t FillValueQxNew[4] = {xyZNA[0],xyZNC[0],xyZNA[1],xyZNC[1]};
2351  Double_t FillValueXXNew[4] = {xyZNA[0]*xyZNC[0],xyZNA[1]*xyZNC[1],xyZNC[0]*xyZNA[1],xyZNC[1]*xyZNA[0]}; //XaXc,YaYc,XcYa,YcXa
2352 
2353  Double_t FillValueQxTrigNew[4] = {TMath::Cos(Psi1A),TMath::Cos(Psi1C),TMath::Sin(Psi1A),TMath::Sin(Psi1C)};
2354  Double_t FillValueXXTrigNew[4] = {TMath::Cos(Psi1A)*TMath::Cos(Psi1C),TMath::Sin(Psi1A)*TMath::Sin(Psi1C),TMath::Cos(Psi1C)*TMath::Sin(Psi1A),TMath::Cos(Psi1A)*TMath::Sin(Psi1C)};
2355 
2356  for(int i=0;i<4;i++){
2357  if(EvtCent>=5 && EvtCent<=45){
2358  fHist_Qx_wiCorr_RunByRun[i]->Fill(runindex,FillValueQxNew[i]);
2359  }
2360 
2361  fHist_Qx_Trig_wiCorr[i]->Fill(EvtCent,FillValueQxTrigNew[i]);
2362  fHist_XX_Trig_wiCorr[i]->Fill(EvtCent,FillValueXXTrigNew[i]);
2363 
2364  for(int j=0;j<5;j++){
2365  if(j>0 && (EvtCent<5 || EvtCent>45)) continue;
2366  fHist_Qx_vs_Obs_wiCorr[i][j]->Fill(FillVsWithNew[j],FillValueQxNew[i]);
2367  fHist_XX_vs_Obs_wiCorr[i][j]->Fill(FillVsWithNew[j],FillValueXXNew[i]);
2368  }
2369  }
2370  }
2371 
2372 
2373 
2374 
2375  Int_t iTracks = fEvent->NumberOfTracks();
2376  AliFlowTrackSimple* pTrack = NULL;
2377  Double_t Qnx_TPC[4] = {0,};
2378  Double_t Qny_TPC[4] = {0,};
2379  Double_t psi2,dPhi,dPt,dEta;
2380  Double_t pTwgt = 1.0;
2381  Double_t npoiMult = 0;
2382  Double_t dUx = 0;
2383  Double_t dUy = 0;
2384  Int_t ipTBin = 1;
2385  Int_t cIndex = -1;
2386  Double_t nRefMult = 0;
2387 
2388  if(EvtCent<5.0) { cIndex = 0; }
2389  else if(EvtCent>=5.0 && EvtCent<10){
2390  cIndex = 1;
2391  }
2392  else{
2393  cIndex = abs(EvtCent/10.0) + 1;
2394  }
2395 
2396  //Use Jacopo's notation:
2397  Double_t Qtot, QRe, QIm;
2398  Double_t ZARe = xyZNA[0];
2399  Double_t ZAIm = xyZNA[1];
2400  Double_t ZCRe = xyZNC[0];
2401  Double_t ZCIm = xyZNC[1];
2402 
2403 
2404  Double_t fullTerm = 0;
2405  Double_t fullReso = 0;
2406  Double_t CentWgt = 1.0;
2407  Int_t dChrg = 0;
2408  Double_t Qxpos[2] = {0.,}; //0=1*phi,1=2*phi
2409  Double_t Qypos[2] = {0.,};
2410  Double_t Qxneg[2] = {0.,}; //0=1*phi,1=2*phi
2411  Double_t Qyneg[2] = {0.,};
2412 
2413  Double_t QxEtaNeg[2] = {0.,}; //0=1*phi,1=2*phi
2414  Double_t QyEtaNeg[2] = {0.,};
2415  Double_t QxEtaPos[2] = {0.,}; //0=1*phi,1=2*phi
2416  Double_t QyEtaPos[2] = {0.,};
2417 
2418  Double_t mPosPoi = 0;
2419  Double_t mNegPoi = 0;
2420  Double_t mSubEtaPos = 0;
2421  Double_t mSubEtaNeg = 0;
2422 
2423 
2424  if(bApplyRecent && bApplyShiftCorr) {
2425  for(int i=0; i<iTracks; i++) {
2426  pTrack = fEvent->GetTrack(i);
2427  if(!pTrack) continue;
2428  dPhi = pTrack->Phi();
2429  dPt = pTrack-> Pt();
2430  dEta = pTrack->Eta();
2431  dChrg = pTrack->Charge();
2432  if(fabs(dEta) > 0.8) continue;
2433  if(dPt<0.20 || dPt>50.0) continue;
2434  if(!pTrack->IsPOItype(1)) continue;
2435  nRefMult++;
2436 
2437  ipTBin = fFB_Efficiency_Cent[cIndex]->FindBin(dPt);
2438  pTwgt = 1.0/fFB_Efficiency_Cent[cIndex]->GetBinContent(ipTBin);
2439 
2440  if(dEta>=0) {
2441  if(dChrg<0){
2442  Qxneg[0] += pTwgt*TMath::Cos(1.*dPhi); //no Eta/Phi weight at this moment, improve later.
2443  Qyneg[0] += pTwgt*TMath::Sin(1.*dPhi);
2444  Qxneg[1] += pTwgt*pTwgt*TMath::Cos(2.*dPhi); //for auto-correlation
2445  Qyneg[1] += pTwgt*pTwgt*TMath::Sin(2.*dPhi);
2446  mNegPoi += pTwgt;
2447  }
2448  else if(dChrg>0) {
2449  Qxpos[0] += pTwgt*TMath::Cos(1.*dPhi); //no Eta/Phi weight at this moment, improve later.
2450  Qypos[0] += pTwgt*TMath::Sin(1.*dPhi);
2451  Qxpos[1] += pTwgt*pTwgt*TMath::Cos(2.*dPhi); //for auto-correlation
2452  Qypos[1] += pTwgt*pTwgt*TMath::Sin(2.*dPhi);
2453  mPosPoi += pTwgt;
2454  }
2455 
2456  QxEtaPos[0] += pTwgt*TMath::Cos(2.*dPhi);
2457  QyEtaPos[0] += pTwgt*TMath::Sin(2.*dPhi);
2458  QxEtaPos[1] += pTwgt*TMath::Cos(4.*dPhi);
2459  QyEtaPos[1] += pTwgt*TMath::Sin(4.*dPhi);
2460  mSubEtaPos += pTwgt;
2461  }
2462 
2463  if(dEta<0) {
2464  QxEtaNeg[0] += pTwgt*TMath::Cos(2.*dPhi);
2465  QyEtaNeg[0] += pTwgt*TMath::Sin(2.*dPhi);
2466  QxEtaNeg[1] += pTwgt*TMath::Cos(4.*dPhi);
2467  QyEtaNeg[1] += pTwgt*TMath::Sin(4.*dPhi);
2468  mSubEtaNeg += pTwgt;
2469  }
2470 
2471 
2472  dUx = TMath::Cos(dPhi);
2473  dUy = TMath::Sin(dPhi);
2474  Qnx_TPC[0] += dUx*pTwgt;
2475  Qny_TPC[0] += dUy*pTwgt;
2476 
2477 
2478  fHist_v1xV1_ZDN_EtaDiff[0][cIndex]->Fill(dEta, dUx*xyZNC[0], pTwgt); //uxCx
2479  fHist_v1xV1_ZDN_EtaDiff[1][cIndex]->Fill(dEta, dUy*xyZNC[1], pTwgt); //uyCy
2480  fHist_v1xV1_ZDN_EtaDiff[2][cIndex]->Fill(dEta, dUx*xyZNA[0], pTwgt); //uxAx
2481  fHist_v1xV1_ZDN_EtaDiff[3][cIndex]->Fill(dEta, dUy*xyZNA[1], pTwgt); //uyAy
2482  fHist_v1xV1_ZDN_pTDiff[0][cIndex]->Fill(dPt, dUx*xyZNC[0], pTwgt); //uxCx
2483  fHist_v1xV1_ZDN_pTDiff[1][cIndex]->Fill(dPt, dUy*xyZNC[1], pTwgt); //uyCy
2484  fHist_v1xV1_ZDN_pTDiff[2][cIndex]->Fill(dPt, dUx*xyZNA[0], pTwgt); //uxAx
2485  fHist_v1xV1_ZDN_pTDiff[3][cIndex]->Fill(dPt, dUy*xyZNA[1], pTwgt); //uyAy
2486 
2487 
2488  dUx = TMath::Cos(2.*dPhi);
2489  dUy = TMath::Sin(2.*dPhi);
2490  Qnx_TPC[1] += dUx*pTwgt;
2491  Qny_TPC[1] += dUy*pTwgt;
2492 
2493  if(cIndex<6){
2494  //fullTerm = dUx*(xyZNA[0]*xyZNC[0] - xyZNA[1]*xyZNC[1]) + dUy*(xyZNA[0]*xyZNC[1] + xyZNA[1]*xyZNC[0]);
2495  fullTerm = dUx*dTermXXYY + dUy*dTermXYXY;
2496 
2497  fHist_v2xV1_ZDN_pTDiff_All[cIndex]->Fill(dPt,fullTerm,pTwgt);
2498  }
2499 
2500 
2501  QRe = TMath::Cos(3.*dPhi);
2502  QIm = TMath::Sin(3.*dPhi);
2503  Qnx_TPC[2] += QRe*pTwgt;
2504  Qny_TPC[2] += QIm*pTwgt;
2505 
2506  if(cIndex<6){
2507  Qtot = QRe*(ZARe*ZARe*ZCRe-2.*ZARe*ZAIm*ZCIm-ZCRe*ZAIm*ZAIm) + QIm*(-ZAIm*ZAIm*ZCIm+2.*ZAIm*ZARe*ZCRe+ZCIm*ZARe*ZARe);
2508  fHist_v3xV1_ZDN_EtaDiff_Comb1[cIndex]->Fill(dEta,Qtot,pTwgt);
2509  Qtot = QRe*(ZCRe*ZCRe*ZARe-2.*ZCRe*ZCIm*ZAIm-ZARe*ZCIm*ZCIm) + QIm*(-ZCIm*ZCIm*ZAIm+2.*ZCIm*ZCRe*ZARe+ZAIm*ZCRe*ZCRe);
2510  fHist_v3xV1_ZDN_EtaDiff_Comb2[cIndex]->Fill(dEta,Qtot,pTwgt);
2511  }
2512 
2513 
2514  QRe = TMath::Cos(4.*dPhi);
2515  QIm = TMath::Sin(4.*dPhi);
2516  Qnx_TPC[3] += QRe*pTwgt;
2517  Qny_TPC[3] += QIm*pTwgt;
2518 
2519  if(cIndex<6){
2520  Qtot = QRe*((ZARe*ZARe-ZAIm*ZAIm)*(ZCRe*ZCRe-ZCIm*ZCIm)-(ZAIm*ZARe+ZARe*ZAIm)*(ZCIm*ZCRe+ZCRe*ZCIm)) + QIm*((ZAIm*ZARe+ZARe*ZAIm)*(ZCRe*ZCRe-ZCIm*ZCIm)+(ZCIm*ZCRe+ZCRe*ZCIm)*(ZARe*ZARe-ZAIm*ZAIm));
2521  fHist_v4xV1_ZDN_pTDiff_All[cIndex]->Fill(dPt,Qtot,pTwgt);
2522  }
2523 
2524  //cout<<"i = "<<i<<" iCentBin = "<<cIndex<<" pTBin "<<ipTBin<<" pt = "<<dPt<<"\t wgt = "<<pTwgt<<endl;
2525  npoiMult += pTwgt;
2526  }
2527  }
2528 
2529 
2530 
2531  if(npoiMult>0){
2532  for(int i=0;i<4;i++){
2533  Qnx_TPC[i] = Qnx_TPC[i]/npoiMult;
2534  Qny_TPC[i] = Qny_TPC[i]/npoiMult;
2535  }
2536  }
2537  else{
2538  for(int i=0;i<4;i++){
2539  Qnx_TPC[i] = 0;
2540  Qny_TPC[i] = 0;
2541  }
2542  }
2543 
2544 
2545  //reduced q,Q for 3p Correlator:
2546  Double_t uPRe=0.,uNRe=0.,uPIm=0.,uNIm=0.,uN2Re=0.,uN2Im=0.,uP2Re=0.,uP2Im=0.,VCRe=0.,VCIm=0., VPRe=0.,VPIm=0.;
2547  Double_t uPM=0.,uNM=0.;
2548 
2549  if(mSubEtaPos>0 && mSubEtaNeg){
2550  VCRe = QxEtaNeg[0] /mSubEtaNeg; //-ve eta for Event plane calculation;
2551  VCIm = QyEtaNeg[0] /mSubEtaNeg;
2552 
2553  VPRe = QxEtaPos[0] /mSubEtaPos; //This is for resolution
2554  VPIm = QyEtaPos[0] /mSubEtaPos;
2555  }
2556 
2557  if( mNegPoi>0 && mPosPoi>0 ) {
2558  uPRe = Qxpos[0];
2559  uPIm = Qypos[0];
2560  uNRe = Qxneg[0];
2561  uNIm = Qyneg[0];
2562 
2563  uP2Re = Qxpos[1];
2564  uP2Im = Qypos[1];
2565  uN2Re = Qxneg[1];
2566  uN2Im = Qyneg[1];
2567 
2568  uPM = mPosPoi;
2569  uNM = mNegPoi;
2570  }
2571 
2572  //else{uPRe=0.; uPIm=0.; uNRe=0.; uNIm=0.;}
2573 
2574  Double_t TwoQpQnV = 0.;
2575  Double_t TwoQpQpV = 0.;
2576  Double_t TwoQnQnV = 0.;
2577 
2578 
2579  fullTerm = 0;
2580  fullReso = 0;
2581 
2582  if(bApplyRecent) {
2583 
2584  if( mNegPoi>0 && mPosPoi>0 ) {
2585  TwoQpQnV = ((uPRe*uNRe-uPIm*uNIm)*VCRe + (uPRe*uNIm+uPIm*uNRe)*VCIm) / (uPM*uNM) ;
2586  TwoQpQpV = ((uPRe*uPRe-uPIm*uPIm-uP2Re)*VCRe + (2.*uPRe*uPIm-uP2Im)*VCIm) / (uPM*(uPM-1.)) ;
2587  TwoQnQnV = ((uNRe*uNRe-uNIm*uNIm-uN2Re)*VCRe + (2.*uNRe*uNIm-uN2Im)*VCIm) / (uNM*(uNM-1.)) ;
2588 
2589  fHist_Corr3p_ZDN_Norm_PN->Fill(EvtCent, TwoQpQnV);
2590  fHist_Corr3p_ZDN_Norm_PP->Fill(EvtCent, TwoQpQpV);
2591  fHist_Corr3p_ZDN_Norm_NN->Fill(EvtCent, TwoQnQnV);
2592 
2593  fHist_Corr3p_ZDN_Cent_PN->Fill(EvtCent, TwoQpQnV);
2594  fHist_Corr3p_ZDN_Cent_PP->Fill(EvtCent, TwoQpQpV);
2595  fHist_Corr3p_ZDN_Cent_NN->Fill(EvtCent, TwoQnQnV);
2596 
2597  fHist_Reso2EP_TPC_Norm->Fill(EvtCent, (VCRe*VPRe+VCIm*VPIm));
2598  fHist_Reso2EP_TPC_Cent->Fill(EvtCent, (VCRe*VPRe+VCIm*VPIm));
2599  }
2600 
2601 
2602 
2603  if(EvtCent>=5 && EvtCent<=45) {
2604  fHist_Psi1_ZDCC_wRectCorr->Fill(Psi1C);
2605  fHist_Psi1_ZDCA_wRectCorr->Fill(Psi1A);
2606 
2607  fHist_PsiSumAC_wiCorr->Fill(PsiSumAC);
2608  fHist_Psi1_ZDCC_RunByRun->Fill(runindex,Psi1C);
2609  fHist_Psi1_ZDCA_RunByRun->Fill(runindex,Psi1A);
2610  }
2611 
2612  fHist_Psi1_ZDCC_wCorrFull->Fill(Psi1C);
2613  fHist_Psi1_ZDCA_wCorrFull->Fill(Psi1A);
2614 
2615  CentWgt = fWeight_Cent->GetBinContent(iCentBin);
2616 
2617  fHist_ZDN_resol_Norm_Sep[0]->Fill(EvtCent, xyZNA[0]*xyZNC[0]);
2618  fHist_ZDN_resol_Cent_Sep[0]->Fill(EvtCent, xyZNA[0]*xyZNC[0]);
2619 
2620  fHist_ZDN_resol_Norm_Sep[1]->Fill(EvtCent, xyZNA[1]*xyZNC[1]);
2621  fHist_ZDN_resol_Cent_Sep[1]->Fill(EvtCent, xyZNA[1]*xyZNC[1]);
2622 
2623  Double_t v1FillTerms[4] = {Qnx_TPC[0]*xyZNC[0], Qny_TPC[0]*xyZNC[1], Qnx_TPC[0]*xyZNA[0], Qny_TPC[0]*xyZNA[1]};
2624 
2625 
2626  for(int i=0; i<4; i++){
2627  fHist_v2xV1_ZDN_Norm_Sep[i]->Fill(EvtCent, v1FillTerms[i]);
2628  fHist_v2xV1_ZDN_Cent_Sep[i]->Fill(EvtCent, v1FillTerms[i]);
2629  }
2630 
2631 
2632  //fullTerm = Qnx_TPC[1]*(xyZNA[0]*xyZNC[0] - xyZNA[1]*xyZNC[1]) + Qny_TPC[1]*(xyZNA[0]*xyZNC[1] + xyZNA[1]*xyZNC[0]);
2633  fullTerm = Qnx_TPC[1]*dTermXXYY + Qny_TPC[1]*dTermXYXY;
2634 
2635  fullReso = xyZNA[0]*xyZNC[0] + xyZNA[1]*xyZNC[1]; //no change in Resolution?
2636 
2637  fHist_v2xV1_ZDN_Norm_All->Fill( EvtCent, fullTerm, CentWgt);
2638  fHist_v2xV1_ZDN_Cent_All->Fill( EvtCent, fullTerm, CentWgt);
2639  fHist_v2xV1_ZDN_Refm_All->Fill(nRefMult, fullTerm, CentWgt);
2640 
2641  fHist_ZDN_resol_Norm_All->Fill( EvtCent, fullReso, CentWgt);
2642  fHist_ZDN_resol_Cent_All->Fill( EvtCent, fullReso, CentWgt);
2643  fHist_ZDN_resol_Refm_All->Fill(nRefMult, fullReso, CentWgt);
2644 
2645  fHist_ZDN_resol_Norm_XX->Fill( EvtCent, xyZNA[0]*xyZNC[0], CentWgt);
2646  fHist_ZDN_resol_Cent_XX->Fill( EvtCent, xyZNA[0]*xyZNC[0], CentWgt);
2647  fHist_ZDN_resol_Norm_YY->Fill( EvtCent, xyZNA[1]*xyZNC[1], CentWgt);
2648  fHist_ZDN_resol_Cent_YY->Fill( EvtCent, xyZNA[1]*xyZNC[1], CentWgt);
2649 
2650 
2651  QRe = Qnx_TPC[2];
2652  QIm = Qny_TPC[2];
2653  //integrated v3:
2654  Qtot = QRe*(ZARe*ZARe*ZCRe-2.*ZARe*ZAIm*ZCIm-ZCRe*ZAIm*ZAIm) + QIm*(-ZAIm*ZAIm*ZCIm+2.*ZAIm*ZARe*ZCRe+ZCIm*ZARe*ZARe);
2655  fHist_v3xV1_ZDN_Norm_Comb1->Fill( EvtCent, Qtot, CentWgt);
2656  fHist_v3xV1_ZDN_Cent_Comb1->Fill( EvtCent, Qtot, CentWgt);
2657 
2658  Qtot = QRe*(ZCRe*ZCRe*ZARe-2.*ZCRe*ZCIm*ZAIm-ZARe*ZCIm*ZCIm) + QIm*(-ZCIm*ZCIm*ZAIm+2.*ZCIm*ZCRe*ZARe+ZAIm*ZCRe*ZCRe);
2659  fHist_v3xV1_ZDN_Norm_Comb2->Fill( EvtCent, Qtot, CentWgt);
2660  fHist_v3xV1_ZDN_Cent_Comb2->Fill( EvtCent, Qtot, CentWgt);
2661 
2662 
2663  QRe = Qnx_TPC[3];
2664  QIm = Qny_TPC[3];
2665  //integrated v4:
2666  Qtot = QRe*((ZARe*ZARe-ZAIm*ZAIm)*(ZCRe*ZCRe-ZCIm*ZCIm)-(ZAIm*ZARe+ZARe*ZAIm)*(ZCIm*ZCRe+ZCRe*ZCIm))
2667  + QIm*((ZAIm*ZARe+ZARe*ZAIm)*(ZCRe*ZCRe-ZCIm*ZCIm)+(ZCIm*ZCRe+ZCRe*ZCIm)*(ZARe*ZARe-ZAIm*ZAIm));
2668  fHist_v4xV1_ZDN_Norm_Comb1->Fill( EvtCent, Qtot, CentWgt);
2669  fHist_v4xV1_ZDN_Cent_Comb1->Fill( EvtCent, Qtot, CentWgt);
2670 
2671  }
2672 
2673 
2674 
2675 
2676  fHist_Event_count->Fill(stepCount);
2677  stepCount++;
2678 
2679 
2680  fHist_Cent_wiZDCcut->Fill(EvtCent);
2681 
2682 
2683 
2684  //if(fievent%20==0) {
2685  //std::cout<<" cent= "<<EvtCent<<"\tV0C[1] = "<<fV0Mult[1]<<"\t V0A[63] = "<<fV0Mult[63]<<"\tRefMult = "<<nRefMult<<std::endl;
2686  //std::cout<<" <XXYY> = "<<CorrC[0]<<"\t <XYXY> = "<<CorrC[1]<<"\t MagField = "<<fMagField<<std::endl;
2687  //}
2688 
2689 
2690  PostData(1,fListHistos);
2691 
2692  if(!bApplyRecent && fAnalysisSet=="DoGainEq") {
2693  PostData(2,fListZDCQxy);
2694  }
2695  else{
2696  PostData(2,fListDummy1); //default if no 'fAnalysisSet' found.
2697  }
2698 
2699 
2700  fievent++;
2701 
2702  //printf("\n ... ::UserExec() is being called. Step last %d... Event %d \n",stepCount,fievent);
2703 
2704 }// UserExec ends
2705 
2706 
2707 
2708 
2710 {
2711  AliDebug(2,"\n ... AliAnalysisTaskZDCGainEq::Terminate() is being called ... \n");
2712 }
2713 
2714 
2715 double AliAnalysisTaskZDCGainEq::GetWDist(const AliVVertex* v0, const AliVVertex* v1)
2716 {
2717  // calculate sqrt of weighted distance to other vertex
2718  if (!v0 || !v1) {
2719  AliDebug(2,"\n\n ::GetWDist => One of vertices is not valid\n\n");
2720  return 0;
2721  }
2722  static TMatrixDSym vVb(3);
2723  double dist = -1;
2724  double dx = v0->GetX()-v1->GetX();
2725  double dy = v0->GetY()-v1->GetY();
2726  double dz = v0->GetZ()-v1->GetZ();
2727  double cov0[6],cov1[6];
2728  v0->GetCovarianceMatrix(cov0);
2729  v1->GetCovarianceMatrix(cov1);
2730  vVb(0,0) = cov0[0]+cov1[0];
2731  vVb(1,1) = cov0[2]+cov1[2];
2732  vVb(2,2) = cov0[5]+cov1[5];
2733  vVb(1,0) = vVb(0,1) = cov0[1]+cov1[1];
2734  vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.;
2735  vVb.InvertFast();
2736  if (!vVb.IsValid()) {
2737  AliDebug(2,"Singular Matrix\n");
2738  return dist;
2739  }
2740  dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz
2741  + 2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz;
2742  return dist>0 ? TMath::Sqrt(dist) : -1;
2743 }
2744 
2746  { // check for multi-vertexer pile-up
2747  const int kMinPlpContrib = 5;
2748  const double kMaxPlpChi2 = 5.0;
2749  const double kMinWDist = 15;
2750 
2751  const AliVVertex* vtPrm = 0;
2752  const AliVVertex* vtPlp = 0;
2753 
2754  int nPlp = 0;
2755 
2756  if(!(nPlp=aod->GetNumberOfPileupVerticesTracks()))
2757  return kFALSE;
2758 
2759  vtPrm = aod->GetPrimaryVertex();
2760  if(vtPrm == aod->GetPrimaryVertexSPD())
2761  return kTRUE; // there are pile-up vertices but no primary
2762 
2763  //int bcPrim = vtPrm->GetBC();
2764 
2765  for(int ipl=0;ipl<nPlp;ipl++) {
2766  vtPlp = (const AliVVertex*)aod->GetPileupVertexTracks(ipl);
2767  if (vtPlp->GetNContributors() < kMinPlpContrib) continue;
2768  if (vtPlp->GetChi2perNDF() > kMaxPlpChi2) continue;
2769  //int bcPlp = vtPlp->GetBC();
2770  //if (bcPlp!=AliVTrack::kTOFBCNA && TMath::Abs(bcPlp-bcPrim)>2)
2771  // return kTRUE; // pile-up from other BC
2772 
2773  double wDst = GetWDist(vtPrm,vtPlp);
2774  if (wDst<kMinWDist) continue;
2775 
2776  return kTRUE; // pile-up: well separated vertices
2777  }
2778 
2779  return kFALSE;
2780  }
2781 
2782 
2783 
2784 
virtual void UserExec(Option_t *option)
TProfile2D * fHist_XX_vs_QnA_2DwoCorr_PosMag[4][6]
TProfile2D * fHist_XX_vs_QnC_2DwoCorr_PosMag[4][6]
TProfile2D * fHist_XX_vs_QnA_2DwoCorr_NegMag[4][6]
double Double_t
Definition: External.C:58
Definition: External.C:236
virtual void Terminate(Option_t *)
AliFlowTrackSimple * GetTrack(Int_t i)
AliMultSelection * fMultSelection
input event
double GetWDist(const AliVVertex *v0, const AliVVertex *v1)
TProfile * fHist_v1xV1_ZDN_pTDiff[4][10]
TProfile2D * fHist_znAy_V0_VxVy[90][10]
TProfile2D * fHist_ZDC_AvgSinPsiDif_VsRun[4]
TProfile2D * fHist_ZDC_AvgCosPsiSum_VsRun[4]
Double_t Phi() const
int Int_t
Definition: External.C:63
float Float_t
Definition: External.C:68
TProfile2D * fHist_XX_vs_QnC_2DwoCorr_NegMag[4][6]
TProfile2D * fHist_znAx_V0_VxVy[90][10]
Definition: External.C:212
Bool_t plpMV(const AliAODEvent *aod)
Double_t GetCentrality() const
TProfile2D * fHist_ZDC_AvgCosPsiDif_VsRun[4]
TProfile2D * fHist_ZDC_AvgSinPsiSum_VsRun[4]
Int_t GetReferenceMultiplicity() const
virtual void GetZDC2Qsub(AliFlowVector *Qarray)
TList * fListZDCQxy
collection of output
TProfile * fHist_v1xV1_ZDN_EtaDiff[4][10]
Bool_t IsPOItype(Int_t poiType) const
const char Option_t
Definition: External.C:48
Double_t Eta() const
bool Bool_t
Definition: External.C:53
TProfile2D * fHist_znCy_V0_VxVy[90][10]
TProfile2D * fHist_znCx_V0_VxVy[90][10]
Int_t NumberOfTracks() const