]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PMD/AliPMDQADataMakerSim.cxx
QA update by Sylwester
[u/mrichter/AliRoot.git] / PMD / AliPMDQADataMakerSim.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 #include <TTree.h>
30
31 // --- Standard library ---
32
33 // --- AliRoot header files ---
34
35 #include "AliLog.h"
36 #include "AliPMDhit.h"
37 #include "AliPMDsdigit.h"
38 #include "AliPMDdigit.h"
39 #include "AliPMDQADataMakerSim.h"
40 #include "AliQAChecker.h"
41
42 ClassImp(AliPMDQADataMakerSim)
43            
44 //____________________________________________________________________________ 
45 AliPMDQADataMakerSim::AliPMDQADataMakerSim() : 
46     AliQADataMakerSim(AliQA::GetDetName(AliQA::kPMD), "PMD Quality Assurance Data Maker")
47 {
48     // ctor
49 }
50
51 //____________________________________________________________________________ 
52 AliPMDQADataMakerSim::AliPMDQADataMakerSim(const AliPMDQADataMakerSim& qadm) :
53     AliQADataMakerSim()
54 {
55     //copy ctor 
56     SetName((const char*)qadm.GetName()) ; 
57     SetTitle((const char*)qadm.GetTitle()); 
58 }
59
60 //__________________________________________________________________
61 AliPMDQADataMakerSim& AliPMDQADataMakerSim::operator = (const AliPMDQADataMakerSim& qadm )
62 {
63     // Assign operator.
64     this->~AliPMDQADataMakerSim();
65     new(this) AliPMDQADataMakerSim(qadm);
66     return *this;
67 }
68  
69 //____________________________________________________________________________ 
70 void AliPMDQADataMakerSim::InitHits()
71 {
72     // create Hits histograms in Hits subdir
73
74     TH1F *h0 = new TH1F("hPreHitsEdep","Hits energy distribution in PRE(PMD)", 100, 0., 2000.); 
75     h0->Sumw2() ;
76     Add2HitsList(h0, 0) ;
77
78     TH1F *h1 = new TH1F("hCpvHitsEdep","Hits energy distribution in CPV(PMD)", 100, 0., 2000.); 
79     h1->Sumw2() ;
80     Add2HitsList(h1, 1) ;
81
82     TH1I *h2 = new TH1I("hPreHitsMult","Hits multiplicity distribution in PRE(PMD)", 500, 0, 10000) ; 
83     h2->Sumw2() ;
84     Add2HitsList(h2, 2) ;
85
86     TH1I *h3 = new TH1I("hCpvHitsMult","Hits multiplicity distribution in PRE(PMD)", 500, 0, 10000) ; 
87     h2->Sumw2() ;
88     Add2HitsList(h3, 3) ;
89 }
90
91 //____________________________________________________________________________ 
92 void AliPMDQADataMakerSim::InitSDigits()
93 {
94     // create SDigits histograms in SDigits subdir
95
96     TH1F *h0 = new TH1F("hPreSDigitsEdep","SDigits energy distribution in PRE(PMD)", 100, 0., 2000.);
97     h0->Sumw2();
98     Add2SDigitsList(h0, 0);
99
100     TH1F *h1 = new TH1F("hCpvSDigitsEdep","SDigits energy distribution in CPV(PMD)", 100, 0., 2000.);
101     h1->Sumw2();
102     Add2SDigitsList(h1, 1);
103
104     TH1I *h2 = new TH1I("hPreSDigitsMult","SDigits multiplicity distribution in PRE(PMD)", 500, 0., 5000.);
105     h2->Sumw2();
106     Add2SDigitsList(h2, 2);
107
108     TH1I *h3 = new TH1I("hCpvSDigitsMult","SDigits multiplicity distribution in CPV(PMD)", 500, 0., 5000.);
109     h3->Sumw2();
110     Add2SDigitsList(h3, 3);
111
112 }
113
114 //____________________________________________________________________________
115 void AliPMDQADataMakerSim::InitDigits()
116 {
117     // create Digits histograms in Digits subdir
118
119     TH1F *h0 = new TH1F("hPreDigitsEdep","Digits energy distribution in PRE(PMD)", 100, 0., 2000.);
120     h0->Sumw2();
121     Add2DigitsList(h0, 0);
122
123     TH1F *h1 = new TH1F("hCpvDigitsEdep","Digits energy distribution in CPV(PMD)", 100, 0., 2000.); 
124     h1->Sumw2();
125     Add2DigitsList(h1, 1);
126
127     TH1I *h2 = new TH1I("hPreDigitsMult","Digits multiplicity distribution in PRE(PMD)", 500, 0, 5000) ; 
128     h2->Sumw2();
129     Add2DigitsList(h2, 2);
130
131     TH1I *h3 = new TH1I("hCpvDigitsMult","Digits multiplicity distribution in CPV(PMD)", 500, 0, 5000);
132     h3->Sumw2();
133     Add2DigitsList(h3, 3);
134
135 }
136
137 //____________________________________________________________________________ 
138 void AliPMDQADataMakerSim::MakeHits(TClonesArray *hits)
139 {
140     //make QA data from Hits
141
142     Int_t premul = 0, cpvmul = 0;
143   
144     TIter next(hits); 
145     AliPMDhit * hit; 
146
147     while ( (hit = dynamic_cast<AliPMDhit *>(next())) )
148     {
149         if (hit->Z() > 361.5)
150         {
151             GetHitsData(0)->Fill(hit->GetEnergy());
152             premul++;
153         }
154         else if (hit->Z() < 361.5)
155         {
156             GetHitsData(1)->Fill(hit->GetEnergy());
157             cpvmul++;
158         }
159     }
160
161     if(premul <= 0)
162     {
163         GetHitsData(2)->Fill(-1.); 
164     }
165     else
166     {
167         GetHitsData(2)->Fill(premul); 
168     }
169
170     if(cpvmul <= 0)
171     {
172         GetHitsData(3)->Fill(-1.); 
173     }
174     else
175     {
176         GetHitsData(3)->Fill(cpvmul); 
177     }
178
179 }
180
181 //____________________________________________________________________________
182 void AliPMDQADataMakerSim::MakeHits(TTree * hitTree)
183 {
184     // make QA data from Hit Tree
185
186     TBranch * branch = hitTree->GetBranch("PMD") ;
187     if ( ! branch )
188     {
189         AliWarning("PMD branch in Hit Tree not found") ;
190         return;
191     }
192
193     static TClonesArray statichits("AliPMDhit", 1000);
194     statichits.Clear();
195     TClonesArray *hits = &statichits;
196     static TClonesArray staticdummy("AliPMDhit", 1000);
197     staticdummy.Clear();
198     TClonesArray *dummy = &staticdummy;
199     branch->SetAddress(&dummy);
200     Int_t index = 0 ;  
201
202     for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
203         branch->GetEntry(ientry) ; 
204         for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
205             AliPMDhit * hit = dynamic_cast<AliPMDhit *> (dummy->At(ihit)) ; 
206             new((*hits)[index]) AliPMDhit(*hit) ; 
207
208             index++ ;
209         } 
210     }   
211
212     MakeHits(hits);
213
214 }
215 //____________________________________________________________________________
216 void AliPMDQADataMakerSim::MakeSDigits(TClonesArray * sdigits)
217 {
218     // makes data from SDigits
219
220     Int_t cpvmul = 0, premul = 0;
221
222     TIter next(sdigits) ; 
223     AliPMDsdigit * sdigit ; 
224     while ( (sdigit = dynamic_cast<AliPMDsdigit *>(next())) )
225     {
226         if(sdigit->GetDetector() == 0)
227         {
228             GetSDigitsData(0)->Fill( sdigit->GetCellEdep());
229             premul++;
230         }
231         if(sdigit->GetDetector() == 1)
232         {
233             GetSDigitsData(1)->Fill( sdigit->GetCellEdep());
234             cpvmul++;
235         }
236         
237     } 
238     if (premul > 0) GetSDigitsData(2)->Fill(premul);
239     if (cpvmul > 0) GetSDigitsData(3)->Fill(cpvmul);
240     
241 }
242
243 //____________________________________________________________________________
244 void AliPMDQADataMakerSim::MakeSDigits(TTree * sdigitTree)
245 {
246     // makes data from SDigit Tree
247
248     TClonesArray * sdigits = new TClonesArray("AliPMDsdigit", 1000) ; 
249     
250     TBranch * branch = sdigitTree->GetBranch("PMDSDigit") ;
251     branch->SetAddress(&sdigits) ;
252
253     if ( ! branch )
254     {
255         AliWarning("PMD branch in SDigit Tree not found") ; 
256     }
257     else
258     {
259         for (Int_t ient = 0; ient < branch->GetEntries(); ient++)
260         {
261             branch->GetEntry(ient) ;
262             MakeSDigits(sdigits) ; 
263         }
264     }
265 }
266
267 //____________________________________________________________________________
268 void AliPMDQADataMakerSim::MakeDigits(TClonesArray * digits)
269 {
270     // makes data from Digits
271     
272     Int_t cpvmul = 0, premul = 0;
273
274     TIter next(digits) ; 
275     AliPMDdigit * digit ; 
276     while ( (digit = dynamic_cast<AliPMDdigit *>(next())) )
277     {
278         if(digit->GetDetector() == 0)
279         {
280             GetDigitsData(0)->Fill( digit->GetADC()) ;
281             premul++;
282         }
283         if(digit->GetDetector() == 1)
284         {
285             GetDigitsData(1)->Fill( digit->GetADC());
286             cpvmul++;
287         }
288     }  
289
290     if (premul > 0) GetDigitsData(2)->Fill(premul);
291     if (cpvmul > 0) GetDigitsData(3)->Fill(cpvmul);
292
293
294 }
295
296 //____________________________________________________________________________
297 void AliPMDQADataMakerSim::MakeDigits(TTree * digitTree)
298 {
299     // makes data from Digit Tree
300
301     TClonesArray * digits = new TClonesArray("AliPMDdigit", 1000) ; 
302     
303     TBranch * branch = digitTree->GetBranch("PMDDigit") ;
304     branch->SetAddress(&digits) ;
305
306     if ( ! branch )
307     {
308         AliWarning("PMD branch in Digit Tree not found") ; 
309     }
310     else
311     {
312         for (Int_t ient = 0; ient < branch->GetEntries(); ient++)
313         {
314             
315             branch->GetEntry(ient) ; 
316             MakeDigits(digits) ; 
317         }
318         
319     }
320 }
321
322
323 //____________________________________________________________________________ 
324
325 void AliPMDQADataMakerSim::StartOfDetectorCycle()
326 {
327     //Detector specific actions at start of cycle
328     
329 }
330 //____________________________________________________________________________ 
331
332 void AliPMDQADataMakerSim::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray * list)
333 {
334     //Detector specific actions at end of cycle
335     // do the QA checking
336     AliQAChecker::Instance()->Run(AliQA::kPMD, task, list) ;  
337 }