]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALQAChecker.cxx
Updated checking and display for AMORE (Yves)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALQAChecker.cxx
CommitLineData
94594e5d 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/*
17 Checks the quality assurance.
18 By comparing with reference data
19
20 Based on PHOS code written by
21 Y. Schutz CERN July 2007
9e47432c 22
a2655076 23 For the moment we only implement the checking of raw data QA.
24 The checked for ESD and RecPoints will be implemented later.
9e47432c 25
26
9e47432c 27 */
28
94594e5d 29
30// --- ROOT system ---
31#include <TClass.h>
9e47432c 32#include <TH1.h>
33#include <TF1.h>
94594e5d 34#include <TH1I.h>
38986b78 35#include <TH2F.h>
94594e5d 36#include <TIterator.h>
37#include <TKey.h>
38#include <TFile.h>
9e47432c 39#include <TLine.h>
38986b78 40#include <TText.h>
9e47432c 41#include <TPaveText.h>
42#include <TMath.h>
94594e5d 43
44// --- Standard library ---
45
46// --- AliRoot header files ---
47#include "AliLog.h"
4e25ac79 48#include "AliQAv1.h"
94594e5d 49#include "AliQAChecker.h"
50#include "AliEMCALQAChecker.h"
51
52ClassImp(AliEMCALQAChecker)
53
9e47432c 54//__________________________________________________________________
55AliEMCALQAChecker::AliEMCALQAChecker() :
56AliQACheckerBase("EMCAL","EMCAL Quality Assurance Data Maker"),
38986b78 57fTextSM(new TText*[fknSM]),
58fLineCol(new TLine(47.5,-0.5,47.5,47.5)),
59fLineRow(new TLine(-0.5,23.5,95.5,23.5)),
60fText(new TPaveText(0.2,1000.,0.7,2000.,"NDC")),
61fTest(new Double_t[AliRecoParam::kNSpecies])
9e47432c 62{
38986b78 63 // ctor
64 fLineCol->SetLineColor(1);
65 fLineCol->SetLineWidth(2);
66 fLineRow->SetLineColor(1);
67 fLineRow->SetLineWidth(2);
68
69 fTextSM[0]= new TText(20, 12, "SM A0");
70 fTextSM[1]= new TText(20, 38, "SM A1");
71 fTextSM[2]= new TText(64, 12, "SM C0");
72 fTextSM[3]= new TText(64, 38, "SM A0");
73
9e47432c 74 for (Int_t sm = 0 ; sm < fknSM ; sm++){
38986b78 75// fLine[sm] = NULL ;
76// fHref[sm] = NULL ;
9e47432c 77 }
38986b78 78 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
79 fTest[es] = 1.0 ;
80 }
9e47432c 81}
82
83//__________________________________________________________________
84AliEMCALQAChecker::~AliEMCALQAChecker()
85{
86 /// dtor
38986b78 87// delete [] fLine ;
88// delete [] fHref ;
89 delete [] fTextSM ;
90 if (fLineCol)
91 delete fLineCol ;
92 if (fLineRow)
93 delete fLineRow ;
9e47432c 94 if (fText)
38986b78 95 delete fText ;
96 if (fTest)
97 delete [] fTest ;
9e47432c 98}
99
100//__________________________________________________________________
101AliEMCALQAChecker::AliEMCALQAChecker(const AliEMCALQAChecker& qac) :
102AliQACheckerBase(qac.GetName(), qac.GetTitle()),
38986b78 103fTextSM(new TText*[fknSM]) ,
104fLineCol(static_cast<TLine*>(qac.fLineCol->Clone())) ,
105fLineRow(static_cast<TLine*>(qac.fLineRow->Clone())) ,
106fText(new TPaveText(0.2,1000.,0.7,2000.,"NDC")),
107fTest(new Double_t[AliRecoParam::kNSpecies])
9e47432c 108{
38986b78 109 // copy ctor
9e47432c 110 for (Int_t sm = 0 ; sm < fknSM ; sm++){
38986b78 111// fLine[sm] = new TLine(qac.fLine[sm]) ;
112// fHref[sm] = new TLine(qac.fHref[sm]) ;
113 fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
9e47432c 114 }
38986b78 115 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
116 fTest[es] = 0.0 ;
117 }
9e47432c 118}
119//__________________________________________________________________
38986b78 120AliEMCALQAChecker& AliEMCALQAChecker::operator = (const AliEMCALQAChecker &qac)
9e47432c 121{
38986b78 122 fTextSM = new TText*[fknSM] ;
123 fLineCol = static_cast<TLine*>(qac.fLineCol->Clone()) ;
124 fLineRow = static_cast<TLine*>(qac.fLineRow->Clone()) ;
125 fText = new TPaveText(0.2,1000.,0.7,2000.,"NDC") ;
126 fTest = new Double_t[AliRecoParam::kNSpecies] ;
9e47432c 127 for (Int_t sm = 0 ; sm < fknSM ; sm++){
38986b78 128 fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
9e47432c 129 }
38986b78 130 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
131 fTest[es] = 0.0 ;
132 }
9e47432c 133 return *this ;
134}
135
136//______________________________________________________________________________
137Double_t *
486788fc 138AliEMCALQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
9e47432c 139{
140 /// Check objects in list
141
142 if ( index == AliQAv1::kRAW )
143 {
144 return CheckRaws(list);
145 printf ("checkers for task %d \n", index) ;
146 }
147
148 if ( index == AliQAv1::kREC)
149 {
150 return CheckRecPoints(list);
151 }
152
153 if ( index == AliQAv1::kESD )
154 {
155 return CheckESD(list);
156 }
157 AliWarning(Form("Checker for task %d not implement for the moment",index));
158 return NULL;
159}
160
161//______________________________________________________________________________
162TH1*
163AliEMCALQAChecker::GetHisto(TObjArray* list, const char* hname, Int_t specie) const
164{
165 /// Get a given histo from the list
166 TH1* h = static_cast<TH1*>(list->FindObject(Form("%s_%s",AliRecoParam::GetEventSpecieName(specie),hname)));
167 if (!h)
168 {
169 AliError(Form("Did not find expected histo %s",hname));
170 }
171 return h;
172}
173
174//______________________________________________________________________________
175Double_t
176AliEMCALQAChecker::MarkHisto(TH1& histo, Double_t value) const
177{
178 /// Mark histo as originator of some QA error/warning
179
180 if ( value != 1.0 )
181 {
182 histo.SetBit(AliQAv1::GetQABit());
183 }
184
185 return value;
186}
187
188
189//______________________________________________________________________________
38986b78 190Double_t * AliEMCALQAChecker::CheckRaws(TObjArray ** list)
9e47432c 191{
a2655076 192// Check RAW QA histograms
193// We count the times of the response for each tower, the propability for all towers should be the same (average is given value).
194// We skip the first few cycles since the statistics is not enough, the average should be always larger than 1 at least.
195// By calculating the difference between the counts for each tower and the average, we decide whether we should recalculate
196// the average depending the the gaus fitting on the divation distribution.
197// During the recalutation of the average, we count how many towers are used for the calculation.
198// From the fraction of towers used, we decide whether each SM works fine or not
199// From the divation of average, we set the QA flag for the full detetcor as INFO, WARNING, ERROR or FATAL.
6a754398 200
a2655076 201// -- Yaxian Mao, CCNU/CERN/LPSC
38986b78 202
203 //Float_t kThreshold = 80. ;
204 Int_t nTowersPerSM = 24*48; // number of towers in a SuperModule; 24x48
205 Double_t nTot = fknSM * nTowersPerSM ;
206 Double_t rv = 0. ;
a2655076 207 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
a2655076 208 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie))
209 continue ;
210 if (list[specie]->GetEntries() == 0)
38986b78 211 fTest[specie] = 0. ; // nothing to check
a2655076 212 else {
38986b78 213 TH2F * hdata = (TH2F*)list[specie]->At(k2DRatioAmp) ;
214 TH1F * ratio = (TH1F*)list[specie]->At(kRatioDist) ;
215 if(hdata->GetEntries()==0 || ratio->GetEntries()==0)
216 continue;
217 //adding the lines to distinguish different SMs
218 if ( hdata->GetListOfFunctions()->GetEntries() == 0 ){
219 hdata->GetListOfFunctions()->Add(fLineCol);
220 hdata->GetListOfFunctions()->Add(fLineRow);
221 //Now adding the text to for each SM
222 for(Int_t iSM = 0 ; iSM < fknSM ; iSM++){ //number of SMs loop start
223 hdata->GetListOfFunctions()->Add(fTextSM[iSM]);
224 }
225 }
226 if ( ratio->GetListOfFunctions()->GetEntries() == 0 ){
227 ratio->GetListOfFunctions()->Add(fText) ;
9e47432c 228 }
38986b78 229
230 //now check the ratio histogram
231 Double_t binContent = 0. ;
232 Int_t NGoodTower = 0 ;
233 for(Int_t ix = 1; ix <= hdata->GetNbinsX(); ix++) {
234 for(Int_t iy = 1; iy <= hdata->GetNbinsY(); iy++) {
235 binContent = hdata->GetBinContent(ix, iy) ;
236 if (binContent < 1.2 && binContent > 0.8)
237 NGoodTower++ ;
6a754398 238 }
6a754398 239 }
38986b78 240 rv = NGoodTower/nTot ;
a2655076 241
a2655076 242
38986b78 243 if (rv < 0.9) {
244 fTest[specie] = 0.9 ;
245 // 2 lines text info for quality
246 fText->Clear() ;
247 fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));
248 fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!"));
6a754398 249 }
38986b78 250 else {
251 fTest[specie] = 0.1 ;
252 fText->Clear() ;
253 fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));
254 fText->AddText(Form("EMCAL = OK"));
6a754398 255 }
38986b78 256 }
257 } //finish the checking
258 return fTest ;
9e47432c 259}
260
261//______________________________________________________________________________
262void AliEMCALQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
263{
264 /// intialises QA and QA checker settings
265 AliQAv1::Instance(det) ;
266 Float_t hiValue[AliQAv1::kNBIT] ;
267 Float_t lowValue[AliQAv1::kNBIT] ;
268 lowValue[AliQAv1::kINFO] = 0.0 ;
269 hiValue[AliQAv1::kINFO] = 0.1 ;
9e47432c 270 lowValue[AliQAv1::kWARNING] = 0.1 ;
6a754398 271 hiValue[AliQAv1::kWARNING] = 0.5 ;
9e47432c 272 lowValue[AliQAv1::kERROR] = 0.5 ;
273 hiValue[AliQAv1::kERROR] = 0.8 ;
274 lowValue[AliQAv1::kFATAL] = 0.8 ;
275 hiValue[AliQAv1::kFATAL] = 1.0 ;
276 SetHiLo(&hiValue[0], &lowValue[0]) ;
277}
94594e5d 278