AliTOFHeader include in AliAODEvent
[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>
be3ada9f 36#include <TF1.h>
37#include <TFitResultPtr.h>
0d849919 38#include <TH2.h>
c03351ac 39#include <TIterator.h>
40#include <TKey.h>
41#include <TFile.h>
446d6ec4 42#include <TMath.h>
0d849919 43#include <TString.h>
be3ada9f 44#include <TPaveText.h>
c03351ac 45
46// --- Standard library ---
47
48// --- AliRoot header files ---
49#include "AliLog.h"
4e25ac79 50#include "AliQAv1.h"
c03351ac 51#include "AliQAChecker.h"
394c1a6d 52#include "AliCDBEntry.h"
53#include "AliQAManager.h"
c03351ac 54#include "AliT0QAChecker.h"
55
56ClassImp(AliT0QAChecker)
be3ada9f 57//____________________________________________________________________________
58AliT0QAChecker::AliT0QAChecker() :
59AliQACheckerBase("T0","T0 Quality Assurance Checker")
60
61{
62 // Standard constructor
63
64}
65
66//____________________________________________________________________________
be3ada9f 67AliT0QAChecker::~AliT0QAChecker(){
68 // destructor
69
70}
c03351ac 71
4e67e173 72//__________________________________________________________________
a42ceb0e 73void AliT0QAChecker::Check(Double_t * test, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
3685c21c 74{
75
76 // Super-basic check on the QA histograms on the input list:
77 // look whether they are empty!
a42ceb0e 78
be3ada9f 79 char * detOCDBDir = Form("T0/%s/%s", AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ;
8825d145 80
394c1a6d 81 AliCDBEntry *QARefRec = AliQAManager::QAManager()->Get(detOCDBDir);
82 // QARefRec->Dump();
83 if( !QARefRec){
84 AliInfo("QA reference data NOT retrieved for Reconstruction check. No T0 reference distribution");
85 }
8825d145 86
be3ada9f 87 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
57acd2d2 88 test[specie] = 10.0 ;
c724dd64 89
57acd2d2 90 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 91 // TString dataType = AliQAv1::GetAliTaskName(index);
92664bc8 92 if (!(AliQAv1::Instance()->IsEventSpecieSet(specie) && list[specie]) || list[specie]->GetEntries() == 0) {
57acd2d2 93 test[specie] = 1. ; // nothing to check
92664bc8 94 continue;
57acd2d2 95 }
92664bc8 96 if (index == AliQAv1::kRAW && AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib)
97 // if (index == AliQAv1::kRAW )
98 {
99 test[specie] = CheckRaw(list[specie]);
100 }
101 if (index == AliQAv1::kESD && AliRecoParam::Convert(specie) != AliRecoParam::kCalib)
102 test[specie] = CheckESD(list[specie]);
103 //
be3ada9f 104 }
105}
394c1a6d 106
be3ada9f 107//--------------------------------------------------------------------------
108Double_t AliT0QAChecker::CheckRaw(TObjArray *listrec) const
109{
110 Float_t checkr = 0;
111
112 TString hname[10];
113 TH1*hdata;
114 const char *cname;
115 TH1 *fhRawEff[10];
116 Int_t nh=0;
117
394c1a6d 118
f88549d9 119 // Int_t nnn[4] = { 420, 458, 459, 460};
13579355 120 Int_t nnn[4] = { 169, 207, 208, 209};
be3ada9f 121 for (Int_t ir=0; ir<4; ir++)
122 {
123 hdata = (TH1*) listrec->UncheckedAt(nnn[ir]);
124 if(hdata) {
125 cname = hdata->GetName();
126 hname[ir] = cname;
127 fhRawEff[nh] = hdata;
128 nh++;
129 }
130 }
131
105ff51c 132 TLine linelowyellow(0, 0.7, 24, 0.7);
133 linelowyellow.SetLineColor(5);
134 linelowyellow.SetLineStyle(3);
135 linelowyellow.SetLineWidth(4);
136 TLine linelowred(0, 0.2, 24, 0.2);
137 linelowred.SetLineColor(2);
138 linelowred.SetLineStyle(3);
139 linelowred.SetLineWidth(4);
8825d145 140
be3ada9f 141 Float_t thryell = 0.7;
105ff51c 142 // TPaveText text(0.30,0.50,0.99,0.99,"NDC");
be3ada9f 143 Float_t thrred = 0.2;
144 Float_t chcont =0;
145 for (Int_t ih= 0; ih<4; ih++)
146 {
105ff51c 147 // clean objects added at previous checks
148 TList* lstF = fhRawEff[ih]->GetListOfFunctions();
149 if (lstF) {
150 TObject *stats = lstF->FindObject("stats");
151 lstF->Remove(stats);
152 TObject *obj;
153 while ((obj = lstF->First())) {
154 while(lstF->Remove(obj)) { }
155 delete obj;
156 }
157 if (stats) lstF->Add(stats);
158 }
be3ada9f 159 fhRawEff[ih]->SetLineWidth(2);
160 fhRawEff[ih]->SetMaximum(2.);
161 fhRawEff[ih]->SetMinimum(0.);
105ff51c 162 fhRawEff[ih]->GetListOfFunctions()->Add((TLine*)linelowyellow.Clone());
163 fhRawEff[ih]->GetListOfFunctions()->Add((TLine*)linelowred.Clone());
8825d145 164
be3ada9f 165 Int_t nbins= fhRawEff[ih]->GetNbinsX();
166 Bool_t yell = kFALSE;
167 Bool_t red = kFALSE;
168 for (Int_t in=1; in<nbins-1; in++)
169 {
170 if(ih==0 && in==5) continue;
171 chcont=fhRawEff[ih]->GetBinContent(in);
172 if (chcont < thryell ) yell = kTRUE;
173 if (chcont < thrred ) red = kTRUE;
174 }
175
176 if (! yell && !red) {
177 AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s is good", fhRawEff[ih]->GetName() ));
178 checkr=1.;
105ff51c 179 // text.AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
180 // text.AddText(Form(" No problems "));
181 // text.SetFillColor(3);
be3ada9f 182 }
183
184 if(red ) {
185 checkr = 0.;
186 AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s is not so good", fhRawEff[ih]->GetName() ));
105ff51c 187 // text.AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
188 // text.AddText(Form("Very serious problem, call expert "));
189 // text.SetFillColor(2);
be3ada9f 190 }
191
192 if ( yell && !red) {
193 AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s is not so good", fhRawEff[ih]->GetName() ));
194 checkr=0.75;
105ff51c 195 // text.AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
196 // text.AddText(Form("Some problems "));
197 // text.SetFillColor(5);
57acd2d2 198 }
105ff51c 199 // fhRawEff[ih]->GetListOfFunctions()->Add((TPaveText*)text.Clone());
be3ada9f 200 }
1d6bd73f 201 return checkr;
be3ada9f 202
3685c21c 203}
5ed41460 204
be3ada9f 205
394c1a6d 206//--------------------------------------------------------------------------
be3ada9f 207Double_t AliT0QAChecker::CheckESD(TObjArray *listrec ) const
394c1a6d 208{
394c1a6d 209 Float_t checkr = 0;
be3ada9f 210 TH1 *fhESD;
211
212 fhESD = (TH1*) listrec->UncheckedAt(2);
213 if(fhESD){
214 AliDebug(AliQAv1::GetQADebugLevel(), Form("count %s ", fhESD->GetName()) );
215 TF1 *f1 = new TF1("f1","gaus",-1,1);
216 fhESD->Fit("f1","R","Q", -1,1);
217 Double_t par[3];
218 f1->GetParameters(&par[0]);
219
105ff51c 220 TPaveText text(0.30,0.50,0.99,0.99,"NDC");
be3ada9f 221
105ff51c 222 text.AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
be3ada9f 223
db33b25a 224 AliDebug(AliQAv1::GetQADebugLevel(), Form("numentries %d mean %f #sigma %f", (int)fhESD->GetEntries(),par[1], par[2]));
be3ada9f 225
226
227 if (par[2] > 0.07 && par[2] < 1.) {
228 checkr=0.5;
105ff51c 229 text.AddText(Form("not good resolution :\n %f ns\n", par[2] ));
230 text.SetFillColor(5);
be3ada9f 231 printf("T0 detector resolution is not good enouph: %f ns\n",par[2] );
232 }
233 if(TMath::Abs(par[1])>0.05) {
234 checkr = 0.5;
105ff51c 235 text.AddText(Form(" Check clock shift on %f ns", par[1]));
236 text.SetFillColor(5);
be3ada9f 237 }
238 if (par[2] > 1. || TMath::Abs(par[1])>0.1) {
239 checkr = 0.25;
105ff51c 240 text.AddText(Form(" Bad resolution:\n mean %f ns sigma %f ns", par[1], par[2]));
241 text.SetFillColor(2);
242 { // RS Clean previous additions
243 TList* lstF = fhESD->GetListOfFunctions();
244 if (lstF) {
245 TObject *stats = lstF->FindObject("stats");
246 lstF->Remove(stats);
247 TObject *obj;
248 while ((obj = lstF->First())) {
249 while(lstF->Remove(obj)) { }
250 delete obj;
251 }
252 if (stats) lstF->Add(stats);
253 }
254 }
255 fhESD->GetListOfFunctions()->Add((TPaveText*)text.Clone());
256 AliDebug(AliQAv1::GetQADebugLevel(),
257 Form("Please, check calibration: shift= %f resolution %f test=%f\n",
258 par[1], par[2], checkr) ) ;
be3ada9f 259 }
394c1a6d 260 }
be3ada9f 261 else
262 {
263 AliDebug(AliQAv1::GetQADebugLevel(),
264 Form("No ESD QA histogram found, nothing to check"));
265 checkr=0;
266 }
267
332b9234 268
394c1a6d 269 return checkr;
270}