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