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 **************************************************************************/
16 /* $Id: AliTRDqaRecPoints.cxx 23387 2008-01-17 17:25:16Z cblume $ */
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 "AliTRDcluster.h"
42 #include "AliTRDqaRecPoints.h"
43 #include "AliTRDgeometry.h"
45 #include "AliQAChecker.h"
47 ClassImp(AliTRDqaRecPoints)
49 //____________________________________________________________________________
51 AliTRDqaRecPoints::AliTRDqaRecPoints() :
59 // Default constructor
64 //____________________________________________________________________________
66 AliTRDqaRecPoints::AliTRDqaRecPoints(const AliTRDqaRecPoints &/*qa*/) :
79 //____________________________________________________________________________
80 void AliTRDqaRecPoints::Process(const char* filename)
83 // Detector specific actions at end of cycle
88 AliInfo("End of TRD cycle");
90 //if (task == AliQAv1::kRECPOINTS) {
92 TH1D *hist = new TH1D("fitHist", "", 200, -0.5, 199.5);
96 for(int i=0; i<540; i++) {
97 Double_t v = ((TH1D*)fHist->At(0))->GetBinContent(i+1);
101 TH2D *detMap = (TH2D*)fHist->At(87);
102 Int_t bin = detMap->FindBin(sm, det);
103 detMap->SetBinContent(bin, v);
107 // Rec points full chambers
108 for (Int_t i=0; i<540; i++) {
110 //AliInfo(Form("I = %d", i));
112 //TH1D *h = ((TH2D*)fHist->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1);
114 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
115 Double_t xvalue = hist->GetBinCenter(b);
116 Int_t bin = ((TH2D*)fHist->At(1))->FindBin(i,xvalue);
117 Double_t value = ((TH2D*)fHist->At(1))->GetBinContent(bin);
118 hist->SetBinContent(b, value);
121 //printf("Sum = %d %f\n", i, hist->GetSum());
122 if (hist->GetSum() < 100) continue; // chamber not present
124 hist->Fit("landau", "q0", "goff", 10, 180);
125 TF1 *fit = hist->GetFunction("landau");
126 ((TH1D*)fHist->At(12))->Fill(fit->GetParameter(1));
127 ((TH1D*)fHist->At(13))->Fill(fit->GetParameter(2));
130 // time-bin by time-bin sm by sm
131 for(Int_t i=0; i<18; i++) { // loop over super-modules
133 for(Int_t j=0; j<35; j++) { // loop over time bins
135 //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1);
137 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
138 Double_t xvalue = hist->GetBinCenter(b);
141 for(Int_t det=i*30; det<(i+1)*30; det++) { // loop over detectors
142 Int_t bin = ((TH3D*)fHist->At(10))->FindBin(det,j,xvalue);
143 Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin);
146 //printf("v = %f\n", value);
147 hist->SetBinContent(b, svalue);
150 if (hist->GetSum() < 100) continue;
151 //printf("fitting %d %d %f\n", i, j, hist->GetSum());
153 hist->Fit("landau", "q0", "goff", 10, 180);
154 TF1 *fit = hist->GetFunction("landau");
156 TH1D *h1 = (TH1D*)fHist->At(14+18+i);
157 Int_t bin = h1->FindBin(j);
158 // printf("%d %d %d\n", det, j, bin);
159 h1->SetBinContent(bin, TMath::Abs(fit->GetParameter(1)));
164 // time-bin by time-bin chamber by chamber
166 for (Int_t i=0; i<540; i++) {
168 //TH1D *test = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35);
169 //if (test->GetSum() < 100) continue;
171 //AliInfo(Form("fitting det = %d", i));
173 for(Int_t j=0; j<35; j++) {
175 //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1);
177 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
178 Double_t xvalue = hist->GetBinCenter(b);
179 Int_t bin = ((TH3D*)fHist->At(10))->FindBin(i,j,xvalue);
180 Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin);
181 //printf("v = %f\n", value);
182 hist->SetBinContent(b, value);
185 if (hist->GetSum() < 100) continue;
186 //printf("fitting %d %d %f\n", i, j, hist->GetSum());
188 hist->Fit("landau", "q0", "goff", 10, 180);
189 TF1 *fit = hist->GetFunction("landau");
193 TH2D *h2 = (TH2D*)fHist->At(14+sm);
194 Int_t bin = h2->FindBin(det,j);
195 // printf("%d %d %d\n", det, j, bin);
196 h2->SetBinContent(bin, TMath::Abs(fit->GetParameter(1)));
197 h2->SetBinError(bin,fit->GetParError(1));
201 if (hist) delete hist;
204 TFile *outFile = new TFile(filename, "RECREATE");
205 outFile->mkdir("TRD");
206 gDirectory->cd("TRD");
207 gDirectory->mkdir("RecPoints");
208 gDirectory->cd("RecPoints");
212 for(Int_t i=0; i<540; i++) {
213 //fRefHist[i]->Scale(1./fnEvents);
214 fRefHist[i]->Write();
222 //____________________________________________________________________________
224 void AliTRDqaRecPoints::Init()
227 // Create Reconstructed Points histograms in RecPoints subdir
230 //const Int_t kNhist = 14 + 4 * 18 + 2;
231 const Int_t kNhist = 88+2*18+1;
234 hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
235 hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5);
236 hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
238 hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1);
239 hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1);
240 hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1);
241 hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1);
243 hist[7] = new TH2D("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
244 hist[8] = new TH1D("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5);
245 hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5);
247 hist[10] = new TH3D("qaTRD_recPoints_sigTime", ";chamber;time bin;signal",
248 540, -0.5, 539.5, 35, -0.5, 34.5, 200, -0.5, 199.5);
249 hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity"
250 , 120, -0.6, 0.6, -1.2, 1.2, "");
252 hist[12] = new TH1D("qaTRD_recPoints_ampMPV", ";amplitude MPV", 150, 0, 150);
253 hist[13] = new TH1D("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 200, 0, 200);
255 // chamber by chamber
256 for(Int_t i=0; i<18; i++) {
257 hist[14+i] = new TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin"),
258 30, -0.5, 29.5, 35, -0.5, 34.5);
259 hist[14+i]->SetMinimum(20);
260 hist[14+i]->SetMaximum(40);
263 // time bin by time bin sm-by-sm
264 for(Int_t i=0; i<18; i++) {
265 hist[14+18+i] = new TH1D(Form("qaTRD_recPoints_sigTimeShape_sm%d", i),
266 Form("sm%d;time bin;signal"),
269 hist[14+18+i]->SetMaximum(120);
273 for(Int_t i=0; i<18; i++) {
274 hist[50+i] = new TH1D(Form("qaTRD_recPoints_nCls_sm%d",i),
275 Form("sm%d;time bin;number of clusters",i),
280 for(Int_t i=0; i<18; i++) {
281 hist[68+i] = new TH1D(Form("qaTRD_recPoints_totalCharge_sm%d", i),
282 Form("sm%d;time bin;total charge", i),
286 hist[86] = new TH1D("qaTRD_recPoints_signal", ";amplitude", 200, -0.5, 199.5);
287 hist[87] = new TH2D("qaTRD_recPoints_detMap", ";sm;chamber", 18, -0.5, 17.5, 30, -0.5, 29.5);
289 for(Int_t i=0; i<18; i++)
290 hist[88+i] = new TH2D(Form("qaTRD_recPoints_XY_sm%d", i),
291 Form("SM%d;Y;X",i), 240, -60, 60, 200, 290, 370);
293 for(Int_t i=0; i<18; i++)
294 hist[106+i] = new TH2D(Form("qaTRD_recPoints_XPad_sm%d", i),
295 Form("SM%d;Y;X",i), 144, -0.5, 143.5, 200, 290, 370);
298 hist[124] = new TH1D("qRef", "ref", 100, 0, 1e4);
300 fHist = new TObjArray(200);
301 for(Int_t i=0; i<kNhist; i++) {
303 fHist->AddAt(hist[i], i);
306 // reference histograms
308 for(Int_t i=0; i<540; i++) {
309 fRefHist[i] = new TH2D(Form("refRecPoints_sm%d", i), "",
310 16, -0.5, 15.5, 144, -0.5, 143.5); //, 30, -0.5, 29.5);
314 TFile *refFile = new TFile("outRef.root");
315 refFile->cd("TRD/RecPoints");
317 for(Int_t i=0; i<540; i++) {
318 fRefHist[i] = (TH2D*)gDirectory->Get(Form("refRecPoints_sm%d", i));
323 //____________________________________________________________________________
325 void AliTRDqaRecPoints::AddEvent(TTree * clustersTree)
328 // Makes data from RecPoints
331 // Info("MakeRecPoints", "making");
333 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
334 TObjArray *clusterArray = new TObjArray(nsize+1000);
336 TBranch *branch = clustersTree->GetBranch("TRDcluster");
338 AliError("Can't get the branch !");
341 branch->SetAddress(&clusterArray);
343 // Loop through all entries in the tree
344 Int_t nEntries = (Int_t) clustersTree->GetEntries();
346 AliTRDcluster *c = 0;
348 for (Int_t i=0; i<540; i++) nDet[i] = 0;
350 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
352 //printf("Entry = %d\n", iEntry);
355 nbytes += clustersTree->GetEvent(iEntry);
357 // Get the number of points in the detector
358 Int_t nCluster = clusterArray->GetEntriesFast();
360 // Loop through all TRD digits
361 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
362 c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
364 Int_t iDet = c->GetDetector();
365 if (iDet < 0 || iDet > 539) continue;
368 Int_t iSM = iDet / 30;
369 //Int_t iStack = iDet % 30;
370 Int_t nPad = c->GetNPads();
372 if (fnPad && nPad != fnPad) continue;
374 //if (iSM == 0 && iStack == 29) continue;
375 //if (iSM == 8 && iStack == 11) continue;
376 //if (iSM == 8 && iStack == 7) continue;
378 Int_t padRow = c->GetPadRow();
379 Int_t padCol = c->GetPadCol();
380 //Int_t timeBin = c->GetPadTime();
385 fRefHist[iDet]->Fill(padRow, padCol, c->GetQ());
387 Int_t bin = fRefHist[iDet]->FindBin(padRow, padCol);
388 refQ = fRefHist[iDet]->GetBinContent(bin);
389 //printf("bin = %d\n", bin);
392 ((TH1D*)fHist->At(124))->Fill(refQ);
393 //printf("ref Q = %lf\n", refQ);
395 Double_t charge = c->GetQ() - (refQ / (490. * 30));
396 if (charge < 0) continue;
399 ((TH2D*)fHist->At(88+iSM))->Fill(c->GetY(), c->GetX());
400 ((TH2D*)fHist->At(106+iSM))->Fill(c->GetPadCol(), c->GetX());
404 ((TH1D*)fHist->At(0))->Fill(iDet);
405 ((TH1D*)fHist->At(86))->Fill(charge);
406 ((TH1D*)fHist->At(1))->Fill(iDet, charge);
407 ((TH1D*)fHist->At(2))->Fill(c->GetNPads());
408 if (c->GetNPads() < 6)
409 ((TH1D*)fHist->At(1+c->GetNPads()))->Fill(c->GetCenter());
411 //if (c->GetPadTime() < 5)
412 ((TH2D*)fHist->At(7))->Fill(padRow, c->GetPadCol());
413 ((TH1D*)fHist->At(8))->Fill(c->GetPadTime());
415 ((TH3D*)fHist->At(10))->Fill(iDet, c->GetPadTime(), charge);
417 ((TH1D*)fHist->At(50+iSM))->Fill(c->GetPadTime());
418 ((TH1D*)fHist->At(68+iSM))->Fill(c->GetPadTime(), charge);
421 //if (c->GetNPads() == 2) {
422 Short_t *sig = c->GetSignals();
425 if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0)
426 frac = 1. * sig[4] / (sig[3] + sig[4]);
428 if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0)
429 frac = -1. * sig[2] / (sig[2] + sig[3]);
431 if (frac > -10) ((TProfile*)fHist->At(11))->Fill(c->GetCenter(), frac);
437 for(Int_t i=0; i<540; i++)
438 if (nDet[i] > 0) ((TH1D*)fHist->At(9))->Fill(nDet[i]);
443 TFile *outFile = new TFile("outQA.root", "RECREATE");
444 outFile->mkdir("TRD");
445 gDirectory->cd("TRD");
446 gDirectory->mkdir("RecPoints");
447 gDirectory->cd("RecPoints");
453 //____________________________________________________________________________