]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFQADataMakerRec.cxx
updated hardcoded status information: disabled not connected MRPC strips
[u/mrichter/AliRoot.git] / TOF / AliTOFQADataMakerRec.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>
5c7c93fa 29
30#include "AliLog.h"
04236e67 31#include "AliESDEvent.h"
32#include "AliESDtrack.h"
04236e67 33#include "AliQAChecker.h"
34#include "AliRawReader.h"
5c7c93fa 35
36#include "AliTOFcluster.h"
37#include "AliTOFQADataMakerRec.h"
04236e67 38#include "AliTOFRawStream.h"
39#include "AliTOFrawData.h"
5c7c93fa 40#include "AliTOFGeometry.h"
5192f264 41#include "AliTOFdigit.h"
04236e67 42
43ClassImp(AliTOFQADataMakerRec)
44
45//____________________________________________________________________________
46 AliTOFQADataMakerRec::AliTOFQADataMakerRec() :
4e25ac79 47 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker")
04236e67 48{
49 //
50 // ctor
51 //
52}
53
54//____________________________________________________________________________
55AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
56 AliQADataMakerRec()
57{
58 //
59 //copy ctor
60 //
61 SetName((const char*)qadm.GetName()) ;
62 SetTitle((const char*)qadm.GetTitle());
63}
64
65//__________________________________________________________________
66AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
67{
68 //
69 // assignment operator.
70 //
71 this->~AliTOFQADataMakerRec();
72 new(this) AliTOFQADataMakerRec(qadm);
73 return *this;
74}
75
76//____________________________________________________________________________
77void AliTOFQADataMakerRec::InitRaws()
78{
79 //
80 // create Raws histograms in Raws subdir
81 //
135306ea 82
7d297381 83 const Bool_t expert = kTRUE ;
84 const Bool_t saveCorr = kTRUE ;
85 const Bool_t image = kTRUE ;
86
db72ff3b 87 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws;TOF raw number [10 power];Counts ",301, -1.02, 5.) ;
5561a41b 88 h0->Sumw2() ;
7d297381 89 Add2RawsList(h0, 0, !expert, image, !saveCorr) ;
04236e67 90
0a2a478c 91 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns);Measured TOF time [ns];Counts", 20000, 0., 2000) ;
04236e67 92 h1->Sumw2() ;
7d297381 93 Add2RawsList(h1, 1, !expert, image, !saveCorr) ;
04236e67 94
db72ff3b 95 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns);Measured TOT time [ns];Counts", 500, 0., 50) ;
04236e67 96 h2->Sumw2() ;
7d297381 97 Add2RawsList(h2, 2, !expert, image, !saveCorr) ;
04236e67 98
db72ff3b 99 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi;2*strip+padz (eta);48*sector+padx (phi)",183, -0.5, 182.5,865,-0.5,864.5) ;
04236e67 100 h3->Sumw2() ;
5561a41b 101 h3->GetYaxis()->SetTitleOffset(1.15);
7d297381 102 Add2RawsList(h3, 3, !expert, image, !saveCorr) ;
04236e67 103
104}
105
44ed7a66 106//____________________________________________________________________________
107void AliTOFQADataMakerRec::InitDigits()
108{
109 //
110 // create Digits histograms in Digits subdir
111 //
112
113 const Bool_t expert = kTRUE ;
114 const Bool_t image = kTRUE ;
115
db72ff3b 116 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits;TOF digit number [10 power];Counts ",301, -1.02, 5.) ;
44ed7a66 117 h0->Sumw2() ;
44ed7a66 118 Add2DigitsList(h0, 0, !expert, image) ;
119
0a2a478c 120 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns);Digitized TOF time [ns];Counts", 20000, 0., 2000) ;
44ed7a66 121 h1->Sumw2() ;
44ed7a66 122 Add2DigitsList(h1, 1, !expert, image) ;
123
db72ff3b 124 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns);Digitized TOF time [ns];Counts", 500, 0., 50) ;
44ed7a66 125 h2->Sumw2() ;
44ed7a66 126 Add2DigitsList(h2, 2, !expert, image) ;
127
db72ff3b 128 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi;2*strip+padz (eta);48*sector+padx (phi)",183, -0.5, 182.5,865,-0.5,864.5) ;
44ed7a66 129 h3->Sumw2() ;
44ed7a66 130 h3->GetYaxis()->SetTitleOffset(1.15);
131 Add2DigitsList(h3, 3, !expert, image) ;
44ed7a66 132}
133
04236e67 134//____________________________________________________________________________
135void AliTOFQADataMakerRec::InitRecPoints()
136{
137 //
138 // create RecPoints histograms in RecPoints subdir
139 //
135306ea 140
7d297381 141 const Bool_t expert = kTRUE ;
142 const Bool_t image = kTRUE ;
eca4fa66 143
db72ff3b 144 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints;TOF recPoint number [10 power];Counts",301, -1.02, 5.) ;
5561a41b 145 h0->Sumw2() ;
7d297381 146 Add2RecPointsList(h0, 0, !expert, image) ;
04236e67 147
0a2a478c 148 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns);Calibrated TOF time [ns];Counts", 20000, 0., 2000) ;
04236e67 149 h1->Sumw2() ;
7d297381 150 Add2RecPointsList(h1, 1, !expert, image) ;
04236e67 151
0a2a478c 152 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns);Measured TOF time [ns];Counts", 20000, 0., 2000) ;
04236e67 153 h2->Sumw2() ;
7d297381 154 Add2RecPointsList(h2, 2, !expert, image) ;
04236e67 155
db72ff3b 156 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns);Measured TOT [ns];Counts", 500, 0., 50) ;
04236e67 157 h3->Sumw2() ;
7d297381 158 Add2RecPointsList(h3, 3, !expert, image) ;
04236e67 159
db72ff3b 160 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta;2*strip+padz (eta);48*sector+padx (phi)",183, -0.5, 182.5,865,-0.5,864.5) ;
04236e67 161 h4->Sumw2() ;
5561a41b 162 h4->GetYaxis()->SetTitleOffset(1.15);
7d297381 163 Add2RecPointsList(h4, 4, !expert, image) ;
04236e67 164}
165
166//____________________________________________________________________________
167void AliTOFQADataMakerRec::InitESDs()
168{
169 //
170 //create ESDs histograms in ESDs subdir
171 //
135306ea 172
7d297381 173 const Bool_t expert = kTRUE ;
174 const Bool_t image = kTRUE ;
db72ff3b 175 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs;Number of TOF matched ESD tracks [10 power];Counts", 250, -1., 4.) ;
04236e67 176 h0->Sumw2() ;
7d297381 177 Add2ESDsList(h0, 0, !expert, image) ;
04236e67 178
0a2a478c 179 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns);Calibrated TOF time [ns];Counts", 20000, 0., 2000) ;
04236e67 180 h1->Sumw2() ;
7d297381 181 Add2ESDsList(h1, 1, !expert, image) ;
04236e67 182
0a2a478c 183 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns);Measured TOF time [ns];Counts", 20000, 0., 2000) ;
04236e67 184 h2->Sumw2() ;
7d297381 185 Add2ESDsList(h2, 2, !expert, image) ;
04236e67 186
db72ff3b 187 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns);Measured TOF time [ns];Counts", 500, 0., 50) ;
04236e67 188 h3->Sumw2() ;
7d297381 189 Add2ESDsList(h3, 3, !expert, image) ;
04236e67 190
db72ff3b 191 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag (%);Fraction of TOF matched ESD tracks with good flag [%];Counts", 101, 0., 101.) ;
04236e67 192 h4->Sumw2() ;
7d297381 193 Add2ESDsList(h4, 4, !expert, image) ;
04236e67 194}
195
196//____________________________________________________________________________
197void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
198{
199 //
200 // makes data from Raws
201 //
eca4fa66 202
04236e67 203 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
204 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
205
206
207 Int_t ntof = 0 ;
208 Int_t in[5];
209 Int_t out[5];
210
211 TClonesArray * clonesRawData;
212 AliTOFRawStream tofInput(rawReader);
213 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
214 rawReader->Reset();
215 tofInput.LoadRawData(iDDL);
216 clonesRawData = (TClonesArray*)tofInput.GetRawData();
217 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
218 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
219 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
220 ntof++;
221 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
222 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
223
224 tofInput.EquipmentId2VolumeId(iDDL,
225 tofRawDatum->GetTRM(),
226 tofRawDatum->GetTRMchain(),
227 tofRawDatum->GetTDC(),
228 tofRawDatum->GetTDCchannel(),
229 in);
230
231 GetMapIndeces(in,out);
232 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
233
234 } // while loop
235
236 clonesRawData->Clear();
237
238 } // DDL Loop
239
240 Int_t nentries=ntof;
241 if(nentries<=0){
242 GetRawsData(0)->Fill(-1.) ;
243 }else{
244 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
245 }
246}
247
248//____________________________________________________________________________
6252ceeb 249void AliTOFQADataMakerRec::MakeDigits()
44ed7a66 250{
251 //
252 // makes data from Digits
253 //
eca4fa66 254
44ed7a66 255 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
256 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
257 Int_t in[5];
258 Int_t out[5];
259
6252ceeb 260 Int_t nentries=fDigitsArray->GetEntriesFast();
44ed7a66 261 if(nentries<=0){
262 GetDigitsData(0)->Fill(-1.) ;
263 }else{
264 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
265 }
266
6252ceeb 267 TIter next(fDigitsArray) ;
44ed7a66 268 AliTOFdigit * digit ;
269 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
270
271 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
272 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
273
274 in[0] = digit->GetSector();
275 in[1] = digit->GetPlate();
276 in[2] = digit->GetStrip();
277 in[3] = digit->GetPadx();
278 in[4]= digit->GetPadz();
279 GetMapIndeces(in,out);
280 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
281 }
44ed7a66 282}
283
284//____________________________________________________________________________
285void AliTOFQADataMakerRec::MakeDigits(TTree * digitTree)
286{
287 //
288 // makes data from Digit Tree
289 //
eca4fa66 290
6252ceeb 291 if (fDigitsArray)
292 fDigitsArray->Clear() ;
293 else
294 fDigitsArray = new TClonesArray("AliTOFdigit", 1000) ;
44ed7a66 295
296 TBranch * branch = digitTree->GetBranch("TOF") ;
297 if ( ! branch ) {
298 AliError("TOF branch in Digit Tree not found") ;
299 return;
300 }
6252ceeb 301 branch->SetAddress(&fDigitsArray) ;
44ed7a66 302 branch->GetEntry(0) ;
6252ceeb 303 MakeDigits() ;
44ed7a66 304}
305
306//____________________________________________________________________________
04236e67 307void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
308{
309 //
310 // Make data from Clusters
311 //
6252ceeb 312
04236e67 313 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
314 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
315
316 Int_t in[5];
317 Int_t out[5];
318
319 TBranch *branch=clustersTree->GetBranch("TOF");
320 if (!branch) {
321 AliError("can't get the branch with the TOF clusters !");
322 return;
323 }
324
b12e6fe4 325 static TClonesArray dummy("AliTOFcluster",10000);
326 dummy.Clear();
327 TClonesArray *clusters=&dummy;
04236e67 328 branch->SetAddress(&clusters);
329
330 // Import the tree
331 clustersTree->GetEvent(0);
332
333 Int_t nentries=clusters->GetEntriesFast();
334 if(nentries<=0){
335 GetRecPointsData(0)->Fill(-1.) ;
336 }else{
337 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
338 }
339
340 TIter next(clusters) ;
341 AliTOFcluster * c ;
342 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
343 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
344 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
345 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
346
347 in[0] = c->GetDetInd(0);
348 in[1] = c->GetDetInd(1);
349 in[2] = c->GetDetInd(2);
350 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
351 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
352
353 GetMapIndeces(in,out);
354 GetRecPointsData(4)->Fill(out[0],out[1]);
355
356 }
357}
358
359//____________________________________________________________________________
360void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
361{
362 //
363 // make QA data from ESDs
364 //
eca4fa66 365
04236e67 366 Int_t ntrk = esd->GetNumberOfTracks() ;
367 Int_t ntof=0;
368 Int_t ntofpid=0;
369 while (ntrk--) {
370 AliESDtrack *track=esd->GetTrack(ntrk);
371 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
372 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
373 Double_t tofToT=track->GetTOFsignalToT(); //in ns
374 if(!(tofTime>0))continue;
375 ntof++;
376 GetESDsData(1)->Fill(tofTime);
377 GetESDsData(2)->Fill(tofTimeRaw);
378 GetESDsData(3)->Fill(tofToT);
379 //check how many tracks where ESD PID is ok
380 UInt_t status=track->GetStatus();
381 if (((status&AliESDtrack::kESDpid)==0) ||
382 ((status&AliESDtrack::kTOFpid)==0)) continue;
383 ntofpid++;
384 }
385
386 Int_t nentries=ntof;
387 if(nentries<=0){
388 GetESDsData(0)->Fill(-1.) ;
389 }else{
390 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
391 }
392
7d53ce61 393 if(ntof>0) {
394 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
395 GetESDsData(4)->Fill(ratio) ;
396 }
04236e67 397}
398
399//____________________________________________________________________________
400void AliTOFQADataMakerRec::StartOfDetectorCycle()
401{
402 //
403 //Detector specific actions at start of cycle
404 //to be implemented
405}
406
407//____________________________________________________________________________
4e25ac79 408void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 409{
410 //Detector specific actions at end of cycle
411 // do the QA checking
4e25ac79 412 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
04236e67 413}
414//____________________________________________________________________________
415void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
416{
417 //
418 //return appropriate indeces for the theta-phi map
419 //
420
421 Int_t npadX = AliTOFGeometry::NpadX();
422 Int_t npadZ = AliTOFGeometry::NpadZ();
423 Int_t nStripA = AliTOFGeometry::NStripA();
424 Int_t nStripB = AliTOFGeometry::NStripB();
425 Int_t nStripC = AliTOFGeometry::NStripC();
426
427 Int_t isector = in[0];
428 Int_t iplate = in[1];
429 Int_t istrip = in[2];
430 Int_t ipadX = in[3];
431 Int_t ipadZ = in[4];
432
433 Int_t stripOffset = 0;
434 switch (iplate) {
435 case 0:
436 stripOffset = 0;
437 break;
438 case 1:
439 stripOffset = nStripC;
440 break;
441 case 2:
442 stripOffset = nStripC+nStripB;
443 break;
444 case 3:
445 stripOffset = nStripC+nStripB+nStripA;
446 break;
447 case 4:
448 stripOffset = nStripC+nStripB+nStripA+nStripB;
449 break;
450 default:
451 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
452 break;
453 };
454 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
455 Int_t phiindex=npadX*isector+ipadX+1;
456 out[0]=zindex;
457 out[1]=phiindex;
458
459}