]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALQAChecker.cxx
Fixing warnings, add physics selection
[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]),
a42ceb0e 58fLineCol(new TLine(48.0,0.,48.0,47.0)),
59fLineRow(new TLine(0.,24.,96.,24.)),
60fText(new TPaveText(0.4,10,0.7,20.))
9e47432c 61{
38986b78 62 // ctor
63 fLineCol->SetLineColor(1);
64 fLineCol->SetLineWidth(2);
65 fLineRow->SetLineColor(1);
66 fLineRow->SetLineWidth(2);
67
68 fTextSM[0]= new TText(20, 12, "SM A0");
69 fTextSM[1]= new TText(20, 38, "SM A1");
70 fTextSM[2]= new TText(64, 12, "SM C0");
a42ceb0e 71 fTextSM[3]= new TText(64, 38, "SM C1");
9e47432c 72}
73
74//__________________________________________________________________
75AliEMCALQAChecker::~AliEMCALQAChecker()
76{
77 /// dtor
38986b78 78 delete [] fTextSM ;
a42ceb0e 79 delete fLineCol ;
80 delete fLineRow ;
81 delete fText ;
9e47432c 82}
83
84//__________________________________________________________________
85AliEMCALQAChecker::AliEMCALQAChecker(const AliEMCALQAChecker& qac) :
86AliQACheckerBase(qac.GetName(), qac.GetTitle()),
38986b78 87fTextSM(new TText*[fknSM]) ,
88fLineCol(static_cast<TLine*>(qac.fLineCol->Clone())) ,
89fLineRow(static_cast<TLine*>(qac.fLineRow->Clone())) ,
a42ceb0e 90fText(new TPaveText(0.4,10,0.7,20.))
9e47432c 91{
38986b78 92 // copy ctor
9e47432c 93 for (Int_t sm = 0 ; sm < fknSM ; sm++){
38986b78 94 fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
9e47432c 95 }
a42ceb0e 96
9e47432c 97}
98//__________________________________________________________________
38986b78 99AliEMCALQAChecker& AliEMCALQAChecker::operator = (const AliEMCALQAChecker &qac)
9e47432c 100{
38986b78 101 fTextSM = new TText*[fknSM] ;
102 fLineCol = static_cast<TLine*>(qac.fLineCol->Clone()) ;
103 fLineRow = static_cast<TLine*>(qac.fLineRow->Clone()) ;
a42ceb0e 104 fText = new TPaveText(0.4,10,0.7,20.) ;
9e47432c 105 for (Int_t sm = 0 ; sm < fknSM ; sm++){
38986b78 106 fTextSM[sm] = static_cast<TText *>(qac.fTextSM[sm]->Clone()) ;
9e47432c 107 }
108 return *this ;
109}
110
111//______________________________________________________________________________
a42ceb0e 112void AliEMCALQAChecker::Check(Double_t * test, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
9e47432c 113{
114 /// Check objects in list
115
116 if ( index == AliQAv1::kRAW )
117 {
a42ceb0e 118 CheckRaws(test, list);
9e47432c 119 printf ("checkers for task %d \n", index) ;
120 }
121
122 if ( index == AliQAv1::kREC)
123 {
a42ceb0e 124 CheckRecPoints(test, list);
9e47432c 125 }
126
127 if ( index == AliQAv1::kESD )
128 {
a42ceb0e 129 CheckESD(test, list);
9e47432c 130 }
131 AliWarning(Form("Checker for task %d not implement for the moment",index));
9e47432c 132}
133
134//______________________________________________________________________________
135TH1*
136AliEMCALQAChecker::GetHisto(TObjArray* list, const char* hname, Int_t specie) const
137{
138 /// Get a given histo from the list
139 TH1* h = static_cast<TH1*>(list->FindObject(Form("%s_%s",AliRecoParam::GetEventSpecieName(specie),hname)));
140 if (!h)
141 {
142 AliError(Form("Did not find expected histo %s",hname));
143 }
144 return h;
145}
146
147//______________________________________________________________________________
148Double_t
149AliEMCALQAChecker::MarkHisto(TH1& histo, Double_t value) const
150{
151 /// Mark histo as originator of some QA error/warning
152
153 if ( value != 1.0 )
154 {
155 histo.SetBit(AliQAv1::GetQABit());
156 }
157
158 return value;
159}
160
161
162//______________________________________________________________________________
a42ceb0e 163void AliEMCALQAChecker::CheckRaws(Double_t * test, TObjArray ** list)
9e47432c 164{
a2655076 165// Check RAW QA histograms
166// We count the times of the response for each tower, the propability for all towers should be the same (average is given value).
167// We skip the first few cycles since the statistics is not enough, the average should be always larger than 1 at least.
168// By calculating the difference between the counts for each tower and the average, we decide whether we should recalculate
169// the average depending the the gaus fitting on the divation distribution.
170// During the recalutation of the average, we count how many towers are used for the calculation.
171// From the fraction of towers used, we decide whether each SM works fine or not
172// From the divation of average, we set the QA flag for the full detetcor as INFO, WARNING, ERROR or FATAL.
6a754398 173
a2655076 174// -- Yaxian Mao, CCNU/CERN/LPSC
38986b78 175
176 //Float_t kThreshold = 80. ;
177 Int_t nTowersPerSM = 24*48; // number of towers in a SuperModule; 24x48
178 Double_t nTot = fknSM * nTowersPerSM ;
179 Double_t rv = 0. ;
a2655076 180 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
a42ceb0e 181 test[specie] = 0.0 ;
a2655076 182 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie))
183 continue ;
184 if (list[specie]->GetEntries() == 0)
a42ceb0e 185 test[specie] = 0. ; // nothing to check
a2655076 186 else {
38986b78 187 TH2F * hdata = (TH2F*)list[specie]->At(k2DRatioAmp) ;
188 TH1F * ratio = (TH1F*)list[specie]->At(kRatioDist) ;
189 if(hdata->GetEntries()==0 || ratio->GetEntries()==0)
190 continue;
191 //adding the lines to distinguish different SMs
192 if ( hdata->GetListOfFunctions()->GetEntries() == 0 ){
193 hdata->GetListOfFunctions()->Add(fLineCol);
194 hdata->GetListOfFunctions()->Add(fLineRow);
195 //Now adding the text to for each SM
196 for(Int_t iSM = 0 ; iSM < fknSM ; iSM++){ //number of SMs loop start
197 hdata->GetListOfFunctions()->Add(fTextSM[iSM]);
198 }
199 }
a42ceb0e 200// if ( ratio->GetListOfFunctions()->GetEntries() == 0 ){
201// ratio->GetListOfFunctions()->Add(fText) ;
202// }
38986b78 203
204 //now check the ratio histogram
205 Double_t binContent = 0. ;
206 Int_t NGoodTower = 0 ;
207 for(Int_t ix = 1; ix <= hdata->GetNbinsX(); ix++) {
208 for(Int_t iy = 1; iy <= hdata->GetNbinsY(); iy++) {
209 binContent = hdata->GetBinContent(ix, iy) ;
210 if (binContent < 1.2 && binContent > 0.8)
211 NGoodTower++ ;
6a754398 212 }
6a754398 213 }
38986b78 214 rv = NGoodTower/nTot ;
a2655076 215
a2655076 216
a42ceb0e 217// if (rv < 0.9) {
218// test[specie] = 0.9 ;
219// // 2 lines text info for quality
220// fText->Clear() ;
221// fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));
222// fText->AddText(Form("EMCAL = NOK, CALL EXPERTS!!!"));
223// }
224// else {
225// test[specie] = 0.1 ;
226// fText->Clear() ;
227// fText->AddText(Form("%2.2f %% towers out of range [0.8, 1.2]", (1-rv)*100));
228// fText->AddText(Form("EMCAL = OK"));
229// }
38986b78 230 }
231 } //finish the checking
9e47432c 232}
233
234//______________________________________________________________________________
235void AliEMCALQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
236{
237 /// intialises QA and QA checker settings
238 AliQAv1::Instance(det) ;
239 Float_t hiValue[AliQAv1::kNBIT] ;
240 Float_t lowValue[AliQAv1::kNBIT] ;
241 lowValue[AliQAv1::kINFO] = 0.0 ;
242 hiValue[AliQAv1::kINFO] = 0.1 ;
9e47432c 243 lowValue[AliQAv1::kWARNING] = 0.1 ;
6a754398 244 hiValue[AliQAv1::kWARNING] = 0.5 ;
9e47432c 245 lowValue[AliQAv1::kERROR] = 0.5 ;
246 hiValue[AliQAv1::kERROR] = 0.8 ;
247 lowValue[AliQAv1::kFATAL] = 0.8 ;
248 hiValue[AliQAv1::kFATAL] = 1.0 ;
249 SetHiLo(&hiValue[0], &lowValue[0]) ;
250}
94594e5d 251