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 **************************************************************************/
17 Produces the data needed to calculate the quality assurance.
18 All data must be mergeable objects.
19 S.Radomski Uni-Heidelberg October 2007
22 // --- ROOT system ---
23 #include <TClonesArray.h>
27 // --- Standard library ---
29 // --- AliRoot header files ---
30 #include "AliESDEvent.h"
32 #include "AliTRDdigit.h"
33 #include "AliTRDhit.h"
34 #include "AliTRDcluster.h"
35 #include "AliTRDQADataMaker.h"
37 #include "AliTRDRawStreamV2.h"
39 ClassImp(AliTRDQADataMaker)
41 //____________________________________________________________________________
42 AliTRDQADataMaker::AliTRDQADataMaker() :
43 AliQADataMaker(AliQA::GetDetName(AliQA::kTRD), "TRD Quality Assurance Data Maker")
48 //____________________________________________________________________________
49 AliTRDQADataMaker::AliTRDQADataMaker(const AliTRDQADataMaker& qadm) :
53 SetName((const char*)qadm.GetName()) ;
54 SetTitle((const char*)qadm.GetTitle());
57 //__________________________________________________________________
58 AliTRDQADataMaker& AliTRDQADataMaker::operator = (const AliTRDQADataMaker& qadm )
61 this->~AliTRDQADataMaker();
62 new(this) AliTRDQADataMaker(qadm);
66 //____________________________________________________________________________
67 void AliTRDQADataMaker::EndOfDetectorCycle()
69 //Detector specific actions at end of cycle
72 //____________________________________________________________________________
73 void AliTRDQADataMaker::InitESDs()
75 //create ESDs histograms in ESDs subdir
76 const Int_t nhist = 1;
79 hist[0] = new TH1D("qaTRD_esd_bits", ";Bits", 64, -0.5, 63.5);
81 for(Int_t i=0; i<nhist; i++) {
83 Add2ESDsList(hist[i], i);
87 //____________________________________________________________________________
88 void AliTRDQADataMaker::InitHits()
90 // create Hits histograms in Hits subdir
91 const Int_t nhist = 4;
94 hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ;
96 hist[1] = new TH1D("qaTRD_hist_Qdrift", ";Charge from tracks", 100, 0, 100);
97 hist[2] = new TH1D("qaTRD_hist_Qamp", ";Charge from TRD photon", 100, 0, 100);
98 hist[3] = new TH1D("qaTRD_hist_Qphoton", ";Charge from TRD photon", 100, 0, 100);
100 for(Int_t i=0; i<nhist; i++) {
102 Add2HitsList(hist[i], i);
106 //____________________________________________________________________________
107 void AliTRDQADataMaker::InitDigits()
109 // create Digits histograms in Digits subdir
111 const Int_t nhist = 3;
114 hist[0] = new TH1D("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
115 hist[1] = new TH1D("qaTRD_digits_time", ";Time bin", 40, -0.5, 39.5);
116 hist[2] = new TH1D("qaTRD_digits_amp", ";Amplitude", 100, 0, 100.);
118 for(Int_t i=0; i<nhist; i++) {
120 Add2DigitsList(hist[i], i);
125 //____________________________________________________________________________
126 void AliTRDQADataMaker::InitRecPoints()
128 // create Reconstructed Points histograms in RecPoints subdir
129 const Int_t nhist = 7;
132 hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
133 hist[1] = new TH1D("qaTRD_recPoints_amp", ";Amplitude", 200, -0.5, 199.5);
134 hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
135 hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1);
136 hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1);
137 hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1);
138 hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1);
140 for(Int_t i=0; i<nhist; i++) {
142 Add2RecPointsList(hist[i], i);
146 //____________________________________________________________________________
147 void AliTRDQADataMaker::InitRaws()
149 // create Raws histograms in Raws subdir
150 const Int_t kSM = 18;
151 const Int_t nhist = 6+kSM;
154 hist[0] = new TH1D("qaTRD_raws_det", ";detector", 540, -0.5, 539.5);
155 hist[1] = new TH1D("qaTRD_raws_sig", ";signal", 100, -0.5, 99.5);
156 hist[2] = new TH1D("qaTRD_raws_sigCentral", "; signal central bin", 100, -0.5, 99.5);
157 hist[3] = new TH1D("qaTRD_raws_sigTail", ";signal cluster", 100, -0.5, 99.5);
158 hist[4] = new TH1D("qaTRD_raws_tiemBin", ";time bin", 40, -0.5, 39.5);
159 hist[5] = new TH1D("qaTRD_rows_smId", ";supermodule", 18, -0.5, 17.5);
161 // one char per ADC chanell
162 const Int_t nADC = 30 * 8 * 16 * 22;
163 for(Int_t i=0; i<kSM; i++)
164 hist[6+i] = new TH1D(Form("qaTRD_raws_sm%d",i),"",nADC, -0.5, nADC-0.5);
166 for(Int_t i=0; i<nhist; i++) {
168 Add2RawsList(hist[i], i);
172 //____________________________________________________________________________
173 void AliTRDQADataMaker::InitSDigits()
175 // create SDigits histograms in SDigits subdir
177 const Int_t nhist = 2;
180 hist[0] = new TH1D("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
181 hist[1] = new TH1D("qaTRD_digits_amp", ";Amplitude", 100, -0.5, 99.5);
183 for(Int_t i=0; i<nhist; i++) {
185 Add2SDigitsList(hist[i], i);
189 //____________________________________________________________________________
190 void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
192 // make QA data from ESDs
194 Int_t nTracks = esd->GetNumberOfTracks();
196 for(Int_t i=0; i<nTracks; i++) {
198 AliESDtrack *track = esd->GetTrack(i);
199 UInt_t status = track->GetStatus();
201 for(Int_t bit=0; bit<64; bit++)
202 if (u<<bit & status) GetESDsData(0)->Fill(bit);
206 //____________________________________________________________________________
207 void AliTRDQADataMaker::MakeHits(TClonesArray * hits)
209 //make QA data from Hits
210 //printf("making QA for TRD hits from an array %d\n", hits->GetEntriesFast());
215 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
216 GetHitsData(0)->Fill(hit->GetDetector());
217 Double_t q = TMath::Abs(hit->GetCharge());
219 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
220 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
221 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
225 //____________________________________________________________________________
226 void AliTRDQADataMaker::MakeHits(TTree * hitTree)
228 //make QA data from Hits
229 //printf("making QA for TRD hits from a tree\n");
231 if (!CheckPointer(hitTree, "TRD hits tree")) return;
233 TBranch *branch = hitTree->GetBranch("TRD");
234 if (!CheckPointer(branch, "TRD hits branch")) return;
236 Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
237 TClonesArray *hits = new TClonesArray("AliTRDhit", nhits+1000);
238 TClonesArray *tmp = new TClonesArray("AliTRDhit", 1000);
239 branch->SetAddress(&tmp);
242 Int_t nEntries = (Int_t)branch->GetEntries();
243 for(Int_t i = 0; i < nEntries; i++) {
245 Int_t nHits = (Int_t)tmp->GetEntries();
246 for(Int_t j=0; j<nHits; j++) {
247 AliTRDhit *hit = (AliTRDhit*)tmp->At(j);
248 new((*hits)[index++]) AliTRDhit(*hit);
256 //____________________________________________________________________________
257 void AliTRDQADataMaker::MakeDigits(TClonesArray * digits)
259 // makes data from Digits
262 AliTRDdigit * digit ;
263 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
264 GetDigitsData(0)->Fill(digit->GetDetector());
265 GetDigitsData(1)->Fill(digit->GetTime());
266 GetDigitsData(2)->Fill(digit->GetAmp());
270 //____________________________________________________________________________
271 void AliTRDQADataMaker::MakeSDigits(TClonesArray * sdigits)
273 // makes data from Digits
275 TIter next(sdigits) ;
276 AliTRDdigit * digit ;
277 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
278 GetDigitsData(0)->Fill(digit->GetDetector());
279 GetDigitsData(1)->Fill(digit->GetAmp());
283 //____________________________________________________________________________
284 void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
289 //const Int_t kSM = 18;
290 //const Int_t kROC = 30;
291 const Int_t kROB = 8;
292 //const Int_t kLayer = 6;
293 //const Int_t kStack = 5;
294 const Int_t kMCM = 16;
295 const Int_t kADC = 22;
297 AliTRDRawStreamV2 *raw = new AliTRDRawStreamV2(rawReader);
299 raw->SetRawVersion(3);
302 while (raw->Next()) {
304 GetRawsData(0)->Fill(raw->GetDet());
306 Int_t *sig = raw->GetSignals();
307 for(Int_t i=0; i<3; i++) GetRawsData(1)->Fill(sig[i]);
309 GetRawsData(2)->Fill(sig[1]);
310 GetRawsData(3)->Fill(sig[0]);
311 GetRawsData(3)->Fill(sig[2]);
313 GetRawsData(4)->Fill(raw->GetTimeBin());
315 // calculate the index;
316 Int_t sm = raw->GetSM();
317 Int_t roc = raw->GetROC();
318 Int_t rob = raw->GetROB();
319 Int_t mcm = raw->GetMCM();
320 Int_t adc = raw->GetADC();
322 Int_t index = roc * (kROB*kMCM*kADC) + rob * (kMCM*kADC) + mcm * kADC + adc;
323 GetRawsData(5)->Fill(sm);
324 //printf("SM = %d\n", sm);
325 GetRawsData(6+sm)->Fill(index);
329 //____________________________________________________________________________
330 void AliTRDQADataMaker::MakeRecPoints(TTree * clustersTree)
333 // makes data from RecPoints
336 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
337 TObjArray *clusterArray = new TObjArray(nsize+1000);
339 TBranch *branch = clustersTree->GetBranch("TRDcluster");
341 AliError("Can't get the branch !");
344 branch->SetAddress(&clusterArray);
346 // Loop through all entries in the tree
347 Int_t nEntries = (Int_t) clustersTree->GetEntries();
349 AliTRDcluster *c = 0;
351 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
354 nbytes += clustersTree->GetEvent(iEntry);
356 // Get the number of points in the detector
357 Int_t nCluster = clusterArray->GetEntriesFast();
359 // Loop through all TRD digits
360 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
361 c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
363 GetRecPointsData(0)->Fill(c->GetDetector());
364 GetRecPointsData(1)->Fill(c->GetQ());
365 GetRecPointsData(2)->Fill(c->GetNPads());
366 if (c->GetNPads() < 6)
367 GetRecPointsData(1+c->GetNPads())->Fill(c->GetCenter());
374 //____________________________________________________________________________
375 void AliTRDQADataMaker::StartOfDetectorCycle()
377 //Detector specific actions at start of cycle
380 //__________________________________________________________________________
381 Int_t AliTRDQADataMaker::CheckPointer(TObject *obj, const char *name) {
383 if (!obj) AliWarning(Form("null pointer: %s", name));
386 //__________________________________________________________________________