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