AddTask for Ds efficiency (Gian Michele)
[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"),
afae9650 57fTextSM(new TText*[fgknSM]),
8a38cd34 58fLineCol(new TLine(47.5,-0.5,47.5,119.5)),
00957c37 59fText(new TPaveText(0.2,0.7,0.8,0.9,"NDC"))
9e47432c 60{
38986b78 61 // ctor
62 fLineCol->SetLineColor(1);
63 fLineCol->SetLineWidth(2);
38986b78 64
65 fTextSM[0]= new TText(20, 12, "SM A0");
8a38cd34 66 fTextSM[1]= new TText(20, 36, "SM A1");
67 fTextSM[2]= new TText(20, 60, "SM A2");
68 fTextSM[3]= new TText(20, 84, "SM A3");
69 fTextSM[4]= new TText(20, 108,"SM A4");
b8769ad2 70 fTextSM[5]= new TText(20, 132,"SM A5");
8a38cd34 71
b8769ad2 72 fTextSM[6]= new TText(64, 12, "SM C0");
73 fTextSM[7]= new TText(64, 36, "SM C1");
74 fTextSM[8]= new TText(64, 60, "SM C2");
75 fTextSM[9]= new TText(64, 84, "SM C3");
76 fTextSM[10]= new TText(64, 108,"SM C4");
77 fTextSM[11]= new TText(64, 132,"SM C5");
8a38cd34 78
b8769ad2 79 for(int i = 0; i < 5; i++) {
8a38cd34 80 fLineRow[i] = new TLine(-0.5,23.5+(24*i),95.5,23.5+(24*i));
81 fLineRow[i]->SetLineColor(1);
82 fLineRow[i]->SetLineWidth(2);
83 }
84
85
9e47432c 86}
87
88//__________________________________________________________________
89AliEMCALQAChecker::~AliEMCALQAChecker()
90{
91 /// dtor
38986b78 92 delete [] fTextSM ;
a42ceb0e 93 delete fLineCol ;
b8769ad2 94 for (Int_t i=0; i<5; ++i) delete fLineRow[i] ;
a42ceb0e 95 delete fText ;
9e47432c 96}
97
9e47432c 98//______________________________________________________________________________
a42ceb0e 99void AliEMCALQAChecker::Check(Double_t * test, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
9e47432c 100{
101 /// Check objects in list
102
103 if ( index == AliQAv1::kRAW )
104 {
a42ceb0e 105 CheckRaws(test, list);
9e47432c 106 printf ("checkers for task %d \n", index) ;
107 }
108
109 if ( index == AliQAv1::kREC)
110 {
a42ceb0e 111 CheckRecPoints(test, list);
9e47432c 112 }
113
114 if ( index == AliQAv1::kESD )
115 {
a42ceb0e 116 CheckESD(test, list);
9e47432c 117 }
118 AliWarning(Form("Checker for task %d not implement for the moment",index));
9e47432c 119}
120
121//______________________________________________________________________________
122TH1*
123AliEMCALQAChecker::GetHisto(TObjArray* list, const char* hname, Int_t specie) const
124{
125 /// Get a given histo from the list
126 TH1* h = static_cast<TH1*>(list->FindObject(Form("%s_%s",AliRecoParam::GetEventSpecieName(specie),hname)));
127 if (!h)
128 {
129 AliError(Form("Did not find expected histo %s",hname));
130 }
131 return h;
132}
133
134//______________________________________________________________________________
135Double_t
136AliEMCALQAChecker::MarkHisto(TH1& histo, Double_t value) const
137{
138 /// Mark histo as originator of some QA error/warning
139
140 if ( value != 1.0 )
141 {
142 histo.SetBit(AliQAv1::GetQABit());
143 }
144
145 return value;
146}
147
148
149//______________________________________________________________________________
a42ceb0e 150void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list)
9e47432c 151{
f05c8877 152 // Check RAW QA histograms
153 // -- Yaxian Mao, CCNU/CERN/LPSC
154 //adding new checking method: 25/04/2010, Yaxian Mao
155 //Comparing the amplitude from current run to the reference run, if the ratio in the range [0.8, .12], count as a good tower.
156 //If more than 90% towers are good, EMCAL works fine, otherwise experts should be contacted.
6a754398 157
38986b78 158
159 //Float_t kThreshold = 80. ;
160 Int_t nTowersPerSM = 24*48; // number of towers in a SuperModule; 24x48
afae9650 161 Double_t nTot = fgknSM * nTowersPerSM ;
180c431b 162 TList *lstF = 0;
a2655076 163 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
a42ceb0e 164 test[specie] = 0.0 ;
a2655076 165 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie))
166 continue ;
167 if (list[specie]->GetEntries() == 0)
a42ceb0e 168 test[specie] = 0. ; // nothing to check
a2655076 169 else {
38986b78 170 TH2F * hdata = (TH2F*)list[specie]->At(k2DRatioAmp) ;
171 TH1F * ratio = (TH1F*)list[specie]->At(kRatioDist) ;
172 if(hdata->GetEntries()==0 || ratio->GetEntries()==0)
173 continue;
174 //adding the lines to distinguish different SMs
180c431b 175 lstF = hdata->GetListOfFunctions();
176 { // RS: clean list of functions
177 if (lstF) {
178 TObject *stats = lstF->FindObject("stats"); lstF->Remove(stats);
179 TObject *obj;
180 while ((obj = lstF->First())) { while(lstF->Remove(obj)) { } delete obj; }
181 if (stats) lstF->Add(stats);
9ae19208 182 }
183 else {
184 AliWarning(Form("Checker : empty list of data functions; returning"));
185 return;
186 }
f05c8877 187 }
180c431b 188 lstF->Add(fLineCol->Clone());
189 for(Int_t iLine = 0; iLine < 4; iLine++) {
190 lstF->Add(fLineRow[iLine]->Clone());
191 }
192 //Now adding the text to for each SM
afae9650 193 for(Int_t iSM = 0 ; iSM < fgknSM ; iSM++){ //number of SMs loop start
180c431b 194 lstF->Add(fTextSM[iSM]->Clone());
195 }
196 //
197 lstF = ratio->GetListOfFunctions();
198 { // RS: clean list of functions
199 if (lstF) {
200 TObject *stats = lstF->FindObject("stats"); lstF->Remove(stats);
201 TObject *obj;
202 while ((obj = lstF->First())) { while(lstF->Remove(obj)) { } delete obj; }
203 if (stats) lstF->Add(stats);
9ae19208 204 }
205 else {
206 AliWarning(Form("Checker : empty list of ratio functions; returning"));
207 return;
180c431b 208 }
209 }
180c431b 210 //
38986b78 211 //now check the ratio histogram
212 Double_t binContent = 0. ;
213 Int_t NGoodTower = 0 ;
f05c8877 214 Double_t rv = 0. ;
38986b78 215 for(Int_t ix = 1; ix <= hdata->GetNbinsX(); ix++) {
216 for(Int_t iy = 1; iy <= hdata->GetNbinsY(); iy++) {
217 binContent = hdata->GetBinContent(ix, iy) ;
218 if (binContent < 1.2 && binContent > 0.8)
219 NGoodTower++ ;
6a754398 220 }
6a754398 221 }
38986b78 222 rv = NGoodTower/nTot ;
f05c8877 223 printf("%2.2f %% towers out of range [0.8, 1.2]\n", (1-rv)*100);
224 if(fText){
8e747257 225 lstF->Add(fText->Clone()) ;
f05c8877 226 fText->Clear() ;
7e1d9a9b 227
228 fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));
229 if (rv < 0.9) {
230 test[specie] = 0.9 ;
231 // 2 lines text info for quality
232 fText->SetFillColor(2) ;
233 fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!"));
234 }
235 else {
236 test[specie] = 0.1 ;
237 fText->SetFillColor(3) ;
238 fText->AddText(Form("EMCAL = OK, ENJOY..."));
239 }
240 //hdata->Reset("ICE");
241 //ratio->Reset("ICE");
242 }//fText
180c431b 243 }
244 } //finish the checking
9e47432c 245}
246
247//______________________________________________________________________________
248void AliEMCALQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
249{
250 /// intialises QA and QA checker settings
251 AliQAv1::Instance(det) ;
252 Float_t hiValue[AliQAv1::kNBIT] ;
253 Float_t lowValue[AliQAv1::kNBIT] ;
254 lowValue[AliQAv1::kINFO] = 0.0 ;
255 hiValue[AliQAv1::kINFO] = 0.1 ;
9e47432c 256 lowValue[AliQAv1::kWARNING] = 0.1 ;
6a754398 257 hiValue[AliQAv1::kWARNING] = 0.5 ;
9e47432c 258 lowValue[AliQAv1::kERROR] = 0.5 ;
259 hiValue[AliQAv1::kERROR] = 0.8 ;
260 lowValue[AliQAv1::kFATAL] = 0.8 ;
261 hiValue[AliQAv1::kFATAL] = 1.0 ;
262 SetHiLo(&hiValue[0], &lowValue[0]) ;
263}
94594e5d 264