]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFQADataMakerSim.cxx
fix include file dependences and correct some inline methods
[u/mrichter/AliRoot.git] / TOF / AliTOFQADataMakerSim.cxx
CommitLineData
04236e67 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16///////////////////////////////////////////////////////////////////////
17// //
18// Produces the data needed to calculate the TOF quality assurance. //
19// QA objects are 1 & 2 Dimensional histograms. //
20// author: S.Arcelli //
21// //
22///////////////////////////////////////////////////////////////////////
23
24#include <TClonesArray.h>
5c7c93fa 25//#include <TFile.h>
26//#include <TH1I.h>
04236e67 27#include <TH1F.h>
28#include <TH2F.h>
29#include <TTree.h>
30#include <TMath.h>
31
5c7c93fa 32#include "AliLog.h"
33
04236e67 34#include "AliTOFdigit.h"
35#include "AliTOFSDigit.h"
36#include "AliTOFhitT0.h"
37#include "AliTOFQADataMakerSim.h"
38#include "AliQAChecker.h"
04236e67 39#include "AliTOFGeometry.h"
40
41
42ClassImp(AliTOFQADataMakerSim)
43
44//____________________________________________________________________________
45 AliTOFQADataMakerSim::AliTOFQADataMakerSim() :
4e25ac79 46 AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker")
04236e67 47{
48 //
49 // ctor
50 //
51}
52
53//____________________________________________________________________________
54AliTOFQADataMakerSim::AliTOFQADataMakerSim(const AliTOFQADataMakerSim& qadm) :
55 AliQADataMakerSim()
56{
57 //
58 //copy ctor
59 //
60 SetName((const char*)qadm.GetName()) ;
61 SetTitle((const char*)qadm.GetTitle());
62}
63
64//__________________________________________________________________
65AliTOFQADataMakerSim& AliTOFQADataMakerSim::operator = (const AliTOFQADataMakerSim& qadm )
66{
67 //
68 // assignment operator.
69 //
70 this->~AliTOFQADataMakerSim();
71 new(this) AliTOFQADataMakerSim(qadm);
72 return *this;
73}
74
75//____________________________________________________________________________
76void AliTOFQADataMakerSim::InitHits()
77{
78 //
79 // create Hits histograms in Hits subdir
80 //
135306ea 81
7d297381 82 const Bool_t expert = kTRUE ;
83 const Bool_t image = kTRUE ;
84
04236e67 85 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
86 h0->Sumw2() ;
5561a41b 87 h0->GetXaxis()->SetTitle("TOF hit number [10 power]");
7d297381 88 Add2HitsList(h0, 0, !expert, image) ;
04236e67 89
90 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
91 h1->Sumw2() ;
5561a41b 92 h1->GetXaxis()->SetTitle("Simulated TOF time [ns]");
7d297381 93 Add2HitsList(h1, 1, !expert, image) ;
04236e67 94
95 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
96 h2->Sumw2() ;
5561a41b 97 h2->GetXaxis()->SetTitle("Track length from primary vertex till hit TOF pad [cm]");
7d297381 98 Add2HitsList(h2, 2, !expert, image) ;
04236e67 99
100 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
101 h3->Sumw2() ;
5561a41b 102 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
103 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
104 h3->GetYaxis()->SetTitleOffset(1.15);
7d297381 105 Add2HitsList(h3, 3, !expert, image) ;
04236e67 106}
107
108//____________________________________________________________________________
109void AliTOFQADataMakerSim::InitDigits()
110{
111 //
112 // create Digits histograms in Digits subdir
113 //
135306ea 114
7d297381 115 const Bool_t expert = kTRUE ;
116 const Bool_t image = kTRUE ;
117
5561a41b 118 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ;
119 h0->Sumw2() ;
120 h0->GetXaxis()->SetTitle("TOF digit number [10 power]");
7d297381 121 Add2DigitsList(h0, 0, !expert, image) ;
04236e67 122
123 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
124 h1->Sumw2() ;
5561a41b 125 h1->GetXaxis()->SetTitle("Digitized TOF time [ns]");
7d297381 126 Add2DigitsList(h1, 1, !expert, image) ;
04236e67 127
128 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
129 h2->Sumw2() ;
5561a41b 130 h2->GetYaxis()->SetTitle("Digitized TOF time [ns]");
7d297381 131 Add2DigitsList(h2, 2, !expert, image) ;
04236e67 132
133 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
134 h3->Sumw2() ;
5561a41b 135 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
136 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
137 h3->GetYaxis()->SetTitleOffset(1.15);
7d297381 138 Add2DigitsList(h3, 3, !expert, image) ;
04236e67 139
140}
141
142//____________________________________________________________________________
143void AliTOFQADataMakerSim::InitSDigits()
144{
145 //
146 // create SDigits histograms in SDigits subdir
147 //
135306ea 148
7d297381 149 const Bool_t expert = kTRUE ;
150 const Bool_t image = kTRUE ;
151
5561a41b 152 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ;
153 h0->Sumw2() ;
154 h0->GetXaxis()->SetTitle("TOF sdigit number [10 power]");
7d297381 155 Add2SDigitsList(h0, 0, !expert, image) ;
04236e67 156
157 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
158 h1->Sumw2() ;
5561a41b 159 h1->GetXaxis()->SetTitle("SDigitized TOF time [ns]");
7d297381 160 Add2SDigitsList(h1, 1, !expert, image) ;
04236e67 161
162 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
163 h2->Sumw2() ;
5561a41b 164 h2->GetXaxis()->SetTitle("2*strip+padz (eta)");
165 h2->GetYaxis()->SetTitle("48*sector+padx (phi)");
166 h2->GetYaxis()->SetTitleOffset(1.15);
7d297381 167 Add2SDigitsList(h2, 2, !expert, image) ;
04236e67 168
169}
170
171//____________________________________________________________________________
172void AliTOFQADataMakerSim::MakeHits(TClonesArray * hits)
173{
174 //
175 //make QA data from Hits
176 //
177
178 Int_t in[5];
179 Int_t out[5];
180
181 Int_t nentries=hits->GetEntriesFast();
182 if(nentries<=0) {
183 GetHitsData(0)->Fill(-1.) ;
184 } else{
185 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
186 }
187 TIter next(hits) ;
188 AliTOFhitT0 * hit ;
189 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
190
191 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
192 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
193
194 in[0] = hit->GetSector();
195 in[1] = hit->GetPlate();
196 in[2]= hit->GetStrip();
197 in[3]= hit->GetPadx();
198 in[4]= hit->GetPadz();
199 GetMapIndeces(in,out);
200 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
201 }
202
203}
204
205
206//____________________________________________________________________________
207void AliTOFQADataMakerSim::MakeHits(TTree * hitTree)
208{
209 //
210 // make QA data from Hit Tree
211 //
212 if(!hitTree){
213 AliError("can't get the tree with TOF hits !");
214 return;
215 }
216
217 TBranch * branch = hitTree->GetBranch("TOF") ;
218
219 if (!branch ) {
220 AliError("TOF branch in Hit Tree not found") ;
221 return;
222 }
223
b24266ca 224 static TClonesArray statichits("AliTOFhitT0", 1000);
225 statichits.Clear();
226 TClonesArray *hits = &statichits;
227 static TClonesArray staticdummy("AliTOFhitT0", 1000);
228 staticdummy.Clear();
229 TClonesArray *dummy = &staticdummy;
04236e67 230 branch->SetAddress(&dummy);
231 Int_t index = 0 ;
232 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
233 branch->GetEntry(ientry) ;
234 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
235 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
236 new((*hits)[index]) AliTOFhitT0(*hit) ;
237 index++ ;
238 }
239 }
240
04236e67 241 MakeHits(hits) ;
242
243}
244
245//____________________________________________________________________________
246void AliTOFQADataMakerSim::MakeDigits(TClonesArray * digits)
247{
248 //
249 // makes data from Digits
250 //
251 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
252 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
253 Int_t in[5];
254 Int_t out[5];
255
256 Int_t nentries=digits->GetEntriesFast();
257 if(nentries<=0){
258 GetDigitsData(0)->Fill(-1.) ;
259 }else{
260 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
261 }
262
263 TIter next(digits) ;
264 AliTOFdigit * digit ;
265 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
266
267 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
268 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
269
270 in[0] = digit->GetSector();
271 in[1] = digit->GetPlate();
272 in[2] = digit->GetStrip();
273 in[3] = digit->GetPadx();
274 in[4]= digit->GetPadz();
275 GetMapIndeces(in,out);
276 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
277 }
278
279}
280
281
282//____________________________________________________________________________
283void AliTOFQADataMakerSim::MakeDigits(TTree * digitTree)
284{
285 //
286 // makes data from Digit Tree
287 //
288 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
289
290 TBranch * branch = digitTree->GetBranch("TOF") ;
291 if ( ! branch ) {
292 AliError("TOF branch in Digit Tree not found") ;
293 return;
294 }
295 branch->SetAddress(&digits) ;
296 branch->GetEntry(0) ;
297 MakeDigits(digits) ;
298}
299
300//____________________________________________________________________________
301void AliTOFQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
302{
303 //
304 // makes data from SDigits
305 //
306
307 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
308 Int_t in[5];
309 Int_t out[5];
310
311 Int_t nentries=sdigits->GetEntriesFast();
312 if(nentries<=0){
313 GetSDigitsData(0)->Fill(-1.) ;
314 }else{
315 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
316 }
317
318 TIter next(sdigits) ;
319 AliTOFSDigit * sdigit ;
320 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
321
322 for(Int_t i=0;i<sdigit->GetNDigits();i++){
323 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
324 }
325
326 in[0] = sdigit->GetSector();
327 in[1] = sdigit->GetPlate();
328 in[2] = sdigit->GetStrip();
329 in[3] = sdigit->GetPadx();
330 in[4]= sdigit->GetPadz();
331 GetMapIndeces(in,out);
332 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
333 }
334}
335
336//____________________________________________________________________________
337void AliTOFQADataMakerSim::MakeSDigits(TTree * sdigitTree)
338{
339 //
340 // makes data from SDigit Tree
341 //
342 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
343
344 TBranch * branch = sdigitTree->GetBranch("TOF") ;
345 if ( ! branch ) {
346 AliError("TOF branch in SDigit Tree not found") ;
347 return;
348 }
349 branch->SetAddress(&sdigits) ;
350 branch->GetEntry(0) ;
351 MakeSDigits(sdigits) ;
352}
353
354//____________________________________________________________________________
355void AliTOFQADataMakerSim::StartOfDetectorCycle()
356{
357 //
358 //Detector specific actions at start of cycle
359 //to be implemented
360}
361
362//____________________________________________________________________________
4e25ac79 363void AliTOFQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 364{
365 //Detector specific actions at end of cycle
366 // do the QA checking
367
4e25ac79 368 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
04236e67 369}
370//____________________________________________________________________________
371void AliTOFQADataMakerSim::GetMapIndeces(Int_t* in , Int_t* out)
372{
373 //
374 //return appropriate indeces for the theta-phi map
375 //
376
377 Int_t npadX = AliTOFGeometry::NpadX();
378 Int_t npadZ = AliTOFGeometry::NpadZ();
379 Int_t nStripA = AliTOFGeometry::NStripA();
380 Int_t nStripB = AliTOFGeometry::NStripB();
381 Int_t nStripC = AliTOFGeometry::NStripC();
382
383 Int_t isector = in[0];
384 Int_t iplate = in[1];
385 Int_t istrip = in[2];
386 Int_t ipadX = in[3];
387 Int_t ipadZ = in[4];
388
389 Int_t stripOffset = 0;
390 switch (iplate) {
391 case 0:
392 stripOffset = 0;
393 break;
394 case 1:
395 stripOffset = nStripC;
396 break;
397 case 2:
398 stripOffset = nStripC+nStripB;
399 break;
400 case 3:
401 stripOffset = nStripC+nStripB+nStripA;
402 break;
403 case 4:
404 stripOffset = nStripC+nStripB+nStripA+nStripB;
405 break;
406 default:
407 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
408 break;
409 };
410 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
411 Int_t phiindex=npadX*isector+ipadX+1;
412 out[0]=zindex;
413 out[1]=phiindex;
414
415}