]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0QADataMaker.cxx
T0 QA classes
[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
44 ClassImp(AliT0QADataMaker)
45            
46 //____________________________________________________________________________ 
47   AliT0QADataMaker::AliT0QADataMaker() : 
48   AliQADataMaker(AliQA::GetDetName(AliQA::kT0), "T0 Quality Assurance Data Maker"),
49   //  fhHitsTime(0x0),
50   // fhHitsAmp(0x0),
51   fhHitsEff(0x0),
52   //  fhDigCFD(0x0),
53   //  fhDigLEDamp(0x0),
54   //  fhDigQTC(0x0),
55   fhDigMean(0x0),
56   fhDigEff(0x0),
57   //  fhRecCFD(0x0),
58   //  fhRecLEDamp(0x0),
59   //  fhRecQTC(0x0),
60   fhRecMean(0x0),
61   fhRecEff(0x0),
62   fhESDMean(0x0),
63   fhESDVertex(0x0)
64
65 {
66   // ctor
67   for(Int_t i=0; i<24; i++) {
68     fhHitsTime[i]=0x0;
69    fhDigCFD[i]=0x0;
70     fhDigLEDamp[i]=0x0;
71     fhRecCFD[i]=0x0;
72     fhRecLEDamp[i]=0x0;
73     fhRecQTC[i]=0x0;
74   }
75  //   fDetectorDir = fOutput->GetDirectory(GetName()) ;  
76 //   if (!fDetectorDir) 
77 //     fDetectorDir = fOutput->mkdir(GetName()) ;  
78 }
79
80 //____________________________________________________________________________ 
81 AliT0QADataMaker::AliT0QADataMaker(const AliT0QADataMaker& qadm) :
82   AliQADataMaker(), 
83  //  fhHitsTime(0x0),
84   fhHitsEff(0x0),
85   //  fhDigCFD(0x0),
86   //  fhDigLEDamp(0x0),
87   //  fhDigQTC(0x0),
88   fhDigMean(0x0),
89   fhDigEff(0x0),
90   //  fhRecCFD(0x0),
91   //  fhRecLEDamp(0x0),
92   //  fhRecQTC(0x0),
93   fhRecMean(0x0),
94   fhRecEff(0x0),
95   fhESDMean(0x0),
96   fhESDVertex(0x0)
97 {
98   //copy ctor 
99   for(Int_t i=0; i<24; i++) {
100     fhHitsTime[i]=0x0;
101     fhDigCFD[i]=0x0;
102     fhDigLEDamp[i]=0x0;
103     fhRecCFD[i]=0x0;
104     fhRecLEDamp[i]=0x0;
105     fhRecQTC[i]=0x0;
106   }
107
108   SetName((const char*)qadm.GetName()) ; 
109   SetTitle((const char*)qadm.GetTitle()); 
110 }
111
112 //__________________________________________________________________
113 AliT0QADataMaker& AliT0QADataMaker::operator = (const AliT0QADataMaker& qadm )
114 {
115   // Equal operator.
116   this->~AliT0QADataMaker();
117   new(this) AliT0QADataMaker(qadm);
118   return *this;
119 }
120  
121 //____________________________________________________________________________ 
122 void AliT0QADataMaker::InitHits()
123 {
124   // create Hits histograms in Hits subdir
125   TString timename;
126   timename ="hHitTime";
127   for (Int_t i=0; i<24; i++)
128     {
129       timename += i;
130        if(i<12)  fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,2,3);
131      else  
132        fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,12,13);
133     }
134   fhHitsEff = new TH1F("hHitsEff", "Hits Efficiency", 25,-0.5,24.5);
135 }
136
137 //____________________________________________________________________________ 
138 void AliT0QADataMaker::InitDigits()
139 {
140   // create Digits histograms in Digits subdir
141   TString timename, ampname, qtcname;
142   timename ="hDigCFD";
143   ampname = "hDigLED";
144   qtcname = "hDigQTC";
145   for (Int_t i=0; i<24; i++)
146     {
147       timename += i;
148       ampname += i;
149       qtcname += i;
150       fhDigCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,1000);
151       fhDigLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,100,1000);
152       fhDigQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,1000);
153     }
154   fhDigEff = new TH1F("hDigEff","digits efficiency", 25,-0.5,24.5);
155   fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
156
157 }
158
159 //____________________________________________________________________________ 
160
161 void AliT0QADataMaker::InitRecPoints()
162 {
163   // create cluster histograms in RecPoint subdir
164  
165   // create Digits histograms in Digits subdir
166   TString timename,ampname, qtcname;
167   timename ="hRecCFD";
168   ampname = "hRecLED";
169   qtcname = "hRecQTC";
170   for (Int_t i=0; i<24; i++)
171     {
172       timename += i;
173       ampname += i;
174       qtcname += i;
175       fhRecCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,1000);
176       fhRecLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,100,1000);
177       fhRecQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,1000);
178     }
179   fhRecEff = new TH1F("hRecEff","Efficiency rec.points",25,-0.5,24.5);
180   fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
181
182 }
183 //____________________________________________________________________________
184 void AliT0QADataMaker::InitESDs()
185 {
186   //create ESDs histograms in ESDs subdir
187   fhESDMean = new TH1F("hESDmean"," ESD mean",100,500,600);
188   fhESDVertex = new TH1F("hESDvertex","EAD vertex",100,-50,50);
189
190
191 }
192 //____________________________________________________________________________
193 void AliT0QADataMaker::MakeHits(TObject * data)
194 {
195   //fills QA histos for Hits
196   TClonesArray * hits = dynamic_cast<TClonesArray *>(data) ; 
197   if (!hits){
198     AliError("Wrong type of hits container") ; 
199   } else {
200     TIter next(hits); 
201     AliT0hit * hit ; 
202     while ( (hit = dynamic_cast<AliT0hit *>(next())) ) {
203       Int_t pmt=hit->Pmt();
204       fhHitsTime[pmt]->Fill(hit->Time()) ;
205        fhHitsEff->Fill(pmt);
206    }
207   } 
208 }
209
210 //____________________________________________________________________________
211 void AliT0QADataMaker::MakeDigits( TObject * data)
212 {
213   //fills QA histos for Digits
214   TArrayI *digCFD = new TArrayI(24);
215   TArrayI *digLED = new TArrayI(24);
216   TArrayI *digQT0 = new TArrayI(24);
217   TArrayI *digQT1 = new TArrayI(24);
218   Int_t refpoint=0;
219
220   TClonesArray * digits = dynamic_cast<TClonesArray *>(data) ; 
221   
222   if ( !digits) {
223     AliError("Wrong type of digits container") ; 
224   } else {
225     TIter next(digits) ; 
226     AliT0digit * digit ; 
227     while ( (digit = dynamic_cast<AliT0digit *>(next())) ) {
228       digit->GetTimeCFD(*digCFD);
229       digit->GetTimeLED(*digLED);
230       digit->GetQT0(*digQT0);
231       digit->GetQT1(*digQT1);
232       refpoint =  digit->RefPoint();
233       for (Int_t i=0; i<24; i++)
234         {
235           if (digCFD->At(i)>0) {
236             Int_t cfd=digCFD->At(i)- refpoint;
237             fhDigCFD[i] -> Fill(cfd);
238             fhDigLEDamp[i] -> Fill(digLED->At(i) - digCFD->At(i));
239             fhDigQTC [i]-> Fill(digQT1->At(i) - digQT0->At(i));
240             fhDigEff->Fill(i);
241           }
242         }  
243     }
244   }
245   delete digCFD;
246   delete digLED;
247   delete digQT0;
248   delete digQT1;
249
250 }
251
252
253 //____________________________________________________________________________
254 void AliT0QADataMaker::MakeRecPoints(TTree * clustersTree)
255 {
256   //fills QA histos for clusters
257
258    AliT0RecPoint* frecpoints= new AliT0RecPoint ();
259     if (!frecpoints) {
260     AliError("Reconstruct Fill ESD >> no recpoints found");
261     return;
262   }
263   TBranch *brRec =clustersTree ->GetBranch("T0");
264   if (brRec) {
265     brRec->SetAddress(&frecpoints);
266   }else{
267     cerr<<"EXEC Branch T0 rec not found"<<endl;
268     // exit(111);
269     return;
270   } 
271     
272   brRec->GetEntry(0);
273   
274   for ( Int_t i=0; i<24; i++) {
275     fhRecCFD[i] -> Fill(frecpoints -> GetTime(i)); 
276     fhRecQTC[i] -> Fill(frecpoints -> GetAmp(i));
277     fhRecLEDamp[i] -> Fill( frecpoints->AmpLED(i));
278     if(frecpoints -> GetTime(i) > 0) fhRecEff->Fill(i);
279   }
280   fhRecMean->Fill(frecpoints->GetMeanTime());
281   
282 }
283
284 //____________________________________________________________________________
285 void AliT0QADataMaker::MakeESDs(AliESDEvent * esd)
286 {
287   //fills QA histos for ESD
288
289   fhESDMean -> Fill(esd->GetT0());
290   fhESDVertex -> Fill(esd->GetT0zVertex());
291
292 }
293