Reduced QA output (Yves)
[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) {
5379c4a3 52 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SPD Checker\n");
5dfa9b71 53 }
54 if(fDet == 0 || fDet == 2) {
5379c4a3 55 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SDD Checker\n");
5dfa9b71 56 }
57 if(fDet == 0 || fDet == 3) {
5379c4a3 58 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SSD Checker\n");
5dfa9b71 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//____________________________________________________________________________
4e25ac79 87Double_t * AliITSQAChecker::Check(AliQAv1::ALITASK_t /*index*/)
57acd2d2 88{
89 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
90 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
91 rv[specie] = 0.5 ;
92 return rv ;
93}
94
95//____________________________________________________________________________
4e25ac79 96Double_t * AliITSQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list)
5dfa9b71 97{
3647765c 98
5dfa9b71 99 // Super-basic check on the QA histograms on the input list:
100 // look whether they are empty!
4e25ac79 101 if(index == AliQAv1::kESD){
57acd2d2 102 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
103 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
104 rv[specie] = 0.0 ;
4e25ac79 105 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
57acd2d2 106 continue ;
5379c4a3 107 AliDebug(AliQAv1::GetQADebugLevel(),"Checker for ESD");
57acd2d2 108 Int_t tested = 0;
109 Int_t empty = 0;
110 // The following flags are set to kTRUE if the corresponding
111 // QA histograms exceed a given quality threshold
112 Bool_t cluMapSA = kFALSE;
113 Bool_t cluMapMI = kFALSE;
114 Bool_t cluMI = kFALSE;
115 Bool_t cluSA = kFALSE;
116 Bool_t verSPDZ = kFALSE;
117 if (list[specie]->GetEntries() == 0) {
118 rv[specie] = 0.; // nothing to check
882ac7f1 119 }
57acd2d2 120 else {
121 TIter next1(list[specie]);
122 TH1 * hdata;
123 Int_t nskipped=0;
124 Bool_t skipped[6]={kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE};
125 // look for layers that we wanted to skip
126 while ( (hdata = dynamic_cast<TH1 *>(next1())) ) {
127 if(!hdata) continue;
128 TString hname = hdata->GetName();
129 if(!hname.Contains("hESDSkippedLayers")) continue;
130 for(Int_t k=1; k<7; k++) {
131 if(hdata->GetBinContent(k)>0) {
132 nskipped++;
133 skipped[k-1]=kTRUE;
134 }
135 }
136 }
137 TIter next(list[specie]);
138 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
139 if(hdata){
140 TString hname = hdata->GetName();
141 Double_t entries = hdata->GetEntries();
142 ++tested;
143 if(!(entries>0.))++empty;
5379c4a3 144 AliDebug(AliQAv1::GetQADebugLevel(),Form("ESD hist name %s - entries %12.1g",hname.Data(),entries));
57acd2d2 145 if(hname.Contains("hESDClusterMapSA") && entries>0.){
146 cluMapSA = kTRUE;
5379c4a3 147 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
57acd2d2 148 // Check if there are layers with anomalously low
149 // contributing points to SA reconstructed tracks
150 for(Int_t k=1;k<7;k++){
151 // check if the layer was skipped
152 if(skipped[k-1]) continue;
153 if(hdata->GetBinContent(k)<0.5*(entries/6.)){
154 cluMapSA = kFALSE;
5379c4a3 155 AliDebug(AliQAv1::GetQADebugLevel(), Form("SA tracks have few points on layer %d - look at histogram hESDClustersSA",k));
57acd2d2 156 }
157 }
158 }
8ea6e205 159
57acd2d2 160 else if(hname.Contains("hESDClusterMapMI") && entries>0.){
161 // Check if there are layers with anomalously low
162 // contributing points to MI reconstructed tracks
5379c4a3 163 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
57acd2d2 164 cluMapMI = kTRUE;
165 for(Int_t k=1;k<7;k++){
166 // check if the layer was skipped
167 if(skipped[k-1]) continue;
168 if(hdata->GetBinContent(k)<0.5*(entries/6.)){
169 cluMapMI = kFALSE;
5379c4a3 170 AliDebug(AliQAv1::GetQADebugLevel(), Form("MI tracks have few points on layer %d - look at histogram hESDClustersMI",k));
57acd2d2 171 }
172 }
173 }
8ea6e205 174
57acd2d2 175 else if(hname.Contains("hESDClustersMI") && entries>0.){
176 // Check if 6 clusters MI tracks are the majority
5379c4a3 177 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
57acd2d2 178 cluMI = kTRUE;
179 Double_t maxlaytracks = hdata->GetBinContent(7-nskipped);
180 for(Int_t k=2; k<7-nskipped; k++){
181 if(hdata->GetBinContent(k)>maxlaytracks){
182 cluMI = kFALSE;
5379c4a3 183 AliDebug(AliQAv1::GetQADebugLevel(), Form("MI Tracks with %d clusters are more than tracks with %d clusters. Look at histogram hESDClustersMI",k-1,6-nskipped));
57acd2d2 184 }
185 }
186 }
8ea6e205 187
57acd2d2 188 else if(hname.Contains("hESDClustersSA") && entries>0.){
189 // Check if 6 clusters SA tracks are the majority
5379c4a3 190 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
57acd2d2 191 cluSA = kTRUE;
192 Double_t maxlaytracks = hdata->GetBinContent(7-nskipped);
193 for(Int_t k=2; k<7-nskipped; k++){
194 if(hdata->GetBinContent(k)>maxlaytracks){
195 cluSA = kFALSE;
5379c4a3 196 AliDebug(AliQAv1::GetQADebugLevel(), Form("SA Tracks with %d clusters are more than tracks with %d clusters. Look at histogram hESDClustersSA",k-1,6-nskipped));
57acd2d2 197 }
198 }
199 }
8ea6e205 200
57acd2d2 201 else if(hname.Contains("hSPDVertexZ") && entries>0.){
202 // Check if average Z vertex coordinate is -5 < z < 5 cm
5379c4a3 203 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
57acd2d2 204 verSPDZ = kTRUE;
205 if(hdata->GetMean()<-5. && hdata->GetMean()>5.){
206 verSPDZ = kFALSE;
5379c4a3 207 AliDebug(AliQAv1::GetQADebugLevel(), Form("Average z vertex coordinate is at z= %10.4g cm",hdata->GetMean()));
57acd2d2 208 }
209 }
210 }
8ea6e205 211
57acd2d2 212 else{
213 AliError("ESD Checker - invalid data type");
214 }
8ea6e205 215
57acd2d2 216 rv[specie] = 0.;
217 if(tested>0){
218 if(tested == empty){
219 rv[specie] = 0.1;
220 AliWarning("All ESD histograms are empty");
221 }
222 else {
223 rv[specie] = 0.1+0.4*(static_cast<Double_t>(tested-empty)/static_cast<Double_t>(tested));
224 if(cluMapSA)rv[specie]+=0.1;
225 if(cluMapMI)rv[specie]+=0.1;
226 if(cluMI)rv[specie]+=0.1;
227 if(cluSA)rv[specie]+=0.1;
228 if(verSPDZ)rv[specie]+=0.1;
229 }
230 }
231 }
232 }
5379c4a3 233 AliDebug(AliQAv1::GetQADebugLevel(), Form("ESD - Tested %d histograms, Return value %f \n",tested,rv[specie]));
57acd2d2 234 }
235 return rv ;
8ea6e205 236 } // end of ESD QA
57acd2d2 237
238 Double_t * retval = new Double_t[AliRecoParam::kNSpecies] ;
614c7e17 239 //____________________________________________________________________________
240
c71529b0 241 Double_t spdCheck, sddCheck, ssdCheck;
614c7e17 242 //pixel
5dfa9b71 243 if(fDet == 0 || fDet == 1) {
5379c4a3 244 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SPD Checker\n");
3647765c 245 if(!fSPDChecker) {
246 fSPDChecker = new AliITSQASPDChecker();
247 }
248 fSPDChecker->SetTaskOffset(fSPDOffset);
57acd2d2 249 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
250 retval[specie] = 1.0 ;
4e25ac79 251 if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
57acd2d2 252 spdCheck = fSPDChecker->Check(index, list[specie]);
253 if(spdCheck<retval[specie])retval[specie] = spdCheck;
254 }
255 }
5dfa9b71 256 }
614c7e17 257 //drift
5dfa9b71 258 if(fDet == 0 || fDet == 2) {
5379c4a3 259 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SDD Checker\n");
3647765c 260 if(!fSDDChecker) {
261 fSDDChecker = new AliITSQASDDChecker();
262 }
263 fSDDChecker->SetTaskOffset(fSDDOffset);
57acd2d2 264 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
265 retval[specie] = 1.0 ;
4e25ac79 266 if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
57acd2d2 267 sddCheck = fSDDChecker->Check(index, list[specie]);
268 if(sddCheck<retval[specie])retval[specie] = sddCheck;
269 }
270 }
882ac7f1 271 }
614c7e17 272 //strip
5dfa9b71 273 if(fDet == 0 || fDet == 3) {
5379c4a3 274 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SSD Checker\n");
3647765c 275 if(!fSSDChecker) {
276 fSSDChecker = new AliITSQASSDChecker();
5379c4a3 277 AliDebug(AliQAv1::GetQADebugLevel(), Form("Number of monitored objects SSD: %d", list[AliRecoParam::kDefault]->GetEntries()));
3647765c 278 }
279 fSSDChecker->SetTaskOffset(fSSDOffset);
57acd2d2 280 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
281 retval[specie] = 1.0 ;
4e25ac79 282 if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
57acd2d2 283 ssdCheck = fSSDChecker->Check(index, list[specie]);
284 if(ssdCheck<retval[specie])retval[specie] = ssdCheck;
285 }
286 }
287 }
5dfa9b71 288 // here merging part for common ITS QA result
c71529b0 289 //
57acd2d2 290
291 return retval;
5dfa9b71 292}
293
294
c71529b0 295//____________________________________________________________________________
296void AliITSQAChecker::SetTaskOffset(Int_t SPDOffset, Int_t SDDOffset, Int_t SSDOffset)
297{
298 //Setting the 3 offsets for each task called
299 fSPDOffset = SPDOffset;
300 fSDDOffset = SDDOffset;
301 fSSDOffset = SSDOffset;
302}
614c7e17 303
304 //____________________________________________________________________________
305 void AliITSQAChecker::SetDetTaskOffset(Int_t subdet,Int_t offset)
306 {
307 switch(subdet){
308 case 1:
309 SetSPDTaskOffset(offset);
310 break;
311 case 2:
312 SetSDDTaskOffset(offset);
313 break;
314 case 3:
315 SetSSDTaskOffset(offset);
316 break;
317 default:
318 AliWarning("No specific (SPD,SDD or SSD) subdetector correspond to to this number!!! all offsets set to zero for all the detectors\n");
319 SetTaskOffset(0, 0, 0);
320 break;
321 }
322 }