mak HLT package consistent
[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);
139 hist[2] = new TH1D("qaTRD_digits_amp", ";Amplitude", 100, 0, 100.);
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 ;
233 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
234 GetDigitsData(0)->Fill(digit->GetDetector());
235 GetDigitsData(1)->Fill(digit->GetTime());
236 GetDigitsData(2)->Fill(digit->GetAmp());
237 }
238
239}
240
241//____________________________________________________________________________
242void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
243{
244 //
245 // Makes data from digits tree
246 //
247
248 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
249 digitsManager->CreateArrays();
250 digitsManager->ReadDigits(digits);
251
252 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
253
625f5260 254 AliTRDdataArrayS *digitsIn = (AliTRDdataArrayS *) digitsManager->GetDigits(i);
04236e67 255
256 // This is to take care of switched off super modules
257 if (digitsIn->GetNtime() == 0) continue;
258
259 digitsIn->Expand();
260
261 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
262 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
263
264 Int_t nRows = digitsIn->GetNrow();
265 Int_t nCols = digitsIn->GetNcol();
266 Int_t nTbins = digitsIn->GetNtime();
267
268 for(Int_t row = 0; row < nRows; row++)
269 for(Int_t col = 0; col < nCols; col++)
270 for(Int_t time = 0; time < nTbins; time++) {
271
272 Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
273 GetDigitsData(0)->Fill(i);
274 GetDigitsData(1)->Fill(time);
275 GetDigitsData(2)->Fill(signal);
276 }
277
278 //delete digitsIn;
279 }
280
281 delete digitsManager;
282
283}
284
285//____________________________________________________________________________
286void AliTRDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
287{
288 //
289 // Makes data from Digits
290 //
291
292 TIter next(sdigits) ;
293 AliTRDdigit * digit ;
294 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
295 GetDigitsData(0)->Fill(digit->GetDetector());
296 GetDigitsData(1)->Fill(digit->GetTime());
297 GetDigitsData(2)->Fill(digit->GetAmp());
298 }
299
300}
301
302//____________________________________________________________________________
303void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
304{
305 //
306 // Makes data from SDigits
307 //
308
309 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
310 digitsManager->CreateArrays();
311 digitsManager->ReadDigits(digits);
312
313 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
314
625f5260 315 AliTRDdataArrayS *digitsIn = (AliTRDdataArrayS *) digitsManager->GetDigits(i);
04236e67 316
317 // This is to take care of switched off super modules
318 if (digitsIn->GetNtime() == 0) continue;
319
320 digitsIn->Expand();
321
322 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
323 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
324
325 Int_t nRows = digitsIn->GetNrow();
326 Int_t nCols = digitsIn->GetNcol();
327 Int_t nTbins = digitsIn->GetNtime();
328
329 for(Int_t row = 0; row < nRows; row++)
330 for(Int_t col = 0; col < nCols; col++)
331 for(Int_t time = 0; time < nTbins; time++) {
332
333 Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
334 if (signal <= 0) continue;
335 GetSDigitsData(0)->Fill(i);
336 GetSDigitsData(1)->Fill(time);
337 GetSDigitsData(2)->Fill(signal);
338 }
339
340 // delete digitsIn;
341 }
342
343 delete digitsManager;
344
345}
346
347//____________________________________________________________________________
348void AliTRDQADataMakerSim::StartOfDetectorCycle()
349{
350 //
351 // Detector specific actions at start of cycle
352 //
353
354}
355
356//__________________________________________________________________________
357Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
358{
359 //
360 // Checks initialization of pointers
361 //
362
363 if (!obj) AliWarning(Form("null pointer: %s", name));
364 return !!obj;
365
366}