Taking into account that only 1 or 2 values may be present for the
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / AliAnalysisTaskGlobalQA.cxx
CommitLineData
45c57a48 1
2/**************************************************************************
3 * Authors : Iouri Belikov, Antonin Maire
4 * Contributors are mentioned in the code where appropriate. *
5 * *
6 * Permission to use, copy, modify and distribute this software and its *
7 * documentation strictly for non-commercial purposes is hereby granted *
8 * without fee, provided that the above copyright notice appears in all *
9 * copies and that both the copyright notice and this permission notice *
10 * appear in the supporting documentation. The authors make no claims *
11 * about the suitability of this software for any purpose. It is *
12 * provided "as is" without express or implied warranty. *
13 **************************************************************************/
14
15//-----------------------------------------------------------------
16// AliAnalysisTaskGlobalQA class
17// This task is for running the GlobalQA over already existing ESDs
18// Origin: I.Belikov, Iouri.Belikov@cern.ch, June 2009
19//-----------------------------------------------------------------
20
21#include <TPDGCode.h>
22
23#include "TChain.h"
24#include "TTree.h"
25#include "TH1F.h"
26#include "TH2F.h"
27#include "TCanvas.h"
28
29#include "AliAnalysisManager.h"
30
31#include "AliESDEvent.h"
32#include "AliESDv0.h"
33#include "AliESDInputHandler.h"
34
35#include "AliAnalysisTaskGlobalQA.h"
36
37//
38// Run the GlobalQA analysis over already existing ESDs
39// Origin: Iouri.Belikov@cern.ch
40//
41
42ClassImp(AliAnalysisTaskGlobalQA)
43
44//________________________________________________________________________
45AliAnalysisTaskGlobalQA::AliAnalysisTaskGlobalQA() :
46 AliAnalysisTaskSE("GlobalQA"),
47 fArrayQA(0)
48{
49 // Default Constructor
50
51 DefineOutput(1, TObjArray::Class());
52}
53
54//________________________________________________________________________
55void AliAnalysisTaskGlobalQA::UserCreateOutputObjects()
56{
57 // Create the histograms
58 // Called once
59
60 fArrayQA = new TObjArray(20);
61
62
63 {// Cluster related QA
64 const Char_t *name[]={
65 "Fraction of the assigned clusters in ITS",
66 "Fraction of the assigned clusters in TPC",
67 "Fraction of the assigned clusters in TRD"
68 };
69 Add2ESDsList(new TH1F(name[0],name[0],100,0.,2.),kClr0);
70 Add2ESDsList(new TH1F(name[1],name[1],100,0.,2.),kClr1);
71 Add2ESDsList(new TH1F(name[2],name[2],100,0.,2.),kClr2);
72 }
73
74 {// Track related QA
75 const Char_t *name[]={
76 "Track azimuthal distribution (rad)", // kTrk0
77 "Track pseudo-rapidity distribution", // kTrk1
78 "TPC: track momentum distribution (GeV)", // kTrk2
79 "TPC-ITS matched: track momentum distribution (GeV)", // kTrk3
80 "TPC-TOF matched: track momentum distribution (GeV)", // kTrk4
81 "TPC-ITS track-matching probability", // kTrk5
82 "TPC-TOF track-matching probability" // kTrk6
83 };
84 Add2ESDsList(new TH1F(name[0],name[0],100, 0.,TMath::TwoPi()),kTrk0);
85 Add2ESDsList(new TH1F(name[1],name[1],100,-2.00,2.00),kTrk1);
86 Add2ESDsList(new TH1F(name[2],name[2],50, 0.20,5.00),kTrk2);
87 Add2ESDsList(new TH1F(name[3],name[3],50, 0.20,5.00),kTrk3);
88 Add2ESDsList(new TH1F(name[4],name[4],50, 0.20,5.00),kTrk4);
89 Add2ESDsList(new TH1F(name[5],name[5],50, 0.20,5.00),kTrk5);
90 Add2ESDsList(new TH1F(name[6],name[6],50, 0.20,5.00),kTrk6);
91 }
92
93 {// V0 related QA
94 const Char_t *name[]={
95 "On-the-fly K0s mass (GeV)",
96 "Offline K0s mass (GeV)",
97 "On-the-fly Lambda0 + Lambda0Bar mass (GeV)",
98 "Offline Lambda0 + Lambda0Bar mass (GeV)"
99 };
100 Add2ESDsList(new TH1F(name[0],name[0],50, 0.4477,0.5477),kK0on);
101 Add2ESDsList(new TH1F(name[1],name[1],50, 0.4477,0.5477),kK0off);
102 Add2ESDsList(new TH1F(name[2],name[2],50, 1.0657,1.1657),kL0on);
103 Add2ESDsList(new TH1F(name[3],name[3],50, 1.0657,1.1657),kL0off);
104 }
105
106 {// PID related QA
107 const Char_t *name[]={
108 "ITS: dEdx (A.U.) for particles with momentum 0.4 - 0.5 (GeV)",
109 "TPC: dEdx (A.U.) for particles with momentum 0.4 - 0.5 (GeV)",
110 "TOF: tracking - measured (ps)",
111 "TPC: dEdx (A.U.) vs momentum (GeV)"
112 };
113 Add2ESDsList(new TH1F(name[0],name[0],50,0.00,200.),kPid0);
114 Add2ESDsList(new TH1F(name[1],name[1],50,0.00,100.),kPid1);
115 Add2ESDsList(new TH1F(name[2],name[2],50,-3500.,3500.),kPid2);
116 Add2ESDsList(new TH2F(name[3],name[3],1500,0.05,15.,700,0.,700.),kPid3);
117 }
118
119}
120
121//________________________________________________________________________
122void AliAnalysisTaskGlobalQA::UserExec(Option_t *)
123{
124 // Main loop
125 // Called for each event
126
127 const AliESDEvent *esd=(const AliESDEvent *)InputEvent();
128
129 if (!esd) {
130 Printf("ERROR: ESD is not available");
131 return;
132 }
133
134 for (Int_t iTracks = 0; iTracks < esd->GetNumberOfTracks(); iTracks++) {
135 AliESDtrack* track = esd->GetTrack(iTracks);
136 if (!track) {
137 Printf("ERROR: Could not receive track %d", iTracks);
138 continue;
139 }
140
141
142 // Cluster related QA
143 if (track->IsOn(AliESDtrack::kITSrefit)) {
144 Int_t n=track->GetITSclusters(0);
145 GetESDsData(kClr0)->Fill(Float_t(n)/6.); //6 is the number of ITS layers
146 }
147
148 if (track->IsOn(AliESDtrack::kTPCrefit)) {
149 Int_t n =track->GetTPCNcls();
150 Int_t nf=track->GetTPCNclsF(); // number of crossed TPC pad rows
151 if (nf>0) {
152 Double_t val = n*1.0/nf;
153 GetESDsData(kClr1)->Fill(val);
154 }
155 }
156
157 if (track->IsOn(AliESDtrack::kTRDrefit)) {
158 Int_t n=track->GetTRDclusters(0);
159 GetESDsData(kClr2)->Fill(Float_t(n)/(6*24));//(6*24) is the number of TRD time bins
160 }
161
162 Double_t p=track->GetP();
163
164 // Track related QA
165 if (track->IsOn(AliESDtrack::kTPCrefit)) {
166 Float_t dz[2];
167 track->GetDZ(0.,0.,0.,esd->GetMagneticField(),dz);
168 if ((TMath::Abs(dz[0])<3.) && (TMath::Abs(dz[1])<3.)) { // beam pipe
169 Double_t phi=track->Phi();
170 GetESDsData(kTrk0)->Fill(phi);
171 Double_t y=track->Eta();
172 GetESDsData(kTrk1)->Fill(y);
173
174 if (TMath::Abs(y)<0.9) {
175 GetESDsData(kTrk2)->Fill(p);
176 if (track->IsOn(AliESDtrack::kITSrefit)) GetESDsData(kTrk3)->Fill(p);
177 //if (track->IsOn(AliESDtrack::kTOFout)) GetESDsData(kTrk4)->Fill(p);
178 if (track->GetTOFsignal()>0) GetESDsData(kTrk4)->Fill(p);
179 }
180 }
181 }
182
183 // PID related QA
184 if ((p>0.4) && (p<0.5)) {
185 if (track->IsOn(AliESDtrack::kITSpid)) {
186 Double_t dedx=track->GetITSsignal();
187 GetESDsData(kPid0)->Fill(dedx);
188 }
189 if (track->IsOn(AliESDtrack::kTPCpid)) {
190 Double_t dedx=track->GetTPCsignal();
191 GetESDsData(kPid1)->Fill(dedx);
192 }
193 }
194 if (p>1.0) {
195 if (track->IsOn(AliESDtrack::kTOFpid)) {
196 Double_t times[10];
197 track->GetIntegratedTimes(times);
198 Double_t tof=track->GetTOFsignal();
199 GetESDsData(kPid2)->Fill(times[2]-tof);
200 }
201 }
202 const AliExternalTrackParam *par=track->GetInnerParam();
203 if (par) {
204 Double_t pp=par->GetP();
205 Double_t dedx=track->GetTPCsignal();
206 TH2F *h = dynamic_cast<TH2F*>(GetESDsData(kPid3));
207 h->Fill(pp,dedx);
208 }
209 }
210
211 // V0 related QA
212 Int_t nV0=esd->GetNumberOfV0s();
213 for (Int_t i=0; i<nV0; i++) {
214 Double_t mass;
215 AliESDv0 v0(*esd->GetV0(i));
216
217 v0.ChangeMassHypothesis(kK0Short);
218 mass=v0.GetEffMass();
219 if (v0.GetOnFlyStatus())
220 GetESDsData(kK0on)->Fill(mass);
221 else
222 GetESDsData(kK0off)->Fill(mass);
223
224 v0.ChangeMassHypothesis(kLambda0);
225 mass=v0.GetEffMass();
226 if (v0.GetOnFlyStatus())
227 GetESDsData(kL0on)->Fill(mass);
228 else
229 GetESDsData(kL0off)->Fill(mass);
230
231 v0.ChangeMassHypothesis(kLambda0Bar);
232 mass=v0.GetEffMass();
233 if (v0.GetOnFlyStatus())
234 GetESDsData(kL0on)->Fill(mass);
235 else
236 GetESDsData(kL0off)->Fill(mass);
237 }
238
239 // Post output data.
240 PostData(1, fArrayQA);
241}
242
243//________________________________________________________________________
244void AliAnalysisTaskGlobalQA::Terminate(Option_t *)
245{
246 // Draw the results on the screen
247 // Called once at the end of the query
248
249 fArrayQA=(TObjArray*)GetOutputData(1);
250
251 TH1 *tpc=GetESDsData(kTrk2); tpc->Sumw2();
252 TH1 *its=GetESDsData(kTrk3); its->Sumw2();
253 TH1 *tof=GetESDsData(kTrk4); tof->Sumw2();
254 GetESDsData(kTrk5)->Divide(its,tpc,1,1.,"b");
255 GetESDsData(kTrk6)->Divide(tof,tpc,1,1.,"b");
256
257 TH1 *hTPCdEdxMIP = GetESDsData(kPid1);
258 if (!hTPCdEdxMIP) {
259 Printf("ERROR: hTPCdEdxMIP not available");
260 return;
261 }
262
263 TH2 *hTPCdEdxVsP = dynamic_cast<TH2*>(GetESDsData(kPid3));
264 if (!hTPCdEdxVsP) {
265 Printf("ERROR: hTPCdEdxVsP not available");
266 return;
267 }
268
269 TCanvas *c2=new TCanvas("c2","",320,32,530,590);
270
271 TPad *p6=new TPad("p6","",0.,0.,1.,.5); p6->Draw(); p6->cd();
272 p6->SetFillColor(42); p6->SetFrameFillColor(10);
273 hTPCdEdxMIP->SetFillColor(2); hTPCdEdxMIP->SetFillStyle(3005);
274 if (hTPCdEdxMIP->GetEntries()<333)
275 hTPCdEdxMIP->DrawCopy("E");
276 else
277 hTPCdEdxMIP->Fit("gaus");
278 c2->cd();
279
280 TPad *p7=new TPad("p7","",0.,0.5,1.,1.); p7->Draw(); p7->cd(); p7->SetLogx();
281 p7->SetFillColor(42); p7->SetFrameFillColor(10);
282 hTPCdEdxVsP->DrawCopy();
283
284}