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