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"
44 #include "AliTRDdataArrayI.h"
46 #include "AliQAChecker.h"
48 ClassImp(AliTRDqaRecPoints)
50 //____________________________________________________________________________
52 AliTRDqaRecPoints::AliTRDqaRecPoints() :
60 // Default constructor
65 //____________________________________________________________________________
67 AliTRDqaRecPoints::AliTRDqaRecPoints(const AliTRDqaRecPoints &/*qa*/) :
80 //____________________________________________________________________________
81 void AliTRDqaRecPoints::Process(const char* filename)
84 // Detector specific actions at end of cycle
89 AliInfo("End of TRD cycle");
91 //if (task == AliQA::kRECPOINTS) {
93 TH1D *hist = new TH1D("fitHist", "", 200, -0.5, 199.5);
97 for(int i=0; i<540; i++) {
98 Double_t v = ((TH1D*)fHist->At(0))->GetBinContent(i+1);
102 TH2D *detMap = (TH2D*)fHist->At(87);
103 Int_t bin = detMap->FindBin(sm, det);
104 detMap->SetBinContent(bin, v);
108 // Rec points full chambers
109 for (Int_t i=0; i<540; i++) {
111 //AliInfo(Form("I = %d", i));
113 //TH1D *h = ((TH2D*)fHist->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1);
115 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
116 Double_t xvalue = hist->GetBinCenter(b);
117 Int_t bin = ((TH2D*)fHist->At(1))->FindBin(i,xvalue);
118 Double_t value = ((TH2D*)fHist->At(1))->GetBinContent(bin);
119 hist->SetBinContent(b, value);
122 //printf("Sum = %d %f\n", i, hist->GetSum());
123 if (hist->GetSum() < 100) continue; // chamber not present
125 hist->Fit("landau", "q0", "goff", 10, 180);
126 TF1 *fit = hist->GetFunction("landau");
127 ((TH1D*)fHist->At(12))->Fill(fit->GetParameter(1));
128 ((TH1D*)fHist->At(13))->Fill(fit->GetParameter(2));
131 // time-bin by time-bin sm by sm
132 for(Int_t i=0; i<18; i++) { // loop over super-modules
134 for(Int_t j=0; j<35; j++) { // loop over time bins
136 //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1);
138 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
139 Double_t xvalue = hist->GetBinCenter(b);
142 for(Int_t det=i*30; det<(i+1)*30; det++) { // loop over detectors
143 Int_t bin = ((TH3D*)fHist->At(10))->FindBin(det,j,xvalue);
144 Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin);
147 //printf("v = %f\n", value);
148 hist->SetBinContent(b, svalue);
151 if (hist->GetSum() < 100) continue;
152 //printf("fitting %d %d %f\n", i, j, hist->GetSum());
154 hist->Fit("landau", "q0", "goff", 10, 180);
155 TF1 *fit = hist->GetFunction("landau");
157 TH1D *h1 = (TH1D*)fHist->At(14+18+i);
158 Int_t bin = h1->FindBin(j);
159 // printf("%d %d %d\n", det, j, bin);
160 h1->SetBinContent(bin, TMath::Abs(fit->GetParameter(1)));
165 // time-bin by time-bin chamber by chamber
167 for (Int_t i=0; i<540; i++) {
169 //TH1D *test = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35);
170 //if (test->GetSum() < 100) continue;
172 //AliInfo(Form("fitting det = %d", i));
174 for(Int_t j=0; j<35; j++) {
176 //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1);
178 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
179 Double_t xvalue = hist->GetBinCenter(b);
180 Int_t bin = ((TH3D*)fHist->At(10))->FindBin(i,j,xvalue);
181 Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin);
182 //printf("v = %f\n", value);
183 hist->SetBinContent(b, value);
186 if (hist->GetSum() < 100) continue;
187 //printf("fitting %d %d %f\n", i, j, hist->GetSum());
189 hist->Fit("landau", "q0", "goff", 10, 180);
190 TF1 *fit = hist->GetFunction("landau");
194 TH2D *h2 = (TH2D*)fHist->At(14+sm);
195 Int_t bin = h2->FindBin(det,j);
196 // printf("%d %d %d\n", det, j, bin);
197 h2->SetBinContent(bin, TMath::Abs(fit->GetParameter(1)));
198 h2->SetBinError(bin,fit->GetParError(1));
202 if (hist) delete hist;
205 TFile *outFile = new TFile(filename, "RECREATE");
206 outFile->mkdir("TRD");
207 gDirectory->cd("TRD");
208 gDirectory->mkdir("RecPoints");
209 gDirectory->cd("RecPoints");
213 for(Int_t i=0; i<540; i++) {
214 //fRefHist[i]->Scale(1./fnEvents);
215 fRefHist[i]->Write();
223 //____________________________________________________________________________
225 void AliTRDqaRecPoints::Init()
228 // Create Reconstructed Points histograms in RecPoints subdir
231 //const Int_t kNhist = 14 + 4 * 18 + 2;
232 const Int_t kNhist = 88+2*18+1;
235 hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
236 hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5);
237 hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
239 hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1);
240 hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1);
241 hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1);
242 hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1);
244 hist[7] = new TH2D("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
245 hist[8] = new TH1D("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5);
246 hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5);
248 hist[10] = new TH3D("qaTRD_recPoints_sigTime", ";chamber;time bin;signal",
249 540, -0.5, 539.5, 35, -0.5, 34.5, 200, -0.5, 199.5);
250 hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity"
251 , 120, -0.6, 0.6, -1.2, 1.2, "");
253 hist[12] = new TH1D("qaTRD_recPoints_ampMPV", ";amplitude MPV", 150, 0, 150);
254 hist[13] = new TH1D("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 200, 0, 200);
256 // chamber by chamber
257 for(Int_t i=0; i<18; i++) {
258 hist[14+i] = new TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin"),
259 30, -0.5, 29.5, 35, -0.5, 34.5);
260 hist[14+i]->SetMinimum(20);
261 hist[14+i]->SetMaximum(40);
264 // time bin by time bin sm-by-sm
265 for(Int_t i=0; i<18; i++) {
266 hist[14+18+i] = new TH1D(Form("qaTRD_recPoints_sigTimeShape_sm%d", i),
267 Form("sm%d;time bin;signal"),
270 hist[14+18+i]->SetMaximum(120);
274 for(Int_t i=0; i<18; i++) {
275 hist[50+i] = new TH1D(Form("qaTRD_recPoints_nCls_sm%d",i),
276 Form("sm%d;time bin;number of clusters",i),
281 for(Int_t i=0; i<18; i++) {
282 hist[68+i] = new TH1D(Form("qaTRD_recPoints_totalCharge_sm%d", i),
283 Form("sm%d;time bin;total charge", i),
287 hist[86] = new TH1D("qaTRD_recPoints_signal", ";amplitude", 200, -0.5, 199.5);
288 hist[87] = new TH2D("qaTRD_recPoints_detMap", ";sm;chamber", 18, -0.5, 17.5, 30, -0.5, 29.5);
290 for(Int_t i=0; i<18; i++)
291 hist[88+i] = new TH2D(Form("qaTRD_recPoints_XY_sm%d", i),
292 Form("SM%d;Y;X",i), 240, -60, 60, 200, 290, 370);
294 for(Int_t i=0; i<18; i++)
295 hist[106+i] = new TH2D(Form("qaTRD_recPoints_XPad_sm%d", i),
296 Form("SM%d;Y;X",i), 144, -0.5, 143.5, 200, 290, 370);
299 hist[124] = new TH1D("qRef", "ref", 100, 0, 1e4);
301 fHist = new TObjArray(200);
302 for(Int_t i=0; i<kNhist; i++) {
304 fHist->AddAt(hist[i], i);
307 // reference histograms
309 for(Int_t i=0; i<540; i++) {
310 fRefHist[i] = new TH2D(Form("refRecPoints_sm%d", i), "",
311 16, -0.5, 15.5, 144, -0.5, 143.5); //, 30, -0.5, 29.5);
315 TFile *refFile = new TFile("outRef.root");
316 refFile->cd("TRD/RecPoints");
318 for(Int_t i=0; i<540; i++) {
319 fRefHist[i] = (TH2D*)gDirectory->Get(Form("refRecPoints_sm%d", i));
324 //____________________________________________________________________________
326 void AliTRDqaRecPoints::AddEvent(TTree * clustersTree)
329 // Makes data from RecPoints
332 // Info("MakeRecPoints", "making");
334 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
335 TObjArray *clusterArray = new TObjArray(nsize+1000);
337 TBranch *branch = clustersTree->GetBranch("TRDcluster");
339 AliError("Can't get the branch !");
342 branch->SetAddress(&clusterArray);
344 // Loop through all entries in the tree
345 Int_t nEntries = (Int_t) clustersTree->GetEntries();
347 AliTRDcluster *c = 0;
349 for (Int_t i=0; i<540; i++) nDet[i] = 0;
351 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
353 //printf("Entry = %d\n", iEntry);
356 nbytes += clustersTree->GetEvent(iEntry);
358 // Get the number of points in the detector
359 Int_t nCluster = clusterArray->GetEntriesFast();
361 // Loop through all TRD digits
362 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
363 c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
365 Int_t iDet = c->GetDetector();
366 if (iDet < 0 || iDet > 539) continue;
369 Int_t iSM = iDet / 30;
370 //Int_t iStack = iDet % 30;
371 Int_t nPad = c->GetNPads();
373 if (fnPad && nPad != fnPad) continue;
375 //if (iSM == 0 && iStack == 29) continue;
376 //if (iSM == 8 && iStack == 11) continue;
377 //if (iSM == 8 && iStack == 7) continue;
379 Int_t padRow = c->GetPadRow();
380 Int_t padCol = c->GetPadCol();
381 //Int_t timeBin = c->GetPadTime();
386 fRefHist[iDet]->Fill(padRow, padCol, c->GetQ());
388 Int_t bin = fRefHist[iDet]->FindBin(padRow, padCol);
389 refQ = fRefHist[iDet]->GetBinContent(bin);
390 //printf("bin = %d\n", bin);
393 ((TH1D*)fHist->At(124))->Fill(refQ);
394 //printf("ref Q = %lf\n", refQ);
396 Double_t charge = c->GetQ() - (refQ / (490. * 30));
397 if (charge < 0) continue;
400 ((TH2D*)fHist->At(88+iSM))->Fill(c->GetY(), c->GetX());
401 ((TH2D*)fHist->At(106+iSM))->Fill(c->GetPadCol(), c->GetX());
405 ((TH1D*)fHist->At(0))->Fill(iDet);
406 ((TH1D*)fHist->At(86))->Fill(charge);
407 ((TH1D*)fHist->At(1))->Fill(iDet, charge);
408 ((TH1D*)fHist->At(2))->Fill(c->GetNPads());
409 if (c->GetNPads() < 6)
410 ((TH1D*)fHist->At(1+c->GetNPads()))->Fill(c->GetCenter());
412 //if (c->GetPadTime() < 5)
413 ((TH2D*)fHist->At(7))->Fill(padRow, c->GetPadCol());
414 ((TH1D*)fHist->At(8))->Fill(c->GetPadTime());
416 ((TH3D*)fHist->At(10))->Fill(iDet, c->GetPadTime(), charge);
418 ((TH1D*)fHist->At(50+iSM))->Fill(c->GetPadTime());
419 ((TH1D*)fHist->At(68+iSM))->Fill(c->GetPadTime(), charge);
422 //if (c->GetNPads() == 2) {
423 Short_t *sig = c->GetSignals();
426 if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0)
427 frac = 1. * sig[4] / (sig[3] + sig[4]);
429 if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0)
430 frac = -1. * sig[2] / (sig[2] + sig[3]);
432 if (frac > -10) ((TProfile*)fHist->At(11))->Fill(c->GetCenter(), frac);
438 for(Int_t i=0; i<540; i++)
439 if (nDet[i] > 0) ((TH1D*)fHist->At(9))->Fill(nDet[i]);
444 TFile *outFile = new TFile("outQA.root", "RECREATE");
445 outFile->mkdir("TRD");
446 gDirectory->cd("TRD");
447 gDirectory->mkdir("RecPoints");
448 gDirectory->cd("RecPoints");
454 //____________________________________________________________________________