]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDQADataMakerRec.cxx
- coverity fixes for unused but set variables in various places
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMakerRec.cxx
CommitLineData
04236e67 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/* $Id$ */
17
18////////////////////////////////////////////////////////////////////////////
19// //
20// Produces the data needed to calculate the quality assurance. //
21// All data must be mergeable objects. //
22// //
23// Author: //
24// Sylwester Radomski (radomski@physi.uni-heidelberg.de) //
25// //
26////////////////////////////////////////////////////////////////////////////
27
28// --- ROOT system ---
490b0b06 29#include <TClonesArray.h>
30#include <TFile.h>
92664bc8 31#include <TH1F.h>
32#include <TH2F.h>
33#include <TH3F.h>
04236e67 34#include <TProfile.h>
35#include <TF1.h>
490b0b06 36#include <TCanvas.h>
04236e67 37
38// --- AliRoot header files ---
39#include "AliESDEvent.h"
490b0b06 40#include "AliLog.h"
78328afd 41#include "AliRawReader.h"
04236e67 42#include "AliTRDcluster.h"
43#include "AliTRDQADataMakerRec.h"
490b0b06 44#include "AliTRDgeometry.h"
8df1f8f5 45#include "AliTRDrawStream.h"
c1eed4d3 46
490b0b06 47#include "AliTRDdigitsManager.h"
48#include "AliTRDSignalIndex.h"
49#include "AliTRDarrayADC.h"
50
51#include "AliQAChecker.h"
52
04236e67 53ClassImp(AliTRDQADataMakerRec)
54
55//____________________________________________________________________________
56 AliTRDQADataMakerRec::AliTRDQADataMakerRec() :
4e25ac79 57 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
04236e67 58{
59 //
60 // Default constructor
61}
62
63//____________________________________________________________________________
64AliTRDQADataMakerRec::AliTRDQADataMakerRec(const AliTRDQADataMakerRec& qadm) :
65 AliQADataMakerRec()
66{
67 //
68 // Copy constructor
69 //
70
71 SetName((const char*)qadm.GetName()) ;
72 SetTitle((const char*)qadm.GetTitle());
73
74}
75
76//__________________________________________________________________
77AliTRDQADataMakerRec& AliTRDQADataMakerRec::operator=(const AliTRDQADataMakerRec& qadm)
78{
79 //
80 // Equal operator.
81 //
82
83 this->~AliTRDQADataMakerRec();
84 new(this) AliTRDQADataMakerRec(qadm);
85 return *this;
86
87}
88
89//____________________________________________________________________________
4e25ac79 90void AliTRDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 91{
92 //
93 // Detector specific actions at end of cycle
94 //
743496f4 95 //TStopwatch watch;
96 //watch.Start();
92664bc8 97 ResetEventTrigClasses();
5379c4a3 98 AliDebug(AliQAv1::GetQADebugLevel(), "End of TRD cycle");
92664bc8 99 //
100 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // loop over event types
101 //
102 if (!IsValidEventSpecie(specie, list)) continue;
103 SetEventSpecie(AliRecoParam::ConvertIndex(specie));
104 //
105 for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class
106 //
107 if (task == AliQAv1::kRAWS) {
108 TH2 *mnCls = (TH2*)GetRawsData(1, itc);
109 TH2 *mClsDet = (TH2*)GetRawsData(2, itc);
110 if (mnCls && mClsDet) mClsDet->Divide(mnCls);
04236e67 111 }
92664bc8 112 //
113 if (task == AliQAv1::kRECPOINTS) {
114 //
115 TH1F * hist = new TH1F("fitHist", "", 200, -0.5, 199.5);
116 TObjArray& arrRP = *GetRecPointsDataOfTrigClass(itc); // RS Histos matching to trigger class
117 // fill detector map;
118 TH1* h0 = (TH1*) arrRP[0];
119 TH1* detMap = (TH1*) arrRP[87];
120 if (h0 && detMap) {
121 for(Int_t i = 0 ; i < 540 ; i++) {
122 Double_t v = h0->GetBinContent(i+1);
123 Int_t sm = i/30;
124 Int_t det = i%30;
125 Int_t bin = detMap->FindBin(sm, det);
126 detMap->SetBinContent(bin, v);
127 }
c1eed4d3 128 }
92664bc8 129 //
130 // Rec points full chambers
131 TH2* h2tmp = (TH2*) arrRP[1];
132 TH1* h12 = (TH1*) arrRP[12];
133 TH1* h13 = (TH1*) arrRP[13];
134 if (h2tmp && h12 && h13) {
135 for (Int_t i = 0 ; i < 540 ; i++) {
136 //AliDebug(AliQAv1::GetQADebugLevel(), Form("I = %d", i));
137 hist->Reset();
138 // project TH2F into TH1F
139 for(Int_t b = 1 ; b < hist->GetXaxis()->GetNbins()-1 ; b++) {
140 Double_t xvalue = hist->GetBinCenter(b);
141 Int_t bin = h2tmp->FindBin(i,xvalue);
142 Double_t value = h2tmp->GetBinContent(bin);
143 hist->SetBinContent(b, value);
144 }
145 //AliDebug(AliQAv1::GetQADebugLevel(), Form("Sum = %d %f\n", i, hist->GetSum()));
146 if (hist->GetSum() < 100) continue; // not enougth data in a chamber
147 //
148 hist->Fit("landau", "q0", "goff", 10, 180);
149 TF1 *fit = hist->GetFunction("landau");
150 h12->Fill(fit->GetParameter(1));
151 h13->Fill(fit->GetParameter(2));
c1eed4d3 152 }
c1eed4d3 153 }
92664bc8 154 //
155 // time-bin by time-bin sm by sm
156 TH3* h3tmp = (TH3*) arrRP[10];
157 if (h3tmp) {
158 for(Int_t i=0; i<18; i++) { // loop over super-modules
159 for(Int_t j=0; j<kTimeBin; j++) { // loop over time bins
160 hist->Reset();
161 for(Int_t b = 1 ; b < hist->GetXaxis()->GetNbins()-1 ; b++) {
162 Double_t xvalue = hist->GetBinCenter(b);
163 Double_t svalue = 0.0;
164 for(Int_t det = i*30 ; det < (i+1)*30 ; det++) { // loop over detectors
165 Int_t bin = h3tmp->FindBin(det,j,xvalue);
166 Double_t value = h3tmp->GetBinContent(bin);
167 svalue += value;
168 }
169 //AliDebug(AliQAv1::GetQADebugLevel(), Form("v = %f\n", value));
170 hist->SetBinContent(b, svalue);
171 }
172 //
173 if (hist->GetSum() < 100) continue;
174 //
175 hist->Fit("landau", "q0", "goff", 10, 180);
176 TF1 *fit = hist->GetFunction("landau");
177 //
178 TH1 *hi = (TH1*)arrRP[14+18+i];
179 if (!hi) continue;
180 hi->SetMarkerStyle(20);
181 Int_t bin = hi->FindBin(j);
182 // printf("%d %d %d\n", det, j, bin);
183 //
184 Double_t value = TMath::Abs(fit->GetParameter(1));
185 Double_t error = TMath::Abs(fit->GetParError(1));
186 //
187 if (value/error < 3) continue; // insuficient statistics
188 //
189 hi->SetBinContent(bin, value);
190 hi->SetBinError(bin, error);
191 } // j
192 } // i
193 //
194 // for numerical convergence
195 TF1 *form = new TF1("formLandau", "landau", 0, 200);
196 //
197 // time-bin by time-bin chamber by chamber
198 for (Int_t i=0; i<540; i++) {
199 for(Int_t j=0; j<kTimeBin; j++) {
200 //
201 hist->Reset();
202 for(Int_t b = 1 ; b < hist->GetXaxis()->GetNbins()-1 ; b++) {
203 Double_t xvalue = hist->GetBinCenter(b);
204 Int_t bin = h3tmp->FindBin(i,j,xvalue);
205 Double_t value = h3tmp->GetBinContent(bin);
206 //AliDebug(AliQAv1::GetQADebugLevel(), Form("v = %f\n", value));
207 hist->SetBinContent(b, value);
208 }
209 //
210 if (hist->GetSum() < 100) continue;
211
212 form->SetParameters(1000, 60, 20);
213 hist->Fit(form, "q0", "goff", 20, 180);
214
215 Int_t sm = i/30;
216 Int_t det = i%30;
217 TH1 *hi = (TH1*)arrRP[14+sm];
218 if (!hi) continue;
219 Int_t bin = hi->FindBin(det,j);
220 // printf("%d %d %d\n", det, j, bin);
221 //
222 Double_t value = TMath::Abs(form->GetParameter(1));
223 Double_t error = TMath::Abs(form->GetParError(1));
224 //
225 if (value/error < 3) continue;
226 //
227 hi->SetBinContent(bin, value);
228 hi->SetBinError(bin, error);
229 } // j
230 } // i
231 } // h3tmp
232 if (hist) delete hist;
233 } // RECPOINTS
234 //
235 //////////////////////////
236 // const Int_t knbits = 6;
237 // const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
238 //const char *sufRatio[4] = {"TRDrTRDo", "TRDoTPCo", "TRDrTPCo", "TRDzTPCo"};
239
240 if (task == AliQAv1::kESDS) {
241 //
242 const Int_t knRatio = 4;
243 const Int_t kN[knRatio] = {4,3,4,5};
244 const Int_t kD[knRatio] = {3,1,1,3};
245 //
246 TObjArray& arrES = *GetESDsDataOfTrigClass(itc); // RS Histos matching to trigger class
247 // create ratios
248 for(Int_t type = 0 ; type < 2 ; type++) {
249 for(Int_t i = 0 ; i < knRatio ; i++) {
250 TH1 *ratio = (TH1*)arrES[19 + 2*i + type];
251 TH1 *histN = (TH1*)arrES[3 + 2*kN[i] + type];
252 TH1 *histD = (TH1*)arrES[3 + 2*kD[i] + type];
253 if ( ! (ratio && histN && histD) ) continue;
254 BuildRatio(ratio, histN, histD);
255 //ratio->Reset();
256 //ratio->Add(histN);
257 //ratio->Divide(histD);
258 }
259 }
260 // ratio for the fraction of electrons per stack
261 TH1 *histN = (TH1*)arrES[33];
262 TH1 *histD = (TH1*)arrES[32];
263 TH1 *ratio = (TH1*)arrES[34];
264 BuildRatio(ratio, histN, histD);
265 } // ESDs
266 } // RS: loop over eventual clones per trigger class
267 } // loop over species
743496f4 268 // call the checker
4e25ac79 269 AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;
92664bc8 270 //
04236e67 271}
272
273//____________________________________________________________________________
274void AliTRDQADataMakerRec::InitESDs()
275{
276 //
277 // Create ESDs histograms in ESDs subdir
278 //
7d297381 279 const Bool_t expert = kTRUE ;
280 const Bool_t image = kTRUE ;
281
f5fd37e8 282 const Int_t kNhist = 36+5+4;
9b99c029 283
04236e67 284 TH1 *hist[kNhist];
285 Int_t histoCounter = -1 ;
286
92664bc8 287 hist[++histoCounter] = new TH1F("qaTRD_esd_ntracks", "TRD esd ntracks;Number of tracks;Counts", 300, -0.5, 299.5);
288 hist[++histoCounter] = new TH1F("qaTRD_esd_sector", "TRD esd sector;Sector;Counts", 18, -0.5, 17.7);
289 hist[++histoCounter] = new TH1F("qaTRD_esd_bits", "TRD esd bits;Bits;Counts", 64, -0.5, 63.5);
04236e67 290
291 const Int_t knbits = 6;
292 const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
293
743496f4 294 // histo = 3
295 for(Int_t i=0; i<knbits; i++) {
92664bc8 296 hist[++histoCounter] = new TH1F(Form("qaTRD_esd_pt%s",suf[i]), Form("qaTRD_esd_pt%s;p_{T} (GeV/c);Counts",suf[i]), 100, 0, 10);
297 hist[++histoCounter] = new TH1F(Form("qaTRD_esd_trdz%s", suf[i]), ";z (cm)", 200, -400, 400);
04236e67 298 }
299
92664bc8 300 hist[++histoCounter] = new TH1F("qaTRD_esd_clsTRDo", "TRDo;number of clusters;Counts", 180, -0.5, 179.5);;
301 hist[++histoCounter] = new TH1F("qaTRD_esd_clsTRDr", "TRDr;number of clusters;Counts", 180, -0.5, 179.5);;
302 hist[++histoCounter] = new TH1F("qaTRD_esd_clsTRDz", "TRDz;number of clusters;Counts", 180, -0.5, 179.5);;
303 //hist[++histoCounter] = new TH1F("qaTRD_esd_clsRatio", ";cluster ratio", 100, 0., 1.3);;
04236e67 304
92664bc8 305 hist[++histoCounter] = new TH2F("qaTRD_esd_sigMom", "TRD esd sig Mom;momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
04236e67 306
743496f4 307 // end of cycle plots (hist 19)
308 const char *sufRatio[4] = {"TRDrTRDo", "TRDoTPCo", "TRDrTPCo", "TRDzTPCo"};
309
310 for(int i=0; i<4; i++) {
92664bc8 311 hist[++histoCounter] = new TH1F(Form("qaTRD_esd_pt%s",sufRatio[i]),
743496f4 312 Form("Efficiency in Pt %s;p_{T};eff", sufRatio[i]),
313 100, 0, 10);
314
92664bc8 315 hist[++histoCounter] = new TH1F(Form("qaTRD_esd_trdz%s",sufRatio[i]),
743496f4 316 Form("Efficiency in Z %s;z (cm);eff", sufRatio[i]),
317 200, -400, 400);
318 }
319
9b99c029 320 // 27 - 31
92664bc8 321 hist[27] = new TH1F("qaTRD_esd_quality", "TRD esd quality;quality;Counts", 120, 0, 12);
322 hist[28] = new TH1F("qaTRD_esd_budget", "TRD esd budget;NN;Counts", 110, -1000, 100);
323 hist[29] = new TH1F("qaTRD_esd_chi2", "TRD esd chi2;chi2;Counts", 200, 0, 100);
324 hist[30] = new TH1F("qaTRD_esd_timeBin", "TRD esd timeBin;time bin;Counts", 7, -0.5, 6.5);
325 hist[31] = new TH1F("qaTRD_esd_pidQuality", "pid Quality;quality;;Counts", 7, -0.5, 6.5);
9b99c029 326
327 // stack by stack electron identyfication
92664bc8 328 hist[32] = new TH1F("qaTRD_esd_tracksStack", "number of all tracks;stack;Counts", 90, -0.5, 89.5);
329 hist[33] = new TH1F("qaTRD_esd_electronStack", "number of electron tracks;stack;Counts", 90, -0.5, 89.5);
330 hist[34] = new TH1F("qaTRD_esd_elRatioStack", "fraction of electron tracks;stack;Counts", 90, -0.5, 89.5);
331 hist[35] = new TH1F("qaTRD_esd_thetaOut", ";tan(theta);", 100, -1, 1);
9b99c029 332
333 const char *partType[5] = {"Electron", "Muon", "Pion", "Kaon", "Proton"};
334
335 for(Int_t i=0; i<AliPID::kSPECIES; i++)
92664bc8 336 hist[36+i] = new TH1F(Form("qaTRD_esd_pid%d",i),
db72ff3b 337 Form("%s;probability;Counts",partType[i]), 100, 0, 1);
9b99c029 338
f5fd37e8 339 // dE/dX vs momentum in three regions
340 const char *zoneName[4] = {"total charge", "ampilification range", "plateau", "TR range"};
341
342 // prepare the scale from 0.1 to 10 GeV
8e2f611a 343 const Int_t nscalex= 50;
344 Double_t scalex[nscalex+1];
345 Double_t dd = (TMath::Log(10) - TMath::Log(0.5)) / nscalex;
346 for(Int_t ix=0; ix<nscalex+1; ix++) {
f5fd37e8 347 scalex[ix] = 0.5 * TMath::Exp(dd * ix);
348 }
349
8e2f611a 350 const Int_t nscaley = 50;
351 Double_t scaley[nscaley+1];
352 for(Int_t iy=0; iy<nscaley+1; iy++) {
353 scaley[iy] = iy * (3e3/nscaley);
f5fd37e8 354 }
355
356
357 for(Int_t i=0; i<4; i++) {
92664bc8 358 hist[41+i] = new TH2F(Form("qaTRD_esd_signalPzone_%d",i),
db72ff3b 359 Form("%s;momentum (GeV/c);signal (a.u.)", zoneName[i]),
8e2f611a 360 nscalex, scalex, nscaley, scaley);
f5fd37e8 361 }
9b99c029 362
363 for(Int_t i=0; i<kNhist; i++) {
04236e67 364 //hist[i]->Sumw2();
7d297381 365 Add2ESDsList(hist[i], i, !expert, image);
04236e67 366 }
92664bc8 367 //
368 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
04236e67 369}
370
371//____________________________________________________________________________
372void AliTRDQADataMakerRec::InitRecPoints()
373{
374 //
375 // Create Reconstructed Points histograms in RecPoints subdir
376 //
7d297381 377 const Bool_t expert = kTRUE ;
378 const Bool_t image = kTRUE ;
379
c1eed4d3 380 //printf("Helo from Init rec points\n");
381
382 const Int_t kNhist = 14 + 4 * 18 + 2 + 9;// + 540;
04236e67 383 TH1 *hist[kNhist];
384
92664bc8 385 hist[0] = new TH1F("qaTRD_recPoints_det", "RRD recPoints det;Detector ID of the cluster;Counts", 540, -0.5, 539.5);
386 hist[1] = new TH2F("qaTRD_recPoints_amp", "TRD recPoints amp;Amplitude;??", 540, -0.5, 539, 200, -0.5, 199.5);
387 hist[2] = new TH1F("qaTRD_recPoints_npad", "TRD recPoints npad;Number of Pads;Counts", 12, -0.5, 11.5);
04236e67 388
92664bc8 389 hist[3] = new TH1F("qaTRD_recPoints_dist2", "TRD recPoints dist2;residuals [2pad];Counts", 100, -1, 1);
390 hist[4] = new TH1F("qaTRD_recPoints_dist3", "TRD recPoints dist3;residuals [3pad];Counts", 100, -1, 1);
391 hist[5] = new TH1F("qaTRD_recPoints_dist4", "TRD recPoints dist4;residuals [4pad];Counts", 100, -1, 1);
392 hist[6] = new TH1F("qaTRD_recPoints_dist5", "TRD recPoints dist5;residuals [5pad];Counts", 100, -1, 1);
04236e67 393
92664bc8 394 hist[7] = new TH2F("qaTRD_recPoints_rowCol", "TRDrecPointsrowCol;row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
395 hist[8] = new TH1F("qaTRD_recPoints_time", "TRDrecPoints time;time bin;Counts", kTimeBin, -0.5, kTimeBin-0.5);
396 hist[9] = new TH1F("qaTRD_recPoints_nCls", "TRD recPoints nCls;number of clusters;Counts", 500, -0.5, 499.5);
04236e67 397
92664bc8 398 hist[10] = new TH3F("qaTRD_recPoints_sigTime", "TRD recPoints sigTime;chamber;time bin;signal",
c1eed4d3 399 540, -0.5, 539.5, kTimeBin, -0.5, kTimeBin-0.5, 200, -0.5, 199.5);
db72ff3b 400 hist[11] = new TProfile("qaTRD_recPoints_prf", "TRD recPoints prf;distance;center of gravity;Counts"
04236e67 401 , 120, -0.6, 0.6, -1.2, 1.2, "");
402
92664bc8 403 hist[12] = new TH1F("qaTRD_recPoints_ampMPV", "TRD recPoints ampMPV;amplitude MPV;Counts", 150, 0, 150);
404 hist[13] = new TH1F("qaTRD_recPoints_ampSigma", "TRD recPoints ampSigma;amplitude Sigma;Counts", 200, 0, 200);
743496f4 405
9b99c029 406 // chamber by chamber
04236e67 407 for(Int_t i=0; i<18; i++) {
92664bc8 408 hist[14+i] = new TH2F(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin",i),
c1eed4d3 409 30, -0.5, 29.5, kTimeBin, -0.5, kTimeBin-0.5);
410 hist[14+i]->SetMinimum(0);
411 hist[14+i]->SetMaximum(150);
04236e67 412 }
743496f4 413
414 // time bin by time bin sm-by-sm
415 for(Int_t i=0; i<18; i++) {
92664bc8 416 hist[14+18+i] = new TH1F(Form("qaTRD_recPoints_sigTimeShape_sm%d", i),
20a6e9c2 417 Form("sm%d;time bin;signal",i),
c1eed4d3 418 kTimeBin, -0.5, kTimeBin-0.5);
9b99c029 419
c1eed4d3 420 hist[14+18+i]->SetMaximum(150);
743496f4 421 }
422
9b99c029 423 // str = 50
424 for(Int_t i=0; i<18; i++) {
92664bc8 425 hist[50+i] = new TH1F(Form("qaTRD_recPoints_nCls_sm%d",i),
9b99c029 426 Form("sm%d;time bin;number of clusters",i),
c1eed4d3 427 kTimeBin, -0.5, kTimeBin-0.5);
9b99c029 428 }
429
430 // str = 68
431 for(Int_t i=0; i<18; i++) {
92664bc8 432 hist[68+i] = new TH1F(Form("qaTRD_recPoints_totalCharge_sm%d", i),
9b99c029 433 Form("sm%d;time bin;total charge", i),
c1eed4d3 434 kTimeBin, -0.5, kTimeBin-0.5);
9b99c029 435 }
436
92664bc8 437 hist[86] = new TH1F("qaTRD_recPoints_signal", "TRD recPoints signal;amplitude;Counts", 400, -0.5, 399.5);
438 hist[87] = new TH2F("qaTRD_recPoints_detMap", "TRD recPoints detMap;sm;chamber;Counts", 18, -0.5, 17.5, 30, -0.5, 29.5);
743496f4 439
c1eed4d3 440
441 // amplitude as a function of the pad size
442 for(Int_t i=0; i<9; i++) {
92664bc8 443 hist[88+i] = new TH1F(Form("qaTRD_recPoints_signalNpad_%d", i+2), Form("qaTRD_recPoints_signalNpad_%d;amplitude, ADC", i+2), 400, -0.5, 399.5);
c1eed4d3 444 }
445
446 // one 2D histogram per chamber
447 // for(Int_t i=0; i<540; i++) {
92664bc8 448 // hist[88+i] = new TH2F(Form("qaTRD_recPoints_map%d", i), ";col;row", 16, -0.5, 15.5, 144, -0.5, 143.5);
c1eed4d3 449 //}
450
04236e67 451
452 for(Int_t i=0; i<kNhist; i++) {
453 //hist[i]->Sumw2();
7d297381 454 Add2RecPointsList(hist[i], i, !expert, image);
04236e67 455 }
92664bc8 456 //
457 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
04236e67 458}
459
460//____________________________________________________________________________
461void AliTRDQADataMakerRec::InitRaws()
462{
463 //
464 // create Raws histograms in Raws subdir
465 //
7d297381 466 const Bool_t expert = kTRUE ;
467 const Bool_t saveCorr = kTRUE ;
468 const Bool_t image = kTRUE ;
469
c1eed4d3 470 AliInfo("Initialization of QA for Raw Data");
490b0b06 471
472 const Int_t kNhist = 7;
c1eed4d3 473 TH1 *hist[kNhist];
474
92664bc8 475 hist[0] = new TH2F("qaTRD_raws_nADC","number of ADC channels;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
476 hist[1] = new TH2F("qaTRD_raws_nCls", "number of clusters;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
477 hist[2] = new TH2F("qaTRD_raws_meanSig", "mean signal;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
490b0b06 478
92664bc8 479 hist[3] = new TH1F("qaTRD_raws_ADC", "ADC amplitude;ADC counts", 100, -0.5, 99.5);
480 hist[4] = new TH1F("qaTRD_raws_Cls", "Cluster amplitude; ADC counts", 100, -0.5, 199.5);
481 hist[5] = new TH2F("qaTRD_raws_ClsTb", "Clusters vs Time Bin;time bin;amoplitude", 30, -0.5, 29.5, 200, -0.5, 199.5);
490b0b06 482
92664bc8 483 hist[6] = new TH2F("qaTRD_raws_ClsAmpDet", ";detector;amplitude", 540, -0.5, 539.5, 100, 0, 200);
490b0b06 484
04236e67 485
c1eed4d3 486 /*
92664bc8 487 hist[0] = new TH2F("qaTRD_raws_DataVolume", ";Sector;Data Volume, kB", 18, -0.5, 17.5, 100, 0, 30);
488 hist[1] = new TH2F("qaTRD_raws_HC", "Data Headers;Sector;HC", 18, -0.5, 17.5, 60, -0.5, 59.5);
489 hist[2] = new TH2F("qaTRD_raws_LME", "Link Monitor Error;Sector;HC", 18, -0.5, 17.5, 60, -0.5, 59.5);
490b0b06 490
92664bc8 491 hist[3] = new TH1F("qaTRD_rawd_cls", "Clusters amplitude;ADC counts", 100, 0, 200);
492 hist[4] = new TH2F("qaTRD_raws_clsTB", "amplitude - time bins;time bin;amplitude"
490b0b06 493 30, -0.5, 29.5, 100, 0, 200);
92664bc8 494 hist[5] = new TH2F("qaTRD_raws_clsSec", "amplitude in sectors;Sector;amplitude, ADCs"
490b0b06 495 18, -0.5, 17.5);
c1eed4d3 496 */
497
490b0b06 498
04236e67 499 // register
500 for(Int_t i=0; i<kNhist; i++) {
501 //hist[i]->Sumw2();
7d297381 502 Add2RawsList(hist[i], i, !expert, image, !saveCorr);
04236e67 503 }
92664bc8 504 //
505 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
04236e67 506}
507
508//____________________________________________________________________________
490b0b06 509void AliTRDQADataMakerRec::MakeESDs(AliESDEvent * esd)
04236e67 510{
511 //
512 // Make QA data from ESDs
513 //
eca4fa66 514
04236e67 515 Int_t nTracks = esd->GetNumberOfTracks();
92664bc8 516 FillESDsData(0,nTracks);
04236e67 517
518 // track loop
42a68282 519 for (Int_t iTrack = 0; iTrack<nTracks; iTrack++) {
04236e67 520
42a68282 521 AliESDtrack *track = esd->GetTrack(iTrack);
04236e67 522 const AliExternalTrackParam *paramOut = track->GetOuterParam();
523 const AliExternalTrackParam *paramIn = track->GetInnerParam();
524
525 // long track ..
526 if (!paramIn) continue;
527 if (!paramOut) continue;
528
529 // not a kink
530 if (track->GetKinkIndex(0) > 0) continue;
531
532 Double_t extZ = GetExtZ(paramIn);
533 if (TMath::Abs(extZ) > 320) continue; // acceptance cut
534
535 // .. in the acceptance
536 Int_t sector = GetSector(paramOut->GetAlpha());
9b99c029 537 Int_t stack = GetStack(paramOut);
04236e67 538
539 UInt_t u = 1;
540 UInt_t status = track->GetStatus();
541 for(Int_t bit=0; bit<32; bit++)
92664bc8 542 if (u<<bit & status) FillESDsData(2,bit);
04236e67 543
544 const Int_t knbits = 6;
545 Int_t bit[6] = {0,0,0,0,0,0};
546 bit[0] = status & AliESDtrack::kTPCin;
547 bit[1] = status & AliESDtrack::kTPCout;
548 bit[2] = (status & AliESDtrack::kTPCout) && !(status & AliESDtrack::kTRDout);
549 bit[3] = status & AliESDtrack::kTRDout;
550 bit[4] = status & AliESDtrack::kTRDrefit;
551 bit[5] = (status & AliESDtrack::kTRDout) && !(status & AliESDtrack::kTRDrefit);
552
553 // transverse momentum
554 //const Double_t *val = paramOut->GetParameter(); // parameters at the Outer plane
555 Double_t pt = paramOut->Pt(); //1./TMath::Abs(val[4]);
556
557 for(Int_t b=0; b<knbits; b++) {
558 if (bit[b]) {
92664bc8 559 FillESDsData(2*b+3,pt);
560 FillESDsData(2*b+4,extZ);
04236e67 561 }
562 }
563
564 // clusters
565 for(Int_t b=0; b<3; b++)
92664bc8 566 if (bit[3+b]) FillESDsData(b+15,track->GetTRDncls0());
04236e67 567
568 // refitted only
569 if (!bit[4]) continue;
570
571 //fQuality->Fill(track->GetTRDQuality());
572 //fBudget->Fill(track->GetTRDBudget());
573 //fSignal->Fill(track->GetTRDsignal());
9b99c029 574
92664bc8 575 FillESDsData(1,sector);
576 FillESDsData(18,track->GetP(), track->GetTRDsignal());
04236e67 577
92664bc8 578 FillESDsData(27,track->GetTRDQuality());
579 FillESDsData(28,track->GetTRDBudget());
580 FillESDsData(29,track->GetTRDchi2());
581 FillESDsData(30,track->GetTRDTimBin(0));
582 FillESDsData(31,track->GetTRDntrackletsPID());
9b99c029 583
f5fd37e8 584
585 // dedx
7bce990c 586 for(Int_t k=0; k<4; ++k) {
f5fd37e8 587 Double_t dedx = 0;
588 for(Int_t j=0; j<6; j++) {
7bce990c 589 dedx += track->GetTRDslice(j, k-1);
f5fd37e8 590 }
92664bc8 591 FillESDsData(41+k,paramOut->GetP(), dedx/6.);
f5fd37e8 592 }
593
9b99c029 594 // probabilities
595 if (status & AliESDtrack::kTRDpid) {
7bce990c 596 for(Int_t k=0; k<AliPID::kSPECIES; ++k)
92664bc8 597 FillESDsData(36+k,track->GetTRDpid(k));
9b99c029 598 }
599
600 // probabilities uniformity
ed15ef4f 601 if (track->GetTRDntrackletsPID() < 6) continue;
92664bc8 602 FillESDsData(35,paramOut->GetZ()/paramOut->GetX());
9b99c029 603
604 Int_t idx = 5 * sector + stack;
92664bc8 605 FillESDsData(32,idx); // all tracks
9b99c029 606 if (track->GetTRDpid(AliPID::kElectron) > 0.9)
92664bc8 607 FillESDsData(33,idx); // electrons only
9b99c029 608
609
610
611 /*
92664bc8 612 hist[27] = new TH1F("qaTRD_esd_quality", ";quality", 120, 0, 12);
613 hist[28] = new TH1F("qaTRD_esd_budget", ";NN", 110, -1000, 100);
614 hist[29] = new TH1F("qaTRD_esd_chi2", ";chi2", 300, 0, 100);
615 hist[30] = new TH1F("qaTRD_esd_timeBin", 7, -0.5, 6.5);
616 hist[31] = new TH1F("qaTRD_esd_pidQuality", 7, -0.5, 6.5);
9b99c029 617 */
618
04236e67 619 /*
620 // PID only
621 if (status & AliESDtrack::kTRDpid) {
622
623 for(Int_t l=0; l<6; l++) fTime->Fill(track->GetTRDTimBin(l));
624
625 // fill pid histograms
626 Double_t trdr0 = 0; //, tpcr0 = 0;
627 Int_t trdBestPid = 5; //, tpcBestPid = 5; // charged
628 const Double_t kminPidValue = 0.9;
629
630 //Double_t pp[5];
631 //track->GetTPCpid(pp); // ESD inconsequence
632
633 for(Int_t pid=0; pid<5; pid++) {
634
635 trdr0 += track->GetTRDpid(pid);
636 //tpcr0 += pp[pid];
637
638 fTrdPID[pid]->Fill(track->GetTRDpid(pid));
639 //fTpcPID[pid]->Fill(pp[pid]);
640
641 if (track->GetTRDpid(pid) > kminPidValue) trdBestPid = pid;
642 //if (pp[pid] > kminPidValue) tpcBestPid = pid;
643 }
644
645 fTrdPID[5]->Fill(trdr0); // check unitarity
646 fTrdSigMomPID[trdBestPid]->Fill(track->GetP(), track->GetTRDsignal());
647
648 //fTpcPID[5]->Fill(tpcr0); // check unitarity
649 //fTpcSigMomPID[tpcBestPid]->Fill(track->GetP(), track->GetTPCsignal());
650 }
651 */
652
653 }
92664bc8 654 //
655 IncEvCountCycleESDs();
656 IncEvCountTotalESDs();
657 //
04236e67 658}
659
660//______________________________________________________________________________
9b99c029 661Int_t AliTRDQADataMakerRec::GetSector(Double_t alpha) const
04236e67 662{
663 //
664 // Gets the sector number
665 //
666
667 Double_t size = TMath::DegToRad() * 20.; // shall use TRDgeo
9b99c029 668 if (alpha < 0) alpha += 2*TMath::Pi();
669 Int_t sector = (Int_t)(alpha/size);
04236e67 670 return sector;
671
672}
9b99c029 673//______________________________________________________________________________
674
675Int_t AliTRDQADataMakerRec::GetStack(const AliExternalTrackParam *paramOut) const
676{
677 //
678 // calculates the stack the track is in
679 //
680
490b0b06 681 const Double_t L = -0.9;
682 const Double_t W = (2*L)/5;
9b99c029 683
684 Double_t tan = paramOut->GetZ() / paramOut->GetX();
490b0b06 685 Double_t pos = (tan - L) / W;
9b99c029 686 return (Int_t) pos;
687}
04236e67 688
689//______________________________________________________________________________
690Double_t AliTRDQADataMakerRec::GetExtZ(const AliExternalTrackParam *in) const
691{
692 //
693 // Returns the Z position at the entry to TRD
694 // using parameters from the TPC in
695 //
696
697 const Double_t kX0 = 300;
698
699 Double_t x = in->GetX();
700 const Double_t *par = in->GetParameter();
701 Double_t theta = par[3];
702 Double_t z = in->GetZ();
703
704 Double_t zz = z + (kX0-x) * TMath::Tan(theta);
705 return zz;
706
707}
708
709//____________________________________________________________________________
710void AliTRDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
711{
712 //
713 // Makes QA data from raw data
714 //
490b0b06 715
716 AliInfo("Making QA for Raws");
717
92664bc8 718 // take histograms (RS: arrays of histos)
719 static TObjArray mnADC,mnCls,mClsDet,mADC,mCls,mClsTb,mClsDetAmp;
720 GetMatchingRawsData(0,&mnADC);
721 GetMatchingRawsData(1,&mnCls);
722 GetMatchingRawsData(2,&mClsDet);
723 GetMatchingRawsData(3,&mADC);
724 GetMatchingRawsData(4,&mCls);
725 GetMatchingRawsData(5,&mClsTb);
726 GetMatchingRawsData(6,&mClsDetAmp);
c1eed4d3 727
490b0b06 728 const Int_t baseline = 10;
729
490b0b06 730 // configure the reader
c1eed4d3 731 rawReader->Reset();
732 rawReader->SelectEquipment(0, 1024, 1041);
733 rawReader->Select("TRD");
c1eed4d3 734
8df1f8f5 735 AliTRDrawStream *data = new AliTRDrawStream(rawReader);
c1eed4d3 736
490b0b06 737 // build data manager
738 AliTRDdigitsManager *digitsManager;
739 digitsManager = new AliTRDdigitsManager(kTRUE);
740 digitsManager->CreateArrays();
c1eed4d3 741
490b0b06 742 // error container
743 const UShort_t kErrorChmb = 1411;
744 UShort_t **fErrorContainer = new UShort_t *[2];
745 fErrorContainer[0] = new UShort_t[kErrorChmb];
746 fErrorContainer[1] = new UShort_t[kErrorChmb];
747
748 Int_t det = 0;
749 Int_t row, col;
c1eed4d3 750
490b0b06 751 while ((det = data->NextChamber(digitsManager, NULL, fErrorContainer)) >= 0){
c1eed4d3 752
490b0b06 753 //printf("DET = %d\n", det);
c1eed4d3 754
490b0b06 755 AliTRDSignalIndex* indexes = digitsManager->GetIndexes(det);
756 if (indexes->HasEntry()) {
c1eed4d3 757
490b0b06 758 AliTRDarrayADC *digits = (AliTRDarrayADC*) digitsManager->GetDigits(det);
c1eed4d3 759
490b0b06 760 while(indexes->NextRCIndex(row, col)) {
761
92664bc8 762 for (int ih=mnADC.GetEntriesFast();ih--;) ((TH2*)mnADC.UncheckedAt(ih))->Fill(det/30, det%30);
c1eed4d3 763
490b0b06 764 for(Int_t tb = 0; tb < digits->GetNtime(); tb++) {
765 Int_t value = digits->GetData(row, col, tb);
92664bc8 766 for (int ih=mADC.GetEntriesFast();ih--;) ((TH1*)mADC.UncheckedAt(ih))->Fill(value);
490b0b06 767
768 // simple clusterizer
48189aa6 769 if (col < 1 || col > digits->GetNcol()-2) continue;
770 if (tb < 1 || tb > digits->GetNtime()-2) continue;
490b0b06 771
772 value -= baseline;
c1eed4d3 773
490b0b06 774 Int_t valueL = digits->GetData(row, col-1, tb) - baseline;
775 if (valueL >= value) continue;
776
777 Int_t valueR = digits->GetData(row, col+1, tb) - baseline;
778 if (valueR >= value) continue;
779
780 Int_t valueUp = digits->GetData(row, col-1, tb+1) +
781 digits->GetData(row, col, tb+1) + digits->GetData(row, col+1, tb+1) - 3 * baseline;
782 if (valueUp < 10) continue;
783
784 Int_t valueDown = digits->GetData(row, col-1, tb-1) +
785 digits->GetData(row, col, tb-1) + digits->GetData(row, col+1, tb-1) - 3 * baseline;
786 if (valueDown < 10) continue;
c1eed4d3 787
490b0b06 788 Int_t valueTot = value + valueL + valueR;
789 if (valueTot < 0) continue;
790
92664bc8 791 for (int ih=mCls.GetEntriesFast();ih--;) ((TH1*)mCls.UncheckedAt(ih))->Fill(valueTot);
792 for (int ih=mClsTb.GetEntriesFast();ih--;) ((TH2*)mClsTb.UncheckedAt(ih))->Fill(tb, valueTot);
793 for (int ih=mClsDetAmp.GetEntriesFast();ih--;) ((TH2*)mClsDetAmp.UncheckedAt(ih))->Fill(det, valueTot);
490b0b06 794
795 if (valueTot < 200) {
92664bc8 796 for (int ih=mnCls.GetEntriesFast();ih--;) ((TH2*)mnCls.UncheckedAt(ih))->Fill(det/30, det%30);
797 for (int ih=mClsDet.GetEntriesFast();ih--;) ((TH2*)mClsDet.UncheckedAt(ih))->Fill(det/30, det%30, valueTot);
c1eed4d3 798 }
490b0b06 799
800 }
c1eed4d3 801 }
c1eed4d3 802
490b0b06 803 digitsManager->ClearArrays(det); // do we need this if object will be deleted ??
804 }
c1eed4d3 805 }
806
2f9bdd85 807 delete [] fErrorContainer[0];
808 delete [] fErrorContainer[1];
809 delete [] fErrorContainer;
810 fErrorContainer = NULL;
490b0b06 811
812 delete digitsManager;
813 delete data;
92664bc8 814 //
815 IncEvCountCycleRaws();
816 IncEvCountTotalRaws();
817 //
44ed7a66 818}
819
04236e67 820//____________________________________________________________________________
821void AliTRDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
822{
823 //
824 // Makes data from RecPoints
825 //
743496f4 826
827 // Info("MakeRecPoints", "making");
6252ceeb 828
04236e67 829 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
830 TObjArray *clusterArray = new TObjArray(nsize+1000);
831
832 TBranch *branch = clustersTree->GetBranch("TRDcluster");
833 if (!branch) {
834 AliError("Can't get the branch !");
835 return;
836 }
837 branch->SetAddress(&clusterArray);
838
839 // Loop through all entries in the tree
c1eed4d3 840 Int_t nEntries = (Int_t)TMath::Ceil( clustersTree->GetEntries() );
04236e67 841 Int_t nbytes = 0;
842 AliTRDcluster *c = 0;
843 Int_t nDet[540];
844 for (Int_t i=0; i<540; i++) nDet[i] = 0;
845
c1eed4d3 846 Int_t nCls = 0;
847
848 //printf("nEntries = %d\n", nEntries);
849 //nEntries++;
850
851 /*
852 // select the event
853 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
854
855 // Import the tree
856 nbytes += clustersTree->GetEvent(iEntry);
857 Int_t nCluster = clusterArray->GetEntries();
858
859 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
860 c = (AliTRDcluster *) clusterArray->At(iCluster);
861 nCls++;
862 }
863 }
864
865 if (nCls < 100) {
866 delete clusterArray;
867 return;
868 }
869 */
870
871 /////
92664bc8 872 TObjArray *hists3D = GetMatchingRecPointsData(10); //RS no alias for 3d histo filling, to directly
873 //
04236e67 874 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
875
876 // Import the tree
877 nbytes += clustersTree->GetEvent(iEntry);
878
879 // Get the number of points in the detector
c1eed4d3 880 Int_t nCluster = clusterArray->GetEntries();
04236e67 881
c1eed4d3 882
04236e67 883 // Loop through all TRD digits
884 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
c1eed4d3 885
886 nCls++;
887 c = (AliTRDcluster *) clusterArray->At(iCluster);
04236e67 888
889 Int_t iDet = c->GetDetector();
c1eed4d3 890 Int_t nPads = c->GetNPads();
891
04236e67 892 nDet[iDet]++;
92664bc8 893 FillRecPointsData(0,iDet);
894 FillRecPointsData(86,c->GetQ());
895 FillRecPointsData(1,iDet, c->GetQ());
896 FillRecPointsData(2,nPads);
c1eed4d3 897 if (nPads < 6)
92664bc8 898 FillRecPointsData(1+c->GetNPads(),c->GetCenter());
c1eed4d3 899
900 if (nPads < 10)
92664bc8 901 FillRecPointsData(88+nPads-2,c->GetQ());
902 else FillRecPointsData(96,c->GetQ());
04236e67 903
904 //if (c->GetPadTime() < 5)
92664bc8 905 FillRecPointsData(7,c->GetPadRow(), c->GetPadCol());
906 FillRecPointsData(8,c->GetPadTime());
907 //
a5ef5a9a 908 if (hists3D) {
909 for (int ih=hists3D->GetEntriesFast();ih--;) {
910 TH3F * ahist = dynamic_cast<TH3F*>(hists3D->At(ih));
911 if (ahist) ahist->Fill(iDet, c->GetPadTime(), c->GetQ());
912 }
913 }
9b99c029 914
915 Int_t iSM = iDet / 30;
92664bc8 916 FillRecPointsData(50+iSM,c->GetPadTime());
917 FillRecPointsData(68+iSM,c->GetPadTime(), c->GetQ());
c1eed4d3 918
919 // total charge sm / det / timeBin
92664bc8 920 // FillRecPointsData(14+iSM,iDet-iSM*30, c->GetPadTime(), c->GetQ());
c1eed4d3 921
04236e67 922
923 // PRF for 2pad
924 //if (c->GetNPads() == 2) {
925 Short_t *sig = c->GetSignals();
926 Double_t frac = -10;
927
928 if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0)
929 frac = 1. * sig[4] / (sig[3] + sig[4]);
930
931 if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0)
932 frac = -1. * sig[2] / (sig[2] + sig[3]);
933
92664bc8 934 if (frac > -10) FillRecPointsData(11,c->GetCenter(), frac);
04236e67 935
936 //}
937 }
142373a6 938 clusterArray->Delete();
04236e67 939 }
940
c1eed4d3 941 /*
04236e67 942 for(Int_t i=0; i<540; i++)
92664bc8 943 if (nDet[i] > 0) FillRecPointsData(9,nDet[i]);
c1eed4d3 944 */
92664bc8 945 FillRecPointsData(9,nCls);
c1eed4d3 946
04236e67 947 delete clusterArray;
92664bc8 948 //
949 IncEvCountCycleRecPoints();
950 IncEvCountTotalRecPoints();
951 //
04236e67 952}
953
954//____________________________________________________________________________
955void AliTRDQADataMakerRec::StartOfDetectorCycle()
956{
957 //
958 // Detector specific actions at start of cycle
959 //
960
961}
962
963//__________________________________________________________________________
490b0b06 964Int_t AliTRDQADataMakerRec::CheckPointer(TObject *obj, const char *name)
04236e67 965{
966 //
967 // Checks initialization of pointers
968 //
969
970 if (!obj) AliWarning(Form("null pointer: %s", name));
971 return !!obj;
743496f4 972}
973//__________________________________________________________________________
92664bc8 974void AliTRDQADataMakerRec::BuildRatio(TH1 *ratio, TH1 *histN, TH1* histD) {
743496f4 975 //
976 // Calculate the ratio of two histograms
977 // error are calculated assuming the histos have the same counts
978 //
04236e67 979
743496f4 980 // calclate
981
982 Int_t nbins = histN->GetXaxis()->GetNbins();
983 for(Int_t i=1; i<nbins+2; i++) {
984
985 Double_t valueN = histN->GetBinContent(i);
986 Double_t valueD = histD->GetBinContent(i);
987
988 if (valueD < 1) {
989 ratio->SetBinContent(i, 0);
990 ratio->SetBinError(i, 0);
991 continue;
992 }
993
994 Double_t eps = (valueN < valueD-valueN)? valueN : valueD-valueN;
995
996 ratio->SetBinContent(i, valueN/valueD);
997 ratio->SetBinError(i, TMath::Sqrt(eps)/valueD);
998 }
999
1000 // style
1001 ratio->SetMinimum(-0.1);
1002 ratio->SetMaximum(1.1);
1003 ratio->SetMarkerStyle(20);
04236e67 1004}
4f5f1ae2 1005//__________________________________________________________________________
490b0b06 1006
92664bc8 1007Int_t AliTRDQADataMakerRec::FillBits(TH1F *hist, Int_t code, Int_t offset) {
c1eed4d3 1008
1009 Int_t nb = 0;
1010 UInt_t test = 1;
1011 for(Int_t i=0; i<8; i++) {
1012 if (code & test) {
1013 hist->Fill(i+offset);
1014 nb++;
1015 }
1016 test *= 2;
1017 }
1018
1019 return nb;
1020}
1021
1022//__________________________________________________________________________