]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSQASPDChecker.cxx
Reverting the previous mods as they cause a segmentation violation
[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"
8db5c9f9 28#include "TCanvas.h"
5dfa9b71 29
30// --- AliRoot header files ---
31#include "AliITSQASPDChecker.h"
96d29da9 32#include "AliITSQADataMakerRec.h"
c71529b0 33#include "AliLog.h"
5dfa9b71 34
35ClassImp(AliITSQASPDChecker)
5dfa9b71 36//__________________________________________________________________
b377c85c 37AliITSQASPDChecker::AliITSQASPDChecker() :
38 TObject(),
39 fSubDetOffset(0),
40 fStepBitSPD(NULL),
41 fLowSPDValue(NULL),
8db5c9f9 42 fHighSPDValue(NULL),
43 fImage(NULL)
b377c85c 44 {
45 for(Int_t i=0; i<6 ; i++) {
8db5c9f9 46 fDisplayStatus[i] = new TPaveText(0.2,0.23,0.7,0.5,"NDC");
b377c85c 47 fDisplayStatus[i]->SetFillColor(kGreen);
48 fDisplayStatus[i]->AddText("OK");
49 }
50 }
51//__________________________________________________________________
5dfa9b71 52AliITSQASPDChecker& AliITSQASPDChecker::operator = (const AliITSQASPDChecker& qac )
53{
54 // Equal operator.
55 this->~AliITSQASPDChecker();
56 new(this) AliITSQASPDChecker(qac);
57 return *this;
58}
b377c85c 59//__________________________________________________________________
60AliITSQASPDChecker::~AliITSQASPDChecker() {
61if(fStepBitSPD) delete[] fStepBitSPD ;
62if(fLowSPDValue)delete[]fLowSPDValue;
63if(fHighSPDValue) delete[]fHighSPDValue;
8db5c9f9 64if(fImage) delete[]fImage;
b377c85c 65for(Int_t i=0; i<6; i++){
66delete fDisplayStatus[i];
67}
68}
3647765c 69
5dfa9b71 70//__________________________________________________________________
96d29da9 71Double_t AliITSQASPDChecker::Check(AliQAv1::ALITASK_t index, TObjArray * list, const AliDetectorRecoParam * /*recoParam*/)
5dfa9b71 72{
96d29da9 73//
74// General methods for SPD Cheks to be used in RAWS and REC ALITASK_t
75//
c71529b0 76
96d29da9 77 AliDebug(2, Form("AliITSQASPDChecker called with offset: %d\n", fSubDetOffset));
80b9610c 78
2eb1130f 79 Double_t test = 0.0;
80 Int_t count = 0;
96d29da9 81 // Checks for ALITASK_t AliQAv1::kRAW
82 if(index == AliQAv1::kRAW) {
83 return CheckRawData(list);
84 } else {
2eb1130f 85 if (list->GetEntries() == 0) {
86 test = 1.; // nothing to check
5dfa9b71 87 }
88 else {
2eb1130f 89 TIter next(list);
90 TH1 * hdata;
91 count = 0;
5dfa9b71 92 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
93 if (hdata) {
2eb1130f 94 TString histName = hdata->GetName();
95 if (!histName.Contains("_SPD")) continue;
5dfa9b71 96 Double_t rv = 0.;
2eb1130f 97 if (hdata->GetEntries()>0) rv = 1;
954ef57a 98 if (histName.Contains("LayPattern")) {
683601f2 99 if (hdata->GetBinContent(1)) {
954ef57a 100 Double_t ratio=hdata->GetBinContent(2)/hdata->GetBinContent(1);
5379c4a3 101 AliDebug(2, Form("%s: ratio RecPoints lay2 / lay1 = %f", hdata->GetName(), ratio));
683601f2 102 }
103 else
5379c4a3 104 AliDebug(AliQAv1::GetQADebugLevel(), "No RecPoints in lay1");
683601f2 105 }
954ef57a 106 else if(histName.Contains("ModPattern")) {
107 Int_t ndead=0;
108 for(Int_t ibin=0;ibin<hdata->GetNbinsX();ibin++) {
109 if(histName.Contains("SPD1") && ibin<80 && hdata->GetBinContent(ibin+1)>0) ndead++;
110 if(histName.Contains("SPD2") && ibin>79 && hdata->GetBinContent(ibin+1)>0) ndead++;
111 }
5379c4a3 112 AliDebug(2, Form("%s: Entries = %d number of empty modules = %d",
954ef57a 113 hdata->GetName(),(Int_t)hdata->GetEntries(),ndead));
114 }
115 else if(histName.Contains("SizeYvsZ")) {
116 Double_t meanz=hdata->GetMean(1);
117 Double_t meany=hdata->GetMean(2);
118 Double_t rmsz=hdata->GetRMS(1);
119 Double_t rmsy=hdata->GetRMS(2);
5379c4a3 120 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeY mean = %f rms = %f", hdata->GetName(),meany,rmsy));
121 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeZ mean = %f rms = %f", hdata->GetName(),meanz,rmsz));
954ef57a 122 }
f4ed01ae 123 else if(histName.Contains("SPDMultiplicity")) {
5379c4a3 124 AliDebug(2, Form("%s: Events = %d mean = %f rms = %f",
954ef57a 125 hdata->GetName(),(Int_t)hdata->GetEntries(),hdata->GetMean(),hdata->GetRMS()));}
126
96d29da9 127 // else AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv));
2eb1130f 128 count++;
129 test += rv;
5dfa9b71 130 }
954ef57a 131 else {
5dfa9b71 132 AliError("Data type cannot be processed") ;
133 }
5dfa9b71 134 }
954ef57a 135
5dfa9b71 136 if (count != 0) {
96d29da9 137 if (AliITSQADataMakerRec::AreEqual(test,0)) {
5dfa9b71 138 AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
96d29da9 139 test = fHighSPDValue[AliQAv1::kWARNING]; //upper limit value to set kWARNING flag for a task
5dfa9b71 140 }
141 else {
2eb1130f 142 test /= count;
5dfa9b71 143 }
144 }
145 }
96d29da9 146}
5379c4a3 147 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test));
5dfa9b71 148 return test ;
3647765c 149
954ef57a 150}
96d29da9 151//__________________________________________________________________
152Double_t AliITSQASPDChecker::CheckRawData(const TObjArray * list) {
153//
154// Checks on the raw data histograms [ preliminary version ]
155// The output of this method is the fraction of SPD histograms which are processed by the checker.
156// The methods returns fHighSPDValue[AliQAv1::kFATAL] in case of data format errors or MEB errors
157//
158// A. Mastroserio
159
160Double_t test =0;
161
162// basic checks on input data
163if(!list) {
164 AliError("NO histogram list for RAWS");
165 return test;
166 }
167
168 if(list->GetEntries() == 0) {
169 AliWarning("No histograms in RAW list \n");
170 return test;
171 }
172
173// loop over the raw data histograms
174TIter next(list);
175TH1 * hdata;
176Double_t totalHistos = 0;
177Double_t goodHistos = 0; // number of histograms which passed the checks
178Double_t response =0;
179Bool_t fatalProblem = kFALSE;
180
181while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
b377c85c 182 if (hdata) {
96d29da9 183 TString histName = hdata->GetName();
184 if(!histName.Contains("SPD")) continue;
185 totalHistos++;
186 // data format error
187 if(histName.Contains("SPDErrorsAll")){
b377c85c 188 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(fDisplayStatus[0]);
96d29da9 189 if(hdata->Integral(0,hdata->GetNbinsX())>0){
b377c85c 190 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
191 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
192 if(funcName.Contains("TPaveText")){
193 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
194 Bool_t isHighMult = kFALSE;
195 for(Int_t ieq=0; ieq<20; ieq++){
196 if(hdata->GetBinContent(ieq+1,17+1)>0 && hdata->GetBinContent(ieq+1,20+1)>0) isHighMult = kTRUE;
197 }
198 if(isHighMult) {
199 p->Clear();
200 p->SetFillColor(kOrange);
201 p->AddText("High occupancy in a chip detected (-> errors type 17,20 and 0 are present). ");
202 p->AddText("ONLY IF OTHER error types are present CALL the expert");
203 }
204 else {
205 p->Clear();
206 p->SetFillColor(kRed);
207 p->AddText("Data Format NOT OK. Please call the expert!");
208 }
209
210 }
211 }
96d29da9 212 response = fHighSPDValue[AliQAv1::kFATAL];
213 fatalProblem=kTRUE;
214 break;
b377c85c 215 } else {
216 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
217 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
218 if(funcName.Contains("TPaveText")){
219 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
220 p->Clear();
221 p->SetFillColor(kGreen);
222 p->AddText("OK");
223
224 }
225 }
226 }
96d29da9 227 }
228 // MEB error
b377c85c 229 else if(histName.Contains("MEB")){
230 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(fDisplayStatus[1]);
96d29da9 231 if(hdata->GetEntries()>0){
b377c85c 232 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
233 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
234 if(funcName.Contains("TPaveText")){
235 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
236 p->Clear();
237 p->SetFillColor(kRed);
238 p->AddText("MEB problem could be present. Please check if SPD is in READY state.");
239 p->AddText("If SPD is in -READY- state, please notify it to the expert.");
240 }
241 }
242
243
96d29da9 244 response = fHighSPDValue[AliQAv1::kFATAL];
245 fatalProblem=kTRUE;
246 break;
b377c85c 247 } else {
248 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
249 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
250 if(funcName.Contains("TPaveText")){
251 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
252 p->Clear();
253 p->SetFillColor(kGreen);
254 p->AddText("OK");
255
256 }
96d29da9 257 }
b377c85c 258 }
96d29da9 259 }
b377c85c 260 goodHistos++;
261 }
262 }
96d29da9 263 if(!fatalProblem) response = goodHistos/totalHistos;
264 // printf("n histos %f - good ones %f ----> ratio %f , fatal response %i\n",totalHistos,goodHistos,goodHistos/totalHistos,(Int_t)fatalProblem);
265 return response;
266}
3647765c 267
268//__________________________________________________________________
269void AliITSQASPDChecker::SetTaskOffset(Int_t TaskOffset)
270{
96d29da9 271// Offset for SPD within ITS QA
3647765c 272 fSubDetOffset = TaskOffset;
273}
80b9610c 274
275//__________________________________________________________________
96d29da9 276void AliITSQASPDChecker::SetStepBit(const Double_t *steprange)
80b9610c 277{
96d29da9 278// Step bit for SPD within ITS QA
80b9610c 279 fStepBitSPD = new Double_t[AliQAv1::kNBIT];
280 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
281 {
282 fStepBitSPD[bit]=steprange[bit];
283 }
284}
285
286
287//__________________________________________________________________
96d29da9 288void AliITSQASPDChecker::SetSPDLimits(const Float_t *lowvalue, const Float_t * highvalue)
80b9610c 289{
96d29da9 290// SPD limints for QA bit within general ITS QA
80b9610c 291 fLowSPDValue = new Float_t[AliQAv1::kNBIT];
292 fHighSPDValue= new Float_t[AliQAv1::kNBIT];
293
294 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
295 {
296 fLowSPDValue[bit]=lowvalue[bit];
297 fHighSPDValue[bit]= highvalue[bit];
298 }
299
300}
8db5c9f9 301//__________________________________________________________________
302Bool_t AliITSQASPDChecker::MakeSPDImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode)
303{
304 Bool_t val=kFALSE;
96d29da9 305
8db5c9f9 306 fImage=(TCanvas**)AliQAChecker::Instance()->GetDetQAChecker(0)->GetImage();
307 //create the image for raws and recpoints. In the other case, the default methodof CheckerBase class will be used
308 switch(task)
309 {
310 case AliQAv1::kRAWS:{
311 val = MakeSPDRawsImage(list, task,mode);
312 }
313 break;
314 case AliQAv1::kRECPOINTS:;
315 case AliQAv1::kHITS:;
316 case AliQAv1::kESDS:;
317 case AliQAv1::kDIGITS:;
318 case AliQAv1::kDIGITSR:;
319 case AliQAv1::kSDIGITS:;
320 case AliQAv1::kTRACKSEGMENTS:;
321 case AliQAv1::kRECPARTICLES:;
322 default:
323 {
324 //AliQAChecker::Instance()->GetDetQAChecker(0)->MakeImage(list,task,mode);
325 val = kFALSE;
326 }
327 break;
328 case AliQAv1::kNULLTASKINDEX:; case AliQAv1::kNTASKINDEX:
329 {AliWarning(Form("No histograms for these tasks ( %s ) \n", AliQAv1::GetTaskName(task).Data())); val = kFALSE;}
330 break;
331 }
332 return val;
333}
334//_______________________________________________________________________
335Bool_t AliITSQASPDChecker::MakeSPDRawsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode )
336{
337 //
338 // create layout of the histograms used in the DQM
339 //
340
341
342 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
343 //printf("-------------------------> %i \n", esIndex);
344 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0)
345 {printf ("Nothing for %s \n", AliRecoParam::GetEventSpecieName(esIndex)); continue;}
346 else{
347 const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ;
348 if ( !fImage[esIndex] ) {
349 fImage[esIndex] = new TCanvas(title, title,1280,980) ;
350 }
351
352 fImage[esIndex]->Clear() ;
353 fImage[esIndex]->SetTitle(title) ;
354 fImage[esIndex]->cd();
355
356 TPaveText someText(0.015, 0.015, 0.98, 0.98);
357 someText.AddText(title);
358 someText.Draw();
359 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;
360 fImage[esIndex]->Clear() ;
361 Int_t nx =3;
362 Int_t ny =2;
363
364 fImage[esIndex]->Divide(nx, ny) ;
365
366 TH1* hist = NULL ;
367 Int_t npad = 1 ;
368 fImage[esIndex]->cd(npad);
369 fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
370
371 TIter next(list[esIndex]);
372
373 while ( (hist=static_cast<TH1*>(next())) ) {
374 //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
375 if(!hist->TestBit(AliQAv1::GetImageBit())) continue;
376 TString name(hist->GetName());
377 if(name.Contains("SPDErrorsAll")) {
378 fImage[esIndex]->cd(1) ;
379 gPad->SetBorderMode(0) ;
380 gPad->SetRightMargin(0.25);
381 hist->SetStats(0);
382 hist->SetOption("colz") ;
383 hist->DrawCopy();
384 }
385 if(name.Contains("MEB")) {
386 fImage[esIndex]->cd(2) ;
387 gPad->SetBorderMode(0) ;
388 gPad->SetBottomMargin(0.25);
389 hist->SetOption("colz") ;
390 hist->DrawCopy();
391 }
392 if(name.Contains("SPDFastOrCorrelation")){
393 fImage[esIndex]->cd(3) ;
394 gPad->SetBorderMode(0) ;
395 hist->SetOption("") ;
396 hist->DrawCopy();
397 }
398
399 if(name.Contains("SPDHitMapStaveChipInner")){
400 fImage[esIndex]->cd(4) ;
401 gPad->SetBorderMode(0) ;
402 gPad->SetRightMargin(0.25);
403 hist->SetOption("colz") ;
404 hist->DrawCopy();
405 }
406 if(name.Contains("SPDHitMapStaveChipOuter")){
407 fImage[esIndex]->cd(5) ;
408 gPad->SetBorderMode(0) ;
409 gPad->SetRightMargin(0.25);
410 hist->SetOption("colz") ;
411 hist->DrawCopy();
412 }
413 if(name.Contains("SPDFastOrMapStaveChip")){
414 fImage[esIndex]->cd(6) ;
415 gPad->SetBorderMode(0) ;
416 gPad->SetRightMargin(0.25);
417 gPad->SetBottomMargin(0.25);
418 hist->SetOption("colz") ;
419 hist->DrawCopy();
420 }
421
422
423 }
424
425 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;
426 }
427 }
428 return kTRUE;
429}