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