temporary fix of bug from Savannah report 54512
[u/mrichter/AliRoot.git] / T0 / AliT0QAChecker.cxx
CommitLineData
c03351ac 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 **************************************************************************/
c03351ac 15//...
16// Checks the quality assurance.
17// By comparing with reference data
18// Skeleton for T0
f6c2d5e2 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
c03351ac 30//...
31
32// --- ROOT system ---
b09247a2 33#include <Riostream.h>
c03351ac 34#include <TClass.h>
35#include <TH1F.h>
0d849919 36#include <TH2.h>
c03351ac 37#include <TIterator.h>
38#include <TKey.h>
39#include <TFile.h>
446d6ec4 40#include <TMath.h>
0d849919 41#include <TString.h>
c03351ac 42
43// --- Standard library ---
44
45// --- AliRoot header files ---
46#include "AliLog.h"
4e25ac79 47#include "AliQAv1.h"
c03351ac 48#include "AliQAChecker.h"
394c1a6d 49#include "AliCDBEntry.h"
50#include "AliQAManager.h"
c03351ac 51#include "AliT0QAChecker.h"
52
53ClassImp(AliT0QAChecker)
54
4e67e173 55//__________________________________________________________________
4e25ac79 56Double_t * AliT0QAChecker::Check(AliQAv1::ALITASK_t index,TObjArray ** list)
3685c21c 57{
58
59 // Super-basic check on the QA histograms on the input list:
60 // look whether they are empty!
394c1a6d 61
57acd2d2 62 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
394c1a6d 63 /*
64 char * detOCDBDir = Form("T0/%s/%s", AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ;
65 AliCDBEntry *QARefRec = AliQAManager::QAManager()->Get(detOCDBDir);
66 // QARefRec->Dump();
67 if( !QARefRec){
68 AliInfo("QA reference data NOT retrieved for Reconstruction check. No T0 reference distribution");
69 }
70 */
71 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
57acd2d2 72 test[specie] = 10.0 ;
c724dd64 73
332b9234 74 Double_t nent[500];
75 TString hname[500];
5ed41460 76 const char *cname;
332b9234 77 memset(nent,0,500*sizeof(Double_t));
78 Double_t w[500];
79 memset(w,1,500*sizeof(Double_t));
0d849919 80 TH2 *fhRecDiff[3];
332b9234 81 TH1 *fhRawEff[500];
57acd2d2 82 TH1 *fhESD[2];
83
84 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 85 // TString dataType = AliQAv1::GetAliTaskName(index);
57acd2d2 86 if (list[specie]->GetEntries() == 0){
87 test[specie] = 1. ; // nothing to check
88 }
89 else {
90 TIter next(list[specie]) ;
3685c21c 91 TH1 * hdata ;
0d849919 92 TH2 * h ;
5379c4a3 93 // AliDebug(AliQAv1::GetQADebugLevel(), Form(" data type %i %s nentries %i\n",
57acd2d2 94 // index,dataType.Data(),list->GetEntries()));
95 for (Int_t ir=0; ir<list[specie]->GetEntries(); ir++) {
96 //raw
97 if(index==0 ){
332b9234 98 if(ir > 204 && ir<208 ) {
57acd2d2 99 // else{
332b9234 100 hdata = (TH1*) list[specie]->UncheckedAt(ir);
5379c4a3 101 AliDebug(AliQAv1::GetQADebugLevel(), Form(" index %i ir %i \n", index,ir));
332b9234 102 if(hdata) {
103 cname = hdata->GetName();
57acd2d2 104 hname[ir] = cname;
5379c4a3 105 AliDebug(AliQAv1::GetQADebugLevel(),Form("count %i %s \n",ir, hname[ir].Data())) ;
332b9234 106 fhRawEff[ir] = hdata;
57acd2d2 107 }
108 }
394c1a6d 109 }
110
57acd2d2 111 //rec
112 if(index==2){
113 h = (TH2*) list[specie]->UncheckedAt(ir);
114 if(h) {
115 cname = h->GetName();
116 hname[ir] = cname;
394c1a6d 117 // AliDebug(AliQAv1::GetQADebugLevel(), Form("count %i %s \n",ir, hname[ir].Data())) ;
118 fhRecDiff[ir] = h;
57acd2d2 119 }
120 }
121 //esd
122 if(index==3){
57acd2d2 123 hdata = (TH1*) list[specie]->UncheckedAt(ir);
124 if(hdata){
125 fhESD[ir] = hdata;
5379c4a3 126 AliDebug(AliQAv1::GetQADebugLevel(), Form("count %i %s ",ir, hname[ir].Data()) );
57acd2d2 127 }
0d849919 128 }
57acd2d2 129 }
394c1a6d 130 //raw data
131 if (index == 0) test[specie] = CheckRaw(list[specie]/*,(TObjArray *)QARefRec->GetObject()*/);
132
133
134
57acd2d2 135 if(index == 2){
136 //rec points
137 for (Int_t icase=0; icase<2; icase++) {
138 for (Int_t idet=0; idet<24; idet++) {
139 Double_t mean = fhRecDiff[icase]->
140 ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
141 idet,idet+1)->GetMean();
142 Double_t rms= fhRecDiff[icase]->
143 ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
144 idet,idet+1)->GetRMS();
5379c4a3 145 AliDebug(AliQAv1::GetQADebugLevel(), Form("name %s icase %i idet %i mean %f, rms %f\n",
57acd2d2 146 fhRecDiff[icase]->GetName(), icase, idet, mean,rms));
0d849919 147
57acd2d2 148 if(TMath::Abs(mean) >1.5 || rms >1){
5379c4a3 149 AliDebug(AliQAv1::GetQADebugLevel(), Form(" calibration is nor perfect; test=%f", test)) ;
57acd2d2 150 test[specie]=0.25;
151 }
152 if(mean>3 || rms >5) {
153 test[specie] = 0.1;
5379c4a3 154 AliDebug(AliQAv1::GetQADebugLevel(), Form(" wrong calibration test=%f", test[specie])) ;
57acd2d2 155 }
156 }
157 }
3685c21c 158 }
57acd2d2 159 if (index == 3) {
160 //ESD
161 for (Int_t icase=0; icase<2; icase++) {
162 Double_t rmsVertex = fhESD[icase]->GetRMS();
163 Double_t meanVertex = fhESD[icase]->GetMean();
164 test[specie]=1;
5379c4a3 165 AliDebug(AliQAv1::GetQADebugLevel(), Form("numentries %d meanVertex %f rmsVertex %f", fhESD[icase]->GetEntries(), meanVertex, rmsVertex));
57acd2d2 166 if (TMath::Abs(rmsVertex)>3) {
167 test[specie]=0.25;
5379c4a3 168 AliDebug(AliQAv1::GetQADebugLevel(), Form("Vertex position resolution not good , rms= %f test=%f",
57acd2d2 169 rmsVertex, test[specie])) ;
170 }
171 if (TMath::Abs(meanVertex)>3) {
172 test[specie]=0.25;
5379c4a3 173 AliDebug(AliQAv1::GetQADebugLevel(), Form("Vertex position bad calibrated , Mean= %f test=%f",
57acd2d2 174 meanVertex, test[specie])) ;
175 }
176 }
177 }
178 } // if (list->GetEntries() != 0
5379c4a3 179 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test[specie])) ;
57acd2d2 180 }
394c1a6d 181
3685c21c 182 return test ;
183}
5ed41460 184
394c1a6d 185//--------------------------------------------------------------------------
186Double_t AliT0QAChecker::CheckRaw(TObjArray *listrec /*, TObjArray *listref*/) const
187{
188
332b9234 189 TH1 *fhRawEff;
394c1a6d 190 // TH2 *fhRawRef;
191 // TIter next(listref) ;
192 // Int_t counter=0;
193 // Float_t refmean[50];
194 // Float_t refrms[50];
195 Float_t checkr = 0;
196 /*
197 // Int_t nref = listref->GetEntries();
198 // Int_t nrec = listrec->GetEntries();
199
200 cout<<" entries in ref "<<nref<<" in rec "<<nrec<<endl;
201 // for (Int_t iref=0; iref<nref; iref++){
202 while (fhRawRef = dynamic_cast<TH2 *>(next())) {
203 // fhRawRef->Dump();
204 // fhRawRef =(TH2*) listref->At(iref);
205 cout<<counter<<" hist "<<fhRawRef<<endl;
206 fhRawRef->Print();
207 fhRawRef->Dump();
208 refmean[counter] = fhRawRef->GetMean(2);
209 cout<<counter<<" mean "<<refmean[counter]<<endl;
210 refrms[counter] = fhRawRef->GetRMS(2);
211 cout<<counter<<" rms "<<refrms[counter]<<endl;
212 counter++;
213 cout<<" !!!!! reference "<<counter<<" "<<refmean[counter]<<" "<<refrms[counter]<<endl;
214 }
215 */
332b9234 216
217 for (Int_t icase=205; icase<208; icase++) {
218 fhRawEff = (TH1*) listrec->At(icase);
394c1a6d 219 for (Int_t idet=0; idet<24; idet++) {
332b9234 220 Double_t mean = fhRawEff->GetBinContent(idet);
221 AliDebug(AliQAv1::GetQADebugLevel(),
222 Form("name %s icase %i idet %i mean %f \n",
223 fhRawEff->GetName(), icase, idet, mean));
224
394c1a6d 225 if (mean<1.2 && mean> 0.8 ) {
226 checkr = 1;
332b9234 227 AliDebug(AliQAv1::GetQADebugLevel(), Form("All channels works meane efficieny %f with test %f", mean, checkr)) ;
394c1a6d 228 }
229 if (mean<=0.8 && mean>= 0.5 ){
230 checkr = 0.5;
231 AliDebug(AliQAv1::GetQADebugLevel(),
232 Form("%s problem in channel %i efficieny %f test %f",
233 fhRawEff->GetName(), idet, mean,checkr )) ;
234 }
235 if (mean<0.5 ) {
236 checkr = 0.25;
237 AliDebug(AliQAv1::GetQADebugLevel(),
238 Form("%s big problem in channel %i efficieny %f test %f",
239 fhRawEff->GetName(), idet, mean,checkr )) ;
240 }
241 }
242 }
332b9234 243 /*
394c1a6d 244 for (Int_t icase=208; icase<210; icase++) {
245 fhRawEff = (TH2*) listrec->At(icase);
246
247 for (Int_t idet=0; idet<24; idet++) {
248 Double_t mean = fhRawEff->
249 ProjectionY(Form("%s_py_%i_%i", fhRawEff ->GetName(), idet,icase),
250 idet,idet+1)->GetMean();
251 Double_t rms= fhRawEff ->
252 ProjectionY(Form("%s_py%i_%i",
253 fhRawEff ->GetName(), idet,icase),
254 idet,idet+1)->GetRMS();
255
256
257
258 AliDebug(AliQAv1::GetQADebugLevel(),
259 Form("name %s icase %i idet %i mean %f, rms %f\n",
260 fhRawEff->GetName(), icase, idet, mean,rms));
332b9234 261
394c1a6d 262 }
263
264 }
332b9234 265 */
394c1a6d 266 return checkr;
267}
268