]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDQADataMakerSim.cxx
1.The QA data created on demand according to the event species at filling time. 2...
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMakerSim.cxx
CommitLineData
04236e67 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/* $Id$ */
17
18////////////////////////////////////////////////////////////////////////////
19// //
20// Produces the data needed to calculate the quality assurance. //
21// All data must be mergeable objects. //
22// //
23// Author: //
24// Sylwester Radomski (radomski@physi.uni-heidelberg.de) //
25// //
26////////////////////////////////////////////////////////////////////////////
27
28// --- ROOT system ---
29#include <TClonesArray.h>
30#include <TFile.h>
31#include <TH1D.h>
32#include <TH2D.h>
33#include <TH3D.h>
34#include <TProfile.h>
35#include <TF1.h>
36#include <TCanvas.h>
37#include <TTree.h>
38
39// --- AliRoot header files ---
40//#include "AliESDEvent.h"
41#include "AliLog.h"
42#include "AliTRDdigit.h"
43#include "AliTRDhit.h"
44//#include "AliTRDcluster.h"
45#include "AliTRDQADataMakerSim.h"
46#include "AliTRDdigitsManager.h"
47#include "AliTRDgeometry.h"
b65e5048 48#include "AliTRDarrayADC.h"
49#include "AliTRDarraySignal.h"
987ba9a3 50//#include "AliTRDrawStream.h"
04236e67 51
52#include "AliQAChecker.h"
53
54ClassImp(AliTRDQADataMakerSim)
55
56//____________________________________________________________________________
57 AliTRDQADataMakerSim::AliTRDQADataMakerSim() :
4e25ac79 58 AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
04236e67 59{
60 //
61 // Default constructor
62}
63
64//____________________________________________________________________________
65AliTRDQADataMakerSim::AliTRDQADataMakerSim(const AliTRDQADataMakerSim& qadm) :
66 AliQADataMakerSim()
67{
68 //
69 // Copy constructor
70 //
71
72 SetName((const char*)qadm.GetName()) ;
73 SetTitle((const char*)qadm.GetTitle());
74
75}
76
77//__________________________________________________________________
78AliTRDQADataMakerSim& AliTRDQADataMakerSim::operator=(const AliTRDQADataMakerSim& qadm)
79{
80 //
81 // Equal operator.
82 //
83
84 this->~AliTRDQADataMakerSim();
85 new(this) AliTRDQADataMakerSim(qadm);
86 return *this;
87
88}
89
90//____________________________________________________________________________
4e25ac79 91void AliTRDQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 92{
93 //
94 // Detector specific actions at end of cycle
95 //
96
5379c4a3 97 //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task));
04236e67 98
99 // call the checker
4e25ac79 100 AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;
04236e67 101
102
103}
104
105//____________________________________________________________________________
106void AliTRDQADataMakerSim::InitHits()
107{
108 //
109 // Create Hits histograms in Hits subdir
110 //
7d297381 111 const Bool_t expert = kTRUE ;
112 const Bool_t image = kTRUE ;
113
04236e67 114 const Int_t kNhist = 4;
115 TH1D *hist[kNhist];
116
db72ff3b 117 hist[0] = new TH1D("qaTRD_hits_det", "TRD hits det;Detector Id of the hit;Counts", 540, -0.5, 539.5) ;
04236e67 118
db72ff3b 119 hist[1] = new TH1D("qaTRD_hist_Qdrift", "TRD hits Qdrift;Charge from tracks;Counts", 100, 0, 100);
120 hist[2] = new TH1D("qaTRD_hist_Qamp", "TRD hits Qamp;Charge from TRD photon;Counts", 100, 0, 100);
121 hist[3] = new TH1D("qaTRD_hist_Qphoton", "TRD hits Qphoton;Charge from TRD photon;Counts", 100, 0, 100);
04236e67 122
123 for(Int_t i=0; i<kNhist; i++) {
124 //hist[i]->Sumw2();
7d297381 125 Add2HitsList(hist[i], i, !expert, image);
04236e67 126 }
127
128}
129
130//____________________________________________________________________________
131void AliTRDQADataMakerSim::InitDigits()
132{
133 //
134 // Create Digits histograms in Digits subdir
135 //
7d297381 136 const Bool_t expert = kTRUE ;
137 const Bool_t image = kTRUE ;
138
04236e67 139 const Int_t kNhist = 3;
140 TH1D *hist[kNhist];
141
db72ff3b 142 hist[0] = new TH1D("qaTRD_digits_det", "TRD digits det;Detector Id of the digit;Counts", 540, -0.5, 539.5);
143 hist[1] = new TH1D("qaTRD_digits_time", "TRDdigits time;Time bin;Counts", 40, -0.5, 39.5);
144 hist[2] = new TH1D("qaTRD_digits_amp", "TRD digits amp;Amplitude;Counts", 100, -5.5, 94.5);
04236e67 145
146 for(Int_t i=0; i<kNhist; i++) {
147 hist[i]->Sumw2();
7d297381 148 Add2DigitsList(hist[i], i, !expert, image);
04236e67 149 }
150
151}
152
153//____________________________________________________________________________
154void AliTRDQADataMakerSim::InitSDigits()
155{
156 //
157 // Create SDigits histograms in SDigits subdir
158 //
7d297381 159 const Bool_t expert = kTRUE ;
160 const Bool_t image = kTRUE ;
161
04236e67 162 const Int_t kNhist = 3;
163 TH1D *hist[kNhist];
164
db72ff3b 165 hist[0] = new TH1D("qaTRD_sdigits_det", "TRD sdigits det;Detector Id of the digit;Counts", 540, -0.5, 539.5);
166 hist[1] = new TH1D("qaTRD_sdigits_time", "TRD sdigits time;Time bin;Counts", 40, -0.5, 39.5);
167 hist[2] = new TH1D("qaTRD_sdigits_amp", "TRD sdigits amp;Amplitude;Counts", 100, 0, 1e7);
04236e67 168
169 for(Int_t i=0; i<kNhist; i++) {
170 hist[i]->Sumw2();
7d297381 171 Add2SDigitsList(hist[i], i, !expert, image);
04236e67 172 }
173
174}
175
176//____________________________________________________________________________
177void AliTRDQADataMakerSim::MakeHits(TClonesArray * hits)
178{
179 //
180 // Make QA data from Hits
181 //
182
eca4fa66 183 // Check id histograms already created for this Event Specie
184 if ( ! GetHitsData(0) )
185 InitHits() ;
186
04236e67 187 TIter next(hits);
188 AliTRDhit * hit;
189
190 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
191 GetHitsData(0)->Fill(hit->GetDetector());
192 Double_t q = TMath::Abs(hit->GetCharge());
193
194 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
195 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
196 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
197 }
198
199}
200
201//____________________________________________________________________________
202void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
203{
204 //
205 // Make QA data from Hits
206 //
207
208 if (!CheckPointer(hitTree, "TRD hits tree")) return;
209
210 TBranch *branch = hitTree->GetBranch("TRD");
211 if (!CheckPointer(branch, "TRD hits branch")) return;
eca4fa66 212
04236e67 213 Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
214 TClonesArray *hits = new TClonesArray("AliTRDhit", nhits+1000);
215 TClonesArray *tmp = new TClonesArray("AliTRDhit", 1000);
216 branch->SetAddress(&tmp);
217
218 Int_t index = 0;
219 Int_t nEntries = (Int_t)branch->GetEntries();
220 for(Int_t i = 0; i < nEntries; i++) {
221 branch->GetEntry(i);
222 Int_t nHits = (Int_t)tmp->GetEntries();
223 for(Int_t j=0; j<nHits; j++) {
224 AliTRDhit *hit = (AliTRDhit*)tmp->At(j);
225 new((*hits)[index++]) AliTRDhit(*hit);
226 }
227 }
228
229 tmp->Delete();
230 delete tmp;
231 MakeHits(hits);
c10bf383 232 hits->Delete();
233 delete hits;
04236e67 234
235}
236
237//____________________________________________________________________________
238void AliTRDQADataMakerSim::MakeDigits(TClonesArray * digits)
239{
240 //
241 // Makes data from Digits
242 //
243
eca4fa66 244 // Check id histograms already created for this Event Specie
245 if ( ! GetDigitsData(0) )
246 InitDigits() ;
247
04236e67 248 TIter next(digits) ;
249 AliTRDdigit * digit ;
3590bda8 250
251 // Info("Make digits", "From the arrya");
252
04236e67 253 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
3590bda8 254 if (digit->GetAmp() < 1) continue;
04236e67 255 GetDigitsData(0)->Fill(digit->GetDetector());
256 GetDigitsData(1)->Fill(digit->GetTime());
257 GetDigitsData(2)->Fill(digit->GetAmp());
258 }
259
260}
261
262//____________________________________________________________________________
263void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
264{
265 //
266 // Makes data from digits tree
267 //
eca4fa66 268 // Check id histograms already created for this Event Specie
269 if ( ! GetDigitsData(0) )
270 InitDigits() ;
3590bda8 271 // Info("Make digits", "From a tree");
272
04236e67 273 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
274 digitsManager->CreateArrays();
275 digitsManager->ReadDigits(digits);
276
3590bda8 277 TH1D *histDet = (TH1D*)GetDigitsData(0);
278 TH1D *histTime = (TH1D*)GetDigitsData(1);
279 TH1D *histSignal = (TH1D*)GetDigitsData(2);
280
b65e5048 281 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
282 {
283 AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);
284
285 // This is to take care of switched off super modules
286 if (digitsIn->GetNtime() == 0) continue;
287
288 digitsIn->Expand();
289
290 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
291 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
292
293 Int_t nRows = digitsIn->GetNrow();
294 Int_t nCols = digitsIn->GetNcol();
295 Int_t nTbins = digitsIn->GetNtime();
296
297 for(Int_t row = 0; row < nRows; row++)
eca4fa66 298 for(Int_t col = 0; col < nCols; col++)
299 for(Int_t time = 0; time < nTbins; time++)
300 {
301 Float_t signal = digitsIn->GetData(row,col,time);
302 if (signal < 1) continue;
303 histDet->Fill(i);
304 histTime->Fill(time);
305 histSignal->Fill(signal);
306 }
307
308 //delete digitsIn;
309 }
04236e67 310 delete digitsManager;
04236e67 311}
312
313//____________________________________________________________________________
314void AliTRDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
315{
316 //
317 // Makes data from Digits
318 //
319
eca4fa66 320 // Check id histograms already created for this Event Specie
321 if ( ! GetSDigitsData(0) )
322 InitSDigits() ;
323
04236e67 324 TIter next(sdigits) ;
325 AliTRDdigit * digit ;
326 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
327 GetDigitsData(0)->Fill(digit->GetDetector());
328 GetDigitsData(1)->Fill(digit->GetTime());
329 GetDigitsData(2)->Fill(digit->GetAmp());
330 }
331
332}
333
334//____________________________________________________________________________
335void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
336{
337 //
338 // Makes data from SDigits
339 //
eca4fa66 340 // Check id histograms already created for this Event Specie
341 if ( ! GetSDigitsData(0) )
342 InitSDigits() ;
343
04236e67 344 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
c10bf383 345 digitsManager->SetSDigits(kTRUE);
04236e67 346 digitsManager->CreateArrays();
347 digitsManager->ReadDigits(digits);
348
3590bda8 349 TH1D *histDet = (TH1D*)GetSDigitsData(0);
350 TH1D *histTime = (TH1D*)GetSDigitsData(1);
351 TH1D *histSignal = (TH1D*)GetSDigitsData(2);
352
b65e5048 353 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
354 {
355 AliTRDarraySignal *digitsIn = (AliTRDarraySignal *) digitsManager->GetSDigits(i);
356
04236e67 357 // This is to take care of switched off super modules
b65e5048 358 if (digitsIn->GetNtime() == 0) continue;
359
360 digitsIn->Expand();
361
362 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
363 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
364 Int_t nRows = digitsIn->GetNrow();
365 Int_t nCols = digitsIn->GetNcol();
366 Int_t nTbins = digitsIn->GetNtime();
367
368 for(Int_t row = 0; row < nRows; row++)
369 {
370 for(Int_t col = 0; col < nCols; col++)
371 {
372 for(Int_t time = 0; time < nTbins; time++)
373 {
374 Float_t signal = digitsIn->GetData(row,col,time);
375 if (signal < 1) continue;
376 histDet->Fill(i);
377 histTime->Fill(time);
378 histSignal->Fill(signal);
379 }
380 }
381 }
382 // delete digitsIn;
383 }
04236e67 384 delete digitsManager;
04236e67 385}
386
387//____________________________________________________________________________
388void AliTRDQADataMakerSim::StartOfDetectorCycle()
389{
390 //
391 // Detector specific actions at start of cycle
392 //
393
394}
395
396//__________________________________________________________________________
397Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
398{
399 //
400 // Checks initialization of pointers
401 //
402
403 if (!obj) AliWarning(Form("null pointer: %s", name));
404 return !!obj;
405
406}