Updates to AddTask macro from Chris
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerQAChecker.cxx
CommitLineData
ece56eb9 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 "AliMUONTriggerQAChecker.h"
19
20/// \class AliMUONTriggerQAChecker
21///
22/// Implementation of QAChecker for MTR
23///
24/// For the moment we only implement the checking of raw data QA for the trigger
25/// by looking at the local structure and trigger response errors.
26///
a026ce9e 27/// \author Diego Stocco, Subatech
ece56eb9 28
29
30#include "AliRecoParam.h"
6482f70b 31#include "AliMUONQAIndices.h"
ffaafee5 32#include "AliQAv1.h"
ece56eb9 33#include "TH1.h"
34#include "TPaveText.h"
35#include "TString.h"
36#include "TObjArray.h"
37#include "TList.h"
38
39/// \cond CLASSIMP
40ClassImp(AliMUONTriggerQAChecker)
41/// \endcond
42
43//__________________________________________________________________
44AliMUONTriggerQAChecker::AliMUONTriggerQAChecker() : AliMUONVQAChecker()
45{
46 /// ctor
47}
48
49//__________________________________________________________________
50AliMUONTriggerQAChecker::~AliMUONTriggerQAChecker()
51{
52 /// dtor
53}
54
55//______________________________________________________________________________
56AliMUONVQAChecker::ECheckCode
57AliMUONTriggerQAChecker::MarkHisto(TH1& histo, AliMUONVQAChecker::ECheckCode value) const
58{
59 /// Mark histo as originator of some QA error/warning
60
61 if ( value != AliMUONVQAChecker::kInfo )
62 {
63 histo.SetBit(AliQAv1::GetQABit());
64 }
65
66 return value;
67}
68
69//__________________________________________________________________
70AliMUONVQAChecker::ECheckCode*
486788fc 71AliMUONTriggerQAChecker::CheckRaws(TObjArray** list, const AliMUONRecoParam* )
ece56eb9 72{
73 /// Check raw data
74
81813481 75 AliMUONVQAChecker::ECheckCode * rv = new AliMUONVQAChecker::ECheckCode[AliRecoParam::kNSpecies];
ece56eb9 76
77 Int_t histoRawsPercentIndex[] = {
6482f70b 78 AliMUONQAIndices::kTriggerErrorSummaryNorm,
79 AliMUONQAIndices::kTriggerCalibSummaryNorm,
80 AliMUONQAIndices::kTriggerReadOutErrorsNorm
ece56eb9 81 };
82 const Int_t kNrawsHistos = sizeof(histoRawsPercentIndex)/sizeof(histoRawsPercentIndex[0]);
83
81813481 84 // BEGIN OF LIMITS
85 // Fixme: Move me to reference histos
86 Float_t safeFactor = 5.;
38a5dfec 87 Float_t warningPercentTrigAlgo[AliMUONQAIndices::kNtrigAlgoErrorBins] = {safeFactor*1., safeFactor*1., safeFactor*1., 100., 100., 100., 100., safeFactor*1., safeFactor*1., safeFactor*1.};
1c9a6054 88 Float_t warningPercentCalib[AliMUONQAIndices::kNtrigCalibSummaryBins] = {safeFactor*0.4, safeFactor*1., 3.1, 0.0001, safeFactor*0.4};
38a5dfec 89 Float_t warningPercentReadout[AliMUONQAIndices::kNtrigStructErrorBins] = {safeFactor*1., safeFactor*1., safeFactor*1., safeFactor*1.};
81813481 90
38a5dfec 91 Float_t* warningPercent[kNrawsHistos] = {warningPercentTrigAlgo, warningPercentCalib, warningPercentReadout};
92
93 Float_t errorFactor = 30.;
94 Float_t errorPercentTrigAlgo[AliMUONQAIndices::kNtrigAlgoErrorBins] = {errorFactor*1., errorFactor*1., errorFactor*1., 100., 100., 100., 100., errorFactor*1., errorFactor*1., errorFactor*1.};
1c9a6054 95 Float_t errorPercentCalib[AliMUONQAIndices::kNtrigCalibSummaryBins] = {errorFactor*0.4, errorFactor*1., 6.2, 3.*0.0001, errorFactor*0.4};
38a5dfec 96 Float_t errorPercentReadout[AliMUONQAIndices::kNtrigStructErrorBins] = {errorFactor*1., errorFactor*1., errorFactor*1., errorFactor*1.};
81813481 97 // END OF LIMTS
98
38a5dfec 99 Float_t* errorPercent[kNrawsHistos] = {errorPercentTrigAlgo, errorPercentCalib, errorPercentReadout};
100
81813481 101 TObjArray messages;
102 messages.SetOwner(kTRUE);
103
ece56eb9 104 TH1* currHisto = 0x0;
105 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
81813481 106 rv[specie] = AliMUONVQAChecker::kInfo;
81813481 107
fa7e0953 108 TH1* hAnalyzedEvents = AliQAv1::GetData(list,AliMUONQAIndices::kTriggerRawNAnalyzedEvents,AliRecoParam::ConvertIndex(specie));
81813481 109
38a5dfec 110 //if ( nAnalyzedEvents == 0 ) rv[specie] = AliMUONVQAChecker::kFatal;
81813481 111
ece56eb9 112 for(Int_t ihisto = 0; ihisto<kNrawsHistos; ihisto++){
1c9a6054 113 Int_t nAnalyzedEvents = 0;
114 Int_t ibinNevents = ( histoRawsPercentIndex[ihisto] == AliMUONQAIndices::kTriggerReadOutErrorsNorm ) ? 1 : 2;
115 if ( hAnalyzedEvents ) nAnalyzedEvents = TMath::Nint(hAnalyzedEvents->GetBinContent(ibinNevents));
6c0d43d8 116 AliMUONVQAChecker::ECheckCode currRv = AliMUONVQAChecker::kInfo;
81813481 117 messages.Clear();
ece56eb9 118 currHisto = AliQAv1::GetData(list,histoRawsPercentIndex[ihisto],AliRecoParam::ConvertIndex(specie));
81813481 119 if ( ! currHisto ) continue;
120
121 Int_t nbins = currHisto->GetXaxis()->GetNbins();
122 for (Int_t ibin = 1; ibin<=nbins; ibin++){
38a5dfec 123 Double_t binContent = currHisto->GetBinContent(ibin);
124 if ( binContent > errorPercent[ihisto][ibin-1] )
125 currRv = AliMUONVQAChecker::kError;
126 else if ( binContent > warningPercent[ihisto][ibin-1] )
127 currRv = AliMUONVQAChecker::kWarning;
128 else if ( ibin == 4 && binContent > 50. && AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib) {
129 messages.Add(new TObjString("Do not panic:"));
130 messages.Add(new TObjString("copy errors do not affect data"));
131 }
81813481 132 } // loop on bins
133 if ( currRv != AliMUONVQAChecker::kInfo ) {
134 switch ( histoRawsPercentIndex[ihisto] ) {
135 case AliMUONQAIndices::kTriggerErrorSummaryNorm:
136 case AliMUONQAIndices::kTriggerCalibSummaryNorm:
137 messages.Add(new TObjString("Trigger algo errors"));
138 break;
139 case AliMUONQAIndices::kTriggerReadOutErrorsNorm:
140 messages.Add(new TObjString("Readout errors"));
6c0d43d8 141 break;
ece56eb9 142 }
81813481 143 if ( currRv == AliMUONVQAChecker::kWarning )
144 messages.Add(new TObjString("are a little bit high"));
145 else if ( currRv == AliMUONVQAChecker::kError ||
146 currRv == AliMUONVQAChecker::kFatal )
147 messages.Add(new TObjString("are too high"));
148 }
38a5dfec 149 else if ( nAnalyzedEvents != 0 ) {
81813481 150 switch ( histoRawsPercentIndex[ihisto] ) {
151 case AliMUONQAIndices::kTriggerErrorSummaryNorm:
152 case AliMUONQAIndices::kTriggerCalibSummaryNorm:
153 case AliMUONQAIndices::kTriggerReadOutErrorsNorm:
154 messages.Add(new TObjString("Values within limits"));
155 break;
ece56eb9 156 }
ece56eb9 157 }
6c0d43d8 158 if ( MarkHisto(*currHisto, currRv) < rv[specie] )
159 rv[specie] = currRv;
81813481 160 currHisto->GetYaxis()->SetRangeUser(0., 110.);
1c9a6054 161 SetupHisto(nAnalyzedEvents, messages, *currHisto, currRv, specie);
ece56eb9 162 } // loop on histos
163 } // loop on species
164
165 return rv;
166}
167
168//__________________________________________________________________
169AliMUONVQAChecker::ECheckCode*
486788fc 170AliMUONTriggerQAChecker::CheckRecPoints(TObjArray** , const AliMUONRecoParam* )
ece56eb9 171{
172 /// Check rec points
173 return 0x0;
174}
175
176//__________________________________________________________________
177AliMUONVQAChecker::ECheckCode*
486788fc 178AliMUONTriggerQAChecker::CheckESD(TObjArray** , const AliMUONRecoParam* )
ece56eb9 179{
180 /// Check esd
181 return 0x0;
182}
81813481 183
184
185//___________________________________________________________________
1c9a6054 186void AliMUONTriggerQAChecker::SetupHisto(Int_t nevents, const TObjArray& messages, TH1& histo, AliMUONVQAChecker::ECheckCode code, Int_t esIndex)
81813481 187{
188 //
189 /// Add text to histos
190 //
191
38a5dfec 192 Double_t y1 = 0.87 - (messages.GetLast()+2)*0.075;
193 TPaveText* text = new TPaveText(0.25,y1,0.75,0.89,"NDC");
1c9a6054 194
195 Int_t eventLimit = ( AliRecoParam::ConvertIndex(esIndex) == AliRecoParam::kCalib ) ? 5 : 20;
196
197 text->AddText(Form("MTR - Specie: %s", AliRecoParam::GetEventSpecieName(esIndex)));
198 text->AddText(Form("Total events %i", nevents));
81813481 199
38a5dfec 200 TString defaultText = "";
81813481 201 Int_t color = 0;
38a5dfec 202
203 if ( nevents == 0 ) {
bd6fae1e 204 color = AliMUONVQAChecker::kFatalColor;
38a5dfec 205 defaultText = "No events analyzed!";
206 }
1c9a6054 207 else if ( nevents <= eventLimit ) {
38a5dfec 208 color = AliMUONVQAChecker::kWarningColor;
209 text->AddText("Not enough events to judge");
405d7b72 210 defaultText = "Please wait for more statistics";
38a5dfec 211 }
212 else {
405d7b72 213 TIter next(&messages);
214 TObjString* str;
215
216 while ( ( str = static_cast<TObjString*>(next()) ) ){
217 text->AddText(str->String());
218 }
219
38a5dfec 220 switch ( code ) {
221 case AliMUONVQAChecker::kInfo:
222 color = AliMUONVQAChecker::kInfoColor;
223 defaultText = "All is fine!";
224 break;
225 case AliMUONVQAChecker::kWarning:
226 color = AliMUONVQAChecker::kWarningColor;
227 defaultText = "Please keep an eye on it!";
228 break;
229 case AliMUONVQAChecker::kFatal:
230 color = AliMUONVQAChecker::kFatalColor;
231 defaultText = "PLEASE CALL MUON TRIGGER EXPERT!!!";
232 break;
233 default:
234 color = AliMUONVQAChecker::kErrorColor;
235 defaultText = "PLEASE CALL MUON TRIGGER EXPERT!";
236 break;
237 }
81813481 238 }
239
81813481 240 text->AddText(defaultText.Data());
241 text->SetFillColor(color);
242
243 histo.SetFillStyle(1001);
244 histo.SetFillColor(color);
245
246 histo.SetStats(kFALSE);
247
338fd726 248 histo.GetListOfFunctions()->Delete();
81813481 249 histo.GetListOfFunctions()->Add(text);
250}