]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0QADataMaker.cxx
minor bugfix in argument scanning
[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   TH1F *    fhHitsTime[24];
145   for (Int_t i=0; i<24; i++)
146     {
147       timename ="hHitTime";
148       timename += i;
149       if(i<12)  fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,2000,3000);
150       else  
151         fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,12000,13000);
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
180   TH1F *fhDigCFD[24]; TH1F * fhDigLEDamp[24]; TH1F *fhDigQTC[24];
181
182   for (Int_t i=0; i<24; i++)
183     {
184       timename ="hDigCFD";
185       ampname = "hDigLED";
186       qtcname = "hDigQTC";
187       timename += i;
188       ampname += i;
189       qtcname += i;
190       fhDigCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,5000);
191       Add2DigitsList( fhDigCFD[i],i);
192       fhDigLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,120000,150000);
193       Add2DigitsList( fhDigLEDamp[i],i+24);
194       fhDigQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,500);
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   TH1F *fhRecCFD[24]; TH1F *fhRecLEDAmp[24];  TH1F * fhRecQTC[24];
223   for (Int_t i=0; i<24; i++)
224     {
225       timename ="hRecCFD";
226       ampname = "hRecLED";
227       qtcname = "hRecQTC";
228       timename += i;
229       ampname += i;
230       qtcname += i;
231       fhRecCFD[i] = new TH1F(timename.Data(), timename.Data(),100,0,1000);
232      Add2RecPointsList ( fhRecCFD[i],i);
233       fhRecLEDAmp[i] = new TH1F(ampname.Data(), ampname.Data(),100,0,200);
234     Add2RecPointsList ( fhRecLEDAmp[i],i+24);
235       fhRecQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,0,200);
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,0,100);
250   Add2ESDsList(fhESDMean, 0) ;
251  TH1F * fhESDVertex = new TH1F("hESDvertex","EAD vertex",100,-50,50);
252   Add2ESDsList(fhESDVertex, 1) ;
253
254
255 }
256 //____________________________________________________________________________
257
258 void AliT0QADataMaker::MakeHits(TTree *hitTree)
259 {
260   //fills QA histos for Hits
261   TClonesArray * hits = new TClonesArray("AliT0hit", 1000);
262   
263   TBranch * branch = hitTree->GetBranch("T0") ;
264   if ( ! branch ) {
265     AliWarning("T0 branch in Hit Tree not found") ;
266   } else {
267
268    if (branch) {
269       branch->SetAddress(&hits);
270     }else{
271       AliError("Branch T0 hit not found");
272       exit(111);
273     } 
274     Int_t ntracks    = (Int_t) hitTree->GetEntries();
275     
276     if (ntracks<=0) return;
277     // Start loop on tracks in the hits containers
278     for (Int_t track=0; track<ntracks;track++) {
279       branch->GetEntry(track);
280       Int_t nhits = hits->GetEntriesFast();
281       for (Int_t ihit=0;ihit<nhits;ihit++) 
282         {
283           AliT0hit  * startHit   = (AliT0hit*) hits->UncheckedAt(ihit);
284           if (!startHit) {
285             AliError("The unchecked hit doesn't exist");
286             break;
287           }
288           Int_t pmt=startHit->Pmt();
289           GetHitsData(pmt)->Fill(startHit->Time()) ;
290         }
291     }
292   }
293 }
294
295 //____________________________________________________________________________
296 void AliT0QADataMaker::MakeDigits( TTree *digitsTree)
297 {
298   //fills QA histos for Digits
299  
300   TArrayI *digCFD = new TArrayI(24);
301   TArrayI *digLED = new TArrayI(24);
302   TArrayI *digQT0 = new TArrayI(24);
303   TArrayI *digQT1 = new TArrayI(24);
304   Int_t refpoint=0;
305
306    TBranch *brDigits=digitsTree->GetBranch("T0");
307   AliT0digit *fDigits = new AliT0digit() ;
308   if (brDigits) {
309     brDigits->SetAddress(&fDigits);
310   }else{
311     AliError(Form("EXEC Branch T0 digits not found"));
312      return;
313   }
314   
315   digitsTree->GetEvent(0);
316   digitsTree->GetEntry(0);
317   brDigits->GetEntry(0);
318   fDigits->GetTimeCFD(*digCFD);
319   fDigits->GetTimeLED(*digLED);
320   fDigits->GetQT0(*digQT0);
321   fDigits->GetQT1(*digQT1);
322   refpoint = fDigits->RefPoint();
323    for (Int_t i=0; i<24; i++)
324     {
325       if (digCFD->At(i)>0) {
326         Int_t cfd=digCFD->At(i)- refpoint;
327         GetDigitsData(i) ->Fill(cfd);
328         GetDigitsData(i+24) -> Fill(digLED->At(i) - digCFD->At(i));
329         GetDigitsData(i+48) -> Fill(digQT1->At(i) - digQT0->At(i));
330       }
331     }  
332       
333   delete digCFD;
334   delete digLED;
335   delete digQT0;
336   delete digQT1;
337
338 }
339
340
341 //____________________________________________________________________________
342 void AliT0QADataMaker::MakeRecPoints(TTree * clustersTree)
343 {
344   //fills QA histos for clusters
345
346    AliT0RecPoint* frecpoints= new AliT0RecPoint ();
347     if (!frecpoints) {
348     AliError("Reconstruct Fill ESD >> no recpoints found");
349     return;
350   }
351   TBranch *brRec =clustersTree ->GetBranch("T0");
352   if (brRec) {
353     brRec->SetAddress(&frecpoints);
354   }else{
355     cerr<<"EXEC Branch T0 rec not found"<<endl;
356     // exit(111);
357     return;
358   } 
359     
360   brRec->GetEntry(0);
361   
362   for ( Int_t i=0; i<24; i++) {
363     GetRecPointsData(i) -> Fill(frecpoints -> GetTime(i)); 
364     GetRecPointsData(i+24) -> Fill(frecpoints -> GetAmp(i));
365     GetRecPointsData(i+48) -> Fill(frecpoints->AmpLED(i));
366     //  if(frecpoints -> GetTime(i) > 0) fhRecEff->Fill(i);
367   }
368      GetRecPointsData(72) ->Fill(frecpoints->GetMeanTime());
369   
370 }
371
372 //____________________________________________________________________________
373 void AliT0QADataMaker::MakeESDs(AliESDEvent * esd)
374 {
375   //fills QA histos for ESD
376
377   GetESDsData(0) -> Fill(esd->GetT0());
378   GetESDsData(1)-> Fill(esd->GetT0zVertex());
379
380 }
381