]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/AliAnalysisTaskSEHFQA.cxx
AliAODEvent::GetHeader() returns AliVHeader
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSEHFQA.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2009, 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 /* $Id$ */
17
18 /////////////////////////////////////////////////////////////
19 //
20 // AliAnalysisTaskSE for HF quality assurance
21 //
22 // Author: Chiara Bianchin, chiara.bianchin@pd.infn.it
23 /////////////////////////////////////////////////////////////
24
25 #include <Riostream.h>
26 #include <TClonesArray.h>
27 #include <TCanvas.h>
28 #include <TList.h>
29 #include <TH1F.h>
30 #include <TH2F.h>
31 #include <TH3F.h>
32 #include <TProfile2D.h>
33 #include <TDatabasePDG.h>
34
35 #include <AliAnalysisDataSlot.h>
36 #include <AliAnalysisDataContainer.h>
37 #include "AliAnalysisManager.h"
38 #include "AliESDtrack.h"
39 #include "AliESDVertex.h"
40 #include "AliVertexerTracks.h"
41 #include "AliPID.h"
42 #include "AliPIDResponse.h"
43 #include "AliTPCPIDResponse.h"
44 #include "AliAODHandler.h"
45 #include "AliAODEvent.h"
46 #include "AliAODVertex.h"
47 #include "AliAODTrack.h"
48 #include "AliAODMCParticle.h"
49 #include "AliAODMCHeader.h"
50 #include "AliAODRecoDecayHF2Prong.h"
51 #include "AliAODRecoCascadeHF.h"
52 #include "AliAnalysisVertexingHF.h"
53 #include "AliAnalysisTaskSE.h"
54 #include "AliCounterCollection.h"
55 #include "AliRDHFCuts.h"
56 #include "AliRDHFCutsDplustoKpipi.h"
57 #include "AliRDHFCutsD0toKpipipi.h"
58 #include "AliRDHFCutsDstoKKpi.h"
59 #include "AliRDHFCutsDStartoKpipi.h"
60 #include "AliRDHFCutsD0toKpi.h"
61 #include "AliRDHFCutsLctopKpi.h"
62 #include "AliRDHFCutsLctoV0.h"
63 #include "AliVertexingHFUtils.h"
64 #include "AliInputEventHandler.h"
65
66 #include "AliFlowEvent.h"
67 #include "AliFlowTrackCuts.h"
68 #include "AliFlowTrackSimple.h"
69 #include "AliFlowVector.h"
70
71 #include "AliTRDTriggerAnalysis.h"
72
73 #include "AliAnalysisTaskSEHFQA.h"
74
75 using std::cout;
76 using std::endl;
77
78 ClassImp(AliAnalysisTaskSEHFQA)
79
80 //____________________________________________________________________________
81
82 AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA():AliAnalysisTaskSE(),
83   fNEntries(0x0),
84   fOutputPID(0x0),
85   fOutputTrack(0x0),
86   fOutputCounters(0x0),
87   fOutputCheckCentrality(0x0),
88   fOutputEvSelection(0x0),
89   fOutputFlowObs(0x0),
90   fDecayChannel(AliAnalysisTaskSEHFQA::kD0toKpi),
91   fCuts(0x0),
92   fFlowEvent(0x0),
93   fRFPcuts(0x0),
94   fEstimator(AliRDHFCuts::kCentTRK),
95   fReadMC(kFALSE),
96   fSimpleMode(kFALSE),
97   fUseSelectionBit(kTRUE),
98   fOnOff(),
99   fFillDistrTrackEffChecks(kFALSE)
100 {
101   //default constructor
102   fOnOff[0]=kTRUE;
103   fOnOff[1]=kTRUE;
104   fOnOff[2]=kTRUE;
105   fOnOff[3]=kTRUE;
106   fOnOff[4]=kTRUE;
107 }
108
109 //____________________________________________________________________________
110 AliAnalysisTaskSEHFQA::AliAnalysisTaskSEHFQA(const char *name, AliAnalysisTaskSEHFQA::DecChannel ch,AliRDHFCuts* cuts):
111   AliAnalysisTaskSE(name),
112   fNEntries(0x0),
113   fOutputPID(0x0),
114   fOutputTrack(0x0),
115   fOutputCounters(0x0),
116   fOutputCheckCentrality(0x0),
117   fOutputEvSelection(0x0),
118   fOutputFlowObs(0x0),
119   fDecayChannel(ch),
120   fCuts(0x0),
121   fFlowEvent(0x0),
122   fRFPcuts(0x0),
123   fEstimator(AliRDHFCuts::kCentTRK),
124   fReadMC(kFALSE),
125   fSimpleMode(kFALSE),
126   fUseSelectionBit(kTRUE),
127   fOnOff(),
128   fFillDistrTrackEffChecks(kFALSE)
129 {
130   //constructor
131
132   //SetCutObject(cuts);
133   fCuts=cuts;
134
135   fOnOff[0]=kTRUE;
136   fOnOff[1]=kTRUE;
137   fOnOff[2]=kTRUE;
138   fOnOff[3]=kTRUE;
139   fOnOff[4]=kTRUE;
140
141   // Output slot #1 writes into a TH1F container (number of events)
142   DefineOutput(1,TH1F::Class());  //My private output
143   // Output slot #2 writes into a TList container (PID)
144   if (fOnOff[1]) DefineOutput(2,TList::Class());  //My private output
145   // Output slot #3 writes into a TList container (Tracks)
146   if (fOnOff[0]) DefineOutput(3,TList::Class());  //My private output
147   // Output slot #4 writes into a AliRDHFCuts container (cuts)
148   switch(fDecayChannel){
149   case 0:
150     DefineOutput(4,AliRDHFCutsDplustoKpipi::Class());  //My private output
151     break;
152   case 1:
153     DefineOutput(4,AliRDHFCutsD0toKpi::Class());  //My private output
154     break;
155   case 2:
156     DefineOutput(4,AliRDHFCutsDStartoKpipi::Class());  //My private output
157     break;
158   case 3:
159     DefineOutput(4,AliRDHFCutsDstoKKpi::Class());  //My private output
160     break;
161   case 4:
162     DefineOutput(4,AliRDHFCutsD0toKpipipi::Class());  //My private output
163     break;
164   case 5:
165     DefineOutput(4,AliRDHFCutsLctopKpi::Class());  //My private output
166     break;
167   case kLambdactoV0:
168     DefineOutput(4,AliRDHFCutsLctoV0::Class());  //My private output
169     break;
170   }
171   if (fOnOff[2]) {
172     // Output slot #5 writes into a TList container (AliCounterCollection)
173     DefineOutput(5,TList::Class());  //My private output
174     // Output slot #6 writes into a TList container (TH1F)
175     DefineOutput(6,TList::Class());  //My private output
176   }
177
178   if(fOnOff[3]) DefineOutput(7,TList::Class());  //My private output
179   if(fOnOff[4]) DefineOutput(8,TList::Class());  //My private output
180
181 }
182
183 //___________________________________________________________________________
184 AliAnalysisTaskSEHFQA::~AliAnalysisTaskSEHFQA()
185 {
186   //destructor
187   delete fNEntries;
188
189   delete fOutputPID;
190
191   delete fOutputTrack;
192
193   delete fOutputCounters;
194
195   delete fOutputCheckCentrality;
196
197   delete fOutputEvSelection;
198
199   if(fOnOff[4]) {
200     delete fOutputFlowObs;
201     delete fFlowEvent;
202   }
203 }
204
205 //___________________________________________________________________________
206 void AliAnalysisTaskSEHFQA::Init(){
207
208   //initialization
209   if(fDebug > 1) printf("AnalysisTaskSEHFQA::Init() \n");
210   AliRDHFCuts *copycut = 0x0;
211
212   switch(fDecayChannel){
213   case 0:
214     {
215       copycut=new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fCuts)));
216     }
217     break;
218   case 1:
219     {
220       copycut=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
221     }
222     break;
223   case 2:
224     {
225       copycut=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
226     }
227     break;
228   case 3:
229     {
230       copycut=new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fCuts)));
231     }
232     break;
233   case 4:
234     {
235       copycut=new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fCuts)));
236     }
237     break;
238   case 5:
239     {
240       copycut=new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fCuts)));
241     }
242     break;
243   case kLambdactoV0:
244     {
245       copycut=new AliRDHFCutsLctoV0(*(static_cast<AliRDHFCutsLctoV0*>(fCuts)));
246     }
247     break;
248   default:
249     AliFatal("Bad initialization for the decay channe - Exiting...");
250     break;
251   }  
252
253   const char* nameoutput=GetOutputSlot(4)->GetContainer()->GetName();
254   if (copycut){
255     copycut->SetName(nameoutput);
256     
257     // Post the data
258     PostData(4,copycut);
259   }else{
260     AliFatal("Failing initializing AliRDHFCuts object - Exiting...");
261   }     
262
263   return;
264
265 }
266
267 //___________________________________________________________________________
268 void AliAnalysisTaskSEHFQA::UserCreateOutputObjects()
269 {
270
271   //create the output container
272   if(fDebug > 1) printf("AnalysisTaskSEHFQA::UserCreateOutputObjects() \n");
273
274   //count events
275
276   fNEntries=new TH1F(GetOutputSlot(1)->GetContainer()->GetName(), "Counts the number of events", 10,-0.5,9.5);
277   fNEntries->GetXaxis()->SetBinLabel(1,"nEventsAnal");
278   fNEntries->GetXaxis()->SetBinLabel(2,"Pile-up Rej");
279   fNEntries->GetXaxis()->SetBinLabel(3,"No VertexingHF");
280   fNEntries->GetXaxis()->SetBinLabel(4,"nCandidates(AnCuts)");
281   fNEntries->GetXaxis()->SetBinLabel(5,"EventsWithGoodVtx");
282   //fNEntries->GetXaxis()->SetBinLabel(6,"N. of 0SMH");
283   fNEntries->GetXaxis()->SetBinLabel(6,"N candidates");
284   if(fReadMC){
285     fNEntries->GetXaxis()->SetBinLabel(7,"MC Cand from c");
286     fNEntries->GetXaxis()->SetBinLabel(8,"MC Cand from b");
287     fNEntries->GetXaxis()->SetBinLabel(9,"N fake Trks");
288     fNEntries->GetXaxis()->SetBinLabel(10,"N true Trks");
289   }
290
291   fNEntries->GetXaxis()->SetNdivisions(1,kFALSE);
292
293   //PID
294   if(fOnOff[1]){
295     fOutputPID=new TList();
296     fOutputPID->SetOwner();
297     fOutputPID->SetName(GetOutputSlot(2)->GetContainer()->GetName());
298
299     //TOF pid
300     TH1F* hTOFflags=new TH1F("hTOFflags","TOF flags",7,-0.5,6.5);
301     hTOFflags->SetMinimum(0.);
302     hTOFflags->GetXaxis()->SetBinLabel(1,"All Tracks");
303     hTOFflags->GetXaxis()->SetBinLabel(2,"kTPCout");
304     hTOFflags->GetXaxis()->SetBinLabel(3,"kTOFout");
305     hTOFflags->GetXaxis()->SetBinLabel(4,"kTIME");
306     hTOFflags->GetXaxis()->SetBinLabel(5,"kTOFpid");
307     hTOFflags->GetXaxis()->SetBinLabel(6,"kTOFmismatch");
308     hTOFflags->GetXaxis()->SetBinLabel(7,"kDetPidOK");
309
310     TString hname="hTOFsig";
311     TH1F* hTOFsig=new TH1F(hname.Data(),"Distribution of TOF signal;TOF time [ps];Entries", 100, -2.e3,40.e3);
312
313     hname="hTOFstartTimeMask";
314     TH1F* hTOFstartTimeMask=new TH1F(hname.Data(),"TOF start time mask; Mask ;Entries", 8, -0.5,7.5);
315     hTOFstartTimeMask->GetXaxis()->SetBinLabel(1,"FILL");
316     hTOFstartTimeMask->GetXaxis()->SetBinLabel(2,"TOF");
317     hTOFstartTimeMask->GetXaxis()->SetBinLabel(3,"T0A");
318     hTOFstartTimeMask->GetXaxis()->SetBinLabel(4,"TOF.and.T0A");
319     hTOFstartTimeMask->GetXaxis()->SetBinLabel(5,"T0C");
320     hTOFstartTimeMask->GetXaxis()->SetBinLabel(6,"TOF.and.T0C");
321     hTOFstartTimeMask->GetXaxis()->SetBinLabel(7,"T0AC");
322     hTOFstartTimeMask->GetXaxis()->SetBinLabel(8,"TOF.and.T0AC");
323
324     hname="hTOFstartTimeRes";
325     TH1F* hTOFstartTimeRes=new TH1F(hname.Data(),"TOF start time resolution; Resolution (ps) ;Entries", 100, 0.,300.);
326
327     hname="hTOFstartTimeDistrib";
328     TH1F* hTOFstartTimeDistrib=new TH1F(hname.Data(),"TOF start time distribution; Start time ;Entries", 400, -1000.,1000.);
329
330     hname="hTOFtime";
331     TH1F* hTOFtime=new TH1F(hname.Data(),"Distribution of TOF time Kaon;TOF time(Kaon) [ps];Entries", 1000, 0.,50000.);
332
333     hname="hTOFtimeKaonHyptime";
334     TH2F* hTOFtimeKaonHyptime=new TH2F(hname.Data(),"TOFtime - timeHypothesisForKaon;p[GeV/c];TOFtime - timeHypothesisForKaon [ps]",500,0.,10.,1000,-20000.,20000.);
335
336     hname="hTOFtimeKaonHyptimeAC";
337     TH2F* hTOFtimeKaonHyptimeAC=new TH2F(hname.Data(),"TOFtime - timeHypothesisForKaon;p[GeV/c];TOFtime - timeHypothesisForKaon [ps]",500,0.,10.,1000,-20000.,20000.);
338
339     hname="hTOFsigmaKSigPid";
340     TH2F* hTOFsigmaKSigPid=new TH2F(hname.Data(),"(TOFsignal-timeK)/tofSigPid;p[GeV/c];(TOFsignal-timeK)/tofSigPid",500,0.,10.,400,-20,20);
341
342     hname="hTOFsigmaPionSigPid";
343     TH2F* hTOFsigmaPionSigPid=new TH2F(hname.Data(),"(TOFsignal-time#pi)/tofSigPid;p[GeV/c];(TOFsignal-time#pi)/tofSigPid",500,0.,10.,400,-20,20);
344
345     hname="hTOFsigmaProtonSigPid";
346     TH2F* hTOFsigmaProtonSigPid=new TH2F(hname.Data(),"(TOFsignal-timep)/tofSigPid;p[GeV/c];(TOFsignal-time p)/tofSigPid",500,0.,10.,400,-20,20);
347
348     hname="hTOFsigPid3sigPion";
349     TH1F* hTOFsigPid3sigPion=new TH1F(hname.Data(),"TOF PID resolution (#pi) [ps]",500,0.,1000.);
350
351     hname="hTOFsigPid3sigKaon";
352     TH1F* hTOFsigPid3sigKaon=new TH1F(hname.Data(),"TOF PID resolution (K) [ps]",500,0.,1000.);
353
354     hname="hTOFsigPid3sigProton";
355     TH1F* hTOFsigPid3sigProton=new TH1F(hname.Data(),"TOF PID resolution (p) [ps]",500,0.,1000.);
356
357
358     //TPC pid
359     hname="hTPCsig";
360     TH1F* hTPCsig=new TH1F(hname.Data(),"Distribution of TPC signal;TPC sig;Entries", 100, 35.,100.);
361
362     hname="hTPCsigvsp";
363     TH2F* hTPCsigvsp=new TH2F(hname.Data(),"TPCsig vs p;TPC p[GeV/c];TPCsig",500,0.,10.,1000,35.,100.);
364  
365     hname="hTPCsigvspAC";
366     TH2F* hTPCsigvspAC=new TH2F(hname.Data(),"TPCsig vs p;TPCp[GeV/c];TPCsig",500,0.,10.,1000,35.,100.);
367
368     hname="hTPCsigmaK";
369     TH2F* hTPCsigmaK=new TH2F(hname.Data(),"TPC Sigma for K as a function of momentum;p[GeV/c];Sigma Kaon",500,0.,10.,400,-20,20);
370
371     hname="hTPCsigmaPion";
372     TH2F* hTPCsigmaPion=new TH2F(hname.Data(),"TPC Sigma for #pi as a function of momentum;p[GeV/c];Sigma #pi",500,0.,10.,400,-20,20);
373
374     hname="hTPCsigmaProton";
375     TH2F* hTPCsigmaProton=new TH2F(hname.Data(),"TPC Sigma for proton as a function of momentum;p[GeV/c];Sigma Proton",500,0.,10.,400,-20,20);
376
377
378     fOutputPID->Add(hTOFflags);
379     fOutputPID->Add(hTOFsig);
380     fOutputPID->Add(hTPCsig);
381     fOutputPID->Add(hTOFstartTimeMask);
382     fOutputPID->Add(hTOFstartTimeRes);
383     fOutputPID->Add(hTOFstartTimeDistrib);
384     fOutputPID->Add(hTOFtime);
385     fOutputPID->Add(hTOFtimeKaonHyptime);
386     fOutputPID->Add(hTOFtimeKaonHyptimeAC);
387     fOutputPID->Add(hTOFsigmaKSigPid);
388     fOutputPID->Add(hTOFsigmaPionSigPid);
389     fOutputPID->Add(hTOFsigmaProtonSigPid);
390     fOutputPID->Add(hTOFsigPid3sigPion);
391     fOutputPID->Add(hTOFsigPid3sigKaon);
392     fOutputPID->Add(hTOFsigPid3sigProton);
393     fOutputPID->Add(hTPCsigvsp);
394     fOutputPID->Add(hTPCsigvspAC);
395     fOutputPID->Add(hTPCsigmaK);
396     fOutputPID->Add(hTPCsigmaPion);
397     fOutputPID->Add(hTPCsigmaProton);
398
399     if(fFillDistrTrackEffChecks){
400
401       hname="hTPCsigNvsPtAllTracks";
402       TH2F* hTPCsigNvsPtAllTracks=new TH2F(hname.Data(),"Distribution of n. points used for TPC dE/dx vs. p_{T};p_{T} [GeV/c]; n. points", 200, 0.,20.,161,-0.5,160.5);
403       
404       hname="hTPCsigNvsPhiAllTracks";
405       TH2F* hTPCsigNvsPhiAllTracks=new TH2F(hname.Data(),"Distribution of n. points used for TPC dE/dx vs. #phi;#phi [rad]; n. points", 100, 0.,2*TMath::Pi(),161,-0.5,160.5);
406       
407       hname="hTPCsigNvsEtaAllTracks";
408       TH2F* hTPCsigNvsEtaAllTracks=new TH2F(hname.Data(),"Distribution of n. points used for TPC dE/dx vs. #eta;eta; n. points", 80,-2.,2.,161,-0.5,160.5);
409       
410       hname="hTPCsigNvsPtDaughters";
411       TH2F* hTPCsigNvsPtDaughters=new TH2F(hname.Data(),"Distribution of n. points used for TPC dE/dx vs. p_{T};p_{T} [GeV/c]; n. points", 200, 0.,20.,161,-0.5,160.5);
412       
413       hname="hTPCsigNvsPhiDaughters";
414       TH2F* hTPCsigNvsPhiDaughters=new TH2F(hname.Data(),"Distribution of n. points used for TPC dE/dx vs. #phi;#phi [rad]; n. points", 100, 0.,2*TMath::Pi(),161,-0.5,160.5);
415       
416       hname="hTPCsigNvsEtaDaughters";
417       TH2F* hTPCsigNvsEtaDaughters=new TH2F(hname.Data(),"Distribution of n. points used for TPC dE/dx vs. #eta;eta; n. points", 80,-2.,2.,161,-0.5,160.5);
418       
419       fOutputPID->Add(hTPCsigNvsPtAllTracks);
420       fOutputPID->Add(hTPCsigNvsPhiAllTracks);
421       fOutputPID->Add(hTPCsigNvsEtaAllTracks);
422       fOutputPID->Add(hTPCsigNvsPtDaughters);
423       fOutputPID->Add(hTPCsigNvsPhiDaughters);
424       fOutputPID->Add(hTPCsigNvsEtaDaughters);
425     }
426     
427     
428     if(fReadMC){
429       //TOF
430       hname="hTOFsigmaMCKSigPid";
431       TH2F* hTOFsigmaMCKSigPid=new TH2F(hname.Data(),"(TOFsignal-timeK)/tofSigPid;p[GeV/c];(TOFsignal-timeK)/tofSigPid",500,0.,10.,400,-20,20);
432
433       hname="hTOFsigmaMCPionSigPid";
434       TH2F* hTOFsigmaMCPionSigPid=new TH2F(hname.Data(),"(TOFsignal-time#pi)/tofSigPid;p[GeV/c];(TOFsignal-time#pi)/tofSigPid",500,0.,10.,400,-20,20);
435
436       hname="hTOFsigmaMCProtonSigPid";
437       TH2F* hTOFsigmaMCProtonSigPid=new TH2F(hname.Data(),"(TOFsignal-timep)/tofSigPid;p[GeV/c];(TOFsignal-time p)/tofSigPid",500,0.,10.,400,-20,20);
438
439       //TPC
440       hname="hTPCsigmaMCK";
441       TH2F* hTPCsigmaMCK=new TH2F(hname.Data(),"TPC Sigma for K as a function of momentum;p[GeV/c];Sigma Kaon",500,0.,10.,400,-20,20);
442
443       hname="hTPCsigmaMCPion";
444       TH2F* hTPCsigmaMCPion=new TH2F(hname.Data(),"TPC Sigma for #pi as a function of momentum;p[GeV/c];Sigma #pi",500,0.,10.,400,-20,20);
445
446       hname="hTPCsigmaMCProton";
447       TH2F* hTPCsigmaMCProton=new TH2F(hname.Data(),"TPC Sigma for proton as a function of momentum;p[GeV/c];Sigma Proton",500,0.,10.,400,-20,20);
448
449       fOutputPID->Add(hTOFsigmaMCKSigPid);
450       fOutputPID->Add(hTOFsigmaMCPionSigPid);
451       fOutputPID->Add(hTOFsigmaMCProtonSigPid);
452       fOutputPID->Add(hTPCsigmaMCK);
453       fOutputPID->Add(hTPCsigmaMCPion);
454       fOutputPID->Add(hTPCsigmaMCProton);
455
456     }
457   }
458
459   //quality of the tracks
460   if(fOnOff[0]){
461     fOutputTrack=new TList();
462     fOutputTrack->SetOwner();
463     fOutputTrack->SetName(GetOutputSlot(3)->GetContainer()->GetName());
464
465     TString hname="hnClsITS";
466     TH1F* hnClsITS=new TH1F(hname.Data(),"Distribution of number of ITS clusters;nITScls;Entries",7,-0.5,6.5);
467
468     hname="hnClsITSselTr";
469     TH1F* hnClsITSselTr=new TH1F(hname.Data(),"Distribution of number of ITS clusters selected tracks;nITScls;Entries",7,-0.5,6.5);
470
471     hname="hnClsITS-SA";
472     TH1F* hnClsITSSA=new TH1F(hname.Data(),"Distribution of number of ITS clusters(ITS-SA);nITScls;Entries",7,-0.5,6.5);
473
474
475     hname="hnLayerITS";
476     TH1F* hnLayerITS=new TH1F(hname.Data(),"Number of tracks with point in layer;ITS layer;",7,-1.5,5.5);
477     hnLayerITS->GetXaxis()->SetBinLabel(1,"n tracks");
478     hnLayerITS->GetXaxis()->SetBinLabel(2,"SPDin");
479     hnLayerITS->GetXaxis()->SetBinLabel(3,"SPDout");
480     hnLayerITS->GetXaxis()->SetBinLabel(4,"SDDin");
481     hnLayerITS->GetXaxis()->SetBinLabel(5,"SDDout");
482     hnLayerITS->GetXaxis()->SetBinLabel(6,"SSDin");
483     hnLayerITS->GetXaxis()->SetBinLabel(7,"SSDout");
484
485     hname="hnLayerITSsa";
486     TH1F* hnLayerITSsa=new TH1F(hname.Data(),"Number of tracks with point in layer;ITS layer;",7,-1.5,5.5);
487     hnLayerITSsa->GetXaxis()->SetBinLabel(1,"n tracks");
488     hnLayerITSsa->GetXaxis()->SetBinLabel(2,"SPDin");
489     hnLayerITSsa->GetXaxis()->SetBinLabel(3,"SPDout");
490     hnLayerITSsa->GetXaxis()->SetBinLabel(4,"SDDin");
491     hnLayerITSsa->GetXaxis()->SetBinLabel(5,"SDDout");
492     hnLayerITSsa->GetXaxis()->SetBinLabel(6,"SSDin");
493     hnLayerITSsa->GetXaxis()->SetBinLabel(7,"SSDout");
494    
495     hname="hnClsSPD";
496     TH1F* hnClsSPD=new TH1F(hname.Data(),"Distribution of number of SPD clusters;nSPDcls;Entries",3,-0.5,2.5);
497
498     hname="hptGoodTr";
499     TH1F* hptGoodTr=new TH1F(hname.Data(),"Pt distribution of 'good' tracks;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
500     hptGoodTr->SetTitleOffset(1.3,"Y");
501
502     if(!fSimpleMode){
503       hname="hptGoodTrFromDaugh";
504       TH1F* hptGoodTrFromDaugh=new TH1F(hname.Data(),"Pt distribution of 'good' candidate's daughters;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
505       hptGoodTrFromDaugh->SetTitleOffset(1.3,"Y");
506       fOutputTrack->Add(hptGoodTrFromDaugh);
507     }
508
509     hname="hdistrGoodTr";
510     TH1F* hdistrGoodTr=new TH1F(hname.Data(),"Distribution of number of 'good' candidate's daughters per event;no.good-tracks/ev;Entries",4000,-0.5,3999.5);
511     hdistrGoodTr->SetTitleOffset(1.3,"Y");
512
513     hname="hdistrSelTr";
514     TH1F* hdistrSelTr=new TH1F(hname.Data(),"Distribution of number of Selected tracks per event;no.good-tracks/ev;Entries",4000,-0.5,3999.5);
515     hdistrSelTr->SetTitleOffset(1.3,"Y");
516
517     hname="hd0dau";
518     TH1F* hd0dau=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of D daughter tracks;d_{0rphi}[cm];Entries/10^{3} cm",200,-0.1,0.1);
519
520     hname="hd0dauphi";
521     TH2F* hd0dauphi=new TH2F(hname.Data(), "Impact parameter (rphi) distribution of D daughter tracks versus #phi; #phi [rad]; d_{0rphi} [cm]",400,0,6.3,200,-0.1,0.1);
522
523     hname="hd0zdau";
524     TH1F* hd0zdau=new TH1F(hname.Data(),"Impact parameter (z) distribution of D daughter tracks;d_{0z}[cm];Entries/10^{3} cm",200,-0.1,0.1);
525
526     hname="hd0zdauphi";
527     TH2F* hd0zdauphi=new TH2F(hname.Data(), "Impact parameter (z) distribution of D daughter tracks versus #phi; #phi [rad]; d_{0z} [cm]",400,0,6.3,200,-0.1,0.1);
528
529     hname="hd0TracksSPDin";
530     TH1F* hd0TracksSPDin=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks kITSrefit, SPDinner; d_{0rphi}[cm];Entries",200,-0.5,0.5);
531
532     hname="hd0TracksSPDany";
533     TH1F* hd0TracksSPDany=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks kITSrefit, SPDany; d_{0rphi}[cm];Entries",200,-0.5,0.5);
534
535     hname="hd0TracksFilterBit4";
536     TH1F* hd0TracksFilterBit4=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks FilterBit4; d_{0rphi}[cm];Entries",200,-0.5,0.5);
537
538     hname="hd0TracksTPCITSSPDany";
539     TH1F* hd0TracksTPCITSSPDany=new TH1F(hname.Data(),"Impact parameter (rphi) distribution of AOD tracks TPC+ITScuts+SPDany; d_{0rphi}[cm];Entries",200,-0.5,0.5);
540
541
542     if(fFillDistrTrackEffChecks){
543       hname="hPtDaughters";
544       TH1F *hPtDaughters=new TH1F(hname.Data(),"p_{T} distributions of the daughter tracks;p_{T} [GeV/c];Entries",200,0.,20.);
545
546       hname="hPhiDaughters";
547       TH1F *hPhiDaughters=new TH1F(hname.Data(),"#phi distribution of the daughter tracks;#phi [rad];Entries",100,0.,2*(TMath::Pi()));
548
549       hname="hEtaDaughters";
550       TH1F *hEtaDaughters=new TH1F(hname.Data(),"#eta distribution of the daughter tracks;#eta;Entries",80,-2.,2.);
551
552       hname="hEtavsPhiDaughters";
553       TH2F *hEtavsPhiDaughters=new TH2F(hname.Data(),"#eta vs #phi distribution of the daughter tracks;#phi;#eta",100,0.,2*(TMath::Pi()),80,-2.,2.);
554
555       hname="hNTPCclsvsPtDaughters";
556       TH2F *hNTPCclsvsPtDaughters=new TH2F(hname.Data(),"N TPC clusters vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];N TPC cls",200,0.,20.,85,-0.5,169.5);
557
558       hname="hNTPCclsvsPhiDaughters";
559       TH2F *hNTPCclsvsPhiDaughters=new TH2F(hname.Data(),"N TPC clusters vs #phi distribution of the daughter tracks;#phi [rad];N TPC cls",100,0.,2*(TMath::Pi()),85,-0.5,169.5);
560
561       hname="hNTPCclsvsEtaDaughters";
562       TH2F *hNTPCclsvsEtaDaughters=new TH2F(hname.Data(),"N TPC clusters vs #eta distribution of the daughter tracks;#eta;N TPC cls",80,-2.,2.,85,-0.5,169.5);
563
564       hname="hNTPCCrossedRowsvsPtDaughters";
565       TH2F *hNTPCCrossedRowsvsPtDaughters=new TH2F(hname.Data(),"N TPC crossed rows vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];N TPC cros. rows",200,0.,20.,100,-0.5,199.5);
566
567       hname="hNTPCCrossedRowsvsPhiDaughters";
568       TH2F *hNTPCCrossedRowsvsPhiDaughters=new TH2F(hname.Data(),"N TPC crossed rows vs #phi distribution of the daughter tracks;#phi [rad];N TPC cros. rows",100,0.,2*(TMath::Pi()),100,-0.5,199.5);
569
570       hname="hNTPCCrossedRowsvsEtaDaughters";
571       TH2F *hNTPCCrossedRowsvsEtaDaughters=new TH2F(hname.Data(),"N TPC crossed rows vs #eta distribution of the daughter tracks;#eta;N TPC cros. rows",80,-2.,2.,100,-0.5,199.5);
572
573       hname="hRatioCRowsOverFclsvsPtDaughters";
574       TH2F *hRatioCRowsOverFclsvsPtDaughters=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];CRows/FCls",200,0.,20,100,0.,1.);
575
576       hname="hRatioCRowsOverFclsvsPhiDaughters";
577       TH2F *hRatioCRowsOverFclsvsPhiDaughters=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #phi distribution of the daughter tracks;#phi [rad];CRows/FCls",100,0.,2*(TMath::Pi()),100,0.,1.);
578
579       hname="hRatioCRowsOverFclsvsEtaDaughters";
580       TH2F *hRatioCRowsOverFclsvsEtaDaughters=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #eta distribution of the daughter tracks;#eta;CRows/FCls",80,-2.,2.,100,0.,1.);
581
582       hname="hNITSclsvsPtDaughters";
583       TH2F *hNITSclsvsPtDaughters=new TH2F(hname.Data(),"N ITS clusters vs p_{T} distribution of the daughter tracks;p_{T} [GeV/c];N ITS cls",200,0.,20,7,-0.5,6.5);
584
585       hname="hNITSclsvsPhiDaughters";
586       TH2F *hNITSclsvsPhiDaughters=new TH2F(hname.Data(),"N ITS clusters vs #phi distribution of the daughter tracks;#phi [rad];N ITS cls",100,0.,2*(TMath::Pi()),7,-0.5,6.5);
587
588       hname="hNITSclsvsEtaDaughters";
589       TH2F *hNITSclsvsEtaDaughters=new TH2F(hname.Data(),"N ITS clusters vs #eta distribution of the daughter tracks;#eta;N ITS cls",80,-2.,2.,7,-0.5,6.5);
590
591       hname="hSPDclsDaughters";
592       TH1I *hSPDclsDaughters = new TH1I(hname.Data(),"N SPD points distribution;;Entries",4,-0.5,3.5);
593       hSPDclsDaughters->GetXaxis()->SetBinLabel(1, "no SPD");
594       hSPDclsDaughters->GetXaxis()->SetBinLabel(2, "kOnlyFirst");
595       hSPDclsDaughters->GetXaxis()->SetBinLabel(3, "kOnlySecond");
596       hSPDclsDaughters->GetXaxis()->SetBinLabel(4, "kBoth");
597
598       hname="hPtAllTracks";
599       TH1F *hPtAllTracks=new TH1F(hname.Data(),"p_{T} distributions of the AOD tracks (ID>0);p_{T} [GeV/c];Entries",200,0.,20.);
600
601       hname="hPhiAllTracks";
602       TH1F *hPhiAllTracks=new TH1F(hname.Data(),"#phi distribution of the AOD tracks (ID>0);#phi [rad];Entries",100,0.,2*(TMath::Pi()));
603
604       hname="hEtaAllTracks";
605       TH1F *hEtaAllTracks=new TH1F(hname.Data(),"#eta distribution of the AOD tracks (ID>0);#eta;Entries",80,-2.,2.);
606
607       hname="hEtavsPhiAllTracks";
608       TH2F *hEtavsPhiAllTracks=new TH2F(hname.Data(),"#eta vs #phi distribution of the AOD tracks (ID>0);#phi;#eta",100,0.,2*(TMath::Pi()),80,-2.,2.);
609
610       hname="hNTPCclsvsPtAllTracks";
611       TH2F *hNTPCclsvsPtAllTracks=new TH2F(hname.Data(),"N TPC clusters vs p_{T} distribution of the AOD tracks (ID>0);p_{T} [GeV/c];N TPC cls",200,0.,20,85,-0.5,169.5);
612
613       hname="hNTPCclsvsPhiAllTracks";
614       TH2F *hNTPCclsvsPhiAllTracks=new TH2F(hname.Data(),"N TPC clusters vs #phi distribution of the AOD tracks (ID>0);#phi [rad];N TPC cls",100,0.,2*(TMath::Pi()),85,-0.5,169.5);
615
616       hname="hNTPCclsvsEtaAllTracks";
617       TH2F *hNTPCclsvsEtaAllTracks=new TH2F(hname.Data(),"N TPC clusters vs #eta distribution of the AOD tracks (ID>0);#eta;N TPC cls",80,-2.,2.,85,-0.5,169.5);
618
619       hname="hNTPCCrossedRowsvsPtAllTracks";
620       TH2F *hNTPCCrossedRowsvsPtAllTracks=new TH2F(hname.Data(),"N TPC crossed rows vs p_{T} distribution of the AOD tracks;p_{T} [GeV/c];N TPC cros. rows",200,0.,20.,100,-0.5,199.5);
621
622       hname="hNTPCCrossedRowsvsPhiAllTracks";
623       TH2F *hNTPCCrossedRowsvsPhiAllTracks=new TH2F(hname.Data(),"N TPC crossed rows vs #phi distribution of the AOD tracks;#phi [rad];N TPC cros. rows",100,0.,2*(TMath::Pi()),100,-0.5,199.5);
624
625       hname="hNTPCCrossedRowsvsEtaAllTracks";
626       TH2F *hNTPCCrossedRowsvsEtaAllTracks=new TH2F(hname.Data(),"N TPC crossed rows vs #eta distribution of the AOD tracks;#eta;N TPC cros. rows",80,-2.,2.,100,-0.5,199.5);
627
628       hname="hRatioCRowsOverFclsvsPtAllTracks";
629       TH2F *hRatioCRowsOverFclsvsPtAllTracks=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs p_{T} distribution of the AOD tracks (ID>0);p_{T} [GeV/c];CRows/FCls",200,0.,20,100,0.,1.);
630
631       hname="hRatioCRowsOverFclsvsPhiAllTracks";
632       TH2F *hRatioCRowsOverFclsvsPhiAllTracks=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #phi distribution of the AOD tracks (ID>0);#phi [rad];CRows/FCls",100,0.,2*(TMath::Pi()),100,0.,1.);
633
634       hname="hRatioCRowsOverFclsvsEtaAllTracks";
635       TH2F *hRatioCRowsOverFclsvsEtaAllTracks=new TH2F(hname.Data(),"CrossedRows/FindableClusters vs #eta distribution of the AOD tracks (ID>0);#eta;CRows/FCls",80,-2.,2.,100,0.,1.);
636
637       hname="hNITSclsvsPtAllTracks";
638       TH2F *hNITSclsvsPtAllTracks=new TH2F(hname.Data(),"N ITS clusters vs p_{T} distribution of the AOD tracks (ID>0);p_{T} [GeV/c];N ITS cls",200,0.,20,7,-0.5,6.5);
639
640       hname="hNITSclsvsPhiAllTracks";
641       TH2F *hNITSclsvsPhiAllTracks=new TH2F(hname.Data(),"N ITS clusters vs #phi distribution of the AOD tracks (ID>0);#phi [rad];N ITS cls",100,0.,2*(TMath::Pi()),7,-0.5,6.5);
642
643       hname="hNITSclsvsEtaAllTracks";
644       TH2F *hNITSclsvsEtaAllTracks=new TH2F(hname.Data(),"N ITS clusters vs #eta distribution of the AOD tracks (ID>0);#eta;N ITS cls",80,-2.,2.,7,-0.5,6.5);
645
646       hname="hSPDclsAllTracks";
647       TH1I *hSPDclsAllTracks = new TH1I(hname.Data(),"N SPD points distribution AOD tracks (ID>0);;Entries",4,-0.5,3.5);
648       hSPDclsAllTracks->GetXaxis()->SetBinLabel(1, "no SPD");
649       hSPDclsAllTracks->GetXaxis()->SetBinLabel(2, "kOnlyFirst");
650       hSPDclsAllTracks->GetXaxis()->SetBinLabel(3, "kOnlySecond");
651       hSPDclsAllTracks->GetXaxis()->SetBinLabel(4, "kBoth");
652
653
654       fOutputTrack->Add(hPtDaughters);
655       fOutputTrack->Add(hPhiDaughters);
656       fOutputTrack->Add(hEtaDaughters);
657       fOutputTrack->Add(hEtavsPhiDaughters);
658       fOutputTrack->Add(hNTPCclsvsPtDaughters);
659       fOutputTrack->Add(hNTPCclsvsPhiDaughters);
660       fOutputTrack->Add(hNTPCclsvsEtaDaughters);
661       fOutputTrack->Add(hNTPCCrossedRowsvsPtDaughters);
662       fOutputTrack->Add(hNTPCCrossedRowsvsPhiDaughters);
663       fOutputTrack->Add(hNTPCCrossedRowsvsEtaDaughters);
664       fOutputTrack->Add(hRatioCRowsOverFclsvsPtDaughters);
665       fOutputTrack->Add(hRatioCRowsOverFclsvsPhiDaughters);
666       fOutputTrack->Add(hRatioCRowsOverFclsvsEtaDaughters);
667       fOutputTrack->Add(hNITSclsvsPtDaughters);
668       fOutputTrack->Add(hNITSclsvsPhiDaughters);
669       fOutputTrack->Add(hNITSclsvsEtaDaughters);
670       fOutputTrack->Add(hSPDclsDaughters);
671       fOutputTrack->Add(hPtAllTracks);
672       fOutputTrack->Add(hPhiAllTracks);
673       fOutputTrack->Add(hEtaAllTracks);
674       fOutputTrack->Add(hEtavsPhiAllTracks);
675       fOutputTrack->Add(hNTPCclsvsPtAllTracks);
676       fOutputTrack->Add(hNTPCclsvsPhiAllTracks);
677       fOutputTrack->Add(hNTPCclsvsEtaAllTracks);
678       fOutputTrack->Add(hNTPCCrossedRowsvsPtAllTracks);
679       fOutputTrack->Add(hNTPCCrossedRowsvsPhiAllTracks);
680       fOutputTrack->Add(hNTPCCrossedRowsvsEtaAllTracks);
681       fOutputTrack->Add(hRatioCRowsOverFclsvsPtAllTracks);
682       fOutputTrack->Add(hRatioCRowsOverFclsvsPhiAllTracks);
683       fOutputTrack->Add(hRatioCRowsOverFclsvsEtaAllTracks);
684       fOutputTrack->Add(hNITSclsvsPtAllTracks);
685       fOutputTrack->Add(hNITSclsvsPhiAllTracks);
686       fOutputTrack->Add(hNITSclsvsEtaAllTracks);
687       fOutputTrack->Add(hSPDclsAllTracks);
688
689     }
690     
691     fOutputTrack->Add(hnClsITS);
692     fOutputTrack->Add(hnClsITSselTr);
693     fOutputTrack->Add(hnClsITSSA);
694     fOutputTrack->Add(hnLayerITS);
695     fOutputTrack->Add(hnLayerITSsa);
696     fOutputTrack->Add(hnClsSPD);
697     fOutputTrack->Add(hptGoodTr);
698     fOutputTrack->Add(hdistrGoodTr);
699     fOutputTrack->Add(hdistrSelTr);
700     fOutputTrack->Add(hd0TracksSPDin);
701     fOutputTrack->Add(hd0TracksSPDany);
702     fOutputTrack->Add(hd0TracksFilterBit4);
703     fOutputTrack->Add(hd0TracksTPCITSSPDany);
704     fOutputTrack->Add(hd0dau);
705     fOutputTrack->Add(hd0dauphi);
706     fOutputTrack->Add(hd0zdau);
707     fOutputTrack->Add(hd0zdauphi);
708     
709
710     if(fReadMC){
711       hname="hdistrFakeTr";
712       TH1F* hdistrFakeTr=new TH1F(hname.Data(),"Distribution of number of fake tracks per event;no.fake-tracks/ev;Entries",4000,-0.5,3999.5);
713       hdistrFakeTr->SetTitleOffset(1.3,"Y");
714
715       hname="hd0f";
716       TH1F* hd0f=new TH1F(hname.Data(),"Impact parameter distribution of fake tracks;d_{0}[cm];Entries/10^{3} cm",200,-0.1,0.1);
717
718       hname="hptFakeTr";
719       TH1F* hptFakeTr=new TH1F(hname.Data(),"Pt distribution of fake tracks;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
720       hptFakeTr->SetTitleOffset(1.3,"Y");
721       if(!fSimpleMode){
722         hname="hptFakeTrFromDaugh";
723         TH1F* hptFakeTrFromDaugh=new TH1F(hname.Data(),"Pt distribution of fake tracks from daughters;p_{t}[GeV];Entries/0.05 GeV/c",400,0.,20.);
724         hptFakeTrFromDaugh->SetTitleOffset(1.3,"Y");
725         fOutputTrack->Add(hptFakeTrFromDaugh);
726       }
727
728       fOutputTrack->Add(hptFakeTr);
729       fOutputTrack->Add(hdistrFakeTr);
730       fOutputTrack->Add(hd0f);
731    
732     }
733   }
734
735   
736   if(fOnOff[2] && fCuts->GetUseCentrality()){
737
738     //Centrality (Counters)
739     fOutputCounters=new TList();
740     fOutputCounters->SetOwner();
741     fOutputCounters->SetName(GetOutputSlot(5)->GetContainer()->GetName());
742
743     AliCounterCollection *stdEstimator=new AliCounterCollection("stdEstimator");
744     stdEstimator->AddRubric("run",500000);
745     stdEstimator->AddRubric("centralityclass","-10_0/0_10/10_20/20_30/30_40/40_50/50_60/60_70/70_80/80_90/90_100/-990_-980");
746     stdEstimator->Init();
747     AliCounterCollection *secondEstimator=new AliCounterCollection("secondEstimator");
748     secondEstimator->AddRubric("run",500000);
749     secondEstimator->AddRubric("centralityclass","-10_0/0_10/10_20/20_30/30_40/40_50/50_60/60_70/70_80/80_90/90_100/-990_-980");
750     secondEstimator->Init();
751  
752     fOutputCounters->Add(stdEstimator);
753     fOutputCounters->Add(secondEstimator);
754  
755     //Centrality (Checks)
756     fOutputCheckCentrality=new TList();
757     fOutputCheckCentrality->SetOwner();
758     fOutputCheckCentrality->SetName(GetOutputSlot(6)->GetContainer()->GetName());
759
760     TString hname="hNtrackletsIn";
761     TH1F* hNtrackletsIn=new TH1F(hname.Data(),"Number of tracklets in Centrality range;ntracklets;Entries",5000,-0.5,4999.5);
762
763     hname="hMultIn";
764     TH1F* hMultIn=new TH1F(hname.Data(),"Multiplicity;multiplicity in Centrality range;Entries",10000,-0.5,9999.5);
765
766     hname="hNtrackletsOut";
767     TH1F* hNtrackletsOut=new TH1F(hname.Data(),"Number of tracklets out of Centrality range;ntracklets;Entries",5000,-0.5,4999.5);
768
769     hname="hMultOut";
770     TH1F* hMultOut=new TH1F(hname.Data(),"Multiplicity out of Centrality range;multiplicity;Entries",10000,-0.5,9999.5);
771
772     hname="hMultvsPercentile";
773     TH2F* hMultvsPercentile=new TH2F(hname.Data(),"Multiplicity vs Percentile;multiplicity;percentile",10000,-0.5,9999.5,240,-10.,110);
774
775     hname="hntrklvsPercentile";
776     TH2F* hntrklvsPercentile=new TH2F(hname.Data(),"N tracklets vs Percentile;ntracklets;percentile",5000,-0.5,4999.5,240,-10.,110);
777
778     hname="hntrklvsPercentile01";
779     TH2F* hntrklvsPercentile01=new TH2F(hname.Data(),"N tracklets vs Percentile |#eta|<1;ntracklets;percentile",5000,-0.5,4999.5,240,-10.,110);
780       
781     hname="hntrklvsPercentile01AllEv";
782     TH2F* hntrklvsPercentile01AllEv=new TH2F(hname.Data(),"N tracklets vs Percentile |#eta|<1 - All Events;ntracklets;percentile",5000,-0.5,4999.5,240,-10.,110);
783
784     hname="hnTPCTracksvsPercentile";
785     TH2F* hnTPCTracksvsPercentile=new TH2F(hname.Data(),"N TPC tracks vs Percentile;nTPCTracks;percentile",5000,-0.5,9999.5,240,-10.,110);
786
787     hname="hnTPCITSTracksvsPercentile";
788     TH2F* hnTPCITSTracksvsPercentile=new TH2F(hname.Data(),"N TPC+ITS tracks vs Percentile;nTPCITSTracks;percentile",5000,-0.5,9999.5,240,-10.,110);
789
790     hname="hnTPCITS1SPDTracksvsPercentile";
791     TH2F* hnTPCITS1SPDTracksvsPercentile=new TH2F(hname.Data(),"N TPC+ITS+1SPD tracks vs Percentile;nTPCITS1SPDTracks;percentile",5000,-0.5,9999.5,240,-10.,110);
792
793     hname="hStdEstimSignalPercentile";
794     TH2F*hStdEstimSignalPercentile = new TH2F(hname.Data(),"Std estimator signal vs Percentile;Std estimator signal;percentile",1000,-0.5,9999.5,120,-10.,110);
795
796     hname="hStdEstimSignalNtrackletsIn";
797     TH2F*hStdEstimSignalNtrackletsIn = new TH2F(hname.Data(),"Std estimator signal vs Number of tracklets in the CC;Std estimator signal;number of tracklets",1000,-0.5,9999.5,5000,-0.5,4999.5);
798
799     hname="hStdEstimSignal";
800     TH1F*hStdEstimSignal = new TH1F(hname.Data(),"Std estimator signal",700,0,1400);
801
802     hname="hStdPercentileSecondPercentile";
803     TH2F* hStdPercentileSecondPercentile = new TH2F(hname.Data(),"Std estimator Percentile Vs Second Estimator Percentile;Std estimator percentile;Second estimator percentile",120,-10.,110,120,-10.,110);
804
805     hname="hStdSignalSecondSignal";
806     TH2F* hStdSignalSecondSignal = new TH2F(hname.Data(),"Std estimator signal Vs Second Estimator signal;Std estimator;Second estimator",1000,-0.5,9999.5,1000,-0.5,9999.5);
807
808     fOutputCheckCentrality->Add(hNtrackletsIn);
809     fOutputCheckCentrality->Add(hNtrackletsOut);
810     fOutputCheckCentrality->Add(hMultIn);
811     fOutputCheckCentrality->Add(hMultOut);
812     fOutputCheckCentrality->Add(hMultvsPercentile);
813     fOutputCheckCentrality->Add(hntrklvsPercentile);
814     fOutputCheckCentrality->Add(hntrklvsPercentile01);
815     fOutputCheckCentrality->Add(hntrklvsPercentile01AllEv);
816     fOutputCheckCentrality->Add(hnTPCTracksvsPercentile);
817     fOutputCheckCentrality->Add(hnTPCITSTracksvsPercentile);
818     fOutputCheckCentrality->Add(hnTPCITS1SPDTracksvsPercentile);
819     fOutputCheckCentrality->Add(hStdEstimSignalPercentile);
820     fOutputCheckCentrality->Add(hStdEstimSignal);
821     fOutputCheckCentrality->Add(hStdEstimSignalNtrackletsIn);
822     fOutputCheckCentrality->Add(hStdPercentileSecondPercentile);
823     fOutputCheckCentrality->Add(hStdSignalSecondSignal);
824
825     PostData(6,fOutputCheckCentrality);
826   
827   } else{
828     if(fOnOff[0]){
829       TString hname="hNtracklets";
830       TH1F* hNtracklets=new TH1F(hname.Data(),"Number of tracklets;ntracklets;Entries",5000,-0.5,4999.5);
831       hname="hNtracklets01";
832       TH1F* hNtracklets01=new TH1F(hname.Data(),"Number of tracklets |#eta|<1;ntracklets;Entries",5000,-0.5,4999.5);
833       hname="hNtracklets01AllEv";
834       TH1F* hNtracklets01AllEv=new TH1F(hname.Data(),"Number of tracklets |#eta|<1 - All events;ntracklets;Entries",5000,-0.5,4999.5);
835       hname="hMult";
836       TH1F* hMult=new TH1F(hname.Data(),"Multiplicity;multiplicity;Entries",10000,-0.5,9999.5);
837       hname="hMultFBit4";
838       TH1F* hMultFBit4=new TH1F(hname.Data(),"Multiplicity (global+tracklet) with filter bit 4;multiplicity;Entries",10000,-0.5,9999.5);
839       hname="hMultComb05";
840       TH1F* hMultC05=new TH1F(hname.Data(),"Multiplicity (global+tracklet) in |#eta|<0.5;multiplicity;Entries",10000,-0.5,9999.5);
841       hname="hMultComb08";
842       TH1F* hMultC08=new TH1F(hname.Data(),"Multiplicity (global+tracklet) in |#eta|<0.8;multiplicity;Entries",10000,-0.5,9999.5);
843
844       fOutputTrack->Add(hNtracklets);
845       fOutputTrack->Add(hNtracklets01);
846       fOutputTrack->Add(hNtracklets01AllEv);
847       fOutputTrack->Add(hMult);
848       fOutputTrack->Add(hMultFBit4);
849       fOutputTrack->Add(hMultC05);
850       fOutputTrack->Add(hMultC08);
851     }
852   }
853
854   //event selection (z vertex for the moment)
855   if(fOnOff[3]){
856     fOutputEvSelection=new TList();
857     fOutputEvSelection->SetOwner();
858     fOutputEvSelection->SetName(GetOutputSlot(7)->GetContainer()->GetName());
859     AliCounterCollection *evselection=new AliCounterCollection("evselection");
860     evselection->AddRubric("run",500000);
861     evselection->AddRubric("evnonsel","zvtx");
862     evselection->Init();
863
864     TH1F* hxvtx=new TH1F("hxvtx", "Distribution of x_{VTX};x_{VTX} [cm];Entries",800,-1,1);
865     TH1F* hyvtx=new TH1F("hyvtx", "Distribution of y_{VTX};y_{VTX} [cm];Entries",800,-1,1);
866     TH1F* hzvtx=new TH1F("hzvtx", "Distribution of z_{VTX};z_{VTX} [cm];Entries",800,-30,30);
867     TH1F* hxvtxSelEv=new TH1F("hxvtxSelEv", "Distribution of x_{VTX} Selected Ev;x_{VTX} [cm];Entries",800,-1,1);
868     TH1F* hyvtxSelEv=new TH1F("hyvtxSelEv", "Distribution of y_{VTX} Selected Ev;y_{VTX} [cm];Entries",800,-1,1);
869     TH1F* hzvtxSelEv=new TH1F("hzvtxSelEv", "Distribution of z_{VTX} Selected Ev;z_{VTX} [cm];Entries",800,-30,30);
870     TH1F* hWhichVert=new TH1F("hWhichVert","Vertex Type",4,-1.5,2.5);
871     hWhichVert->GetXaxis()->SetBinLabel(1,"Not found");
872     hWhichVert->GetXaxis()->SetBinLabel(2,"Track");
873     hWhichVert->GetXaxis()->SetBinLabel(3,"SPD-3D");
874     hWhichVert->GetXaxis()->SetBinLabel(4,"SPD-z");
875     TH1F* hWhichVertSelEv=new TH1F("hWhichVertSelEv","Vertex Type",4,-1.5,2.5);
876     hWhichVertSelEv->GetXaxis()->SetBinLabel(1,"Not found");
877     hWhichVertSelEv->GetXaxis()->SetBinLabel(2,"Track");
878     hWhichVertSelEv->GetXaxis()->SetBinLabel(3,"SPD-3D");
879     hWhichVertSelEv->GetXaxis()->SetBinLabel(4,"SPD-z");
880
881     TH2F* hTrigCent=new TH2F("hTrigCent","Centrality vs. Trigger types",24,-1.5,22.5,12,-10,110);
882     hTrigCent->GetXaxis()->SetBinLabel(1,"All");
883     hTrigCent->GetXaxis()->SetBinLabel(2,"kAny");
884     hTrigCent->GetXaxis()->SetBinLabel(3,"kMB");
885     hTrigCent->GetXaxis()->SetBinLabel(4,"kINT7");
886     hTrigCent->GetXaxis()->SetBinLabel(5,"kINT8");
887     hTrigCent->GetXaxis()->SetBinLabel(6,"kCINT5");
888     hTrigCent->GetXaxis()->SetBinLabel(7,"kCent");
889     hTrigCent->GetXaxis()->SetBinLabel(8,"kSemiCent");
890     hTrigCent->GetXaxis()->SetBinLabel(9,"kEMC1");
891     hTrigCent->GetXaxis()->SetBinLabel(10,"kEMC7");
892     hTrigCent->GetXaxis()->SetBinLabel(11,"kEMC8");
893     hTrigCent->GetXaxis()->SetBinLabel(12,"kEMCJET7");
894     hTrigCent->GetXaxis()->SetBinLabel(13,"kEMCGAMMA7");
895     hTrigCent->GetXaxis()->SetBinLabel(14,"kEMCJET8");
896     hTrigCent->GetXaxis()->SetBinLabel(15,"kEMCGAMMA8");
897     hTrigCent->GetXaxis()->SetBinLabel(16,"Muons");
898     hTrigCent->GetXaxis()->SetBinLabel(17,"PHOS");
899     hTrigCent->GetXaxis()->SetBinLabel(18,"TRD");
900     hTrigCent->GetXaxis()->SetBinLabel(19,"TRDHJT");
901     hTrigCent->GetXaxis()->SetBinLabel(20,"TRDHSE");
902     hTrigCent->GetXaxis()->SetBinLabel(21,"HighMult");
903     hTrigCent->GetXaxis()->SetBinLabel(22,"SPI7");
904     hTrigCent->GetXaxis()->SetBinLabel(23,"SPI8");
905     hTrigCent->GetXaxis()->SetBinLabel(24,"Others");
906
907     TH2F* hTrigMul=new TH2F("hTrigMul","Multiplicity vs. Trigger types",24,-1.5,22.5,1000,0.,10000.);
908     hTrigMul->GetXaxis()->SetBinLabel(1,"All");
909     hTrigMul->GetXaxis()->SetBinLabel(2,"kAny");
910     hTrigMul->GetXaxis()->SetBinLabel(3,"kMB");
911     hTrigMul->GetXaxis()->SetBinLabel(4,"kINT7");
912     hTrigMul->GetXaxis()->SetBinLabel(5,"kINT8");
913     hTrigMul->GetXaxis()->SetBinLabel(6,"kCINT5");
914     hTrigMul->GetXaxis()->SetBinLabel(7,"kCent");
915     hTrigMul->GetXaxis()->SetBinLabel(8,"kSemiCent");
916     hTrigMul->GetXaxis()->SetBinLabel(9,"kEMC1");
917     hTrigMul->GetXaxis()->SetBinLabel(10,"kEMC7");
918     hTrigMul->GetXaxis()->SetBinLabel(11,"kEMC8");
919     hTrigMul->GetXaxis()->SetBinLabel(12,"kEMCJET7");
920     hTrigMul->GetXaxis()->SetBinLabel(13,"kEMCGAMMA7");
921     hTrigMul->GetXaxis()->SetBinLabel(14,"kEMCJET8");
922     hTrigMul->GetXaxis()->SetBinLabel(15,"kEMCGAMMA8");
923     hTrigMul->GetXaxis()->SetBinLabel(16,"Muons");
924     hTrigMul->GetXaxis()->SetBinLabel(17,"PHOS");
925     hTrigMul->GetXaxis()->SetBinLabel(18,"TRD");
926     hTrigMul->GetXaxis()->SetBinLabel(19,"TRDHJT");
927     hTrigMul->GetXaxis()->SetBinLabel(20,"TRDHSE");
928     hTrigMul->GetXaxis()->SetBinLabel(21,"HighMult");
929     hTrigMul->GetXaxis()->SetBinLabel(22,"SPI7");
930     hTrigMul->GetXaxis()->SetBinLabel(23,"SPI8");
931     hTrigMul->GetXaxis()->SetBinLabel(24,"Others");
932
933     TH2F* hTrigCentSel=new TH2F("hTrigCentSel","Trigger types",24,-1.5,22.5,12,-10,110);
934     hTrigCentSel->GetXaxis()->SetBinLabel(1,"All");
935     hTrigCentSel->GetXaxis()->SetBinLabel(2,"kAny");
936     hTrigCentSel->GetXaxis()->SetBinLabel(3,"kMB");
937     hTrigCentSel->GetXaxis()->SetBinLabel(4,"kINT7");
938     hTrigCentSel->GetXaxis()->SetBinLabel(5,"kINT8");
939     hTrigCentSel->GetXaxis()->SetBinLabel(6,"kCINT5");
940     hTrigCentSel->GetXaxis()->SetBinLabel(7,"kCent");
941     hTrigCentSel->GetXaxis()->SetBinLabel(8,"kSemiCent");
942     hTrigCentSel->GetXaxis()->SetBinLabel(9,"kEMC1");
943     hTrigCentSel->GetXaxis()->SetBinLabel(10,"kEMC7");
944     hTrigCentSel->GetXaxis()->SetBinLabel(11,"kEMC8");
945     hTrigCentSel->GetXaxis()->SetBinLabel(12,"kEMCJET7");
946     hTrigCentSel->GetXaxis()->SetBinLabel(13,"kEMCGAMMA7");
947     hTrigCentSel->GetXaxis()->SetBinLabel(14,"kEMCJET8");
948     hTrigCentSel->GetXaxis()->SetBinLabel(15,"kEMCGAMMA8");
949     hTrigCentSel->GetXaxis()->SetBinLabel(16,"Muons");
950     hTrigCentSel->GetXaxis()->SetBinLabel(17,"PHOS");
951     hTrigCentSel->GetXaxis()->SetBinLabel(18,"TRD");
952     hTrigCentSel->GetXaxis()->SetBinLabel(19,"TRDHJT");
953     hTrigCentSel->GetXaxis()->SetBinLabel(20,"TRDHSE");
954     hTrigCentSel->GetXaxis()->SetBinLabel(21,"HighMult");
955     hTrigCentSel->GetXaxis()->SetBinLabel(22,"SPI7");
956     hTrigCentSel->GetXaxis()->SetBinLabel(23,"SPI8");
957     hTrigCentSel->GetXaxis()->SetBinLabel(24,"Others");
958
959     TH2F* hTrigMulSel=new TH2F("hTrigMulSel","Multiplicity after selection vs. Trigger types",24,-1.5,22.5,1000,0.,10000.);
960     hTrigMulSel->GetXaxis()->SetBinLabel(1,"All");
961     hTrigMulSel->GetXaxis()->SetBinLabel(2,"kAny");
962     hTrigMulSel->GetXaxis()->SetBinLabel(3,"kMB");
963     hTrigMulSel->GetXaxis()->SetBinLabel(4,"kINT7");
964     hTrigMulSel->GetXaxis()->SetBinLabel(5,"kINT8");
965     hTrigMulSel->GetXaxis()->SetBinLabel(6,"kCINT5");
966     hTrigMulSel->GetXaxis()->SetBinLabel(7,"kCent");
967     hTrigMulSel->GetXaxis()->SetBinLabel(8,"kSemiCent");
968     hTrigMulSel->GetXaxis()->SetBinLabel(9,"kEMC1");
969     hTrigMulSel->GetXaxis()->SetBinLabel(10,"kEMC7");
970     hTrigMulSel->GetXaxis()->SetBinLabel(11,"kEMC8");
971     hTrigMulSel->GetXaxis()->SetBinLabel(12,"kEMCJET7");
972     hTrigMulSel->GetXaxis()->SetBinLabel(13,"kEMCGAMMA7");
973     hTrigMulSel->GetXaxis()->SetBinLabel(14,"kEMCJET8");
974     hTrigMulSel->GetXaxis()->SetBinLabel(15,"kEMCGAMMA8");
975     hTrigMulSel->GetXaxis()->SetBinLabel(16,"Muons");
976     hTrigMulSel->GetXaxis()->SetBinLabel(17,"PHOS");
977     hTrigMulSel->GetXaxis()->SetBinLabel(18,"TRD");
978     hTrigMulSel->GetXaxis()->SetBinLabel(19,"TRDHJT");
979     hTrigMulSel->GetXaxis()->SetBinLabel(20,"TRDHSE");
980     hTrigMulSel->GetXaxis()->SetBinLabel(21,"HighMult");
981     hTrigMulSel->GetXaxis()->SetBinLabel(22,"SPI7");
982     hTrigMulSel->GetXaxis()->SetBinLabel(23,"SPI8");
983     hTrigMulSel->GetXaxis()->SetBinLabel(24,"Others");
984
985     AliCounterCollection *trigCounter=new AliCounterCollection("trigCounter");
986     trigCounter->AddRubric("run",500000);
987     trigCounter->AddRubric("triggerType","All/Any/MB/Cent/SemiCent/EMCAL/MUON/NoPhysSelMUON/NoPhysSelEvNot7/NoPhysSelCMUP1/NoPhysSelMB/NoPhysSelCent/NoPhysSelSemiCent/CINT7/INT8");
988     trigCounter->Init();
989
990     AliCounterCollection *trigCounter2=new AliCounterCollection("trigCounter2");
991     trigCounter2->AddRubric("run",500000);
992     trigCounter2->AddRubric("triggerType","All/Any/MB/CINT7/INT8/NoPhysSelEvNot7/NoPhysSelMB/HighMult/SPI7/SPI8/EMC1/EMC7/EMC8/EMCJET7/EMCJET8/EMCGAMMA/TRD/TRDHJT/TRDHSE");
993     trigCounter2->Init();
994
995     TH1F* hWhyEvRejected=new TH1F("hWhyEvRejected", "Why Event rejected",7,-1.5,5.5);
996
997     hWhyEvRejected->GetXaxis()->SetBinLabel(1,"N events");
998     hWhyEvRejected->GetXaxis()->SetBinLabel(2,"pileup");
999     hWhyEvRejected->GetXaxis()->SetBinLabel(3,"centrality");
1000     hWhyEvRejected->GetXaxis()->SetBinLabel(4,"Vertex not found");
1001     hWhyEvRejected->GetXaxis()->SetBinLabel(5,"trigger");
1002     hWhyEvRejected->GetXaxis()->SetBinLabel(6,"z vertex out of 10 cm");
1003     hWhyEvRejected->GetXaxis()->SetBinLabel(7,"physics sel");
1004
1005
1006     fOutputEvSelection->Add(evselection);
1007     fOutputEvSelection->Add(hxvtx);
1008     fOutputEvSelection->Add(hyvtx);
1009     fOutputEvSelection->Add(hzvtx);
1010     fOutputEvSelection->Add(hxvtxSelEv);
1011     fOutputEvSelection->Add(hyvtxSelEv);
1012     fOutputEvSelection->Add(hzvtxSelEv);
1013     fOutputEvSelection->Add(hWhichVert);
1014     fOutputEvSelection->Add(hWhichVertSelEv);
1015     fOutputEvSelection->Add(hTrigCent);
1016     fOutputEvSelection->Add(hTrigMul);
1017     fOutputEvSelection->Add(hTrigMulSel);
1018     fOutputEvSelection->Add(hTrigCentSel);
1019     fOutputEvSelection->Add(trigCounter);
1020     fOutputEvSelection->Add(trigCounter2);
1021     fOutputEvSelection->Add(hWhyEvRejected);
1022
1023   }
1024   if(fOnOff[4]){ // FLOW OBSERVABLES
1025     fOutputFlowObs=new TList();
1026     fOutputFlowObs->SetOwner();
1027     fOutputFlowObs->SetName(GetOutputSlot(8)->GetContainer()->GetName());
1028
1029     fFlowEvent = new AliFlowEvent(3000);
1030     fRFPcuts = new AliFlowTrackCuts("rfpCuts");
1031
1032     TH2F *hFEvents = new TH2F("hFlowEvents","FlowEvent Selection",7,0,7,7,-10,60);
1033     hFEvents->GetXaxis()->SetBinLabel(1,"REACHED");
1034     hFEvents->GetXaxis()->SetBinLabel(2,"TRIGGERED");
1035     hFEvents->GetXaxis()->SetBinLabel(3,"kMB");
1036     hFEvents->GetXaxis()->SetBinLabel(4,"kCent");
1037     hFEvents->GetXaxis()->SetBinLabel(5,"kSemiC");
1038     hFEvents->GetXaxis()->SetBinLabel(6,"Triggered + vtx cut");
1039     hFEvents->GetXaxis()->SetBinLabel(7,"UnexpectedBehaviour");
1040     fOutputFlowObs->Add(hFEvents);
1041
1042     TProfile2D *hQ[3];
1043     TH2F *hAngleQ[3];
1044     TH3F *hPhiEta[3];
1045     TString ref[3] = {"FB1","FB128","VZE"};
1046     Int_t etabin[3] = {40,40,20};
1047     Int_t etamax[3] = { 1, 1, 5};
1048     for(Int_t i=0; i<3; ++i) {
1049       hQ[i]= new TProfile2D( Form("h%s_Q",ref[i].Data()),
1050                              Form("Q_{2} components for %s",ref[i].Data()),
1051                              4,0,4,12,0,60,"s");
1052       hQ[i]->GetXaxis()->SetBinLabel(1,"Qx^{-}");
1053       hQ[i]->GetXaxis()->SetBinLabel(2,"Qy^{-}");
1054       hQ[i]->GetXaxis()->SetBinLabel(3,"Qx^{+}");
1055       hQ[i]->GetXaxis()->SetBinLabel(4,"Qy^{+}");
1056       hQ[i]->GetYaxis()->SetTitle("Centrality");
1057       fOutputFlowObs->Add(hQ[i]);
1058
1059       hAngleQ[i] = new TH2F( Form("h%s_AngleQ",ref[i].Data()),
1060                              Form("#Psi_{2} for %s",ref[i].Data()),
1061                              72,0,TMath::Pi(),12,0,60);
1062       hAngleQ[i]->GetXaxis()->SetTitle( Form("#Psi_{2}^{%s}",ref[i].Data()) );
1063       hAngleQ[i]->GetYaxis()->SetTitle("Centrality");
1064       fOutputFlowObs->Add(hAngleQ[i]);
1065
1066       hPhiEta[i] = new TH3F( Form("h%s_PhiEta",ref[i].Data()),
1067                              Form("Eta vs Phi for %s",ref[i].Data()),
1068                              144,0,TMath::TwoPi(),etabin[i],-1.0*etamax[i],+1.0*etamax[i],12,0,60);
1069       hPhiEta[i]->GetXaxis()->SetTitle("Phi");
1070       hPhiEta[i]->GetYaxis()->SetTitle("Eta");
1071       hPhiEta[i]->GetZaxis()->SetTitle("Centrality");
1072       fOutputFlowObs->Add(hPhiEta[i]);
1073
1074     }
1075     TH3F *hTPCVZE_AngleQ = new TH3F("hTPCVZE_AngleQ","#Psi_{2}^{VZERO} vs #Psi_{2}^{TPC}",   72,0,TMath::Pi(),72,0,TMath::Pi(),12,0,60);
1076     hTPCVZE_AngleQ->GetXaxis()->SetTitle("#Psi_{2}^{TPC}");
1077     hTPCVZE_AngleQ->GetYaxis()->SetTitle("#Psi_{2}^{VZE}");
1078     hTPCVZE_AngleQ->GetZaxis()->SetTitle("Centrality");
1079     fOutputFlowObs->Add(hTPCVZE_AngleQ);
1080
1081     TH2F *hCentVsMultRPS = new TH2F("hCentVsMultRPS", " Centrality Vs. Multiplicity RPs",5000, 0, 5000.,12,0,60 );
1082     hCentVsMultRPS->GetXaxis()->SetTitle("Multiplicity RPs");
1083     hCentVsMultRPS->GetYaxis()->SetTitle("Centrality");
1084     fOutputFlowObs->Add(hCentVsMultRPS);
1085   }
1086
1087   // Post the data
1088   PostData(1,fNEntries);
1089
1090   if(fOnOff[1]) PostData(2,fOutputPID);
1091   if(fOnOff[0]) PostData(3,fOutputTrack);
1092   PostData(4,fCuts);
1093   if(fOnOff[2]) PostData(5,fOutputCounters);
1094   if(fOnOff[3]) PostData(7,fOutputEvSelection);
1095   if(fOnOff[4]) PostData(8,fOutputFlowObs);
1096
1097   if(!fOnOff[0] && !fOnOff[1] && !fOnOff[2]) AliError("Nothing will be filled!");
1098 }
1099
1100 //___________________________________________________________________________
1101 void AliAnalysisTaskSEHFQA::UserExec(Option_t */*option*/)
1102 {
1103   // Execute analysis for current event
1104
1105   AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
1106   if(fDebug>2) printf("Analysing decay %d\n",fDecayChannel);
1107   // Post the data already here
1108   PostData(1,fNEntries);
1109   if(fOnOff[1]) PostData(2,fOutputPID);
1110   if(fOnOff[0]) PostData(3,fOutputTrack);
1111   PostData(4,fCuts);
1112   if(fOnOff[2]) {
1113     PostData(5,fOutputCounters);
1114     if(fCuts->GetUseCentrality()) PostData(6,fOutputCheckCentrality);
1115   }
1116
1117   TClonesArray *arrayProng =0;
1118   Int_t pdg=0;
1119   Int_t *pdgdaughters=0x0;
1120
1121   if(!aod && AODEvent() && IsStandardAOD()) { 
1122     // In case there is an AOD handler writing a standard AOD, use the AOD 
1123     // event in memory rather than the input (ESD) event.    
1124     aod = dynamic_cast<AliAODEvent*> (AODEvent());
1125     // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
1126     // have to taken from the AOD event hold by the AliAODExtension
1127     AliAODHandler* aodHandler = (AliAODHandler*) 
1128       ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
1129     if(aodHandler->GetExtensions()) {
1130       
1131       AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
1132       AliAODEvent *aodFromExt = ext->GetAOD();
1133    
1134    
1135       
1136       switch(fDecayChannel){
1137       case 0:
1138         arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
1139         pdg=411;
1140         if(fReadMC){
1141           pdgdaughters =new Int_t[3];
1142           pdgdaughters[0]=211;//pi
1143           pdgdaughters[1]=321;//K
1144           pdgdaughters[2]=211;//pi
1145         }
1146         break; 
1147       case 1:
1148         arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("D0toKpi");
1149         pdg=421;
1150         if(fReadMC){
1151           pdgdaughters =new Int_t[2];
1152           pdgdaughters[0]=211;//pi 
1153           pdgdaughters[1]=321;//K
1154         }
1155         break; 
1156       case 2:
1157         arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Dstar");
1158         pdg=413;
1159         if(fReadMC){
1160           pdgdaughters =new Int_t[3];
1161           pdgdaughters[1]=211;//pi
1162           pdgdaughters[0]=321;//K
1163           pdgdaughters[2]=211;//pi (soft?)
1164         }
1165         break; 
1166       case 3:
1167         arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
1168         pdg=431;
1169         if(fReadMC){
1170           pdgdaughters =new Int_t[3];
1171           pdgdaughters[0]=321;//K
1172           pdgdaughters[1]=321;//K
1173           pdgdaughters[2]=211;//pi
1174         }
1175         break; 
1176       case 4:
1177         arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm4Prong");
1178         pdg=421;
1179         if(fReadMC){
1180           pdgdaughters =new Int_t[4];
1181           pdgdaughters[0]=321;
1182           pdgdaughters[1]=211;
1183           pdgdaughters[2]=211;
1184           pdgdaughters[3]=211;
1185         }
1186         break; 
1187       case 5:
1188         arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
1189         pdg=4122;
1190         if(fReadMC){
1191           pdgdaughters =new Int_t[3];
1192           pdgdaughters[0]=2212;//p
1193           pdgdaughters[1]=321;//K
1194           pdgdaughters[2]=211;//pi
1195         }
1196         break; 
1197       case kLambdactoV0:
1198         arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject("CascadesHF");
1199         pdg=4122;
1200         if(fReadMC){
1201           pdgdaughters =new Int_t[3];
1202           pdgdaughters[0]=2212;//p
1203           pdgdaughters[1]=211;//pi
1204           pdgdaughters[2]=211;//pi
1205         }
1206         break; 
1207       }
1208     }
1209   } else if(aod) {
1210     switch(fDecayChannel){
1211     case 0:
1212       arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
1213       pdg=411;
1214       if(fReadMC){
1215         pdgdaughters =new Int_t[3];
1216         pdgdaughters[0]=211;//pi
1217         pdgdaughters[1]=321;//K
1218         pdgdaughters[2]=211;//pi
1219       }
1220       break; 
1221     case 1:
1222       arrayProng=(TClonesArray*)aod->GetList()->FindObject("D0toKpi");
1223       pdg=421;
1224       if(fReadMC){
1225         pdgdaughters =new Int_t[2];
1226         pdgdaughters[0]=211;//pi 
1227         pdgdaughters[1]=321;//K
1228       }
1229       break; 
1230     case 2:
1231       arrayProng=(TClonesArray*)aod->GetList()->FindObject("Dstar");
1232       pdg=413;
1233       if(fReadMC){
1234         pdgdaughters =new Int_t[3];
1235         pdgdaughters[1]=211;//pi
1236         pdgdaughters[0]=321;//K
1237         pdgdaughters[2]=211;//pi (soft?)
1238       }
1239       break; 
1240     case 3:
1241       arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
1242       pdg=431;
1243       if(fReadMC){
1244         pdgdaughters =new Int_t[3];
1245         pdgdaughters[0]=321;//K
1246         pdgdaughters[1]=321;//K
1247         pdgdaughters[2]=211;//pi
1248       }
1249       break; 
1250     case 4:
1251       arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm4Prong");
1252       pdg=421;
1253       if(fReadMC){
1254         pdgdaughters =new Int_t[4];
1255         pdgdaughters[0]=321;
1256         pdgdaughters[1]=211;
1257         pdgdaughters[2]=211;
1258         pdgdaughters[3]=211;
1259       }
1260       break; 
1261     case 5:
1262       arrayProng=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
1263       pdg=4122;
1264       if(fReadMC){
1265         pdgdaughters =new Int_t[3];
1266         pdgdaughters[0]=2212;//p
1267         pdgdaughters[1]=321;//K
1268         pdgdaughters[2]=211;//pi
1269       }
1270       break; 
1271       case kLambdactoV0:
1272         arrayProng=(TClonesArray*)aod->GetList()->FindObject("CascadesHF");
1273         pdg=4122;
1274         if(fReadMC){
1275           pdgdaughters =new Int_t[3];
1276           pdgdaughters[0]=2212;//p
1277           pdgdaughters[1]=211;//pi
1278           pdgdaughters[2]=211;//pi
1279         }
1280         break; 
1281     }
1282   }
1283   Bool_t isSimpleMode=fSimpleMode;
1284   if(!arrayProng) {
1285     AliInfo("Branch not found! The output will contain only track related histograms\n");
1286     isSimpleMode=kTRUE;
1287     fNEntries->Fill(2);
1288   }
1289   
1290   TClonesArray *mcArray = 0;
1291   AliAODMCHeader *mcHeader = 0;
1292
1293   if(!aod) {
1294     delete [] pdgdaughters;
1295     return;
1296   }
1297
1298   //check if MC
1299   if(fReadMC) {
1300     // load MC particles
1301     mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1302     if(!mcArray) {
1303       printf("AliAnalysisTaskSEHFQA::UserExec: MC particles branch not found!\n");
1304       delete [] pdgdaughters;
1305       return;
1306     }
1307     
1308     // load MC header
1309     mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1310     if(!mcHeader) {
1311       printf("AliAnalysisTaskSEHFQA::UserExec: MC header branch not found!\n");
1312       delete [] pdgdaughters;
1313       return;
1314     }
1315   }
1316
1317   
1318   UInt_t evSelMask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
1319   Double_t centrality=fCuts->GetCentrality(aod);
1320   AliAODHeader * header = dynamic_cast<AliAODHeader*>(aod->GetHeader());
1321   if(!header) AliFatal("Not a standard AOD");
1322
1323   Double_t multiplicity=header->GetRefMultiplicity();
1324   Int_t runNumber = aod->GetRunNumber();
1325   TString trigClass=aod->GetFiredTriggerClasses();
1326   Int_t nAODtracks=aod->GetNumberOfTracks();
1327   Int_t nSelTracksTPCOnly=0;
1328   Int_t nSelTracksTPCITS=0;
1329   Int_t nSelTracksTPCITS1SPD=0;
1330   Int_t ntracksFBit4=0;
1331
1332   AliTRDTriggerAnalysis trdSelection;
1333   trdSelection.CalcTriggers(aod);
1334
1335   if(fReadMC) {
1336     if(aod->GetTriggerMask()==0 && 
1337        (runNumber>=195344 && runNumber<=195677)){
1338       AliDebug(3,"Event rejected because of null trigger mask");
1339       delete [] pdgdaughters;
1340       return;
1341     }
1342   }
1343
1344   for (Int_t k=0;k<nAODtracks;k++){
1345     AliAODTrack* track=aod->GetTrack(k);
1346     if(track->GetID()<0) continue;
1347     Int_t nclsTot=0,nclsSPD=0;
1348     for(Int_t l=0;l<6;l++) {
1349       if(TESTBIT(track->GetITSClusterMap(),l)) {
1350         nclsTot++; if(l<2) nclsSPD++;
1351       }
1352     }
1353     UShort_t nTPCClus=track->GetTPCClusterMap().CountBits();
1354     if(TMath::Abs(track->Eta())<0.8 && nTPCClus>=70 && track->GetStatus()&AliESDtrack::kTPCrefit){
1355       if(track->TestFilterBit(1))  nSelTracksTPCOnly++;
1356       if(track->GetStatus()&AliESDtrack::kITSrefit){
1357         nSelTracksTPCITS++;
1358         if(nclsSPD>0) nSelTracksTPCITS1SPD++;      
1359       }
1360     }
1361     if(track->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)){
1362       ntracksFBit4++;
1363     }
1364   }
1365
1366   if(fOnOff[4]) {
1367     FillFlowObs(aod);
1368     PostData(8,fOutputFlowObs);
1369   }
1370   if(fOnOff[3]){
1371     TH2F* hTrigC=(TH2F*)fOutputEvSelection->FindObject("hTrigCent");
1372     TH2F* hTrigM=(TH2F*)fOutputEvSelection->FindObject("hTrigMul");
1373     AliCounterCollection* trigCount=(AliCounterCollection*)fOutputEvSelection->FindObject("trigCounter");
1374     AliCounterCollection* trigCount2=(AliCounterCollection*)fOutputEvSelection->FindObject("trigCounter2");
1375
1376     hTrigC->Fill(-1.,centrality);
1377     hTrigM->Fill(-1.,multiplicity);
1378     trigCount->Count(Form("triggerType:All/Run:%d",runNumber));
1379     trigCount2->Count(Form("triggerType:All/Run:%d",runNumber));
1380     if(evSelMask==0){
1381       if(aod->GetEventType()!=7 || trigClass.Contains("BEAMB")){
1382         trigCount->Count(Form("triggerType:NoPhysSelEvNot7/Run:%d",runNumber));
1383         trigCount2->Count(Form("triggerType:NoPhysSelEvNot7/Run:%d",runNumber));
1384       }else if(trigClass.Contains("CMUP1")){
1385         trigCount->Count(Form("triggerType:NoPhysSelCMUP1/Run:%d",runNumber));
1386       }else if(trigClass.Contains("MUON")){
1387         trigCount->Count(Form("triggerType:NoPhysSelMUON/Run:%d",runNumber));
1388       }else if(trigClass.Contains("CPBI2_B1-B") || trigClass.Contains(" CPBI2WU_B1-B")){
1389         trigCount->Count(Form("triggerType:NoPhysSelMB/Run:%d",runNumber));
1390         trigCount2->Count(Form("triggerType:NoPhysSelMB/Run:%d",runNumber));
1391       }else if(trigClass.Contains("CCENT") || trigClass.Contains("CVHN")){
1392         trigCount->Count(Form("triggerType:NoPhysSelCent/Run:%d",runNumber));
1393       }else if(trigClass.Contains("CSEMI") || trigClass.Contains("CVLN")){
1394         trigCount->Count(Form("triggerType:NoPhysSelSemiCent/Run:%d",runNumber));
1395       }
1396     }
1397     if(evSelMask & AliVEvent::kAny){
1398       hTrigC->Fill(0.,centrality);
1399       hTrigM->Fill(0.,multiplicity);
1400       trigCount->Count(Form("triggerType:Any/Run:%d",runNumber));
1401       trigCount2->Count(Form("triggerType:Any/Run:%d",runNumber));
1402     }  
1403     if(evSelMask & AliVEvent::kMB){
1404       hTrigC->Fill(1.,centrality);
1405       hTrigM->Fill(1.,multiplicity);
1406       trigCount->Count(Form("triggerType:MB/Run:%d",runNumber));
1407       trigCount2->Count(Form("triggerType:MB/Run:%d",runNumber));
1408     }
1409     if(evSelMask & AliVEvent::kINT7){ 
1410       hTrigC->Fill(2.,centrality);
1411       hTrigM->Fill(2.,multiplicity);
1412       trigCount->Count(Form("triggerType:CINT7/Run:%d",runNumber));
1413       trigCount2->Count(Form("triggerType:CINT7/Run:%d",runNumber));
1414     }
1415     if(evSelMask & AliVEvent::kINT8){ 
1416       hTrigC->Fill(3.,centrality);
1417       hTrigM->Fill(3.,multiplicity);
1418       trigCount->Count(Form("triggerType:INT8/Run:%d",runNumber));   
1419       trigCount2->Count(Form("triggerType:INT8/Run:%d",runNumber));      
1420     }
1421     if(evSelMask & AliVEvent::kCINT5){ 
1422       hTrigC->Fill(4.,centrality);
1423       hTrigM->Fill(4.,multiplicity);
1424     }
1425     if(evSelMask & AliVEvent::kCentral){
1426       hTrigC->Fill(5.,centrality);
1427       hTrigM->Fill(5.,multiplicity);
1428       trigCount->Count(Form("triggerType:Cent/Run:%d",runNumber));
1429     }
1430     if(evSelMask & AliVEvent::kSemiCentral){ 
1431       hTrigC->Fill(6.,centrality);
1432       hTrigM->Fill(6.,multiplicity);
1433       trigCount->Count(Form("triggerType:SemiCent/Run:%d",runNumber));
1434     }
1435
1436     if(evSelMask & AliVEvent::kEMC1){
1437       hTrigC->Fill(7.,centrality);
1438       hTrigM->Fill(7.,multiplicity);
1439       trigCount->Count(Form("triggerType:EMCAL/Run:%d",runNumber));
1440       trigCount2->Count(Form("triggerType:EMC1/Run:%d",runNumber));
1441     }
1442     if((evSelMask & AliVEvent::kEMC7) && trigClass.Contains("CEMC7")){
1443       hTrigC->Fill(8.,centrality);
1444       hTrigM->Fill(8.,multiplicity);
1445       trigCount->Count(Form("triggerType:EMCAL/Run:%d",runNumber));
1446       trigCount2->Count(Form("triggerType:EMC7/Run:%d",runNumber));
1447     }
1448     if((evSelMask & AliVEvent::kEMC8) && trigClass.Contains("CEMC8")){
1449       hTrigC->Fill(9.,centrality);
1450       hTrigM->Fill(9.,multiplicity);
1451       trigCount->Count(Form("triggerType:EMCAL/Run:%d",runNumber));
1452       trigCount2->Count(Form("triggerType:EMC8/Run:%d",runNumber));
1453     }
1454     if(evSelMask & AliVEvent::kEMCEJE){
1455        trigCount->Count(Form("triggerType:EMCAL/Run:%d",runNumber));
1456        if(trigClass.Contains("CEMC7EJE")) {
1457          trigCount2->Count(Form("triggerType:EMCJET7/Run:%d",runNumber));
1458          hTrigC->Fill(10.,centrality);
1459          hTrigM->Fill(10.,multiplicity);
1460
1461        }
1462        else if(trigClass.Contains("CEMC8EJE")) {
1463          trigCount2->Count(Form("triggerType:EMCJET8/Run:%d",runNumber));
1464          hTrigC->Fill(12.,centrality);
1465          hTrigM->Fill(12.,multiplicity);
1466        }
1467     }
1468     if(evSelMask & AliVEvent::kEMCEGA){
1469       if(trigClass.Contains("CEMC7EGA")) {
1470         hTrigC->Fill(11.,centrality);
1471         hTrigM->Fill(11.,multiplicity);
1472       } else if (trigClass.Contains("CEMC8EGA")){
1473         hTrigC->Fill(13.,centrality);
1474         hTrigM->Fill(13.,multiplicity);
1475
1476       }
1477       trigCount->Count(Form("triggerType:EMCAL/Run:%d",runNumber));
1478       trigCount2->Count(Form("triggerType:EMCGAMMA/Run:%d",runNumber));
1479     }
1480     if(evSelMask & (((AliVEvent::kCMUS5 | AliVEvent::kMUSH7) | (AliVEvent::kMUL7 | AliVEvent::kMUU7)) |  (AliVEvent::kMUS7 | AliVEvent::kMUON))){
1481       hTrigC->Fill(14.,centrality);
1482       hTrigM->Fill(14.,multiplicity);
1483       trigCount->Count(Form("triggerType:MUON/Run:%d",runNumber));
1484     }
1485     if(evSelMask & (AliVEvent::kPHI1 | AliVEvent::kPHI7)){ 
1486       hTrigC->Fill(15.,centrality);
1487       hTrigM->Fill(15.,multiplicity);
1488     }
1489     if(evSelMask & (AliVEvent::kTRD)){
1490       hTrigC->Fill(16.,centrality);
1491       hTrigM->Fill(16.,multiplicity);
1492       trigCount2->Count(Form("triggerType:TRD/Run:%d",runNumber));
1493     }
1494     if((evSelMask & AliVEvent::kTRD) && trdSelection.IsFired(AliTRDTriggerAnalysis::kHJT)){
1495       hTrigC->Fill(17.,centrality);
1496       hTrigM->Fill(17.,multiplicity);
1497       trigCount2->Count(Form("triggerType:TRDHJT/Run:%d",runNumber));
1498     }
1499     if((evSelMask & AliVEvent::kTRD) && trdSelection.IsFired(AliTRDTriggerAnalysis::kHSE)){
1500       hTrigC->Fill(18.,centrality);
1501       hTrigM->Fill(18.,multiplicity);
1502       trigCount2->Count(Form("triggerType:TRDHSE/Run:%d",runNumber));
1503     }
1504     if(evSelMask & (AliVEvent::kHighMult)){
1505       hTrigC->Fill(19.,centrality);
1506       hTrigM->Fill(19.,multiplicity);
1507       trigCount2->Count(Form("triggerType:HighMult/Run:%d",runNumber));
1508     }
1509     if(evSelMask & AliVEvent::kSPI7){
1510       if(trigClass.Contains("CSPI7")) {
1511         hTrigC->Fill(20.,centrality);
1512         hTrigM->Fill(20.,multiplicity);
1513         trigCount2->Count(Form("triggerType:SPI7/Run:%d",runNumber));
1514       }
1515     }
1516     if(evSelMask & AliVEvent::kSPI){
1517       if(trigClass.Contains("CSPI8")) {
1518         hTrigC->Fill(21.,centrality);
1519         hTrigM->Fill(21.,multiplicity);
1520         trigCount2->Count(Form("triggerType:SPI8/Run:%d",runNumber));
1521       }
1522     }
1523     if(evSelMask & (AliVEvent::kDG5 | AliVEvent::kZED)){
1524       hTrigC->Fill(22.,centrality);
1525       hTrigM->Fill(22.,multiplicity);
1526     }
1527   }
1528   
1529
1530   // fix for temporary bug in ESDfilter 
1531   // the AODs with null vertex pointer didn't pass the PhysSel
1532   if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) {
1533     delete [] pdgdaughters;
1534     return;
1535   }
1536
1537   // count event
1538   fNEntries->Fill(0);
1539
1540   //count events with good vertex
1541   // AOD primary vertex
1542   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
1543
1544   Double_t pos[3],cov[6];
1545   vtx1->GetXYZ(pos);
1546   vtx1->GetCovarianceMatrix(cov);
1547   const AliESDVertex vESD(pos,cov,100.,100);
1548
1549   TString primTitle = vtx1->GetTitle();
1550   if(primTitle.Contains("VertexerTracks") && vtx1->GetNContributors()>0) fNEntries->Fill(4);
1551
1552   // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
1553   //TString trigclass=aod->GetFiredTriggerClasses();
1554   //if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fNEntries->Fill(5); //tmp
1555
1556
1557
1558
1559   Bool_t evSelbyCentrality=kTRUE,evSelected=kTRUE,evSelByVertex=kTRUE,evselByPileup=kTRUE,evSelByPS=kTRUE;
1560
1561   TH1F* hWhyEvRejected=0x0;
1562   if(fOnOff[3]){
1563     hWhyEvRejected=(TH1F*)fOutputEvSelection->FindObject("hWhyEvRejected");
1564      if(hWhyEvRejected) hWhyEvRejected->Fill(-1); 
1565   }
1566
1567   //select event
1568   if(!fCuts->IsEventSelected(aod)) {
1569     evSelected=kFALSE;
1570     if(fCuts->IsEventRejectedDueToPileup()) {
1571       if(hWhyEvRejected) hWhyEvRejected->Fill(0); 
1572       evselByPileup=kFALSE;
1573     }// rejected for pileup
1574     if(fCuts->IsEventRejectedDueToCentrality()) {
1575       if(hWhyEvRejected) hWhyEvRejected->Fill(1); 
1576       evSelbyCentrality=kFALSE; //rejected by centrality
1577     }
1578     if(fCuts->IsEventRejectedDueToNotRecoVertex() ||
1579        fCuts->IsEventRejectedDueToVertexContributors()){ 
1580       evSelByVertex=kFALSE; 
1581       if(hWhyEvRejected) hWhyEvRejected->Fill(2);
1582     }
1583     if(fCuts->IsEventRejectedDueToTrigger()){
1584       if(hWhyEvRejected) hWhyEvRejected->Fill(3);
1585     }
1586     if(fCuts->IsEventRejectedDueToZVertexOutsideFiducialRegion()) {
1587       evSelByVertex=kFALSE; 
1588       if(fOnOff[3]) ((AliCounterCollection*)fOutputEvSelection->FindObject("evselection"))->Count(Form("evnonsel:zvtx/Run:%d",runNumber)); 
1589       if(hWhyEvRejected) hWhyEvRejected->Fill(4);
1590     }
1591     if(fCuts->IsEventRejectedDuePhysicsSelection()) { 
1592       evSelByPS=kFALSE;
1593       if(hWhyEvRejected) hWhyEvRejected->Fill(5); 
1594     }
1595   }
1596   if(evSelected && fOnOff[3]){
1597     TH2F* hTrigS=(TH2F*)fOutputEvSelection->FindObject("hTrigCentSel");
1598     TH2F* hTrigSM=(TH2F*)fOutputEvSelection->FindObject("hTrigMulSel");
1599     hTrigS->Fill(-1.,centrality);
1600     hTrigSM->Fill(-1.,multiplicity);
1601     if(evSelMask & AliVEvent::kAny) {
1602       hTrigS->Fill(0.,centrality);
1603       hTrigSM->Fill(0.,multiplicity);}
1604     if(evSelMask & AliVEvent::kMB) {
1605       hTrigS->Fill(1.,centrality);
1606       hTrigSM->Fill(1.,multiplicity);}
1607     if(evSelMask & AliVEvent::kINT7){
1608       hTrigS->Fill(2.,centrality);
1609       hTrigSM->Fill(2.,multiplicity);}
1610     if(evSelMask & AliVEvent::kINT8){
1611       hTrigS->Fill(3.,centrality);
1612       hTrigSM->Fill(3.,multiplicity);}
1613     if(evSelMask & AliVEvent::kCINT5){ 
1614       hTrigS->Fill(4.,centrality);
1615       hTrigSM->Fill(4.,multiplicity);}
1616     if(evSelMask & AliVEvent::kCentral){
1617       hTrigS->Fill(5.,centrality);
1618       hTrigSM->Fill(5.,multiplicity);}
1619     if(evSelMask & AliVEvent::kSemiCentral){
1620       hTrigS->Fill(6.,centrality);
1621       hTrigSM->Fill(6.,multiplicity);}
1622     if(evSelMask & AliVEvent::kEMC1){
1623       hTrigS->Fill(7.,centrality);
1624       hTrigSM->Fill(7.,multiplicity);
1625     }
1626     if((evSelMask & AliVEvent::kEMC7) && trigClass.Contains("CEMC7")){
1627       hTrigS->Fill(8.,centrality);
1628       hTrigSM->Fill(8.,multiplicity);
1629     }
1630     if((evSelMask & AliVEvent::kEMC8) && trigClass.Contains("CEMC8")){
1631       hTrigS->Fill(9.,centrality);
1632       hTrigSM->Fill(9.,multiplicity);
1633     }
1634       if((evSelMask & AliVEvent::kEMCEJE) && trigClass.Contains("CEMC7EJE")){
1635       hTrigS->Fill(10.,centrality);
1636       hTrigSM->Fill(10.,multiplicity);
1637     }
1638     if((evSelMask & AliVEvent::kEMCEGA) && trigClass.Contains("CEMC7EGA")){
1639       hTrigS->Fill(11.,centrality);
1640       hTrigSM->Fill(11.,multiplicity);
1641     }
1642     if((evSelMask & AliVEvent::kEMCEJE) && trigClass.Contains("CEMC8EJE")){
1643       hTrigS->Fill(12.,centrality);
1644       hTrigSM->Fill(12.,multiplicity);
1645     }
1646     if((evSelMask & AliVEvent::kEMCEGA) && trigClass.Contains("CEMC8EGA")){
1647       hTrigS->Fill(13.,centrality);
1648       hTrigSM->Fill(13.,multiplicity);
1649     }
1650     if(evSelMask & (((AliVEvent::kCMUS5 | AliVEvent::kMUSH7) | (AliVEvent::kMUL7 | AliVEvent::kMUU7)) |  (AliVEvent::kMUS7 | AliVEvent::kMUON))){
1651       hTrigS->Fill(14.,centrality);
1652       hTrigSM->Fill(14.,multiplicity);}
1653     if(evSelMask & (AliVEvent::kPHI1 | AliVEvent::kPHI7)){
1654       hTrigS->Fill(15.,centrality);
1655       hTrigSM->Fill(15.,multiplicity);}
1656     if(evSelMask & (AliVEvent::kTRD)){
1657       hTrigS->Fill(16.,centrality);
1658       hTrigSM->Fill(16.,multiplicity);
1659     }
1660     if((evSelMask & AliVEvent::kTRD) && trdSelection.IsFired(AliTRDTriggerAnalysis::kHJT)){
1661       hTrigS->Fill(17.,centrality);
1662       hTrigSM->Fill(17.,multiplicity);
1663     }
1664     if((evSelMask & AliVEvent::kTRD) && trdSelection.IsFired(AliTRDTriggerAnalysis::kHSE)){
1665       hTrigS->Fill(18.,centrality);
1666       hTrigSM->Fill(18.,multiplicity);
1667     }
1668     if(evSelMask & (AliVEvent::kHighMult)){
1669       hTrigS->Fill(19.,centrality);
1670       hTrigSM->Fill(19.,multiplicity);}
1671     if(evSelMask & AliVEvent::kSPI7){
1672       if(trigClass.Contains("CSPI7")) {
1673         hTrigS->Fill(20.,centrality);
1674         hTrigSM->Fill(20.,multiplicity);
1675       }
1676     }
1677     if(evSelMask & AliVEvent::kSPI){
1678       if(trigClass.Contains("CSPI8")) {
1679         hTrigS->Fill(21.,centrality);
1680         hTrigSM->Fill(21.,multiplicity);
1681       }
1682     }
1683     if(evSelMask & (AliVEvent::kDG5 | AliVEvent::kZED)){
1684       hTrigS->Fill(22.,centrality);
1685       hTrigSM->Fill(22.,multiplicity);}
1686   }
1687   
1688   if(evSelected || (!evSelbyCentrality && evSelByVertex && evselByPileup && evSelByPS)){ //events selected or not selected because of centrality
1689     if(fOnOff[2] && fCuts->GetUseCentrality()){
1690
1691       Float_t stdCentf=fCuts->GetCentrality(aod);
1692       Int_t stdCent = (Int_t)(stdCentf+0.5);
1693       Float_t secondCentf =fCuts->GetCentrality(aod,fEstimator);
1694       Int_t secondCent = (Int_t)(secondCentf+0.5);
1695       Int_t mincent=stdCent-stdCent%10;
1696       Float_t stdSignal = 0.;
1697       Float_t secondSignal = 0.;
1698       AliAODVZERO *vzeroAOD = (AliAODVZERO*)aod->GetVZEROData();
1699       AliAODZDC *zdcAOD = (AliAODZDC*)aod->GetZDCData();
1700       const Double_t *towerZNASignal = zdcAOD->GetZNATowerEnergy();
1701       switch(fCuts->GetUseCentrality())
1702       {
1703          case AliRDHFCuts::kCentV0M:
1704             stdSignal = vzeroAOD->GetMTotV0A() +  vzeroAOD->GetMTotV0C();
1705             break;
1706          case AliRDHFCuts::kCentV0A:
1707             stdSignal = vzeroAOD->GetMTotV0A();
1708             break;
1709          case AliRDHFCuts::kCentZNA:
1710             stdSignal = towerZNASignal[0];
1711             break;
1712          default:
1713             stdSignal = 0.;
1714             break;
1715       }
1716       switch(fEstimator)
1717       {
1718          case AliRDHFCuts::kCentV0M:
1719             secondSignal = vzeroAOD->GetMTotV0A() +  vzeroAOD->GetMTotV0C();
1720             break;
1721          case AliRDHFCuts::kCentV0A:
1722             secondSignal = vzeroAOD->GetMTotV0A();
1723             break;
1724          case AliRDHFCuts::kCentZNA:
1725             secondSignal = towerZNASignal[0];
1726             break;
1727          default:
1728             secondSignal = 0.;
1729             break;
1730       }
1731       //AliCentrality *aodcent = aod->GetCentrality();
1732       // Float_t spdCentf = aodcent->GetCentralityPercentile("CL1");
1733       if(stdCentf==-1) {
1734          mincent=-10; 
1735          stdCent=-1;
1736       }
1737       if(mincent==100)mincent--;
1738       ((AliCounterCollection*)fOutputCounters->FindObject("stdEstimator"))->Count(Form("centralityclass:%d_%d/Run:%d",mincent,mincent+10,runNumber));
1739
1740       mincent=secondCent-secondCent%10;
1741       if(secondCentf==-1) {
1742         mincent=-10;
1743         secondCent=-1;
1744       }
1745       if(mincent==100)mincent--;
1746       ((AliCounterCollection*)fOutputCounters->FindObject("secondEstimator"))->Count(Form("centralityclass:%d_%d/Run:%d",mincent,mincent+10,runNumber));
1747
1748       AliAODHeader * header = dynamic_cast<AliAODHeader*>(aod->GetHeader());
1749       if(!header) AliFatal("Not a standard AOD");
1750
1751
1752       if(stdCent<fCuts->GetMinCentrality() || stdCent>fCuts->GetMaxCentrality()){
1753         ((TH1F*)fOutputCheckCentrality->FindObject("hNtrackletsOut"))->Fill(aod->GetTracklets()->GetNumberOfTracklets());
1754         ((TH1F*)fOutputCheckCentrality->FindObject("hMultOut"))->Fill(header->GetRefMultiplicity());
1755       }else{
1756         ((TH1F*)fOutputCheckCentrality->FindObject("hNtrackletsIn"))->Fill(aod->GetTracklets()->GetNumberOfTracklets());
1757         ((TH1F*)fOutputCheckCentrality->FindObject("hMultIn"))->Fill(header->GetRefMultiplicity());
1758       }
1759       ((TH2F*)fOutputCheckCentrality->FindObject("hMultvsPercentile"))->Fill(header->GetRefMultiplicity(),stdCentf);
1760       ((TH2F*)fOutputCheckCentrality->FindObject("hntrklvsPercentile"))->Fill(aod->GetTracklets()->GetNumberOfTracklets(),stdCentf);
1761       ((TH2F*)fOutputCheckCentrality->FindObject("hntrklvsPercentile01"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.),stdCentf);
1762       ((TH2F*)fOutputCheckCentrality->FindObject("hnTPCTracksvsPercentile"))->Fill(nSelTracksTPCOnly,stdCentf);
1763       ((TH2F*)fOutputCheckCentrality->FindObject("hnTPCITSTracksvsPercentile"))->Fill(nSelTracksTPCITS,stdCentf);
1764       ((TH2F*)fOutputCheckCentrality->FindObject("hnTPCITS1SPDTracksvsPercentile"))->Fill(nSelTracksTPCITS1SPD,stdCentf);
1765       ((TH2F*)fOutputCheckCentrality->FindObject("hStdEstimSignalPercentile"))->Fill(stdSignal,stdCentf);
1766       ((TH1F*)fOutputCheckCentrality->FindObject("hStdEstimSignal"))->Fill(stdSignal);
1767       ((TH2F*)fOutputCheckCentrality->FindObject("hStdEstimSignalNtrackletsIn"))->Fill(stdSignal,aod->GetTracklets()->GetNumberOfTracklets());
1768       ((TH2F*)fOutputCheckCentrality->FindObject("hStdPercentileSecondPercentile"))->Fill(stdCentf,secondCentf);
1769       ((TH2F*)fOutputCheckCentrality->FindObject("hStdSignalSecondSignal"))->Fill(stdSignal,secondSignal);
1770
1771       PostData(6,fOutputCheckCentrality);
1772
1773     } else{
1774       if(fOnOff[0]){
1775         ((TH1F*)fOutputTrack->FindObject("hNtracklets"))->Fill(aod->GetTracklets()->GetNumberOfTracklets());
1776         ((TH1F*)fOutputTrack->FindObject("hNtracklets01"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.));
1777         ((TH1F*)fOutputTrack->FindObject("hMult"))->Fill(header->GetRefMultiplicity());
1778         ((TH1F*)fOutputTrack->FindObject("hMultFBit4"))->Fill(ntracksFBit4);
1779         ((TH1F*)fOutputTrack->FindObject("hMultComb05"))->Fill(header->GetRefMultiplicityComb05());
1780         ((TH1F*)fOutputTrack->FindObject("hMultComb08"))->Fill(header->GetRefMultiplicityComb08());
1781       }
1782     }
1783   }
1784
1785   if(evSelected || (!evSelbyCentrality && evSelByVertex && evselByPileup && evSelByPS) || (!evSelByVertex && evselByPileup && evSelByPS)){ //events selected or not selected because of centrality
1786     if(fOnOff[2] && fCuts->GetUseCentrality()){
1787       ((TH2F*)fOutputCheckCentrality->FindObject("hntrklvsPercentile01AllEv"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.),fCuts->GetCentrality(aod));
1788     }else{
1789       if(fOnOff[0]){
1790         ((TH1F*)fOutputTrack->FindObject("hNtracklets01AllEv"))->Fill(AliVertexingHFUtils::GetNumberOfTrackletsInEtaRange(aod,-1.,1.));
1791       }
1792     }
1793   }
1794
1795   if(fOnOff[3]){
1796     const AliVVertex *vertex = aod->GetPrimaryVertex();
1797     Double_t xvtx=vertex->GetX();
1798     Double_t yvtx=vertex->GetY();
1799     Double_t zvtx=vertex->GetZ();
1800     Int_t vtxTyp=0;
1801     if(vertex->GetNContributors()<=0) vtxTyp=-1;
1802     TString title=vertex->GetTitle();
1803     if(title.Contains("Z")) vtxTyp=2;
1804     if(title.Contains("3D")) vtxTyp=1;    
1805     ((TH1F*)fOutputEvSelection->FindObject("hxvtx"))->Fill(xvtx);
1806     ((TH1F*)fOutputEvSelection->FindObject("hyvtx"))->Fill(yvtx);
1807     ((TH1F*)fOutputEvSelection->FindObject("hzvtx"))->Fill(zvtx);
1808     ((TH1F*)fOutputEvSelection->FindObject("hWhichVert"))->Fill(vtxTyp);
1809     if(evSelected){
1810       ((TH1F*)fOutputEvSelection->FindObject("hxvtxSelEv"))->Fill(xvtx);
1811       ((TH1F*)fOutputEvSelection->FindObject("hyvtxSelEv"))->Fill(yvtx);
1812       ((TH1F*)fOutputEvSelection->FindObject("hzvtxSelEv"))->Fill(zvtx);
1813       ((TH1F*)fOutputEvSelection->FindObject("hWhichVertSelEv"))->Fill(vtxTyp);
1814     }
1815   }
1816
1817   if(!evSelected) {
1818     delete [] pdgdaughters;
1819     return; //discard all events not selected (vtx and/or centrality)
1820   }
1821
1822
1823   AliAODPidHF* pidHF=fCuts->GetPidHF();
1824   if(!pidHF) {
1825     delete [] pdgdaughters;
1826     return;
1827   }
1828   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1829   AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
1830   AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
1831
1832   //AliPIDResponse* respF=pidHF->GetPidResponse();
1833   AliTPCPIDResponse* tpcres=new AliTPCPIDResponse();
1834   Bool_t oldPID=pidHF->GetOldPid();
1835   if(oldPID){ 
1836     Double_t alephParameters[5];
1837     pidHF->GetTPCBetheBlochParams(alephParameters);
1838     tpcres->SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
1839   }
1840
1841
1842   Int_t ntracks=0;
1843   Int_t isGoodTrack=0, isFakeTrack=0, isSelTrack=0;
1844
1845   if(aod) ntracks=aod->GetNumberOfTracks();
1846
1847   if(fOnOff[0] || fOnOff[1]){
1848     //loop on tracks in the event
1849     for (Int_t k=0;k<ntracks;k++){
1850       AliAODTrack* track=aod->GetTrack(k);
1851
1852       // Track selection cuts
1853       if(track->GetID()<0) continue;
1854       Double_t d0z0[2],covd0z0[3];
1855       if(!track->PropagateToDCA(vtx1,aod->GetMagneticField(),99999.,d0z0,covd0z0)) continue;
1856       if(track->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)){
1857         ((TH1F*)fOutputTrack->FindObject("hd0TracksFilterBit4"))->Fill(d0z0[0]);
1858       }
1859       ULong_t trStatus=track->GetStatus();
1860       if(trStatus&AliESDtrack::kITSrefit){
1861         if(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)){
1862           ((TH1F*)fOutputTrack->FindObject("hd0TracksSPDany"))->Fill(d0z0[0]);
1863           if(track->HasPointOnITSLayer(0)){
1864             ((TH1F*)fOutputTrack->FindObject("hd0TracksSPDin"))->Fill(d0z0[0]);
1865           }
1866         }
1867       }
1868
1869       Bool_t selTrack=kTRUE;
1870        if (!((trStatus & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
1871           !((trStatus & AliVTrack::kITSrefit) == AliVTrack::kITSrefit)){
1872         selTrack=kFALSE;
1873       }
1874       if(!track->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)){ // BIT(4) standard cuts with very loose DCA
1875          selTrack=kFALSE;
1876       }
1877       if(TMath::Abs(track->Eta())>0.9){
1878          selTrack=kFALSE;
1879       }
1880       Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
1881       Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
1882       if (track->GetTPCNclsF()>0) {
1883         ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
1884       }
1885       
1886       if(selTrack){
1887         if(track->HasPointOnITSLayer(0) || track->HasPointOnITSLayer(1)){
1888           ((TH1F*)fOutputTrack->FindObject("hd0TracksTPCITSSPDany"))->Fill(d0z0[0]);
1889         }
1890       }
1891       
1892       AliAODPid *pid = track->GetDetPid();
1893       if(!pid && fDebug>1) cout<<"No AliAODPid found"<<endl;
1894
1895       if(pid && fOnOff[1]){
1896         Double_t times[AliPID::kSPECIES];
1897         pid->GetIntegratedTimes(times);
1898     
1899         Double_t tofRes[AliPID::kSPECIES];
1900         pid->GetTOFpidResolution(tofRes);
1901
1902         //check TOF
1903         TH1F* htmpfl=((TH1F*)fOutputPID->FindObject("hTOFflags"));
1904         htmpfl->Fill(0.);
1905         if (trStatus&AliESDtrack::kTPCout) htmpfl->Fill(1.);
1906         if (trStatus&AliESDtrack::kTOFout) htmpfl->Fill(2.);
1907         if (trStatus&AliESDtrack::kTIME) htmpfl->Fill(3.);
1908         if (trStatus&AliESDtrack::kTOFpid) htmpfl->Fill(4.);
1909         if (trStatus&AliESDtrack::kTOFmismatch) htmpfl->Fill(5.);
1910
1911         Bool_t isTOFok=kFALSE;
1912         if(pidResp){
1913           Double_t prob[AliPID::kSPECIES];
1914           if(pidResp->ComputeTOFProbability(track,AliPID::kSPECIES,prob)==AliPIDResponse::kDetPidOk){
1915             isTOFok=kTRUE;
1916             htmpfl->Fill(6.);
1917           }
1918         }
1919       
1920         if(selTrack && isTOFok){
1921           Double_t tofTime=pid->GetTOFsignal();
1922           AliTOFHeader* tofH=(AliTOFHeader*)aod->GetTOFHeader();
1923           if (tofH && (TMath::Abs(tofRes[0]) <= 1.E-16) ) { // new AOD
1924             // with new AOD we need to retrieve startTime, subtract it and retrieve correctly TOF PID resolutions  *PA*
1925             AliTOFPIDResponse tofResp=pidResp->GetTOFResponse();
1926             Double_t startTime = tofResp.GetStartTime(track->P());
1927             Float_t startTimeRes = tofResp.GetStartTimeRes(track->P());  
1928             Int_t startTimeMask = tofResp.GetStartTimeMask(track->P());  
1929             ((TH1F*)fOutputPID->FindObject("hTOFstartTimeDistrib"))->Fill(startTime);
1930             ((TH1F*)fOutputPID->FindObject("hTOFstartTimeMask"))->Fill(startTimeMask);
1931             ((TH1F*)fOutputPID->FindObject("hTOFstartTimeRes"))->Fill(startTimeRes);
1932             tofTime-=startTime;
1933             for (Int_t type=0;type<AliPID::kSPECIES;type++) tofRes[type]=tofResp.GetExpectedSigma(track->P(),times[type],AliPID::ParticleMassZ(type)); 
1934           }
1935           ((TH1F*)fOutputPID->FindObject("hTOFtime"))->Fill(times[AliPID::kProton]);
1936           ((TH2F*)fOutputPID->FindObject("hTOFtimeKaonHyptime"))->Fill(track->P(),tofTime-times[3]); //3 is kaon
1937           ((TH1F*)fOutputPID->FindObject("hTOFsig"))->Fill(tofTime);
1938           if (pid->GetTOFsignal()< 0) ((TH1F*)fOutputPID->FindObject("hTOFsig"))->Fill(-1);
1939
1940           Double_t nsigma[3]={-10,-10,-10};
1941           nsigma[0]=pidResp->NumberOfSigmasTOF(track,AliPID::kPion);
1942           nsigma[1]=pidResp->NumberOfSigmasTOF(track,AliPID::kKaon);
1943           nsigma[2]=pidResp->NumberOfSigmasTOF(track,AliPID::kProton);
1944
1945           ((TH2F*)fOutputPID->FindObject("hTOFsigmaKSigPid"))->Fill(track->P(),nsigma[1]);
1946           ((TH2F*)fOutputPID->FindObject("hTOFsigmaPionSigPid"))->Fill(track->P(),nsigma[0]);
1947           ((TH2F*)fOutputPID->FindObject("hTOFsigmaProtonSigPid"))->Fill(track->P(),nsigma[2]);
1948           if(fReadMC){
1949             Int_t label=track->GetLabel();
1950             if(label<=0) continue;
1951             AliMCParticle* mcpart=(AliMCParticle*)mcArray->At(label);
1952             if(mcpart){
1953               Int_t abspdgcode=TMath::Abs(mcpart->PdgCode());
1954               if(abspdgcode==211) ((TH2F*)fOutputPID->FindObject("hTOFsigmaMCPionSigPid"))->Fill(track->P(),nsigma[0]);
1955               if(abspdgcode==321) ((TH2F*)fOutputPID->FindObject("hTOFsigmaMCKSigPid"))->Fill(track->P(),nsigma[1]);
1956               if(abspdgcode==2212) ((TH2F*)fOutputPID->FindObject("hTOFsigmaMCProtonSigPid"))->Fill(track->P(),nsigma[2]);
1957
1958             }
1959           }
1960
1961           for (Int_t iS=2; iS<5; iS++){ //we plot TOF Pid resolution for 3-sigma identified particles
1962             if ( TMath::Abs(nsigma[iS-2])<3.){
1963               switch (iS) {
1964               case AliPID::kPion:
1965                 ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigPion"))->Fill(tofRes[iS]);
1966                 break;
1967               case AliPID::kKaon:
1968                 ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigKaon"))->Fill(tofRes[iS]);
1969                 break;
1970               case AliPID::kProton:
1971                 ((TH1F*)fOutputPID->FindObject("hTOFsigPid3sigProton"))->Fill(tofRes[iS]);
1972                 break;
1973               default:
1974                 break;
1975               }
1976             }
1977           }
1978         }//if TOF status
1979         //}
1980       
1981         if(pidHF && pidHF->CheckStatus(track,"TPC") && selTrack){ 
1982
1983           Double_t TPCp=pid->GetTPCmomentum();
1984           Double_t TPCsignal=pid->GetTPCsignal();
1985           UShort_t TPCsignalN=pid->GetTPCsignalN();
1986           ((TH1F*)fOutputPID->FindObject("hTPCsig"))->Fill(TPCsignal);
1987           ((TH1F*)fOutputPID->FindObject("hTPCsigvsp"))->Fill(TPCp,TPCsignal);
1988           //if (pidHF->IsKaonRaw(track, "TOF"))
1989           Double_t nsigma[3]={-10,-10,-10};
1990           pidHF->GetnSigmaTPC(track,(Int_t)AliPID::kPion,nsigma[0]);     
1991           pidHF->GetnSigmaTPC(track,(Int_t)AliPID::kKaon,nsigma[1]);     
1992           pidHF->GetnSigmaTPC(track,(Int_t)AliPID::kProton,nsigma[2]);   
1993
1994           ((TH2F*)fOutputPID->FindObject("hTPCsigmaK"))->Fill(TPCp,nsigma[1]);
1995           
1996           ((TH2F*)fOutputPID->FindObject("hTPCsigmaPion"))->Fill(TPCp,nsigma[0]);         
1997           ((TH2F*)fOutputPID->FindObject("hTPCsigmaProton"))->Fill(TPCp,nsigma[2]);
1998           
1999           if(fReadMC){
2000             Int_t label=track->GetLabel();
2001             if(label<=0) continue;
2002             AliMCParticle* mcpart=(AliMCParticle*)mcArray->At(label);
2003             if(mcpart){
2004               Int_t abspdgcode=TMath::Abs(mcpart->PdgCode());
2005               if(abspdgcode==211) ((TH2F*)fOutputPID->FindObject("hTPCsigmaMCPion"))->Fill(track->P(),nsigma[0]);
2006               if(abspdgcode==321) ((TH2F*)fOutputPID->FindObject("hTPCsigmaMCK"))->Fill(track->P(),nsigma[1]);
2007               if(abspdgcode==2212) ((TH2F*)fOutputPID->FindObject("hTPCsigmaMCProton"))->Fill(track->P(),nsigma[2]);
2008
2009             }
2010
2011           }
2012           if(fFillDistrTrackEffChecks && track->GetStatus()&AliESDtrack::kITSrefit && track->GetStatus()&AliESDtrack::kTPCrefit){
2013             ((TH2F*)fOutputPID->FindObject("hTPCsigNvsPtAllTracks"))->Fill(track->Pt(),(Float_t)TPCsignalN);
2014             ((TH2F*)fOutputPID->FindObject("hTPCsigNvsPhiAllTracks"))->Fill(track->Phi(),(Float_t)TPCsignalN);
2015             ((TH2F*)fOutputPID->FindObject("hTPCsigNvsEtaAllTracks"))->Fill(track->Eta(),(Float_t)TPCsignalN);
2016           }
2017           
2018         }//if TPC status
2019       } //end PID histograms
2020       
2021       Int_t nclsTot=0,nclsSPD=0;
2022
2023       //check clusters of the tracks
2024       if(fOnOff[0]){
2025
2026         ((TH1F*)fOutputTrack->FindObject("hnLayerITS"))->Fill(-1);
2027         for(Int_t l=0;l<6;l++) {
2028           if(TESTBIT(track->GetITSClusterMap(),l)) {
2029             ((TH1F*)fOutputTrack->FindObject("hnLayerITS"))->Fill(l);
2030             nclsTot++; if(l<2) nclsSPD++;
2031           }
2032         }
2033         ((TH1F*)fOutputTrack->FindObject("hnClsITS"))->Fill(nclsTot);
2034         ((TH1F*)fOutputTrack->FindObject("hnClsSPD"))->Fill(nclsSPD);
2035         
2036         if(fFillDistrTrackEffChecks && track->GetStatus()&AliESDtrack::kITSrefit && track->GetStatus()&AliESDtrack::kTPCrefit){
2037
2038           ((TH1F*)fOutputTrack->FindObject("hPtAllTracks"))->Fill(track->Pt());
2039           ((TH1F*)fOutputTrack->FindObject("hPhiAllTracks"))->Fill(track->Phi());
2040           ((TH1F*)fOutputTrack->FindObject("hEtaAllTracks"))->Fill(track->Eta());
2041           ((TH2F*)fOutputTrack->FindObject("hEtavsPhiAllTracks"))->Fill(track->Phi(),track->Eta());
2042           ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPtAllTracks"))->Fill(track->Pt(),track->GetTPCNcls());
2043           ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPhiAllTracks"))->Fill(track->Phi(),track->GetTPCNcls());
2044           ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsEtaAllTracks"))->Fill(track->Eta(),track->GetTPCNcls());
2045
2046           ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPtAllTracks"))->Fill(track->Pt(),nCrossedRowsTPC);
2047           ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPhiAllTracks"))->Fill(track->Phi(),nCrossedRowsTPC);
2048           ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsEtaAllTracks"))->Fill(track->Eta(),nCrossedRowsTPC);
2049
2050           ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPtAllTracks"))->Fill(track->Pt(),ratioCrossedRowsOverFindableClustersTPC);
2051           ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPhiAllTracks"))->Fill(track->Phi(),ratioCrossedRowsOverFindableClustersTPC);
2052           ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsEtaAllTracks"))->Fill(track->Eta(),ratioCrossedRowsOverFindableClustersTPC);
2053
2054           if(!(track->HasPointOnITSLayer(0)) && !(track->HasPointOnITSLayer(1))){ //no SPD points
2055             ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(0);
2056           } 
2057           if(track->HasPointOnITSLayer(0) && !(track->HasPointOnITSLayer(1))){ //kOnlyFirst
2058             ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(1);
2059           } 
2060           if(!(track->HasPointOnITSLayer(0)) && track->HasPointOnITSLayer(1)){ //kOnlySecond
2061             ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(2);
2062           }
2063           if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)){ //kBoth
2064             ((TH1I*)fOutputTrack->FindObject("hSPDclsAllTracks"))->Fill(3);
2065           } 
2066           ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPtAllTracks"))->Fill(track->Pt(), nclsTot);
2067           ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPhiAllTracks"))->Fill(track->Phi(), nclsTot);
2068           ((TH2F*)fOutputTrack->FindObject("hNITSclsvsEtaAllTracks"))->Fill(track->Eta(), nclsTot);
2069
2070         }
2071         
2072         if(track->Pt()>0.3 &&
2073            TMath::Abs(track->Eta())<0.8 &&
2074            track->GetStatus()&AliESDtrack::kITSrefit &&
2075            track->GetStatus()&AliESDtrack::kTPCrefit &&
2076            nclsSPD>0){
2077           ((TH1F*)fOutputTrack->FindObject("hnClsITSselTr"))->Fill(nclsTot);
2078         }
2079         if(!(track->GetStatus()&AliESDtrack::kTPCin) && track->GetStatus()&AliESDtrack::kITSrefit && !(track->GetStatus()&AliESDtrack::kITSpureSA)){//tracks retrieved in the ITS and not reconstructed in the TPC
2080           ((TH1F*)fOutputTrack->FindObject("hnClsITS-SA"))->Fill(nclsTot);
2081           ((TH1F*)fOutputTrack->FindObject("hnLayerITS"))->Fill(-1);
2082           for(Int_t l=0;l<6;l++) {
2083             if(TESTBIT(track->GetITSClusterMap(),l)) {
2084               ((TH1F*)fOutputTrack->FindObject("hnLayerITSsa"))->Fill(l);
2085             }
2086           }
2087         }
2088         Int_t label=0;
2089         if(fReadMC){
2090           label=track->GetLabel();
2091           if (label<0)fNEntries->Fill(8);
2092           else fNEntries->Fill(9); 
2093         }
2094
2095
2096         if (track->Pt()>0.3 &&
2097             track->GetStatus()&AliESDtrack::kTPCrefit &&
2098             track->GetStatus()&AliESDtrack::kITSrefit &&
2099             /*nclsTot>3 &&*/
2100             nclsSPD>0) {//count good tracks
2101
2102         
2103           if(fReadMC && label<0) {
2104             ((TH1F*)fOutputTrack->FindObject("hptFakeTr"))->Fill(track->Pt());
2105             isFakeTrack++;      
2106           } else {
2107             ((TH1F*)fOutputTrack->FindObject("hptGoodTr"))->Fill(track->Pt());
2108             isGoodTrack++;
2109           }
2110
2111           if(fCuts->IsDaughterSelected(track,&vESD,fCuts->GetTrackCuts())){
2112             isSelTrack++;
2113           }//select tracks for our analyses
2114
2115         }
2116       } //fill track histos
2117     } //end loop on tracks
2118
2119     //fill once per event
2120     if(fOnOff[0]){
2121       if (fReadMC) ((TH1F*)fOutputTrack->FindObject("hdistrFakeTr"))->Fill(isFakeTrack);
2122       ((TH1F*)fOutputTrack->FindObject("hdistrGoodTr"))->Fill(isGoodTrack);
2123       ((TH1F*)fOutputTrack->FindObject("hdistrSelTr"))->Fill(isSelTrack);
2124     }
2125
2126     if(!isSimpleMode){
2127       // loop over candidates
2128       Int_t nCand = arrayProng->GetEntriesFast();
2129       Int_t ndaugh=3;
2130       if(fDecayChannel==AliAnalysisTaskSEHFQA::kD0toKpi) ndaugh=2;
2131       if(fDecayChannel==AliAnalysisTaskSEHFQA::kD0toKpipipi) ndaugh=4;
2132
2133       for (Int_t iCand = 0; iCand < nCand; iCand++) {
2134         AliAODRecoDecayHF *d = (AliAODRecoDecayHF*)arrayProng->UncheckedAt(iCand);
2135         if(fUseSelectionBit && d->GetSelectionMap()) {
2136           if(fDecayChannel==AliAnalysisTaskSEHFQA::kD0toKpi && !d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts)) continue; //skip the D0 from Dstar
2137           if(fDecayChannel==AliAnalysisTaskSEHFQA::kDplustoKpipi && !d->HasSelectionBit(AliRDHFCuts::kDplusCuts)) continue; //skip the 3 prong !D+
2138         }
2139
2140         if(fReadMC){ 
2141
2142           Int_t labD = -1;
2143           if (fDecayChannel==AliAnalysisTaskSEHFQA::kLambdactoV0 && (dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0()) {
2144
2145             Int_t pdgDgLctoV0bachelor[2]={2212,310};
2146             Int_t pdgDgV0toDaughters[2]={211,211};
2147             Int_t mcLabelK0S = (dynamic_cast<AliAODRecoCascadeHF*>(d))->MatchToMC(pdg,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE); // Lc->K0S+p and cc
2148             pdgDgLctoV0bachelor[1]=3122, pdgDgLctoV0bachelor[0]=211;
2149             pdgDgV0toDaughters[0]=2212,  pdgDgV0toDaughters[1]=211;
2150             Int_t mcLabelLambda = (dynamic_cast<AliAODRecoCascadeHF*>(d))->MatchToMC(pdg,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,mcArray,kTRUE); // Lc->Lambda+pi and cc
2151             if (mcLabelK0S!=-1 || mcLabelLambda!=-1) AliInfo(Form("mcLabelK0S=%d - mcLabelLambda=%d",mcLabelK0S,mcLabelLambda));
2152
2153             if (mcLabelK0S!=-1 && mcLabelLambda!=-1)
2154               AliInfo("Strange: current Lc->V0+bachelor candidate has two MC different labels!");
2155             else if (mcLabelK0S>-1 && mcLabelLambda==-1)
2156               labD = mcLabelK0S;
2157             else if (mcLabelLambda>-1 && mcLabelK0S==-1)
2158               labD = mcLabelLambda;
2159           }
2160           else
2161             labD = d->MatchToMC(pdg,mcArray,ndaugh,pdgdaughters);
2162
2163           if(labD>=0){
2164             AliAODMCParticle *partD = (AliAODMCParticle*)mcArray->At(labD);
2165             Int_t label=partD->GetMother();
2166             AliAODMCParticle *mot = (AliAODMCParticle*)mcArray->At(label);
2167             while(label>=0){//get first mother
2168               mot = (AliAODMCParticle*)mcArray->At(label);
2169               label=mot->GetMother();
2170             }
2171             if(mot){
2172               Int_t pdgMotCode = mot->GetPdgCode();
2173         
2174               if(TMath::Abs(pdgMotCode)==4) fNEntries->Fill(6); //from primary charm
2175               if(TMath::Abs(pdgMotCode)==5) fNEntries->Fill(7); //from beauty
2176             }
2177           }
2178         }//end MC
2179         fNEntries->Fill(5); //count the candidates (data and MC)
2180
2181         for(Int_t id=0;id<ndaugh;id++){
2182           //other histograms to be filled when the cut object is given
2183           AliAODTrack* track=0;
2184
2185           if (fDecayChannel==AliAnalysisTaskSEHFQA::kLambdactoV0 && (dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0()) {
2186             if (id==0)
2187               track=(AliAODTrack*)(dynamic_cast<AliAODRecoCascadeHF*>(d))->GetBachelor();
2188             else if (id==1)
2189               track=(AliAODTrack*)(dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0PositiveTrack();
2190             else if (id==2)
2191               track=(AliAODTrack*)(dynamic_cast<AliAODRecoCascadeHF*>(d))->Getv0NegativeTrack();
2192           }
2193           else 
2194             track=(AliAODTrack*)d->GetDaughter(id);
2195
2196           //track quality
2197
2198           if (fCuts->IsInFiducialAcceptance(d->Pt(),d->Y(pdg)) && fCuts->IsSelected(d,AliRDHFCuts::kTracks,aod)) {
2199             
2200             Int_t label=0;
2201             if(fReadMC)label=track->GetLabel();
2202             if(fOnOff[0]){
2203               
2204               if(fReadMC && label<0) {
2205                 isFakeTrack++;
2206                 ((TH1F*)fOutputTrack->FindObject("hptFakeTrFromDaugh"))->Fill(track->Pt());
2207            
2208                 ((TH1F*)fOutputTrack->FindObject("hd0f"))->Fill(d->Getd0Prong(id));
2209               } else {
2210                 ((TH1F*)fOutputTrack->FindObject("hptGoodTrFromDaugh"))->Fill(track->Pt());
2211                 ((TH1F*)fOutputTrack->FindObject("hd0dau"))->Fill(d->Getd0Prong(id));
2212                 Double_t phidaughter = d->PhiProng(id);
2213                 if(phidaughter<0) phidaughter=2.0*TMath::Pi()+phidaughter;
2214                 ((TH2F*)fOutputTrack->FindObject("hd0dauphi"))->Fill(phidaughter, d->Getd0Prong(id));
2215                 Double_t d0rphiz[2],covd0[3];
2216                 Bool_t isDCA=track->PropagateToDCA(aod->GetPrimaryVertex(),aod->GetMagneticField(),9999.,d0rphiz,covd0);
2217                 if(isDCA){
2218                   ((TH1F*)fOutputTrack->FindObject("hd0zdau"))->Fill(d0rphiz[1]);
2219                   ((TH2F*)fOutputTrack->FindObject("hd0zdauphi"))->Fill(phidaughter,d0rphiz[1]);
2220                 }
2221               }
2222             }
2223
2224
2225             if(fFillDistrTrackEffChecks){
2226               Int_t nITScls = 0;
2227               Double_t nTPCCrossedRows = track->GetTPCClusterInfo(2,1);
2228               Double_t ratioCrossedRowsOverFcls = 1.0;
2229               if(track->GetTPCNclsF()>0){
2230                 ratioCrossedRowsOverFcls = (nTPCCrossedRows)/(track->GetTPCNclsF());
2231               }
2232               for(Int_t l=0;l<6;l++) {
2233                 if(TESTBIT(track->GetITSClusterMap(),l)) {
2234                   nITScls++;
2235                 }
2236               }
2237
2238               ((TH1F*)fOutputTrack->FindObject("hPtDaughters"))->Fill(track->Pt());
2239               ((TH1F*)fOutputTrack->FindObject("hPhiDaughters"))->Fill(track->Phi());
2240               ((TH1F*)fOutputTrack->FindObject("hEtaDaughters"))->Fill(track->Eta());
2241               ((TH2F*)fOutputTrack->FindObject("hEtavsPhiDaughters"))->Fill(track->Phi(),track->Eta());
2242
2243               ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPtDaughters"))->Fill(track->Pt(),track->GetTPCNcls());
2244               ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsPhiDaughters"))->Fill(track->Phi(),track->GetTPCNcls());
2245               ((TH2F*)fOutputTrack->FindObject("hNTPCclsvsEtaDaughters"))->Fill(track->Eta(),track->GetTPCNcls());
2246
2247               ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPtDaughters"))->Fill(track->Pt(),nTPCCrossedRows);
2248               ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsPhiDaughters"))->Fill(track->Phi(),nTPCCrossedRows);
2249               ((TH2F*)fOutputTrack->FindObject("hNTPCCrossedRowsvsEtaDaughters"))->Fill(track->Eta(),nTPCCrossedRows);
2250
2251               ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPtDaughters"))->Fill(track->Pt(),ratioCrossedRowsOverFcls);
2252               ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsPhiDaughters"))->Fill(track->Phi(),ratioCrossedRowsOverFcls);
2253               ((TH2F*)fOutputTrack->FindObject("hRatioCRowsOverFclsvsEtaDaughters"))->Fill(track->Eta(),ratioCrossedRowsOverFcls);
2254
2255               ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPtDaughters"))->Fill(track->Pt(), nITScls);
2256               ((TH2F*)fOutputTrack->FindObject("hNITSclsvsPhiDaughters"))->Fill(track->Phi(), nITScls);
2257               ((TH2F*)fOutputTrack->FindObject("hNITSclsvsEtaDaughters"))->Fill(track->Eta(), nITScls);
2258               if(!(track->HasPointOnITSLayer(0)) && !(track->HasPointOnITSLayer(1))){ //no SPD points
2259                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(0);
2260               } 
2261               if(track->HasPointOnITSLayer(0) && !(track->HasPointOnITSLayer(1))){ //kOnlyFirst
2262                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(1);
2263               } 
2264               if(!(track->HasPointOnITSLayer(0)) && track->HasPointOnITSLayer(1)){ //kOnlySecond
2265                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(2);
2266               }
2267               if(track->HasPointOnITSLayer(0) && track->HasPointOnITSLayer(1)){ //kBoth
2268                 ((TH1I*)fOutputTrack->FindObject("hSPDclsDaughters"))->Fill(3);
2269               }
2270
2271
2272               if(fOnOff[1]){
2273                 AliAODPid *pid = track->GetDetPid();
2274                 if(pid){
2275                   if(pidHF && pidHF->CheckStatus(track,"TPC")){
2276                     ((TH2F*)fOutputPID->FindObject("hTPCsigNvsPtDaughters"))->Fill(track->Pt(),pid->GetTPCsignalN());
2277                     ((TH2F*)fOutputPID->FindObject("hTPCsigNvsPhiDaughters"))->Fill(track->Phi(),pid->GetTPCsignalN());
2278                     ((TH2F*)fOutputPID->FindObject("hTPCsigNvsEtaDaughters"))->Fill(track->Eta(),pid->GetTPCsignalN());
2279                   }
2280                 }
2281               }
2282             }
2283
2284
2285             if (fCuts->IsSelected(d,AliRDHFCuts::kAll,aod) && fOnOff[1]){
2286               fNEntries->Fill(3); //candidates passing analysis cuts         
2287
2288             AliAODPid *pid = track->GetDetPid();
2289               if(pid){
2290                 Double_t times[5];
2291                 pid->GetIntegratedTimes(times);
2292                 if(pidHF && pidHF->CheckStatus(track,"TOF")){
2293                   Double_t tofTime=pid->GetTOFsignal();
2294                   AliTOFHeader* tofH=(AliTOFHeader*)aod->GetTOFHeader();
2295                   Double_t tofRes[AliPID::kSPECIES];
2296                   pid->GetTOFpidResolution(tofRes);
2297                   if (tofH && (TMath::Abs(tofRes[0]) <= 1.E-16) ) { // new AOD
2298                     AliTOFPIDResponse tofResp=pidHF->GetPidResponse()->GetTOFResponse();
2299                     Double_t startTime=tofResp.GetStartTime(track->P());
2300                     tofTime-=startTime;
2301                   }
2302                   ((TH2F*)fOutputPID->FindObject("hTOFtimeKaonHyptimeAC"))->Fill(track->P(),tofTime-times[AliPID::kKaon]);
2303                 }
2304                 if(pidHF && pidHF->CheckStatus(track,"TPC")) ((TH2F*)fOutputPID->FindObject("hTPCsigvspAC"))->Fill(pid->GetTPCmomentum(),pid->GetTPCsignal());
2305               }
2306               
2307             } //end analysis cuts
2308           } //end acceptance and track cuts
2309         } //end loop on tracks in the candidate
2310       } //end loop on candidates
2311       
2312     }
2313   } //end if on pid or track histograms
2314
2315   delete tpcres;
2316   delete [] pdgdaughters;
2317   PostData(1,fNEntries);
2318   if(fOnOff[1]) PostData(2,fOutputPID);
2319   if(fOnOff[0]) PostData(3,fOutputTrack);
2320   PostData(4,fCuts);
2321   if(fOnOff[2]) PostData(5,fOutputCounters);
2322   //Post data 6 done in case of centrality on   
2323
2324 }
2325
2326 //____________________________________________________________________________
2327 void AliAnalysisTaskSEHFQA::FillFlowObs(AliAODEvent *aod){
2328   //fills the flow observables
2329   Double_t cc;
2330   cc = fCuts->GetCentrality(aod);
2331   ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(0., cc);
2332
2333   UInt_t mask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
2334   UInt_t trigger=AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
2335   if(mask & trigger) {
2336     ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(1.,cc); // fired
2337     if (mask & AliVEvent::kMB) ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(2.,cc);
2338     if (mask & AliVEvent::kCentral) ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(3.,cc);
2339     if (mask & AliVEvent::kSemiCentral) ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(4.,cc);
2340     Bool_t rejected=false;
2341     if(cc<0 || cc>60) rejected=true;
2342     const AliVVertex *vertex = aod->GetPrimaryVertex();
2343     Double_t zvtx=vertex->GetZ();
2344     if(TMath::Abs(zvtx)>fCuts->GetMaxVtxZ()) rejected=true;
2345     if(rejected) return; //not interesting for flow QA
2346   } else {
2347     return;
2348   }
2349
2350   // event accepted
2351   ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(5.,cc);
2352   fRFPcuts->SetParamType(AliFlowTrackCuts::kGlobal);
2353   fRFPcuts->SetPtRange(0.2,5.);
2354   fRFPcuts->SetEtaRange(-0.8,0.8);
2355   fRFPcuts->SetMinNClustersTPC(70);
2356   fRFPcuts->SetMinChi2PerClusterTPC(0.2);
2357   fRFPcuts->SetMaxChi2PerClusterTPC(4.0);
2358   fRFPcuts->SetAcceptKinkDaughters(kFALSE);
2359   fRFPcuts->SetEvent(aod);
2360
2361   TString ref[3] = {"FB1","FB128","VZE"};
2362   Double_t psi[3];
2363   for(Int_t i=0; i!=3; ++i) {
2364     if(i==0) { // switching to bit 1
2365       fRFPcuts->SetMinimalTPCdedx(10.);
2366       fRFPcuts->SetAODfilterBit(1);
2367     } else { // switching to bit 128
2368       fRFPcuts->SetMinimalTPCdedx(-1);
2369       fRFPcuts->SetAODfilterBit(128);
2370     }
2371     if(i>1) {
2372       fRFPcuts->SetParamType(AliFlowTrackCuts::kVZERO);
2373       fRFPcuts->SetEtaRange(-5,+5);
2374       fRFPcuts->SetPhiMin(0);
2375       fRFPcuts->SetPhiMax(TMath::TwoPi());
2376     }
2377     fFlowEvent->Fill(fRFPcuts,fRFPcuts);
2378     fFlowEvent->TagSubeventsInEta(-5,0,0,+5);
2379     // getting informationt
2380     AliFlowVector vQ, vQaQb[2];
2381     fFlowEvent->Get2Qsub(vQaQb,2);
2382     vQ = vQaQb[0]+vQaQb[1];
2383     Double_t dMa=vQaQb[0].GetMult();
2384     Double_t dMb=vQaQb[1].GetMult();
2385     if( dMa<2 || dMb<2 ) {
2386       ((TH2F*) fOutputFlowObs->FindObject("hFlowEvents"))->Fill(6.,cc); //???
2387       continue;
2388     }
2389     psi[i] = vQ.Phi()/2;
2390     // publishing
2391     ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(0,cc,vQaQb[0].X()/dMa,dMa); // Qx-
2392     ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(1,cc,vQaQb[0].Y()/dMa,dMa); // Qy-
2393     ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(2,cc,vQaQb[1].X()/dMb,dMb); // Qx+
2394     ((TProfile2D*) fOutputFlowObs->FindObject( Form("h%s_Q",ref[i].Data())))->Fill(3,cc,vQaQb[1].Y()/dMb,dMb); // Qy+
2395     ((TH2F*) fOutputFlowObs->FindObject( Form("h%s_AngleQ",ref[i].Data()) ))->Fill(psi[i],cc); // Psi
2396     AliFlowTrackSimple *track;
2397     for(Int_t t=0; t!=fFlowEvent->NumberOfTracks(); ++t) {
2398       track = (AliFlowTrackSimple*) fFlowEvent->GetTrack(t);
2399       if(!track) continue;
2400       if(!track->InRPSelection()) continue;
2401       ((TH3F*) fOutputFlowObs->FindObject( Form("h%s_PhiEta",ref[i].Data()) ))->Fill(track->Phi(),track->Eta(),cc,track->Weight()); //PhiEta
2402     }
2403   
2404   //histo filled only for TPCFB1
2405   if (i==0) {
2406     ((TH2F*) fOutputFlowObs->FindObject("hCentVsMultRPS"))->Fill(fFlowEvent->GetNumberOfRPs(),cc);
2407   }
2408   }
2409   // TPC vs VZERO
2410   ((TH3F*) fOutputFlowObs->FindObject( "hTPCVZE_AngleQ" ))->Fill(psi[0],psi[2],cc);
2411 }
2412
2413 //____________________________________________________________________________
2414 void AliAnalysisTaskSEHFQA::Terminate(Option_t */*option*/){
2415   //terminate analysis
2416
2417   fNEntries = dynamic_cast<TH1F*>(GetOutputData(1));
2418   if(!fNEntries){
2419     printf("ERROR: %s not available\n",GetOutputSlot(1)->GetContainer()->GetName());
2420     return;
2421   }
2422
2423   fOutputPID = dynamic_cast<TList*> (GetOutputData(2));
2424   if (!fOutputPID && fOnOff[1]) {     
2425     printf("ERROR: %s not available\n",GetOutputSlot(2)->GetContainer()->GetName());
2426     return;
2427   }
2428
2429   fOutputTrack = dynamic_cast<TList*> (GetOutputData(3));
2430   if (!fOutputTrack && fOnOff[0]) {     
2431     printf("ERROR: %s not available\n",GetOutputSlot(3)->GetContainer()->GetName());
2432     return;
2433   }
2434
2435 }
2436