]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQAChecker.cxx
Added QA for digits during reconstruction (Yves)
[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(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SPD Checker\n");
53   }
54   if(fDet == 0 || fDet == 2) {
55     AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SDD Checker\n");
56   }
57   if(fDet == 0 || fDet == 3) {
58     AliDebug(AliQAv1::GetQADebugLevel(),"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 Double_t * AliITSQAChecker::Check(AliQAv1::ALITASK_t /*index*/)
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 //____________________________________________________________________________
96 Double_t * AliITSQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list)
97 {
98   
99   // Super-basic check on the QA histograms on the input list:
100   // look whether they are empty!
101   if(index == AliQAv1::kESD){
102     Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ; 
103     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
104       rv[specie] = 0.0 ; 
105       if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
106         continue ; 
107       AliDebug(AliQAv1::GetQADebugLevel(),"Checker for ESD");
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
119       }
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;
144             AliDebug(AliQAv1::GetQADebugLevel(),Form("ESD hist name %s - entries %12.1g",hname.Data(),entries));
145             if(hname.Contains("hESDClusterMapSA") && entries>0.){
146               cluMapSA = kTRUE;
147               AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
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;
155                   AliDebug(AliQAv1::GetQADebugLevel(), Form("SA tracks have few points on layer %d - look at histogram hESDClustersSA",k));
156                 }
157               }  
158             }
159
160             else if(hname.Contains("hESDClusterMapMI") && entries>0.){
161               // Check if there are layers with anomalously low 
162               // contributing points to MI reconstructed tracks
163               AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
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;
170                   AliDebug(AliQAv1::GetQADebugLevel(), Form("MI tracks have few points on layer %d - look at histogram hESDClustersMI",k));
171                 }
172               }  
173             }
174
175             else if(hname.Contains("hESDClustersMI") && entries>0.){
176               // Check if 6 clusters MI tracks are the majority
177               AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
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;
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));
184                 }
185               }
186             }
187
188             else if(hname.Contains("hESDClustersSA") && entries>0.){
189               // Check if 6 clusters SA tracks are the majority
190               AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
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;
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));
197                 }
198               }
199             }
200
201             else if(hname.Contains("hSPDVertexZ") && entries>0.){
202               // Check if average Z vertex coordinate is -5 < z < 5 cm
203               AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
204               verSPDZ = kTRUE;
205               if(hdata->GetMean()<-5. && hdata->GetMean()>5.){
206                 verSPDZ = kFALSE;
207                 AliDebug(AliQAv1::GetQADebugLevel(), Form("Average z vertex coordinate is at z= %10.4g cm",hdata->GetMean()));
208               }
209             }
210           }
211
212           else{
213             AliError("ESD Checker - invalid data type");
214           }
215           
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       }  
233       AliDebug(AliQAv1::GetQADebugLevel(), Form("ESD - Tested %d histograms, Return value %f \n",tested,rv[specie]));
234     }
235     return rv ; 
236   }  // end of ESD QA
237   
238   Double_t * retval = new Double_t[AliRecoParam::kNSpecies] ; 
239   //____________________________________________________________________________
240
241   Double_t spdCheck, sddCheck, ssdCheck;
242   //pixel
243   if(fDet == 0 || fDet == 1) {
244     AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SPD Checker\n");
245     if(!fSPDChecker) {
246       fSPDChecker = new AliITSQASPDChecker();
247     }
248     fSPDChecker->SetTaskOffset(fSPDOffset);
249     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
250       retval[specie] = 1.0 ; 
251       if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
252         spdCheck = fSPDChecker->Check(index, list[specie]);
253         if(spdCheck<retval[specie])retval[specie] = spdCheck;
254       }
255     }
256   }
257   //drift
258   if(fDet == 0 || fDet == 2) {
259     AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SDD Checker\n");
260     if(!fSDDChecker) {
261       fSDDChecker = new AliITSQASDDChecker();
262     }
263     fSDDChecker->SetTaskOffset(fSDDOffset);
264     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
265       retval[specie] = 1.0 ; 
266       if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
267         sddCheck = fSDDChecker->Check(index, list[specie]);
268         if(sddCheck<retval[specie])retval[specie] = sddCheck;
269       }
270     }
271   }
272   //strip
273   if(fDet == 0 || fDet == 3) {
274     AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SSD Checker\n");
275     if(!fSSDChecker) {
276       fSSDChecker = new AliITSQASSDChecker();
277       AliDebug(AliQAv1::GetQADebugLevel(), Form("Number of monitored objects SSD: %d", list[AliRecoParam::kDefault]->GetEntries()));
278     }
279     fSSDChecker->SetTaskOffset(fSSDOffset);
280     for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
281       retval[specie] = 1.0 ; 
282       if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
283         ssdCheck = fSSDChecker->Check(index, list[specie]);
284         if(ssdCheck<retval[specie])retval[specie] = ssdCheck;  
285       }
286     }
287   }
288   // here merging part for common ITS QA result
289   // 
290
291   return retval;  
292 }
293
294
295 //____________________________________________________________________________
296 void 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 }
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  }