]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0QAChecker.cxx
material cherenkov properties adopted to TGeo according Savannah bug #67031, done...
[u/mrichter/AliRoot.git] / T0 / AliT0QAChecker.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 //  Checks the quality assurance. 
17 //  By comparing with reference data
18 //  Skeleton for T0
19 //---------------------------------------------
20 //checkig without reference data:
21 //for RAW QA all histograms should have approximatly the same 
22 //number of entries as RefPoint
23 //for Rec Points checks 
24 //  - amplitude measured by 2 methos
25 //  - online and offline T0 measurements
26 // for ESD quality of reconstruction ( and measurements):
27 // RMS of vertex and T0 less than 75ps
28 //
29 // Alla.Maevskaya@cern.ch   
30 //...
31
32 // --- ROOT system ---
33 #include <Riostream.h>
34 #include <TClass.h>
35 #include <TH1F.h> 
36 #include <TH2.h> 
37 #include <TIterator.h> 
38 #include <TKey.h> 
39 #include <TFile.h> 
40 #include <TMath.h>
41 #include <TString.h>
42
43 // --- Standard library ---
44
45 // --- AliRoot header files ---
46 #include "AliLog.h"
47 #include "AliQAv1.h"
48 #include "AliQAChecker.h"
49 #include "AliCDBEntry.h"
50 #include "AliQAManager.h"
51 #include "AliT0QAChecker.h"
52
53 ClassImp(AliT0QAChecker)
54
55 //__________________________________________________________________
56 void AliT0QAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
57 {
58
59   // Super-basic check on the QA histograms on the input list:
60   // look whether they are empty!
61     
62   char * detOCDBDir = Form("T0/%s/%s", AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ; 
63
64   AliCDBEntry *QARefRec = AliQAManager::QAManager()->Get(detOCDBDir);
65   //  QARefRec->Dump();
66   if( !QARefRec){
67     AliInfo("QA reference data NOT retrieved for Reconstruction check. No T0 reference distribution");
68   }
69   
70    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
71     test[specie]    = 10.0 ; 
72
73   Double_t nent[500];
74   TString hname[500];
75   const char *cname;
76   memset(nent,0,500*sizeof(Double_t));
77   Double_t w[500];
78   memset(w,1,500*sizeof(Double_t));
79   TH2 *fhRecDiff[3];  
80   TH1 *fhRawEff[500];
81   TH2 *fhRawTime[500];
82   TH1 *fhESD[2];
83   TH2 *fhHits[10];
84   
85   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
86     //  TString dataType = AliQAv1::GetAliTaskName(index);
87     if (list[specie]->GetEntries() == 0){
88       test[specie] = 1. ; // nothing to check
89     }
90     else {
91       TH1 * hdata ;
92       TH2 * h ;
93       for (Int_t ir=0; ir<list[specie]->GetEntries(); ir++) {
94       
95         //hits
96
97         if(index == AliQAv1::kSIM && AliQAv1::GetTaskName(AliQAv1::kHITS)){
98           h =  (TH2*) list[specie]->UncheckedAt(ir);
99           cname = h->GetName();
100           hname[ir] = cname;
101           fhHits[ir] = h;
102         }
103
104         //raw
105       if(index == AliQAv1::kRAW ){
106         if(ir > 204 && ir<208 ) {
107           hdata = (TH1*) list[specie]->UncheckedAt(ir);
108           if(hdata) {
109             cname = hdata->GetName();
110             hname[ir] = cname;
111             fhRawEff[ir] = hdata;
112           }
113         }
114         if((ir>207 && ir<210)  && specie == AliRecoParam::kCalib) {
115           h =  (TH2*) list[specie]->UncheckedAt(ir);
116           if(h) {
117             cname = h->GetName();
118             hname[ir] = cname;
119             fhRawTime[ir] = h;
120           AliDebug(AliQAv1::GetQADebugLevel(), Form("count %i %s ",ir, hname[ir].Data()) );
121           }
122         }
123       }
124       //rec
125       if(index == AliQAv1::kREC){
126         h = (TH2*) list[specie]->UncheckedAt(ir);
127         if(h) {
128           cname = h->GetName();
129           hname[ir] = cname;
130            fhRecDiff[ir] = h;
131         }
132       }
133       //esd
134       if(index ==  AliQAv1::kESD){
135         hdata = (TH1*) list[specie]->UncheckedAt(ir);
136         if(hdata){
137           fhESD[ir] = hdata;
138           AliDebug(AliQAv1::GetQADebugLevel(), Form("count %i %s ",ir, hname[ir].Data()) );
139         }
140       }
141     }
142
143
144
145     //raw data
146
147       if (index == AliQAv1::kRAW && specie == AliRecoParam::kCalib){
148         test[specie] = CheckRaw(list[specie],dynamic_cast<TObjArray*>(dynamic_cast<TList *>(QARefRec->GetObject())->First()));
149       }
150       
151       if(index == AliQAv1::kREC){
152         //rec points
153         for (Int_t icase=0; icase<2; icase++) {
154           for (Int_t idet=0; idet<24; idet++) {
155             Double_t mean = fhRecDiff[icase]->
156             ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
157                         idet,idet+1)->GetMean();
158             Double_t rms= fhRecDiff[icase]->
159             ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
160                         idet,idet+1)->GetRMS();
161             AliDebug(AliQAv1::GetQADebugLevel(), Form("name %s icase %i idet %i mean %f, rms %f\n",
162                          fhRecDiff[icase]->GetName(), icase, idet, mean,rms)); 
163                   
164             if(TMath::Abs(mean) >1.5 || rms >1){
165               AliDebug(AliQAv1::GetQADebugLevel(), Form(" calibration is nor perfect; test=%f", test)) ;
166               test[specie]=0.25;
167             }
168             if(mean>3 || rms >5) {
169               test[specie] = 0.1;
170               AliDebug(AliQAv1::GetQADebugLevel(), Form(" wrong calibration test=%f", test[specie])) ;
171             } 
172           }
173         }        
174       }
175       if (index == AliQAv1::kESD) {
176         //ESD
177         for (Int_t icase=0; icase<2; icase++) {
178           Double_t rmsVertex = fhESD[icase]->GetRMS();
179           Double_t meanVertex = fhESD[icase]->GetMean();
180           test[specie]=1;
181           AliDebug(AliQAv1::GetQADebugLevel(), Form("numentries %d meanVertex %f rmsVertex %f", fhESD[icase]->GetEntries(), meanVertex, rmsVertex));
182           if (TMath::Abs(rmsVertex)>3) {
183             test[specie]=0.25;
184             AliDebug(AliQAv1::GetQADebugLevel(), Form("Vertex position resolution not good  , rms= %f test=%f",
185                             rmsVertex, test[specie])) ; 
186           }
187           if (TMath::Abs(meanVertex)>3) {
188             test[specie]=0.25;
189             AliDebug(AliQAv1::GetQADebugLevel(), Form("Vertex position bad calibrated  , Mean= %f test=%f",
190                             meanVertex, test[specie])) ; 
191           }
192         }
193       }
194     } //  if (list->GetEntries() != 0
195     AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test[specie])) ;
196   } 
197 }
198
199 //--------------------------------------------------------------------------
200 Double_t AliT0QAChecker::CheckRaw(TObjArray *listrec , TObjArray *listref) const
201 {
202   
203     //TH1 *fhRawEff;
204     //TH1 *fhRawRef;
205   TH2 *fhRawRec2d;
206   TH2 *fhTime;
207
208   TIter next(listref) ;
209     //Int_t counter=0;
210   Float_t refmean[50][25]; 
211   Float_t refrms[50][25]; 
212   Float_t checkr = 0;
213   
214     //Int_t nref = listref->GetEntries(); 
215     //Int_t nrec = listrec->GetEntries(); 
216   
217   for (Int_t iii=4; iii<6; iii++){
218     fhRawRec2d =(TH2*) listref->At(iii); 
219     for (Int_t idet=1; idet<25; idet++) {
220       
221       refmean[iii-4][idet] = fhRawRec2d->       
222         ProjectionY(Form("%s_py_%i_%i",                                                              fhRawRec2d ->GetName(), idet,iii-4),
223                     idet,idet+1)->GetMean();
224       
225       refrms[iii-4][idet] = fhRawRec2d->
226         ProjectionY(Form("%s_py%i_%i", 
227                          fhRawRec2d ->GetName(), idet,iii-4),
228                     idet,idet+1)->GetRMS();
229       
230       }
231   }
232
233   
234   TString nameDev[2] = {"CDF", "LED"};
235   for (Int_t icase=208; icase<210; icase++) {
236     fhTime = (TH2*) listrec->At(icase);
237     for (Int_t idet=1; idet<25; idet++) {
238       Double_t binmean = fhTime->
239       ProjectionY(Form("%s_py_%i_%i",                                                              fhTime ->GetName(), idet,icase),
240                     idet,idet+1)->GetMean();
241 //        Double_t rms= fhTime ->ProjectionY(Form("%s_py%i_%i", 
242 //                                              fhTime ->GetName(), idet,icase),
243 //                                         idet,idet+1)->GetRMS();
244       Double_t diffmean = binmean-refmean[icase-208][idet];
245       
246       if (TMath::Abs(diffmean) < 2 ) {
247         checkr = 1;
248         //      printf(" Laser calibration signal sits on its place %f for PMT %s %i : check = %f\n",  diffmean, nameDev[icase-208].Data() ,idet, checkr);
249         AliDebug(AliQAv1::GetQADebugLevel(),
250                  Form(" Laser calibration signal sits on its place %f for PMT %s %i : check = %f\n",  diffmean, nameDev[icase-208].Data(),idet, checkr)) ; 
251      }
252      if (TMath::Abs(diffmean) <= 5 && TMath::Abs(diffmean) >= 2 ){
253        checkr = 0.5;
254        // printf(" Laser calibration signal shifted by  %f ps for PMT %s %i : check = %f\n",  diffmean*24.4, nameDev[icase-208].Data(),idet, checkr);
255        AliDebug(AliQAv1::GetQADebugLevel(),
256                 Form(" Laser calibration signal shifted by  %f ps (%f channels) for PMT %s %i : check = %f\n",  diffmean*24.4 ,diffmean , nameDev[icase-208].Data(),idet, checkr)) ; 
257       }
258      if (TMath::Abs(diffmean) > 5) { 
259        checkr = 0.25;
260        //   printf(" Big problems :laser calibration signal shifted by  %f ps (%f channels) for PMT %s %i : check = %f\n",  diffmean*24.4, diffmean, nameDev[icase-208].Data(),idet, checkr);
261        AliDebug(AliQAv1::GetQADebugLevel(),
262                 Form(" Big problems :laser calibration signal shifted by  %f ps (%f channels) for PMT %s %i : check = %i\n",  diffmean*24.4, diffmean, nameDev[icase-208].Data(),idet, checkr)) ; 
263        
264      }
265      
266    }
267  }
268
269   return checkr;
270 }
271