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
183 // Check id histograms already created for this Event Specie
184 if ( ! GetHitsData(0) )
190 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
191 GetHitsData(0)->Fill(hit->GetDetector());
192 Double_t q = TMath::Abs(hit->GetCharge());
194 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
195 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
196 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
201 //____________________________________________________________________________
202 void AliTRDQADataMakerSim::MakeHits(TTree * hitTree)
205 // Make QA data from Hits
208 if (!CheckPointer(hitTree, "TRD hits tree")) return;
210 TBranch *branch = hitTree->GetBranch("TRD");
211 if (!CheckPointer(branch, "TRD hits branch")) return;
213 Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
214 TClonesArray *hits = new TClonesArray("AliTRDhit", nhits+1000);
215 TClonesArray *tmp = new TClonesArray("AliTRDhit", 1000);
216 branch->SetAddress(&tmp);
219 Int_t nEntries = (Int_t)branch->GetEntries();
220 for(Int_t i = 0; i < nEntries; i++) {
222 Int_t nHits = (Int_t)tmp->GetEntries();
223 for(Int_t j=0; j<nHits; j++) {
224 AliTRDhit *hit = (AliTRDhit*)tmp->At(j);
225 new((*hits)[index++]) AliTRDhit(*hit);
237 //____________________________________________________________________________
238 void AliTRDQADataMakerSim::MakeDigits(TClonesArray * digits)
241 // Makes data from Digits
244 // Check id histograms already created for this Event Specie
245 if ( ! GetDigitsData(0) )
249 AliTRDdigit * digit ;
251 // Info("Make digits", "From the arrya");
253 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
254 if (digit->GetAmp() < 1) continue;
255 GetDigitsData(0)->Fill(digit->GetDetector());
256 GetDigitsData(1)->Fill(digit->GetTime());
257 GetDigitsData(2)->Fill(digit->GetAmp());
262 //____________________________________________________________________________
263 void AliTRDQADataMakerSim::MakeDigits(TTree * digits)
266 // Makes data from digits tree
268 // Check id histograms already created for this Event Specie
269 if ( ! GetDigitsData(0) )
271 // Info("Make digits", "From a tree");
273 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
274 digitsManager->CreateArrays();
275 digitsManager->ReadDigits(digits);
277 TH1D *histDet = (TH1D*)GetDigitsData(0);
278 TH1D *histTime = (TH1D*)GetDigitsData(1);
279 TH1D *histSignal = (TH1D*)GetDigitsData(2);
281 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
283 AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);
285 // This is to take care of switched off super modules
286 if (digitsIn->GetNtime() == 0) continue;
290 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
291 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
293 Int_t nRows = digitsIn->GetNrow();
294 Int_t nCols = digitsIn->GetNcol();
295 Int_t nTbins = digitsIn->GetNtime();
297 for(Int_t row = 0; row < nRows; row++)
298 for(Int_t col = 0; col < nCols; col++)
299 for(Int_t time = 0; time < nTbins; time++)
301 Float_t signal = digitsIn->GetData(row,col,time);
302 if (signal < 1) continue;
304 histTime->Fill(time);
305 histSignal->Fill(signal);
310 delete digitsManager;
313 //____________________________________________________________________________
314 void AliTRDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
317 // Makes data from Digits
320 // Check id histograms already created for this Event Specie
321 if ( ! GetSDigitsData(0) )
324 TIter next(sdigits) ;
325 AliTRDdigit * digit ;
326 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
327 GetDigitsData(0)->Fill(digit->GetDetector());
328 GetDigitsData(1)->Fill(digit->GetTime());
329 GetDigitsData(2)->Fill(digit->GetAmp());
334 //____________________________________________________________________________
335 void AliTRDQADataMakerSim::MakeSDigits(TTree * digits)
338 // Makes data from SDigits
340 // Check id histograms already created for this Event Specie
341 if ( ! GetSDigitsData(0) )
344 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
345 digitsManager->SetSDigits(kTRUE);
346 digitsManager->CreateArrays();
347 digitsManager->ReadDigits(digits);
349 TH1D *histDet = (TH1D*)GetSDigitsData(0);
350 TH1D *histTime = (TH1D*)GetSDigitsData(1);
351 TH1D *histSignal = (TH1D*)GetSDigitsData(2);
353 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
355 AliTRDarraySignal *digitsIn = (AliTRDarraySignal *) digitsManager->GetSDigits(i);
357 // This is to take care of switched off super modules
358 if (digitsIn->GetNtime() == 0) continue;
362 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
363 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
364 Int_t nRows = digitsIn->GetNrow();
365 Int_t nCols = digitsIn->GetNcol();
366 Int_t nTbins = digitsIn->GetNtime();
368 for(Int_t row = 0; row < nRows; row++)
370 for(Int_t col = 0; col < nCols; col++)
372 for(Int_t time = 0; time < nTbins; time++)
374 Float_t signal = digitsIn->GetData(row,col,time);
375 if (signal < 1) continue;
377 histTime->Fill(time);
378 histSignal->Fill(signal);
384 delete digitsManager;
387 //____________________________________________________________________________
388 void AliTRDQADataMakerSim::StartOfDetectorCycle()
391 // Detector specific actions at start of cycle
396 //__________________________________________________________________________
397 Int_t AliTRDQADataMakerSim::CheckPointer(TObject *obj, const char *name)
400 // Checks initialization of pointers
403 if (!obj) AliWarning(Form("null pointer: %s", name));