0cfc28d9526ac9ea7a4a706ff4f2454435564d8f
[u/mrichter/AliRoot.git] / PWGPP / Centrality / AliMultiplicityCorrelations.cxx
1 //-*- Mode: C++ -*-
2
3 #if __GNUC__>= 3
4    using namespace std;
5 #endif
6
7 #include "TH1F.h"
8 #include "TH2F.h"
9 #include "TList.h"
10
11 #include "AliMultiplicityCorrelations.h"
12
13 // Task for HI Multiplicity correlation checks
14 // Author: Jochen Thaeder <jochen@thaeder.de>
15
16 /** ROOT macro for the implementation of ROOT specific class methods */
17 ClassImp(AliMultiplicityCorrelations)
18
19 /*
20  * ---------------------------------------------------------------------------------
21  *                            Constructor / Destructor
22  * ---------------------------------------------------------------------------------
23  */
24
25 //##################################################################################
26 AliMultiplicityCorrelations::AliMultiplicityCorrelations() :
27   TNamed(),
28   fHistList(NULL),
29   fIsMC(kFALSE),
30   fESDEvent(NULL),
31   fESDZDC(NULL), fESDVZERO(NULL), fESDMultiplicity(NULL),
32   fESDTrackCuts(NULL), fESDTrackCuts2(NULL),
33   fCleanSample(kFALSE), fCleanMinKeep(0.),fCleanMaxKeep(999999999.),
34   fRunNo(-1), fCurrentRunNo(-1),
35   fProcessTPC(kTRUE), fProcessSPD(kTRUE), fProcessVZERO(kTRUE), fProcessZDC(kTRUE),
36   fEsdTracks(0), fEsdTracksA(0), fTpcTracks(0), fTpcTracksA(0),
37   fVzeroMult(0.), fVzeroMultA(0.), fVzeroMultC(0.),
38   fSpdNClusters(0), fSpdNClustersInner(0), fSpdNClustersOuter(0),
39   fVzeroBinning(1500), fVzeroBinningMin(0.), fVzeroBinningMax(30000.),
40   fTpcBinning(800),fTpcBinningMin(0.),fTpcBinningMax(8000.),
41   fZdcBinning(1000),fZdcBinningMin(0.),fZdcBinningMax(6000.),
42   fZemBinning(500),fZemBinningMin(0.),fZemBinningMax(2500.),
43   fSpdBinning(750),fSpdBinningMin(0.),fSpdBinningMax(15000.) {
44   // see header file for class documentation
45   
46 }
47 //##################################################################################
48 AliMultiplicityCorrelations::AliMultiplicityCorrelations(Char_t* name, Char_t* title) : 
49   TNamed(name,title), 
50   fHistList(NULL),
51   fIsMC(kFALSE),
52   fESDEvent(NULL),
53   fESDZDC(NULL), fESDVZERO(NULL), fESDMultiplicity(NULL),
54   fESDTrackCuts(NULL), fESDTrackCuts2(NULL),       
55   fCleanSample(kFALSE), fCleanMinKeep(0.),fCleanMaxKeep(999999999.),
56   fRunNo(-1), fCurrentRunNo(-1),
57   fProcessTPC(kTRUE), fProcessSPD(kTRUE),fProcessVZERO(kTRUE), fProcessZDC(kTRUE),
58   fEsdTracks(0), fEsdTracksA(0), fTpcTracks(0), fTpcTracksA(0),
59   fVzeroMult(0.), fVzeroMultA(0.), fVzeroMultC(0.),
60   fSpdNClusters(0), fSpdNClustersInner(0), fSpdNClustersOuter(0),
61   fVzeroBinning(1000), fVzeroBinningMin(0.), fVzeroBinningMax(20000.),
62   fTpcBinning(800),fTpcBinningMin(0.),fTpcBinningMax(8000.),
63   fZdcBinning(280),fZdcBinningMin(0.),fZdcBinningMax(140.),
64   fZemBinning(100),fZemBinningMin(0.),fZemBinningMax(5.),
65   fSpdBinning(750),fSpdBinningMin(0.),fSpdBinningMax(15000.) {
66   // see header file for class documentation
67   
68 }
69
70 //##################################################################################
71 AliMultiplicityCorrelations::~AliMultiplicityCorrelations() {
72   // see header file for class documentation
73
74   if ( fHistList ) {
75     fHistList->Clear();
76     delete fHistList;
77   }
78   fHistList = NULL;
79 }
80
81 /*
82  * ---------------------------------------------------------------------------------
83  *                                   Initialize / Reset
84  * ---------------------------------------------------------------------------------
85  */
86
87 //##################################################################################
88 Int_t AliMultiplicityCorrelations::Initialize( const Char_t* listName) {
89   // see header file for class documentation  
90
91   Int_t iResult = 0;
92
93   fHistList = new TList();
94   fHistList->SetOwner(kTRUE);
95   fHistList->SetName(Form("MultiplicityCorrelations_%s",listName));
96   iResult = SetupHistograms();
97   
98   if (fProcessZDC)   { AliInfo("Processing of ZDC enabled"); }
99   if (fProcessTPC)   { AliInfo("Processing of TPC enabled"); }
100   if (fProcessSPD)   { AliInfo("Processing of SPD enabled"); }
101   if (fProcessVZERO) { AliInfo("Processing of VZERO enabled"); }
102
103   return iResult;
104 }
105
106 /*
107  * ---------------------------------------------------------------------------------
108  *                             Output - public
109  * ---------------------------------------------------------------------------------
110  */
111
112 //##################################################################################
113 Int_t AliMultiplicityCorrelations::ProcessEvent(AliESDEvent *esd) {
114   // see header file for class documentation  
115
116   Int_t iResult = 0;
117
118   if ( ! AddESDEvent(esd) ) {
119     AliWarning("No ESD event.");
120     return -1;
121   }
122   
123   // -- TPC .. To be done before the others
124   if (fESDEvent->GetNumberOfTracks() > 0 && fProcessTPC)
125     iResult = ProcessTPC();
126     
127   // -- TPC / global track cuts
128   if (iResult == -3)
129     return iResult;
130   
131   // -- check if cleaning 
132   if (iResult == -2)
133     return iResult;
134   
135   // -- SPD
136   if (fESDMultiplicity && fProcessSPD)
137     iResult = ProcessSPD();
138   
139   // -- VZERO
140   if (fESDVZERO && fProcessVZERO)
141     iResult = ProcessVZERO();
142
143   // -- ZDC and Correlations
144   if (fESDZDC && fProcessZDC)
145     iResult = ProcessZDC();
146  
147   return iResult;
148 }
149
150 ////////////////////////////////////////////////////////////////////////////////////
151 ////////////////////////////////////////////////////////////////////////////////////
152 ///                                                                              ///
153 //////                             PRIVATE                                    //////
154 ///                                                                              ///
155 ////////////////////////////////////////////////////////////////////////////////////
156 ////////////////////////////////////////////////////////////////////////////////////
157
158 /*
159  * ---------------------------------------------------------------------------------
160  *                          Setup / Initialize - private
161  * ---------------------------------------------------------------------------------
162  */
163
164 //##################################################################################
165 Bool_t AliMultiplicityCorrelations::AddESDEvent( AliESDEvent* esd ) {
166   // see header file for class documentation  
167
168   fESDEvent = esd;
169   
170   // -- Check for ESD
171   if ( !fESDEvent ) {
172     AliWarning("No ESD event present.");
173     return kFALSE;
174   }
175     
176   fESDZDC = esd->GetESDZDC();
177   if ( !fESDZDC ) {
178     AliInfo("No ZDC information !");
179   }
180   
181   fESDVZERO = esd->GetVZEROData();
182   if ( !fESDVZERO ) {
183     AliInfo("No VZERO information !");
184   }
185   
186   fESDMultiplicity = const_cast<AliMultiplicity*>(esd->GetMultiplicity());
187   if ( !fESDMultiplicity ) {
188     AliInfo("No Multiplicity information !");
189   }
190
191   if (fCurrentRunNo == esd->GetRunNumber())
192     return kTRUE;
193       
194   fCurrentRunNo = esd->GetRunNumber();
195   fRunNo = fCurrentRunNo;
196
197   // CHANGE HERE FOR RUN RANGES
198   if      ( fRunNo == 137162 ) fRunNo = 137161;
199   else if ( fRunNo == 137365 ) fRunNo = 137366;
200   else if ( fRunNo  > 137366 ) fRunNo = 137366;
201   // CHANGE HERE FOR RUN RANGES
202
203   return kTRUE;
204 }
205
206 //##################################################################################
207 Int_t AliMultiplicityCorrelations::SetupHistograms() {
208   // see header file for class documentation  
209
210   Int_t iResult = 0;
211   
212   if (fProcessVZERO) iResult = SetupVZERO();
213   if (fProcessZDC)   iResult = SetupZDC();
214   if (fProcessTPC)   iResult = SetupTPC();
215   if (fProcessSPD)   iResult = SetupSPD();
216   
217   iResult = SetupCorrelations();
218
219   return iResult;
220 }
221
222 //##################################################################################
223 Int_t AliMultiplicityCorrelations::SetupVZERO() {
224   // see header file for class documentation  
225
226   // VzeroMult
227   fHistList->Add(new TH1F("fVzeroMult",  "Multiplicity^{VZERO};Multiplicity^{VZERO};N_{Events}",   
228                           fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
229
230   fHistList->Add(new TH1F("fVzeroMultUnCorr", "Multiplicity^{VZERO} uncorrected;Multiplicity^{VZERO};N_{Events}",   
231                           fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
232
233   fHistList->Add(new TH2F("fVzeroMultAC", "Multiplicity^{VZERO} A vs C;Multiplicity^{VZERO}A ;Multiplicity^{VZERO} C", 
234                           fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax, fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax)); 
235
236   return 0;
237 }
238
239 //##################################################################################
240 Int_t AliMultiplicityCorrelations::SetupZDC() {
241   // see header file for class documentation  
242     
243   // E_{ZDC}
244   fHistList->Add(new TH1F("fZdcEzdc",  "E_{ZDC};E_{ZDC} (TeV);N_{Events}",   
245                           fZdcBinning,fZdcBinningMin,fZdcBinningMax));
246
247   // E_{ZEM}
248   fHistList->Add(new TH1F("fZdcEzem",  "E_{ZEM};E_{ZEM} (TeV);N_{Events}",   
249                           fZemBinning,fZemBinningMin,fZemBinningMax));
250   
251   // E_{ZEM} vs E_{ZDC} 
252   fHistList->Add(new TH2F("fZdcEzemEzdc", "E_{ZEM} vs E_{ZDC};E_{ZEM} (TeV); E_{ZDC} (TeV)",   
253                           fZemBinning,fZemBinningMin,fZemBinningMax, fZdcBinning,fZdcBinningMin,fZdcBinningMax));
254
255   return 0;
256 }
257
258 //##################################################################################
259 Int_t AliMultiplicityCorrelations::SetupTPC() {
260   // see header file for class documentation  
261
262   // Multiplicity
263   fHistList->Add(new TH1F("fTpcNch0", "N_{ch} esdTracks; N_{ch};N_{Events}", 
264                           fTpcBinning,fTpcBinningMin,fTpcBinningMax));
265   fHistList->Add(new TH1F("fTpcNch1", "N_{ch} accepted esdTracks; N_{ch};N_{Events}", 
266                           fTpcBinning,fTpcBinningMin,fTpcBinningMax));
267   fHistList->Add(new TH1F("fTpcNch2", "N_{ch} tpcTracks; N_{ch};N_{Events}", 
268                           fTpcBinning,fTpcBinningMin,fTpcBinningMax));
269   fHistList->Add(new TH1F("fTpcNch3", "N_{ch} accepted tpcTracks; N_{ch};N_{Events}", 
270                           fTpcBinning,fTpcBinningMin,fTpcBinningMax));
271
272   fHistList->Add(new TH2F("fTpcCorrNch","N_{ch} accepted tpcTracks vs globalTracks; N_{tpc};N_{global}", 
273                           fTpcBinning,fTpcBinningMin,fTpcBinningMax, fTpcBinning,fTpcBinningMin,fTpcBinningMax));
274
275   fHistList->Add(new TH1F("fTpcRatioNch","N_{ch} accepted tpcTracks/globalTracks; N_{ch};Ratio", 
276                           201,0.,2.));
277
278   fHistList->Add(new TH2F("fTpcCorrNchAll","N_{ch} accepted tpcTracks vs globalTracks - uncleaned ; N_{tpc};N_{global}", 
279                           fTpcBinning,fTpcBinningMin,fTpcBinningMax, fTpcBinning,fTpcBinningMin,fTpcBinningMax));
280
281   fHistList->Add(new TH1F("fTpcRatioNchAll","N_{ch} accepted tpcTracks/globalTracks - uncleaned; N_{ch};Ratio", 
282                           201,0.,2.));
283
284   return 0;
285 }
286
287 //##################################################################################
288 Int_t AliMultiplicityCorrelations::SetupCorrelations() {
289   // see header file for class documentation  
290
291   // ----------------------------------------------------
292   //   TPC vs ZDC
293   // ----------------------------------------------------
294   if (fProcessTPC && fProcessZDC) {
295
296     // N_{ch} vs E_{ZDC}
297     fHistList->Add(new TH2F("fCorrEzdcNch", "N_{ch}^{TPC} vs E_{ZDC};N_{ch}^{TPC};E_{ZDC} (TeV)",   
298                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fZdcBinning,fZdcBinningMin,fZdcBinningMax));
299
300
301     // N_{ch} vs E_{ZEM}
302     fHistList->Add(new TH2F("fCorrEzemNch", "N_{ch}^{TPC} vs E_{ZEM};N_{ch}^{TPC};E_{ZEM} (TeV)",   
303                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fZdcBinning,fZdcBinningMin,fZdcBinningMax));
304   }
305   // ----------------------------------------------------
306   //   ZDC vs VZERO
307   // ----------------------------------------------------
308   if (fProcessZDC && fProcessVZERO) {
309
310     // E_{ZDC} vs Multiplicity VZERO
311     fHistList->Add(new TH2F("fCorrEzdcVzero", 
312                             "E_{ZDC} vs Multiplicity^{VZERO};E_{ZDC} (TeV);Multiplicity^{VZERO}",  
313                             fZdcBinning,fZdcBinningMin,fZdcBinningMax, fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
314     
315     // E_{ZEM} vs Multiplicity VZERO
316     fHistList->Add(new TH2F("fCorrEzemVzero", 
317                             "E_{ZEM} vs Multiplicity^{VZERO};E_{ZEM} (TeV);Multiplicity^{VZERO}",  
318                             fZemBinning,fZemBinningMin,fZemBinningMax, fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
319
320   }
321   // ----------------------------------------------------
322   //   TPC vs VZERO
323   // ----------------------------------------------------
324   if ( fProcessTPC && fProcessVZERO ) {
325
326     fHistList->Add(new TH2F("fCorrVzeroNch", 
327                             "N_{ch}^{TPC} vs Multiplicity^{VZERO};N_{ch}^{TPC};Multiplicity^{VZERO}", 
328                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
329
330     fHistList->Add(new TH2F("fCorrVzeroNchUnCorr", 
331                             "N_{ch}^{TPC} vs Multiplicity^{VZERO} uncorrected;N_{ch}^{TPC};Multiplicity^{VZERO}", 
332                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
333
334     fHistList->Add(new TH2F("fCorrVzeroESDNch", 
335                             "N_{ch}^{global} vs Multiplicity^{VZERO};N_{ch}^{TPC};Multiplicity^{VZERO}", 
336                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
337
338     fHistList->Add(new TH2F("fCorrVzeroESDNchUnCorr", 
339                             "N_{ch}^{global} vs Multiplicity^{VZERO} uncorrected;N_{ch}^{TPC};Multiplicity^{VZERO}", 
340                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax));
341
342   }
343   // ----------------------------------------------------
344   //   TPC vs SPD
345   // ----------------------------------------------------
346   if ( fProcessSPD && fProcessTPC ) {
347
348     fHistList->Add(new TH2F("fCorrSpdTpcNch", "N_{ch}^{TPC} vs N_{clusters}^{SPD};N_{ch}^{TPC};N_{clusters}^{SPD}",   
349                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fSpdBinning,fSpdBinningMin,fSpdBinningMax));  
350
351     fHistList->Add(new TH2F("fCorrSpdOuterTpcNch"," N_{ch}^{TPC} vs N_{clusters}^{SPD}_{Outer};N_{ch}^{TPC};N_{clusters}^{SPD}",   
352                             fTpcBinning,fTpcBinningMin,fTpcBinningMax, fSpdBinning,fSpdBinningMin,fSpdBinningMax));  
353   }
354   // ----------------------------------------------------
355   //   SPD vs VZERO
356   // ----------------------------------------------------
357   if ( fProcessSPD && fProcessVZERO ) {
358
359     fHistList->Add(new TH2F("fCorrVzeroSpd", 
360                             "Multiplicity^{VZERO} vs N_{ch}^{SPD};Multiplicity^{VZERO};N^{SPD}", 
361                             fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax, fSpdBinning,fSpdBinningMin,fSpdBinningMax));
362     
363     fHistList->Add(new TH2F("fCorrVzeroSpdOuter", 
364                             "Multiplicity^{VZERO} vs N_{ch}^{SPD}_{Outer};Multiplicity^{VZERO};N^{SPD}", 
365                             fVzeroBinning,fVzeroBinningMin,fVzeroBinningMax, fSpdBinning,fSpdBinningMin,fSpdBinningMax));
366   }
367   // ----------------------------------------------------
368   //   SPD vs ZDC
369   // ----------------------------------------------------
370   if ( fProcessSPD && fProcessZDC) {
371
372     // E_{ZDC} vs Multiplicity SPD
373     fHistList->Add(new TH2F("fCorrEzdcSpd", "E_{ZDC} vs N_{ch}^{SPD};E_{ZDC} (TeV);N^{SPD}",   
374                             fZdcBinning,fZdcBinningMin,fZdcBinningMax, fSpdBinning,fSpdBinningMin,fSpdBinningMax));
375
376     fHistList->Add(new TH2F("fCorrEzdcSpdOuter", "E_{ZDC} vs N_{ch}^{SPD};E_{ZDC} (TeV);N^{SPD}",   
377                             fZdcBinning,fZdcBinningMin,fZdcBinningMax, fSpdBinning,fSpdBinningMin,fSpdBinningMax));
378     
379   }
380
381   return 0;
382 }
383
384 //##################################################################################
385 Int_t AliMultiplicityCorrelations::SetupSPD() {
386   // see header file for class documentation  
387   
388   fHistList->Add(new TH1F("fSpdNClusters", "Multplicity_{SPD};Multplicity_{SPD};N_{Events}",   
389                           fSpdBinning,fSpdBinningMin,fSpdBinningMax));
390
391   fHistList->Add(new TH1F("fSpdNClustersInner", "Multplicity_{SPD} Layer 0;Multplicity_{SPD};N_{Events}",   
392                           fSpdBinning,fSpdBinningMin,fSpdBinningMax));
393
394   fHistList->Add(new TH1F("fSpdNClustersOuter", "Multplicity_{SPD} Layer 1;Multplicity_{SPD};N_{Events}",   
395                           fSpdBinning,fSpdBinningMin,fSpdBinningMax));
396   return 0;
397 }
398
399 /*
400  * ---------------------------------------------------------------------------------
401  *                               Process - private
402  * ---------------------------------------------------------------------------------
403  */
404
405 //##################################################################################
406 Int_t AliMultiplicityCorrelations::ProcessTPC() {
407   // see header file for class documentation  
408
409   Int_t iResult = 0 ;
410
411   fEsdTracks = 0;  
412   fEsdTracksA = 0;  
413   fTpcTracks = 0;  
414   fTpcTracksA = 0;  
415   
416   // -----------------------------------------------------------------
417
418   for (Int_t idx = 0; idx < fESDEvent->GetNumberOfTracks(); idx++) {
419
420     // -- check  track
421     AliESDtrack* esdTrack = fESDEvent->GetTrack(idx);
422     if (!esdTrack) continue;
423
424     ++fEsdTracks;
425     
426     if (!fESDTrackCuts2->AcceptTrack(esdTrack)) continue;
427     ++fEsdTracksA;
428   }
429
430   // -----------------------------------------------------------------
431
432   for (Int_t idx = 0; idx < fESDEvent->GetNumberOfTracks(); idx++) {
433
434     // -- check  track
435     AliESDtrack* esdTrack = fESDEvent->GetTrack(idx);
436     if (!esdTrack) continue;
437
438     // -- TPC only
439     const AliExternalTrackParam *tpcTrack = esdTrack->GetTPCInnerParam();
440     if (!tpcTrack) continue;
441     ++fTpcTracks;
442
443     if (!fESDTrackCuts->AcceptTrack(esdTrack)) continue;
444     ++fTpcTracksA;
445   }
446
447   // -----------------------------------------------------------------
448
449   if (fCleanSample) {
450     if(fTpcTracksA < fCleanMinKeep || fTpcTracksA > fCleanMaxKeep)
451       return -2;
452   }
453
454   Float_t nESD  = (Float_t) fEsdTracksA;
455   Float_t nTPC  = (Float_t) fTpcTracksA;
456   Float_t ratio = -1;
457
458   if ( nESD != 0 )
459     ratio = nTPC/nESD;
460
461   (static_cast<TH2F*>(fHistList->FindObject("fTpcCorrNchAll")))->Fill(fTpcTracksA,fEsdTracksA);  
462   (static_cast<TH1F*>(fHistList->FindObject("fTpcRatioNchAll")))->Fill(ratio);
463
464   // Cleaning Cut tpcTracks and globalTracks
465   if ( fEsdTracksA < (-39+0.5797*fTpcTracksA))
466     return -3;
467
468   (static_cast<TH1F*>(fHistList->FindObject("fTpcNch0")))->Fill(fEsdTracks);
469   (static_cast<TH1F*>(fHistList->FindObject("fTpcNch1")))->Fill(fEsdTracksA);
470   (static_cast<TH1F*>(fHistList->FindObject("fTpcNch2")))->Fill(fTpcTracks);
471   (static_cast<TH1F*>(fHistList->FindObject("fTpcNch3")))->Fill(fTpcTracksA);
472
473   (static_cast<TH2F*>(fHistList->FindObject("fTpcCorrNch")))->Fill(fTpcTracksA,fEsdTracksA);
474   (static_cast<TH1F*>(fHistList->FindObject("fTpcRatioNch")))->Fill(ratio);
475
476   return iResult;
477 }
478
479 //##################################################################################
480 Int_t AliMultiplicityCorrelations::ProcessVZERO() {
481   // see header file for class documentation  
482
483   Int_t iResult = 0 ;
484   Float_t vzeroCorr;;
485   fVzeroMultA = fESDVZERO->GetMTotV0A();
486   fVzeroMultC = fESDVZERO->GetMTotV0C();
487   if (!fIsMC)
488     fVzeroMult  = GetCorrVZERO(vzeroCorr);
489   else
490     fVzeroMult  = (fVzeroMultA+fVzeroMultC) * 0.85871;
491
492   (static_cast<TH1F*>(fHistList->FindObject("fVzeroMult")))->Fill(fVzeroMult);
493   (static_cast<TH1F*>(fHistList->FindObject("fVzeroMultUnCorr")))->Fill(fVzeroMultA+fVzeroMultC);
494   (static_cast<TH1F*>(fHistList->FindObject("fVzeroMultAC")))->Fill(fVzeroMultA,fVzeroMultC);
495
496   // -- VZERO - TPC correlations
497   if (fESDEvent->GetNumberOfTracks() > 0 && fProcessTPC) {
498     (static_cast<TH2F*>(fHistList->FindObject("fCorrVzeroNch")))->Fill(fTpcTracksA,fVzeroMult);
499     (static_cast<TH2F*>(fHistList->FindObject("fCorrVzeroNchUnCorr")))->Fill(fTpcTracksA,fVzeroMultA+fVzeroMultC);
500
501     (static_cast<TH2F*>(fHistList->FindObject("fCorrVzeroESDNch")))->Fill(fEsdTracksA,fVzeroMult);
502     (static_cast<TH2F*>(fHistList->FindObject("fCorrVzeroESDNchUnCorr")))->Fill(fEsdTracksA,fVzeroMultA+fVzeroMultC);
503   }
504
505   // -- VZERO - SPD correlations
506   if (fESDEvent->GetNumberOfTracks() > 0 && fProcessSPD) {
507     (static_cast<TH2F*>(fHistList->FindObject("fCorrVzeroSpd")))->Fill(fVzeroMult, fSpdNClusters);
508     (static_cast<TH2F*>(fHistList->FindObject("fCorrVzeroSpdOuter")))->Fill(fVzeroMult, fSpdNClustersOuter);
509   }
510   
511   return iResult;
512 }
513
514 //##################################################################################
515 Int_t AliMultiplicityCorrelations::ProcessZDC() {
516   // see header file for class documentation  
517
518   Int_t iResult = 0 ;
519
520   Double_t zdcEznA = fESDZDC->GetZDCN2Energy() / 8.;
521   Double_t zdcEznC = fESDZDC->GetZDCN1Energy() / 8.;
522   //  Double_t zdcEznA = fESDZDC->GetZDCN2Energy() / 1000.;
523   //  Double_t zdcEznC = fESDZDC->GetZDCN1Energy() / 1000.;
524   
525   Double_t zdcEzpA = fESDZDC->GetZDCP2Energy() / 8.;
526   Double_t zdcEzpC = fESDZDC->GetZDCP1Energy() / 8.;
527   //  Double_t zdcEzpA = fESDZDC->GetZDCP2Energy() / 1000.;
528   //  Double_t zdcEzpC = fESDZDC->GetZDCP1Energy() / 1000.;
529   
530   Double_t zdcEA = (zdcEznA + zdcEzpA);
531   Double_t zdcEC = (zdcEznC + zdcEzpC);
532   Double_t zdcE = zdcEA + zdcEC;
533   
534   Double_t zdcEzemA = fESDZDC->GetZDCEMEnergy(1) / 8.;
535   Double_t zdcEzemC = fESDZDC->GetZDCEMEnergy(0) / 8.;
536   //  Double_t zdcEzemA = fESDZDC->GetZDCEMEnergy(1) / 1000.;
537   //  Double_t zdcEzemC = fESDZDC->GetZDCEMEnergy(0) / 1000.;
538   Double_t zdcEzem  = zdcEzemA + zdcEzemC;
539
540   (static_cast<TH1F*>(fHistList->FindObject("fZdcEzdc")))->Fill(zdcE);
541   
542   (static_cast<TH1F*>(fHistList->FindObject("fZdcEzem")))->Fill(zdcEzem);
543   (static_cast<TH2F*>(fHistList->FindObject("fZdcEzemEzdc")))->Fill(zdcEzem, zdcE);
544   
545   // -- ZDC - TPC correlations
546   if (fESDEvent->GetNumberOfTracks() > 0 && fProcessTPC) {
547     (static_cast<TH2F*>(fHistList->FindObject("fCorrEzdcNch")))->Fill(fTpcTracksA, zdcE);
548     (static_cast<TH2F*>(fHistList->FindObject("fCorrEzemNch")))->Fill(fTpcTracksA, zdcEzem);
549   }
550   
551   // -- ZDC - SPD correlations
552   if (fProcessSPD) {
553     (static_cast<TH2F*>(fHistList->FindObject("fCorrEzdcSpd")))->Fill(zdcE, fSpdNClusters);
554     (static_cast<TH2F*>(fHistList->FindObject("fCorrEzdcSpdOuter")))->Fill(zdcE, fSpdNClustersOuter);
555   }
556
557   // -- VZERO - ZDC correlations
558   if (fESDVZERO && fProcessVZERO) {
559     (static_cast<TH2F*>(fHistList->FindObject("fCorrEzdcVzero")))->Fill(zdcE, fVzeroMult);
560     (static_cast<TH2F*>(fHistList->FindObject("fCorrEzemVzero")))->Fill(zdcEzem, fVzeroMult);
561   }
562
563   return iResult;
564 }
565
566 //##################################################################################
567 Int_t AliMultiplicityCorrelations::ProcessSPD() {
568   // see header file for class documentation
569   
570    const AliESDVertex* vtxESD = fESDEvent->GetPrimaryVertexSPD();
571    Float_t zvtx = vtxESD->GetZ();
572
573   if (!fIsMC) {
574     fSpdNClustersInner = GetCorrSPD2(fESDMultiplicity->GetNumberOfITSClusters(0),zvtx);
575     fSpdNClustersOuter = GetCorrSPD2(fESDMultiplicity->GetNumberOfITSClusters(1),zvtx);
576   }
577   else {
578     fSpdNClustersInner = fESDMultiplicity->GetNumberOfITSClusters(0);
579     fSpdNClustersOuter = fESDMultiplicity->GetNumberOfITSClusters(1);
580   }    
581
582   fSpdNClusters      = fSpdNClustersOuter + fSpdNClustersInner;
583
584   (static_cast<TH2F*>(fHistList->FindObject("fSpdNClusters")))->Fill(fSpdNClusters);
585   (static_cast<TH2F*>(fHistList->FindObject("fSpdNClustersInner")))->Fill(fSpdNClustersInner);
586   (static_cast<TH2F*>(fHistList->FindObject("fSpdNClustersOuter")))->Fill(fSpdNClustersOuter);
587   
588   // -- SPD vs TPC correlations
589   if (fProcessTPC) {
590     (static_cast<TH2F*>(fHistList->FindObject("fCorrSpdTpcNch")))->Fill(fTpcTracksA, fSpdNClusters);
591     (static_cast<TH2F*>(fHistList->FindObject("fCorrSpdOuterTpcNch")))->Fill(fTpcTracksA, fSpdNClustersOuter);
592   }
593
594   return 0;
595 }
596
597 //##################################################################################
598 Float_t AliMultiplicityCorrelations::GetCorrVZERO(Float_t &v0CorrResc) {
599   // correct V0 non-linearity, prepare a version rescaled to SPD2 corr
600
601   Double_t *par0;
602   Double_t *par1;
603   Double_t *par2;
604   
605   Double_t par0R137161[64] = { 6.71e-02 , 6.86e-02 , 7.06e-02 , 6.32e-02 , 
606                                5.91e-02 , 6.07e-02 , 5.78e-02 , 5.73e-02 , 5.91e-02 , 6.22e-02 , 
607                                5.90e-02 , 6.11e-02 , 5.55e-02 , 5.29e-02 , 5.19e-02 , 5.56e-02 , 
608                                6.25e-02 , 7.03e-02 , 5.64e-02 , 5.81e-02 , 4.57e-02 , 5.30e-02 , 
609                                5.13e-02 , 6.43e-02 , 6.27e-02 , 6.48e-02 , 6.07e-02 , 1.01e-01 , 
610                                6.68e-02 , 7.16e-02 , 6.36e-02 , 5.95e-02 , 2.52e-02 , 2.82e-02 , 
611                                2.56e-02 , 2.86e-02 , 2.82e-02 , 2.10e-02 , 2.13e-02 , 2.32e-02 , 
612                                2.75e-02 , 4.34e-02 , 3.78e-02 , 4.52e-02 , 4.11e-02 , 3.89e-02 , 
613                                4.10e-02 , 3.73e-02 , 4.51e-02 , 5.07e-02 , 5.42e-02 , 4.74e-02 , 
614                                4.33e-02 , 4.44e-02 , 4.64e-02 , 3.01e-02 , 6.38e-02 , 5.26e-02 , 
615                                4.99e-02 , 5.26e-02 , 5.47e-02 , 3.84e-02 , 5.00e-02 , 5.20e-02 };
616   Double_t par1R137161[64] = { -6.68e-05 , -7.78e-05 , -6.88e-05 , -5.92e-05 , 
617                                -2.43e-05 , -3.54e-05 , -2.91e-05 , -1.99e-05 , -1.40e-05 , -4.01e-05 , 
618                                -2.29e-05 , -3.68e-05 , -2.53e-05 , -2.44e-06 , -9.22e-06 , -1.51e-05 , 
619                                -2.80e-05 , -2.34e-05 , -1.72e-05 , -1.81e-05 , -1.29e-05 , -2.65e-05 , 
620                                -1.61e-05 , -2.86e-05 , -1.74e-05 , -4.23e-05 , -3.41e-05 , -1.05e-04 , 
621                                -2.76e-05 , -4.71e-05 , -3.06e-05 , -2.32e-05 , -1.55e-06 , 2.15e-05 , 
622                                1.40e-05 , 2.16e-05 , 1.21e-05 , 3.05e-06 , 1.67e-05 , -3.84e-06 , 
623                                3.09e-06 , 1.50e-05 , 3.47e-06 , 4.87e-06 , -3.71e-07 , -1.75e-06 , 
624                                -1.80e-06 , 9.99e-06 , -6.46e-06 , -4.91e-06 , 1.33e-05 , -2.52e-07 , 
625                                -3.85e-06 , 4.94e-06 , -2.48e-07 , -1.20e-05 , 2.07e-06 , 6.12e-06 , 
626                                -1.18e-06 , 4.54e-06 , -1.54e-05 , -1.25e-05 , 1.46e-06 , -6.67e-06 };
627   Double_t par2R137161[64] = { 1.29e-08 , 1.51e-08 , 1.43e-08 , 1.11e-08 , 
628                                5.04e-09 , 6.99e-09 , 5.58e-09 , 4.15e-09 , 4.00e-09 , 8.22e-09 , 
629                                4.97e-09 , 7.66e-09 , 4.91e-09 , 1.10e-09 , 2.64e-09 , 3.64e-09 , 
630                                5.76e-09 , 5.46e-09 , 3.38e-09 , 3.47e-09 , 2.43e-09 , 4.13e-09 , 
631                                2.80e-09 , 5.80e-09 , 3.86e-09 , 7.46e-09 , 5.98e-09 , 2.58e-08 , 
632                                5.50e-09 , 8.72e-09 , 5.23e-09 , 4.37e-09 , 2.33e-09 , -6.01e-10 , 
633                                3.99e-11 , -2.02e-10 , 7.67e-10 , 2.03e-09 , 1.17e-10 , 2.56e-09 , 
634                                1.16e-09 , -4.75e-10 , 1.28e-09 , 1.23e-09 , 1.62e-09 , 1.61e-09 , 
635                                1.93e-09 , 2.97e-10 , 2.21e-09 , 2.16e-09 , 5.22e-10 , 1.03e-09 , 
636                                1.56e-09 , 5.00e-10 , 1.01e-09 , 2.93e-09 , 1.05e-09 , 9.96e-11 , 
637                                1.21e-09 , 7.45e-10 , 3.07e-09 , 2.31e-09 , 6.70e-10 , 1.89e-09 };
638   
639   Double_t par0R137366[64] = { 7.12e-02 , 7.34e-02 , 7.39e-02 , 6.54e-02 , 6.11e-02 , 6.31e-02 , 6.15e-02 , 
640                                6.00e-02 , 6.10e-02 , 6.49e-02 , 6.17e-02 , 6.33e-02 , 6.00e-02 , 5.48e-02 , 
641                                5.44e-02 , 5.81e-02 , 6.49e-02 , 7.07e-02 , 5.91e-02 , 6.18e-02 , 4.82e-02 , 
642                                5.67e-02 , 5.36e-02 , 6.60e-02 , 6.37e-02 , 6.78e-02 , 6.31e-02 , 1.04e-01 , 
643                                6.91e-02 , 7.32e-02 , 6.61e-02 , 6.16e-02 , 2.64e-02 , 2.81e-02 , 2.64e-02 , 
644                                2.85e-02 , 2.87e-02 , 2.18e-02 , 2.19e-02 , 2.43e-02 , 2.81e-02 , 4.37e-02 , 
645                                3.90e-02 , 4.66e-02 , 4.24e-02 , 4.09e-02 , 4.21e-02 , 3.88e-02 , 4.83e-02 , 
646                                5.23e-02 , 5.44e-02 , 4.85e-02 , 4.42e-02 , 4.58e-02 , 4.74e-02 , 3.14e-02 , 
647                                6.31e-02 , 5.30e-02 , 5.01e-02 , 5.33e-02 , 5.70e-02 , 3.95e-02 , 4.98e-02 , 5.31e-02 };
648   Double_t par1R137366[64] = { -6.99e-05 , -6.99e-05 , -6.94e-05 , -6.55e-05 , -3.55e-05 , -4.50e-05 , 
649                                -3.10e-05 , -2.81e-05 , -2.29e-05 , -3.89e-05 , -2.53e-05 , -4.25e-05 ,
650                                -1.87e-05 , -2.01e-05 , -1.53e-05 , -2.14e-05 , -2.86e-05 , -4.70e-05 ,
651                                -2.23e-05 , -3.30e-05 ,-9.74e-06 , -2.62e-05 , -1.76e-05 , -2.38e-05 , 
652                                -2.40e-05 , -3.43e-05 , -2.75e-05 , -6.86e-05 ,-2.35e-05 , -4.45e-05 , 
653                                -2.51e-05 , -2.20e-05 , -1.25e-16 , -2.04e-17 , -2.06e-17 , -3.74e-19 ,
654                                -1.18e-18 , -2.02e-15 , -3.78e-06 , -1.26e-06 , -2.71e-06 , -6.23e-17 , 
655                                -7.39e-08 , -1.76e-16 , -8.98e-06 , -4.10e-18 , -1.34e-05 , -1.06e-16 , 
656                                -3.34e-06 , -1.04e-05 , -5.28e-06 , -7.34e-06 , -1.05e-05 , -7.68e-06 ,
657                                -1.78e-05 , -1.19e-05 , -1.78e-05 , -1.34e-06 , -9.23e-06 , -3.34e-06 ,
658                                -8.02e-06 , -1.39e-05 , -1.38e-05 , -1.40e-05 };
659   Double_t par2R137366[64] = { 1.41e-08 , 1.47e-08 , 1.48e-08 , 1.24e-08 , 6.82e-09 , 8.73e-09 , 6.26e-09 , 
660                                5.53e-09 , 5.40e-09 , 7.93e-09 , 5.49e-09 , 8.77e-09 , 4.21e-09 , 3.93e-09 , 
661                                3.60e-09 , 4.67e-09 , 5.59e-09 , 8.81e-09 , 3.89e-09 , 6.19e-09 , 1.97e-09 , 
662                                4.38e-09 , 3.26e-09 , 5.00e-09 , 4.58e-09 , 6.39e-09 , 5.03e-09 , 1.30e-08 , 
663                                4.95e-09 , 8.26e-09 , 4.57e-09 , 4.10e-09 , 2.35e-09 , 2.30e-09 , 2.15e-09 , 
664                                2.27e-09 , 2.17e-09 , 2.27e-09 , 2.97e-09 , 2.25e-09 , 1.69e-09 , 1.44e-09 , 
665                                1.66e-09 , 1.75e-09 , 2.88e-09 , 1.82e-09 , 3.64e-09 , 1.80e-09 , 1.71e-09 , 
666                                2.66e-09 , 3.01e-09 , 1.95e-09 , 2.64e-09 , 2.42e-09 , 3.68e-09 , 2.66e-09 , 
667                                3.92e-09 , 1.18e-09 , 2.26e-09 , 1.57e-09 , 2.02e-09 , 2.71e-09 , 2.99e-09 , 3.04e-09 }; 
668   
669   
670
671   if ( fRunNo == 137161 ) {
672     par0=par0R137161;
673     par1=par1R137161;
674     par2=par2R137161;
675   }  
676   else {
677     par0=par0R137366;
678     par1=par1R137366;
679     par2=par2R137366;
680   }
681
682   Float_t multCorr = 0;
683   Float_t multCorr2 = 0;
684   Float_t multChCorr[64];
685
686   for(Int_t i = 0; i < 64; ++i) {
687     Double_t b = (fESDVZERO->GetMultiplicity(i)*par1[i]-par0[i]);
688     Double_t s = (b*b-4.*par2[i]*fESDVZERO->GetMultiplicity(i)*fESDVZERO->GetMultiplicity(i));
689     Double_t n;
690     if (s<0) {
691       printf("FPE %d %.2f %.2f %.2e\n",i,fESDVZERO->GetMultiplicity(i),b,(b*b-4.*par2[i]*fESDVZERO->GetMultiplicity(i)*fESDVZERO->GetMultiplicity(i)));
692       n = -b;
693     }
694     else {
695       n = (-b + TMath::Sqrt(s));
696     }
697     multChCorr[i] = 2.*fESDVZERO->GetMultiplicity(i)/n*par0[i];
698     multCorr += multChCorr[i];
699     multCorr2 += (multChCorr[i]/par0[i]/64.);
700   }
701   v0CorrResc = multCorr2;
702   return multCorr;
703 }
704
705
706 //##################################################################################
707 Float_t AliMultiplicityCorrelations::GetCorrSPD2(Float_t spd2raw,Float_t zv) const {
708   // renormalize N spd2 clusters at given Zv to acceptance at Zv=0
709   const double pars[] = {8.10030e-01,-2.80364e-03,-7.19504e-04};
710   zv -= pars[0];
711   float corr = 1 + zv*(pars[1] + zv*pars[2]);
712   return corr>0 ? spd2raw/corr : -1;
713 }