Separate the checks for DATE and DIM installation (requested by Laurent)
[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, TObjArray ** list)
f587a77d 66{
67 /// Check objects in list
68
4e25ac79 69 if ( index == AliQAv1::kRAW )
f587a77d 70 {
71 return CheckRaws(list);
72 }
73
4e25ac79 74 if ( index == AliQAv1::kREC)
5bb54f70 75 {
76 return CheckRecPoints(list);
77 }
78
4e25ac79 79 if ( index == AliQAv1::kESD )
5bb54f70 80 {
81 return CheckESD(list);
82 }
83
f587a77d 84 AliWarning(Form("Checker for task %d not implement for the moment",index));
57acd2d2 85 return NULL;
f587a77d 86}
87
88//______________________________________________________________________________
5bb54f70 89TH1*
96664c0d 90AliMUONQAChecker::GetHisto(TObjArray* list, const char* hname, Int_t specie) const
5bb54f70 91{
92 /// Get a given histo from the list
96664c0d 93 TH1* h = static_cast<TH1*>(list->FindObject(Form("%s_%s",AliRecoParam::GetEventSpecieName(specie),hname)));
5bb54f70 94 if (!h)
95 {
96 AliError(Form("Did not find expected histo %s",hname));
97 }
98 return h;
99}
100
101//______________________________________________________________________________
57acd2d2 102Double_t *
103AliMUONQAChecker::CheckRecPoints(TObjArray ** list)
5bb54f70 104{
105 /// Check rec points
106 /// Very binary check for the moment.
107
57acd2d2 108 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
109 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
110 rv[specie] = 1.0 ;
5bb54f70 111
57acd2d2 112 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
96664c0d 113 TH1* h = GetHisto(list[specie],"hTrackerNumberOfClustersPerDE",specie);
5bb54f70 114
57acd2d2 115 if ( !h ) rv[specie] = 0.75; // only a warning if histo not found, in order not to kill anything because QA failed...
5bb54f70 116
57acd2d2 117 else if ( h->GetMean() == 0.0 ) rv[specie] = MarkHisto(*h,0.0);
118 }
119 return rv;
5bb54f70 120}
121
122//______________________________________________________________________________
94bf739c 123Double_t
e6cfc17e 124AliMUONQAChecker::MarkHisto(TH1& histo, Double_t value) const
125{
126 /// Mark histo as originator of some QA error/warning
127
128 if ( value != 1.0 )
129 {
4e25ac79 130 histo.SetBit(AliQAv1::GetQABit());
e6cfc17e 131 }
132
133 return value;
134}
135
136//______________________________________________________________________________
57acd2d2 137Double_t *
138AliMUONQAChecker::CheckESD(TObjArray ** list)
5bb54f70 139{
140 /// Check ESD
141
57acd2d2 142 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
143 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
144 rv[specie] = 1.0 ;
5bb54f70 145
57acd2d2 146 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
147
96664c0d 148 TH1* h = GetHisto(list[specie],"hESDnTracks",specie);
5bb54f70 149
57acd2d2 150 if (!h) rv[specie] = 0.75;
5bb54f70 151
57acd2d2 152 else if ( h->GetMean() == 0.0 ) rv[specie] = MarkHisto(*h,0.0); // no track -> fatal
5bb54f70 153
96664c0d 154 h = GetHisto(list[specie],"hESDMatchTrig",specie);
5bb54f70 155
57acd2d2 156 if (!h) rv[specie] = 0.75;
5bb54f70 157
57acd2d2 158 else if (h->GetMean() == 0.0 ) rv[specie] = MarkHisto(*h,0.25); // no trigger matching -> error
159 }
160 return rv;
5bb54f70 161}
162
163//______________________________________________________________________________
57acd2d2 164Double_t *
165AliMUONQAChecker::CheckRaws(TObjArray ** list)
f587a77d 166{
ea49e931 167 /// Check raws
168
57acd2d2 169 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
170 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
171 rv[specie] = 1.0 ;
172
173 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
174 TIter next(list[specie]);
175 TObject* object;
176 AliMUONVTrackerData* data(0x0);
f587a77d 177
57acd2d2 178 while ( (object=next()) && !data )
179 {
180 if (object->InheritsFrom("AliMUONVTrackerData"))
181 {
182 data = static_cast<AliMUONVTrackerData*>(object);
183 }
184 }
f587a77d 185
57acd2d2 186 if ( !data )
187 {
188 AliError("Did not find TrackerData in the list !");
189 return NULL;
190 }
f587a77d 191
57acd2d2 192 AliMpManuIterator it;
193 Int_t detElemId;
194 Int_t manuId;
195 Int_t n50(0); // number of manus with occupancy above 0.5
196 Int_t n75(0); // number of manus with occupancy above 0.75
197 Int_t n(0); // number of manus with some occupancy
f587a77d 198
57acd2d2 199 while ( it.Next(detElemId,manuId) )
200 {
201 Float_t occ = data->Manu(detElemId,manuId,2);
202 if (occ > 0 ) ++n;
203 if (occ >= 0.5 ) ++n50;
204 if (occ >= 0.75 ) ++n75;
205 }
f587a77d 206
57acd2d2 207 AliInfo(Form("n %d n50 %d n75 %d",n,n50,n75));
f587a77d 208
57acd2d2 209 if ( n == 0 )
210 {
211 AliError("Oups. Got zero occupancy in all manus ?!");
212 rv[specie] = 0.0;
213 }
f587a77d 214
57acd2d2 215 if ( n75 )
216 {
217 AliError(Form("Got %d manus with occupancy above 0.75",n75));
218 rv[specie] = 0.1;
219 }
f587a77d 220
57acd2d2 221 if ( n50 )
222 {
223 AliWarning(Form("Got %d manus with occupancy above 0.5",n50));
224 rv[specie] = 0.9;
225 }
f587a77d 226 }
57acd2d2 227 return rv;
228}
f587a77d 229
57acd2d2 230//______________________________________________________________________________
4e25ac79 231void AliMUONQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
57acd2d2 232{
cddcc1f3 233 /// intialises QA and QA checker settings
4e25ac79 234 AliQAv1::Instance(det) ;
235 Float_t hiValue[AliQAv1::kNBIT] ;
236 Float_t lowValue[AliQAv1::kNBIT] ;
237 lowValue[AliQAv1::kINFO] = 0.999 ;
238 hiValue[AliQAv1::kINFO] = 1.0 ;
239 hiValue[AliQAv1::kWARNING] = 0.99 ;
240 lowValue[AliQAv1::kWARNING] = 0.5 ;
241 lowValue[AliQAv1::kERROR] = 0.0 ;
242 hiValue[AliQAv1::kERROR] = 0.5 ;
243 lowValue[AliQAv1::kFATAL] = -1.0 ;
244 hiValue[AliQAv1::kFATAL] = 0.0 ;
26b391fe 245 SetHiLo(&hiValue[0], &lowValue[0]) ;
f587a77d 246}
247
248//______________________________________________________________________________
249void
4e25ac79 250AliMUONQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
f587a77d 251{
ea49e931 252 /// sets the QA according the return value of the Check
f587a77d 253
4e25ac79 254 AliQAv1 * qa = AliQAv1::Instance(index);
f587a77d 255
57acd2d2 256 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 257 qa->UnSet(AliQAv1::kFATAL, specie);
258 qa->UnSet(AliQAv1::kWARNING, specie);
259 qa->UnSet(AliQAv1::kERROR, specie);
260 qa->UnSet(AliQAv1::kINFO, specie);
57acd2d2 261
262 if ( ! value ) { // No checker is implemented, set all QA to Fatal
4e25ac79 263 qa->Set(AliQAv1::kFATAL, specie) ;
57acd2d2 264 } else {
4e25ac79 265 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
266 qa->Set(AliQAv1::kFATAL, specie) ;
267 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
268 qa->Set(AliQAv1::kERROR, specie) ;
269 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
270 qa->Set(AliQAv1::kWARNING, specie) ;
271 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
272 qa->Set(AliQAv1::kINFO, specie) ;
57acd2d2 273 }
f587a77d 274 }
94b4cb08 275}