Fixes for bug #49914: Compilation breaks in trunk, and bug #48629: Trunk cannot read...
[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)
22//...
23
24// --- ROOT system ---
25#include <TClass.h>
26#include <TH1F.h>
27#include <TH1I.h>
28#include <TIterator.h>
29#include <TKey.h>
30#include <TFile.h>
31
32// --- Standard library ---
33
34// --- AliRoot header files ---
35#include "AliLog.h"
4e25ac79 36#include "AliQAv1.h"
51504028 37#include "AliQAChecker.h"
38#include "AliACORDEQAChecker.h"
fcdfb1ff 39#include "AliCDBEntry.h"
40#include "AliQAManager.h"
51504028 41
42ClassImp(AliACORDEQAChecker)
43
57acd2d2 44//____________________________________________________________________________
4e25ac79 45Double_t * AliACORDEQAChecker::Check(AliQAv1::ALITASK_t /*index*/)
57acd2d2 46{
47 Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
48 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
49 rv[specie] = 0.0 ;
50 return rv ;
51}
f307c383 52
57acd2d2 53//__________________________________________________________________
4e25ac79 54Double_t * AliACORDEQAChecker::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** list)
f307c383 55{
56
fcdfb1ff 57 // We added one check to the ACORDE's QA histograms:
58 // 1.- We check if they are empty
59 // we check for the reference histogram to start the QAChecker. If not QAref object
60 // is found, we check that the number of hits per channel is not so far from
61 // the maximum number of hits.
57acd2d2 62 Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
63 Int_t * count = new Int_t[AliRecoParam::kNSpecies] ;
fcdfb1ff 64 Double_t * acoTest = new Double_t[AliRecoParam::kNSpecies];
65 Double_t acoHitsNorm = 0;
66 Double_t * acoRefTest = new Double_t[AliRecoParam::kNSpecies];
67
68 // Look at the QAref data for ACORDE
69
4e25ac79 70 char * acoOCDBDir = Form("ACORDE/%s/%s",AliQAv1::GetRefOCDBDirName(),AliQAv1::GetRefDataDirName());
fcdfb1ff 71 AliCDBEntry *acoQARefDir = AliQAManager::QAManager()->Get(acoOCDBDir);
72
73
57acd2d2 74 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
75 test[specie] = 0.0 ;
76 count[specie] = 0 ;
fcdfb1ff 77 acoTest[specie] = 0.0;
f307c383 78 }
57acd2d2 79
80 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
81 if (list[specie]->GetEntries() == 0){
82 test[specie] = 1. ; // nothing to check
fcdfb1ff 83 acoTest[specie] = 1.;
f307c383 84 }
57acd2d2 85 else {
86 TIter next(list[specie]) ;
87 TH1 * hdata ;
88 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
89 if (hdata) {
90 Double_t rv = 0.0 ;
91 if(hdata->GetEntries()>0)rv=1;
92 AliInfo(Form("%s -> %f", hdata->GetName(), rv)) ;
93 count[specie]++ ;
94 test[specie] += rv ;
fcdfb1ff 95
96
97 // here we implement the second version for ACORDEQAChecker
98 // by the moment we only compare that the hits in every ACORDE's channel
99 // are close and > 0
100 for (Int_t i=0;i<60;i++)
101 {
102 acoHitsNorm = hdata->GetBinContent(i)/hdata->GetMaximum();
103 if (acoQARefDir)
104 {
4662d69c 105 // AliWarning("Using the QA Reference data for ACORDE !!!");
fcdfb1ff 106 test[specie] = CheckAcordeRefHits(list[specie],(TObjArray *)acoQARefDir->GetObject());
107 if ((test[specie] = 0.86) || (acoHitsNorm>0.50))
108 {
4662d69c 109 acoRefTest[specie]=0.78;//printf("testMario: %f\n",acoRefTest[specie]);printf("histo:%f\n",hdata->GetMaximum());
fcdfb1ff 110 }
111 }else{
4662d69c 112 // AliWarning("Using the inner ACORDE QA Checker !!!");
fcdfb1ff 113 if ( (acoHitsNorm>0.40) && (acoHitsNorm<=1) ) acoTest[specie] = 0.75;
114 if ( (acoHitsNorm>0.0020) && (acoHitsNorm<=0.40) ) acoTest[specie] = 0.251;
115 if ( (acoHitsNorm>0.0) && (acoHitsNorm<=0.0020) ) acoTest[specie] = 0.0010;
116 if ( (acoHitsNorm>-1.0) && (acoHitsNorm<=0.0) ) acoTest[specie] = -0.5;
117 }
118 }
57acd2d2 119 }
120 else{
121 AliError("Data type cannot be processed") ;
122 }
f307c383 123 }
57acd2d2 124 if (count[specie] != 0) {
125 if (test[specie]==0) {
4662d69c 126 // AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
57acd2d2 127 test[specie] = 0.5; //upper limit value to set kWARNING flag for a task
128 }
129 else {
fcdfb1ff 130 if (acoQARefDir) test[specie] = acoRefTest[specie];
131 else{
4662d69c 132 test[specie] = acoTest[specie];//printf("testDyMa: %f\n",test[specie]);
133 }
57acd2d2 134 }
f307c383 135 }
136 }
4662d69c 137 // AliInfo(Form("Test Result = %f", test[specie])) ;
f307c383 138 }
f307c383 139 return test ;
f307c383 140}
f6f88056 141Double_t AliACORDEQAChecker::CheckAcordeRefHits(TObjArray *AcordeList, TObjArray * /*AcordeRef */) const
fcdfb1ff 142{
143 Double_t acoTest = 0;
144 TIter next(AcordeList);
4662d69c 145 TH1 *histo;
146 for (Int_t i=0;i<60;i++)
fcdfb1ff 147 {
4662d69c 148 while ( (histo = dynamic_cast<TH1 *>(next())) )
149 {
1b70710b 150 if (histo->GetMaximum() && ((histo->GetBinContent(i)/histo->GetMaximum())<1.0) ) acoTest = 0.86;
4662d69c 151// if( histo->KolmogorovTest((TH1F *)AcordeRef->At(0))<0.8) acoTest = 0.86;
152 //printf("href:%f\n",histo->GetMaximum());
153 }
fcdfb1ff 154 }
155 return acoTest;
156}