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 ---
30 // --- AliRoot header files ---
31 #include "AliITSQASPDChecker.h"
32 #include "AliITSQADataMakerRec.h"
35 ClassImp(AliITSQASPDChecker)
36 //__________________________________________________________________
37 AliITSQASPDChecker::AliITSQASPDChecker() :
45 for(Int_t i=0; i<6 ; i++) {
46 fDisplayStatus[i] = new TPaveText(0.2,0.23,0.7,0.5,"NDC");
47 fDisplayStatus[i]->SetFillColor(kGreen);
48 fDisplayStatus[i]->AddText("OK");
51 //__________________________________________________________________
52 AliITSQASPDChecker& AliITSQASPDChecker::operator = (const AliITSQASPDChecker& qac )
55 this->~AliITSQASPDChecker();
56 new(this) AliITSQASPDChecker(qac);
59 //__________________________________________________________________
60 AliITSQASPDChecker::~AliITSQASPDChecker() {
61 if(fStepBitSPD) delete[] fStepBitSPD ;
62 if(fLowSPDValue)delete[]fLowSPDValue;
63 if(fHighSPDValue) delete[]fHighSPDValue;
64 if(fImage) delete[]fImage;
65 for(Int_t i=0; i<6; i++){
66 delete fDisplayStatus[i];
70 //__________________________________________________________________
71 Double_t AliITSQASPDChecker::Check(AliQAv1::ALITASK_t index, TObjArray * list, const AliDetectorRecoParam * /*recoParam*/)
74 // General methods for SPD Cheks to be used in RAWS and REC ALITASK_t
77 AliDebug(2, Form("AliITSQASPDChecker called with offset: %d\n", fSubDetOffset));
81 // Checks for ALITASK_t AliQAv1::kRAW
82 if(index == AliQAv1::kRAW) {
83 return CheckRawData(list);
85 if (list->GetEntries() == 0) {
86 test = 1.; // nothing to check
92 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
94 TString histName = hdata->GetName();
95 if (!histName.Contains("_SPD")) continue;
97 if (hdata->GetEntries()>0) rv = 1;
98 if (histName.Contains("LayPattern")) {
99 if (hdata->GetBinContent(1)) {
100 Double_t ratio=hdata->GetBinContent(2)/hdata->GetBinContent(1);
101 AliDebug(2, Form("%s: ratio RecPoints lay2 / lay1 = %f", hdata->GetName(), ratio));
104 AliDebug(AliQAv1::GetQADebugLevel(), "No RecPoints in lay1");
106 else if(histName.Contains("ModPattern")) {
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++;
112 AliDebug(2, Form("%s: Entries = %d number of empty modules = %d",
113 hdata->GetName(),(Int_t)hdata->GetEntries(),ndead));
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);
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));
123 else if(histName.Contains("SPDMultiplicity")) {
124 AliDebug(2, Form("%s: Events = %d mean = %f rms = %f",
125 hdata->GetName(),(Int_t)hdata->GetEntries(),hdata->GetMean(),hdata->GetRMS()));}
127 // else AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv));
132 AliError("Data type cannot be processed") ;
137 if (AliITSQADataMakerRec::AreEqual(test,0)) {
138 AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
139 test = fHighSPDValue[AliQAv1::kWARNING]; //upper limit value to set kWARNING flag for a task
147 AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test));
151 //__________________________________________________________________
152 Double_t AliITSQASPDChecker::CheckRawData(const TObjArray * list) {
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
162 // basic checks on input data
164 AliError("NO histogram list for RAWS");
168 if(list->GetEntries() == 0) {
169 AliWarning("No histograms in RAW list \n");
173 // loop over the raw data histograms
176 Double_t totalHistos = 0;
177 Double_t goodHistos = 0; // number of histograms which passed the checks
178 Double_t response =0;
179 Bool_t fatalProblem = kFALSE;
181 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
183 TString histName = hdata->GetName();
184 if(!histName.Contains("SPD")) continue;
187 if(histName.Contains("SPDErrorsAll")){
188 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(fDisplayStatus[0]);
189 if(hdata->Integral(0,hdata->GetNbinsX())>0){
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;
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");
206 p->SetFillColor(kRed);
207 p->AddText("Data Format NOT OK. Please call the expert!");
212 response = fHighSPDValue[AliQAv1::kFATAL];
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);
221 p->SetFillColor(kGreen);
229 else if(histName.Contains("MEB")){
230 if(hdata->GetListOfFunctions()->GetEntries()<1) hdata->GetListOfFunctions()->Add(fDisplayStatus[1]);
231 if(hdata->GetEntries()>0){
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);
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.");
244 response = fHighSPDValue[AliQAv1::kFATAL];
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);
253 p->SetFillColor(kGreen);
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);
268 //__________________________________________________________________
269 void AliITSQASPDChecker::SetTaskOffset(Int_t TaskOffset)
271 // Offset for SPD within ITS QA
272 fSubDetOffset = TaskOffset;
275 //__________________________________________________________________
276 void AliITSQASPDChecker::SetStepBit(const Double_t *steprange)
278 // Step bit for SPD within ITS QA
279 fStepBitSPD = new Double_t[AliQAv1::kNBIT];
280 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
282 fStepBitSPD[bit]=steprange[bit];
287 //__________________________________________________________________
288 void AliITSQASPDChecker::SetSPDLimits(const Float_t *lowvalue, const Float_t * highvalue)
290 // SPD limints for QA bit within general ITS QA
291 fLowSPDValue = new Float_t[AliQAv1::kNBIT];
292 fHighSPDValue= new Float_t[AliQAv1::kNBIT];
294 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
296 fLowSPDValue[bit]=lowvalue[bit];
297 fHighSPDValue[bit]= highvalue[bit];
301 //__________________________________________________________________
302 Bool_t AliITSQASPDChecker::MakeSPDImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode)
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
310 case AliQAv1::kRAWS:{
311 val = MakeSPDRawsImage(list, task,mode);
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:;
324 //AliQAChecker::Instance()->GetDetQAChecker(0)->MakeImage(list,task,mode);
328 case AliQAv1::kNULLTASKINDEX:; case AliQAv1::kNTASKINDEX:
329 {AliWarning(Form("No histograms for these tasks ( %s ) \n", AliQAv1::GetTaskName(task).Data())); val = kFALSE;}
334 //_______________________________________________________________________
335 Bool_t AliITSQASPDChecker::MakeSPDRawsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode )
338 // create layout of the histograms used in the DQM
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;}
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) ;
352 fImage[esIndex]->Clear() ;
353 fImage[esIndex]->SetTitle(title) ;
354 fImage[esIndex]->cd();
356 TPaveText someText(0.015, 0.015, 0.98, 0.98);
357 someText.AddText(title);
359 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;
360 fImage[esIndex]->Clear() ;
364 fImage[esIndex]->Divide(nx, ny) ;
368 fImage[esIndex]->cd(npad);
369 fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
371 TIter next(list[esIndex]);
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);
382 hist->SetOption("colz") ;
385 if(name.Contains("MEB")) {
386 fImage[esIndex]->cd(2) ;
387 gPad->SetBorderMode(0) ;
388 gPad->SetBottomMargin(0.25);
389 hist->SetOption("colz") ;
392 if(name.Contains("SPDFastOrCorrelation")){
393 fImage[esIndex]->cd(3) ;
394 gPad->SetBorderMode(0) ;
395 hist->SetOption("") ;
399 if(name.Contains("SPDHitMapStaveChipInner")){
400 fImage[esIndex]->cd(4) ;
401 gPad->SetBorderMode(0) ;
402 gPad->SetRightMargin(0.25);
403 hist->SetOption("colz") ;
406 if(name.Contains("SPDHitMapStaveChipOuter")){
407 fImage[esIndex]->cd(5) ;
408 gPad->SetBorderMode(0) ;
409 gPad->SetRightMargin(0.25);
410 hist->SetOption("colz") ;
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") ;
425 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;