]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ACORDE/AliACORDEQAChecker.cxx
Update of AliACORDEQAChecker and AliACORDEQADataMakerSim(Yves) implementing one secon...
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEQAChecker.cxx
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"
36 #include "AliQA.h"
37 #include "AliQAChecker.h"
38 #include "AliACORDEQAChecker.h"
39 #include "AliCDBEntry.h"
40 #include "AliQAManager.h"
41
42 ClassImp(AliACORDEQAChecker)
43
44 //____________________________________________________________________________
45 Double_t * AliACORDEQAChecker::Check(AliQA::ALITASK_t /*index*/)
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 }
52
53 //__________________________________________________________________
54 Double_t * AliACORDEQAChecker::Check(AliQA::ALITASK_t /*index*/, TObjArray ** list)
55 {
56
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.
62   Double_t * test = new Double_t[AliRecoParam::kNSpecies] ; 
63   Int_t * count   = new Int_t[AliRecoParam::kNSpecies] ; 
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
70         char * acoOCDBDir = Form("ACORDE/%s/%s",AliQA::GetRefOCDBDirName(),AliQA::GetRefDataDirName());
71         AliCDBEntry *acoQARefDir = AliQAManager::QAManager()->Get(acoOCDBDir);
72
73
74   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
75     test[specie]    = 0.0 ; 
76     count[specie] = 0 ; 
77         acoTest[specie] = 0.0;
78   }
79   
80   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
81     if (list[specie]->GetEntries() == 0){  
82       test[specie] = 1. ; // nothing to check
83         acoTest[specie] = 1.;
84     }
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 ; 
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                 {
105                         AliWarning("Using the QA Reference data for ACORDE !!!");
106                         test[specie] = CheckAcordeRefHits(list[specie],(TObjArray *)acoQARefDir->GetObject());
107                         if ((test[specie] = 0.86) || (acoHitsNorm>0.50)) 
108                         {
109                                 acoRefTest[specie]=0.78;printf("testMario: %f\n",acoRefTest[specie]);
110                         }
111                 }else{
112                 AliWarning("Using the inner ACORDE QA Checker !!!");
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         }
119         }
120         else{
121           AliError("Data type cannot be processed") ;
122         }
123       }
124       if (count[specie] != 0) { 
125         if (test[specie]==0) {
126           AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
127           test[specie] = 0.5;  //upper limit value to set kWARNING flag for a task
128         }
129         else {
130         if (acoQARefDir) test[specie] = acoRefTest[specie];
131         else{
132         test[specie] = acoTest[specie];printf("testDyMa: %f\n",test[specie]);}
133         }
134       }
135     }
136     AliInfo(Form("Test Result = %f", test[specie])) ; 
137   }
138   return test ; 
139 }
140 Double_t AliACORDEQAChecker::CheckAcordeRefHits(TObjArray *AcordeList, TObjArray *AcordeRef) const
141 {
142         Double_t acoTest = 0;
143         TIter next(AcordeList);
144         TH1 * histo;
145         
146         while ( (histo = dynamic_cast<TH1 *>(next())) )
147         {
148                 if( histo->KolmogorovTest((TH1F *)AcordeRef->At(0))<0.8)  acoTest = 0.86;
149         }       
150         return acoTest;
151 }