]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0QADataMaker.cxx
coding conventions
[u/mrichter/AliRoot.git] / T0 / AliT0QADataMaker.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$ */
18
19 //---
20 //  Produces the data needed to calculate the quality assurance. 
21 //  All data must be mergeable objects.
22 //  A. Mastroserio
23 //---
24
25 // --- ROOT system ---
26 #include <TClonesArray.h>
27 #include <TFile.h> 
28 #include <TH1F.h> 
29 #include <TH2F.h>
30 #include <TH1I.h> 
31 #include <TDirectory.h>
32 #include <Riostream.h>
33 // --- Standard library ---
34
35 // --- AliRoot header files ---
36 #include "AliESDCaloCluster.h"
37 #include "AliESDEvent.h"
38 #include "AliLog.h"
39 #include "AliT0digit.h"
40 #include "AliT0hit.h"
41 #include "AliT0RecPoint.h"
42 #include "AliT0QADataMaker.h"
43 #include "AliQAChecker.h"
44
45 ClassImp(AliT0QADataMaker)
46            
47 //____________________________________________________________________________ 
48   AliT0QADataMaker::AliT0QADataMaker() : 
49   AliQADataMaker(AliQA::GetDetName(AliQA::kT0), "T0 Quality Assurance Data Maker")
50   //  fhHitsTime(0x0),
51   // fhHitsAmp(0x0),
52   // fhHitsEff(0x0),
53   //  fhDigCFD(0x0),
54   //  fhDigLEDamp(0x0),
55   //  fhDigQTC(0x0),
56   // fhDigMean(0x0),
57   //  fhDigEff(0x0),
58   //  fhRecCFD(0x0),
59   //  fhRecLEDamp(0x0),
60   //  fhRecQTC(0x0),
61   //  fhRecMean(0x0),
62   //  fhRecEff(0x0),
63   //  fhESDMean(0x0),
64   //  fhESDVertex(0x0)
65
66 {
67   // ctor
68   /*
69   for(Int_t i=0; i<24; i++) {
70     fhHitsTime[i]=0x0;
71    fhDigCFD[i]=0x0;
72     fhDigLEDamp[i]=0x0;
73     fhRecCFD[i]=0x0;
74     fhRecLEDamp[i]=0x0;
75     fhRecQTC[i]=0x0;
76   }
77   */
78  //   fDetectorDir = fOutput->GetDirectory(GetName()) ;  
79 //   if (!fDetectorDir) 
80 //     fDetectorDir = fOutput->mkdir(GetName()) ;  
81 }
82
83 //____________________________________________________________________________ 
84 AliT0QADataMaker::AliT0QADataMaker(const AliT0QADataMaker& qadm) :
85   AliQADataMaker() 
86  //  fhHitsTime(0x0),
87  // fhHitsEff(0x0),
88   //  fhDigCFD(0x0),
89   //  fhDigLEDamp(0x0),
90   //  fhDigQTC(0x0),
91   // fhDigMean(0x0),
92   // fhDigEff(0x0),
93   //  fhRecCFD(0x0),
94   //  fhRecLEDamp(0x0),
95   //  fhRecQTC(0x0),
96   // fhRecMean(0x0),
97   // fhRecEff(0x0),
98   // //  fhESDMean(0x0),
99   // fhESDVertex(0x0)
100 {
101   //copy ctor 
102   /*
103   for(Int_t i=0; i<24; i++) {
104     fhHitsTime[i]=0x0;
105     fhDigCFD[i]=0x0;
106     fhDigLEDamp[i]=0x0;
107     fhRecCFD[i]=0x0;
108     fhRecLEDamp[i]=0x0;
109     fhRecQTC[i]=0x0;
110   }
111   */
112   SetName((const char*)qadm.GetName()) ; 
113   SetTitle((const char*)qadm.GetTitle()); 
114 }
115
116 //__________________________________________________________________
117 AliT0QADataMaker& AliT0QADataMaker::operator = (const AliT0QADataMaker& qadm )
118 {
119   // Equal operator.
120   this->~AliT0QADataMaker();
121   new(this) AliT0QADataMaker(qadm);
122   return *this;
123 }
124 //____________________________________________________________________________
125 void AliT0QADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TList * list)
126 {
127   //Detector specific actions at end of cycle
128   // do the QA checking
129   AliQAChecker::Instance()->Run(AliQA::kT0, task, list) ;
130 }
131
132 //____________________________________________________________________________
133 void AliT0QADataMaker::StartOfDetectorCycle()
134 {
135   //Detector specific actions at start of cycle
136
137 }
138  
139 //____________________________________________________________________________ 
140 void AliT0QADataMaker::InitHits()
141 {
142   // create Hits histograms in Hits subdir
143   TString timename;
144   timename ="hHitTime";
145   TH1F *    fhHitsTime[24];
146   for (Int_t i=0; i<24; i++)
147     {
148       timename += i;
149       if(i<12)  fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,2,3);
150       else  
151         fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,12,13);
152       Add2HitsList( fhHitsTime[i],i);
153     }
154   /*
155   TH2F *fhHitsEffA = new TH2F("hHitsEffA", "Hits Efficiency A side", 25,-0.5,24.5, 100,12,13 );
156   Add2HitsList(fhHitsEffA,0);
157   TH2F *fhHitsEffC = new TH2F("hHitsEffC", "Hits Efficiency C side", 25,-0.5,24.5, 100,2,3 );
158   Add2HitsList(fhHitsEffC,1);
159   */
160 }
161
162 //____________________________________________________________________________ 
163 void AliT0QADataMaker::InitDigits()
164 {
165   // create Digits histograms in Digits subdir
166
167   /*
168   TH2F * fhDigCFD = new TH2F("fhDigCFD", " CFD digits",25,-0.5,24.5,100,100,1000);
169   Add2DigitsList( fhDigCFD,0);
170   TH2F *fhDigLEDamp = new TH2F("fhDigLEDamp", " LED-CFD digits",25,-0.5,24.5,100,100,1000);
171   Add2DigitsList( fhDigLEDamp,1);
172   TH2F * fhDigQTC = new TH2F("fhDigQTC", " QTC digits",25,-0.5,24.5,100,100,1000);
173   Add2DigitsList( fhDigQTC,2);
174   TH1F * fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
175   Add2DigitsList( fhDigMean,23);
176   */
177   
178   TString timename, ampname, qtcname;
179   timename ="hDigCFD";
180   ampname = "hDigLED";
181   qtcname = "hDigQTC";
182
183   TH1F *fhDigCFD[24]; TH1F * fhDigLEDamp[24]; TH1F *fhDigQTC[24];
184
185   for (Int_t i=0; i<24; i++)
186     {
187       timename += i;
188       ampname += i;
189       qtcname += i;
190       fhDigCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,1000);
191       Add2DigitsList( fhDigCFD[i],i);
192       fhDigLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,100,1000);
193       Add2DigitsList( fhDigLEDamp[i],i+24);
194       fhDigQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,1000);
195       Add2DigitsList( fhDigQTC[i],i+48);
196      }
197   
198   TH1F* fhDigEff = new TH1F("hDigEff","digits efficiency", 25,-0.5,24.5);
199   Add2DigitsList( fhDigEff,72);
200   TH1F* fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
201   Add2DigitsList( fhDigMean,73);
202   
203 }
204
205 //____________________________________________________________________________ 
206
207 void AliT0QADataMaker::InitRecPoints()
208 {
209   // create cluster histograms in RecPoint subdir
210   /* 
211  TH2F * fhRecCFD = new TH2F("fhRecCFD", " CFD reconstructed",25,-0.5,24.5,100,12,13);
212   Add2DigitsList( fhRecCFD,0);
213   TH2F *fhRecLEDamp = new TH2F("fhRecLEDamp", " amplitude LED reconstructed",25,-0.5,24.5,100,1000,1000);
214   Add2DigitsList( fhRecLEDamp,1);
215  TH2F * fhRecQTC = new TH2F("fhRecQTC", " amplitude QTC reconstructed",25,-0.5,24.5,100,1000,1000);
216   Add2DigitsList( fhRecQTC,2);
217  TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
218   Add2DigitsList( fhRecMean,3);
219   */ 
220   
221   TString timename,ampname, qtcname;
222   timename ="hRecCFD";
223   ampname = "hRecLED";
224   qtcname = "hRecQTC";
225   TH1F *fhRecCFD[24]; TH1F *fhRecLEDAmp[24];  TH1F * fhRecQTC[24];
226   for (Int_t i=0; i<24; i++)
227     {
228       timename += i;
229       ampname += i;
230       qtcname += i;
231       fhRecCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,1000);
232      Add2RecPointsList ( fhRecCFD[i],i);
233       fhRecLEDAmp[i] = new TH1F(ampname.Data(), ampname.Data(),100,100,1000);
234     Add2RecPointsList ( fhRecLEDAmp[i],i+24);
235       fhRecQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,1000);
236     Add2RecPointsList ( fhRecQTC[i],i+48);
237      }
238    
239   TH1F *fhRecEff = new TH1F("hRecEff","Efficiency rec.points",25,-0.5,24.5);
240  Add2RecPointsList ( fhRecEff,72);
241   TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
242  Add2RecPointsList( fhRecMean,73);
243   
244 }
245 //____________________________________________________________________________
246 void AliT0QADataMaker::InitESDs()
247 {
248   //create ESDs histograms in ESDs subdir
249   TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean",100,500,600);
250   Add2ESDsList(fhESDMean, 0) ;
251  TH1F * fhESDVertex = new TH1F("hESDvertex","EAD vertex",100,-50,50);
252   Add2ESDsList(fhESDVertex, 1) ;
253
254
255 }
256 //____________________________________________________________________________
257 void AliT0QADataMaker::MakeHits(TObject * data)
258 {
259   //fills QA histos for Hits
260   TClonesArray * hits = dynamic_cast<TClonesArray *>(data) ; 
261   if (!hits){
262     AliError("Wrong type of hits container") ; 
263   } else {
264     TIter next(hits); 
265     AliT0hit * hit ; 
266     while ( (hit = dynamic_cast<AliT0hit *>(next())) ) {
267       Int_t pmt=hit->Pmt();
268       GetHitsData(pmt)->Fill(pmt,hit->Time()) ;
269     }
270   } 
271 }
272
273 //____________________________________________________________________________
274 void AliT0QADataMaker::MakeDigits( TObject * data)
275 {
276   //fills QA histos for Digits
277  
278   TArrayI *digCFD = new TArrayI(24);
279   TArrayI *digLED = new TArrayI(24);
280   TArrayI *digQT0 = new TArrayI(24);
281   TArrayI *digQT1 = new TArrayI(24);
282   Int_t refpoint=0;
283
284   TClonesArray * digits = dynamic_cast<TClonesArray *>(data) ; 
285   
286   if ( !digits) {
287     AliError("Wrong type of digits container") ; 
288   } else {
289     TIter next(digits) ; 
290     AliT0digit * digit ; 
291     while ( (digit = dynamic_cast<AliT0digit *>(next())) ) {
292       digit->GetTimeCFD(*digCFD);
293       digit->GetTimeLED(*digLED);
294       digit->GetQT0(*digQT0);
295       digit->GetQT1(*digQT1);
296       refpoint =  digit->RefPoint();
297       for (Int_t i=0; i<24; i++)
298         {
299           if (digCFD->At(i)>0) {
300             Int_t cfd=digCFD->At(i)- refpoint;
301             GetDigitsData(i) ->Fill(i,cfd);
302             GetDigitsData(i+24) -> Fill(i, digLED->At(i) - digCFD->At(i));
303             GetDigitsData(i+48) -> Fill(i, digQT1->At(i) - digQT0->At(i));
304             //      fhDigEff->Fill(i);
305           }
306         }  
307     }
308   }
309   delete digCFD;
310   delete digLED;
311   delete digQT0;
312   delete digQT1;
313
314 }
315
316
317 //____________________________________________________________________________
318 void AliT0QADataMaker::MakeRecPoints(TTree * clustersTree)
319 {
320   //fills QA histos for clusters
321
322    AliT0RecPoint* frecpoints= new AliT0RecPoint ();
323     if (!frecpoints) {
324     AliError("Reconstruct Fill ESD >> no recpoints found");
325     return;
326   }
327   TBranch *brRec =clustersTree ->GetBranch("T0");
328   if (brRec) {
329     brRec->SetAddress(&frecpoints);
330   }else{
331     cerr<<"EXEC Branch T0 rec not found"<<endl;
332     // exit(111);
333     return;
334   } 
335     
336   brRec->GetEntry(0);
337   
338   for ( Int_t i=0; i<24; i++) {
339     GetRecPointsData(i) -> Fill(frecpoints -> GetTime(i)); 
340     GetRecPointsData(i+24) -> Fill(frecpoints -> GetAmp(i));
341     GetRecPointsData(i+48) -> Fill(frecpoints->AmpLED(i));
342     //  if(frecpoints -> GetTime(i) > 0) fhRecEff->Fill(i);
343   }
344      GetRecPointsData(72) ->Fill(frecpoints->GetMeanTime());
345   
346 }
347
348 //____________________________________________________________________________
349 void AliT0QADataMaker::MakeESDs(AliESDEvent * esd)
350 {
351   //fills QA histos for ESD
352
353   GetESDsData(0) -> Fill(esd->GetT0());
354   GetESDsData(1)-> Fill(esd->GetT0zVertex());
355
356 }
357