1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // *****************************************
19 // Checks the quality assurance
20 // by comparing with reference data
21 // P. Cerello Apr 2008
24 // --- ROOT system ---
32 #include "TPaletteAxis.h"
34 // --- AliRoot header files ---
35 #include"AliQACheckerBase.h"
36 #include "AliITSQASPDChecker.h"
37 #include "AliITSQADataMakerRec.h"
40 ClassImp(AliITSQASPDChecker)
41 //__________________________________________________________________
42 AliITSQASPDChecker::AliITSQASPDChecker() :
52 //__________________________________________________________________
53 AliITSQASPDChecker& AliITSQASPDChecker::operator = (const AliITSQASPDChecker& qac )
56 this->~AliITSQASPDChecker();
57 new(this) AliITSQASPDChecker(qac);
60 //__________________________________________________________________
61 AliITSQASPDChecker::~AliITSQASPDChecker() {
63 if(fStepBitSPD) delete[] fStepBitSPD ;
64 if(fLowSPDValue)delete[]fLowSPDValue;
65 if(fHighSPDValue) delete[]fHighSPDValue;
66 if(fImage) delete[]fImage;
69 //__________________________________________________________________
70 Double_t AliITSQASPDChecker::Check(AliQAv1::ALITASK_t index, TObjArray * list, const AliDetectorRecoParam * /*recoParam*/)
73 // General methods for SPD Cheks to be used in RAWS and REC ALITASK_t
76 AliDebug(2, Form("AliITSQASPDChecker called with offset: %d\n", fSubDetOffset));
80 // Checks for ALITASK_t AliQAv1::kRAW
81 if(index == AliQAv1::kRAW) {
82 return CheckRawData(list);
84 if (list->GetEntries() == 0) {
85 test = 1.; // nothing to check
91 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
93 TString histName = hdata->GetName();
94 if (!histName.Contains("_SPD")) continue;
96 if (hdata->GetEntries()>0) rv = 1;
97 if (histName.Contains("LayPattern")) {
98 if (hdata->GetBinContent(1)) {
99 Double_t ratio=hdata->GetBinContent(2)/hdata->GetBinContent(1);
100 AliDebug(2, Form("%s: ratio RecPoints lay2 / lay1 = %f", hdata->GetName(), ratio));
103 AliDebug(AliQAv1::GetQADebugLevel(), "No RecPoints in lay1");
105 else if(histName.Contains("ModPattern")) {
107 for(Int_t ibin=0;ibin<hdata->GetNbinsX();ibin++) {
108 if(histName.Contains("SPD1") && ibin<80 && hdata->GetBinContent(ibin+1)>0) ndead++;
109 if(histName.Contains("SPD2") && ibin>79 && hdata->GetBinContent(ibin+1)>0) ndead++;
111 AliDebug(2, Form("%s: Entries = %d number of empty modules = %d",
112 hdata->GetName(),(Int_t)hdata->GetEntries(),ndead));
114 else if(histName.Contains("SizeYvsZ")) {
115 Double_t meanz=hdata->GetMean(1);
116 Double_t meany=hdata->GetMean(2);
117 Double_t rmsz=hdata->GetRMS(1);
118 Double_t rmsy=hdata->GetRMS(2);
119 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeY mean = %f rms = %f", hdata->GetName(),meany,rmsy));
120 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeZ mean = %f rms = %f", hdata->GetName(),meanz,rmsz));
122 else if(histName.Contains("SPDMultiplicity")) {
123 AliDebug(2, Form("%s: Events = %d mean = %f rms = %f",
124 hdata->GetName(),(Int_t)hdata->GetEntries(),hdata->GetMean(),hdata->GetRMS()));}
126 // else AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv));
131 AliError("Data type cannot be processed") ;
136 if (AliITSQADataMakerRec::AreEqual(test,0)) {
137 AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
138 test = fHighSPDValue[AliQAv1::kWARNING]; //upper limit value to set kWARNING flag for a task
146 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test));
150 //__________________________________________________________________
151 Double_t AliITSQASPDChecker::CheckRawData(const TObjArray * list) {
153 // Checks on the raw data histograms [ preliminary version ]
154 // The output of this method is the fraction of SPD histograms which are processed by the checker.
155 // The methods returns fHighSPDValue[AliQAv1::kFATAL] in case of data format errors or MEB errors
161 // basic checks on input data
163 AliError("NO histogram list for RAWS");
167 if(list->GetEntries() == 0) {
168 AliWarning("No histograms in RAW list \n");
172 // loop over the raw data histograms
175 Double_t totalHistos = 0;
176 Double_t goodHistos = 0; // number of histograms which passed the checks
177 Double_t response =0;
178 Bool_t fatalProblem = kFALSE;
180 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
182 TString histName = hdata->GetName();
183 if(!histName.Contains("SPD")) continue;
186 if(histName.Contains("SPDErrorsAll")){
187 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(new TPaveText(0.2,0.23,0.7,0.5,"NDC"));
189 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
190 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
191 if(funcName.Contains("TPaveText")){
192 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
195 if(hdata->Integral(0,hdata->GetNbinsX())>0){
196 Bool_t isHighMult = kFALSE;
197 Bool_t isDataCorrupted=kFALSE;
198 for(Int_t ieq=0; ieq<20; ieq++){
199 if(hdata->GetBinContent(ieq+1,17+1)>0 && hdata->GetBinContent(ieq+1,20+1)>0) isHighMult = kTRUE;
200 for(Int_t iErr=1; iErr<20; iErr++){
201 if(iErr==20 || iErr==17) continue;
202 if(hdata->GetBinContent(ieq+1,iErr+1)>0) isDataCorrupted=kTRUE;
205 if(isHighMult && !isDataCorrupted) {
206 p->SetFillColor(kOrange);
207 p->AddText("High occupancy in a chip detected (-> errors type 17,20 and 0 are present). ");
208 p->AddText("ONLY IF OTHER error types are present CALL the expert");
209 response = fHighSPDValue[AliQAv1::kWARNING];
210 } else if(isDataCorrupted) {
211 p->SetFillColor(kRed);
212 p->AddText("Data Format NOT OK. Please call the expert!");
213 response = fHighSPDValue[AliQAv1::kFATAL];
220 p->SetFillColor(kGreen);
225 } // data format error
228 else if(histName.Contains("MEB")){
229 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(new TPaveText(0.2,0.23,0.7,0.5,"NDC"));
231 for(Int_t i=0; i<hdata->GetListOfFunctions()->GetEntries(); i++){
232 TString funcName = hdata->GetListOfFunctions()->At(i)->ClassName();
233 if(funcName.Contains("TPaveText")){
234 TPaveText *p = (TPaveText*)hdata->GetListOfFunctions()->At(i);
237 if(hdata->GetEntries()>0){
238 p->SetFillColor(kRed);
239 p->AddText("MEB problem could be present. Please check if SPD is in READY state.");
240 p->AddText("If SPD is in -READY- state, please notify it to the expert.");
241 response = fHighSPDValue[AliQAv1::kFATAL];
246 p->SetFillColor(kGreen);
256 if(!fatalProblem) response = goodHistos/totalHistos;
257 // printf("n histos %f - good ones %f ----> ratio %f , fatal response %i\n",totalHistos,goodHistos,goodHistos/totalHistos,(Int_t)fatalProblem);
261 //__________________________________________________________________
262 void AliITSQASPDChecker::SetTaskOffset(Int_t TaskOffset)
264 // Offset for SPD within ITS QA
265 fSubDetOffset = TaskOffset;
268 //__________________________________________________________________
269 void AliITSQASPDChecker::SetStepBit(const Double_t *steprange)
271 // Step bit for SPD within ITS QA
272 fStepBitSPD = new Double_t[AliQAv1::kNBIT];
273 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
275 fStepBitSPD[bit]=steprange[bit];
280 //__________________________________________________________________
281 void AliITSQASPDChecker::SetSPDLimits(const Float_t *lowvalue, const Float_t * highvalue)
283 // SPD limints for QA bit within general ITS QA
284 fLowSPDValue = new Float_t[AliQAv1::kNBIT];
285 fHighSPDValue= new Float_t[AliQAv1::kNBIT];
287 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
289 fLowSPDValue[bit]=lowvalue[bit];
290 fHighSPDValue[bit]= highvalue[bit];
294 //__________________________________________________________________
295 Bool_t AliITSQASPDChecker::MakeSPDImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode)
297 //create the image for raws and recpoints. In the other case, the default methodof CheckerBase class will be used
301 fImage=(TCanvas**)AliQAChecker::Instance()->GetDetQAChecker(0)->GetImage();
305 case AliQAv1::kRAWS:{
306 val = MakeSPDRawsImage(list, task,mode);
309 case AliQAv1::kRECPOINTS:;
310 case AliQAv1::kHITS:;
311 case AliQAv1::kESDS:;
312 case AliQAv1::kDIGITS:;
313 case AliQAv1::kDIGITSR:;
314 case AliQAv1::kSDIGITS:;
315 case AliQAv1::kTRACKSEGMENTS:;
316 case AliQAv1::kRECPARTICLES:;
319 //AliQAChecker::Instance()->GetDetQAChecker(0)->MakeImage(list,task,mode);
323 case AliQAv1::kNULLTASKINDEX:; case AliQAv1::kNTASKINDEX:
324 {AliWarning(Form("No histograms for these tasks ( %s ) \n", AliQAv1::GetTaskName(task).Data())); val = kFALSE;}
329 //_______________________________________________________________________
330 Bool_t AliITSQASPDChecker::MakeSPDRawsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode )
333 // create layout of the histograms used in the DQM
336 // some style settings
337 gStyle->SetOptStat(10);
338 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
339 //printf("-------------------------> %i \n", esIndex);
340 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0)
341 {printf ("Nothing for %s \n", AliRecoParam::GetEventSpecieName(esIndex)); continue;}
343 const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ;
344 if ( !fImage[esIndex] ) {
345 fImage[esIndex] = new TCanvas(title, title,6000,3200) ;
348 fImage[esIndex]->Clear() ;
349 fImage[esIndex]->SetTitle(title) ;
350 fImage[esIndex]->cd();
352 TPaveText someText(0.015, 0.015, 0.98, 0.98);
353 someText.AddText(title);
355 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;
356 fImage[esIndex]->Clear() ;
360 fImage[esIndex]->Divide(nx, ny) ;
364 fImage[esIndex]->cd(npad);
365 fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
367 TIter next(list[esIndex]);
369 while ( (hist=static_cast<TH1*>(next())) ) {
370 //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
371 if(!hist->TestBit(AliQAv1::GetImageBit())) continue;
372 TString name(hist->GetName());
373 if(name.Contains("SPDErrorsAll")) {
374 fImage[esIndex]->cd(1) ;
375 gPad->SetBorderMode(0) ;
376 gPad->SetRightMargin(0.05);
377 gPad->SetLeftMargin(0.1);
380 hist->SetOption("text") ;
383 if(name.Contains("MEB")) {
384 fImage[esIndex]->cd(2) ;
385 gPad->SetBorderMode(0) ;
388 gPad->SetRightMargin(0.05);
389 gPad->SetLeftMargin(0.15);
390 gPad->SetBottomMargin(0.1);
391 hist->SetOption("text") ;
394 if(name.Contains("SPDFastOrCorrelation")){
395 fImage[esIndex]->cd(3) ;
396 gPad->SetBorderMode(0) ;
397 hist->SetOption("") ;
401 if(name.Contains("SPDHitMapStaveChipInner")){
402 fImage[esIndex]->cd(4) ;
403 gPad->SetBorderMode(0) ;
404 gPad->SetRightMargin(0.25);
407 hist->SetObjectStat(0);
408 hist->SetOption("colz") ;
411 if(name.Contains("SPDHitMapStaveChipOuter")){
412 fImage[esIndex]->cd(5) ;
413 gPad->SetBorderMode(0) ;
414 gPad->SetRightMargin(0.25);
417 hist->SetObjectStat(0);
418 hist->SetOption("colz") ;
421 if(name.Contains("SPDFastOrMapStaveChip")){
422 fImage[esIndex]->cd(6) ;
423 gPad->SetBorderMode(0) ;
424 gPad->SetRightMargin(0.1);
425 gPad->SetLeftMargin(0.15);
426 gPad->SetBottomMargin(0.15);
427 gPad->SetTopMargin(-0.2);
430 hist->SetObjectStat(0);
431 hist->SetOption("colz") ;
432 hist->DrawCopy("colz");
433 TH2F *h2 = (TH2F*)(gPad->GetListOfPrimitives()->At(0));
434 for(Int_t i=0; i<h2->GetListOfFunctions()->GetEntries(); i++){
435 TString cname = h2->GetListOfFunctions()->At(i)->ClassName();
436 if(cname.Contains("TPaletteAxis")){
437 TPaletteAxis *palette = (TPaletteAxis*)(h2->GetListOfFunctions()->At(i));
438 if(palette) palette->SetLabelSize(0.02);
441 hist->DrawCopy("colz");
448 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;
449 //fImage[esIndex]->SaveAs("image.png");