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 //#include "Riostream.h"
32 // --- AliRoot header files ---
33 #include "AliITSQASSDChecker.h"
34 #include "AliITSQADataMakerRec.h"
37 ClassImp(AliITSQASSDChecker)
38 //__________________________________________________________________
39 AliITSQASSDChecker& AliITSQASSDChecker::operator = (const AliITSQASSDChecker& qac )
42 this->~AliITSQASSDChecker();
43 new(this) AliITSQASSDChecker(qac);
47 void AliITSQASSDChecker::CheckRaws(TH1* histo) {
49 Double_t minSSDDataSize = 0;
50 Double_t maxSSDDataSize = 200;
51 Double_t minDDLDataSize = 0;
52 Double_t maxDDLDataSize = 50;
53 Double_t minLDCDataSize = 0;
54 Double_t maxLDCDataSize = 100;
55 Double_t minMeanDDLDataSize = 0;
56 Double_t maxMeanDDLDataSize = 50;
57 Double_t minMeanLDCDataSize = 0;
58 Double_t maxMeanLDCDataSize = 100;
59 // Double_t maxOccupancy = 5;
61 TString histname = histo->GetName();
63 if (histname.EndsWith("SSDEventType")) {
64 if (histo->GetEntries()==0) {
65 AliWarning("Event type histogram is empty");
67 else if (histo->GetBinContent(histo->FindBin(7))==0) AliWarning("No type 7 (physics) events in EventType");
70 if (histname.EndsWith("SSDDataSize")) {
71 if (histo->GetEntries()==0) AliWarning("SSD data size histogram is empty");
72 if (histo->GetMean()>maxSSDDataSize||histo->GetMean()<minSSDDataSize) AliWarning(Form("SSD mean data size is %-.2g kB", histo->GetMean()));
75 if (histname.EndsWith("SSDDataSizePerDDL")) {
76 if (histo->GetEntries()==0) {
77 AliWarning("Data size per DDL histogram is empty");
80 for(Int_t i = 512; i < 528; i++) {
81 if(histo->GetBinContent(histo->FindBin(i))==0) {
82 AliWarning(Form("Data size / DDL histogram: bin for DDL %i is empty",i));
84 else if(histo->GetBinContent(histo->FindBin(i))<minDDLDataSize||histo->GetBinContent(histo->FindBin(i))>maxDDLDataSize) AliWarning(Form("Data size DDL %i is %-.2g kB",i,histo->GetBinContent(histo->FindBin(i))));
89 if (histname.EndsWith("SSDDataSizePerLDC")) {
90 if (histo->GetEntries()==0) {
91 AliWarning("Data size per LDC histogram is empty");
94 AliInfo(Form("Data size per LDC histogram has %f entries",histo->GetEntries()));
95 for(Int_t i = 170; i < 178; i++) {
96 if(histo->GetBinContent(histo->FindBin(i))==0) {
97 AliWarning(Form("Data size / LDC histogram: bin for LDC %i is empty",i));
99 else if(AliITSQADataMakerRec::AreEqual(histo->GetBinContent(histo->FindBin(i)),minLDCDataSize) ||histo->GetBinContent(histo->FindBin(i))>maxLDCDataSize) AliWarning(Form("Data size LDC %i is %-.2g kB",i,histo->GetBinContent(i)));
104 if (histname.EndsWith("SSDLDCId")) {
105 if (histo->GetEntries()==0) {
106 AliWarning("LDC ID histogram is empty");
109 for(Int_t i = 170; i < 177; i++) {
110 if(histo->GetBinContent(histo->FindBin(i))==0) {
111 AliWarning(Form("LDC ID histogram: No entries for LDC %i",i));
113 else if(histo->GetBinContent(histo->FindBin(i))!=histo->GetBinContent(histo->FindBin(i+1))) {
114 AliWarning("LDC Id distribution is not uniform");
121 if (histname.EndsWith("SSDDDLId")) {
122 if (histo->GetEntries()==0) {
123 AliWarning("DDL ID histogram is empty");
126 for(Int_t i = 512; i < 527; i++) {
127 if(histo->GetBinContent(histo->FindBin(i))==0) {
128 AliWarning(Form("DDL ID histogram: No entries for DDL %i",i));
130 else if(histo->GetBinContent(histo->FindBin(i))!=histo->GetBinContent(histo->FindBin(i+1))) {
131 AliWarning("DDL Id distribution is not uniform");
138 if (histname.Contains("SSDDataSizeLDC")) {
139 if (histo->GetEntries()==0) {
140 AliWarning(Form("LDC %s data size distribution is empty", histname(histname.Length()-3,3).Data()));
142 else if (histo->GetMean()<minMeanLDCDataSize||histo->GetMean()>maxMeanLDCDataSize) AliWarning(Form("Mean data size of LDC %s is %-.2g kB",histname(histname.Length()-3,3).Data(), histo->GetMean()));
145 if (histname.Contains("SSDDataSizeDDL")) {
146 if (histo->GetEntries()==0) {
147 AliWarning(Form("DDL %s data size distribution is empty", histname(histname.Length()-3,3).Data()));
149 else if (histo->GetMean()<minMeanDDLDataSize||histo->GetMean()>maxMeanDDLDataSize) AliWarning(Form("Mean data size of DDL %s is %-.2g kB",histname(histname.Length()-3,3).Data(), histo->GetMean()));
152 if (histname.Contains("SSDAverageOccupancy")) {
154 const char* side = "";
158 if (histname.EndsWith("5")) layernr = 499;
159 if (histname.EndsWith("6")) layernr = 599;
161 for (Int_t i = 1; i < histo->GetNbinsY() + 1; i++) { //ladder/side loop
163 ladder=int(i/3.)+layernr;
166 else if(i==3.*int(i+1/3.)){
167 ladder=int((i+1)/3.)+layernr;
171 for (Int_t j = 1; j < histo->GetNbinsX() + 1; j++) { //module loop
172 //if(histo->GetBinContent(j,i)>maxOccupancy)
173 // AliWarning(Form("Occupancy ladder %i, module %i, %s is %-.2f %%",ladder,j,side, histo->GetBinContent(j,i)));
181 //__________________________________________________________________
182 Bool_t AliITSQASSDChecker::MakeSSDImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode) {
183 //create the image for raws and recpoints. In the other case, the default methodof CheckerBase class will be used //
184 gStyle->SetPalette(1,0);
186 fImage=(TCanvas**)AliQAChecker::Instance()->GetDetQAChecker(0)->GetImage();
188 if(task == AliQAv1::kRAWS)
189 rval = MakeSSDRawsImage(list, task,mode);
195 //_______________________________________________________________________
196 Bool_t AliITSQASSDChecker::MakeSSDRawsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode ) {
197 // MakeSSDRawsImage: raw data QA plots
198 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
199 //printf("-------------------------> %i \n", esIndex);
200 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0) continue;
202 const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ;
203 if ( !fImage[esIndex] ) fImage[esIndex] = new TCanvas(title, title,1280,980) ;
205 fImage[esIndex]->Clear() ;
206 fImage[esIndex]->SetTitle(title) ;
207 fImage[esIndex]->cd();
209 //TPaveText someText(0.015, 0.015, 0.98, 0.98);
210 //someText.AddText(title);
212 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;
213 fImage[esIndex]->Clear() ;
214 Int_t nx =2; //TMath::Nint(TMath::Sqrt(nImages));
217 fImage[esIndex]->Divide(nx, ny) ;
218 TIter nexthist(list[esIndex]) ;
221 fImage[esIndex]->cd(npad);
222 fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
223 while ( (hist=static_cast<TH1*>(nexthist())) ) {
224 //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
225 TString cln(hist->ClassName()) ;
226 if ( ! cln.Contains("TH") ) continue ;
228 if(hist->TestBit(AliQAv1::GetImageBit())) {
229 //Printf("Histo name: %s - Class: %s",hist->GetName(),hist->ClassName());
230 hist->GetXaxis()->SetTitleSize(0.02);
231 hist->GetYaxis()->SetTitleSize(0.02);
232 hist->GetXaxis()->SetLabelSize(0.02);
233 hist->GetYaxis()->SetLabelSize(0.02);
234 if(cln.Contains("TH2")) {
235 gPad->SetRightMargin(0.15);
236 gPad->SetLeftMargin(0.05);
238 hist->SetOption("colz") ;
239 //hist->GetListOfFunctions()->FindObject("palette")->SetLabelSize(0.025);
243 fImage[esIndex]->cd(++npad) ;
244 fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
247 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ;
254 //__________________________________________________________________
255 Double_t AliITSQASSDChecker::Check(AliQAv1::ALITASK_t /*index*/, const TObjArray * list, const AliDetectorRecoParam * /*recoParam*/) {
256 // main checker method
257 AliDebug(AliQAv1::GetQADebugLevel(),Form("AliITSQASSDChecker called with offset: %d\n", fSubDetOffset));
259 AliInfo(Form("AliITSQASSDChecker called with offset: %d\n", fSubDetOffset) );
260 //cout<<"(AliITSQASSDChecker::Check): List name "<<list->GetName()<<endl;
261 Double_t test = 0.0 ;
263 TString listname = list->GetName();
265 if (list->GetEntries() == 0){
266 test = 1. ; // nothing to check
273 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
275 TString histname = hdata->GetName();
276 if(!histname.Contains("fHistSSD")) continue;
278 if(hdata->GetEntries()>0) {
281 //if(histname.Contains("PerDDL")) cout << "(AliITSQASSDChecker::Check) " << histname << " has " << hdata->GetEntries() << " entries. Mean: " << hdata->GetMean() << endl;
283 // if(hdata->GetMean()>0&&!histname.Contains("_Ladder")) cout << "(AliITSQASSDChecker::Check) " << histname << " not empty! " << hdata->GetEntries() << " entries. Mean: " << hdata->GetMean() << endl;
286 // if (listname.Contains("Raws")) CheckRaws(hdata);
287 // if (listname.Contains("RecPoints")) CheckRecPoints(hdata);
289 //AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv)) ;
290 //cout<<hdata->GetName()<<" - "<<rv<<endl;
295 AliError("Data type cannot be processed") ;
299 if (AliITSQADataMakerRec::AreEqual(test,0.)) {
300 AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
301 test = 0.5; //upper limit value to set kWARNING flag for a task
309 //AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test)) ;
310 //cout<<"Test result: "<<test<<endl;
319 //__________________________________________________________________
320 void AliITSQASSDChecker::SetTaskOffset(Int_t TaskOffset){
321 // defines offset for SSD
322 fSubDetOffset = TaskOffset;
325 //__________________________________________________________________
326 void AliITSQASSDChecker::SetStepBit(const Double_t *steprange) {
327 // defines step range
328 fStepBitSSD = new Double_t[AliQAv1::kNBIT];
329 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
331 fStepBitSSD[bit]=steprange[bit];
335 //__________________________________________________________________
336 void AliITSQASSDChecker::SetSSDLimits(const Float_t *lowvalue, const Float_t * highvalue){
338 fLowSSDValue = new Float_t[AliQAv1::kNBIT];
339 fHighSSDValue= new Float_t[AliQAv1::kNBIT];
341 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
343 fLowSSDValue[bit]=lowvalue[bit];
344 fHighSSDValue[bit]= highvalue[bit];