]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSQASPDChecker.cxx
Attemting bug fix, again
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDChecker.cxx
CommitLineData
5dfa9b71 1/**************************************************************************
2 * Copyright(c) 2007-2009, 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
2eb1130f 16/* $Id $ */
5dfa9b71 17
18// *****************************************
19// Checks the quality assurance
20// by comparing with reference data
21// P. Cerello Apr 2008
22// INFN Torino
23
24// --- ROOT system ---
2eb1130f 25#include "TH1.h"
26#include "TString.h"
b377c85c 27#include "TList.h"
5dfa9b71 28
29// --- AliRoot header files ---
30#include "AliITSQASPDChecker.h"
96d29da9 31#include "AliITSQADataMakerRec.h"
c71529b0 32#include "AliLog.h"
5dfa9b71 33
34ClassImp(AliITSQASPDChecker)
5dfa9b71 35//__________________________________________________________________
b377c85c 36AliITSQASPDChecker::AliITSQASPDChecker() :
37 TObject(),
38 fSubDetOffset(0),
39 fStepBitSPD(NULL),
40 fLowSPDValue(NULL),
41 fHighSPDValue(NULL)
42 {
43 for(Int_t i=0; i<6 ; i++) {
44 fDisplayStatus[i] = new TPaveText(0.2,0.1,0.8,0.3,"NDC");
45 fDisplayStatus[i]->SetFillColor(kGreen);
46 fDisplayStatus[i]->AddText("OK");
47 }
48 }
49//__________________________________________________________________
5dfa9b71 50AliITSQASPDChecker& AliITSQASPDChecker::operator = (const AliITSQASPDChecker& qac )
51{
52 // Equal operator.
53 this->~AliITSQASPDChecker();
54 new(this) AliITSQASPDChecker(qac);
55 return *this;
56}
b377c85c 57//__________________________________________________________________
58AliITSQASPDChecker::~AliITSQASPDChecker() {
59if(fStepBitSPD) delete[] fStepBitSPD ;
60if(fLowSPDValue)delete[]fLowSPDValue;
61if(fHighSPDValue) delete[]fHighSPDValue;
62for(Int_t i=0; i<6; i++){
63delete fDisplayStatus[i];
64}
65}
3647765c 66
5dfa9b71 67//__________________________________________________________________
96d29da9 68Double_t AliITSQASPDChecker::Check(AliQAv1::ALITASK_t index, TObjArray * list, const AliDetectorRecoParam * /*recoParam*/)
5dfa9b71 69{
96d29da9 70//
71// General methods for SPD Cheks to be used in RAWS and REC ALITASK_t
72//
c71529b0 73
96d29da9 74 AliDebug(2, Form("AliITSQASPDChecker called with offset: %d\n", fSubDetOffset));
80b9610c 75
2eb1130f 76 Double_t test = 0.0;
77 Int_t count = 0;
96d29da9 78 // Checks for ALITASK_t AliQAv1::kRAW
79 if(index == AliQAv1::kRAW) {
80 return CheckRawData(list);
81 } else {
2eb1130f 82 if (list->GetEntries() == 0) {
83 test = 1.; // nothing to check
5dfa9b71 84 }
85 else {
2eb1130f 86 TIter next(list);
87 TH1 * hdata;
88 count = 0;
5dfa9b71 89 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
90 if (hdata) {
2eb1130f 91 TString histName = hdata->GetName();
92 if (!histName.Contains("_SPD")) continue;
5dfa9b71 93 Double_t rv = 0.;
2eb1130f 94 if (hdata->GetEntries()>0) rv = 1;
954ef57a 95 if (histName.Contains("LayPattern")) {
683601f2 96 if (hdata->GetBinContent(1)) {
954ef57a 97 Double_t ratio=hdata->GetBinContent(2)/hdata->GetBinContent(1);
5379c4a3 98 AliDebug(2, Form("%s: ratio RecPoints lay2 / lay1 = %f", hdata->GetName(), ratio));
683601f2 99 }
100 else
5379c4a3 101 AliDebug(AliQAv1::GetQADebugLevel(), "No RecPoints in lay1");
683601f2 102 }
954ef57a 103 else if(histName.Contains("ModPattern")) {
104 Int_t ndead=0;
105 for(Int_t ibin=0;ibin<hdata->GetNbinsX();ibin++) {
106 if(histName.Contains("SPD1") && ibin<80 && hdata->GetBinContent(ibin+1)>0) ndead++;
107 if(histName.Contains("SPD2") && ibin>79 && hdata->GetBinContent(ibin+1)>0) ndead++;
108 }
5379c4a3 109 AliDebug(2, Form("%s: Entries = %d number of empty modules = %d",
954ef57a 110 hdata->GetName(),(Int_t)hdata->GetEntries(),ndead));
111 }
112 else if(histName.Contains("SizeYvsZ")) {
113 Double_t meanz=hdata->GetMean(1);
114 Double_t meany=hdata->GetMean(2);
115 Double_t rmsz=hdata->GetRMS(1);
116 Double_t rmsy=hdata->GetRMS(2);
5379c4a3 117 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeY mean = %f rms = %f", hdata->GetName(),meany,rmsy));
118 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeZ mean = %f rms = %f", hdata->GetName(),meanz,rmsz));
954ef57a 119 }
f4ed01ae 120 else if(histName.Contains("SPDMultiplicity")) {
5379c4a3 121 AliDebug(2, Form("%s: Events = %d mean = %f rms = %f",
954ef57a 122 hdata->GetName(),(Int_t)hdata->GetEntries(),hdata->GetMean(),hdata->GetRMS()));}
123
96d29da9 124 // else AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv));
2eb1130f 125 count++;
126 test += rv;
5dfa9b71 127 }
954ef57a 128 else {
5dfa9b71 129 AliError("Data type cannot be processed") ;
130 }
5dfa9b71 131 }
954ef57a 132
5dfa9b71 133 if (count != 0) {
96d29da9 134 if (AliITSQADataMakerRec::AreEqual(test,0)) {
5dfa9b71 135 AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
96d29da9 136 test = fHighSPDValue[AliQAv1::kWARNING]; //upper limit value to set kWARNING flag for a task
5dfa9b71 137 }
138 else {
2eb1130f 139 test /= count;
5dfa9b71 140 }
141 }
142 }
96d29da9 143}
5379c4a3 144 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test));
5dfa9b71 145 return test ;
3647765c 146
954ef57a 147}
96d29da9 148//__________________________________________________________________
149Double_t AliITSQASPDChecker::CheckRawData(const TObjArray * list) {
150//
151// Checks on the raw data histograms [ preliminary version ]
152// The output of this method is the fraction of SPD histograms which are processed by the checker.
153// The methods returns fHighSPDValue[AliQAv1::kFATAL] in case of data format errors or MEB errors
154//
155// A. Mastroserio
156
157Double_t test =0;
158
159// basic checks on input data
160if(!list) {
161 AliError("NO histogram list for RAWS");
162 return test;
163 }
164
165 if(list->GetEntries() == 0) {
166 AliWarning("No histograms in RAW list \n");
167 return test;
168 }
169
170// loop over the raw data histograms
171TIter next(list);
172TH1 * hdata;
173Double_t totalHistos = 0;
174Double_t goodHistos = 0; // number of histograms which passed the checks
175Double_t response =0;
176Bool_t fatalProblem = kFALSE;
177
178while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
b377c85c 179 if (hdata) {
96d29da9 180 TString histName = hdata->GetName();
181 if(!histName.Contains("SPD")) continue;
182 totalHistos++;
183 // data format error
184 if(histName.Contains("SPDErrorsAll")){
b377c85c 185 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(fDisplayStatus[0]);
96d29da9 186 if(hdata->Integral(0,hdata->GetNbinsX())>0){
b377c85c 187 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
188 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
189 if(funcName.Contains("TPaveText")){
190 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
191 Bool_t isHighMult = kFALSE;
192 for(Int_t ieq=0; ieq<20; ieq++){
193 if(hdata->GetBinContent(ieq+1,17+1)>0 && hdata->GetBinContent(ieq+1,20+1)>0) isHighMult = kTRUE;
194 }
195 if(isHighMult) {
196 p->Clear();
197 p->SetFillColor(kOrange);
198 p->AddText("High occupancy in a chip detected (-> errors type 17,20 and 0 are present). ");
199 p->AddText("ONLY IF OTHER error types are present CALL the expert");
200 }
201 else {
202 p->Clear();
203 p->SetFillColor(kRed);
204 p->AddText("Data Format NOT OK. Please call the expert!");
205 }
206
207 }
208 }
96d29da9 209 response = fHighSPDValue[AliQAv1::kFATAL];
210 fatalProblem=kTRUE;
211 break;
b377c85c 212 } else {
213 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
214 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
215 if(funcName.Contains("TPaveText")){
216 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
217 p->Clear();
218 p->SetFillColor(kGreen);
219 p->AddText("OK");
220
221 }
222 }
223 }
96d29da9 224 }
225 // MEB error
b377c85c 226 else if(histName.Contains("MEB")){
227 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(fDisplayStatus[1]);
96d29da9 228 if(hdata->GetEntries()>0){
b377c85c 229 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
230 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
231 if(funcName.Contains("TPaveText")){
232 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
233 p->Clear();
234 p->SetFillColor(kRed);
235 p->AddText("MEB problem could be present. Please check if SPD is in READY state.");
236 p->AddText("If SPD is in -READY- state, please notify it to the expert.");
237 }
238 }
239
240
96d29da9 241 response = fHighSPDValue[AliQAv1::kFATAL];
242 fatalProblem=kTRUE;
243 break;
b377c85c 244 } else {
245 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
246 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
247 if(funcName.Contains("TPaveText")){
248 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
249 p->Clear();
250 p->SetFillColor(kGreen);
251 p->AddText("OK");
252
253 }
96d29da9 254 }
b377c85c 255 }
96d29da9 256 }
b377c85c 257 goodHistos++;
258 }
259 }
96d29da9 260 if(!fatalProblem) response = goodHistos/totalHistos;
261 // printf("n histos %f - good ones %f ----> ratio %f , fatal response %i\n",totalHistos,goodHistos,goodHistos/totalHistos,(Int_t)fatalProblem);
262 return response;
263}
3647765c 264
265//__________________________________________________________________
266void AliITSQASPDChecker::SetTaskOffset(Int_t TaskOffset)
267{
96d29da9 268// Offset for SPD within ITS QA
3647765c 269 fSubDetOffset = TaskOffset;
270}
80b9610c 271
272//__________________________________________________________________
96d29da9 273void AliITSQASPDChecker::SetStepBit(const Double_t *steprange)
80b9610c 274{
96d29da9 275// Step bit for SPD within ITS QA
80b9610c 276 fStepBitSPD = new Double_t[AliQAv1::kNBIT];
277 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
278 {
279 fStepBitSPD[bit]=steprange[bit];
280 }
281}
282
283
284//__________________________________________________________________
96d29da9 285void AliITSQASPDChecker::SetSPDLimits(const Float_t *lowvalue, const Float_t * highvalue)
80b9610c 286{
96d29da9 287// SPD limints for QA bit within general ITS QA
80b9610c 288 fLowSPDValue = new Float_t[AliQAv1::kNBIT];
289 fHighSPDValue= new Float_t[AliQAv1::kNBIT];
290
291 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
292 {
293 fLowSPDValue[bit]=lowvalue[bit];
294 fHighSPDValue[bit]= highvalue[bit];
295 }
296
297}
96d29da9 298