]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZEROQAChecker.cxx
ATO-98 make macro to calculate correction derivative again working
[u/mrichter/AliRoot.git] / VZERO / AliVZEROQAChecker.cxx
CommitLineData
508b9fc0 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
17/*
7cde7f18 18 Checks the quality assurance. Under construction.
508b9fc0 19 By comparing with reference data
20
21*/
22
23// --- ROOT system ---
24#include <TClass.h>
25#include <TH1F.h>
26#include <TH1I.h>
27#include <TIterator.h>
28#include <TKey.h>
29#include <TFile.h>
30
31// --- Standard library ---
32
33// --- AliRoot header files ---
34#include "AliLog.h"
4e25ac79 35#include "AliQAv1.h"
508b9fc0 36#include "AliQAChecker.h"
37#include "AliVZEROQAChecker.h"
5feb4a9e 38#include "AliVZEROQADataMakerRec.h"
508b9fc0 39
40ClassImp(AliVZEROQAChecker)
41
42//__________________________________________________________________
9a84e5f1 43AliVZEROQAChecker::AliVZEROQAChecker() : AliQACheckerBase("VZERO","VZERO Quality Assurance Data Checker"),
44 fLowEventCut(1000),
45 fORvsANDCut(0.2),
46 fBGvsBBCut(0.2)
427ef3a5 47{
9a84e5f1 48 // Default constructor
49 // Nothing else here
50}
427ef3a5 51
9a84e5f1 52//__________________________________________________________________
53void AliVZEROQAChecker::Check(Double_t * check, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
54{
55 // Main check function: Depending on the TASK, different checks will be applied
56 // Check for missing channels and check on the trigger type for raw data
57 // Check for missing disk or rings for esd (to be redone)
427ef3a5 58
57acd2d2 59 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
9a84e5f1 60 check[specie] = 1.0;
61 // no check on cosmic or calibration events
62 if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib)
63 continue;
4e25ac79 64 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
9a84e5f1 65 continue;
66 if (index == AliQAv1::kRAW) {
67 check[specie] = CheckRaws(list[specie]);
68 } else if (index == AliQAv1::kESD) {
69 // Check for one disk missing (FATAL) or one ring missing (ERROR) in ESDs (to be redone)
70 check[specie] = CheckEsds(list[specie]);
57acd2d2 71 }
72 }
427ef3a5 73}
57acd2d2 74
427ef3a5 75//_________________________________________________________________
9a84e5f1 76Double_t AliVZEROQAChecker::CheckRaws(TObjArray * list) const
427ef3a5 77{
5feb4a9e 78
9a84e5f1 79 // Check on the QA histograms on the raw-data input list:
80 // Two things are checked: the presence of data in all channels and
81 // the ratio between different trigger types
7cde7f18 82
9a84e5f1 83 Double_t test = 1.0;
427ef3a5 84 if (list->GetEntries() == 0){
9a84e5f1 85 AliWarning("There are no histograms to be checked");
5feb4a9e 86 } else {
9a84e5f1 87 TH1F *hTriggers = (TH1F*)list->At(AliVZEROQADataMakerRec::kTriggers);
88 if (!hTriggers) {
89 AliWarning("Trigger type histogram is not found");
90 }
91 else if (hTriggers->GetEntries() < fLowEventCut) {
92 AliInfo("Not enough events to perform QA checks");
93 }
94 else {
95 Double_t nANDs = hTriggers->GetBinContent(hTriggers->FindBin(0));
96 Double_t nORs = hTriggers->GetBinContent(hTriggers->FindBin(1));
97 Double_t nBGAs = hTriggers->GetBinContent(hTriggers->FindBin(2));
98 Double_t nBGCs = hTriggers->GetBinContent(hTriggers->FindBin(3));
99 if ((nORs - nANDs) > fORvsANDCut*nANDs) test = 0.001;
100 if ((nBGAs + nBGCs) > fBGvsBBCut*nANDs) test = 0.002;
101 }
102 TH1F *hBBflags = (TH1F*)list->At(AliVZEROQADataMakerRec::kBBFlagsPerChannel);
103 if (!hBBflags) {
104 AliWarning("BB-flags per channel histogram is not found");
105 }
106 else if (hBBflags->GetEntries() < fLowEventCut) {
107 AliInfo("Not enough events to perform QA checks");
108 }
109 else {
110 for(Int_t iBin = 1; iBin <= 64; ++iBin) {
111 if (hBBflags->GetBinContent(iBin) < 1.0) test = -1.0;
112 }
113 }
427ef3a5 114 }
427ef3a5 115 return test ;
116}
148dbed9 117
118//_________________________________________________________________
119Double_t AliVZEROQAChecker::CheckEsds(TObjArray * list) const
120{
121
122// check the ESDs for missing disk or ring
148dbed9 123// printf(" Number of entries in ESD list = %d\n", list->GetEntries());
124// list->Print();
125
126 Double_t test = 1.0; // initialisation to OK
5fc205b9 127 Int_t histonb = 0;
128 Double_t multV0A = 0.0;
129 Double_t multV0C = 0.0;
130 Double_t v0ABBRing[4], v0CBBRing[4];
131 Double_t v0ABGRing[4], v0CBGRing[4];
148dbed9 132 for (Int_t i=0; i<4; i++) {
5fc205b9 133 v0ABBRing[i]= v0CBBRing[i]= 0.0;
134 v0ABGRing[i]= v0CBGRing[i]= 0.0;
148dbed9 135 }
136 TIter next(list) ;
137 TH1 * hdata ;
138
139 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
5feb4a9e 140 if (hdata) {
5fc205b9 141 switch (histonb) {
5feb4a9e 142 case AliVZEROQADataMakerRec::kCellMultiV0A:
5fc205b9 143 multV0A = hdata->GetMean();
5feb4a9e 144 break;
145 case AliVZEROQADataMakerRec::kCellMultiV0C:
5fc205b9 146 multV0C = hdata->GetMean();
5feb4a9e 147 break;
148 case AliVZEROQADataMakerRec::kBBFlag:
149 for (Int_t i=0; i<8; i++) {
5fc205b9 150 if(i<4) v0CBBRing[i] = hdata->Integral((i*8)+1, (i*8) +8);
151 else v0ABBRing[i-4] = hdata->Integral((i*8)+1, (i*8) +8);
5feb4a9e 152 }
153 break;
154 case AliVZEROQADataMakerRec::kBGFlag:
155 for (Int_t i=0; i<8; i++) {
5fc205b9 156 if(i<4) v0CBGRing[i] = hdata->Integral((i*8)+1, (i*8) +8);
157 else v0ABGRing[i-4] = hdata->Integral((i*8)+1, (i*8) +8);
5feb4a9e 158 }
159 break;
160 }
161 }
5fc205b9 162 histonb++;
148dbed9 163 }
164
5fc205b9 165 if(multV0A == 0.0 || multV0C == 0.0) {
148dbed9 166 AliWarning(Form("One of the two disks is missing !") );
167 test = 0.0; // bit FATAL set
168 }
5fc205b9 169 if( v0ABBRing[0]+v0ABGRing[0] == 0.0 ||
170 v0ABBRing[1]+v0ABGRing[1] == 0.0 ||
171 v0ABBRing[2]+v0ABGRing[2] == 0.0 ||
172 v0ABBRing[3]+v0ABGRing[3] == 0.0 ||
173 v0CBBRing[0]+v0CBGRing[0] == 0.0 ||
174 v0CBBRing[1]+v0CBGRing[1] == 0.0 ||
175 v0CBBRing[2]+v0CBGRing[2] == 0.0 ||
176 v0CBBRing[3]+v0CBGRing[3] == 0.0 ){
148dbed9 177 AliWarning(Form("One ring is missing !") );
178 test = 0.1; // bit ERROR set
179 }
180
181 return test ;
182}
5feb4a9e 183
427ef3a5 184//______________________________________________________________________________
4e25ac79 185void AliVZEROQAChecker::Init(const AliQAv1::DETECTORINDEX_t det)
57acd2d2 186{
187 // intialises QA and QA checker settings
4e25ac79 188 AliQAv1::Instance(det) ;
189 Float_t * hiValue = new Float_t[AliQAv1::kNBIT] ;
190 Float_t * lowValue = new Float_t[AliQAv1::kNBIT] ;
191 lowValue[AliQAv1::kINFO] = 0.5 ;
192 hiValue[AliQAv1::kINFO] = 1.0 ;
193 lowValue[AliQAv1::kWARNING] = 0.2 ;
194 hiValue[AliQAv1::kWARNING] = 0.5 ;
195 lowValue[AliQAv1::kERROR] = 0.0 ;
196 hiValue[AliQAv1::kERROR] = 0.2 ;
197 lowValue[AliQAv1::kFATAL] = -1.0 ;
198 hiValue[AliQAv1::kFATAL] = 0.0 ;
57acd2d2 199 SetHiLo(hiValue, lowValue) ;
127e0d90 200 delete [] hiValue;
201 delete [] lowValue;
57acd2d2 202}
203
204//______________________________________________________________________________
4e25ac79 205void AliVZEROQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
427ef3a5 206{
7cde7f18 207// sets the QA word according to return value of the Check
4e25ac79 208 AliQAv1 * qa = AliQAv1::Instance(index);
57acd2d2 209 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
4e25ac79 210 qa->UnSet(AliQAv1::kFATAL, specie);
211 qa->UnSet(AliQAv1::kWARNING, specie);
212 qa->UnSet(AliQAv1::kERROR, specie);
213 qa->UnSet(AliQAv1::kINFO, specie);
57acd2d2 214 if ( ! value ) { // No checker is implemented, set all QA to Fatal
4e25ac79 215 qa->Set(AliQAv1::kFATAL, specie) ;
57acd2d2 216 } else {
4e25ac79 217 if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] )
218 qa->Set(AliQAv1::kFATAL, specie) ;
219 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
220 qa->Set(AliQAv1::kERROR, specie) ;
221 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
222 qa->Set(AliQAv1::kWARNING, specie) ;
223 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
224 qa->Set(AliQAv1::kINFO, specie) ;
57acd2d2 225 }
226 }
427ef3a5 227}
148dbed9 228