Speed up CE code - Using floats instead of the TVectorF
[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 *
eedcd663 65AliMUONQAChecker::Check(AliQAv1::ALITASK_t index, TObjArray ** list, AliDetectorRecoParam * /*recoParam*/)
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
8f29b706 173 Bool_t IsAnyTrackerDataPresent = kFALSE;
57acd2d2 174 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
175 TIter next(list[specie]);
176 TObject* object;
177 AliMUONVTrackerData* data(0x0);
f587a77d 178
57acd2d2 179 while ( (object=next()) && !data )
180 {
181 if (object->InheritsFrom("AliMUONVTrackerData"))
182 {
183 data = static_cast<AliMUONVTrackerData*>(object);
184 }
185 }
f587a77d 186
57acd2d2 187 if ( !data )
188 {
8f29b706 189 AliWarning(Form("Did not find TrackerData for specie %s !",AliRecoParam::GetEventSpecieName(specie)));
190 continue;
57acd2d2 191 }
f587a77d 192
8f29b706 193 IsAnyTrackerDataPresent = kTRUE;
57acd2d2 194 AliMpManuIterator it;
195 Int_t detElemId;
196 Int_t manuId;
197 Int_t n50(0); // number of manus with occupancy above 0.5
198 Int_t n75(0); // number of manus with occupancy above 0.75
199 Int_t n(0); // number of manus with some occupancy
f587a77d 200
57acd2d2 201 while ( it.Next(detElemId,manuId) )
202 {
203 Float_t occ = data->Manu(detElemId,manuId,2);
204 if (occ > 0 ) ++n;
205 if (occ >= 0.5 ) ++n50;
206 if (occ >= 0.75 ) ++n75;
207 }
f587a77d 208
8f29b706 209 AliDebug(1,Form("n %d n50 %d n75 %d",n,n50,n75));
f587a77d 210
57acd2d2 211 if ( n == 0 )
212 {
213 AliError("Oups. Got zero occupancy in all manus ?!");
214 rv[specie] = 0.0;
215 }
f587a77d 216
57acd2d2 217 if ( n75 )
218 {
219 AliError(Form("Got %d manus with occupancy above 0.75",n75));
220 rv[specie] = 0.1;
221 }
f587a77d 222
57acd2d2 223 if ( n50 )
224 {
225 AliWarning(Form("Got %d manus with occupancy above 0.5",n50));
226 rv[specie] = 0.9;
227 }
f587a77d 228 }
8f29b706 229
230 if ( !IsAnyTrackerDataPresent )
231 {
232 AliError("Did not find any TrackerData in the list !");
233 return NULL;
234 }
235
57acd2d2 236 return rv;
237}
f587a77d 238
57acd2d2 239//______________________________________________________________________________
4e25ac79 240void AliMUONQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
57acd2d2 241{
cddcc1f3 242 /// intialises QA and QA checker settings
4e25ac79 243 AliQAv1::Instance(det) ;
244 Float_t hiValue[AliQAv1::kNBIT] ;
245 Float_t lowValue[AliQAv1::kNBIT] ;
246 lowValue[AliQAv1::kINFO] = 0.999 ;
247 hiValue[AliQAv1::kINFO] = 1.0 ;
248 hiValue[AliQAv1::kWARNING] = 0.99 ;
249 lowValue[AliQAv1::kWARNING] = 0.5 ;
250 lowValue[AliQAv1::kERROR] = 0.0 ;
251 hiValue[AliQAv1::kERROR] = 0.5 ;
252 lowValue[AliQAv1::kFATAL] = -1.0 ;
253 hiValue[AliQAv1::kFATAL] = 0.0 ;
26b391fe 254 SetHiLo(&hiValue[0], &lowValue[0]) ;
f587a77d 255}
256
257//______________________________________________________________________________
258void
4e25ac79 259AliMUONQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
f587a77d 260{
ea49e931 261 /// sets the QA according the return value of the Check
f587a77d 262
4e25ac79 263 AliQAv1 * qa = AliQAv1::Instance(index);
f587a77d 264
57acd2d2 265 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 266 qa->UnSet(AliQAv1::kFATAL, specie);
267 qa->UnSet(AliQAv1::kWARNING, specie);
268 qa->UnSet(AliQAv1::kERROR, specie);
269 qa->UnSet(AliQAv1::kINFO, specie);
57acd2d2 270
271 if ( ! value ) { // No checker is implemented, set all QA to Fatal
4e25ac79 272 qa->Set(AliQAv1::kFATAL, specie) ;
57acd2d2 273 } else {
4e25ac79 274 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
275 qa->Set(AliQAv1::kFATAL, specie) ;
276 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
277 qa->Set(AliQAv1::kERROR, specie) ;
278 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
279 qa->Set(AliQAv1::kWARNING, specie) ;
280 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
281 qa->Set(AliQAv1::kINFO, specie) ;
57acd2d2 282 }
f587a77d 283 }
94b4cb08 284}