]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDQADataMakerRec.cxx
extra bit for TPC and Global constrained flagging
[u/mrichter/AliRoot.git] / PMD / AliPMDQADataMakerRec.cxx
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"
38 #include "AliPMDdigit.h" 
39 #include "AliPMDrecpoint1.h" 
40 #include "AliPMDRawStream.h"
41 #include "AliPMDddldata.h"
42 #include "AliPMDUtility.h"
43 #include "AliESDPmdTrack.h"
44 //#include "AliPMDRecoParam.h"
45
46 ClassImp(AliPMDQADataMakerRec)
47            
48 //____________________________________________________________________________ 
49   AliPMDQADataMakerRec::AliPMDQADataMakerRec() : 
50   AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kPMD), "PMD Quality Assurance Data Maker")
51 {
52   // ctor
53 }
54
55 //____________________________________________________________________________ 
56 AliPMDQADataMakerRec::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 //__________________________________________________________________
65 AliPMDQADataMakerRec& AliPMDQADataMakerRec::operator = (const AliPMDQADataMakerRec& qadm )
66 {
67   // Equal operator.
68   this->~AliPMDQADataMakerRec();
69   new(this) AliPMDQADataMakerRec(qadm);
70   return *this;
71 }
72  
73
74 //____________________________________________________________________________ 
75 void AliPMDQADataMakerRec::InitRaws()
76 {
77   // create Raws histograms in Raws subdir
78
79   const Bool_t expert   = kTRUE ; 
80   const Bool_t saveCorr = kTRUE ; 
81   const Bool_t image    = kTRUE ; 
82   
83   TH1F *hCellAdcPRE = new TH1F("hCellAdcPRE", "Cell Wise ADC fill for PRE Shower Plane;Cells in SMN-ROW-COL;ADC", 234795, 0, 234795);
84  
85   Add2RawsList(hCellAdcPRE, 0, !expert, image, !saveCorr);  
86
87
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);  
91
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);  
96
97
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);  
101
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   //  
109   ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
110 }
111
112 //____________________________________________________________________________
113 void AliPMDQADataMakerRec::InitDigits()
114 {
115   // create Digits histograms in Digits subdir
116   const Bool_t expert   = kTRUE ; 
117   const Bool_t image    = kTRUE ; 
118   
119   TH1F *h0 = new TH1F("hPreDigitsEdep","Digits energy distribution in PRE(PMD);Amplitude [ADC counts];Counts", 100, 0., 2000.);
120   h0->Sumw2();
121   Add2DigitsList(h0, 0, !expert, image);
122   
123   TH1F *h1 = new TH1F("hCpvDigitsEdep","Digits energy distribution in CPV(PMD);Amplitude [ADC counts];Counts", 100, 0., 2000.); 
124   h1->Sumw2();
125   Add2DigitsList(h1, 1, !expert, image);
126   
127   TH1I *h2 = new TH1I("hPreDigitsMult","Digits multiplicity distribution in PRE(PMD);# of Digits;Entries", 500, 0, 1000) ; 
128   h2->Sumw2();
129   Add2DigitsList(h2, 2, !expert, image);
130   
131   TH1I *h3 = new TH1I("hCpvDigitsMult","Digits multiplicity distribution in CPV(PMD);# of Digits;Entries", 500, 0, 1000);
132   h3->Sumw2();
133   Add2DigitsList(h3, 3, !expert, image);  
134   //
135   ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
136 }
137
138 //____________________________________________________________________________ 
139 void AliPMDQADataMakerRec::InitRecPoints()
140 {
141   // create Reconstructed Points histograms in RecPoints subdir
142   
143   /*
144     TH2F * h0 = new TH2F("hPreXY","RecPoints Y vs X PRE(PMD)", 100,-100.,100.,100,-100.,100.);
145     Add2RecPointsList(h0,0);
146     
147     TH2F * h1 = new TH2F("hCpvXY","RecPoints Y vs X CPV(PMD)", 100,-100.,100.,100,-100.,100.);
148     Add2RecPointsList(h1,1);
149   */
150
151     //  Ncell distribution in a cluster
152   
153     // PRE plane
154
155   const Bool_t expert   = kTRUE ; 
156   const Bool_t image    = kTRUE ; 
157
158   TH1F * h0 = new TH1F("hPreDdl0Ncell","PRE: Ddl0 Ncell in a cluster;# of cells;Counts",50,0.,50.);
159   h0->Sumw2();
160   Add2RecPointsList(h0, 0, !expert, image);
161
162
163   TH1F * h1 = new TH1F("hPreDdl1Ncell","PRE: Ddl1 Ncell in a cluste;# of cells;Countsr",50,0.,50.);
164   h1->Sumw2();
165   Add2RecPointsList(h1, 1, !expert, image);
166
167
168   TH1F * h2 = new TH1F("hPreDdl2Ncell","PRE: Ddl2 Ncell in a cluster;# of cells;Counts",50,0.,50.);
169   h2->Sumw2();
170   Add2RecPointsList(h2, 2, !expert, image);
171
172
173   TH1F * h3 = new TH1F("hPreDdl3Ncell","PRE: Ddl3 Ncell in a cluster;# of cells;Counts",50,0.,50.);
174   h3->Sumw2();
175   Add2RecPointsList(h3, 3, !expert, image);
176
177   // CPV plane
178
179   TH1F * h4 = new TH1F("hCpvDdl4Ncell","CPV: Ddl4 Ncell in a cluster;# of cells;Counts",50,0.,50.);
180   h4->Sumw2();
181   Add2RecPointsList(h4, 4, !expert, image);
182
183   TH1F * h5 = new TH1F("hCpvDdl5Ncell","CPV: Ddl5 Ncell in a cluster;# of cells;Counts",50,0.,50.);
184   h5->Sumw2();
185   Add2RecPointsList(h5, 5, !expert, image);
186
187   // Correlation plot
188
189   TH2I *h6 = new TH2I("hPre10","Cluster - DDL1 vs DDL0;DDL0;DDL1", 100,0,200,100,0,200);
190   Add2RecPointsList(h6,6, !expert, image);
191
192   TH2I *h7 = new TH2I("hPre32","Cluster - DDL3 vs DDL2;DDL2;DDL3", 100,0,200,100,0,200);
193   Add2RecPointsList(h7,7, !expert, image);
194
195   TH2I *h8 = new TH2I("hCpv54","Cluster - DDL5 vs DDL4;DDL4;DDL5", 100,0,200,100,0,200);
196   Add2RecPointsList(h8,8, !expert, image);
197   //
198   ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
199 }
200
201 //____________________________________________________________________________ 
202
203 void AliPMDQADataMakerRec::InitESDs()
204 {
205   //Create histograms to controll ESD
206
207   const Bool_t expert   = kTRUE ; 
208   const Bool_t image    = kTRUE ; 
209
210   TH1F *h0 = new TH1F("hPreClADC","Cluster ADC of PRE plane;# of clusters;Counts",500,0.,10000.);
211   h0->Sumw2();
212   Add2ESDsList(h0, 0, !expert, image)  ;
213
214   TH1F *h1 = new TH1F("hCpvClADC","Cluster ADC of CPV plane;# of clusters;Counts",500,0.,10000.);
215   h1->Sumw2();
216   Add2ESDsList(h1, 1, !expert, image)  ;
217
218   TH2I *h2 = new TH2I("hPmdClMult","Cluster Multiplicity: PRE vs. CPVplane;CPV multiplicity;PRE Multiplicity",100,0,1000,100,0,1000);
219   h2->Sumw2();
220   Add2ESDsList(h2, 2, !expert, image)  ;
221
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
229 }
230
231 //____________________________________________________________________________
232 void AliPMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
233 {
234   //Fill prepared histograms with Raw digit properties
235
236   TObjArray *pmdddlcont = 0x0;
237     pmdddlcont = new TObjArray();
238     AliPMDRawStream stream(rawReader);
239     
240     AliPMDddldata *pmdddl = 0x0;
241
242     Int_t   iddl = -1;
243     Int_t   xpad = -1;
244     Int_t   ypad = -1;
245     Float_t xx = 0., yy = 0.;
246
247     AliPMDUtility cc;
248
249     while ((iddl = stream.DdlData(pmdddlcont)) >=0)
250     {
251         Int_t ientries = pmdddlcont->GetEntries();
252         //printf(" ======= DDLNO = %d ientries = %d \n", iddl, ientries);
253         
254         for (Int_t ient = 0; ient < ientries; ient++)
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();
262             //Int_t chno = pmdddl->GetChannel();
263             Int_t row = pmdddl->GetRow();
264             Int_t col = pmdddl->GetColumn();
265             Int_t sig = pmdddl->GetSignal();
266             
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;
272
273             Int_t ipp = 10000*smn + 100*row + col;
274
275             if (det == 0)
276             {
277               FillRawsData(0,ipp, sig);
278               FillRawsData(2,ipp);
279
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                 }
290
291
292                 cc.RectGeomCellPos(smn,xpad,ypad,xx,yy);
293                 FillRawsData(4,xx,yy);
294             }
295             if (det == 1)
296             {
297               FillRawsData(1,ipp, sig);
298               FillRawsData(3,ipp);
299         
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);
312                 FillRawsData(5,xx,yy);
313
314             }
315
316           }
317
318         pmdddlcont->Delete();
319     }
320
321     delete pmdddlcont;
322     pmdddlcont = 0x0;
323     //
324     IncEvCountCycleRaws();
325     IncEvCountTotalRaws();
326     //
327 }
328 //____________________________________________________________________________
329 void AliPMDQADataMakerRec::MakeDigits()
330 {
331   // makes data from Digits
332   
333    Int_t cpvmul = 0, premul = 0;
334   
335   TIter next(fDigitsArray) ; 
336   AliPMDdigit * digit ; 
337   while ( (digit = dynamic_cast<AliPMDdigit *>(next())) )
338     {
339     if(digit->GetDetector() == 0)
340       {
341             FillDigitsData(0, digit->GetADC()) ;
342             premul++;
343       }
344     if(digit->GetDetector() == 1)
345       {
346             FillDigitsData(1, digit->GetADC());
347             cpvmul++;
348       }
349     }  
350   
351   if (premul > 0) FillDigitsData(2,premul);
352   if (cpvmul > 0) FillDigitsData(3,cpvmul);
353   
354   
355 }
356
357 //____________________________________________________________________________
358 void AliPMDQADataMakerRec::MakeDigits(TTree * digitTree)
359 {
360   // makes data from Digit Tree
361   
362   if (fDigitsArray) 
363     fDigitsArray->Clear() ; 
364   else
365     fDigitsArray = new TClonesArray("AliPMDdigit", 1000) ; 
366   
367   TBranch * branch = digitTree->GetBranch("PMDDigit") ;
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   //
379 }
380
381 //____________________________________________________________________________
382 void AliPMDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
383 {
384     // makes data from RecPoints
385
386   Int_t multDdl0 = 0, multDdl1 = 0, multDdl2 = 0;
387   Int_t multDdl3 = 0, multDdl4 = 0, multDdl5 = 0;
388   
389   AliPMDrecpoint1 * recpoint; 
390   
391   if (fRecPointsArray) 
392     fRecPointsArray->Clear() ; 
393   else 
394     fRecPointsArray = new TClonesArray("AliPMDrecpoint1", 1000) ; 
395   
396   TBranch * branch = clustersTree->GetBranch("PMDRecpoint") ;
397
398   if ( ! branch )
399     {
400       AliWarning("PMD branch in Recpoints Tree not found") ; 
401     }
402   else
403     {
404       branch->SetAddress(&fRecPointsArray) ;
405       
406       for (Int_t imod = 0; imod < branch->GetEntries(); imod++)
407         {
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                     {
422                       FillRecPointsData(0,recpoint->GetClusCells());
423                       multDdl0++;
424                     }
425                   if(recpoint->GetSMNumber() >= 6 && recpoint->GetSMNumber() < 12)
426                     {
427                       FillRecPointsData(1,recpoint->GetClusCells());
428                       multDdl1++;
429                     }
430                   if(recpoint->GetSMNumber() >= 12 && recpoint->GetSMNumber() < 18)
431                     {
432                       FillRecPointsData(2,recpoint->GetClusCells());
433                       multDdl2++;
434                     }
435                   if(recpoint->GetSMNumber() >= 18 && recpoint->GetSMNumber() < 24)
436                     {
437                       FillRecPointsData(3,recpoint->GetClusCells());
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                     {
447                       FillRecPointsData(4,recpoint->GetClusCells());
448                       multDdl4++;
449                     }
450                   if(recpoint->GetSMNumber() >= 6 && recpoint->GetSMNumber() < 18 )
451                     {
452                       FillRecPointsData(5,recpoint->GetClusCells());
453                       multDdl5++;
454                     }
455                 }
456             } 
457         }
458     }
459   
460   FillRecPointsData(6,multDdl0,multDdl1);
461   FillRecPointsData(7,multDdl2,multDdl3);
462   FillRecPointsData(8,multDdl4,multDdl5);
463   //
464   IncEvCountCycleRecPoints();
465   IncEvCountTotalRecPoints();  
466   //
467 }
468
469 //____________________________________________________________________________
470
471 void AliPMDQADataMakerRec::MakeESDs(AliESDEvent * esd)
472 {
473   // make QA data from ESDs
474
475   Int_t premul = 0, cpvmul = 0;
476
477   for (Int_t icl = 0; icl < esd->GetNumberOfPmdTracks(); icl++)
478     {
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)
490         {
491           FillESDsData(0,adc);
492           premul++;
493         }
494       if (pmdtr->GetDetector() == 1)
495         {
496           FillESDsData(1,adc) ;
497           cpvmul++;
498         }
499     }
500   
501   FillESDsData(2,cpvmul,premul) ;
502   //FillESDsData(3,cpvmul) ;  
503   //
504   IncEvCountCycleESDs();
505   IncEvCountTotalESDs(); 
506   //
507 }
508
509 //____________________________________________________________________________ 
510
511 void AliPMDQADataMakerRec::StartOfDetectorCycle()
512 {
513   //Detector specific actions at start of cycle
514   
515 }
516 //____________________________________________________________________________ 
517 void AliPMDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
518 {
519   //Detector specific actions at end of cycle
520   // do the QA checking
521   AliQAChecker::Instance()->Run(AliQAv1::kPMD, task, list) ;  
522 }