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 "AliTRDdataArrayS.h"
49 #include "AliTRDdataArrayF.h"
50 //#include "AliTRDrawStreamTB.h"
52 #include "AliQAChecker.h"
54 ClassImp(AliTRDQADataMakerSim)
56 //____________________________________________________________________________
57 AliTRDQADataMakerSim::AliTRDQADataMakerSim() :
58 AliQADataMakerSim(AliQA::GetDetName(AliQA::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(AliQA::TASKINDEX_t task, TObjArray * list)
94 // Detector specific actions at end of cycle
97 //AliInfo(Form("EndOfCycle", "Fitting RecPoints %d", task));
100 AliQAChecker::Instance()->Run(AliQA::kTRD, task, list) ;
105 //____________________________________________________________________________
106 void AliTRDQADataMakerSim::InitHits()
109 // Create Hits histograms in Hits subdir
112 const Int_t kNhist = 4;
115 hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ;
117 hist[1] = new TH1D("qaTRD_hist_Qdrift", ";Charge from tracks", 100, 0, 100);
118 hist[2] = new TH1D("qaTRD_hist_Qamp", ";Charge from TRD photon", 100, 0, 100);
119 hist[3] = new TH1D("qaTRD_hist_Qphoton", ";Charge from TRD photon", 100, 0, 100);
121 for(Int_t i=0; i<kNhist; i++) {
123 Add2HitsList(hist[i], i);
128 //____________________________________________________________________________
129 void AliTRDQADataMakerSim::InitDigits()
132 // Create Digits histograms in Digits subdir
135 const Int_t kNhist = 3;
138 hist[0] = new TH1D("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
139 hist[1] = new TH1D("qaTRD_digits_time", ";Time bin", 40, -0.5, 39.5);
140 hist[2] = new TH1D("qaTRD_digits_amp", ";Amplitude", 100, -5.5, 94.5);
142 for(Int_t i=0; i<kNhist; i++) {
144 Add2DigitsList(hist[i], i);
149 //____________________________________________________________________________
150 void AliTRDQADataMakerSim::InitSDigits()
153 // Create SDigits histograms in SDigits subdir
156 const Int_t kNhist = 3;
159 hist[0] = new TH1D("qaTRD_sdigits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
160 hist[1] = new TH1D("qaTRD_sdigits_time", ";Time bin", 40, -0.5, 39.5);
161 hist[2] = new TH1D("qaTRD_sdigits_amp", ";Amplitude", 100, 0, 1e7);
163 for(Int_t i=0; i<kNhist; i++) {
165 Add2SDigitsList(hist[i], i);
170 //____________________________________________________________________________
171 void AliTRDQADataMakerSim::MakeHits(TClonesArray * hits)
174 // Make QA data from Hits
180 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
181 GetHitsData(0)->Fill(hit->GetDetector());
182 Double_t q = TMath::Abs(hit->GetCharge());
184 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
185 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
186 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
191 //____________________________________________________________________________
192 void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
195 // Make QA data from Hits
198 if (!CheckPointer(hitTree, "TRD hits tree")) return;
200 TBranch *branch = hitTree->GetBranch("TRD");
201 if (!CheckPointer(branch, "TRD hits branch")) return;
203 Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
204 TClonesArray *hits = new TClonesArray("AliTRDhit", nhits+1000);
205 TClonesArray *tmp = new TClonesArray("AliTRDhit", 1000);
206 branch->SetAddress(&tmp);
209 Int_t nEntries = (Int_t)branch->GetEntries();
210 for(Int_t i = 0; i < nEntries; i++) {
212 Int_t nHits = (Int_t)tmp->GetEntries();
213 for(Int_t j=0; j<nHits; j++) {
214 AliTRDhit *hit = (AliTRDhit*)tmp->At(j);
215 new((*hits)[index++]) AliTRDhit(*hit);
227 //____________________________________________________________________________
228 void AliTRDQADataMakerSim::MakeDigits(TClonesArray * digits)
231 // Makes data from Digits
235 AliTRDdigit * digit ;
237 // Info("Make digits", "From the arrya");
239 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
240 if (digit->GetAmp() < 1) continue;
241 GetDigitsData(0)->Fill(digit->GetDetector());
242 GetDigitsData(1)->Fill(digit->GetTime());
243 GetDigitsData(2)->Fill(digit->GetAmp());
248 //____________________________________________________________________________
249 void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
252 // Makes data from digits tree
255 // Info("Make digits", "From a tree");
257 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
258 digitsManager->CreateArrays();
259 digitsManager->ReadDigits(digits);
261 TH1D *histDet = (TH1D*)GetDigitsData(0);
262 TH1D *histTime = (TH1D*)GetDigitsData(1);
263 TH1D *histSignal = (TH1D*)GetDigitsData(2);
265 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
267 AliTRDdataArrayS *digitsIn = (AliTRDdataArrayS *) digitsManager->GetDigits(i);
269 // This is to take care of switched off super modules
270 if (digitsIn->GetNtime() == 0) continue;
274 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
275 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
277 Int_t nRows = digitsIn->GetNrow();
278 Int_t nCols = digitsIn->GetNcol();
279 Int_t nTbins = digitsIn->GetNtime();
281 for(Int_t row = 0; row < nRows; row++)
282 for(Int_t col = 0; col < nCols; col++)
283 for(Int_t time = 0; time < nTbins; time++) {
285 Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
286 if (signal < 1) continue;
288 histTime->Fill(time);
289 histSignal->Fill(signal);
295 delete digitsManager;
299 //____________________________________________________________________________
300 void AliTRDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
303 // Makes data from Digits
306 TIter next(sdigits) ;
307 AliTRDdigit * digit ;
308 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
309 GetDigitsData(0)->Fill(digit->GetDetector());
310 GetDigitsData(1)->Fill(digit->GetTime());
311 GetDigitsData(2)->Fill(digit->GetAmp());
316 //____________________________________________________________________________
317 void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
320 // Makes data from SDigits
323 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
324 digitsManager->SetSDigits(kTRUE);
325 digitsManager->CreateArrays();
326 digitsManager->ReadDigits(digits);
328 TH1D *histDet = (TH1D*)GetSDigitsData(0);
329 TH1D *histTime = (TH1D*)GetSDigitsData(1);
330 TH1D *histSignal = (TH1D*)GetSDigitsData(2);
332 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
334 //AliTRDdataArrayS *digitsIn = (AliTRDdataArrayS *) digitsManager->GetDigits(i);
335 AliTRDdataArrayF *digitsIn = (AliTRDdataArrayF *) digitsManager->GetDigits(i);
337 // This is to take care of switched off super modules
338 if (digitsIn->GetNtime() == 0) continue;
342 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
343 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
345 Int_t nRows = digitsIn->GetNrow();
346 Int_t nCols = digitsIn->GetNcol();
347 Int_t nTbins = digitsIn->GetNtime();
349 for(Int_t row = 0; row < nRows; row++)
350 for(Int_t col = 0; col < nCols; col++)
351 for(Int_t time = 0; time < nTbins; time++) {
353 Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
354 if (signal < 1) continue;
356 histTime->Fill(time);
357 histSignal->Fill(signal);
363 delete digitsManager;
367 //____________________________________________________________________________
368 void AliTRDQADataMakerSim::StartOfDetectorCycle()
371 // Detector specific actions at start of cycle
376 //__________________________________________________________________________
377 Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
380 // Checks initialization of pointers
383 if (!obj) AliWarning(Form("null pointer: %s", name));