Changes in QA to be able to process separately different triggers (Ruben)
[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);
92664bc8 108 //
109 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
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);
92664bc8 134 //
135 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
44ed7a66 136}
137
a9523c3e 138//____________________________________________________________________________
139void AliPMDQADataMakerRec::InitRecPoints()
140{
141 // create Reconstructed Points histograms in RecPoints subdir
2c1131dd 142
143 /*
a9523c3e 144 TH2F * h0 = new TH2F("hPreXY","RecPoints Y vs X PRE(PMD)", 100,-100.,100.,100,-100.,100.);
2c1131dd 145 Add2RecPointsList(h0,0);
146
a9523c3e 147 TH2F * h1 = new TH2F("hCpvXY","RecPoints Y vs X CPV(PMD)", 100,-100.,100.,100,-100.,100.);
2c1131dd 148 Add2RecPointsList(h1,1);
149 */
a9523c3e 150
2c1131dd 151 // Ncell distribution in a cluster
152
b5144d1f 153 // PRE plane
154
7d297381 155 const Bool_t expert = kTRUE ;
156 const Bool_t image = kTRUE ;
157
db72ff3b 158 TH1F * h0 = new TH1F("hPreDdl0Ncell","PRE: Ddl0 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 159 h0->Sumw2();
7d297381 160 Add2RecPointsList(h0, 0, !expert, image);
a9523c3e 161
a9523c3e 162
db72ff3b 163 TH1F * h1 = new TH1F("hPreDdl1Ncell","PRE: Ddl1 Ncell in a cluste;# of cells;Countsr",50,0.,50.);
2c1131dd 164 h1->Sumw2();
7d297381 165 Add2RecPointsList(h1, 1, !expert, image);
2c1131dd 166
167
db72ff3b 168 TH1F * h2 = new TH1F("hPreDdl2Ncell","PRE: Ddl2 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 169 h2->Sumw2();
7d297381 170 Add2RecPointsList(h2, 2, !expert, image);
2c1131dd 171
172
db72ff3b 173 TH1F * h3 = new TH1F("hPreDdl3Ncell","PRE: Ddl3 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 174 h3->Sumw2();
7d297381 175 Add2RecPointsList(h3, 3, !expert, image);
2c1131dd 176
b5144d1f 177 // CPV plane
178
db72ff3b 179 TH1F * h4 = new TH1F("hCpvDdl4Ncell","CPV: Ddl4 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 180 h4->Sumw2();
7d297381 181 Add2RecPointsList(h4, 4, !expert, image);
2c1131dd 182
db72ff3b 183 TH1F * h5 = new TH1F("hCpvDdl5Ncell","CPV: Ddl5 Ncell in a cluster;# of cells;Counts",50,0.,50.);
2c1131dd 184 h5->Sumw2();
7d297381 185 Add2RecPointsList(h5, 5, !expert, image);
2c1131dd 186
187 // Correlation plot
188
db72ff3b 189 TH2I *h6 = new TH2I("hPre10","Cluster - DDL1 vs DDL0;DDL0;DDL1", 100,0,200,100,0,200);
7d297381 190 Add2RecPointsList(h6,6, !expert, image);
2c1131dd 191
db72ff3b 192 TH2I *h7 = new TH2I("hPre32","Cluster - DDL3 vs DDL2;DDL2;DDL3", 100,0,200,100,0,200);
7d297381 193 Add2RecPointsList(h7,7, !expert, image);
2c1131dd 194
db72ff3b 195 TH2I *h8 = new TH2I("hCpv54","Cluster - DDL5 vs DDL4;DDL4;DDL5", 100,0,200,100,0,200);
7d297381 196 Add2RecPointsList(h8,8, !expert, image);
92664bc8 197 //
198 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
a9523c3e 199}
200
201//____________________________________________________________________________
202
203void AliPMDQADataMakerRec::InitESDs()
204{
205 //Create histograms to controll ESD
2c1131dd 206
7d297381 207 const Bool_t expert = kTRUE ;
208 const Bool_t image = kTRUE ;
209
db72ff3b 210 TH1F *h0 = new TH1F("hPreClADC","Cluster ADC of PRE plane;# of clusters;Counts",500,0.,10000.);
a9523c3e 211 h0->Sumw2();
7d297381 212 Add2ESDsList(h0, 0, !expert, image) ;
a9523c3e 213
db72ff3b 214 TH1F *h1 = new TH1F("hCpvClADC","Cluster ADC of CPV plane;# of clusters;Counts",500,0.,10000.);
a9523c3e 215 h1->Sumw2();
7d297381 216 Add2ESDsList(h1, 1, !expert, image) ;
a9523c3e 217
db72ff3b 218 TH2I *h2 = new TH2I("hPmdClMult","Cluster Multiplicity: PRE vs. CPVplane;CPV multiplicity;PRE Multiplicity",100,0,1000,100,0,1000);
a9523c3e 219 h2->Sumw2();
7d297381 220 Add2ESDsList(h2, 2, !expert, image) ;
a9523c3e 221
92664bc8 222 /*
223 TH1I * h3 = new TH1I("hCpvClMult","Cluster Multiplicity of CPV plane",100,0.,1000.);
224 h3->Sumw2();
225 Add2ESDsList(h3, 3, !expert, image) ;
226 */
227 //
228 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
a9523c3e 229}
230
231//____________________________________________________________________________
232void AliPMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
233{
92664bc8 234 //Fill prepared histograms with Raw digit properties
a9523c3e 235
eca4fa66 236 TObjArray *pmdddlcont = 0x0;
2c1131dd 237 pmdddlcont = new TObjArray();
a9523c3e 238 AliPMDRawStream stream(rawReader);
239
2c1131dd 240 AliPMDddldata *pmdddl = 0x0;
a9523c3e 241
2c1131dd 242 Int_t iddl = -1;
243 Int_t xpad = -1;
244 Int_t ypad = -1;
be8b7039 245 Float_t xx = 0., yy = 0.;
a9523c3e 246
2c1131dd 247 AliPMDUtility cc;
248
249 while ((iddl = stream.DdlData(pmdddlcont)) >=0)
a9523c3e 250 {
2c1131dd 251 Int_t ientries = pmdddlcont->GetEntries();
a9523c3e 252 //printf(" ======= DDLNO = %d ientries = %d \n", iddl, ientries);
2c1131dd 253
a9523c3e 254 for (Int_t ient = 0; ient < ientries; ient++)
2c1131dd 255 {
256 //AliPMDddldata *pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient);
257 pmdddl = (AliPMDddldata*)pmdddlcont->UncheckedAt(ient);
258
259 Int_t det = pmdddl->GetDetector();
260 Int_t smn = pmdddl->GetSMN();
261 Int_t mcm = pmdddl->GetMCM();
a9523c3e 262 //Int_t chno = pmdddl->GetChannel();
2c1131dd 263 Int_t row = pmdddl->GetRow();
264 Int_t col = pmdddl->GetColumn();
a9523c3e 265 Int_t sig = pmdddl->GetSignal();
a9523c3e 266
f15229be 267 if (mcm == 0) continue;
268 if (det < 0 || det > 1) continue;
269 if (smn < 0 || smn > 23) continue;
270 if (row < 0 || row > 47) continue;
271 if (col < 0 || col > 95) continue;
2c1131dd 272
6fb728a5 273 Int_t ipp = 10000*smn + 100*row + col;
274
2c1131dd 275 if (det == 0)
276 {
92664bc8 277 FillRawsData(0,ipp, sig);
278 FillRawsData(2,ipp);
6fb728a5 279
2c1131dd 280 if(smn < 12)
281 {
282 xpad = col;
283 ypad = row;
284 }
285 else if(smn >= 12 && smn < 24)
286 {
287 xpad = row;
288 ypad = col;
289 }
6fb728a5 290
291
2c1131dd 292 cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
92664bc8 293 FillRawsData(4,xx,yy);
2c1131dd 294 }
295 if (det == 1)
296 {
92664bc8 297 FillRawsData(1,ipp, sig);
298 FillRawsData(3,ipp);
6fb728a5 299
2c1131dd 300 if(smn < 12)
301 {
302 xpad = col;
303 ypad = row;
304 }
305 else if(smn >= 12 && smn < 24)
306 {
307 xpad = row;
308 ypad = col;
309 }
310
311 cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
92664bc8 312 FillRawsData(5,xx,yy);
2c1131dd 313
314 }
315
316 }
317
318 pmdddlcont->Delete();
a9523c3e 319 }
2c1131dd 320
321 delete pmdddlcont;
322 pmdddlcont = 0x0;
92664bc8 323 //
324 IncEvCountCycleRaws();
325 IncEvCountTotalRaws();
326 //
a9523c3e 327}
328//____________________________________________________________________________
6252ceeb 329void AliPMDQADataMakerRec::MakeDigits()
44ed7a66 330{
331 // makes data from Digits
332
6252ceeb 333 Int_t cpvmul = 0, premul = 0;
44ed7a66 334
6252ceeb 335 TIter next(fDigitsArray) ;
44ed7a66 336 AliPMDdigit * digit ;
337 while ( (digit = dynamic_cast<AliPMDdigit *>(next())) )
338 {
339 if(digit->GetDetector() == 0)
340 {
92664bc8 341 FillDigitsData(0, digit->GetADC()) ;
44ed7a66 342 premul++;
343 }
344 if(digit->GetDetector() == 1)
345 {
92664bc8 346 FillDigitsData(1, digit->GetADC());
44ed7a66 347 cpvmul++;
348 }
349 }
350
92664bc8 351 if (premul > 0) FillDigitsData(2,premul);
352 if (cpvmul > 0) FillDigitsData(3,cpvmul);
44ed7a66 353
354
355}
356
357//____________________________________________________________________________
358void AliPMDQADataMakerRec::MakeDigits(TTree * digitTree)
359{
360 // makes data from Digit Tree
361
6252ceeb 362 if (fDigitsArray)
363 fDigitsArray->Clear() ;
364 else
365 fDigitsArray = new TClonesArray("AliPMDdigit", 1000) ;
44ed7a66 366
367 TBranch * branch = digitTree->GetBranch("PMDDigit") ;
92664bc8 368 if ( ! branch ) {AliWarning("PMD branch in Digit Tree not found"); return;}
369 //
370 branch->SetAddress(&fDigitsArray) ;
371 for (Int_t ient = 0; ient < branch->GetEntries(); ient++) {
372 branch->GetEntry(ient) ;
373 MakeDigits() ;
374 }
375 //
376 IncEvCountCycleDigits();
377 IncEvCountTotalDigits();
378 //
44ed7a66 379}
380
381//____________________________________________________________________________
a9523c3e 382void AliPMDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
383{
384 // makes data from RecPoints
385
eca4fa66 386 Int_t multDdl0 = 0, multDdl1 = 0, multDdl2 = 0;
db06ef51 387 Int_t multDdl3 = 0, multDdl4 = 0, multDdl5 = 0;
388
389 AliPMDrecpoint1 * recpoint;
390
6252ceeb 391 if (fRecPointsArray)
392 fRecPointsArray->Clear() ;
393 else
394 fRecPointsArray = new TClonesArray("AliPMDrecpoint1", 1000) ;
db06ef51 395
396 TBranch * branch = clustersTree->GetBranch("PMDRecpoint") ;
a9523c3e 397
db06ef51 398 if ( ! branch )
a9523c3e 399 {
db06ef51 400 AliWarning("PMD branch in Recpoints Tree not found") ;
a9523c3e 401 }
db06ef51 402 else
a9523c3e 403 {
db06ef51 404 branch->SetAddress(&fRecPointsArray) ;
405
406 for (Int_t imod = 0; imod < branch->GetEntries(); imod++)
a9523c3e 407 {
db06ef51 408 branch->GetEntry(imod) ;
409
410 TIter next(fRecPointsArray) ;
411
412 while ( (recpoint = dynamic_cast<AliPMDrecpoint1 *>(next())) )
413 {
414 //Float_t xpos = recpoint->GetClusX();
415 //Float_t ypos = recpoint->GetClusY();
416 //Int_t smn = recpoint->GetSMNumber();
417
418 if(recpoint->GetDetector() == 0)
419 {
420 if(recpoint->GetSMNumber() >= 0 && recpoint->GetSMNumber() < 6)
421 {
92664bc8 422 FillRecPointsData(0,recpoint->GetClusCells());
db06ef51 423 multDdl0++;
424 }
425 if(recpoint->GetSMNumber() >= 6 && recpoint->GetSMNumber() < 12)
426 {
92664bc8 427 FillRecPointsData(1,recpoint->GetClusCells());
db06ef51 428 multDdl1++;
429 }
430 if(recpoint->GetSMNumber() >= 12 && recpoint->GetSMNumber() < 18)
431 {
92664bc8 432 FillRecPointsData(2,recpoint->GetClusCells());
db06ef51 433 multDdl2++;
434 }
435 if(recpoint->GetSMNumber() >= 18 && recpoint->GetSMNumber() < 24)
436 {
92664bc8 437 FillRecPointsData(3,recpoint->GetClusCells());
db06ef51 438 multDdl3++;
439 }
440 }
441
442 if(recpoint->GetDetector() == 1)
443 {
444 if((recpoint->GetSMNumber() >= 0 && recpoint->GetSMNumber() < 6) ||
445 (recpoint->GetSMNumber() >= 18 && recpoint->GetSMNumber() < 24))
446 {
92664bc8 447 FillRecPointsData(4,recpoint->GetClusCells());
db06ef51 448 multDdl4++;
449 }
450 if(recpoint->GetSMNumber() >= 6 && recpoint->GetSMNumber() < 18 )
451 {
92664bc8 452 FillRecPointsData(5,recpoint->GetClusCells());
db06ef51 453 multDdl5++;
454 }
455 }
456 }
a9523c3e 457 }
458 }
db06ef51 459
92664bc8 460 FillRecPointsData(6,multDdl0,multDdl1);
461 FillRecPointsData(7,multDdl2,multDdl3);
462 FillRecPointsData(8,multDdl4,multDdl5);
463 //
464 IncEvCountCycleRecPoints();
465 IncEvCountTotalRecPoints();
466 //
a9523c3e 467}
468
469//____________________________________________________________________________
470
471void AliPMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
472{
473 // make QA data from ESDs
474
eca4fa66 475 Int_t premul = 0, cpvmul = 0;
2c1131dd 476
477 for (Int_t icl = 0; icl < esd->GetNumberOfPmdTracks(); icl++)
a9523c3e 478 {
2c1131dd 479 AliESDPmdTrack *pmdtr = esd->GetPmdTrack(icl);
480
481 //Int_t det = pmdtr->GetDetector();
482 //Float_t clsX = pmdtr->GetClusterX();
483 //Float_t clsY = pmdtr->GetClusterY();
484 //Float_t clsZ = pmdtr->GetClusterZ();
485 //Float_t ncell = pmdtr->GetClusterCells();
486 Float_t adc = pmdtr->GetClusterADC();
487 //Float_t pid = pmdtr->GetClusterPID();
488
489 if (pmdtr->GetDetector() == 0)
a9523c3e 490 {
92664bc8 491 FillESDsData(0,adc);
2c1131dd 492 premul++;
a9523c3e 493 }
2c1131dd 494 if (pmdtr->GetDetector() == 1)
a9523c3e 495 {
92664bc8 496 FillESDsData(1,adc) ;
2c1131dd 497 cpvmul++;
a9523c3e 498 }
499 }
2c1131dd 500
92664bc8 501 FillESDsData(2,cpvmul,premul) ;
502 //FillESDsData(3,cpvmul) ;
503 //
504 IncEvCountCycleESDs();
505 IncEvCountTotalESDs();
506 //
a9523c3e 507}
508
509//____________________________________________________________________________
510
511void AliPMDQADataMakerRec::StartOfDetectorCycle()
512{
513 //Detector specific actions at start of cycle
514
515}
516//____________________________________________________________________________
4e25ac79 517void AliPMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
a9523c3e 518{
519 //Detector specific actions at end of cycle
520 // do the QA checking
4e25ac79 521 AliQAChecker::Instance()->Run(AliQAv1::kPMD, task, list) ;
a9523c3e 522}