1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Produces the data needed to calculate the quality assurance. //
21 // All data must be mergeable objects. //
24 // Sylwester Radomski (radomski@physi.uni-heidelberg.de) //
26 ////////////////////////////////////////////////////////////////////////////
28 // --- ROOT system ---
29 #include <TClonesArray.h>
39 // --- AliRoot header files ---
40 //#include "AliESDEvent.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"
48 #include "AliTRDarrayADC.h"
49 #include "AliTRDarraySignal.h"
50 //#include "AliTRDrawStream.h"
52 #include "AliQAChecker.h"
54 ClassImp(AliTRDQADataMakerSim)
56 //____________________________________________________________________________
57 AliTRDQADataMakerSim::AliTRDQADataMakerSim() :
58 AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
61 // Default constructor
64 //____________________________________________________________________________
65 AliTRDQADataMakerSim::AliTRDQADataMakerSim(const AliTRDQADataMakerSim& qadm) :
72 SetName((const char*)qadm.GetName()) ;
73 SetTitle((const char*)qadm.GetTitle());
77 //__________________________________________________________________
78 AliTRDQADataMakerSim& AliTRDQADataMakerSim::operator=(const AliTRDQADataMakerSim& qadm)
84 this->~AliTRDQADataMakerSim();
85 new(this) AliTRDQADataMakerSim(qadm);
90 //____________________________________________________________________________
91 void AliTRDQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
94 // Detector specific actions at end of cycle
97 //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task));
100 AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;
105 //____________________________________________________________________________
106 void AliTRDQADataMakerSim::InitHits()
109 // Create Hits histograms in Hits subdir
111 const Bool_t expert = kTRUE ;
112 const Bool_t image = kTRUE ;
114 const Int_t kNhist = 4;
117 hist[0] = new TH1D("qaTRD_hits_det", "TRD hits det;Detector Id of the hit;Counts", 540, -0.5, 539.5) ;
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);
123 for(Int_t i=0; i<kNhist; i++) {
125 Add2HitsList(hist[i], i, !expert, image);
130 //____________________________________________________________________________
131 void AliTRDQADataMakerSim::InitDigits()
134 // Create Digits histograms in Digits subdir
136 const Bool_t expert = kTRUE ;
137 const Bool_t image = kTRUE ;
139 const Int_t kNhist = 3;
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);
146 for(Int_t i=0; i<kNhist; i++) {
148 Add2DigitsList(hist[i], i, !expert, image);
153 //____________________________________________________________________________
154 void AliTRDQADataMakerSim::InitSDigits()
157 // Create SDigits histograms in SDigits subdir
159 const Bool_t expert = kTRUE ;
160 const Bool_t image = kTRUE ;
162 const Int_t kNhist = 3;
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);
169 for(Int_t i=0; i<kNhist; i++) {
171 Add2SDigitsList(hist[i], i, !expert, image);
176 //____________________________________________________________________________
177 void AliTRDQADataMakerSim::MakeHits(TClonesArray * hits)
180 // Make QA data from Hits
186 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
187 GetHitsData(0)->Fill(hit->GetDetector());
188 Double_t q = TMath::Abs(hit->GetCharge());
190 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
191 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
192 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
197 //____________________________________________________________________________
198 void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
201 // Make QA data from Hits
204 if (!CheckPointer(hitTree, "TRD hits tree")) return;
206 TBranch *branch = hitTree->GetBranch("TRD");
207 if (!CheckPointer(branch, "TRD hits branch")) return;
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);
215 Int_t nEntries = (Int_t)branch->GetEntries();
216 for(Int_t i = 0; i < nEntries; 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);
233 //____________________________________________________________________________
234 void AliTRDQADataMakerSim::MakeDigits(TClonesArray * digits)
237 // Makes data from Digits
241 AliTRDdigit * digit ;
243 // Info("Make digits", "From the arrya");
245 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
246 if (digit->GetAmp() < 1) continue;
247 GetDigitsData(0)->Fill(digit->GetDetector());
248 GetDigitsData(1)->Fill(digit->GetTime());
249 GetDigitsData(2)->Fill(digit->GetAmp());
254 //____________________________________________________________________________
255 void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
258 // Makes data from digits tree
261 // Info("Make digits", "From a tree");
263 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
264 digitsManager->CreateArrays();
265 digitsManager->ReadDigits(digits);
267 TH1D *histDet = (TH1D*)GetDigitsData(0);
268 TH1D *histTime = (TH1D*)GetDigitsData(1);
269 TH1D *histSignal = (TH1D*)GetDigitsData(2);
271 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
273 AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);
275 // This is to take care of switched off super modules
276 if (digitsIn->GetNtime() == 0) continue;
280 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
281 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
283 Int_t nRows = digitsIn->GetNrow();
284 Int_t nCols = digitsIn->GetNcol();
285 Int_t nTbins = digitsIn->GetNtime();
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++)
291 Float_t signal = digitsIn->GetData(row,col,time);
292 if (signal < 1) continue;
294 histTime->Fill(time);
295 histSignal->Fill(signal);
300 delete digitsManager;
303 //____________________________________________________________________________
304 void AliTRDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
307 // Makes data from Digits
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());
320 //____________________________________________________________________________
321 void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
324 // Makes data from SDigits
327 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
328 digitsManager->SetSDigits(kTRUE);
329 digitsManager->CreateArrays();
330 digitsManager->ReadDigits(digits);
332 TH1D *histDet = (TH1D*)GetSDigitsData(0);
333 TH1D *histTime = (TH1D*)GetSDigitsData(1);
334 TH1D *histSignal = (TH1D*)GetSDigitsData(2);
336 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
338 AliTRDarraySignal *digitsIn = (AliTRDarraySignal *) digitsManager->GetSDigits(i);
340 // This is to take care of switched off super modules
341 if (digitsIn->GetNtime() == 0) continue;
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();
351 for(Int_t row = 0; row < nRows; row++)
353 for(Int_t col = 0; col < nCols; col++)
355 for(Int_t time = 0; time < nTbins; time++)
357 Float_t signal = digitsIn->GetData(row,col,time);
358 if (signal < 1) continue;
360 histTime->Fill(time);
361 histSignal->Fill(signal);
367 delete digitsManager;
370 //____________________________________________________________________________
371 void AliTRDQADataMakerSim::StartOfDetectorCycle()
374 // Detector specific actions at start of cycle
379 //__________________________________________________________________________
380 Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
383 // Checks initialization of pointers
386 if (!obj) AliWarning(Form("null pointer: %s", name));