fix minor bug: add task argument was not passed to tak
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEQAChecker.cxx
CommitLineData
51504028 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// Checks the quality assurance for ACORDE.
17// Default implementation
18// Authors:
19// Mario Rodriguez Cahuantzi <mrodrigu@mail.cern.ch> (FCFM-BUAP)
20// Luciano Diaz Gonzalez <luciano.diaz@nucleares.unam.mx> (ICN-UNAM)
21// Arturo Fernandez <afernan@mail.cern.ch> (FCFM-BUAP)
1b368017 22// Last update: Nov. 14t 2009 --> MRC <mrodrigu@mail.cern.ch> (FCFM-BUAP)
51504028 23//...
24
25// --- ROOT system ---
26#include <TClass.h>
27#include <TH1F.h>
28#include <TH1I.h>
29#include <TIterator.h>
30#include <TKey.h>
31#include <TFile.h>
dd1da44f 32#include <TPaveText.h>
33#include <TLine.h>
51504028 34// --- Standard library ---
35
36// --- AliRoot header files ---
37#include "AliLog.h"
4e25ac79 38#include "AliQAv1.h"
51504028 39#include "AliQAChecker.h"
40#include "AliACORDEQAChecker.h"
fcdfb1ff 41#include "AliCDBEntry.h"
42#include "AliQAManager.h"
51504028 43
dd1da44f 44/*************************************************************************
45 Last update: Oct. 10th 2011 from Mario RC, <mrodrigu@mail.cern.ch>
46 |-> Adding the checker class for raw and esd index
47 |-> Setting the threshold lines and box for DQM shifter
48
49*************************************************************************/
50
51504028 51ClassImp(AliACORDEQAChecker)
52
1b368017 53//____________________________________________________________________________
dd1da44f 54
55AliACORDEQAChecker::AliACORDEQAChecker() :
56AliQACheckerBase("ACORDE","ACORDE Quality Assurance Data Maker"),
e144815e 57fTextDQMShifterInfo(new TPaveText(2.2,0.90,2.9,0.99,"T")),
58fMax(new TLine(1,0.5,3,0.5))
dd1da44f 59{
60 // default constructor
61 fMax->SetLineColor(kGreen);
62 fMax->SetLineWidth(3);
dd1da44f 63}
64//____________________________________________________________________________
65AliACORDEQAChecker::~AliACORDEQAChecker()
66{
67 // destructor
68 delete fTextDQMShifterInfo;
69 delete fMax;
dd1da44f 70}
71//____________________________________________________________________________
72AliACORDEQAChecker::AliACORDEQAChecker(const AliACORDEQAChecker& qac) :
73AliQACheckerBase(qac.GetName(), qac.GetTitle()),
e144815e 74fTextDQMShifterInfo(new TPaveText(2.2,0.90,2.9,0.99,"T")),
12a90f05 75fMax(static_cast<TLine*>(qac.fMax->Clone()))
dd1da44f 76{
77 //
78}
79//____________________________________________________________________________
80AliACORDEQAChecker& AliACORDEQAChecker::operator = (const AliACORDEQAChecker &qac)
81{
81f0f392 82 // use cpy option from constructor
83 if (&qac==this) return *this;
84 new (this) AliACORDEQAChecker(qac);
dd1da44f 85 return *this;
86}
87//____________________________________________________________________________
86017bd8 88void AliACORDEQAChecker::Check(Double_t * test, AliQAv1::ALITASK_t /*index*/)
1b368017 89{
1b368017 90 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
86017bd8 91 test[specie] = 0.0 ;
1b368017 92}
93//____________________________________________________________________________
86017bd8 94void AliACORDEQAChecker::Check(Double_t * test, AliQAv1::ALITASK_t /*index*/, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
f307c383 95{
1b368017 96// Close version to the final one for the ACORDE QA Checker
57acd2d2 97
1b368017 98// Loop over the run species (for specie!= cosmic by now we set QA to INFO)
99
100 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
101 {
e144815e 102 test[specie] = 1.0;
1b368017 103 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue ;
86017bd8 104 if (list[specie]->GetEntries() == 0) test[specie] = 1.; // Nothing to check
1b368017 105 else
bd97a569 106 {
1b368017 107 TIter next(list[specie]) ;
108 TH1 * hdata ; // Data created by the AliACORDEQADataMakerXXX (Sim/Rec)
109 while ( (hdata = dynamic_cast<TH1 *>(next())) )
fcdfb1ff 110 {
e144815e 111 //if (hdata)
112 if (hdata->GetEntries()!=0)
bd97a569 113 {
1b368017 114 Double_t rv = 0.0 ;
115 if(hdata->GetEntries()>0) rv=1;
116 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv)) ;
117 TString hdataName = hdata->GetName();
12a90f05 118 //if (hdata->GetListOfFunctions()->GetEntries() == 0) continue;
e144815e 119
120 if (hdataName.Contains("fhACORDEStatusAMU_DQM"))
121 {
df4e2848 122 if (!hdata->GetListOfFunctions()->Contains(fTextDQMShifterInfo))
e144815e 123 hdata->GetListOfFunctions()->Add(fTextDQMShifterInfo);
df4e2848 124 if (!hdata->GetListOfFunctions()->Contains(fMax))
e144815e 125 hdata->GetListOfFunctions()->Add(fMax);
dd1da44f 126 }
e144815e 127 // check with OCDB ref. data
1b368017 128 if ( (fRefOCDBSubDir[specie]) && (hdataName.Contains("ACORDEBitPattern")) )
bd97a569 129 {
1b368017 130 TH1 * href = NULL;
131 if (fRefSubDir) href = static_cast<TH1*>(fRefSubDir->Get(hdata->GetName()));
132 else if (fRefOCDBSubDir[specie]) href = static_cast<TH1*>(fRefOCDBSubDir[specie]->FindObject(hdata->GetName()));
86017bd8 133 test[specie] = CheckAcordeRefHits(href,hdata);
e144815e 134 }else
bd97a569 135 {
e144815e 136 if (hdataName.Contains("ACORDEBitPattern"))
137 // Here we use an inner QA Checher without the QAref data
bd97a569 138 {
e144815e 139 Float_t acoDataMax = hdata->GetMaximum();
140 Int_t flagAcoQAChecker = 0;
141 if (acoDataMax == 0) continue;
142 for(Int_t i=0;i<60;i++)
143 {
144 if ((hdata->GetBinContent(i)/acoDataMax) < 0.75) flagAcoQAChecker++;
145 }
dd1da44f 146 Double_t simpleFlag = 1.-flagAcoQAChecker/60.;
147 if ( (simpleFlag >= 0.90) && (simpleFlag <= 1.0) ) test[specie] = 0.75; // INFO
148 if ( (simpleFlag >= 0.70) && (simpleFlag < 0.90) ) test[specie] = 0.50; // WARNING
149 if ( (simpleFlag >= 0.25) && (simpleFlag < 0.70) ) test[specie] = 0.25; // ERROR
150 if ( (simpleFlag >= 0.0) && (simpleFlag < 0.25) ) test[specie] = -1.0; // FATAL
e144815e 151 if (test[specie]>0) rv = test[specie];
152 else rv = 1.0;
dd1da44f 153 }
12a90f05 154 if (hdataName.Contains("fhACORDEStatusAMU_DQM"))
155 {
e144815e 156 Float_t goodModules = hdata->GetBinContent(1);
157 Float_t badModules = hdata->GetBinContent(2);
158 if (goodModules >= badModules)
12a90f05 159 test[specie] = 0.75;
e144815e 160 else test[specie] = 0.30;
161
162 } // check for DQM condition
163 rv = test[specie];
164 if (fTextDQMShifterInfo) // DQM-flag asignment
165 {
166 fTextDQMShifterInfo->Clear();
167 if (rv > 0.4){
168 fTextDQMShifterInfo->SetFillColor(kGreen);
169 fTextDQMShifterInfo->AddText("ACORDE: O.K.");
170 }else{
171 fTextDQMShifterInfo->SetFillColor(kRed);
172 fTextDQMShifterInfo->AddText("ACORDE: Not, O.K.");
173 }
174 } // end DQM flag asignment
175 }// NO OCDB checking
176 } // hdata with entries
177 else AliError("Data type cannot be processed") ;
178 } // loop over histograms from QADataMaker
179 } // end checker
86017bd8 180 if ( (specie == AliRecoParam::kHighMult) || (specie == AliRecoParam::kLowMult) || (specie == AliRecoParam::kCalib) ) test[specie] = 0.75;
e144815e 181 } // end of species
f307c383 182}
1b368017 183//____________________________________________________________________________
184Double_t AliACORDEQAChecker::CheckAcordeRefHits(const TH1 * href, const TH1 * hdata) const
fcdfb1ff 185{
86017bd8 186 Double_t test = 0.;
1b368017 187 Int_t flag=0;
188 for (Int_t i=0;i<60;i++)
fcdfb1ff 189 {
0200d7cf 190 if (TMath::Abs(href->GetBinContent(i)-hdata->GetBinContent(i))>10) flag++;
bd97a569 191 }
86017bd8 192 if ((flag>50)&&(flag<=60)) test = -1.;
193 if ((flag>30)&&(flag<=50)) test = 0.25;
194 if ((flag>10)&&(flag<=30)) test = 0.5;
195 if ((flag>0)&&(flag<=10)) test = 0.75;
196 return test;
fcdfb1ff 197}