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"),
62 // Default constructor
65 //____________________________________________________________________________
66 AliTRDQADataMakerSim::AliTRDQADataMakerSim(const AliTRDQADataMakerSim& qadm) :
74 SetName((const char*)qadm.GetName()) ;
75 SetTitle((const char*)qadm.GetTitle());
79 //__________________________________________________________________
80 AliTRDQADataMakerSim& AliTRDQADataMakerSim::operator=(const AliTRDQADataMakerSim& qadm)
86 this->~AliTRDQADataMakerSim();
87 new(this) AliTRDQADataMakerSim(qadm);
92 //____________________________________________________________________________
93 AliTRDQADataMakerSim::~AliTRDQADataMakerSim()
101 //____________________________________________________________________________
102 void AliTRDQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
105 // Detector specific actions at end of cycle
108 //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task));
111 AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;
116 //____________________________________________________________________________
117 void AliTRDQADataMakerSim::InitHits()
120 // Create Hits histograms in Hits subdir
122 const Bool_t expert = kTRUE ;
123 const Bool_t image = kTRUE ;
125 const Int_t kNhist = 4;
128 hist[0] = new TH1D("qaTRD_hits_det", "TRD hits det;Detector Id of the hit;Counts", 540, -0.5, 539.5) ;
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);
134 for(Int_t i=0; i<kNhist; i++) {
136 Add2HitsList(hist[i], i, !expert, image);
141 //____________________________________________________________________________
142 void AliTRDQADataMakerSim::InitDigits()
145 // Create Digits histograms in Digits subdir
147 const Bool_t expert = kTRUE ;
148 const Bool_t image = kTRUE ;
150 const Int_t kNhist = 3;
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);
157 for(Int_t i=0; i<kNhist; i++) {
159 Add2DigitsList(hist[i], i, !expert, image);
164 //____________________________________________________________________________
165 void AliTRDQADataMakerSim::InitSDigits()
168 // Create SDigits histograms in SDigits subdir
170 const Bool_t expert = kTRUE ;
171 const Bool_t image = kTRUE ;
173 const Int_t kNhist = 3;
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);
180 for(Int_t i=0; i<kNhist; i++) {
182 Add2SDigitsList(hist[i], i, !expert, image);
187 //____________________________________________________________________________
188 void AliTRDQADataMakerSim::MakeHits()
191 // Make QA data from Hits
194 TIter next(fHitsArray);
197 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
198 GetHitsData(0)->Fill(hit->GetDetector());
199 Double_t q = TMath::Abs(hit->GetCharge());
201 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
202 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
203 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
208 //____________________________________________________________________________
209 void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
212 // Make QA data from Hits
215 if (!CheckPointer(hitTree, "TRD hits tree")) return;
217 TBranch *branch = hitTree->GetBranch("TRD");
218 if (!CheckPointer(branch, "TRD hits branch")) return;
220 Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
222 fHitsArray->Clear() ;
224 fHitsArray = new TClonesArray("AliTRDhit", nhits+1000);
227 Int_t nEntries = (Int_t)branch->GetEntries();
228 for(Int_t i = 0; i < nEntries; i++) {
231 fHitsArray->Clear() ;
235 //____________________________________________________________________________
236 void AliTRDQADataMakerSim::MakeDigits()
239 // Makes data from Digits
245 TIter next(fDigitsArray) ;
246 AliTRDdigit * digit ;
248 // Info("Make digits", "From the arrya");
250 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
251 if (digit->GetAmp() < 1) continue;
252 GetDigitsData(0)->Fill(digit->GetDetector());
253 GetDigitsData(1)->Fill(digit->GetTime());
254 GetDigitsData(2)->Fill(digit->GetAmp());
259 //____________________________________________________________________________
260 void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
263 // Makes data from digits tree
265 // Info("Make digits", "From a tree");
267 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
268 digitsManager->CreateArrays();
269 digitsManager->ReadDigits(digits);
271 TH1D *histDet = (TH1D*)GetDigitsData(0);
272 TH1D *histTime = (TH1D*)GetDigitsData(1);
273 TH1D *histSignal = (TH1D*)GetDigitsData(2);
275 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
277 AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);
279 // This is to take care of switched off super modules
280 if (digitsIn->GetNtime() == 0) continue;
284 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
285 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
287 Int_t nRows = digitsIn->GetNrow();
288 Int_t nCols = digitsIn->GetNcol();
289 Int_t nTbins = digitsIn->GetNtime();
291 for(Int_t row = 0; row < nRows; row++)
292 for(Int_t col = 0; col < nCols; col++)
293 for(Int_t time = 0; time < nTbins; time++)
295 Float_t signal = digitsIn->GetData(row,col,time);
296 if (signal < 1) continue;
298 histTime->Fill(time);
299 histSignal->Fill(signal);
304 delete digitsManager;
307 //____________________________________________________________________________
308 void AliTRDQADataMakerSim::MakeSDigits()
311 // Makes data from Digits
317 TIter next(fSDigitsArray) ;
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());
327 //____________________________________________________________________________
328 void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
331 // Makes data from SDigits
333 // Check id histograms already created for this Event Specie
334 if ( ! GetSDigitsData(0) )
337 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
338 digitsManager->SetSDigits(kTRUE);
339 digitsManager->CreateArrays();
340 digitsManager->ReadDigits(digits);
342 TH1D *histDet = (TH1D*)GetSDigitsData(0);
343 TH1D *histTime = (TH1D*)GetSDigitsData(1);
344 TH1D *histSignal = (TH1D*)GetSDigitsData(2);
346 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
348 AliTRDarraySignal *digitsIn = (AliTRDarraySignal *) digitsManager->GetSDigits(i);
350 // This is to take care of switched off super modules
351 if (digitsIn->GetNtime() == 0) continue;
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();
361 for(Int_t row = 0; row < nRows; row++)
363 for(Int_t col = 0; col < nCols; col++)
365 for(Int_t time = 0; time < nTbins; time++)
367 Float_t signal = digitsIn->GetData(row,col,time);
368 if (signal < 1) continue;
370 histTime->Fill(time);
371 histSignal->Fill(signal);
377 delete digitsManager;
380 //____________________________________________________________________________
381 void AliTRDQADataMakerSim::StartOfDetectorCycle()
384 // Detector specific actions at start of cycle
389 //__________________________________________________________________________
390 Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
393 // Checks initialization of pointers
396 if (!obj) AliWarning(Form("null pointer: %s", name));