Fix for outliers in centrality.
[u/mrichter/AliRoot.git] / PWG1 / VZERO / AliAnaVZEROPbPb.cxx
1 #include "TChain.h"
2 #include "TTree.h"
3 #include "TH1F.h"
4 #include "TH2F.h"
5
6 #include "AliAnalysisTask.h"
7 #include "AliAnalysisManager.h"
8
9 #include "AliESDEvent.h"
10 #include "AliESDInputHandler.h"
11 #include "AliAnaVZEROPbPb.h"
12 #include "AliMultiplicity.h"
13 #include "AliESDUtils.h"
14 #include "AliCentrality.h"
15
16 // VZERO includes
17 #include "AliESDVZERO.h"
18
19 ClassImp(AliAnaVZEROPbPb)
20
21 AliAnaVZEROPbPb::AliAnaVZEROPbPb() 
22   : AliAnalysisTaskSE(), fESD(0), fEsdV0(0), fOutputList(0), fNClasses(0), fClassesNames(0),
23   fNFlags(0),
24   fhAdcPMTNoTime(0),
25   fhAdcPMTWithTime(0),
26   fhTimePMT(0),
27   fhWidthPMT(0),
28   fhTimeCorr(0),
29   fhPmtMult(0),
30   fhV0ampl(0),
31   fhEvents(0),
32   fhVtxXYBB(0),
33   fhVtxZBB(0),
34   fhVtxXYBGA(0),
35   fhVtxZBGA(0),
36   fhVtxXYBGC(0),
37   fhVtxZBGC(0),
38   fhL2Triggers(0),
39 fhOnlineCharge(0),
40 fhRecoMult(0),
41 fhRecoMultPMT(0),
42 fhV0vsSPDCentrality(0),
43 fhTriggerBits(0),
44 fhTotRecoMult(0),
45 fhCentrality(0),
46 fhEqualizedMult(0),
47 fhEqualizedMultSum(0),
48 fNBinTotMult(100),
49 fTotMultMax(30000),
50 fNBinMult(100),
51 fV0AMultMax(20000),
52 fV0CMultMax(30000),
53 fNBinOnlineCharge(100),
54 fV0AOnlineChargeMax(20000),
55 fV0COnlineChargeMax(30000),
56 fNBinEquaMult(100),
57 fEquaMultMax(200.),
58 fNBinSumsEqMult(100),
59 fV0AEqMultMax(2000.),
60 fV0CEqMultMax(2000.)
61
62 {
63   // Constructor
64   // Init arrays
65   for(Int_t i = 0; i < 2; ++i) {
66         fhAdcNoTime[i] = fhAdcWithTime[i] =  fhWidth[i] =  fhTime[i] = NULL;
67         fhAdcTime[i] =  fhAdcWidth[i] = NULL;
68   }
69
70 }
71
72 //________________________________________________________________________
73 AliAnaVZEROPbPb::AliAnaVZEROPbPb(const char *name) 
74   : AliAnalysisTaskSE(name), fESD(0), fEsdV0(0), fOutputList(0),fNClasses(0),fClassesNames(0),
75   fNFlags(0),
76   fhAdcPMTNoTime(0),
77   fhAdcPMTWithTime(0),
78   fhTimePMT(0),
79   fhWidthPMT(0),
80   fhTimeCorr(0),
81   fhPmtMult(0),
82   fhV0ampl(0),
83   fhEvents(0),
84   fhVtxXYBB(0),
85   fhVtxZBB(0),
86   fhVtxXYBGA(0),
87   fhVtxZBGA(0),
88   fhVtxXYBGC(0),
89   fhVtxZBGC(0),
90   fhL2Triggers(0),
91 fhOnlineCharge(0),
92 fhRecoMult(0),
93 fhRecoMultPMT(0),
94 fhV0vsSPDCentrality(0),
95 fhTriggerBits(0),
96 fhTotRecoMult(0),
97 fhCentrality(0),
98 fhEqualizedMult(0),
99 fhEqualizedMultSum(0),
100 fNBinTotMult(100),
101 fTotMultMax(30000),
102 fNBinMult(100),
103 fV0AMultMax(20000),
104 fV0CMultMax(30000),
105 fNBinOnlineCharge(100),
106 fV0AOnlineChargeMax(20000),
107 fV0COnlineChargeMax(30000),
108 fNBinEquaMult(400),
109 fEquaMultMax(1000),
110 fNBinSumsEqMult(100),
111 fV0AEqMultMax(4000.),
112 fV0CEqMultMax(4000.)
113 {
114   // Constructor
115   // Init arrays
116   for(Int_t i = 0; i < 2; ++i) {
117         fhAdcNoTime[i] = fhAdcWithTime[i] =  fhWidth[i] =  fhTime[i] = NULL;
118         fhAdcTime[i] =  fhAdcWidth[i] = NULL;
119   }
120   // Define input and output slots here
121   // Input slot #0 works with a TChain
122   DefineInput(0, TChain::Class());
123   // Output slot #0 id reserved by the base class for AOD
124   // Output slot #1 writes into a TH1 container
125   DefineOutput(1, TList::Class());
126 }
127 //________________________________________________________________________
128 void AliAnaVZEROPbPb::SetClassesNames(const Char_t * nameList){
129   // Initialize the class names
130   // which are used in the trigger split
131         TString  names("AllClasses,");
132         names += nameList;
133         fClassesNames = names.Tokenize(",");
134         fNClasses = fClassesNames->GetEntriesFast();
135 }
136 //________________________________________________________________________
137 TH1F * AliAnaVZEROPbPb::CreateHisto1D(const char* name, const char* title,Int_t nBins, 
138                                     Double_t xMin, Double_t xMax,
139                                     const char* xLabel, const char* yLabel)
140 {
141   // create a histogram
142   // and set the axis labels and the style
143   TH1F* result = new TH1F(name, title, nBins, xMin, xMax);
144   result->SetOption("hist");
145   if (xLabel) result->GetXaxis()->SetTitle(xLabel);
146   if (yLabel) result->GetYaxis()->SetTitle(yLabel);
147   result->SetMarkerStyle(kFullCircle);
148   return result;
149 }
150
151 //________________________________________________________________________
152 TH2F * AliAnaVZEROPbPb::CreateHisto2D(const char* name, const char* title,Int_t nBinsX, 
153                                     Double_t xMin, Double_t xMax,
154                                     Int_t nBinsY,
155                                     Double_t yMin, Double_t yMax,
156                                     const char* xLabel, const char* yLabel)
157 {
158   // create a histogram
159   // and set the axis labels and the style
160   TH2F* result = new TH2F(name, title, nBinsX, xMin, xMax, nBinsY, yMin, yMax);
161   if (xLabel) result->GetXaxis()->SetTitle(xLabel);
162   if (yLabel) result->GetYaxis()->SetTitle(yLabel);
163   return result;
164 }
165
166
167 //________________________________________________________________________
168 void AliAnaVZEROPbPb::UserCreateOutputObjects()
169 {
170   // Create histograms
171   // Called once
172         if(fNClasses==0) {
173                 AliFatal("No Classes Defined");
174                 return;
175         }
176
177   fOutputList = new TList();
178   fOutputList->SetOwner(kTRUE);
179
180
181         CreateHistosPerL2Trigger();
182     CreateQAHistos();
183
184   PostData(1, fOutputList);
185  }
186 //________________________________________________________________________
187 void AliAnaVZEROPbPb::Init()
188 {
189   // Nothing here
190   // ...
191 }
192
193 //________________________________________________________________________
194 void AliAnaVZEROPbPb::UserExec(Option_t *) 
195 {
196   // Main loop
197   // Called for each event
198
199   fESD = dynamic_cast<AliESDEvent*>(InputEvent());
200   if (!fESD) {
201     printf("ERROR: fESD not available\n");
202     return;
203   }
204   
205   fEsdV0 = fESD->GetVZEROData();
206   if (!fEsdV0) {
207     Printf("ERROR: esd V0  not available");
208     return;
209   }
210
211   FillQAHistos();
212
213   Bool_t isSelected = (fEsdV0->GetV0ADecision()==1) && (fEsdV0->GetV0CDecision()==1);
214   if (isSelected) FillPerL2TriggerHistos();
215
216         
217
218   PostData(1, fOutputList);
219 }      
220 //________________________________________________________________________
221 void AliAnaVZEROPbPb::CreateHistosPerL2Trigger(){
222   // Create the histograms
223   // for all the required L2 trigger classes    
224         fhOnlineCharge= new TH2F*[fNClasses];
225         fhCentrality= new TH1F*[fNClasses];
226         fhV0vsSPDCentrality= new TH2F*[fNClasses];
227         fhRecoMult= new TH2F*[fNClasses];
228         fhRecoMultPMT= new TH2F*[fNClasses];
229         fhTotRecoMult= new TH1F*[fNClasses];
230         fhTriggerBits= new TH1F*[fNClasses];
231         fhEqualizedMult= new TH2F*[fNClasses];
232         fhEqualizedMultSum = new TH2F*[fNClasses];
233         
234         fhL2Triggers = CreateHisto1D("hL2Triggers","L2 Triggers",fNClasses,0,fNClasses);
235         fOutputList->Add(fhL2Triggers);   
236         
237         TIter iter(fClassesNames);
238         TObjString* name;
239         Int_t iClass =0;
240         while((name = (TObjString*) iter.Next())){
241                 fhL2Triggers->GetXaxis()->SetBinLabel(iClass+1,name->String().Data());
242                 
243                 fhOnlineCharge[iClass] = CreateHisto2D(Form("hOnlineCharge_%s",name->String().Data()),Form("Online Charge for %s",name->String().Data()),fNBinOnlineCharge,0.,fV0AOnlineChargeMax,fNBinOnlineCharge,0.,fV0COnlineChargeMax,"V0A","V0C");
244                 fOutputList->Add(fhOnlineCharge[iClass]);         
245
246                 fhCentrality[iClass] = CreateHisto1D(Form("hV0Centrality_%s",name->String().Data()),Form("V0 centrality for %s",name->String().Data()),100,0.,100.);
247                 fOutputList->Add(fhCentrality[iClass]);   
248
249                 fhV0vsSPDCentrality[iClass] = CreateHisto2D(Form("hV0vsSPDCentrality_%s",name->String().Data()),Form("Centrality for %s",name->String().Data()),100,0.,100.,100,0.,100,"SPD Centrality (CL1)","V0 Centrality (V0M)");
250                 fOutputList->Add(fhV0vsSPDCentrality[iClass]);    
251
252                 fhRecoMult[iClass] = CreateHisto2D(Form("hRecoMult_%s",name->String().Data()),Form("Reco Multiplicity for %s",name->String().Data()),fNBinMult,0.,fV0AMultMax,fNBinMult,0.,fV0CMultMax,"V0A Offline Mult","V0C Offline Mult");
253                 fOutputList->Add(fhRecoMult[iClass]);     
254
255                 fhRecoMultPMT[iClass] = CreateHisto2D(Form("hRecoMultPMT_%s",name->String().Data()),Form("Reco Multiplicity per PMT for %s",name->String().Data()),64,-0.5,63.5,200,0.,2000.,"PMT channel","Offline Mult");
256                 fOutputList->Add(fhRecoMultPMT[iClass]);          
257
258                 fhTotRecoMult[iClass] = CreateHisto1D(Form("hTotRecoMult_%s",name->String().Data()),Form("Total Reco Multiplicity for %s",name->String().Data()),fNBinTotMult,0.,fTotMultMax,"V0A + V0C Offline Mult");
259                 fOutputList->Add(fhTotRecoMult[iClass]);          
260
261                 fhTriggerBits[iClass] = CreateHisto1D(Form("hTriggerBits_%s",name->String().Data()),Form("Trigger Bits for %s",name->String().Data()),16,-0.5,15.5);
262                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(1,"BBA_AND_BBC");
263                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(2,"BBA_OR_BBC");
264                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(3,"BGA_AND_BBC");
265                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(4,"BGA");
266                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(5,"BBA_AND_BGC");
267                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(6,"BGC");
268                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(7,"CTA1_AND_CTC1");
269                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(8,"CTA1_OR_CTC1");
270                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(9,"CTA2_AND_CTC2");
271                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(10,"CTA2_OR_CTC2");
272                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(11,"MTA_AND_MTC");
273                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(12,"MTA_OR_MTC");
274                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(13,"BBA");
275                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(14,"BBC");
276                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(15,"BGA_OR_BGC");
277                 fhTriggerBits[iClass]->GetXaxis()->SetBinLabel(16,"All True BG");
278                 fOutputList->Add(fhTriggerBits[iClass]);
279         
280                 fhEqualizedMult[iClass] = CreateHisto2D(Form("hEqualizedMult_%s",name->String().Data()),Form("Equalized Multiplicity for %s",name->String().Data()),64,-0.5,63.5,fNBinEquaMult,0.,fEquaMultMax,"PMT channel","Equalized Multiplicity");
281                 fOutputList->Add(fhEqualizedMult[iClass]);
282         
283                 fhEqualizedMultSum[iClass] = CreateHisto2D(Form("hEqualizedMultSum_%s",name->String().Data()),Form("Summed Equalized Multiplicity for %s",name->String().Data()),fNBinSumsEqMult,0.,fV0AEqMultMax,fNBinSumsEqMult,0.,fV0CEqMultMax,"V0A","V0C");
284                 fOutputList->Add(fhEqualizedMultSum[iClass]);
285
286                 
287                 iClass++;
288         }
289         
290 }
291 //________________________________________________________________________
292 void AliAnaVZEROPbPb::CreateQAHistos(){
293   // Create the main
294   // QA histos
295   fNFlags    = CreateHisto2D("hNFlags","BB Flags",33,-0.5,32.5,33,-0.5,32.5,"V0A","V0C");
296   fOutputList->Add(fNFlags);
297
298         for(int iSide = 0; iSide < 2; ++iSide){
299                 TString side;
300                 if(iSide) side = "V0A";
301                 else side = "V0C";
302                 
303                 fhAdcNoTime[iSide] = CreateHisto1D(Form("hAdcNoTime%s",side.Data()),Form("ADC (no Leading Time) %s",side.Data()),200,0,200,"ADC charge","Entries");
304                 fOutputList->Add(fhAdcNoTime[iSide]);     
305                 fhAdcWithTime[iSide] = CreateHisto1D(Form("hAdcWithTime%s",side.Data()),Form("ADC (with Leading Time) %s",side.Data()),200,0,200,"ADC charge","Entries");
306                 fOutputList->Add(fhAdcWithTime[iSide]);
307                 fhTime[iSide] = CreateHisto1D(Form("htimepmt%s",side.Data()),Form("Time measured by TDC %s",side.Data()),1000,-100,100,"Leading time (ns)","Entries");
308                 fOutputList->Add(fhTime[iSide]);
309                 fhWidth[iSide] = CreateHisto1D(Form("hwidth%s",side.Data()),Form("Signal width measured by TDC %s",side.Data()),128,0,800,"Signal width (ns)","Entries");
310                 fOutputList->Add(fhWidth[iSide]);
311                 fhAdcWidth[iSide] = CreateHisto2D(Form("hadcwidth%s",side.Data()),Form("Time width vs ADC %s",side.Data()),200,0,1200,128,0,800,"ADC charge","Width (ns)");
312                 fOutputList->Add(fhAdcWidth[iSide]);
313                 fhAdcTime[iSide] = CreateHisto2D(Form("hAdcTime%s",side.Data()),Form("ADC vs Time %s",side.Data()),200,-100,100,200,0,200,"Time (ns)","ADC charge");
314                 fOutputList->Add(fhAdcTime[iSide]);
315         }
316
317   fhAdcPMTNoTime = CreateHisto2D("hadcpmtnotime","ADC vs PMT index (no leading time)",64,-0.5,63.5,200,0,200,"PMT index","ADC charge");
318   fhAdcPMTWithTime = CreateHisto2D("hadcpmtwithtime","ADC vs PMT index (with leading time)",64,-0.5,63.5,200,0,2000,"PMT index","ADC charge");
319
320   fhTimePMT = CreateHisto2D("htimepmt","Time measured by TDC vs PMT index",64,-0.5,63.5,200,-50,50,"PMT Index","Leading time (ns)");
321   fhWidthPMT = CreateHisto2D("hwidthpmt","Time width vs PMT index",64,-0.5,63.5,128,0,800,"PMT Index","Signal width (ns)");
322
323   fhTimeCorr = CreateHisto2D("htimecorr","Average time C side vs. A side",200,-50,50,200,-50,50,"Time V0A (ns)","Time V0C (ns");
324
325   fhV0ampl  = CreateHisto1D("hV0ampl","V0 multiplicity in single channel (all V0 channels)",500,-0.5,499.5);
326
327   fhEvents = CreateHisto2D("hTriggerDecision","Trigger Decision",3,-0.5,2.5,3,-0.5,2.5,"V0A Decision","V0C Decision");
328   fhEvents->GetXaxis()->SetBinLabel(1,"Fake");
329   fhEvents->GetXaxis()->SetBinLabel(2,"BB");
330   fhEvents->GetXaxis()->SetBinLabel(3,"BG");
331   fhEvents->GetYaxis()->SetBinLabel(1,"Fake");
332   fhEvents->GetYaxis()->SetBinLabel(2,"BB");
333   fhEvents->GetYaxis()->SetBinLabel(3,"BG");
334
335   fhVtxXYBB = CreateHisto2D("fhVtxXYBB","XY SPD vertex (bb)",200,-2,2,200,-2,2);
336   fhVtxZBB = CreateHisto1D("fhVtxZBB","Z SPD vertex (bb)",400,-50,50);
337   fhVtxXYBGA = CreateHisto2D("fhVtxXYBGA","XY SPD vertex (bga)",200,-2,2,200,-2,2);
338   fhVtxZBGA = CreateHisto1D("fhVtxZBGA","Z SPD vertex (bga)",400,-50,50);
339   fhVtxXYBGC = CreateHisto2D("fhVtxXYBGC","XY SPD vertex (bgc)",200,-2,2,200,-2,2);
340   fhVtxZBGC = CreateHisto1D("fhVtxZBGC","Z SPD vertex (bgc)",400,-50,50);
341
342   fhPmtMult = CreateHisto2D("hV0CellMult","Number of fired PMTs (V0C vs V0A)",33,-0.5,32.5,33,-0.5,32.5,"# Cell (V0A)","# Cell (V0C)");
343         fOutputList->Add(fhPmtMult);
344
345
346   fOutputList->Add(fhAdcPMTNoTime);
347   fOutputList->Add(fhAdcPMTWithTime);
348
349   fOutputList->Add(fhTimePMT);
350   fOutputList->Add(fhWidthPMT);
351
352   fOutputList->Add(fhTimeCorr);
353   fOutputList->Add(fhV0ampl);
354
355   fOutputList->Add(fhEvents);
356
357   fOutputList->Add(fhVtxXYBB);
358   fOutputList->Add(fhVtxZBB);
359   fOutputList->Add(fhVtxXYBGA);
360   fOutputList->Add(fhVtxZBGA);
361   fOutputList->Add(fhVtxXYBGC);
362   fOutputList->Add(fhVtxZBGC);
363   
364 }
365 //________________________________________________________________________
366 void AliAnaVZEROPbPb::FillPerL2TriggerHistos(){
367   // Fill the histos which are split
368   // by L2 trigger class
369    TString trigStr(fESD->GetFiredTriggerClasses());
370   
371         TIter iter(fClassesNames);
372         TObjString* name;
373         Int_t iClass =0;
374         
375    
376         TObjArray * tokens = trigStr.Tokenize(" ");
377     Int_t ntokens = tokens->GetEntriesFast();
378                 
379   while((name = (TObjString*) iter.Next())){
380         
381         Bool_t goodTrig = kFALSE;
382         if(iClass>0){
383         for (Int_t itoken = 0; itoken < ntokens; ++itoken) {
384                         if (!((((TObjString*)tokens->At(itoken))->String()).Contains("-B-"))) continue;
385                         if ((((TObjString*)tokens->At(itoken))->String()).BeginsWith(name->String().Data())) {
386                                 goodTrig = kTRUE;
387                                 break;
388                         }
389                 }
390         } else goodTrig = kTRUE;
391         
392         if (!goodTrig) {
393                 iClass++;
394                 continue;
395         }
396 //      if (!trigStr.Contains(name->String().Data())) continue;
397         
398         fhOnlineCharge[iClass]->Fill(fEsdV0->GetTriggerChargeA(),fEsdV0->GetTriggerChargeC());
399         
400         fhL2Triggers->Fill(iClass);
401                 
402         fhRecoMult[iClass]->Fill(fEsdV0->GetMTotV0A(),fEsdV0->GetMTotV0C());
403         fhTotRecoMult[iClass]->Fill(fEsdV0->GetMTotV0A()+fEsdV0->GetMTotV0C());
404
405         for(int iTrig = 0; iTrig < 16; ++iTrig){
406                 if(fEsdV0->GetTriggerBits() & (1<<iTrig)) fhTriggerBits[iClass]->Fill(iTrig);   
407         }
408         
409     AliCentrality *centrality = fESD->GetCentrality();
410         Float_t percentile = centrality->GetCentralityPercentile("V0M");
411         Float_t spdPercentile = centrality->GetCentralityPercentile("CL1");
412         //      if (spdPercentile < 0) spdPercentile = 0;
413         //      if (percentile < 0) percentile = 0;
414         fhCentrality[iClass]->Fill(percentile);
415         fhV0vsSPDCentrality[iClass]->Fill(spdPercentile,percentile);
416         
417         Float_t sumEqMult[2] = {0.,0.};
418         for(int iCh = 0; iCh < 64; ++iCh){
419                 if(fEsdV0->GetTime(iCh) < -1024.+ 1e-6) continue;
420                 fhRecoMultPMT[iClass]->Fill(iCh,fEsdV0->GetMultiplicity(iCh));
421                 Int_t side = iCh / 32 ;
422                 sumEqMult[side] += fESD->GetVZEROEqMultiplicity(iCh);
423                 fhEqualizedMult[iClass]->Fill(iCh,fESD->GetVZEROEqMultiplicity(iCh));
424         }
425         fhEqualizedMultSum[iClass]->Fill(sumEqMult[1],sumEqMult[0]);
426         
427         iClass++;
428   }
429         delete tokens;
430
431 }
432 //________________________________________________________________________
433 void AliAnaVZEROPbPb::FillQAHistos(){
434   // Fill the main QA histos
435   // Count V0 flags
436   Int_t nV0A = 0, nV0C = 0;
437   for(Int_t i = 0; i < 32; ++i) {
438     if (fEsdV0->GetBBFlag(i)) nV0C++;
439     if (fEsdV0->GetBBFlag(i+32)) nV0A++;
440   }
441   fNFlags->Fill((Float_t)nV0A,(Float_t)nV0C);
442
443   for (Int_t i=0; i<64; ++i) {
444         Int_t side = i/32;
445         if (fEsdV0->GetTime(i) < 1e-6) {
446                 fhAdcNoTime[side]->Fill(fEsdV0->GetAdc(i));
447                 fhAdcPMTNoTime->Fill(i,fEsdV0->GetAdc(i));
448     } else {
449                 fhAdcWithTime[side]->Fill(fEsdV0->GetAdc(i));
450                 fhAdcPMTWithTime->Fill(i,fEsdV0->GetAdc(i));
451     }
452
453         fhTime[side]->Fill(fEsdV0->GetTime(i));
454         fhWidth[side]->Fill(fEsdV0->GetWidth(i));
455         fhAdcWidth[side]->Fill(fEsdV0->GetAdc(i),fEsdV0->GetWidth(i));
456         fhAdcTime[side]->Fill(fEsdV0->GetTime(i),fEsdV0->GetAdc(i));
457
458     fhTimePMT->Fill(i,fEsdV0->GetTime(i));
459     fhWidthPMT->Fill(i,fEsdV0->GetWidth(i));
460
461   }
462
463   fhTimeCorr->Fill(fEsdV0->GetV0ATime(),fEsdV0->GetV0CTime());
464
465   AliESDVZERO::Decision flaga = fEsdV0->GetV0ADecision();
466   AliESDVZERO::Decision flagc = fEsdV0->GetV0CDecision();
467
468   fhEvents->Fill(flaga,flagc);
469
470   const AliESDVertex *vtx = fESD->GetPrimaryVertexSPD();
471
472   if (flaga <= 1 && flagc <=1) {
473     fhVtxXYBB->Fill(vtx->GetXv(),vtx->GetYv());
474     fhVtxZBB->Fill(vtx->GetZv());
475   }
476   else {
477     if (flaga == 2) {
478       fhVtxXYBGA->Fill(vtx->GetXv(),vtx->GetYv());
479       fhVtxZBGA->Fill(vtx->GetZv());
480     }
481     if (flagc == 2) {
482       fhVtxXYBGC->Fill(vtx->GetXv(),vtx->GetYv());
483       fhVtxZBGC->Fill(vtx->GetZv());
484     }
485   }
486
487   fhPmtMult->Fill(fEsdV0->GetNbPMV0A(),fEsdV0->GetNbPMV0C());
488   for(Int_t i = 0; i < 64; i++) {
489     fhV0ampl->Fill(fEsdV0->GetMultiplicity(i));
490   }
491   
492 }
493 //________________________________________________________________________
494 void AliAnaVZEROPbPb::Terminate(Option_t *) 
495 {
496   // Check if the output list is there
497   // Called once at the end of the query
498
499   fOutputList = dynamic_cast<TList*> (GetOutputData(1));
500   if (!fOutputList) {
501     printf("ERROR: Output list not available\n");
502     return;
503   }
504
505 }
506 //________________________________________________________________________
507 void AliAnaVZEROPbPb::SetOnlineChargeRange(Int_t nbins, Float_t maxA, Float_t maxC){
508   // Set Trigger charge
509   // range used for histogramming
510         fNBinOnlineCharge = nbins;
511         fV0AOnlineChargeMax = maxA;
512         fV0COnlineChargeMax = maxC;
513 }
514 //________________________________________________________________________
515 void AliAnaVZEROPbPb::SetTotalMultiplicityRange(Int_t nbins, Float_t max){
516   // Set Multiplicity 
517   // range used for histogramming
518         fNBinTotMult = nbins;
519         fTotMultMax = max;
520 }
521 //________________________________________________________________________
522 void AliAnaVZEROPbPb::SetMultiplicityRange(Int_t nbins, Float_t maxA, Float_t maxC){
523   // Set Multiplicity 
524   // range used for histogramming
525         fNBinMult = nbins;
526         fV0AMultMax = maxA;
527         fV0CMultMax = maxC;
528 }
529 //________________________________________________________________________
530 void AliAnaVZEROPbPb::SetEquaMultRange(Int_t nbins, Float_t max){
531   // Set Equalized multiplicity
532   // range used for histogramming
533         fNBinEquaMult = nbins;
534         fEquaMultMax = max;
535 }
536 //________________________________________________________________________
537 void AliAnaVZEROPbPb::SetSumEquaMultRange(Int_t nbins, Float_t maxA, Float_t maxC){
538   // Set Equalized multiplicity
539   // range used for histogramming
540         fNBinSumsEqMult = nbins;
541         fV0AEqMultMax = maxA;
542         fV0CEqMultMax = maxC;
543 }
544