]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDQADataMakerSim.cxx
various updates in the resolution performance/calibration tasks
[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
97 //AliInfo(Form("EndOfCycle", "Fitting RecPoints %d", task));
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
117 hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ;
118
119 hist[1] = new TH1D("qaTRD_hist_Qdrift", ";Charge from tracks", 100, 0, 100);
120 hist[2] = new TH1D("qaTRD_hist_Qamp", ";Charge from TRD photon", 100, 0, 100);
121 hist[3] = new TH1D("qaTRD_hist_Qphoton", ";Charge from TRD photon", 100, 0, 100);
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
142 hist[0] = new TH1D("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
143 hist[1] = new TH1D("qaTRD_digits_time", ";Time bin", 40, -0.5, 39.5);
3590bda8 144 hist[2] = new TH1D("qaTRD_digits_amp", ";Amplitude", 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
165 hist[0] = new TH1D("qaTRD_sdigits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
166 hist[1] = new TH1D("qaTRD_sdigits_time", ";Time bin", 40, -0.5, 39.5);
167 hist[2] = new TH1D("qaTRD_sdigits_amp", ";Amplitude", 100, 0, 1e7);
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
183 TIter next(hits);
184 AliTRDhit * hit;
185
186 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
187 GetHitsData(0)->Fill(hit->GetDetector());
188 Double_t q = TMath::Abs(hit->GetCharge());
189
190 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
191 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
192 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
193 }
194
195}
196
197//____________________________________________________________________________
198void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
199{
200 //
201 // Make QA data from Hits
202 //
203
204 if (!CheckPointer(hitTree, "TRD hits tree")) return;
205
206 TBranch *branch = hitTree->GetBranch("TRD");
207 if (!CheckPointer(branch, "TRD hits branch")) return;
208
209 Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
210 TClonesArray *hits = new TClonesArray("AliTRDhit", nhits+1000);
211 TClonesArray *tmp = new TClonesArray("AliTRDhit", 1000);
212 branch->SetAddress(&tmp);
213
214 Int_t index = 0;
215 Int_t nEntries = (Int_t)branch->GetEntries();
216 for(Int_t i = 0; i < nEntries; i++) {
217 branch->GetEntry(i);
218 Int_t nHits = (Int_t)tmp->GetEntries();
219 for(Int_t j=0; j<nHits; j++) {
220 AliTRDhit *hit = (AliTRDhit*)tmp->At(j);
221 new((*hits)[index++]) AliTRDhit(*hit);
222 }
223 }
224
225 tmp->Delete();
226 delete tmp;
227 MakeHits(hits);
c10bf383 228 hits->Delete();
229 delete hits;
04236e67 230
231}
232
233//____________________________________________________________________________
234void AliTRDQADataMakerSim::MakeDigits(TClonesArray * digits)
235{
236 //
237 // Makes data from Digits
238 //
239
240 TIter next(digits) ;
241 AliTRDdigit * digit ;
3590bda8 242
243 // Info("Make digits", "From the arrya");
244
04236e67 245 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
3590bda8 246 if (digit->GetAmp() < 1) continue;
04236e67 247 GetDigitsData(0)->Fill(digit->GetDetector());
248 GetDigitsData(1)->Fill(digit->GetTime());
249 GetDigitsData(2)->Fill(digit->GetAmp());
250 }
251
252}
253
254//____________________________________________________________________________
255void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
256{
257 //
258 // Makes data from digits tree
259 //
260
3590bda8 261 // Info("Make digits", "From a tree");
262
04236e67 263 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
264 digitsManager->CreateArrays();
265 digitsManager->ReadDigits(digits);
266
3590bda8 267 TH1D *histDet = (TH1D*)GetDigitsData(0);
268 TH1D *histTime = (TH1D*)GetDigitsData(1);
269 TH1D *histSignal = (TH1D*)GetDigitsData(2);
270
b65e5048 271 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
272 {
273 AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);
274
275 // This is to take care of switched off super modules
276 if (digitsIn->GetNtime() == 0) continue;
277
278 digitsIn->Expand();
279
280 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
281 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
282
283 Int_t nRows = digitsIn->GetNrow();
284 Int_t nCols = digitsIn->GetNcol();
285 Int_t nTbins = digitsIn->GetNtime();
286
287 for(Int_t row = 0; row < nRows; row++)
288 for(Int_t col = 0; col < nCols; col++)
289 for(Int_t time = 0; time < nTbins; time++)
290 {
291 Float_t signal = digitsIn->GetData(row,col,time);
292 if (signal < 1) continue;
293 histDet->Fill(i);
294 histTime->Fill(time);
295 histSignal->Fill(signal);
296 }
04236e67 297
298 //delete digitsIn;
299 }
04236e67 300 delete digitsManager;
04236e67 301}
302
303//____________________________________________________________________________
304void AliTRDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
305{
306 //
307 // Makes data from Digits
308 //
309
310 TIter next(sdigits) ;
311 AliTRDdigit * digit ;
312 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
313 GetDigitsData(0)->Fill(digit->GetDetector());
314 GetDigitsData(1)->Fill(digit->GetTime());
315 GetDigitsData(2)->Fill(digit->GetAmp());
316 }
317
318}
319
320//____________________________________________________________________________
321void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
322{
323 //
324 // Makes data from SDigits
325 //
326
327 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
c10bf383 328 digitsManager->SetSDigits(kTRUE);
04236e67 329 digitsManager->CreateArrays();
330 digitsManager->ReadDigits(digits);
331
3590bda8 332 TH1D *histDet = (TH1D*)GetSDigitsData(0);
333 TH1D *histTime = (TH1D*)GetSDigitsData(1);
334 TH1D *histSignal = (TH1D*)GetSDigitsData(2);
335
b65e5048 336 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
337 {
338 AliTRDarraySignal *digitsIn = (AliTRDarraySignal *) digitsManager->GetSDigits(i);
339
04236e67 340 // This is to take care of switched off super modules
b65e5048 341 if (digitsIn->GetNtime() == 0) continue;
342
343 digitsIn->Expand();
344
345 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
346 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
347 Int_t nRows = digitsIn->GetNrow();
348 Int_t nCols = digitsIn->GetNcol();
349 Int_t nTbins = digitsIn->GetNtime();
350
351 for(Int_t row = 0; row < nRows; row++)
352 {
353 for(Int_t col = 0; col < nCols; col++)
354 {
355 for(Int_t time = 0; time < nTbins; time++)
356 {
357 Float_t signal = digitsIn->GetData(row,col,time);
358 if (signal < 1) continue;
359 histDet->Fill(i);
360 histTime->Fill(time);
361 histSignal->Fill(signal);
362 }
363 }
364 }
365 // delete digitsIn;
366 }
04236e67 367 delete digitsManager;
04236e67 368}
369
370//____________________________________________________________________________
371void AliTRDQADataMakerSim::StartOfDetectorCycle()
372{
373 //
374 // Detector specific actions at start of cycle
375 //
376
377}
378
379//__________________________________________________________________________
380Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
381{
382 //
383 // Checks initialization of pointers
384 //
385
386 if (!obj) AliWarning(Form("null pointer: %s", name));
387 return !!obj;
388
389}