Removing obsolete option
[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"
5bb54f70 35#include "AliQA.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//______________________________________________________________________________
d1b21c1b 64Double_t
f587a77d 65AliMUONQAChecker::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 0.0;
72}
73
74//______________________________________________________________________________
d1b21c1b 75Double_t
f587a77d 76AliMUONQAChecker::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
5bb54f70 85 if ( index == AliQA::kREC)
86 {
87 return CheckRecPoints(list);
88 }
89
3119131e 90 if ( index == AliQA::kESD )
5bb54f70 91 {
92 return CheckESD(list);
93 }
94
f587a77d 95 AliWarning(Form("Checker for task %d not implement for the moment",index));
96 return 0.0;
97}
98
99//______________________________________________________________________________
5bb54f70 100TH1*
101AliMUONQAChecker::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//______________________________________________________________________________
94bf739c 113Double_t
5bb54f70 114AliMUONQAChecker::CheckRecPoints(TObjArray * list)
115{
116 /// Check rec points
117 /// Very binary check for the moment.
118
119 TH1* h = GetHisto(list,"hTrackerNumberOfClustersPerDE");
120
121 if ( !h ) return 0.75; // only a warning if histo not found, in order not to kill anything because QA failed...
122
e6cfc17e 123 if ( h->GetMean() == 0.0 ) return MarkHisto(*h,0.0);
5bb54f70 124
125 return 1.0;
126}
127
128//______________________________________________________________________________
94bf739c 129Double_t
e6cfc17e 130AliMUONQAChecker::MarkHisto(TH1& histo, Double_t value) const
131{
132 /// Mark histo as originator of some QA error/warning
133
134 if ( value != 1.0 )
135 {
136 histo.SetBit(AliQA::GetQABit());
137 }
138
139 return value;
140}
141
142//______________________________________________________________________________
94bf739c 143Double_t
5bb54f70 144AliMUONQAChecker::CheckESD(TObjArray * list)
145{
146 /// Check ESD
147
148 TH1* h = GetHisto(list,"hESDnTracks");
149
150 if (!h) return 0.75;
151
e6cfc17e 152 if ( h->GetMean() == 0.0 ) return MarkHisto(*h,0.0); // no track -> fatal
5bb54f70 153
154 h = GetHisto(list,"hESDMatchTrig");
155
156 if (!h) return 0.75;
157
e6cfc17e 158 if (h->GetMean() == 0.0 ) return MarkHisto(*h,0.25); // no trigger matching -> error
5bb54f70 159
160 return 1.0;
161}
162
163//______________________________________________________________________________
94bf739c 164Double_t
f587a77d 165AliMUONQAChecker::CheckRaws(TObjArray * list)
166{
ea49e931 167 /// Check raws
168
f587a77d 169 TIter next(list);
170 TObject* object;
171 AliMUONVTrackerData* data(0x0);
172
173 while ( (object=next()) && !data )
174 {
175 if (object->InheritsFrom("AliMUONVTrackerData"))
176 {
177 data = static_cast<AliMUONVTrackerData*>(object);
178 }
179 }
180
181 if ( !data )
182 {
183 AliError("Did not find TrackerData in the list !");
184 return 0.0;
185 }
186
187 AliMpManuIterator it;
188 Int_t detElemId;
189 Int_t manuId;
190 Int_t n50(0); // number of manus with occupancy above 0.5
191 Int_t n75(0); // number of manus with occupancy above 0.75
192 Int_t n(0); // number of manus with some occupancy
193
194 while ( it.Next(detElemId,manuId) )
195 {
196 Float_t occ = data->Manu(detElemId,manuId,2);
197 if (occ > 0 ) ++n;
198 if (occ >= 0.5 ) ++n50;
199 if (occ >= 0.75 ) ++n75;
200 }
201
202 AliInfo(Form("n %d n50 %d n75 %d",n,n50,n75));
203
204 if ( n == 0 )
205 {
206 AliError("Oups. Got zero occupancy in all manus ?!");
207 return 0.0;
208 }
209
210 if ( n75 )
211 {
212 AliError(Form("Got %d manus with occupancy above 0.75",n75));
213 return 0.1;
214 }
215
216 if ( n50 )
217 {
218 AliWarning(Form("Got %d manus with occupancy above 0.5",n50));
219 return 0.9;
220 }
221
222 return 1.0;
223}
224
225//______________________________________________________________________________
226void
227AliMUONQAChecker::SetQA(AliQA::ALITASK_t index, const Double_t value) const
228{
ea49e931 229 /// sets the QA according the return value of the Check
f587a77d 230
231 AliQA * qa = AliQA::Instance(index);
232
233 qa->UnSet(AliQA::kFATAL);
234 qa->UnSet(AliQA::kWARNING);
235 qa->UnSet(AliQA::kERROR);
236 qa->UnSet(AliQA::kINFO);
237
238 if ( value == 1.0 )
239 {
240 qa->Set(AliQA::kINFO);
241 }
242 else if ( value == 0.0 )
243 {
244 qa->Set(AliQA::kFATAL);
245 }
246 else if ( value > 0.5 )
247 {
248 qa->Set(AliQA::kWARNING);
249 }
250 else
251 {
252 qa->Set(AliQA::kERROR);
253 }
94b4cb08 254}