]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONQAChecker.cxx
Adding the cascade performance task (Antonin Maire)
[u/mrichter/AliRoot.git] / MUON / AliMUONQAChecker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 #include "AliMUONQAChecker.h"
19
20 /// \class AliMUONQAChecker
21 ///
22 /// Implementation of AliQACheckerBase for MCH and MTR
23 ///
24 /// For the moment we only implement the checking of raw data QA for the tracker
25 /// by looking at the occupancy at the manu level.
26 /// We count the number of manus above a given occupancy threshold, and
27 /// depending on that number, the resulting QA flag is warning, error or fatal.
28 /// (there's no "info" type in this case).
29 ///
30 /// \author Laurent Aphecetche, Subatech
31
32 #include "AliLog.h"
33 #include "AliMUONVTrackerData.h"
34 #include "AliMpManuIterator.h"
35 #include "AliQA.h"
36 #include <TDirectory.h>
37 #include <TH1.h>
38
39 /// \cond CLASSIMP
40 ClassImp(AliMUONQAChecker)
41 /// \endcond
42
43 //__________________________________________________________________
44 AliMUONQAChecker::AliMUONQAChecker() : 
45     AliQACheckerBase("MUON","MUON Quality Assurance Data Maker") 
46 {
47         /// ctor
48 }          
49
50 //__________________________________________________________________
51 AliMUONQAChecker::~AliMUONQAChecker() 
52 {
53         /// dtor
54 }
55
56 //__________________________________________________________________
57 AliMUONQAChecker::AliMUONQAChecker(const AliMUONQAChecker& qac) : 
58     AliQACheckerBase(qac.GetName(), qac.GetTitle()) 
59 {
60         /// copy ctor 
61 }   
62
63 //______________________________________________________________________________
64 Double_t *
65 AliMUONQAChecker::Check(AliQA::ALITASK_t /*index*/)
66 {
67   /// Check data
68   
69   AliError(Form("This method is not implemented. Should it be ? fDataSubDir = %p (%s)",
70                 fDataSubDir, ( fDataSubDir ? fDataSubDir->GetPath() : "")));
71   return NULL;
72 }
73
74 //______________________________________________________________________________
75 Double_t *
76 AliMUONQAChecker::Check(AliQA::ALITASK_t index, TObjArray ** list)
77 {
78   /// Check objects in list
79   
80   if ( index == AliQA::kRAW ) 
81   {
82     return CheckRaws(list);
83   }
84   
85   if ( index == AliQA::kREC)
86   {
87     return CheckRecPoints(list);
88   }
89   
90   if ( index == AliQA::kESD )
91   {
92     return CheckESD(list);
93   }
94   
95   AliWarning(Form("Checker for task %d not implement for the moment",index));
96   return NULL;
97 }
98
99 //______________________________________________________________________________
100 TH1* 
101 AliMUONQAChecker::GetHisto(TObjArray* list, const char* hname) const
102 {
103   /// Get a given histo from the list
104   TH1* h = static_cast<TH1*>(list->FindObject(hname));
105   if (!h)
106   {
107     AliError(Form("Did not find expected histo %s",hname));
108   }
109   return h;
110 }
111
112 //______________________________________________________________________________
113 Double_t *
114 AliMUONQAChecker::CheckRecPoints(TObjArray ** list)
115 {
116   /// Check rec points
117   /// Very binary check for the moment. 
118   
119   Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ; 
120   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
121     rv[specie] = 1.0 ; 
122   
123   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
124     TH1* h = GetHisto(list[specie],"hTrackerNumberOfClustersPerDE");
125   
126     if ( !h ) rv[specie] =  0.75; // only a warning if histo not found, in order not to kill anything because QA failed...
127   
128     else if ( h->GetMean() == 0.0 ) rv[specie] =  MarkHisto(*h,0.0);
129   }
130   return rv;
131 }
132
133 //______________________________________________________________________________
134 Double_t 
135 AliMUONQAChecker::MarkHisto(TH1& histo, Double_t value) const
136 {
137   /// Mark histo as originator of some QA error/warning
138   
139   if ( value != 1.0 )
140   {
141     histo.SetBit(AliQA::GetQABit());
142   }
143   
144   return value;
145 }
146
147 //______________________________________________________________________________
148 Double_t *
149 AliMUONQAChecker::CheckESD(TObjArray ** list)
150 {
151   /// Check ESD
152   
153   Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ; 
154   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
155     rv[specie] = 1.0 ; 
156   
157   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
158     
159     TH1* h = GetHisto(list[specie],"hESDnTracks");
160   
161     if (!h) rv[specie] = 0.75;
162   
163     else if ( h->GetMean() == 0.0 ) rv[specie] =  MarkHisto(*h,0.0); // no track -> fatal
164   
165     h = GetHisto(list[specie],"hESDMatchTrig");
166   
167     if (!h) rv[specie] =  0.75;
168   
169     else if (h->GetMean() == 0.0 ) rv[specie] = MarkHisto(*h,0.25); // no trigger matching -> error
170   }
171   return rv;
172 }
173
174 //______________________________________________________________________________
175 Double_t *
176 AliMUONQAChecker::CheckRaws(TObjArray ** list)
177 {
178   /// Check raws
179
180   Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ; 
181   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
182     rv[specie] = 1.0 ; 
183  
184   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
185     TIter next(list[specie]);
186     TObject* object;
187     AliMUONVTrackerData* data(0x0);
188   
189     while ( (object=next()) && !data )
190       {
191         if (object->InheritsFrom("AliMUONVTrackerData"))
192           {
193             data = static_cast<AliMUONVTrackerData*>(object);
194           }
195       }
196
197     if ( !data ) 
198       {
199         AliError("Did not find TrackerData in the list !");
200         return NULL;
201       }
202   
203     AliMpManuIterator it;
204     Int_t detElemId;
205     Int_t manuId;
206     Int_t n50(0); // number of manus with occupancy above 0.5
207     Int_t n75(0); // number of manus with occupancy above 0.75
208     Int_t n(0); // number of manus with some occupancy
209   
210     while ( it.Next(detElemId,manuId) )
211       {
212         Float_t occ = data->Manu(detElemId,manuId,2);
213         if (occ > 0 ) ++n;
214         if (occ >= 0.5 ) ++n50;
215         if (occ >= 0.75 ) ++n75;    
216       }
217
218     AliInfo(Form("n %d n50 %d n75 %d",n,n50,n75));
219   
220     if ( n == 0 ) 
221       {
222         AliError("Oups. Got zero occupancy in all manus ?!");
223         rv[specie] =  0.0;
224       }
225
226     if ( n75 ) 
227       {
228         AliError(Form("Got %d manus with occupancy above 0.75",n75));
229         rv[specie] =  0.1;
230       }
231     
232     if ( n50 ) 
233       {
234         AliWarning(Form("Got %d manus with occupancy above 0.5",n50));
235         rv[specie] =  0.9;
236       }
237   }
238   return rv;
239 }
240
241 //______________________________________________________________________________
242 void AliMUONQAChecker::Init(const AliQA::DETECTORINDEX_t det) 
243 {
244   // intialises QA and QA checker settings
245   AliQA::Instance(det) ; 
246   Float_t hiValue[AliQA::kNBIT] ; 
247   Float_t lowValue[AliQA::kNBIT] ;
248   lowValue[AliQA::kINFO]      = 0.999   ; 
249   hiValue[AliQA::kINFO]       = 1.0 ; 
250   hiValue[AliQA::kWARNING]    = 0.99 ; 
251   lowValue[AliQA::kWARNING]   = 0.5 ; 
252   lowValue[AliQA::kERROR]     = 0.0   ; 
253   hiValue[AliQA::kERROR]      = 0.5 ; 
254   lowValue[AliQA::kFATAL]     = -1.0   ; 
255   hiValue[AliQA::kFATAL]      = 0.0 ; 
256   SetHiLo(&hiValue[0], &lowValue[0]) ; 
257 }
258
259 //______________________________________________________________________________
260 void 
261 AliMUONQAChecker::SetQA(AliQA::ALITASK_t index, Double_t * value) const
262 {
263   /// sets the QA according the return value of the Check
264
265   AliQA * qa = AliQA::Instance(index);
266   
267   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
268     qa->UnSet(AliQA::kFATAL, specie);
269     qa->UnSet(AliQA::kWARNING, specie);
270     qa->UnSet(AliQA::kERROR, specie);
271     qa->UnSet(AliQA::kINFO, specie);
272
273     if ( ! value ) { // No checker is implemented, set all QA to Fatal
274       qa->Set(AliQA::kFATAL, specie) ; 
275     } else {
276       if ( value[specie] >= fLowTestValue[AliQA::kFATAL] && value[specie] < fUpTestValue[AliQA::kFATAL] ) 
277         qa->Set(AliQA::kFATAL, specie) ; 
278       else if ( value[specie] > fLowTestValue[AliQA::kERROR] && value[specie] <= fUpTestValue[AliQA::kERROR]  )
279         qa->Set(AliQA::kERROR, specie) ; 
280       else if ( value[specie] > fLowTestValue[AliQA::kWARNING] && value[specie] <= fUpTestValue[AliQA::kWARNING]  )
281         qa->Set(AliQA::kWARNING, specie) ;
282       else if ( value[specie] > fLowTestValue[AliQA::kINFO] && value[specie] <= fUpTestValue[AliQA::kINFO] ) 
283         qa->Set(AliQA::kINFO, specie) ;         
284     }
285   }
286 }