]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQAChecker.cxx
Temporary fix for 2 overlaps in SPD/FMD (M. Sitta)
[u/mrichter/AliRoot.git] / ITS / AliITSQAChecker.cxx
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
16 /* $Id$ */
17
18 // *****************************************
19 //  Checks the quality assurance 
20 //  by comparing with reference data
21 //  W.Ferrarese  P.Cerello  Mag 2008
22 //  INFN Torino
23
24 // --- ROOT system ---
25 #include "TH1.h"
26 #include <Riostream.h>
27
28 // --- AliRoot header files ---
29 #include "AliITSQAChecker.h"
30 #include "AliITSQASPDChecker.h"
31 #include "AliITSQASDDChecker.h"
32 #include "AliITSQASSDChecker.h"
33
34 ClassImp(AliITSQAChecker)
35
36 //____________________________________________________________________________
37 AliITSQAChecker::AliITSQAChecker(Bool_t kMode, Short_t subDet, Short_t ldc) :
38 AliQACheckerBase("ITS","SDD Quality Assurance Checker"),
39 fkOnline(0),
40 fDet(0),  
41 fLDC(0),
42 fSPDOffset(0), 
43 fSDDOffset(0), 
44 fSSDOffset(0),
45 fSPDChecker(0),  // SPD Checker
46 fSDDChecker(0),  // SDD Checker
47 fSSDChecker(0)  // SSD Checker
48 {
49   // Standard constructor
50   fkOnline = kMode; fDet = subDet; fLDC = ldc;
51   if(fDet == 0 || fDet == 1) {
52     AliDebug(1,"AliITSQAChecker::Create SPD Checker\n");
53   }
54   if(fDet == 0 || fDet == 2) {
55     AliDebug(1,"AliITSQAChecker::Create SDD Checker\n");
56   }
57   if(fDet == 0 || fDet == 3) {
58     AliDebug(1,"AliITSQAChecker::Create SSD Checker\n");
59   }
60
61 }
62
63 //____________________________________________________________________________
64 AliITSQAChecker::AliITSQAChecker(const AliITSQAChecker& qac):
65 AliQACheckerBase(qac.GetName(), qac.GetTitle()), 
66 fkOnline(qac.fkOnline), 
67 fDet(qac.fDet), 
68 fLDC(qac.fLDC), 
69 fSPDOffset(qac.fSPDOffset), 
70 fSDDOffset(qac.fSDDOffset), 
71 fSSDOffset(qac.fSSDOffset), 
72 fSPDChecker(0), 
73 fSDDChecker(0), 
74 fSSDChecker(0) {
75   // copy constructor
76   AliError("Copy should not be used with this class\n");
77 }
78 //____________________________________________________________________________
79 AliITSQAChecker& AliITSQAChecker::operator=(const AliITSQAChecker& qac){
80   // assignment operator
81   this->~AliITSQAChecker();
82   new(this)AliITSQAChecker(qac);
83   return *this;
84 }
85
86 //____________________________________________________________________________
87 const Double_t AliITSQAChecker::Check(AliQA::ALITASK_t index, TObjArray * list)
88 {
89   
90   // Super-basic check on the QA histograms on the input list:
91   // look whether they are empty!
92   if(index == AliQA::kESD){
93     AliDebug(1,"Checker for ESD");
94     Int_t tested = 0;
95     Int_t empty = 0;
96     Double_t rv = 0.;
97     // The following flags are set to kTRUE if the corresponding
98     // QA histograms exceed a given quality threshold
99     Bool_t cluMapSA = kFALSE;
100     Bool_t cluMapMI = kFALSE;
101     Bool_t cluMI = kFALSE;
102     Bool_t cluSA = kFALSE;
103     Bool_t verSPDZ = kFALSE;
104     if (list->GetEntries() == 0) {
105       rv = 0.; // nothing to check
106     }
107     else {
108       TIter next(list);
109       TH1 * hdata;
110       while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
111         if(hdata){
112           TString hname = hdata->GetName();
113           Double_t entries = hdata->GetEntries();
114           ++tested;
115           if(!(entries>0.))++empty;
116           AliDebug(1,Form("ESD hist name %s - entries %12.1g",hname.Data(),entries));
117
118           if(hname.Contains("hESDClusterMapSA") && entries>0.){
119             cluMapSA = kTRUE;
120             AliDebug(1,Form("Processing histogram %s",hname.Data()));
121             // Check if there are layers with anomalously low 
122             // contributing points to SA reconstructed tracks
123             for(Int_t k=1;k<7;k++){
124               if(hdata->GetBinContent(k)<0.5*(entries/6.)){
125                 cluMapSA = kFALSE;
126                 AliInfo(Form("SA tracks have few points on layer %d - look at histogram hESDClustersSA",k));
127               }
128             }  
129           }
130
131           else if(hname.Contains("hESDClusterMapMI") && entries>0.){
132             // Check if there are layers with anomalously low 
133             // contributing points to MI reconstructed tracks
134             AliDebug(1,Form("Processing histogram %s",hname.Data()));
135             cluMapMI = kTRUE;
136             for(Int_t k=1;k<7;k++){
137               if(hdata->GetBinContent(k)<0.5*(entries/6.)){
138                 cluMapMI = kFALSE;
139                 AliInfo(Form("MI tracks have few points on layer %d - look at histogram hESDClustersMI",k));
140               }
141             }  
142           }
143
144           else if(hname.Contains("hESDClustersMI") && entries>0.){
145             // Check if 6 clusters MI tracks are the majority
146             AliDebug(1,Form("Processing histogram %s",hname.Data()));
147             cluMI = kTRUE;
148             Double_t sixlaytracks = hdata->GetBinContent(7);
149             for(Int_t k=2; k<7; k++){
150               if(hdata->GetBinContent(k)>sixlaytracks){
151                 cluMI = kFALSE;
152                 AliInfo(Form("MI Tracks with %d clusters are more than tracks with 6 clusters. Look at histogram hESDClustersMI",k-1));
153               }
154             }
155           }
156
157           else if(hname.Contains("hESDClustersSA") && entries>0.){
158             // Check if 6 clusters SA tracks are the majority
159             AliDebug(1,Form("Processing histogram %s",hname.Data()));
160             cluSA = kTRUE;
161             Double_t sixlaytracks = hdata->GetBinContent(7);
162             for(Int_t k=2; k<7; k++){
163               if(hdata->GetBinContent(k)>sixlaytracks){
164                 cluSA = kFALSE;
165                 AliInfo(Form("SA Tracks with %d clusters are more than tracks with 6 clusters. Look at histogram hESDClustersSA",k-1));
166               }
167             }
168           }
169
170           else if(hname.Contains("hSPDVertexZ") && entries>0.){
171             // Check if average Z vertex coordinate is -5 < z < 5 cm
172             AliDebug(1,Form("Processing histogram %s",hname.Data()));
173             verSPDZ = kTRUE;
174             if(hdata->GetMean()<-5. && hdata->GetMean()>5.){
175               verSPDZ = kFALSE;
176               AliInfo(Form("Average z vertex coordinate is at z= %10.4g cm",hdata->GetMean()));
177             }
178           }
179
180         }
181         else{
182           AliError("ESD Checker - invalid data type");
183         }
184           
185         rv = 0.;
186         if(tested>0){
187           if(tested == empty){
188             rv = 0.1;
189             AliWarning("All ESD histograms are empty");
190           }
191           else {
192             rv = 0.1+0.4*(static_cast<Double_t>(tested-empty)/static_cast<Double_t>(tested));
193             if(cluMapSA)rv+=0.1;
194             if(cluMapMI)rv+=0.1;
195             if(cluMI)rv+=0.1;
196             if(cluSA)rv+=0.1;
197             if(verSPDZ)rv+=0.1;
198           }
199         }
200   
201       }
202     }  
203       AliInfo(Form("ESD - Tested %d histograms, Return value %f \n",tested,rv));
204       return rv;
205   }  // end of ESD QA
206
207   Double_t spdCheck, sddCheck, ssdCheck;
208   Double_t retval = 1.;
209   if(fDet == 0 || fDet == 1) {
210     AliDebug(1,"AliITSQAChecker::Create SPD Checker\n");
211     if(!fSPDChecker) {
212       fSPDChecker = new AliITSQASPDChecker();
213     }
214     fSPDChecker->SetTaskOffset(fSPDOffset);
215     spdCheck = fSPDChecker->Check(index, list);
216     if(spdCheck<retval)retval = spdCheck;
217   }
218   if(fDet == 0 || fDet == 2) {
219     AliDebug(1,"AliITSQAChecker::Create SDD Checker\n");
220     if(!fSDDChecker) {
221       fSDDChecker = new AliITSQASDDChecker();
222     }
223     fSDDChecker->SetTaskOffset(fSDDOffset);
224     sddCheck = fSDDChecker->Check(index, list);
225     if(sddCheck<retval)retval = sddCheck;
226  }
227   if(fDet == 0 || fDet == 3) {
228     AliDebug(1,"AliITSQAChecker::Create SSD Checker\n");
229     if(!fSSDChecker) {
230       fSSDChecker = new AliITSQASSDChecker();
231       AliInfo(Form("Number of monitored objects SSD: %d", list->GetEntries()));
232     }
233     fSSDChecker->SetTaskOffset(fSSDOffset);
234     ssdCheck = fSSDChecker->Check(index, list);
235     if(ssdCheck<retval)retval = ssdCheck;  }
236   // here merging part for common ITS QA result
237   // 
238   AliDebug(1,Form("AliITSQAChecker::QAChecker returned value is %f \n",retval));
239   return retval;
240   
241 }
242
243
244 //____________________________________________________________________________
245 void AliITSQAChecker::SetTaskOffset(Int_t SPDOffset, Int_t SDDOffset, Int_t SSDOffset)
246 {
247   //Setting the 3 offsets for each task called
248   fSPDOffset = SPDOffset;
249   fSDDOffset = SDDOffset;
250   fSSDOffset = SSDOffset;
251 }