AliPhysics  857879d (857879d)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskZDCEP.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 
16 /***********************************
17  * ZDC Event Plane *
18  * *
19  * author: Jacopo Margutti *
20  * email: jacopo.margutti@cern.ch *
21  ***********************************/
22 
23 #define AliAnalysisTaskZDCEP_cxx
24 
25 #include "Riostream.h"
26 #include "AliFlowCommonConstants.h"
27 #include "AliFlowCommonHist.h"
29 #include "TChain.h"
30 
31 #include "TFile.h"
32 #include "TList.h"
33 #include "TGraph.h"
34 #include "TParticle.h"
35 #include "TRandom3.h"
36 #include "TStyle.h"
37 #include "TProfile.h"
38 #include "TProfile2D.h"
39 #include "TMath.h"
40 #include "TArrow.h"
41 #include "TPaveLabel.h"
42 #include "TCanvas.h"
43 #include "TVector2.h"
44 #include "AliFlowEventSimple.h"
45 #include "AliFlowVector.h"
46 #include "AliFlowTrackSimple.h"
47 #include "AliFlowAnalysisCRC.h"
48 #include "TRandom.h"
49 #include "TF1.h"
50 #include "TNtuple.h"
51 #include "THnSparse.h"
52 #include "AliAnalysisTaskZDCEP.h"
53 #include "AliAODTrack.h"
54 #include "AliAODEvent.h"
55 #include "AliAODZDC.h"
56 #include "TProfile2D.h"
57 #include "TProfile3D.h"
58 #include "AliFlowEvent.h"
59 
60 class TH1;
61 class TH2;
62 class TGraph;
63 class TPave;
64 class TLatex;
65 class TMarker;
66 class TRandom3;
67 class TObjArray;
68 class TList;
69 class TCanvas;
70 class TSystem;
71 class TROOT;
72 class TVector2;
73 class AliFlowVector;
74 
77 fOutputList(0x0),
78 fHistList(0x0),
79 fZDCGainAlpha(0.395),
80 fZDCCalibList(0x0),
81 fTowerEqList(0x0),
82 fCachedRunNum(0),
83 fAnalysisUtils(0x0),
84 fMultSelection(0x0),
85 fFlowEvent(NULL)
86 {
87  for(Int_t k=0; k<4; k++) {
88  fZDCQHist[k] = NULL;
89  fZDCVtxHist[k] = NULL;
90  fZDCEcomTotHist[k] = NULL;
91  for(Int_t c=0; c<10; c++) {
92  fZDCVtxCenHist[c][k] = NULL;
93  }
94  }
95  for(Int_t c=0; c<2; c++) {
96  for(Int_t i=0; i<5; i++) {
97  fTowerGainEq[c][i] = NULL;
98  }
99  }
100  for (Int_t i=0; i<2; i++) fZDCFlowVect[i] = NULL;
101 
102  Int_t dRun15o[] = {244917, 244918, 244975, 244980, 244982, 244983, 245064, 245066, 245068, 246390, 246391, 246392, 246994, 246991, 246989, 246984, 246982, 246980, 246948, 246945, 246928, 246851, 246847, 246846, 246845, 246844, 246810, 246809, 246808, 246807, 246805, 246804, 246766, 246765, 246763, 246760, 246759, 246758, 246757, 246751, 246750, 246495, 246493, 246488, 246487, 246434, 246431, 246428, 246424, 246276, 246275, 246272, 246271, 246225, 246222, 246217, 246185, 246182, 246181, 246180, 246178, 246153, 246152, 246151, 246115, 246113, 246089, 246087, 246053, 246052, 246049, 246048, 246042, 246037, 246036, 246012, 246003, 246001, 245954, 245952, 245949, 245923, 245833, 245831, 245829, 245705, 245702, 245700, 245692, 245683};
103  Double_t dVtxPosX15o[] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,7.619407e-02, 7.612905e-02, 7.609009e-02, 7.610981e-02, 7.608885e-02, 7.609981e-02, 7.559263e-02, 7.563009e-02, 7.551201e-02, 7.570994e-02, 7.571927e-02, 7.575639e-02, 7.571133e-02, 7.570653e-02, 7.528412e-02, 7.535235e-02, 7.539954e-02, 7.535435e-02, 7.541641e-02, 7.543658e-02, 7.527343e-02, 7.526024e-02, 7.528295e-02, 7.533821e-02, 7.540461e-02, 7.538317e-02, 7.531677e-02, 7.539861e-02, 7.537667e-02, 7.659318e-02, 7.656796e-02, 7.662898e-02, 7.664257e-02, 7.597872e-02, 7.597437e-02, 7.599091e-02, 7.601310e-02, 7.000359e-02, 6.999659e-02, 6.992559e-02, 6.996793e-02, 7.028519e-02, 7.032696e-02, 7.033503e-02, 6.952509e-02, 6.956378e-02, 6.952446e-02, 6.959759e-02, 6.956048e-02, 6.933134e-02, 6.932882e-02, 6.939338e-02, 6.950613e-02, 6.943631e-02, 6.946196e-02, 6.950454e-02, 7.030973e-02, 7.030203e-02, 7.032272e-02, 7.030936e-02, 7.038967e-02, 7.035136e-02, 7.024752e-02, 6.942316e-02, 6.940115e-02, 6.936367e-02, 6.860689e-02, 6.881501e-02, 6.886743e-02, 6.932714e-02, 6.970325e-02, 6.966504e-02, 6.957355e-02, 6.932303e-02, 6.938184e-02, 6.944933e-02, 6.952461e-02, 6.964167e-02};
104  Double_t dVtxPosY15o[] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,3.361709e-01, 3.361818e-01, 3.362205e-01, 3.363199e-01, 3.363092e-01, 3.362369e-01, 3.374328e-01, 3.374148e-01, 3.375140e-01, 3.361514e-01, 3.361743e-01, 3.362329e-01, 3.361395e-01, 3.361633e-01, 3.367675e-01, 3.366963e-01, 3.366845e-01, 3.366490e-01, 3.366937e-01, 3.366825e-01, 3.373764e-01, 3.373762e-01, 3.373721e-01, 3.373705e-01, 3.373943e-01, 3.373675e-01, 3.374071e-01, 3.373368e-01, 3.373442e-01, 3.375773e-01, 3.375333e-01, 3.377335e-01, 3.378285e-01, 3.362674e-01, 3.362492e-01, 3.362604e-01, 3.363473e-01, 3.295003e-01, 3.295046e-01, 3.295761e-01, 3.296100e-01, 3.291527e-01, 3.292071e-01, 3.290824e-01, 3.299371e-01, 3.300008e-01, 3.300078e-01, 3.300391e-01, 3.300740e-01, 3.300345e-01, 3.300776e-01, 3.301195e-01, 3.289427e-01, 3.289736e-01, 3.296084e-01, 3.297025e-01, 3.297724e-01, 3.298166e-01, 3.298278e-01, 3.298682e-01, 3.297381e-01, 3.296875e-01, 3.297720e-01, 3.298361e-01, 3.298561e-01, 3.299325e-01, 3.300111e-01, 3.301161e-01, 3.302630e-01, 3.289954e-01, 3.292915e-01, 3.293319e-01, 3.294174e-01, 3.314355e-01, 3.314431e-01, 3.316189e-01, 3.318682e-01, 3.323906e-01};
105  Double_t dVtxPosZ15o[] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,5.559279e-01, 3.535446e-01, 4.846955e-01, 4.525585e-01, 3.684501e-01, 2.485494e-01, 2.372653e-01, 1.707859e-01, 3.314213e-01, 1.709195e-01, 2.209753e-01, 3.125757e-01, 3.422085e-01, 3.868156e-01, 4.859695e-01, 4.780697e-01, 4.400149e-01, 4.014992e-01, 3.049883e-01, 3.708501e-01, 3.883566e-01, 3.940632e-01, 4.197670e-01, 3.938399e-01, 3.814413e-01, 3.335539e-01, 3.181929e-01, 2.300734e-01, 2.722395e-01, 5.241033e-01, 3.225908e-01, 1.925791e-01, 1.892765e-01, 3.384066e-01, 2.026459e-01, 2.495699e-01, 3.569992e-01, 3.891381e-01, 4.603724e-01, 3.696685e-01, 3.002207e-01, 2.929533e-01, 3.095468e-01, 3.517200e-01, 2.784445e-01, 3.866626e-01, 3.058719e-01, 3.336752e-01, 3.226473e-01, 3.222815e-01, 3.428469e-01, 3.728514e-01, 2.858642e-01, 2.832485e-01, 3.378933e-01, 3.547548e-01, 3.799414e-01, 4.043543e-01, 4.314049e-01, 4.141138e-01, 3.888746e-01, 4.103586e-01, 3.871045e-01, 4.614473e-01, 4.023404e-01, 4.203531e-01, 4.401272e-01, 6.450558e-01, 6.819582e-01, 2.588529e-01, 3.693471e-01, 3.990708e-01, 3.813842e-01, 3.471682e-01, 3.356156e-01, 2.550150e-01, 3.830723e-01, 4.293259e-01};
106  for(Int_t r=0; r<fnRun; r++) {
107  fRunList[r] = dRun15o[r];
108  }
109  fAvVtxPosX=TArrayD(fnRun,dVtxPosX15o);
110  fAvVtxPosY=TArrayD(fnRun,dVtxPosY15o);
111  fAvVtxPosZ=TArrayD(fnRun,dVtxPosZ15o);
112 }
113 
114 //=====================================================================
115 
117 : AliAnalysisTaskSE(name),
118 fOutputList(0x0),
119 fHistList(0x0),
120 fZDCGainAlpha(0.395),
121 fZDCCalibList(0x0),
122 fTowerEqList(0x0),
123 fCachedRunNum(0),
124 fAnalysisUtils(0x0),
125 fMultSelection(0x0),
126 fFlowEvent(NULL)
127 {
128  for(Int_t k=0; k<4; k++) {
129  fZDCQHist[k] = NULL;
130  fZDCVtxHist[k] = NULL;
131  fZDCEcomTotHist[k] = NULL;
132  for(Int_t c=0; c<10; c++) {
133  fZDCVtxCenHist[c][k] = NULL;
134  }
135  }
136  for(Int_t c=0; c<2; c++) {
137  for(Int_t i=0; i<5; i++) {
138  fTowerGainEq[c][i] = NULL;
139  }
140  }
141  for (Int_t i=0; i<2; i++) fZDCFlowVect[i] = NULL;
142 
143  Int_t dRun15o[] = {244917, 244918, 244975, 244980, 244982, 244983, 245064, 245066, 245068, 246390, 246391, 246392, 246994, 246991, 246989, 246984, 246982, 246980, 246948, 246945, 246928, 246851, 246847, 246846, 246845, 246844, 246810, 246809, 246808, 246807, 246805, 246804, 246766, 246765, 246763, 246760, 246759, 246758, 246757, 246751, 246750, 246495, 246493, 246488, 246487, 246434, 246431, 246428, 246424, 246276, 246275, 246272, 246271, 246225, 246222, 246217, 246185, 246182, 246181, 246180, 246178, 246153, 246152, 246151, 246115, 246113, 246089, 246087, 246053, 246052, 246049, 246048, 246042, 246037, 246036, 246012, 246003, 246001, 245954, 245952, 245949, 245923, 245833, 245831, 245829, 245705, 245702, 245700, 245692, 245683};
144  Double_t dVtxPosX15o[] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,7.619407e-02, 7.612905e-02, 7.609009e-02, 7.610981e-02, 7.608885e-02, 7.609981e-02, 7.559263e-02, 7.563009e-02, 7.551201e-02, 7.570994e-02, 7.571927e-02, 7.575639e-02, 7.571133e-02, 7.570653e-02, 7.528412e-02, 7.535235e-02, 7.539954e-02, 7.535435e-02, 7.541641e-02, 7.543658e-02, 7.527343e-02, 7.526024e-02, 7.528295e-02, 7.533821e-02, 7.540461e-02, 7.538317e-02, 7.531677e-02, 7.539861e-02, 7.537667e-02, 7.659318e-02, 7.656796e-02, 7.662898e-02, 7.664257e-02, 7.597872e-02, 7.597437e-02, 7.599091e-02, 7.601310e-02, 7.000359e-02, 6.999659e-02, 6.992559e-02, 6.996793e-02, 7.028519e-02, 7.032696e-02, 7.033503e-02, 6.952509e-02, 6.956378e-02, 6.952446e-02, 6.959759e-02, 6.956048e-02, 6.933134e-02, 6.932882e-02, 6.939338e-02, 6.950613e-02, 6.943631e-02, 6.946196e-02, 6.950454e-02, 7.030973e-02, 7.030203e-02, 7.032272e-02, 7.030936e-02, 7.038967e-02, 7.035136e-02, 7.024752e-02, 6.942316e-02, 6.940115e-02, 6.936367e-02, 6.860689e-02, 6.881501e-02, 6.886743e-02, 6.932714e-02, 6.970325e-02, 6.966504e-02, 6.957355e-02, 6.932303e-02, 6.938184e-02, 6.944933e-02, 6.952461e-02, 6.964167e-02};
145  Double_t dVtxPosY15o[] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,3.361709e-01, 3.361818e-01, 3.362205e-01, 3.363199e-01, 3.363092e-01, 3.362369e-01, 3.374328e-01, 3.374148e-01, 3.375140e-01, 3.361514e-01, 3.361743e-01, 3.362329e-01, 3.361395e-01, 3.361633e-01, 3.367675e-01, 3.366963e-01, 3.366845e-01, 3.366490e-01, 3.366937e-01, 3.366825e-01, 3.373764e-01, 3.373762e-01, 3.373721e-01, 3.373705e-01, 3.373943e-01, 3.373675e-01, 3.374071e-01, 3.373368e-01, 3.373442e-01, 3.375773e-01, 3.375333e-01, 3.377335e-01, 3.378285e-01, 3.362674e-01, 3.362492e-01, 3.362604e-01, 3.363473e-01, 3.295003e-01, 3.295046e-01, 3.295761e-01, 3.296100e-01, 3.291527e-01, 3.292071e-01, 3.290824e-01, 3.299371e-01, 3.300008e-01, 3.300078e-01, 3.300391e-01, 3.300740e-01, 3.300345e-01, 3.300776e-01, 3.301195e-01, 3.289427e-01, 3.289736e-01, 3.296084e-01, 3.297025e-01, 3.297724e-01, 3.298166e-01, 3.298278e-01, 3.298682e-01, 3.297381e-01, 3.296875e-01, 3.297720e-01, 3.298361e-01, 3.298561e-01, 3.299325e-01, 3.300111e-01, 3.301161e-01, 3.302630e-01, 3.289954e-01, 3.292915e-01, 3.293319e-01, 3.294174e-01, 3.314355e-01, 3.314431e-01, 3.316189e-01, 3.318682e-01, 3.323906e-01};
146  Double_t dVtxPosZ15o[] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,5.559279e-01, 3.535446e-01, 4.846955e-01, 4.525585e-01, 3.684501e-01, 2.485494e-01, 2.372653e-01, 1.707859e-01, 3.314213e-01, 1.709195e-01, 2.209753e-01, 3.125757e-01, 3.422085e-01, 3.868156e-01, 4.859695e-01, 4.780697e-01, 4.400149e-01, 4.014992e-01, 3.049883e-01, 3.708501e-01, 3.883566e-01, 3.940632e-01, 4.197670e-01, 3.938399e-01, 3.814413e-01, 3.335539e-01, 3.181929e-01, 2.300734e-01, 2.722395e-01, 5.241033e-01, 3.225908e-01, 1.925791e-01, 1.892765e-01, 3.384066e-01, 2.026459e-01, 2.495699e-01, 3.569992e-01, 3.891381e-01, 4.603724e-01, 3.696685e-01, 3.002207e-01, 2.929533e-01, 3.095468e-01, 3.517200e-01, 2.784445e-01, 3.866626e-01, 3.058719e-01, 3.336752e-01, 3.226473e-01, 3.222815e-01, 3.428469e-01, 3.728514e-01, 2.858642e-01, 2.832485e-01, 3.378933e-01, 3.547548e-01, 3.799414e-01, 4.043543e-01, 4.314049e-01, 4.141138e-01, 3.888746e-01, 4.103586e-01, 3.871045e-01, 4.614473e-01, 4.023404e-01, 4.203531e-01, 4.401272e-01, 6.450558e-01, 6.819582e-01, 2.588529e-01, 3.693471e-01, 3.990708e-01, 3.813842e-01, 3.471682e-01, 3.356156e-01, 2.550150e-01, 3.830723e-01, 4.293259e-01};
147  for(Int_t r=0; r<fnRun; r++) {
148  fRunList[r] = dRun15o[r];
149  }
150  fAvVtxPosX=TArrayD(fnRun,dVtxPosX15o);
151  fAvVtxPosY=TArrayD(fnRun,dVtxPosY15o);
152  fAvVtxPosZ=TArrayD(fnRun,dVtxPosZ15o);
153 
154  DefineInput(0,TChain::Class());
155  DefineOutput(1,AliFlowEventSimple::Class());
156 }
157 
158 //=====================================================================
159 
161 {
162  // Destructor
163  delete fOutputList;
164  delete fHistList;
165  delete fFlowEvent;
166  if(fAnalysisUtils) delete fAnalysisUtils;
167  if(fMultSelection) delete fMultSelection;
168 }
169 
170 //=====================================================================
171 
173 {
174  // create a new TList that OWNS its objects
175  fOutputList = new TList();
176  fOutputList->SetOwner(kTRUE);
177 
178  for(Int_t c=0;c<2;c++) {
179  fZDCFlowVect[c] = new AliFlowVector();
180  fOutputList->Add(fZDCFlowVect[c]);
181  }
182 
183  fHistList = new TList();
184  fHistList->SetOwner(kTRUE);
185 
186  for(Int_t k=0; k<4; k++) {
187  fZDCQHist[k] = new TProfile();
188  fHistList->Add(fZDCQHist[k]);
189  fZDCVtxHist[k] = new TProfile3D();
190  fHistList->Add(fZDCVtxHist[k]);
191  fZDCEcomTotHist[k] = new TProfile2D();
192  fHistList->Add(fZDCEcomTotHist[k]);
193  for(Int_t c=0; c<10; c++) {
194  fZDCVtxCenHist[c][k] = new TProfile3D();
195  fHistList->Add(fZDCVtxCenHist[c][k]);
196  }
197  }
198  for(Int_t c=0; c<2; c++) {
199  for(Int_t i=0; i<5; i++) {
200  fTowerGainEq[c][i] = new TH1D();
201  fHistList->Add(fTowerGainEq[c][i]);
202  }
203  }
204 
205  fAnalysisUtils = new AliAnalysisUtils;
206  fAnalysisUtils->SetUseMVPlpSelection(kTRUE);
207  fAnalysisUtils->SetUseOutOfBunchPileUp(kTRUE);
208 
209  fFlowEvent = new AliFlowEvent(1);
210 }
211 
212 //=====================================================================
213 
215 {
216  // get an event from the analysis manager
217  AliAODEvent *aod = dynamic_cast<AliAODEvent*>(InputEvent());
218  if(!aod) return;
219  Float_t Centrality = 0.;
220  fMultSelection = (AliMultSelection*)aod->FindListObject("MultSelection");
221  if(!fMultSelection) {
222  AliWarning("WARNING: AliMultSelection object not found ! \n");
223  } else {
224  Centrality = fMultSelection->GetMultiplicityPercentile("V0M");
225  }
226  Int_t RunNum = aod->GetRunNumber();
227  Int_t RunBin=-1, bin=0;
228  for(Int_t c=0;c<fnRun;c++) {
229  if(fRunList[c]==RunNum) RunBin=bin;
230  else bin++;
231  }
232  if(RunBin==-1) return;
233  Int_t fCenBin = GetCenBin(Centrality);
234 
235  // get primary vertex position
236  Double_t fVtxPos[3]={0.,0.,0.};
237  fVtxPos[0] = ((AliAODVertex*)aod->GetPrimaryVertex())->GetX();
238  fVtxPos[1] = ((AliAODVertex*)aod->GetPrimaryVertex())->GetY();
239  fVtxPos[2] = ((AliAODVertex*)aod->GetPrimaryVertex())->GetZ();
240  Double_t fVtxPosCor[3] = {fVtxPos[0]-fAvVtxPosX[RunBin],fVtxPos[1]-fAvVtxPosY[RunBin],fVtxPos[2]-fAvVtxPosZ[RunBin]};
241 
242  // event cuts
243  // const AliVVertex* pvtx = aod->GetPrimaryVertex();
244  // Double_t pvtxz = 0.;
245  // Int_t ncontrib = 0;
246  // if(pvtx) pvtxz = pvtx->GetZ();
247  // if(fabs(pvtxz)>10.) return;
248  // if(fAnalysisUtils->IsPileUpEvent(InputEvent())) return;
249 
250  // zdc selection
251  AliAODZDC *aodZDC = aod->GetZDCData();
252 
253  const Double_t * towZNCraw = aodZDC->GetZNCTowerEnergy();
254  const Double_t * towZNAraw = aodZDC->GetZNATowerEnergy();
255 
256  // Get centroid from ZDCs *******************************************************
257 
258  Double_t Enucl = (RunNum < 209122 ? 1380. : 2511.);
259  Double_t xyZNC[2]={0.,0.}, xyZNA[2]={0.,0.};
260  Double_t towZNC[5]={0.}, towZNA[5]={0.};
261 
262  Double_t ZNCcalib=1., ZNAcalib=1.;
263 
264  // equalize gain of all towers
265  if(RunNum!=fCachedRunNum) {
266  for(Int_t i=0; i<5; i++) {
267  fTowerGainEq[0][i] = (TH1D*)(fTowerEqList->FindObject(Form("fZNCTower[%d][%d]",RunNum,i)));
268  fTowerGainEq[1][i] = (TH1D*)(fTowerEqList->FindObject(Form("fZNATower[%d][%d]",RunNum,i)));
269  }
270  }
271  for(Int_t i=0; i<5; i++) {
272  if(fTowerGainEq[0][i]) towZNC[i] = towZNCraw[i]*fTowerGainEq[0][i]->GetBinContent(fTowerGainEq[0][i]->FindBin(Centrality));
273  if(fTowerGainEq[1][i]) towZNA[i] = towZNAraw[i]*fTowerGainEq[1][i]->GetBinContent(fTowerGainEq[1][i]->FindBin(Centrality));
274  }
275 
276  if(RunNum>=245829) towZNA[2] = 0.;
277  Double_t zncEnergy=0., znaEnergy=0.;
278  for(Int_t i=0; i<5; i++){
279  zncEnergy += towZNC[i];
280  znaEnergy += towZNA[i];
281  }
282  if(RunNum>=245829) znaEnergy *= 8./7.;
283  Double_t fZNCen = towZNC[0]/Enucl;
284  Double_t fZNAen = towZNA[0]/Enucl;
285 
286  const Double_t x[4] = {-1.75, 1.75, -1.75, 1.75};
287  const Double_t y[4] = {-1.75, -1.75, 1.75, 1.75};
288  Double_t numXZNC=0., numYZNC=0., denZNC=0., cZNC, wZNC, EZNC, SumEZNC=0.;
289  Double_t numXZNA=0., numYZNA=0., denZNA=0., cZNA, wZNA, EZNA, SumEZNA=0., BadChOr;
290  Bool_t fAllChONZNC=kTRUE, fAllChONZNA=kTRUE;
291 
292  for(Int_t i=0; i<4; i++){
293  // get energy
294  EZNC = towZNC[i+1];
295  SumEZNC += EZNC;
296 
297  // build centroid
298  wZNC = TMath::Power(EZNC, fZDCGainAlpha);
299  numXZNC += x[i]*wZNC;
300  numYZNC += y[i]*wZNC;
301  denZNC += wZNC;
302 
303  // get energy
304  if(i==1) {
305  EZNA = towZNA[0]-towZNA[1]-towZNA[3]-towZNA[4];
306  } else {
307  EZNA = towZNA[i+1];
308  }
309  SumEZNA += EZNA;
310 
311  // build centroid
312  wZNA = TMath::Power(EZNA, fZDCGainAlpha);
313  numXZNA += x[i]*wZNA;
314  numYZNA += y[i]*wZNA;
315  denZNA += wZNA;
316  }
317  if(denZNC>0.){
318  Double_t nSpecnC = SumEZNC/Enucl;
319  cZNC = 1.89358-0.71262/(nSpecnC+0.71789);
320  xyZNC[0] = cZNC*numXZNC/denZNC;
321  xyZNC[1] = cZNC*numYZNC/denZNC;
322  denZNC *= cZNC;
323  }
324  else{
325  xyZNC[0] = xyZNC[1] = 0.;
326  }
327  if(denZNA>0.){
328  Double_t nSpecnA = SumEZNA/Enucl;
329  cZNA = 1.89358-0.71262/(nSpecnA+0.71789);
330  xyZNA[0] = cZNA*numXZNA/denZNA;
331  xyZNA[1] = cZNA*numYZNA/denZNA;
332  denZNA *= cZNA;
333  }
334  else{
335  xyZNA[0] = xyZNA[1] = 0.;
336  }
337 
338  fZDCFlowVect[0]->Set(xyZNC[0],xyZNC[1]);
339  fZDCFlowVect[1]->Set(xyZNA[0],xyZNA[1]);
340  fZDCFlowVect[0]->SetMult(denZNC);
341  fZDCFlowVect[1]->SetMult(denZNA);
342 
343  if(fZDCCalibList) {
344  if(RunNum!=fCachedRunNum) {
345  // get histos of run
346  fZDCQHist[0] = (TProfile*)(fZDCCalibList->FindObject(Form("Run %d",RunNum))->FindObject(Form("fCRCZDCQVecC[%d][%d]",RunNum,0)));
347  fZDCQHist[1] = (TProfile*)(fZDCCalibList->FindObject(Form("Run %d",RunNum))->FindObject(Form("fCRCZDCQVecC[%d][%d]",RunNum,1)));
348  fZDCQHist[2] = (TProfile*)(fZDCCalibList->FindObject(Form("Run %d",RunNum))->FindObject(Form("fCRCZDCQVecA[%d][%d]",RunNum,0)));
349  fZDCQHist[3] = (TProfile*)(fZDCCalibList->FindObject(Form("Run %d",RunNum))->FindObject(Form("fCRCZDCQVecA[%d][%d]",RunNum,1)));
350 
351  for(Int_t k=0; k<4; k++) {
352  fZDCVtxHist[k] = (TProfile3D*)(fZDCCalibList->FindObject(Form("Run %d",RunNum))->FindObject(Form("fCRCZDCQVecVtxPos[%d][%d]",RunNum,k)));
353 
354  fZDCEcomTotHist[k] = (TProfile2D*)(fZDCCalibList->FindObject(Form("fCRCZDCQVecEComTot[%d]",k)));
355  }
356 
357  for(Int_t c=0; c<10; c++) {
358  for(Int_t k=0; k<4; k++) {
359  fZDCVtxCenHist[c][k] = (TProfile3D*)(fZDCCalibList->FindObject(Form("fCRCZDCQVecVtxPosCen[%d][%d]",c,k)));
360  }
361  }
362  }
363 
364  // ZDCN-C
365  Double_t QCRe = fZDCFlowVect[0]->X();
366  Double_t QCIm = fZDCFlowVect[0]->Y();
367  Double_t QMC = fZDCFlowVect[0]->GetMult();
368  // ZDCN-A
369  Double_t QARe = fZDCFlowVect[1]->X();
370  Double_t QAIm = fZDCFlowVect[1]->Y();
371  Double_t QMA = fZDCFlowVect[1]->GetMult();
372 
373  Double_t QCReR=QCRe, QCImR=QCIm, QAReR=QARe, QAImR=QAIm;
374 
375  // STEP #1: re-center vs centrality (1%) vs run number
376 
377  if (fZDCQHist[0]) {
378  Double_t AvQCRe = fZDCQHist[0]->GetBinContent(fZDCQHist[0]->FindBin(Centrality));
379  Double_t SDQCRe = fZDCQHist[0]->GetBinError(fZDCQHist[0]->FindBin(Centrality));
380  Double_t AvQCIm = fZDCQHist[1]->GetBinContent(fZDCQHist[1]->FindBin(Centrality));
381  Double_t SDQCIm = fZDCQHist[1]->GetBinError(fZDCQHist[1]->FindBin(Centrality));
382 
383  Double_t AvQARe = fZDCQHist[2]->GetBinContent(fZDCQHist[2]->FindBin(Centrality));
384  Double_t SDQARe = fZDCQHist[2]->GetBinError(fZDCQHist[2]->FindBin(Centrality));
385  Double_t AvQAIm = fZDCQHist[3]->GetBinContent(fZDCQHist[3]->FindBin(Centrality));
386  Double_t SDQAIm = fZDCQHist[3]->GetBinError(fZDCQHist[3]->FindBin(Centrality));
387 
388  if(AvQCRe && AvQCIm && QMC>0. && sqrt(QCRe*QCRe+QCIm*QCIm)>1.E-6) {
389  QCReR = QCRe-AvQCRe;
390  QCImR = QCIm-AvQCIm;
391  fZDCFlowVect[0]->Set(QCReR,QCImR);
392  }
393 
394  if(AvQARe && AvQAIm && QMA>0. && sqrt(QARe*QARe+QAIm*QAIm)>1.E-6) {
395  QAReR = QARe-AvQARe;
396  QAImR = QAIm-AvQAIm;
397  fZDCFlowVect[1]->Set(QAReR,QAImR);
398  }
399  }
400 
401  // STEP #2: re-center vs primary vtx vs centrality (10%)
402 
403  if (fZDCVtxCenHist[fCenBin][0]) {
404  Bool_t pass = kTRUE;
405  if(fVtxPosCor[0] < fZDCVtxCenHist[fCenBin][0]->GetXaxis()->GetXmin() || fVtxPosCor[0] > fZDCVtxCenHist[fCenBin][0]->GetXaxis()->GetXmax()) pass = kFALSE;
406  if(fVtxPosCor[1] < fZDCVtxCenHist[fCenBin][0]->GetYaxis()->GetXmin() || fVtxPosCor[1] > fZDCVtxCenHist[fCenBin][0]->GetYaxis()->GetXmax()) pass = kFALSE;
407  if(fVtxPosCor[2] < fZDCVtxCenHist[fCenBin][0]->GetZaxis()->GetXmin() || fVtxPosCor[2] > fZDCVtxCenHist[fCenBin][0]->GetZaxis()->GetXmax()) pass = kFALSE;
408  if(!pass) {
409  fZDCFlowVect[0]->Set(0.,0.);
410  fZDCFlowVect[1]->Set(0.,0.);
411  return;
412  } else {
413  QCReR -= fZDCVtxCenHist[fCenBin][0]->GetBinContent(fZDCVtxCenHist[fCenBin][0]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
414  QCImR -= fZDCVtxCenHist[fCenBin][1]->GetBinContent(fZDCVtxCenHist[fCenBin][1]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
415  QAReR -= fZDCVtxCenHist[fCenBin][2]->GetBinContent(fZDCVtxCenHist[fCenBin][2]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
416  QAImR -= fZDCVtxCenHist[fCenBin][3]->GetBinContent(fZDCVtxCenHist[fCenBin][3]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
417  fZDCFlowVect[0]->Set(QCReR,QCImR);
418  fZDCFlowVect[1]->Set(QAReR,QAImR);
419  }
420  }
421 
422  // STEP #3: re-center vs primary vtx vs run number
423 
424  if (fZDCVtxHist[0]) {
425  QCReR -= fZDCVtxHist[0]->GetBinContent(fZDCVtxHist[0]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
426  QCImR -= fZDCVtxHist[1]->GetBinContent(fZDCVtxHist[1]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
427  fZDCFlowVect[0]->Set(QCReR,QCImR);
428  QAReR -= fZDCVtxHist[2]->GetBinContent(fZDCVtxHist[2]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
429  QAImR -= fZDCVtxHist[3]->GetBinContent(fZDCVtxHist[3]->FindBin(fVtxPosCor[0],fVtxPosCor[1],fVtxPosCor[2]));
430  fZDCFlowVect[1]->Set(QAReR,QAImR);
431  }
432 
433  // STEP #4: re-center vs centrality vs energy in the common tower
434 
435  if(fZDCEcomTotHist[0]) {
436  QCReR -= fZDCEcomTotHist[0]->GetBinContent(fZDCEcomTotHist[0]->FindBin(Centrality,fZNCen));
437  QCImR -= fZDCEcomTotHist[1]->GetBinContent(fZDCEcomTotHist[1]->FindBin(Centrality,fZNCen));
438  fZDCFlowVect[0]->Set(QCReR,QCImR);
439  QAReR -= fZDCEcomTotHist[2]->GetBinContent(fZDCEcomTotHist[2]->FindBin(Centrality,fZNAen));
440  QAImR -= fZDCEcomTotHist[3]->GetBinContent(fZDCEcomTotHist[3]->FindBin(Centrality,fZNAen));
441  fZDCFlowVect[1]->Set(QAReR,QAImR);
442  }
443 
444  } else {
445  printf("WARNING: no list provided for ZDC Q-vector re-centering ! \n");
446  }
447 
448  Double_t xyZNCfinal[2]={fZDCFlowVect[0]->X(),fZDCFlowVect[0]->Y()};
449  Double_t xyZNAfinal[2]={-fZDCFlowVect[1]->X(),fZDCFlowVect[1]->Y()}; // this is not a bug: QAReR --> -QAReR
450  fFlowEvent->SetZDC2Qsub(xyZNCfinal,denZNC,xyZNAfinal,denZNA);
451 
452  // save run number
453  fCachedRunNum = RunNum;
454 
455  PostData(1, fFlowEvent);
456 }
457 
458 //=====================================================================
459 
461 {
462  QAX = fZDCFlowVect[1]->X();
463  QAY = fZDCFlowVect[1]->Y();
464  QCX = fZDCFlowVect[0]->X();
465  QCY = fZDCFlowVect[0]->Y();
466 }
467 
468 //=====================================================================
469 
471 {
472  Int_t CenBin=-1;
473  if (Centrality>0. && Centrality<5.) CenBin=0;
474  if (Centrality>5. && Centrality<10.) CenBin=1;
475  if (Centrality>10. && Centrality<20.) CenBin=2;
476  if (Centrality>20. && Centrality<30.) CenBin=3;
477  if (Centrality>30. && Centrality<40.) CenBin=4;
478  if (Centrality>40. && Centrality<50.) CenBin=5;
479  if (Centrality>50. && Centrality<60.) CenBin=6;
480  if (Centrality>60. && Centrality<70.) CenBin=7;
481  if (Centrality>70. && Centrality<80.) CenBin=8;
482  if (Centrality>80. && Centrality<90.) CenBin=9;
483  if (Centrality>90. && Centrality<100.) CenBin=10;
484  return CenBin;
485 } // end of AliAnalysisTaskZDCEP::GetCenBin(Double_t Centrality)
486 
487 //=====================================================================
488 
490 {
491 }
492 
493 
void GetZDCQVectors(Double_t QAX, Double_t QAY, Double_t QCX, Double_t QCY)
double Double_t
Definition: External.C:58
Double_t fZDCGainAlpha
output list containing QA histograms
virtual void SetZDC2Qsub(Double_t *QVC, Double_t MC, Double_t *QVA, Double_t MA)
Double_t GetMult() const
Definition: AliFlowVector.h:46
TCanvas * c
Definition: TestFitELoss.C:172
AliFlowVector * fZDCFlowVect[2]
virtual void Terminate(Option_t *option)
TList * fHistList
output list containing ZDC q-vectors
int Int_t
Definition: External.C:63
virtual void UserCreateOutputObjects()
float Float_t
Definition: External.C:68
void SetMult(Double_t mult)
Definition: AliFlowVector.h:45
Definition: External.C:212
AliAnalysisUtils * fAnalysisUtils
TArrayD fAvVtxPosX
run-by-run list
virtual void UserExec(Option_t *option)
virtual Int_t GetCenBin(Double_t Centrality)
Int_t fCachedRunNum
ZDC q-vectors.
Definition: External.C:220
TProfile2D * fZDCEcomTotHist[4]
static const Int_t fnRun
TProfile3D * fZDCVtxHist[4]
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
AliMultSelection * fMultSelection
Definition: External.C:196
TProfile3D * fZDCVtxCenHist[10][4]