]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDQADataMaker.cxx
Test beam raw data reading
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMaker.cxx
CommitLineData
ffb5de4c 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/*
17Produces the data needed to calculate the quality assurance.
18All data must be mergeable objects.
19S.Radomski Uni-Heidelberg October 2007
20*/
21
22// --- ROOT system ---
23#include <TClonesArray.h>
24#include <TFile.h>
25#include <TH1D.h>
26
27// --- Standard library ---
28
29// --- AliRoot header files ---
30#include "AliESDEvent.h"
31#include "AliLog.h"
32#include "AliTRDdigit.h"
33#include "AliTRDhit.h"
34#include "AliTRDcluster.h"
35#include "AliTRDQADataMaker.h"
36
37#include "AliTRDRawStreamV2.h"
38
39ClassImp(AliTRDQADataMaker)
40
41//____________________________________________________________________________
42 AliTRDQADataMaker::AliTRDQADataMaker() :
43 AliQADataMaker(AliQA::GetDetName(AliQA::kTRD), "TRD Quality Assurance Data Maker")
44{
45 // ctor
46}
47
48//____________________________________________________________________________
49AliTRDQADataMaker::AliTRDQADataMaker(const AliTRDQADataMaker& qadm) :
50 AliQADataMaker()
51{
52 //copy ctor
53 SetName((const char*)qadm.GetName()) ;
54 SetTitle((const char*)qadm.GetTitle());
55}
56
57//__________________________________________________________________
58AliTRDQADataMaker& AliTRDQADataMaker::operator = (const AliTRDQADataMaker& qadm )
59{
60 // Equal operator.
61 this->~AliTRDQADataMaker();
62 new(this) AliTRDQADataMaker(qadm);
63 return *this;
64}
65
66//____________________________________________________________________________
67void AliTRDQADataMaker::EndOfDetectorCycle()
68{
69 //Detector specific actions at end of cycle
70}
71
72//____________________________________________________________________________
73void AliTRDQADataMaker::InitESDs()
74{
75 //create ESDs histograms in ESDs subdir
76 const Int_t nhist = 1;
77 TH1D *hist[nhist];
78
79 hist[0] = new TH1D("qaTRD_esd_bits", ";Bits", 64, -0.5, 63.5);
80
81 for(Int_t i=0; i<nhist; i++) {
82 //hist[i]->Sumw2();
83 Add2ESDsList(hist[i], i);
84 }
85}
86
87//____________________________________________________________________________
88void AliTRDQADataMaker::InitHits()
89{
90 // create Hits histograms in Hits subdir
91 const Int_t nhist = 4;
92 TH1D *hist[nhist];
93
94 hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ;
95
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);
99
100 for(Int_t i=0; i<nhist; i++) {
101 //hist[i]->Sumw2();
102 Add2HitsList(hist[i], i);
103 }
104}
105
106//____________________________________________________________________________
107void AliTRDQADataMaker::InitDigits()
108{
109 // create Digits histograms in Digits subdir
110
111 const Int_t nhist = 3;
112 TH1D *hist[nhist];
113
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.);
117
118 for(Int_t i=0; i<nhist; i++) {
119 hist[i]->Sumw2();
120 Add2DigitsList(hist[i], i);
121 }
122
123}
124
125//____________________________________________________________________________
126void AliTRDQADataMaker::InitRecPoints()
127{
128 // create Reconstructed Points histograms in RecPoints subdir
129 const Int_t nhist = 7;
130 TH1D *hist[nhist];
131
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);
139
140 for(Int_t i=0; i<nhist; i++) {
141 //hist[i]->Sumw2();
142 Add2RecPointsList(hist[i], i);
143 }
144}
145
146//____________________________________________________________________________
147void AliTRDQADataMaker::InitRaws()
148{
149 // create Raws histograms in Raws subdir
150 const Int_t kSM = 18;
151 const Int_t nhist = 6+kSM;
152 TH1D *hist[nhist];
153
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);
160
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);
165
166 for(Int_t i=0; i<nhist; i++) {
167 //hist[i]->Sumw2();
168 Add2RawsList(hist[i], i);
169 }
170}
171
172//____________________________________________________________________________
173void AliTRDQADataMaker::InitSDigits()
174{
175 // create SDigits histograms in SDigits subdir
176
177 const Int_t nhist = 2;
178 TH1D *hist[nhist];
179
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);
182
183 for(Int_t i=0; i<nhist; i++) {
184 hist[i]->Sumw2();
185 Add2SDigitsList(hist[i], i);
186 }
187}
188
189//____________________________________________________________________________
190void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
191{
192 // make QA data from ESDs
193
194 Int_t nTracks = esd->GetNumberOfTracks();
195
196 for(Int_t i=0; i<nTracks; i++) {
197
198 AliESDtrack *track = esd->GetTrack(i);
199 UInt_t status = track->GetStatus();
200 UInt_t u = 1;
201 for(Int_t bit=0; bit<64; bit++)
202 if (u<<bit & status) GetESDsData(0)->Fill(bit);
203 }
204}
205
206//____________________________________________________________________________
207void AliTRDQADataMaker::MakeHits(TClonesArray * hits)
208{
209 //make QA data from Hits
210 //printf("making QA for TRD hits from an array %d\n", hits->GetEntriesFast());
211
212 TIter next(hits);
213 AliTRDhit * hit;
214
215 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
216 GetHitsData(0)->Fill(hit->GetDetector());
217 Double_t q = TMath::Abs(hit->GetCharge());
218
219 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
220 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
221 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
222 }
223
224}
225//____________________________________________________________________________
226void AliTRDQADataMaker::MakeHits(TTree * hitTree)
227{
228 //make QA data from Hits
229 //printf("making QA for TRD hits from a tree\n");
230
231 if (!CheckPointer(hitTree, "TRD hits tree")) return;
232
233 TBranch *branch = hitTree->GetBranch("TRD");
234 if (!CheckPointer(branch, "TRD hits branch")) return;
235
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);
240
241 Int_t index = 0;
242 Int_t nEntries = (Int_t)branch->GetEntries();
243 for(Int_t i = 0; i < nEntries; i++) {
244 branch->GetEntry(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);
249 }
250 }
251
252 tmp->Delete();
253 delete tmp;
254 MakeHits(hits);
255}
256//____________________________________________________________________________
257void AliTRDQADataMaker::MakeDigits(TClonesArray * digits)
258{
259 // makes data from Digits
260
261 TIter next(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());
267 }
268}
269
270//____________________________________________________________________________
271void AliTRDQADataMaker::MakeSDigits(TClonesArray * sdigits)
272{
273 // makes data from Digits
274
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());
280 }
281}
282
283//____________________________________________________________________________
284void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
285{
286 // 157
287 // T9 -- T10
288
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;
296
297 AliTRDRawStreamV2 *raw = new AliTRDRawStreamV2(rawReader);
298
299 raw->SetRawVersion(3);
300 raw->Init();
301
302 while (raw->Next()) {
303
304 GetRawsData(0)->Fill(raw->GetDet());
305
306 Int_t *sig = raw->GetSignals();
307 for(Int_t i=0; i<3; i++) GetRawsData(1)->Fill(sig[i]);
308
309 GetRawsData(2)->Fill(sig[1]);
310 GetRawsData(3)->Fill(sig[0]);
311 GetRawsData(3)->Fill(sig[2]);
312
313 GetRawsData(4)->Fill(raw->GetTimeBin());
314
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();
321
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);
326 }
327}
328
329//____________________________________________________________________________
330void AliTRDQADataMaker::MakeRecPoints(TTree * clustersTree)
331{
332
333 // makes data from RecPoints
334 //
335
336 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
337 TObjArray *clusterArray = new TObjArray(nsize+1000);
338
339 TBranch *branch = clustersTree->GetBranch("TRDcluster");
340 if (!branch) {
341 AliError("Can't get the branch !");
342 return;
343 }
344 branch->SetAddress(&clusterArray);
345
346 // Loop through all entries in the tree
347 Int_t nEntries = (Int_t) clustersTree->GetEntries();
348 Int_t nbytes = 0;
349 AliTRDcluster *c = 0;
350
351 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
352
353 // Import the tree
354 nbytes += clustersTree->GetEvent(iEntry);
355
356 // Get the number of points in the detector
357 Int_t nCluster = clusterArray->GetEntriesFast();
358
359 // Loop through all TRD digits
360 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
361 c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
362
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());
368 }
369 }
370
371 delete clusterArray;
372}
373
374//____________________________________________________________________________
375void AliTRDQADataMaker::StartOfDetectorCycle()
376{
377 //Detector specific actions at start of cycle
378
379}
380//__________________________________________________________________________
381Int_t AliTRDQADataMaker::CheckPointer(TObject *obj, const char *name) {
382
383 if (!obj) AliWarning(Form("null pointer: %s", name));
384 return !!obj;
385}
386//__________________________________________________________________________