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