Previous commit had the bad side-effect of changing the behaviour of Raw QA to comput...
[u/mrichter/AliRoot.git] / MUON / AliMUONQAChecker.cxx
CommitLineData
8aa336b1 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
bf4d93eb 16// $Id$
17
8aa336b1 18#include "AliMUONQAChecker.h"
19
8aa336b1 20/// \class AliMUONQAChecker
21///
f587a77d 22/// Implementation of AliQACheckerBase for MCH and MTR
8aa336b1 23///
f587a77d 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
5bb54f70 32#include "AliLog.h"
f587a77d 33#include "AliMUONVTrackerData.h"
34#include "AliMpManuIterator.h"
4e25ac79 35#include "AliQAv1.h"
f587a77d 36#include <TDirectory.h>
5bb54f70 37#include <TH1.h>
8aa336b1 38
39/// \cond CLASSIMP
40ClassImp(AliMUONQAChecker)
41/// \endcond
42
43//__________________________________________________________________
44AliMUONQAChecker::AliMUONQAChecker() :
45 AliQACheckerBase("MUON","MUON Quality Assurance Data Maker")
46{
f587a77d 47 /// ctor
8aa336b1 48}
49
50//__________________________________________________________________
51AliMUONQAChecker::~AliMUONQAChecker()
52{
f587a77d 53 /// dtor
8aa336b1 54}
55
56//__________________________________________________________________
57AliMUONQAChecker::AliMUONQAChecker(const AliMUONQAChecker& qac) :
58 AliQACheckerBase(qac.GetName(), qac.GetTitle())
59{
f587a77d 60 /// copy ctor
8aa336b1 61}
62
f587a77d 63//______________________________________________________________________________
57acd2d2 64Double_t *
4e25ac79 65AliMUONQAChecker::Check(AliQAv1::ALITASK_t /*index*/)
f587a77d 66{
67 /// Check data
68
69 AliError(Form("This method is not implemented. Should it be ? fDataSubDir = %p (%s)",
70 fDataSubDir, ( fDataSubDir ? fDataSubDir->GetPath() : "")));
57acd2d2 71 return NULL;
f587a77d 72}
73
74//______________________________________________________________________________
57acd2d2 75Double_t *
4e25ac79 76AliMUONQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list)
f587a77d 77{
78 /// Check objects in list
79
4e25ac79 80 if ( index == AliQAv1::kRAW )
f587a77d 81 {
82 return CheckRaws(list);
83 }
84
4e25ac79 85 if ( index == AliQAv1::kREC)
5bb54f70 86 {
87 return CheckRecPoints(list);
88 }
89
4e25ac79 90 if ( index == AliQAv1::kESD )
5bb54f70 91 {
92 return CheckESD(list);
93 }
94
f587a77d 95 AliWarning(Form("Checker for task %d not implement for the moment",index));
57acd2d2 96 return NULL;
f587a77d 97}
98
99//______________________________________________________________________________
5bb54f70 100TH1*
96664c0d 101AliMUONQAChecker::GetHisto(TObjArray* list, const char* hname, Int_t specie) const
5bb54f70 102{
103 /// Get a given histo from the list
96664c0d 104 TH1* h = static_cast<TH1*>(list->FindObject(Form("%s_%s",AliRecoParam::GetEventSpecieName(specie),hname)));
5bb54f70 105 if (!h)
106 {
107 AliError(Form("Did not find expected histo %s",hname));
108 }
109 return h;
110}
111
112//______________________________________________________________________________
57acd2d2 113Double_t *
114AliMUONQAChecker::CheckRecPoints(TObjArray ** list)
5bb54f70 115{
116 /// Check rec points
117 /// Very binary check for the moment.
118
57acd2d2 119 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
120 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
121 rv[specie] = 1.0 ;
5bb54f70 122
57acd2d2 123 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
96664c0d 124 TH1* h = GetHisto(list[specie],"hTrackerNumberOfClustersPerDE",specie);
5bb54f70 125
57acd2d2 126 if ( !h ) rv[specie] = 0.75; // only a warning if histo not found, in order not to kill anything because QA failed...
5bb54f70 127
57acd2d2 128 else if ( h->GetMean() == 0.0 ) rv[specie] = MarkHisto(*h,0.0);
129 }
130 return rv;
5bb54f70 131}
132
133//______________________________________________________________________________
94bf739c 134Double_t
e6cfc17e 135AliMUONQAChecker::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 {
4e25ac79 141 histo.SetBit(AliQAv1::GetQABit());
e6cfc17e 142 }
143
144 return value;
145}
146
147//______________________________________________________________________________
57acd2d2 148Double_t *
149AliMUONQAChecker::CheckESD(TObjArray ** list)
5bb54f70 150{
151 /// Check ESD
152
57acd2d2 153 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
154 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
155 rv[specie] = 1.0 ;
5bb54f70 156
57acd2d2 157 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
158
96664c0d 159 TH1* h = GetHisto(list[specie],"hESDnTracks",specie);
5bb54f70 160
57acd2d2 161 if (!h) rv[specie] = 0.75;
5bb54f70 162
57acd2d2 163 else if ( h->GetMean() == 0.0 ) rv[specie] = MarkHisto(*h,0.0); // no track -> fatal
5bb54f70 164
96664c0d 165 h = GetHisto(list[specie],"hESDMatchTrig",specie);
5bb54f70 166
57acd2d2 167 if (!h) rv[specie] = 0.75;
5bb54f70 168
57acd2d2 169 else if (h->GetMean() == 0.0 ) rv[specie] = MarkHisto(*h,0.25); // no trigger matching -> error
170 }
171 return rv;
5bb54f70 172}
173
174//______________________________________________________________________________
57acd2d2 175Double_t *
176AliMUONQAChecker::CheckRaws(TObjArray ** list)
f587a77d 177{
ea49e931 178 /// Check raws
179
57acd2d2 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);
f587a77d 188
57acd2d2 189 while ( (object=next()) && !data )
190 {
191 if (object->InheritsFrom("AliMUONVTrackerData"))
192 {
193 data = static_cast<AliMUONVTrackerData*>(object);
194 }
195 }
f587a77d 196
57acd2d2 197 if ( !data )
198 {
199 AliError("Did not find TrackerData in the list !");
200 return NULL;
201 }
f587a77d 202
57acd2d2 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
f587a77d 209
57acd2d2 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 }
f587a77d 217
57acd2d2 218 AliInfo(Form("n %d n50 %d n75 %d",n,n50,n75));
f587a77d 219
57acd2d2 220 if ( n == 0 )
221 {
222 AliError("Oups. Got zero occupancy in all manus ?!");
223 rv[specie] = 0.0;
224 }
f587a77d 225
57acd2d2 226 if ( n75 )
227 {
228 AliError(Form("Got %d manus with occupancy above 0.75",n75));
229 rv[specie] = 0.1;
230 }
f587a77d 231
57acd2d2 232 if ( n50 )
233 {
234 AliWarning(Form("Got %d manus with occupancy above 0.5",n50));
235 rv[specie] = 0.9;
236 }
f587a77d 237 }
57acd2d2 238 return rv;
239}
f587a77d 240
57acd2d2 241//______________________________________________________________________________
4e25ac79 242void AliMUONQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
57acd2d2 243{
cddcc1f3 244 /// intialises QA and QA checker settings
4e25ac79 245 AliQAv1::Instance(det) ;
246 Float_t hiValue[AliQAv1::kNBIT] ;
247 Float_t lowValue[AliQAv1::kNBIT] ;
248 lowValue[AliQAv1::kINFO] = 0.999 ;
249 hiValue[AliQAv1::kINFO] = 1.0 ;
250 hiValue[AliQAv1::kWARNING] = 0.99 ;
251 lowValue[AliQAv1::kWARNING] = 0.5 ;
252 lowValue[AliQAv1::kERROR] = 0.0 ;
253 hiValue[AliQAv1::kERROR] = 0.5 ;
254 lowValue[AliQAv1::kFATAL] = -1.0 ;
255 hiValue[AliQAv1::kFATAL] = 0.0 ;
26b391fe 256 SetHiLo(&hiValue[0], &lowValue[0]) ;
f587a77d 257}
258
259//______________________________________________________________________________
260void
4e25ac79 261AliMUONQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
f587a77d 262{
ea49e931 263 /// sets the QA according the return value of the Check
f587a77d 264
4e25ac79 265 AliQAv1 * qa = AliQAv1::Instance(index);
f587a77d 266
57acd2d2 267 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 268 qa->UnSet(AliQAv1::kFATAL, specie);
269 qa->UnSet(AliQAv1::kWARNING, specie);
270 qa->UnSet(AliQAv1::kERROR, specie);
271 qa->UnSet(AliQAv1::kINFO, specie);
57acd2d2 272
273 if ( ! value ) { // No checker is implemented, set all QA to Fatal
4e25ac79 274 qa->Set(AliQAv1::kFATAL, specie) ;
57acd2d2 275 } else {
4e25ac79 276 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
277 qa->Set(AliQAv1::kFATAL, specie) ;
278 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
279 qa->Set(AliQAv1::kERROR, specie) ;
280 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
281 qa->Set(AliQAv1::kWARNING, specie) ;
282 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
283 qa->Set(AliQAv1::kINFO, specie) ;
57acd2d2 284 }
f587a77d 285 }
94b4cb08 286}