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