variables are initialised at creation
[u/mrichter/AliRoot.git] / PMD / AliPMDQADataMakerRec.cxx
CommitLineData
a9523c3e 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 quality assurance.
19 All data must be mergeable objects.
20 B.K. Nandi
21*/
22
23// --- ROOT system ---
24#include <TClonesArray.h>
25#include <TFile.h>
26#include <TH1F.h>
27#include <TH1I.h>
28#include <TH2F.h>
29
30// --- Standard library ---
31
32// --- AliRoot header files ---
33
34#include "AliESDEvent.h"
35#include "AliLog.h"
36#include "AliPMDQADataMakerRec.h"
37#include "AliQAChecker.h"
5192f264 38#include "AliPMDdigit.h"
a9523c3e 39#include "AliPMDrecpoint1.h"
40#include "AliPMDRawStream.h"
41#include "AliPMDddldata.h"
42#include "AliPMDUtility.h"
43#include "AliESDPmdTrack.h"
78328afd 44//#include "AliPMDRecoParam.h"
a9523c3e 45
46ClassImp(AliPMDQADataMakerRec)
47
48//____________________________________________________________________________
49 AliPMDQADataMakerRec::AliPMDQADataMakerRec() :
4e25ac79 50 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kPMD), "PMD Quality Assurance Data Maker")
a9523c3e 51{
52 // ctor
53}
54
55//____________________________________________________________________________
56AliPMDQADataMakerRec::AliPMDQADataMakerRec(const AliPMDQADataMakerRec& qadm) :
57 AliQADataMakerRec()
58{
59 //copy ctor
60 SetName((const char*)qadm.GetName()) ;
61 SetTitle((const char*)qadm.GetTitle());
62}
63
64//__________________________________________________________________
65AliPMDQADataMakerRec& AliPMDQADataMakerRec::operator = (const AliPMDQADataMakerRec& qadm )
66{
67 // Equal operator.
68 this->~AliPMDQADataMakerRec();
69 new(this) AliPMDQADataMakerRec(qadm);
70 return *this;
71}
72
73
74//____________________________________________________________________________
75void AliPMDQADataMakerRec::InitRaws()
76{
77 // create Raws histograms in Raws subdir
a9523c3e 78
7d297381 79 const Bool_t expert = kTRUE ;
80 const Bool_t saveCorr = kTRUE ;
81 const Bool_t image = kTRUE ;
6fb728a5 82
83 TH1F *hCellAdcPRE = new TH1F("hCellAdcPRE", "Cell Wise ADC fill for PRE Shower Plane;Cells in SMN-ROW-COL;ADC", 234795, 0, 234795);
2c1131dd 84
6fb728a5 85 Add2RawsList(hCellAdcPRE, 0, !expert, image, !saveCorr);
2c1131dd 86
2c1131dd 87
6fb728a5 88 TH1F *hCellAdcCPV = new TH1F("hCellAdcCPV", "Cell Wise ADC fill for CPV Veto Plane;Cells in SMN-ROW-COL;ADC", 234795, 0, 234795);
89
90 Add2RawsList(hCellAdcCPV, 1, !expert, image, !saveCorr);
2c1131dd 91
6fb728a5 92
93 TH1F *hCalibEntPRE = new TH1F("hCalibEntPRE", "Cell Wise Frequency for PRE Shower Plane;Cells in SMN-ROW-COL;Frequency", 234795, 0, 234795);
94
95 Add2RawsList(hCalibEntPRE, 2, !expert, image, !saveCorr);
2c1131dd 96
97
6fb728a5 98 TH1F *hCellEntCPV = new TH1F("hCellEntCPV", "Cell Wise Frequency for CPV Veto Plane;Cells in SMN-ROW-COL;Frequency", 234795, 0, 234795);
99
100 Add2RawsList(hCellEntCPV, 3, !expert, image, !saveCorr);
2c1131dd 101
6fb728a5 102
103 TH2F *hPreXY = new TH2F("hPreXY","PRE plane;X [cm];Y [cm]",200,-100.,100.,200,-100.,100.);
104 Add2RawsList(hPreXY, 4, !expert, !image, saveCorr);
105
106 TH2F *hCpvXY = new TH2F("hCpvXY","CPV plane;X [cm];Y [cm]",200,-100.,100.,200,-100.,100.);
107 Add2RawsList(hCpvXY, 5, !expert, !image, saveCorr);
108
a9523c3e 109
a9523c3e 110}
44ed7a66 111
112//____________________________________________________________________________
113void AliPMDQADataMakerRec::InitDigits()
114{
115 // create Digits histograms in Digits subdir
116 const Bool_t expert = kTRUE ;
117 const Bool_t image = kTRUE ;
118
db72ff3b 119 TH1F *h0 = new TH1F("hPreDigitsEdep","Digits energy distribution in PRE(PMD);Amplitude [ADC counts];Counts", 100, 0., 2000.);
44ed7a66 120 h0->Sumw2();
121 Add2DigitsList(h0, 0, !expert, image);
122
db72ff3b 123 TH1F *h1 = new TH1F("hCpvDigitsEdep","Digits energy distribution in CPV(PMD);Amplitude [ADC counts];Counts", 100, 0., 2000.);
44ed7a66 124 h1->Sumw2();
125 Add2DigitsList(h1, 1, !expert, image);
126
db72ff3b 127 TH1I *h2 = new TH1I("hPreDigitsMult","Digits multiplicity distribution in PRE(PMD);# of Digits;Entries", 500, 0, 1000) ;
44ed7a66 128 h2->Sumw2();
129 Add2DigitsList(h2, 2, !expert, image);
130
db72ff3b 131 TH1I *h3 = new TH1I("hCpvDigitsMult","Digits multiplicity distribution in CPV(PMD);# of Digits;Entries", 500, 0, 1000);
44ed7a66 132 h3->Sumw2();
db72ff3b 133 Add2DigitsList(h3, 3, !expert, image);
44ed7a66 134}
135
a9523c3e 136//____________________________________________________________________________
137void AliPMDQADataMakerRec::InitRecPoints()
138{
139 // create Reconstructed Points histograms in RecPoints subdir
2c1131dd 140
141 /*
a9523c3e 142 TH2F * h0 = new TH2F("hPreXY","RecPoints Y vs X PRE(PMD)", 100,-100.,100.,100,-100.,100.);
2c1131dd 143 Add2RecPointsList(h0,0);
144
a9523c3e 145 TH2F * h1 = new TH2F("hCpvXY","RecPoints Y vs X CPV(PMD)", 100,-100.,100.,100,-100.,100.);
2c1131dd 146 Add2RecPointsList(h1,1);
147 */
a9523c3e 148
2c1131dd 149 // Ncell distribution in a cluster
150
b5144d1f 151 // PRE plane
152
7d297381 153 const Bool_t expert = kTRUE ;
154 const Bool_t image = kTRUE ;
155
db72ff3b 156 TH1F * h0 = new TH1F("hPreDdl0Ncell","PRE: Ddl0 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 157 h0->Sumw2();
7d297381 158 Add2RecPointsList(h0, 0, !expert, image);
a9523c3e 159
a9523c3e 160
db72ff3b 161 TH1F * h1 = new TH1F("hPreDdl1Ncell","PRE: Ddl1 Ncell in a cluste;# of cells;Countsr",50,0.,50.);
2c1131dd 162 h1->Sumw2();
7d297381 163 Add2RecPointsList(h1, 1, !expert, image);
2c1131dd 164
165
db72ff3b 166 TH1F * h2 = new TH1F("hPreDdl2Ncell","PRE: Ddl2 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 167 h2->Sumw2();
7d297381 168 Add2RecPointsList(h2, 2, !expert, image);
2c1131dd 169
170
db72ff3b 171 TH1F * h3 = new TH1F("hPreDdl3Ncell","PRE: Ddl3 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 172 h3->Sumw2();
7d297381 173 Add2RecPointsList(h3, 3, !expert, image);
2c1131dd 174
b5144d1f 175 // CPV plane
176
db72ff3b 177 TH1F * h4 = new TH1F("hCpvDdl4Ncell","CPV: Ddl4 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 178 h4->Sumw2();
7d297381 179 Add2RecPointsList(h4, 4, !expert, image);
2c1131dd 180
db72ff3b 181 TH1F * h5 = new TH1F("hCpvDdl5Ncell","CPV: Ddl5 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 182 h5->Sumw2();
7d297381 183 Add2RecPointsList(h5, 5, !expert, image);
2c1131dd 184
185 // Correlation plot
186
db72ff3b 187 TH2I *h6 = new TH2I("hPre10","Cluster - DDL1 vs DDL0;DDL0;DDL1", 100,0,200,100,0,200);
7d297381 188 Add2RecPointsList(h6,6, !expert, image);
2c1131dd 189
db72ff3b 190 TH2I *h7 = new TH2I("hPre32","Cluster - DDL3 vs DDL2;DDL2;DDL3", 100,0,200,100,0,200);
7d297381 191 Add2RecPointsList(h7,7, !expert, image);
2c1131dd 192
db72ff3b 193 TH2I *h8 = new TH2I("hCpv54","Cluster - DDL5 vs DDL4;DDL4;DDL5", 100,0,200,100,0,200);
7d297381 194 Add2RecPointsList(h8,8, !expert, image);
a9523c3e 195
a9523c3e 196
197
198}
199
200//____________________________________________________________________________
201
202void AliPMDQADataMakerRec::InitESDs()
203{
204 //Create histograms to controll ESD
2c1131dd 205
7d297381 206 const Bool_t expert = kTRUE ;
207 const Bool_t image = kTRUE ;
208
db72ff3b 209 TH1F *h0 = new TH1F("hPreClADC","Cluster ADC of PRE plane;# of clusters;Counts",500,0.,10000.);
a9523c3e 210 h0->Sumw2();
7d297381 211 Add2ESDsList(h0, 0, !expert, image) ;
a9523c3e 212
db72ff3b 213 TH1F *h1 = new TH1F("hCpvClADC","Cluster ADC of CPV plane;# of clusters;Counts",500,0.,10000.);
a9523c3e 214 h1->Sumw2();
7d297381 215 Add2ESDsList(h1, 1, !expert, image) ;
a9523c3e 216
db72ff3b 217 TH2I *h2 = new TH2I("hPmdClMult","Cluster Multiplicity: PRE vs. CPVplane;CPV multiplicity;PRE Multiplicity",100,0,1000,100,0,1000);
a9523c3e 218 h2->Sumw2();
7d297381 219 Add2ESDsList(h2, 2, !expert, image) ;
a9523c3e 220
2c1131dd 221/*
222 TH1I * h3 = new TH1I("hCpvClMult","Cluster Multiplicity of CPV plane",100,0.,1000.);
a9523c3e 223 h3->Sumw2();
7d297381 224 Add2ESDsList(h3, 3, !expert, image) ;
2c1131dd 225*/
a9523c3e 226
227}
228
229//____________________________________________________________________________
230void AliPMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
231{
232 //Fill prepared histograms with Raw digit properties
233
eca4fa66 234 TObjArray *pmdddlcont = 0x0;
2c1131dd 235 pmdddlcont = new TObjArray();
a9523c3e 236 AliPMDRawStream stream(rawReader);
237
2c1131dd 238 AliPMDddldata *pmdddl = 0x0;
a9523c3e 239
2c1131dd 240 Int_t iddl = -1;
241 Int_t xpad = -1;
242 Int_t ypad = -1;
be8b7039 243 Float_t xx = 0., yy = 0.;
a9523c3e 244
2c1131dd 245 AliPMDUtility cc;
246
247 while ((iddl = stream.DdlData(pmdddlcont)) >=0)
a9523c3e 248 {
2c1131dd 249 Int_t ientries = pmdddlcont->GetEntries();
a9523c3e 250 //printf(" ======= DDLNO = %d ientries = %d \n", iddl, ientries);
2c1131dd 251
a9523c3e 252 for (Int_t ient = 0; ient < ientries; ient++)
2c1131dd 253 {
254 //AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient);
255 pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient);
256
257 Int_t det = pmdddl->GetDetector();
258 Int_t smn = pmdddl->GetSMN();
259 Int_t mcm = pmdddl->GetMCM();
a9523c3e 260 //Int_t chno = pmdddl->GetChannel();
2c1131dd 261 Int_t row = pmdddl->GetRow();
262 Int_t col = pmdddl->GetColumn();
a9523c3e 263 Int_t sig = pmdddl->GetSignal();
a9523c3e 264
f15229be 265 if (mcm == 0) continue;
266 if (det < 0 || det > 1) continue;
267 if (smn < 0 || smn > 23) continue;
268 if (row < 0 || row > 47) continue;
269 if (col < 0 || col > 95) continue;
2c1131dd 270
6fb728a5 271 Int_t ipp = 10000*smn + 100*row + col;
272
2c1131dd 273 if (det == 0)
274 {
6fb728a5 275 GetRawsData(0)->Fill(ipp, sig);
276 GetRawsData(2)->Fill(ipp);
277
2c1131dd 278 if(smn < 12)
279 {
280 xpad = col;
281 ypad = row;
282 }
283 else if(smn >= 12 && smn < 24)
284 {
285 xpad = row;
286 ypad = col;
287 }
6fb728a5 288
289
2c1131dd 290 cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
6fb728a5 291 GetRawsData(4)->Fill(xx,yy);
2c1131dd 292 }
293 if (det == 1)
294 {
6fb728a5 295 GetRawsData(1)->Fill(ipp, sig);
296 GetRawsData(3)->Fill(ipp);
297
2c1131dd 298 if(smn < 12)
299 {
300 xpad = col;
301 ypad = row;
302 }
303 else if(smn >= 12 && smn < 24)
304 {
305 xpad = row;
306 ypad = col;
307 }
308
309 cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
6fb728a5 310 GetRawsData(5)->Fill(xx,yy);
2c1131dd 311
312 }
313
314 }
315
316 pmdddlcont->Delete();
a9523c3e 317 }
2c1131dd 318
319 delete pmdddlcont;
320 pmdddlcont = 0x0;
321
a9523c3e 322}
323//____________________________________________________________________________
6252ceeb 324void AliPMDQADataMakerRec::MakeDigits()
44ed7a66 325{
326 // makes data from Digits
327
6252ceeb 328 Int_t cpvmul = 0, premul = 0;
44ed7a66 329
6252ceeb 330 TIter next(fDigitsArray) ;
44ed7a66 331 AliPMDdigit * digit ;
332 while ( (digit = dynamic_cast<AliPMDdigit *>(next())) )
333 {
334 if(digit->GetDetector() == 0)
335 {
336 GetDigitsData(0)->Fill( digit->GetADC()) ;
337 premul++;
338 }
339 if(digit->GetDetector() == 1)
340 {
341 GetDigitsData(1)->Fill( digit->GetADC());
342 cpvmul++;
343 }
344 }
345
346 if (premul > 0) GetDigitsData(2)->Fill(premul);
347 if (cpvmul > 0) GetDigitsData(3)->Fill(cpvmul);
348
349
350}
351
352//____________________________________________________________________________
353void AliPMDQADataMakerRec::MakeDigits(TTree * digitTree)
354{
355 // makes data from Digit Tree
356
6252ceeb 357 if (fDigitsArray)
358 fDigitsArray->Clear() ;
359 else
360 fDigitsArray = new TClonesArray("AliPMDdigit", 1000) ;
44ed7a66 361
362 TBranch * branch = digitTree->GetBranch("PMDDigit") ;
6252ceeb 363 branch->SetAddress(&fDigitsArray) ;
44ed7a66 364
365 if ( ! branch )
366 {
367 AliWarning("PMD branch in Digit Tree not found") ;
368 }
369 else
370 {
371 for (Int_t ient = 0; ient < branch->GetEntries(); ient++)
372 {
373 branch->GetEntry(ient) ;
6252ceeb 374 MakeDigits() ;
44ed7a66 375 }
376
377 }
378}
379
380//____________________________________________________________________________
a9523c3e 381void AliPMDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
382{
383 // makes data from RecPoints
384
eca4fa66 385 Int_t multDdl0 = 0, multDdl1 = 0, multDdl2 = 0;
b5144d1f 386 Int_t multDdl3 = 0, multDdl4 = 0, multDdl5 = 0;
2c1131dd 387
a9523c3e 388 AliPMDrecpoint1 * recpoint;
389
6252ceeb 390 if (fRecPointsArray)
391 fRecPointsArray->Clear() ;
392 else
393 fRecPointsArray = new TClonesArray("AliPMDrecpoint1", 1000) ;
a9523c3e 394
395 TBranch * branch = clustersTree->GetBranch("PMDRecpoint") ;
6252ceeb 396 branch->SetAddress(&fRecPointsArray) ;
a9523c3e 397
398 if ( ! branch )
399 {
b5144d1f 400 AliWarning("PMD branch in Recpoints Tree not found") ;
a9523c3e 401 }
402 else
403 {
404 for (Int_t imod = 0; imod < branch->GetEntries(); imod++)
405 {
406 branch->GetEntry(imod) ;
407
6252ceeb 408 TIter next(fRecPointsArray) ;
a9523c3e 409
410 while ( (recpoint = dynamic_cast<AliPMDrecpoint1 *>(next())) )
2c1131dd 411 {
a9523c3e 412 //Float_t xpos = recpoint->GetClusX();
413 //Float_t ypos = recpoint->GetClusY();
2c1131dd 414 //Int_t smn = recpoint->GetSMNumber();
415
416 if(recpoint->GetDetector() == 0)
417 {
418 if(recpoint->GetSMNumber() >= 0 && recpoint->GetSMNumber() < 6)
419 {
420 GetRecPointsData(0)->Fill(recpoint->GetClusCells());
b5144d1f 421 multDdl0++;
2c1131dd 422 }
423 if(recpoint->GetSMNumber() >= 6 && recpoint->GetSMNumber() < 12)
424 {
425 GetRecPointsData(1)->Fill(recpoint->GetClusCells());
b5144d1f 426 multDdl1++;
2c1131dd 427 }
428 if(recpoint->GetSMNumber() >= 12 && recpoint->GetSMNumber() < 18)
429 {
430 GetRecPointsData(2)->Fill(recpoint->GetClusCells());
b5144d1f 431 multDdl2++;
2c1131dd 432 }
433 if(recpoint->GetSMNumber() >= 18 && recpoint->GetSMNumber() < 24)
434 {
b5144d1f 435 GetRecPointsData(3)->Fill(recpoint->GetClusCells());
436 multDdl3++;
2c1131dd 437 }
438 }
a9523c3e 439
2c1131dd 440 if(recpoint->GetDetector() == 1)
441 {
d6cc2277 442 if((recpoint->GetSMNumber() >= 0 && recpoint->GetSMNumber() < 6) ||
443 (recpoint->GetSMNumber() >= 18 && recpoint->GetSMNumber() < 24))
2c1131dd 444 {
445 GetRecPointsData(4)->Fill(recpoint->GetClusCells());
b5144d1f 446 multDdl4++;
2c1131dd 447 }
448 if(recpoint->GetSMNumber() >= 6 && recpoint->GetSMNumber() < 18 )
449 {
450 GetRecPointsData(5)->Fill(recpoint->GetClusCells());
b5144d1f 451 multDdl5++;
2c1131dd 452 }
453 }
454 }
a9523c3e 455 }
456 }
2c1131dd 457
b5144d1f 458 GetRecPointsData(6)->Fill(multDdl0,multDdl1);
459 GetRecPointsData(7)->Fill(multDdl2,multDdl3);
460 GetRecPointsData(8)->Fill(multDdl4,multDdl5);
a9523c3e 461}
462
463//____________________________________________________________________________
464
465void AliPMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
466{
467 // make QA data from ESDs
468
eca4fa66 469 Int_t premul = 0, cpvmul = 0;
2c1131dd 470
471 for (Int_t icl = 0; icl < esd->GetNumberOfPmdTracks(); icl++)
a9523c3e 472 {
2c1131dd 473 AliESDPmdTrack *pmdtr = esd->GetPmdTrack(icl);
474
475 //Int_t det = pmdtr->GetDetector();
476 //Float_t clsX = pmdtr->GetClusterX();
477 //Float_t clsY = pmdtr->GetClusterY();
478 //Float_t clsZ = pmdtr->GetClusterZ();
479 //Float_t ncell = pmdtr->GetClusterCells();
480 Float_t adc = pmdtr->GetClusterADC();
481 //Float_t pid = pmdtr->GetClusterPID();
482
483 if (pmdtr->GetDetector() == 0)
a9523c3e 484 {
2c1131dd 485 GetESDsData(0)->Fill(adc);
486 premul++;
a9523c3e 487 }
2c1131dd 488 if (pmdtr->GetDetector() == 1)
a9523c3e 489 {
2c1131dd 490 GetESDsData(1)->Fill(adc) ;
491 cpvmul++;
a9523c3e 492 }
493 }
2c1131dd 494
495 GetESDsData(2)->Fill(cpvmul,premul) ;
496 //GetESDsData(3)->Fill(cpvmul) ;
a9523c3e 497}
498
499//____________________________________________________________________________
500
501void AliPMDQADataMakerRec::StartOfDetectorCycle()
502{
503 //Detector specific actions at start of cycle
504
505}
506//____________________________________________________________________________
4e25ac79 507void AliPMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
a9523c3e 508{
509 //Detector specific actions at end of cycle
510 // do the QA checking
4e25ac79 511 AliQAChecker::Instance()->Run(AliQAv1::kPMD, task, list) ;
a9523c3e 512}