improved version from Tomek
[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"
47#include "AliQA.h"
48#include "AliQAChecker.h"
49#include "AliT0QAChecker.h"
50
51ClassImp(AliT0QAChecker)
52
3685c21c 53
4e67e173 54//__________________________________________________________________
d1b21c1b 55Double_t AliT0QAChecker::Check(AliQA::ALITASK_t index,TObjArray * list)
3685c21c 56{
57
58 // Super-basic check on the QA histograms on the input list:
59 // look whether they are empty!
446d6ec4 60
c724dd64 61
5ed41460 62 Double_t test = 10.0 ;
0d849919 63
64 Double_t nent[250];
c4b97145 65 TString hname[250];
5ed41460 66 const char *cname;
c4b97145 67 memset(nent,0,250*sizeof(Double_t));
68 Double_t w[250];
69 memset(w,1,250*sizeof(Double_t));
0d849919 70 TH2 *fhRecDiff[3];
71 TH2 *fhRawEff[250];
72 TH1 *fhESD[2];
73
74 // TString dataType = AliQA::GetAliTaskName(index);
c03351ac 75
3685c21c 76 if (list->GetEntries() == 0){
77 test = 1. ; // nothing to check
3685c21c 78 }
79 else {
446d6ec4 80
3685c21c 81 TIter next(list) ;
82 TH1 * hdata ;
c724dd64 83
0d849919 84 TH2 * h ;
85 // printf(" data type %i %s nentries %i\n",
86 // index,dataType.Data(),list->GetEntries());
87
88 for (Int_t ir=0; ir<list->GetEntries(); ir++)
89 {
90 //raw
91 if(index==0 ){
92 /*
93 if(ir < 205) {
94 hdata = (TH1*) list->UncheckedAt(ir);
95 if(hdata) {
96 cname = hdata->GetName();
97 hname[ir] = cname;
98 AliDebug(10,Form("count %i %s \n",ir, hname[ir].Data())) ;
99 fhRaw[ir] = hdata;
100 }
101 }*/
102 if(ir > 204) {
103 // else{
104 h = (TH2*) list->UncheckedAt(ir);
105 printf(" index %i ir %i \n", index,ir);
106 if(h) {
107 cname = h->GetName();
108 hname[ir] = cname;
109 AliDebug(1,Form("count %i %s \n",ir, hname[ir].Data())) ;
110 fhRawEff[ir] = h;
111 }
112 }
113 }
114
115 //rec
c724dd64 116 if(index==2){
0d849919 117 h = (TH2*) list->UncheckedAt(ir);
118
119 if(h) {
120 cname = h->GetName();
121 hname[ir] = cname;
122 AliDebug(1,Form("count %i %s \n",ir, hname[ir].Data())) ;
123 fhRecDiff[ir] = h;
124 }
c724dd64 125 }
0d849919 126 //esd
c33b02bf 127 if(index==3){
0d849919 128 cout<<" ir "<<ir<<endl;
129 hdata = (TH1*) list->UncheckedAt(ir);
130 if(hdata){
131 fhESD[ir] = hdata;
132 AliDebug(1,Form("count %i %s ",ir, hname[ir].Data()) );
0608f4dc 133 }
c33b02bf 134 }
0d849919 135 }
136
137 if (index == 0)
138 {
139 //raw data
5ed41460 140
0d849919 141 for (Int_t icase=205; icase<207; icase++) {
142 for (Int_t idet=0; idet<24; idet++) {
143 Double_t mean = fhRawEff[icase]->
144 ProjectionY(Form("%s_py_%i_%i",
145 fhRawEff[icase]->GetName(), idet,icase),
146 idet,idet+1)->GetMean();
147 Double_t rms= fhRawEff[icase]->
148 ProjectionY(Form("%s_py%i_%i",
149 fhRawEff[icase]->GetName(), idet,icase),
150 idet,idet+1)->GetRMS();
151 printf("name %s icase %i idet %i mean %f, rms %f\n",
152 fhRawEff[icase]->GetName(), icase, idet, mean,rms);
153
154 if (mean<1.2 && mean> 0.8 ) {
155 test = 1;
156 AliDebug(1,Form("All channels works meane efficieny %f with rms %f test %f", mean, rms, test)) ;
157 }
158 if (mean<=0.8 && mean>= 0.5 ){
159 test = 0.5;
160 AliDebug(1,Form("%s problem in channel %i efficieny %f test %f",
161 fhRawEff[icase]->GetName(), idet, mean, test)) ;
162 }
163 if (mean<0.5 ) {
164 test = 0.25;
165 AliDebug(1,Form("%s big problem in channel %i efficieny %f test %f",
166 fhRawEff[icase]->GetName(), idet, mean, test)) ;
167 }
168
169 }
170
171 }
3685c21c 172 }
5ed41460 173
0d849919 174 if(index == 2){
175 //rec points
176 for (Int_t icase=0; icase<2; icase++) {
177 for (Int_t idet=0; idet<24; idet++) {
178 Double_t mean = fhRecDiff[icase]->
179 ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
180 idet,idet+1)->GetMean();
181 Double_t rms= fhRecDiff[icase]->
182 ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
183 idet,idet+1)->GetRMS();
184 printf("name %s icase %i idet %i mean %f, rms %f\n",
185 fhRecDiff[icase]->GetName(), icase, idet, mean,rms);
186
187 if(TMath::Abs(mean) >1.5 || rms >1){
188 AliDebug(1,Form(" calibration is nor perfect; test=%f", test)) ;
189 test=0.25;
c724dd64 190 }
0d849919 191 if(mean>3 || rms >5) {
192 test = 0.1;
193 AliDebug(1,Form(" wrong calibration test=%f", test)) ;
194 }
195 }
196
197 }
198 }
199
200 if (index == 3) {
201 //ESD
202 for (Int_t icase=0; icase<2; icase++) {
203 Double_t rmsVertex = fhESD[icase]->GetRMS();
204 Double_t meanVertex = fhESD[icase]->GetMean();
205
206 test=1;
207 cout<<"numentries "<< fhESD[icase]->GetEntries()<<" meanVertex "<<meanVertex<<" rmsVertex "<<rmsVertex<<endl;
208 if (TMath::Abs(rmsVertex)>3) {
209 test=0.25;
210 AliDebug(1,Form("Vertex position resolution not good , rms= %f test=%f",
211 rmsVertex, test)) ;
446d6ec4 212 }
0d849919 213 if (TMath::Abs(meanVertex)>3) {
214 test=0.25;
215 AliDebug(1,Form("Vertex position bad calibrated , Mean= %f test=%f",
216 meanVertex, test)) ;
c33b02bf 217 }
3685c21c 218 }
5ed41460 219
3685c21c 220 }
0d849919 221
c724dd64 222 } // if (list->GetEntries() != 0
0d849919 223
3685c21c 224 AliInfo(Form("Test Result = %f", test)) ;
0d849919 225
3685c21c 226 return test ;
227}
5ed41460 228