]>
Commit | Line | Data |
---|---|---|
1ee39b3a | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ///////////////////////////////////////////////////// | |
17 | // | |
18 | // Check basic detector results at ESD level | |
19 | // - Geometrical efficiency | |
20 | // - Tracking efficiency | |
21 | // - PID efficiency | |
22 | // - Refit efficiency | |
23 | // | |
24 | // Author | |
25 | // Alex Bercuci <A.Bercuci@gsi.de> | |
26 | // | |
27 | ////////////////////////////////////////////////////// | |
28 | ||
29 | #include <TClonesArray.h> | |
30 | #include <TObjArray.h> | |
629ae9b8 | 31 | #include <TPad.h> |
32 | #include <TLegend.h> | |
33 | #include <TF1.h> | |
1ee39b3a | 34 | #include <TH2I.h> |
fb09668f | 35 | #include <TH3S.h> |
1ee39b3a | 36 | #include <TGraphErrors.h> |
37 | #include <TGraphAsymmErrors.h> | |
38 | #include <TFile.h> | |
39 | #include <TTree.h> | |
40 | #include <TROOT.h> | |
41 | #include <TChain.h> | |
42 | #include <TParticle.h> | |
43 | ||
44 | #include "AliLog.h" | |
45 | #include "AliAnalysisManager.h" | |
46 | #include "AliESDEvent.h" | |
47 | #include "AliESDkink.h" | |
48 | #include "AliMCEvent.h" | |
49 | #include "AliESDInputHandler.h" | |
50 | #include "AliMCEventHandler.h" | |
51 | ||
52 | #include "AliESDtrack.h" | |
53 | #include "AliMCParticle.h" | |
54 | #include "AliPID.h" | |
55 | #include "AliStack.h" | |
56 | #include "AliTrackReference.h" | |
57 | ||
58 | #include "AliTRDcheckESD.h" | |
59 | ||
60 | ClassImp(AliTRDcheckESD) | |
61 | ||
62 | const Float_t AliTRDcheckESD::fgkxTPC = 290.; | |
63 | const Float_t AliTRDcheckESD::fgkxTOF = 365.; | |
1f6edfbc | 64 | const UChar_t AliTRDcheckESD::fgkNgraph[AliTRDcheckESD::kNrefs] ={ |
735d88d4 | 65 | 0, 4, 2, 20}; |
9b496b5e | 66 | FILE* AliTRDcheckESD::fgFile = NULL; |
1ee39b3a | 67 | |
68 | //____________________________________________________________________ | |
69 | AliTRDcheckESD::AliTRDcheckESD(): | |
f8f46e4d | 70 | AliAnalysisTaskSE() |
1ee39b3a | 71 | ,fStatus(0) |
629ae9b8 | 72 | ,fNRefFigures(0) |
9b496b5e | 73 | ,fESD(NULL) |
74 | ,fMC(NULL) | |
75 | ,fHistos(NULL) | |
76 | ,fResults(NULL) | |
1ee39b3a | 77 | { |
78 | // | |
79 | // Default constructor | |
80 | // | |
db99a57a | 81 | SetNameTitle("checkESD", "Check TRD @ ESD level"); |
1ee39b3a | 82 | SetMC(kTRUE); |
f8f46e4d | 83 | } |
84 | ||
f2e89a4c | 85 | //____________________________________________________________________ |
f8f46e4d | 86 | AliTRDcheckESD::AliTRDcheckESD(char* name): |
87 | AliAnalysisTaskSE(name) | |
88 | ,fStatus(0) | |
629ae9b8 | 89 | ,fNRefFigures(0) |
f8f46e4d | 90 | ,fESD(NULL) |
91 | ,fMC(NULL) | |
92 | ,fHistos(NULL) | |
93 | ,fResults(NULL) | |
94 | { | |
95 | // | |
96 | // Default constructor | |
97 | // | |
98 | SetMC(kTRUE); | |
f2e89a4c | 99 | SetTitle("Check TRD @ ESD level"); |
f8f46e4d | 100 | DefineOutput(1, TObjArray::Class()); |
1ee39b3a | 101 | } |
102 | ||
103 | //____________________________________________________________________ | |
104 | AliTRDcheckESD::~AliTRDcheckESD() | |
105 | { | |
106 | // Destructor | |
107 | if(fHistos){ | |
108 | //fHistos->Delete(); | |
109 | delete fHistos; | |
110 | } | |
111 | if(fResults){ | |
112 | fResults->Delete(); | |
113 | delete fResults; | |
114 | } | |
115 | } | |
116 | ||
117 | //____________________________________________________________________ | |
f8f46e4d | 118 | void AliTRDcheckESD::UserCreateOutputObjects() |
1ee39b3a | 119 | { |
120 | // | |
121 | // Create Output Containers (TObjectArray containing 1D histograms) | |
122 | // | |
a96ac33a | 123 | //OpenFile(0, "RECREATE"); |
124 | ||
1ee39b3a | 125 | Histos(); |
126 | } | |
127 | ||
629ae9b8 | 128 | |
1ee39b3a | 129 | //____________________________________________________________________ |
629ae9b8 | 130 | Bool_t AliTRDcheckESD::GetRefFigure(Int_t ifig) |
1ee39b3a | 131 | { |
629ae9b8 | 132 | if(ifig>=fNRefFigures){ |
133 | AliWarning(Form("Ref plot %d not available. Valid only up to %d", ifig, fNRefFigures)); | |
134 | return kFALSE; | |
1ee39b3a | 135 | } |
629ae9b8 | 136 | if(!gPad){ |
137 | AliWarning("Please provide a canvas to draw results."); | |
138 | return kFALSE; | |
1ee39b3a | 139 | } |
140 | ||
629ae9b8 | 141 | const Char_t *title[20]; |
142 | TH1 *hF(NULL); | |
143 | if((hF=(TH1S*)gROOT->FindObject("hFcheckESD"))) delete hF; | |
144 | TLegend *leg(NULL); | |
735d88d4 | 145 | TList *l(NULL); TVirtualPad *pad(NULL); |
629ae9b8 | 146 | TGraphErrors *g(NULL);TGraphAsymmErrors *ga(NULL); |
147 | TObjArray *arr(NULL); | |
148 | switch(ifig){ | |
149 | case kNCl: // number of clusters/track | |
150 | ((TH1I*)fResults->At(kNCl))->Draw("c"); | |
151 | break; | |
152 | case kTRDstat: // Efficiency | |
153 | if(!(arr = (TObjArray*)fResults->At(kTRDstat))) return kFALSE; | |
154 | leg = new TLegend(.65, .7, .95, .99); | |
155 | leg->SetHeader("TRD Efficiency"); | |
156 | leg->SetBorderSize(1); leg->SetFillColor(0); | |
157 | title[0] = "Geometrical (TRDin/TPCout)"; | |
158 | title[1] = "Tracking (TRDout/TRDin)"; | |
159 | title[2] = "PID (TRDpid/TRDin)"; | |
160 | title[3] = "Refit (TRDrefit/TRDin)"; | |
161 | hF = new TH1S("hFcheckESD", ";p [GeV/c];Efficiency", 10, 0.1, 10.); | |
162 | hF->SetMaximum(1.3); | |
163 | hF->GetXaxis()->SetMoreLogLabels(); | |
164 | hF->Draw("p"); | |
165 | for(Int_t ig(0); ig<fgkNgraph[kTRDstat]; ig++){ | |
166 | if(!(g = (TGraphErrors*)arr->At(ig))) return kFALSE; | |
167 | g->Draw("pl"); leg->AddEntry(g, title[ig], "pl"); | |
168 | //PutTrendValue(name[id], g->GetMean(2)); | |
169 | //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2)); | |
1ee39b3a | 170 | } |
629ae9b8 | 171 | leg->Draw(); gPad->SetLogx(); |
172 | break; | |
173 | case kTRDmom: // Energy loss | |
174 | if(!(arr = (TObjArray*)fResults->At(kTRDmom))) return kFALSE; | |
175 | leg = new TLegend(.65, .7, .95, .99); | |
176 | leg->SetHeader("Energy Loss"); | |
177 | leg->SetBorderSize(1); leg->SetFillColor(0); | |
178 | title[0] = "Max & 90% quantile"; | |
179 | title[1] = "Mean & 60% quantile"; | |
180 | hF = new TH1S("hFcheckESD", ";layer;#Delta E", 6, -0.5, 5.5); | |
181 | hF->SetMaximum(1.3);hF->SetMinimum(-.3); | |
182 | hF->Draw("p"); | |
183 | for(Int_t ig(0); ig<fgkNgraph[kTRDmom]; ig++){ | |
184 | if(!(ga = (TGraphAsymmErrors*)arr->At(ig))) return kFALSE; | |
185 | ga->Draw("pl"); leg->AddEntry(ga, title[ig], "pl"); | |
186 | //PutTrendValue(name[id], g->GetMean(2)); | |
187 | //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2)); | |
1ee39b3a | 188 | } |
629ae9b8 | 189 | leg->Draw();gPad->SetLogx(kFALSE); |
190 | break; | |
191 | case kPtRes: // Pt resolution @ vertex | |
192 | if(!(arr = (TObjArray*)fResults->At(kPtRes))) return kFALSE; | |
735d88d4 | 193 | gPad->Divide(2, 1, 1.e-5, 1.e-5); l=gPad->GetListOfPrimitives(); |
194 | pad = ((TVirtualPad*)l->At(0)); pad->cd(); pad->SetLogx(); | |
195 | pad->SetMargin(0.1, 0.022, 0.1, 0.023); | |
196 | hF = new TH1S("hFcheckESD", "ITS+TPC+TRD;p_{t} [GeV/c];#Delta p_{t} / p_{t} [%]", 10, 0.2, 10.); | |
197 | hF->SetMaximum(10.);hF->SetMinimum(-3.); | |
198 | hF->GetXaxis()->SetMoreLogLabels(); | |
199 | hF->GetXaxis()->SetTitleOffset(1.2); | |
200 | hF->GetYaxis()->CenterTitle(); | |
201 | hF->Draw("p"); | |
202 | for(Int_t ig(0); ig<fgkNgraph[kPtRes]/2; ig++){ | |
203 | if(!(g = (TGraphErrors*)arr->At(ig))) continue; | |
204 | if(!g->GetN()) continue; | |
205 | g->Draw("pl"); | |
206 | //PutTrendValue(name[id], g->GetMean(2)); | |
207 | //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2)); | |
208 | } | |
209 | pad = ((TVirtualPad*)l->At(1)); pad->cd(); pad->SetLogx(); | |
210 | pad->SetMargin(0.1, 0.22, 0.1, 0.023); | |
211 | hF = (TH1*)hF->Clone("hFcheckESD1"); | |
212 | hF->SetTitle("ITS+TPC"); | |
213 | hF->SetMaximum(10.);hF->SetMinimum(-3.); | |
214 | hF->Draw("p"); | |
629ae9b8 | 215 | leg = new TLegend(.78, .1, .99, .98); |
216 | leg->SetHeader("P_{t} @ DCA"); | |
217 | leg->SetBorderSize(1); leg->SetFillColor(0); | |
218 | leg->SetTextAlign(22); | |
219 | leg->SetTextFont(12); | |
220 | leg->SetTextSize(0.03813559); | |
92d6d80c | 221 | { |
222 | Int_t nPlots(0); | |
735d88d4 | 223 | for(Int_t ig(fgkNgraph[kPtRes]/2); ig<fgkNgraph[kPtRes]; ig++){ |
224 | if(!(g = (TGraphErrors*)arr->At(ig))) continue; | |
92d6d80c | 225 | if(!g->GetN()) continue; |
226 | nPlots++; | |
227 | g->Draw("pl"); leg->AddEntry(g, g->GetTitle(), "pl"); | |
228 | //PutTrendValue(name[id], g->GetMean(2)); | |
229 | //PutTrendValue(Form("%sRMS", name[id]), g->GetRMS(2)); | |
230 | } | |
231 | if(nPlots) leg->Draw(); | |
629ae9b8 | 232 | } |
735d88d4 | 233 | |
629ae9b8 | 234 | break; |
1ee39b3a | 235 | } |
e2e3cec2 | 236 | return kTRUE; |
237 | } | |
238 | ||
1ee39b3a | 239 | //____________________________________________________________________ |
f8f46e4d | 240 | void AliTRDcheckESD::UserExec(Option_t *){ |
1ee39b3a | 241 | // |
242 | // Run the Analysis | |
243 | // | |
f8f46e4d | 244 | fESD = dynamic_cast<AliESDEvent*>(InputEvent()); |
245 | fMC = MCEvent(); | |
705f8b0a | 246 | |
1ee39b3a | 247 | if(!fESD){ |
248 | AliError("ESD event missing."); | |
249 | return; | |
250 | } | |
f8f46e4d | 251 | |
1ee39b3a | 252 | // Get MC information if available |
9b496b5e | 253 | AliStack * fStack = NULL; |
1ee39b3a | 254 | if(HasMC()){ |
255 | if(!fMC){ | |
256 | AliWarning("MC event missing"); | |
257 | SetMC(kFALSE); | |
258 | } else { | |
259 | if(!(fStack = fMC->Stack())){ | |
260 | AliWarning("MC stack missing"); | |
261 | SetMC(kFALSE); | |
262 | } | |
263 | } | |
264 | } | |
9b496b5e | 265 | TH2 *h(NULL); |
266 | ||
267 | AliESDtrack *esdTrack(NULL); | |
1ee39b3a | 268 | for(Int_t itrk = 0; itrk < fESD->GetNumberOfTracks(); itrk++){ |
1ee39b3a | 269 | esdTrack = fESD->GetTrack(itrk); |
270 | ||
1ee39b3a | 271 | // track status |
fb09668f | 272 | ULong_t status = esdTrack->GetStatus(); //PrintStatus(status); |
1ee39b3a | 273 | if(!Bool_t(status & AliESDtrack::kTPCout)) continue; |
274 | if(esdTrack->GetKinkIndex(0) > 0) continue; | |
275 | ||
fb09668f | 276 | //Int_t nTPC(esdTrack->GetNcls(1)); |
277 | Int_t nTRD(esdTrack->GetNcls(2)); | |
278 | Double_t pt(esdTrack->Pt()); | |
279 | //Double_t eta(esdTrack->Eta()); | |
280 | //Double_t phi(esdTrack->Phi()); | |
1ee39b3a | 281 | Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p); |
282 | // pid quality | |
283 | //esdTrack->GetTRDntrackletsPID(); | |
fb09668f | 284 | Bool_t kBarrel = Bool_t(status & AliESDtrack::kTRDin); |
1ee39b3a | 285 | |
286 | // look at external track param | |
287 | const AliExternalTrackParam *op = esdTrack->GetOuterParam(); | |
288 | const AliExternalTrackParam *ip = esdTrack->GetInnerParam(); | |
1ee39b3a | 289 | |
fb09668f | 290 | Double_t pt0(0.), eta0(0.), phi0(0.), ptTRD(0.); |
9b496b5e | 291 | // read MC info if available |
fb09668f | 292 | Bool_t kFOUND(kFALSE), kPhysPrim(kFALSE); |
293 | AliMCParticle *mcParticle(NULL); | |
9b496b5e | 294 | if(HasMC()){ |
295 | AliTrackReference *ref(NULL); | |
296 | Int_t fLabel(esdTrack->GetLabel()); | |
fb09668f | 297 | Int_t fIdx(TMath::Abs(fLabel)); |
298 | if(fIdx > fStack->GetNtrack()) continue; | |
9b496b5e | 299 | |
fb09668f | 300 | // read MC particle |
301 | if(!(mcParticle = (AliMCParticle*) fMC->GetTrack(fIdx))) { | |
9b496b5e | 302 | AliWarning(Form("MC particle missing. Label[ %d].", fLabel)); |
303 | continue; | |
304 | } | |
fb09668f | 305 | pt0 = mcParticle->Pt(); |
306 | eta0 = mcParticle->Eta(); | |
307 | phi0 = mcParticle->Phi(); | |
308 | kPhysPrim = fMC->IsPhysicalPrimary(fIdx); | |
309 | ||
310 | // read track references | |
9b496b5e | 311 | Int_t nRefs = mcParticle->GetNumberOfTrackReferences(); |
312 | if(!nRefs){ | |
fb09668f | 313 | AliWarning(Form("No TR found for track @ Label[%d].", fLabel)); |
9b496b5e | 314 | continue; |
315 | } | |
316 | Int_t iref = 0; | |
317 | while(iref<nRefs){ | |
318 | ref = mcParticle->GetTrackReference(iref); | |
319 | if(ref->LocalX() > fgkxTPC) break; | |
320 | ref=NULL; iref++; | |
321 | } | |
322 | if(ref){ | |
323 | if(ref->LocalX() > fgkxTOF){ // track skipping TRD fiducial volume | |
324 | ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0)); | |
325 | } | |
326 | } else { // track stopped in TPC | |
327 | ref = mcParticle->GetTrackReference(TMath::Max(iref-1, 0)); | |
328 | } | |
fb09668f | 329 | ptTRD = ref->Pt();kFOUND=kTRUE; |
9b496b5e | 330 | } else { // use reconstructed values |
331 | if(op){ | |
332 | Double_t x(op->GetX()); | |
333 | if(x<fgkxTOF && x>fgkxTPC){ | |
fb09668f | 334 | ptTRD=op->Pt(); |
9b496b5e | 335 | kFOUND=kTRUE; |
336 | } | |
337 | } | |
1ee39b3a | 338 | |
9b496b5e | 339 | if(!kFOUND && ip){ |
fb09668f | 340 | ptTRD=ip->Pt(); |
9b496b5e | 341 | kFOUND=kTRUE; |
342 | } | |
1ee39b3a | 343 | } |
344 | ||
9b496b5e | 345 | if(kFOUND){ |
346 | h = (TH2I*)fHistos->At(kTRDstat); | |
fb09668f | 347 | if(status & AliESDtrack::kTPCout) h->Fill(ptTRD, kTPCout); |
348 | if(status & AliESDtrack::kTRDin) h->Fill(ptTRD, kTRDin); | |
349 | if(kBarrel && (status & AliESDtrack::kTRDout)){ | |
350 | ((TH1*)fHistos->At(kNCl))->Fill(nTRD); | |
351 | h->Fill(ptTRD, kTRDout); | |
1ee39b3a | 352 | } |
fb09668f | 353 | if(kBarrel && (status & AliESDtrack::kTRDpid)) h->Fill(ptTRD, kTRDpid); |
354 | if(kBarrel && (status & AliESDtrack::kTRDrefit)) h->Fill(ptTRD, kTRDref); | |
355 | } | |
71f43a24 | 356 | if(HasMC() && |
357 | kBarrel && kPhysPrim && | |
a47a87c5 | 358 | TMath::Abs(eta0) < 0.9) { |
fb09668f | 359 | TH3 *h3 = (TH3S*)fHistos->At(kPtRes); |
a47a87c5 | 360 | Int_t sgn = mcParticle->Charge()<0?0:1; |
361 | Int_t offset = (status & AliESDtrack::kTRDrefit) ? 0 : 10; | |
362 | ||
363 | h3->Fill(pt0, 1.e2*(pt/pt0-1.), | |
364 | offset + 2*Pdg2Idx(TMath::Abs(mcParticle->PdgCode())) + sgn); | |
1ee39b3a | 365 | } |
1ee39b3a | 366 | if(ip){ |
367 | h = (TH2I*)fHistos->At(kTRDmom); | |
fb09668f | 368 | Float_t pTRD(0.); |
1ee39b3a | 369 | for(Int_t ily=6; ily--;){ |
fb09668f | 370 | if((pTRD=esdTrack->GetTRDmomentum(ily))<0.) continue; |
371 | h->Fill(ip->GetP()-pTRD, ily); | |
1ee39b3a | 372 | } |
373 | } | |
374 | } | |
f8f46e4d | 375 | PostData(1, fHistos); |
1ee39b3a | 376 | } |
377 | ||
378 | //____________________________________________________________________ | |
379 | TObjArray* AliTRDcheckESD::Histos() | |
380 | { | |
381 | // Retrieve histograms array if already build or build it | |
382 | ||
383 | if(fHistos) return fHistos; | |
384 | ||
385 | fHistos = new TObjArray(kNhistos); | |
386 | //fHistos->SetOwner(kTRUE); | |
629ae9b8 | 387 | |
9b496b5e | 388 | TH1 *h = NULL; |
1ee39b3a | 389 | |
390 | // clusters per tracklet | |
391 | if(!(h = (TH1I*)gROOT->FindObject("hNCl"))){ | |
fb09668f | 392 | h = new TH1I("hNCl", "Clusters per TRD track;N_{cl}^{TRD};entries", 100, 0., 200.); |
1ee39b3a | 393 | } else h->Reset(); |
629ae9b8 | 394 | fHistos->AddAt(h, kNCl); fNRefFigures++; |
1ee39b3a | 395 | |
396 | // status bits histogram | |
a310e49b | 397 | const Int_t kNpt(30), kNbits(5); |
398 | Float_t Pt(0.2), Bits(.5); | |
fb09668f | 399 | Float_t binsPt[kNpt+1], binsBits[kNbits+1]; |
a310e49b | 400 | for(Int_t i=0;i<kNpt+1; i++,Pt+=(TMath::Exp(i*i*.001)-1.)) binsPt[i]=Pt; |
fb09668f | 401 | for(Int_t i=0; i<kNbits+1; i++,Bits+=1.) binsBits[i]=Bits; |
1ee39b3a | 402 | if(!(h = (TH2I*)gROOT->FindObject("hTRDstat"))){ |
629ae9b8 | 403 | h = new TH2I("hTRDstat", "TRD status bits;p_{t} @ TRD [GeV/c];status;entries", kNpt, binsPt, kNbits, binsBits); |
fb09668f | 404 | TAxis *ay(h->GetYaxis()); |
405 | ay->SetBinLabel(1, "kTPCout"); | |
406 | ay->SetBinLabel(2, "kTRDin"); | |
407 | ay->SetBinLabel(3, "kTRDout"); | |
408 | ay->SetBinLabel(4, "kTRDpid"); | |
409 | ay->SetBinLabel(5, "kTRDrefit"); | |
1ee39b3a | 410 | } else h->Reset(); |
411 | fHistos->AddAt(h, kTRDstat); | |
412 | ||
413 | // energy loss | |
414 | if(!(h = (TH2I*)gROOT->FindObject("hTRDmom"))){ | |
fb09668f | 415 | h = new TH2I("hTRDmom", "TRD energy loss;p_{inner} - p_{ly} [GeV/c];ly;entries", 100, -1., 2., 6, -0.5, 5.5); |
1ee39b3a | 416 | } else h->Reset(); |
417 | fHistos->AddAt(h, kTRDmom); | |
629ae9b8 | 418 | if(!HasMC()) return fHistos; |
1ee39b3a | 419 | |
fb09668f | 420 | // pt resolution |
a47a87c5 | 421 | const Int_t kNdpt(100), kNspec(4*AliPID::kSPECIES); |
422 | Float_t DPt(-3.), Spec(-0.5); | |
fb09668f | 423 | Float_t binsDPt[kNdpt+1], binsSpec[kNspec+1]; |
424 | for(Int_t i=0; i<kNdpt+1; i++,DPt+=6.e-2) binsDPt[i]=DPt; | |
425 | for(Int_t i=0; i<kNspec+1; i++,Spec+=1.) binsSpec[i]=Spec; | |
426 | if(!(h = (TH3S*)gROOT->FindObject("hPtRes"))){ | |
427 | h = new TH3S("hPtRes", "P_{t} resolution @ DCA;p_{t}^{MC} [GeV/c];#Delta p_{t}/p_{t}^{MC} [%];SPECIES", kNpt, binsPt, kNdpt, binsDPt, kNspec, binsSpec); | |
428 | TAxis *az(h->GetZaxis()); | |
a47a87c5 | 429 | az->SetLabelOffset(0.015); |
fb09668f | 430 | for(Int_t i(0); i<AliPID::kSPECIES; i++){ |
a47a87c5 | 431 | az->SetBinLabel(2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i))); |
432 | az->SetBinLabel(2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i))); | |
433 | az->SetBinLabel(10+2*i+1, Form("%s^{-}", AliPID::ParticleLatexName(i))); | |
434 | az->SetBinLabel(10+2*i+2, Form("%s^{+}", AliPID::ParticleLatexName(i))); | |
fb09668f | 435 | } |
436 | } else h->Reset(); | |
437 | fHistos->AddAt(h, kPtRes); | |
438 | ||
1ee39b3a | 439 | return fHistos; |
440 | } | |
441 | ||
442 | //____________________________________________________________________ | |
443 | Bool_t AliTRDcheckESD::Load(const Char_t *filename, const Char_t *name) | |
444 | { | |
445 | // Load data from performance file | |
446 | ||
447 | if(!TFile::Open(filename)){ | |
448 | AliWarning(Form("Couldn't open file %s.", filename)); | |
449 | return kFALSE; | |
450 | } | |
9b496b5e | 451 | TObjArray *o = NULL; |
1ee39b3a | 452 | if(!(o = (TObjArray*)gFile->Get(name ? name : GetName()))){ |
453 | AliWarning("Missing histogram container."); | |
454 | return kFALSE; | |
455 | } | |
456 | fHistos = (TObjArray*)o->Clone(GetName()); | |
457 | gFile->Close(); | |
a96ac33a | 458 | SETBIT(fStatus, kLoad); |
1ee39b3a | 459 | return kTRUE; |
460 | } | |
461 | ||
462 | //_______________________________________________________ | |
463 | Bool_t AliTRDcheckESD::PutTrendValue(const Char_t *name, Double_t val) | |
464 | { | |
465 | // Dump trending value to default file | |
466 | ||
467 | if(!fgFile){ | |
468 | fgFile = fopen("TRD.Performance.txt", "at"); | |
469 | } | |
470 | fprintf(fgFile, "%s_%s %f\n", GetName(), name, val); | |
471 | return kTRUE; | |
472 | } | |
473 | ||
474 | //____________________________________________________________________ | |
475 | void AliTRDcheckESD::Terminate(Option_t *) | |
476 | { | |
477 | // Steer post-processing | |
a96ac33a | 478 | if(!IsLoad()){ |
2efff183 | 479 | fHistos = dynamic_cast<TObjArray *>(GetOutputData(1)); |
a96ac33a | 480 | if(!fHistos){ |
481 | AliError("Histogram container not found in output"); | |
482 | return; | |
483 | } | |
9b496b5e | 484 | } |
1ee39b3a | 485 | |
629ae9b8 | 486 | const Char_t *name[kNrefs] = { |
487 | "Ncl", "Eff", "Eloss", "PtResDCA" | |
488 | }; | |
489 | TObjArray *arr(NULL); TGraph *g(NULL); | |
490 | if(!fResults){ | |
491 | fResults = new TObjArray(kNrefs); | |
492 | fResults->SetOwner(); | |
493 | fResults->SetName("results"); | |
494 | for(Int_t iref(0); iref<kNrefs; iref++){ | |
495 | fResults->AddAt(arr = new TObjArray(fgkNgraph[iref]), iref); | |
496 | arr->SetName(name[iref]); arr->SetOwner(); | |
497 | switch(iref){ | |
498 | case kTRDmom: | |
499 | for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){ | |
500 | arr->AddAt(g = new TGraphAsymmErrors(), ig); | |
501 | g->SetLineColor(ig+1); | |
502 | g->SetMarkerColor(ig+1); | |
503 | g->SetMarkerStyle(ig+20); | |
504 | } | |
505 | break; | |
506 | case kPtRes: | |
735d88d4 | 507 | for(Int_t idx(0); idx<AliPID::kSPECIES; idx++){ |
508 | Int_t ig(2*idx); | |
509 | arr->AddAt(g = new TGraphErrors(), ig); | |
510 | g->SetLineColor(kRed-idx); | |
511 | g->SetMarkerColor(kRed-idx); | |
512 | g->SetMarkerStyle(20+idx); | |
513 | g->SetNameTitle(Form("s%d", ig), Form("res %s", AliPID::ParticleLatexName(idx))); | |
514 | arr->AddAt(g = new TGraphErrors(), ig+1); | |
515 | g->SetLineColor(kBlue-idx); | |
516 | g->SetMarkerColor(kBlue-idx); | |
517 | g->SetMarkerStyle(20+idx); | |
518 | g->SetNameTitle(Form("m%d", ig+1), Form("sys %s", AliPID::ParticleLatexName(idx))); | |
519 | ||
520 | ig+=10; | |
521 | arr->AddAt(g = new TGraphErrors(), ig); | |
629ae9b8 | 522 | g->SetLineColor(kRed-idx); |
523 | g->SetMarkerColor(kRed-idx); | |
735d88d4 | 524 | g->SetMarkerStyle(20+idx); |
525 | g->SetNameTitle(Form("s%d", ig), Form("sigma %s", AliPID::ParticleLatexName(idx))); | |
526 | arr->AddAt(g = new TGraphErrors(), ig+1); | |
629ae9b8 | 527 | g->SetLineColor(kBlue-idx); |
528 | g->SetMarkerColor(kBlue-idx); | |
735d88d4 | 529 | g->SetMarkerStyle(20+idx); |
530 | g->SetNameTitle(Form("m%d", ig+1), Form("mean %s", AliPID::ParticleLatexName(idx))); | |
629ae9b8 | 531 | } |
532 | break; | |
533 | default: | |
534 | for(Int_t ig(0); ig<fgkNgraph[iref]; ig++){ | |
535 | arr->AddAt(g = new TGraphErrors(), ig); | |
536 | g->SetLineColor(ig+1); | |
537 | g->SetMarkerColor(ig+1); | |
538 | g->SetMarkerStyle(ig+20); | |
539 | } | |
540 | break; | |
541 | } | |
542 | } | |
543 | } | |
544 | fNRefFigures = 1; | |
545 | ||
546 | // EFFICIENCY | |
1ee39b3a | 547 | // geometrical efficiency |
629ae9b8 | 548 | TH2I *h2(NULL); |
549 | if(!(h2 = (TH2I*)fHistos->At(kTRDstat))) return; | |
550 | arr = (TObjArray*)fResults->At(kTRDstat); | |
9b496b5e | 551 | TH1 *h1[2] = {NULL, NULL}; |
1ee39b3a | 552 | h1[0] = h2->ProjectionX("checkESDx0", kTPCout, kTPCout); |
553 | h1[1] = h2->ProjectionX("checkESDx1", kTRDin, kTRDin); | |
629ae9b8 | 554 | Process(h1, (TGraphErrors*)arr->At(0)); |
1ee39b3a | 555 | delete h1[0];delete h1[1]; |
1ee39b3a | 556 | // tracking efficiency |
557 | h1[0] = h2->ProjectionX("checkESDx0", kTRDin, kTRDin); | |
558 | h1[1] = h2->ProjectionX("checkESDx1", kTRDout, kTRDout); | |
629ae9b8 | 559 | Process(h1, (TGraphErrors*)arr->At(1)); |
1ee39b3a | 560 | delete h1[1]; |
1ee39b3a | 561 | // PID efficiency |
562 | h1[1] = h2->ProjectionX("checkESDx1", kTRDpid, kTRDpid); | |
629ae9b8 | 563 | Process(h1, (TGraphErrors*)arr->At(2)); |
1ee39b3a | 564 | delete h1[1]; |
1ee39b3a | 565 | // Refit efficiency |
566 | h1[1] = h2->ProjectionX("checkESDx1", kTRDref, kTRDref); | |
629ae9b8 | 567 | Process(h1, (TGraphErrors*)arr->At(3)); |
1ee39b3a | 568 | delete h1[1]; |
629ae9b8 | 569 | fNRefFigures++; |
570 | ||
571 | // ENERGY LOSS | |
1ee39b3a | 572 | if(!(h2 = dynamic_cast<TH2I*>(fHistos->At(kTRDmom)))) return; |
629ae9b8 | 573 | arr = (TObjArray*)fResults->At(kTRDmom); |
574 | TGraphAsymmErrors *g06 = (TGraphAsymmErrors*)arr->At(0), *g09 = (TGraphAsymmErrors*)arr->At(1); | |
1ee39b3a | 575 | TAxis *ax=h2->GetXaxis(); |
576 | const Int_t nq(4); | |
577 | const Double_t xq[nq] = {0.05, 0.2, 0.8, 0.95}; | |
578 | Double_t yq[nq]; | |
579 | for(Int_t ily=6; ily--;){ | |
580 | h1[0] = h2->ProjectionX("checkESDp0", ily+1, ily+1); | |
581 | h1[0]->GetQuantiles(nq,yq,xq); | |
582 | g06->SetPoint(ily, Float_t(ily), ax->GetBinCenter(h1[0]->GetMaximumBin())); | |
583 | g06->SetPointError(ily, 0., 0., TMath::Abs(yq[0]), yq[3]); | |
584 | g09->SetPoint(ily, Float_t(ily), h1[0]->GetMean()); | |
585 | g09->SetPointError(ily, 0., 0., TMath::Abs(yq[1]), yq[2]); | |
586 | ||
587 | //printf(" max[%f] mean[%f] q[%f %f %f %f]\n", ax->GetBinCenter(h1[0]->GetMaximumBin()), h1[0]->GetMean(), yq[0], yq[1], yq[2], yq[3]); | |
588 | delete h1[0]; | |
589 | } | |
629ae9b8 | 590 | fNRefFigures++; |
591 | if(!HasMC()) return; | |
592 | ||
593 | // Pt RESOLUTION @ DCA | |
594 | TH3S* h3(NULL); TGraphErrors *gg[2] = {NULL,NULL}; | |
595 | if(!(h3 = dynamic_cast<TH3S*>(fHistos->At(kPtRes)))) return; | |
596 | arr = (TObjArray*)fResults->At(kPtRes); | |
597 | TAxis *az(h3->GetZaxis()); | |
598 | for(Int_t i(0); i<AliPID::kSPECIES; i++){ | |
735d88d4 | 599 | Int_t idx(2*i); |
600 | az->SetRange(idx+1, idx+2); | |
601 | gg[1] = (TGraphErrors*)arr->At(idx); | |
602 | gg[0] = (TGraphErrors*)arr->At(idx+1); | |
603 | Process2D((TH2*)h3->Project3D("yx"), gg); | |
604 | ||
605 | idx+=10; | |
606 | az->SetRange(idx+1, idx+2); | |
607 | gg[1] = (TGraphErrors*)arr->At(idx); | |
608 | gg[0] = (TGraphErrors*)arr->At(idx+1); | |
629ae9b8 | 609 | Process2D((TH2*)h3->Project3D("yx"), gg); |
629ae9b8 | 610 | } |
611 | fNRefFigures++; | |
1ee39b3a | 612 | } |
613 | ||
fb09668f | 614 | //____________________________________________________________________ |
615 | Int_t AliTRDcheckESD::Pdg2Idx(Int_t pdg) | |
616 | { | |
617 | switch(pdg){ | |
a47a87c5 | 618 | case kElectron: return AliPID::kElectron; |
619 | case kMuonMinus: return AliPID::kMuon; | |
620 | case kPiPlus: return AliPID::kPion; | |
621 | case kKPlus: return AliPID::kKaon; | |
622 | case kProton: return AliPID::kProton; | |
fb09668f | 623 | } |
a47a87c5 | 624 | return -1; |
fb09668f | 625 | } |
626 | ||
1ee39b3a | 627 | //____________________________________________________________________ |
628 | void AliTRDcheckESD::Process(TH1 **h1, TGraphErrors *g) | |
629 | { | |
630 | // Generic function to process one reference plot | |
631 | ||
632 | Int_t n1 = 0, n2 = 0, ip=0; | |
633 | Double_t eff = 0.; | |
634 | ||
635 | TAxis *ax = h1[0]->GetXaxis(); | |
636 | for(Int_t ib=1; ib<=ax->GetNbins(); ib++){ | |
637 | if(!(n1 = (Int_t)h1[0]->GetBinContent(ib))) continue; | |
638 | n2 = (Int_t)h1[1]->GetBinContent(ib); | |
639 | eff = n2/Float_t(n1); | |
640 | ||
641 | ip=g->GetN(); | |
642 | g->SetPoint(ip, ax->GetBinCenter(ib), eff); | |
643 | g->SetPointError(ip, 0., n2 ? eff*TMath::Sqrt(1./n1+1./n2) : 0.); | |
644 | } | |
645 | } | |
629ae9b8 | 646 | //________________________________________________________ |
647 | void AliTRDcheckESD::Process2D(TH2 * const h2, TGraphErrors **g) | |
648 | { | |
649 | // | |
650 | // Do the processing | |
651 | // | |
1ee39b3a | 652 | |
629ae9b8 | 653 | Int_t n = 0; |
654 | if((n=g[0]->GetN())) for(;n--;) g[0]->RemovePoint(n); | |
655 | if((n=g[1]->GetN())) for(;n--;) g[1]->RemovePoint(n); | |
656 | TF1 f("fg", "gaus", -3.,3.); | |
657 | for(Int_t ibin = 1; ibin <= h2->GetNbinsX(); ibin++){ | |
658 | Double_t x = h2->GetXaxis()->GetBinCenter(ibin); | |
659 | TH1D *h = h2->ProjectionY("py", ibin, ibin); | |
660 | if(h->GetEntries()<100) continue; | |
661 | //AdjustF1(h, f); | |
662 | ||
663 | h->Fit(&f, "QN"); | |
664 | Int_t ip = g[0]->GetN(); | |
665 | g[0]->SetPoint(ip, x, f.GetParameter(1)); | |
666 | g[0]->SetPointError(ip, 0., f.GetParError(1)); | |
667 | g[1]->SetPoint(ip, x, f.GetParameter(2)); | |
668 | g[1]->SetPointError(ip, 0., f.GetParError(2)); | |
669 | } | |
670 | return; | |
671 | } | |
1ee39b3a | 672 | //____________________________________________________________________ |
673 | void AliTRDcheckESD::PrintStatus(ULong_t status) | |
674 | { | |
675 | // Dump track status to stdout | |
676 | ||
677 | printf("ITS[i(%d) o(%d) r(%d)] TPC[i(%d) o(%d) r(%d) p(%d)] TRD[i(%d) o(%d) r(%d) p(%d) s(%d)] HMPID[o(%d) p(%d)]\n" | |
678 | ,Bool_t(status & AliESDtrack::kITSin) | |
679 | ,Bool_t(status & AliESDtrack::kITSout) | |
680 | ,Bool_t(status & AliESDtrack::kITSrefit) | |
681 | ,Bool_t(status & AliESDtrack::kTPCin) | |
682 | ,Bool_t(status & AliESDtrack::kTPCout) | |
683 | ,Bool_t(status & AliESDtrack::kTPCrefit) | |
684 | ,Bool_t(status & AliESDtrack::kTPCpid) | |
685 | ,Bool_t(status & AliESDtrack::kTRDin) | |
686 | ,Bool_t(status & AliESDtrack::kTRDout) | |
687 | ,Bool_t(status & AliESDtrack::kTRDrefit) | |
688 | ,Bool_t(status & AliESDtrack::kTRDpid) | |
689 | ,Bool_t(status & AliESDtrack::kTRDStop) | |
690 | ,Bool_t(status & AliESDtrack::kHMPIDout) | |
691 | ,Bool_t(status & AliESDtrack::kHMPIDpid) | |
692 | ); | |
693 | } | |
694 |