1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Produces the data needed to calculate the quality assurance. //
21 // All data must be mergeable objects. //
24 // Sylwester Radomski (radomski@physi.uni-heidelberg.de) //
26 ////////////////////////////////////////////////////////////////////////////
28 // --- ROOT system ---
29 #include <TClonesArray.h>
38 // --- AliRoot header files ---
39 #include "AliESDEvent.h"
41 #include "AliRawReader.h"
42 #include "AliTRDcluster.h"
43 #include "AliTRDQADataMakerRec.h"
44 #include "AliTRDgeometry.h"
45 #include "AliTRDrawStream.h"
47 #include "AliTRDdigitsManager.h"
48 #include "AliTRDSignalIndex.h"
49 #include "AliTRDarrayADC.h"
51 #include "AliQAChecker.h"
53 ClassImp(AliTRDQADataMakerRec)
55 //____________________________________________________________________________
56 AliTRDQADataMakerRec::AliTRDQADataMakerRec() :
57 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
60 // Default constructor
63 //____________________________________________________________________________
64 AliTRDQADataMakerRec::AliTRDQADataMakerRec(const AliTRDQADataMakerRec& qadm) :
71 SetName((const char*)qadm.GetName()) ;
72 SetTitle((const char*)qadm.GetTitle());
76 //__________________________________________________________________
77 AliTRDQADataMakerRec& AliTRDQADataMakerRec::operator=(const AliTRDQADataMakerRec& qadm)
83 this->~AliTRDQADataMakerRec();
84 new(this) AliTRDQADataMakerRec(qadm);
89 //____________________________________________________________________________
90 void AliTRDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
93 // Detector specific actions at end of cycle
97 ResetEventTrigClasses();
98 AliDebug(AliQAv1::GetQADebugLevel(), "End of TRD cycle");
100 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { // loop over event types
102 if (!IsValidEventSpecie(specie, list)) continue;
103 SetEventSpecie(AliRecoParam::ConvertIndex(specie));
105 for (int itc=-1;itc<GetNTrigClasses();itc++) { // RS: loop over eventual clones per trigger class
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);
113 if (task == AliQAv1::kRECPOINTS) {
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];
121 for(Int_t i = 0 ; i < 540 ; i++) {
122 Double_t v = h0->GetBinContent(i+1);
125 Int_t bin = detMap->FindBin(sm, det);
126 detMap->SetBinContent(bin, v);
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));
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);
145 //AliDebug(AliQAv1::GetQADebugLevel(), Form("Sum = %d %f\n", i, hist->GetSum()));
146 if (hist->GetSum() < 100) continue; // not enougth data in a chamber
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));
155 // time-bin by time-bin sm by sm
156 TH3* h3tmp = (TH3*) arrRP[10];
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
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);
169 //AliDebug(AliQAv1::GetQADebugLevel(), Form("v = %f\n", value));
170 hist->SetBinContent(b, svalue);
173 if (hist->GetSum() < 100) continue;
175 hist->Fit("landau", "q0", "goff", 10, 180);
176 TF1 *fit = hist->GetFunction("landau");
178 TH1 *hi = (TH1*)arrRP[14+18+i];
180 hi->SetMarkerStyle(20);
181 Int_t bin = hi->FindBin(j);
182 // printf("%d %d %d\n", det, j, bin);
184 Double_t value = TMath::Abs(fit->GetParameter(1));
185 Double_t error = TMath::Abs(fit->GetParError(1));
187 if (value/error < 3) continue; // insuficient statistics
189 hi->SetBinContent(bin, value);
190 hi->SetBinError(bin, error);
194 // for numerical convergence
195 TF1 *form = new TF1("formLandau", "landau", 0, 200);
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++) {
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);
210 if (hist->GetSum() < 100) continue;
212 form->SetParameters(1000, 60, 20);
213 hist->Fit(form, "q0", "goff", 20, 180);
217 TH1 *hi = (TH1*)arrRP[14+sm];
219 Int_t bin = hi->FindBin(det,j);
220 // printf("%d %d %d\n", det, j, bin);
222 Double_t value = TMath::Abs(form->GetParameter(1));
223 Double_t error = TMath::Abs(form->GetParError(1));
225 if (value/error < 3) continue;
227 hi->SetBinContent(bin, value);
228 hi->SetBinError(bin, error);
232 if (hist) delete hist;
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"};
240 if (task == AliQAv1::kESDS) {
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};
246 TObjArray& arrES = *GetESDsDataOfTrigClass(itc); // RS Histos matching to trigger class
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);
257 //ratio->Divide(histD);
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);
266 } // RS: loop over eventual clones per trigger class
267 } // loop over species
269 AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;
273 //____________________________________________________________________________
274 void AliTRDQADataMakerRec::InitESDs()
277 // Create ESDs histograms in ESDs subdir
279 const Bool_t expert = kTRUE ;
280 const Bool_t image = kTRUE ;
282 const Int_t kNhist = 36+5+4;
285 Int_t histoCounter = -1 ;
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);
291 const Int_t knbits = 6;
292 const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
295 for(Int_t i=0; i<knbits; i++) {
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);
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);;
305 hist[++histoCounter] = new TH2F("qaTRD_esd_sigMom", "TRD esd sig Mom;momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
307 // end of cycle plots (hist 19)
308 const char *sufRatio[4] = {"TRDrTRDo", "TRDoTPCo", "TRDrTPCo", "TRDzTPCo"};
310 for(int i=0; i<4; i++) {
311 hist[++histoCounter] = new TH1F(Form("qaTRD_esd_pt%s",sufRatio[i]),
312 Form("Efficiency in Pt %s;p_{T};eff", sufRatio[i]),
315 hist[++histoCounter] = new TH1F(Form("qaTRD_esd_trdz%s",sufRatio[i]),
316 Form("Efficiency in Z %s;z (cm);eff", sufRatio[i]),
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);
327 // stack by stack electron identyfication
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);
333 const char *partType[5] = {"Electron", "Muon", "Pion", "Kaon", "Proton"};
335 for(Int_t i=0; i<AliPID::kSPECIES; i++)
336 hist[36+i] = new TH1F(Form("qaTRD_esd_pid%d",i),
337 Form("%s;probability;Counts",partType[i]), 100, 0, 1);
339 // dE/dX vs momentum in three regions
340 const char *zoneName[4] = {"total charge", "ampilification range", "plateau", "TR range"};
342 // prepare the scale from 0.1 to 10 GeV
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++) {
347 scalex[ix] = 0.5 * TMath::Exp(dd * ix);
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);
357 for(Int_t i=0; i<4; i++) {
358 hist[41+i] = new TH2F(Form("qaTRD_esd_signalPzone_%d",i),
359 Form("%s;momentum (GeV/c);signal (a.u.)", zoneName[i]),
360 nscalex, scalex, nscaley, scaley);
363 for(Int_t i=0; i<kNhist; i++) {
365 Add2ESDsList(hist[i], i, !expert, image);
368 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
371 //____________________________________________________________________________
372 void AliTRDQADataMakerRec::InitRecPoints()
375 // Create Reconstructed Points histograms in RecPoints subdir
377 const Bool_t expert = kTRUE ;
378 const Bool_t image = kTRUE ;
380 //printf("Helo from Init rec points\n");
382 const Int_t kNhist = 14 + 4 * 18 + 2 + 9;// + 540;
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);
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);
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);
398 hist[10] = new TH3F("qaTRD_recPoints_sigTime", "TRD recPoints sigTime;chamber;time bin;signal",
399 540, -0.5, 539.5, kTimeBin, -0.5, kTimeBin-0.5, 200, -0.5, 199.5);
400 hist[11] = new TProfile("qaTRD_recPoints_prf", "TRD recPoints prf;distance;center of gravity;Counts"
401 , 120, -0.6, 0.6, -1.2, 1.2, "");
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);
406 // chamber by chamber
407 for(Int_t i=0; i<18; i++) {
408 hist[14+i] = new TH2F(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin",i),
409 30, -0.5, 29.5, kTimeBin, -0.5, kTimeBin-0.5);
410 hist[14+i]->SetMinimum(0);
411 hist[14+i]->SetMaximum(150);
414 // time bin by time bin sm-by-sm
415 for(Int_t i=0; i<18; i++) {
416 hist[14+18+i] = new TH1F(Form("qaTRD_recPoints_sigTimeShape_sm%d", i),
417 Form("sm%d;time bin;signal",i),
418 kTimeBin, -0.5, kTimeBin-0.5);
420 hist[14+18+i]->SetMaximum(150);
424 for(Int_t i=0; i<18; i++) {
425 hist[50+i] = new TH1F(Form("qaTRD_recPoints_nCls_sm%d",i),
426 Form("sm%d;time bin;number of clusters",i),
427 kTimeBin, -0.5, kTimeBin-0.5);
431 for(Int_t i=0; i<18; i++) {
432 hist[68+i] = new TH1F(Form("qaTRD_recPoints_totalCharge_sm%d", i),
433 Form("sm%d;time bin;total charge", i),
434 kTimeBin, -0.5, kTimeBin-0.5);
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);
441 // amplitude as a function of the pad size
442 for(Int_t i=0; i<9; i++) {
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);
446 // one 2D histogram per chamber
447 // for(Int_t i=0; i<540; i++) {
448 // hist[88+i] = new TH2F(Form("qaTRD_recPoints_map%d", i), ";col;row", 16, -0.5, 15.5, 144, -0.5, 143.5);
452 for(Int_t i=0; i<kNhist; i++) {
454 Add2RecPointsList(hist[i], i, !expert, image);
457 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
460 //____________________________________________________________________________
461 void AliTRDQADataMakerRec::InitRaws()
464 // create Raws histograms in Raws subdir
466 const Bool_t expert = kTRUE ;
467 const Bool_t saveCorr = kTRUE ;
468 const Bool_t image = kTRUE ;
470 AliInfo("Initialization of QA for Raw Data");
472 const Int_t kNhist = 7;
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);
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);
483 hist[6] = new TH2F("qaTRD_raws_ClsAmpDet", ";detector;amplitude", 540, -0.5, 539.5, 100, 0, 200);
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);
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"
493 30, -0.5, 29.5, 100, 0, 200);
494 hist[5] = new TH2F("qaTRD_raws_clsSec", "amplitude in sectors;Sector;amplitude, ADCs"
500 for(Int_t i=0; i<kNhist; i++) {
502 Add2RawsList(hist[i], i, !expert, image, !saveCorr);
505 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
508 //____________________________________________________________________________
509 void AliTRDQADataMakerRec::MakeESDs(AliESDEvent * esd)
512 // Make QA data from ESDs
515 Int_t nTracks = esd->GetNumberOfTracks();
516 FillESDsData(0,nTracks);
519 for (Int_t iTrack = 0; iTrack<nTracks; iTrack++) {
521 AliESDtrack *track = esd->GetTrack(iTrack);
522 const AliExternalTrackParam *paramOut = track->GetOuterParam();
523 const AliExternalTrackParam *paramIn = track->GetInnerParam();
526 if (!paramIn) continue;
527 if (!paramOut) continue;
530 if (track->GetKinkIndex(0) > 0) continue;
532 Double_t extZ = GetExtZ(paramIn);
533 if (TMath::Abs(extZ) > 320) continue; // acceptance cut
535 // .. in the acceptance
536 Int_t sector = GetSector(paramOut->GetAlpha());
537 Int_t stack = GetStack(paramOut);
540 UInt_t status = track->GetStatus();
541 for(Int_t bit=0; bit<32; bit++)
542 if (u<<bit & status) FillESDsData(2,bit);
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);
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]);
557 for(Int_t b=0; b<knbits; b++) {
559 FillESDsData(2*b+3,pt);
560 FillESDsData(2*b+4,extZ);
565 for(Int_t b=0; b<3; b++)
566 if (bit[3+b]) FillESDsData(b+15,track->GetTRDncls0());
569 if (!bit[4]) continue;
571 //fQuality->Fill(track->GetTRDQuality());
572 //fBudget->Fill(track->GetTRDBudget());
573 //fSignal->Fill(track->GetTRDsignal());
575 FillESDsData(1,sector);
576 FillESDsData(18,track->GetP(), track->GetTRDsignal());
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());
586 for(Int_t k=0; k<4; ++k) {
588 for(Int_t j=0; j<6; j++) {
589 dedx += track->GetTRDslice(j, k-1);
591 FillESDsData(41+k,paramOut->GetP(), dedx/6.);
595 if (status & AliESDtrack::kTRDpid) {
596 for(Int_t k=0; k<AliPID::kSPECIES; ++k)
597 FillESDsData(36+k,track->GetTRDpid(k));
600 // probabilities uniformity
601 if (track->GetTRDntrackletsPID() < 6) continue;
602 FillESDsData(35,paramOut->GetZ()/paramOut->GetX());
604 Int_t idx = 5 * sector + stack;
605 FillESDsData(32,idx); // all tracks
606 if (track->GetTRDpid(AliPID::kElectron) > 0.9)
607 FillESDsData(33,idx); // electrons only
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);
621 if (status & AliESDtrack::kTRDpid) {
623 for(Int_t l=0; l<6; l++) fTime->Fill(track->GetTRDTimBin(l));
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;
631 //track->GetTPCpid(pp); // ESD inconsequence
633 for(Int_t pid=0; pid<5; pid++) {
635 trdr0 += track->GetTRDpid(pid);
638 fTrdPID[pid]->Fill(track->GetTRDpid(pid));
639 //fTpcPID[pid]->Fill(pp[pid]);
641 if (track->GetTRDpid(pid) > kminPidValue) trdBestPid = pid;
642 //if (pp[pid] > kminPidValue) tpcBestPid = pid;
645 fTrdPID[5]->Fill(trdr0); // check unitarity
646 fTrdSigMomPID[trdBestPid]->Fill(track->GetP(), track->GetTRDsignal());
648 //fTpcPID[5]->Fill(tpcr0); // check unitarity
649 //fTpcSigMomPID[tpcBestPid]->Fill(track->GetP(), track->GetTPCsignal());
655 IncEvCountCycleESDs();
656 IncEvCountTotalESDs();
660 //______________________________________________________________________________
661 Int_t AliTRDQADataMakerRec::GetSector(Double_t alpha) const
664 // Gets the sector number
667 Double_t size = TMath::DegToRad() * 20.; // shall use TRDgeo
668 if (alpha < 0) alpha += 2*TMath::Pi();
669 Int_t sector = (Int_t)(alpha/size);
673 //______________________________________________________________________________
675 Int_t AliTRDQADataMakerRec::GetStack(const AliExternalTrackParam *paramOut) const
678 // calculates the stack the track is in
681 const Double_t L = -0.9;
682 const Double_t W = (2*L)/5;
684 Double_t tan = paramOut->GetZ() / paramOut->GetX();
685 Double_t pos = (tan - L) / W;
689 //______________________________________________________________________________
690 Double_t AliTRDQADataMakerRec::GetExtZ(const AliExternalTrackParam *in) const
693 // Returns the Z position at the entry to TRD
694 // using parameters from the TPC in
697 const Double_t kX0 = 300;
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();
704 Double_t zz = z + (kX0-x) * TMath::Tan(theta);
709 //____________________________________________________________________________
710 void AliTRDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
713 // Makes QA data from raw data
716 AliInfo("Making QA for Raws");
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);
728 const Int_t baseline = 10;
730 // configure the reader
732 rawReader->SelectEquipment(0, 1024, 1041);
733 rawReader->Select("TRD");
735 AliTRDrawStream *data = new AliTRDrawStream(rawReader);
737 // build data manager
738 AliTRDdigitsManager *digitsManager;
739 digitsManager = new AliTRDdigitsManager(kTRUE);
740 digitsManager->CreateArrays();
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];
751 while ((det = data->NextChamber(digitsManager, NULL, fErrorContainer)) >= 0){
753 //printf("DET = %d\n", det);
755 AliTRDSignalIndex* indexes = digitsManager->GetIndexes(det);
756 if (indexes->HasEntry()) {
758 AliTRDarrayADC *digits = (AliTRDarrayADC*) digitsManager->GetDigits(det);
760 while(indexes->NextRCIndex(row, col)) {
762 for (int ih=mnADC.GetEntriesFast();ih--;) ((TH2*)mnADC.UncheckedAt(ih))->Fill(det/30, det%30);
764 for(Int_t tb = 0; tb < digits->GetNtime(); tb++) {
765 Int_t value = digits->GetData(row, col, tb);
766 for (int ih=mADC.GetEntriesFast();ih--;) ((TH1*)mADC.UncheckedAt(ih))->Fill(value);
768 // simple clusterizer
769 if (col < 1 || col > digits->GetNcol()-2) continue;
770 if (tb < 1 || tb > digits->GetNtime()-2) continue;
774 Int_t valueL = digits->GetData(row, col-1, tb) - baseline;
775 if (valueL >= value) continue;
777 Int_t valueR = digits->GetData(row, col+1, tb) - baseline;
778 if (valueR >= value) continue;
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;
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;
788 Int_t valueTot = value + valueL + valueR;
789 if (valueTot < 0) continue;
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);
795 if (valueTot < 200) {
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);
803 digitsManager->ClearArrays(det); // do we need this if object will be deleted ??
807 delete [] fErrorContainer[0];
808 delete [] fErrorContainer[1];
809 delete [] fErrorContainer;
810 fErrorContainer = NULL;
812 delete digitsManager;
815 IncEvCountCycleRaws();
816 IncEvCountTotalRaws();
820 //____________________________________________________________________________
821 void AliTRDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
824 // Makes data from RecPoints
827 // Info("MakeRecPoints", "making");
829 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
830 TObjArray *clusterArray = new TObjArray(nsize+1000);
832 TBranch *branch = clustersTree->GetBranch("TRDcluster");
834 AliError("Can't get the branch !");
837 branch->SetAddress(&clusterArray);
839 // Loop through all entries in the tree
840 Int_t nEntries = (Int_t)TMath::Ceil( clustersTree->GetEntries() );
842 AliTRDcluster *c = 0;
844 for (Int_t i=0; i<540; i++) nDet[i] = 0;
848 //printf("nEntries = %d\n", nEntries);
853 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
856 nbytes += clustersTree->GetEvent(iEntry);
857 Int_t nCluster = clusterArray->GetEntries();
859 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
860 c = (AliTRDcluster *) clusterArray->At(iCluster);
872 TObjArray *hists3D = GetMatchingRecPointsData(10); //RS no alias for 3d histo filling, to directly
874 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
877 nbytes += clustersTree->GetEvent(iEntry);
879 // Get the number of points in the detector
880 Int_t nCluster = clusterArray->GetEntries();
883 // Loop through all TRD digits
884 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
887 c = (AliTRDcluster *) clusterArray->At(iCluster);
889 Int_t iDet = c->GetDetector();
890 Int_t nPads = c->GetNPads();
893 FillRecPointsData(0,iDet);
894 FillRecPointsData(86,c->GetQ());
895 FillRecPointsData(1,iDet, c->GetQ());
896 FillRecPointsData(2,nPads);
898 FillRecPointsData(1+c->GetNPads(),c->GetCenter());
901 FillRecPointsData(88+nPads-2,c->GetQ());
902 else FillRecPointsData(96,c->GetQ());
904 //if (c->GetPadTime() < 5)
905 FillRecPointsData(7,c->GetPadRow(), c->GetPadCol());
906 FillRecPointsData(8,c->GetPadTime());
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());
915 Int_t iSM = iDet / 30;
916 FillRecPointsData(50+iSM,c->GetPadTime());
917 FillRecPointsData(68+iSM,c->GetPadTime(), c->GetQ());
919 // total charge sm / det / timeBin
920 // FillRecPointsData(14+iSM,iDet-iSM*30, c->GetPadTime(), c->GetQ());
924 //if (c->GetNPads() == 2) {
925 Short_t *sig = c->GetSignals();
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]);
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]);
934 if (frac > -10) FillRecPointsData(11,c->GetCenter(), frac);
938 clusterArray->Delete();
942 for(Int_t i=0; i<540; i++)
943 if (nDet[i] > 0) FillRecPointsData(9,nDet[i]);
945 FillRecPointsData(9,nCls);
949 IncEvCountCycleRecPoints();
950 IncEvCountTotalRecPoints();
954 //____________________________________________________________________________
955 void AliTRDQADataMakerRec::StartOfDetectorCycle()
958 // Detector specific actions at start of cycle
963 //__________________________________________________________________________
964 Int_t AliTRDQADataMakerRec::CheckPointer(TObject *obj, const char *name)
967 // Checks initialization of pointers
970 if (!obj) AliWarning(Form("null pointer: %s", name));
973 //__________________________________________________________________________
974 void AliTRDQADataMakerRec::BuildRatio(TH1 *ratio, TH1 *histN, TH1* histD) {
976 // Calculate the ratio of two histograms
977 // error are calculated assuming the histos have the same counts
982 Int_t nbins = histN->GetXaxis()->GetNbins();
983 for(Int_t i=1; i<nbins+2; i++) {
985 Double_t valueN = histN->GetBinContent(i);
986 Double_t valueD = histD->GetBinContent(i);
989 ratio->SetBinContent(i, 0);
990 ratio->SetBinError(i, 0);
994 Double_t eps = (valueN < valueD-valueN)? valueN : valueD-valueN;
996 ratio->SetBinContent(i, valueN/valueD);
997 ratio->SetBinError(i, TMath::Sqrt(eps)/valueD);
1001 ratio->SetMinimum(-0.1);
1002 ratio->SetMaximum(1.1);
1003 ratio->SetMarkerStyle(20);
1005 //__________________________________________________________________________
1007 Int_t AliTRDQADataMakerRec::FillBits(TH1F *hist, Int_t code, Int_t offset) {
1011 for(Int_t i=0; i<8; i++) {
1013 hist->Fill(i+offset);
1022 //__________________________________________________________________________