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 "AliTRDrawStreamTB.h"
51 #include "AliQAChecker.h"
53 ClassImp(AliTRDQADataMakerSim)
55 //____________________________________________________________________________
56 AliTRDQADataMakerSim::AliTRDQADataMakerSim() :
57 AliQADataMakerSim(AliQA::GetDetName(AliQA::kTRD), "TRD Quality Assurance Data Maker")
60 // Default constructor
63 //____________________________________________________________________________
64 AliTRDQADataMakerSim::AliTRDQADataMakerSim(const AliTRDQADataMakerSim& qadm) :
71 SetName((const char*)qadm.GetName()) ;
72 SetTitle((const char*)qadm.GetTitle());
76 //__________________________________________________________________
77 AliTRDQADataMakerSim& AliTRDQADataMakerSim::operator=(const AliTRDQADataMakerSim& qadm)
83 this->~AliTRDQADataMakerSim();
84 new(this) AliTRDQADataMakerSim(qadm);
89 //____________________________________________________________________________
90 void AliTRDQADataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
93 // Detector specific actions at end of cycle
96 //AliInfo(Form("EndOfCycle", "Fitting RecPoints %d", task));
99 AliQAChecker::Instance()->Run(AliQA::kTRD, task, list) ;
104 //____________________________________________________________________________
105 void AliTRDQADataMakerSim::InitHits()
108 // Create Hits histograms in Hits subdir
111 const Int_t kNhist = 4;
114 hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ;
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);
120 for(Int_t i=0; i<kNhist; i++) {
122 Add2HitsList(hist[i], i);
127 //____________________________________________________________________________
128 void AliTRDQADataMakerSim::InitDigits()
131 // Create Digits histograms in Digits subdir
134 const Int_t kNhist = 3;
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, -5.5, 94.5);
141 for(Int_t i=0; i<kNhist; i++) {
143 Add2DigitsList(hist[i], i);
148 //____________________________________________________________________________
149 void AliTRDQADataMakerSim::InitSDigits()
152 // Create SDigits histograms in SDigits subdir
155 const Int_t kNhist = 3;
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);
162 for(Int_t i=0; i<kNhist; i++) {
164 Add2SDigitsList(hist[i], i);
169 //____________________________________________________________________________
170 void AliTRDQADataMakerSim::MakeHits(TClonesArray * hits)
173 // Make QA data from Hits
179 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
180 GetHitsData(0)->Fill(hit->GetDetector());
181 Double_t q = TMath::Abs(hit->GetCharge());
183 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
184 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
185 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
190 //____________________________________________________________________________
191 void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
194 // Make QA data from Hits
197 if (!CheckPointer(hitTree, "TRD hits tree")) return;
199 TBranch *branch = hitTree->GetBranch("TRD");
200 if (!CheckPointer(branch, "TRD hits branch")) return;
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);
208 Int_t nEntries = (Int_t)branch->GetEntries();
209 for(Int_t i = 0; i < nEntries; 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);
224 //____________________________________________________________________________
225 void AliTRDQADataMakerSim::MakeDigits(TClonesArray * digits)
228 // Makes data from Digits
232 AliTRDdigit * digit ;
234 // Info("Make digits", "From the arrya");
236 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
237 if (digit->GetAmp() < 1) continue;
238 GetDigitsData(0)->Fill(digit->GetDetector());
239 GetDigitsData(1)->Fill(digit->GetTime());
240 GetDigitsData(2)->Fill(digit->GetAmp());
245 //____________________________________________________________________________
246 void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
249 // Makes data from digits tree
252 // Info("Make digits", "From a tree");
254 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
255 digitsManager->CreateArrays();
256 digitsManager->ReadDigits(digits);
258 TH1D *histDet = (TH1D*)GetDigitsData(0);
259 TH1D *histTime = (TH1D*)GetDigitsData(1);
260 TH1D *histSignal = (TH1D*)GetDigitsData(2);
262 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
264 AliTRDdataArrayS *digitsIn = (AliTRDdataArrayS *) digitsManager->GetDigits(i);
266 // This is to take care of switched off super modules
267 if (digitsIn->GetNtime() == 0) continue;
271 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
272 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
274 Int_t nRows = digitsIn->GetNrow();
275 Int_t nCols = digitsIn->GetNcol();
276 Int_t nTbins = digitsIn->GetNtime();
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++) {
282 Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
283 if (signal < 1) continue;
285 histTime->Fill(time);
286 histSignal->Fill(signal);
292 delete digitsManager;
296 //____________________________________________________________________________
297 void AliTRDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
300 // Makes data from Digits
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());
313 //____________________________________________________________________________
314 void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
317 // Makes data from SDigits
320 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
321 digitsManager->CreateArrays();
322 digitsManager->ReadDigits(digits);
324 TH1D *histDet = (TH1D*)GetSDigitsData(0);
325 TH1D *histTime = (TH1D*)GetSDigitsData(1);
326 TH1D *histSignal = (TH1D*)GetSDigitsData(2);
328 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
330 AliTRDdataArrayS *digitsIn = (AliTRDdataArrayS *) digitsManager->GetDigits(i);
332 // This is to take care of switched off super modules
333 if (digitsIn->GetNtime() == 0) continue;
337 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
338 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
340 Int_t nRows = digitsIn->GetNrow();
341 Int_t nCols = digitsIn->GetNcol();
342 Int_t nTbins = digitsIn->GetNtime();
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++) {
348 Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
349 if (signal < 1) continue;
351 histTime->Fill(time);
352 histSignal->Fill(signal);
358 delete digitsManager;
362 //____________________________________________________________________________
363 void AliTRDQADataMakerSim::StartOfDetectorCycle()
366 // Detector specific actions at start of cycle
371 //__________________________________________________________________________
372 Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
375 // Checks initialization of pointers
378 if (!obj) AliWarning(Form("null pointer: %s", name));