]> git.uio.no Git - u/mrichter/AliRoot.git/blob - AD/ADsim/AliADQADataMakerSim.cxx
1da249c4b88ccde25d42fd3ffeefb9d205368caf
[u/mrichter/AliRoot.git] / AD / ADsim / AliADQADataMakerSim.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 /* $Id: AliADQADataMakerSim.cxx 23123 2007-12-18 09:08:18Z hristov $ */
18
19 //---
20 //  Produces the data needed to calculate the quality assurance. 
21 //  All data must be mergeable objects.
22 //  Author : BC
23 //---
24
25 // --- ROOT system ---
26 #include <TClonesArray.h>
27 #include <TFile.h> 
28 #include <TH1F.h> 
29 #include <TDirectory.h>
30 // --- Standard library ---
31
32 // --- AliRoot header files ---
33 #include "AliESDEvent.h"
34 #include "AliLog.h"
35 #include "AliADdigit.h"
36 #include "AliADSDigit.h" 
37 #include "AliADhit.h"
38 #include "AliADQADataMakerSim.h"
39 #include "AliQAChecker.h"
40
41 ClassImp(AliADQADataMakerSim)
42            
43 //____________________________________________________________________________ 
44   AliADQADataMakerSim::AliADQADataMakerSim() : 
45   AliQADataMakerSim(AliQAv1::GetDetName(AliQAv1::kAD), "AD Quality Assurance Data Maker")
46
47 {
48   // constructor
49
50   
51 }
52
53 //____________________________________________________________________________ 
54 AliADQADataMakerSim::AliADQADataMakerSim(const AliADQADataMakerSim& qadm) :
55   AliQADataMakerSim() 
56 {
57   //copy constructor 
58
59   SetName((const char*)qadm.GetName()) ; 
60   SetTitle((const char*)qadm.GetTitle()); 
61 }
62
63 //__________________________________________________________________
64 AliADQADataMakerSim& AliADQADataMakerSim::operator = (const AliADQADataMakerSim& qadm )
65 {
66   // Assign operator.
67   this->~AliADQADataMakerSim();
68   new(this) AliADQADataMakerSim(qadm);
69   return *this;
70 }
71 //____________________________________________________________________________
72 void AliADQADataMakerSim::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
73 {
74   //Detector specific actions at end of cycle
75   // do the QA checking
76   ResetEventTrigClasses();
77   AliQAChecker::Instance()->Run(AliQAv1::kAD, task, list) ;
78 }
79
80  
81 //____________________________________________________________________________ 
82 void AliADQADataMakerSim::InitHits()
83 {
84  
85   // create Hits histograms in Hits subdir
86   const Bool_t expert   = kTRUE ; 
87   const Bool_t image    = kTRUE ; 
88   
89   TH1I * h0 = new TH1I("hHitMultiplicity", "Hit multiplicity distribution in AD;# of Hits;Entries", 300, 0, 299) ; 
90   h0->Sumw2() ;
91   Add2HitsList(h0, 0, !expert, image) ;  
92   
93   TH1I * h1 = new TH1I("hHitCellNumber", "Hit cell distribution in AD;Cell;# of Hits", 16, 0, 16) ; 
94   h1->Sumw2() ;
95   Add2HitsList(h1, 1, !expert, image) ; 
96   
97   TH1I * h2 = new TH1I("hHitNPhotons", "Number of photons per hit in AD;# of Photons;Entries", 100000, 0, 100000) ; 
98   h2->Sumw2() ;
99   Add2HitsList(h2, 2, !expert, image) ;
100   
101   TH2I * h3 = new TH2I("hCellNPhotons", "Number of photons per cell in AD;Cell;# of Photons", 16, 0, 16, 100000, 0, 100000) ; 
102   h2->Sumw2() ;
103   Add2HitsList(h3, 3, !expert, image) ;
104   
105   TH2D * h4 = new TH2D("hCellTof", "Time of flight per cell in AD;Cell;Time of Flight [ns]", 16, 0, 16, 6000,40,100) ; 
106   h2->Sumw2() ;
107   Add2HitsList(h4, 4, !expert, image) ;  
108  
109   //
110   ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line    
111 }
112
113
114 //____________________________________________________________________________ 
115 void AliADQADataMakerSim::InitSDigits()
116 {
117   // create Digits histograms in Digits subdir
118   const Bool_t expert   = kTRUE ; 
119   const Bool_t image    = kTRUE ; 
120   
121   TH1I *fhSDigCharge[16]; 
122
123   // create SDigits histograms in SDigits subdir
124   TH1I * h0 = new TH1I("hSDigitMultiplicity", "SDigits multiplicity distribution in AD;# of Digits;Entries", 100, 0, 99) ; 
125   h0->Sumw2() ;
126   Add2SDigitsList(h0, 0, !expert, image) ;
127   
128   for (Int_t i=0; i<16; i++)
129     {
130        fhSDigCharge[i] = new TH1I(Form("hSDigitCharge%d", i),Form("SDigit charges in cell %d; Time;Entries",i),1700,0.,1700);
131        
132        Add2SDigitsList(fhSDigCharge[i],i+1, !expert, image);
133        
134      }   
135   //
136   ClonePerTrigClass(AliQAv1::kSDIGITS); // this should be the last line
137 }
138
139
140
141 //____________________________________________________________________________ 
142 void AliADQADataMakerSim::InitDigits()
143 {
144   // create Digits histograms in Digits subdir
145   const Bool_t expert   = kTRUE ; 
146   const Bool_t image    = kTRUE ; 
147
148   // create Digits histograms in Digits subdir
149   TH1I * h0 = new TH1I("hDigitMultiplicity", "Digits multiplicity distribution in AD;# of Digits;Entries", 100, 0, 99) ; 
150   h0->Sumw2() ;
151   Add2DigitsList(h0, 0, !expert, image) ;
152      
153   TH2D * h1 = new TH2D("hDigitLeadingTimePerPM", "Leading time distribution per PM in AD;PM number;Leading Time [ns]",16,0,16, 1000, 200, 300); 
154   h1->Sumw2() ;
155   Add2DigitsList(h1, 1, !expert, image) ; 
156   
157   TH2D * h2 = new TH2D("hDigitTimeWidthPerPM", "Time width distribution per PM in AD;PM number;Time width [ns]",16,0,16, 1000, 0, 100); 
158   h2->Sumw2() ;
159   Add2DigitsList(h2, 2, !expert, image) ;
160   
161   TH2I * h3 = new TH2I("hDigitChargePerClockPerPM", "Charge array per PM in AD;PM number; Clock",16,0,16,21, -10.5, 10.5);
162   h3->Sumw2();
163   Add2DigitsList(h3, 3, !expert, image) ;
164   
165   TH1I * h4 = new TH1I("hDigitBBflagsAD","Number of BB flags in AD; # of BB flags; Entries",17,-0.5,16.5);
166   h4->Sumw2();
167   Add2DigitsList(h4, 4, !expert, image) ;
168   
169   TH1I * h5 = new TH1I("hDigitBBflagsADA","Number of BB flags in ADA; # of BB flags; Entries",9,-0.5,8.5);
170   h5->Sumw2();
171   Add2DigitsList(h5, 5, !expert, image) ;
172   
173   TH1I * h6 = new TH1I("hDigitBBflagsADC","Number of BB flags in ADC; # of BB flags; Entries",9,-0.5,8.5);
174   h6->Sumw2();
175   Add2DigitsList(h6, 6, !expert, image) ;
176   
177   TH2D * h7 = new TH2D("hDigitTotalChargePerPM", "Total Charge per PM in AD;PM number; Charge [ADC counts]",16,0,16,10000,0,10000);
178   h7->Sumw2();
179   Add2DigitsList(h7, 7, !expert, image) ;
180   
181   TH2I * h8 = new TH2I("hDigitMaxChargeClockPerPM", "Clock with maximum charge per PM in AD;PM number; Clock ",16,0,16,21, -10.5, 10.5);
182   h8->Sumw2();
183   Add2DigitsList(h8, 8, !expert, image) ;
184    
185   //
186   ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
187 }
188
189
190 //____________________________________________________________________________
191 void AliADQADataMakerSim::MakeHits()
192 {
193         //make QA data from Hits
194
195   Int_t nhits = fHitsArray->GetEntriesFast();
196   FillHitsData(0,nhits) ;    // fills Hit multiplicity
197   for (Int_t ihit=0;ihit<nhits;ihit++) 
198     {
199            AliADhit  * ADHit   = (AliADhit*) fHitsArray->UncheckedAt(ihit);
200            if (!ADHit) {
201               AliError("The unchecked hit doesn't exist");
202               break;
203            }
204            FillHitsData(1,ADHit->GetCell());
205            FillHitsData(2,ADHit->GetNphot());
206            FillHitsData(3,ADHit->GetCell(),ADHit->GetNphot());
207            FillHitsData(4,ADHit->GetCell(),ADHit->GetTof());
208         }
209 }
210
211
212 //____________________________________________________________________________
213
214 void AliADQADataMakerSim::MakeHits(TTree *hitTree)
215 {
216   //fills QA histos for Hits
217  if (fHitsArray)
218    fHitsArray->Clear() ; 
219   else 
220     fHitsArray = new TClonesArray("AliADhit", 1000);
221   
222   TBranch * branch = hitTree->GetBranch("AD") ;
223   if ( ! branch ) {
224     AliWarning("AD branch in Hit Tree not found") ;
225   } else {
226
227    if (branch) {
228       branch->SetAddress(&fHitsArray);
229     }else{
230       AliError("Branch AD hit not found");
231       exit(111);
232     } 
233     // Check id histograms already created for this Event Specie
234     if ( ! GetHitsData(0) )
235       InitHits() ;
236     
237     Int_t ntracks    = (Int_t) hitTree->GetEntries();
238     
239     if (ntracks<=0) return;
240     // Start loop on tracks in the hits containers
241     for (Int_t track=0; track<ntracks;track++) {
242       branch->GetEntry(track);
243       Int_t nhits = fHitsArray->GetEntriesFast();
244       FillHitsData(0,nhits) ;    // fills Hit multiplicity
245       for (Int_t ihit=0;ihit<nhits;ihit++) 
246         {
247           AliADhit  * ADHit   = (AliADhit*) fHitsArray->UncheckedAt(ihit);
248           if (!ADHit) {
249             AliError("The unchecked hit doesn't exist");
250             break;
251           }
252           FillHitsData(1,ADHit->GetCell());
253           FillHitsData(2,ADHit->GetNphot());
254           FillHitsData(3,ADHit->GetCell(),ADHit->GetNphot());
255           FillHitsData(4,ADHit->GetCell(),ADHit->GetTof());      
256         }
257     }
258   }
259   //
260   IncEvCountCycleHits();
261   IncEvCountTotalHits();
262   //
263 }
264
265
266
267 //____________________________________________________________________________
268 void AliADQADataMakerSim::MakeSDigits(TTree *sdigitTree)
269 {
270     // makes data from Digit Tree
271         
272   if (fSDigitsArray)
273     fSDigitsArray->Clear() ; 
274   else 
275     fSDigitsArray = new TClonesArray("AliADSDigit", 1000) ; 
276
277     TBranch * branch = sdigitTree->GetBranch("ADSDigit") ;
278     if ( ! branch ) {
279          AliWarning("AD branch in SDigit Tree not found") ; 
280     } else {
281          branch->SetAddress(&fSDigitsArray) ;
282          branch->GetEntry(0) ; 
283          MakeSDigits() ; 
284     }  
285     //
286     IncEvCountCycleDigits();
287     IncEvCountTotalDigits();
288     //    
289 }
290
291 //____________________________________________________________________________
292 void AliADQADataMakerSim::MakeSDigits()
293 {
294   // makes data from SDigits
295
296   FillSDigitsData(0,fSDigitsArray->GetEntriesFast()) ; 
297   TIter next(fSDigitsArray) ; 
298     AliADSDigit *ADSDigit ; 
299     while ( (ADSDigit = dynamic_cast<AliADSDigit *>(next())) ) {
300          Int_t   PMNumber  = ADSDigit->PMNumber();       
301          FillSDigitsData(PMNumber +1, ADSDigit->GetNBins()) ;
302     }  
303 }
304
305 //____________________________________________________________________________
306 void AliADQADataMakerSim::MakeDigits()
307 {
308   // makes data from Digits
309
310   FillDigitsData(0,fDigitsArray->GetEntriesFast()) ; 
311   TIter next(fDigitsArray) ; 
312     AliADdigit *ADDigit ; 
313     Int_t nBBflagsADA = 0;
314     Int_t nBBflagsADC = 0;
315     
316     while ( (ADDigit = dynamic_cast<AliADdigit *>(next())) ) {
317          Int_t totCharge = 0;
318          Int_t   PMNumber  = ADDigit->PMNumber();
319
320          if(PMNumber<8 && ADDigit->GetBBflag()) nBBflagsADA++;
321          if(PMNumber>7 && ADDigit->GetBBflag()) nBBflagsADC++;
322          
323          Short_t adc[21];
324          for(Int_t iClock=0; iClock<21; iClock++) { 
325          adc[iClock]= ADDigit->ChargeADC(iClock);
326          FillDigitsData(3, PMNumber,(float)iClock-10,(float)adc[iClock]);
327          totCharge += adc[iClock];
328          }
329             
330          FillDigitsData(1,PMNumber,ADDigit->Time()); 
331          FillDigitsData(2,PMNumber,ADDigit->Width());
332          FillDigitsData(7,PMNumber,totCharge);
333          FillDigitsData(8,PMNumber,TMath::LocMax(21,adc)-10); 
334          
335     }
336     FillDigitsData(4,nBBflagsADA+nBBflagsADC);
337     FillDigitsData(5,nBBflagsADA);
338     FillDigitsData(6,nBBflagsADC);  
339 }
340
341 //____________________________________________________________________________
342 void AliADQADataMakerSim::MakeDigits(TTree *digitTree)
343 {
344     // makes data from Digit Tree
345         
346   if (fDigitsArray)
347     fDigitsArray->Clear() ; 
348   else 
349     fDigitsArray = new TClonesArray("AliADdigit", 1000) ; 
350
351     TBranch * branch = digitTree->GetBranch("ADDigit") ;
352     if ( ! branch ) {
353          AliWarning("AD branch in Digit Tree not found") ; 
354     } else {
355          branch->SetAddress(&fDigitsArray) ;
356          branch->GetEntry(0) ; 
357          MakeDigits() ; 
358     }  
359     //
360     IncEvCountCycleDigits();
361     IncEvCountTotalDigits();
362     //    
363 }
364
365
366 //____________________________________________________________________________
367 void AliADQADataMakerSim::StartOfDetectorCycle()
368 {
369   //Detector specific actions at start of cycle
370
371 }