]> git.uio.no Git - u/mrichter/AliRoot.git/blob - T0/AliT0QAChecker.cxx
protection if aplitude calibration for some PMT does not exist
[u/mrichter/AliRoot.git] / T0 / AliT0QAChecker.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. 
17 //  By comparing with reference data
18 //  Skeleton for T0
19 //---------------------------------------------
20 //checkig without reference data:
21 //for RAW QA all histograms should have approximatly the same 
22 //number of entries as RefPoint
23 //for Rec Points checks 
24 //  - amplitude measured by 2 methos
25 //  - online and offline T0 measurements
26 // for ESD quality of reconstruction ( and measurements):
27 // RMS of vertex and T0 less than 75ps
28 //
29 // Alla.Maevskaya@cern.ch   
30 //...
31
32 // --- ROOT system ---
33 #include <Riostream.h>
34 #include <TClass.h>
35 #include <TH1F.h> 
36 #include <TF1.h> 
37 #include <TFitResultPtr.h>
38 #include <TH2.h> 
39 #include <TIterator.h> 
40 #include <TKey.h> 
41 #include <TFile.h> 
42 #include <TMath.h>
43 #include <TString.h>
44 #include <TPaveText.h>
45
46 // --- Standard library ---
47
48 // --- AliRoot header files ---
49 #include "AliLog.h"
50 #include "AliQAv1.h"
51 #include "AliQAChecker.h"
52 #include "AliCDBEntry.h"
53 #include "AliQAManager.h"
54 #include "AliT0QAChecker.h"
55
56 ClassImp(AliT0QAChecker)
57 //____________________________________________________________________________
58 AliT0QAChecker::AliT0QAChecker() :
59 AliQACheckerBase("T0","T0 Quality Assurance Checker")
60
61 {
62   // Standard constructor
63
64 }
65
66 //____________________________________________________________________________
67 AliT0QAChecker::AliT0QAChecker(const AliT0QAChecker& qac):
68   AliQACheckerBase(qac.GetName(), qac.GetTitle()) 
69 {
70   // copy constructor
71   AliError("Copy should not be used with this class\n");
72 }
73 //____________________________________________________________________________
74 AliT0QAChecker& AliT0QAChecker::operator=(const AliT0QAChecker& qac){
75   // assignment operator
76   this->~AliT0QAChecker();
77   new(this)AliT0QAChecker(qac);
78   return *this;
79 }
80
81
82 //____________________________________________________________________________
83 AliT0QAChecker::~AliT0QAChecker(){
84   // destructor
85
86 }
87
88 //__________________________________________________________________
89 void AliT0QAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
90 {
91
92   // Super-basic check on the QA histograms on the input list:
93   // look whether they are empty!
94     
95  char * detOCDBDir = Form("T0/%s/%s", AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ; 
96
97   AliCDBEntry *QARefRec = AliQAManager::QAManager()->Get(detOCDBDir);
98   //  QARefRec->Dump();
99   if( !QARefRec){
100     AliInfo("QA reference data NOT retrieved for Reconstruction check. No T0 reference distribution");
101   }
102   
103   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) 
104     test[specie]    = 10.0 ; 
105
106   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
107     //  TString dataType = AliQAv1::GetAliTaskName(index);
108     if (!(AliQAv1::Instance()->IsEventSpecieSet(specie) && list[specie]) || list[specie]->GetEntries() == 0) {
109       test[specie] = 1. ; // nothing to check
110       continue;
111     }
112     if (index == AliQAv1::kRAW && AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib)
113       //      if (index == AliQAv1::kRAW )
114       {
115         test[specie] = CheckRaw(list[specie]);
116       }
117     if (index == AliQAv1::kESD && AliRecoParam::Convert(specie) != AliRecoParam::kCalib)
118       test[specie] = CheckESD(list[specie]);
119     //
120   }
121 }
122
123 //--------------------------------------------------------------------------
124 Double_t AliT0QAChecker::CheckRaw(TObjArray *listrec) const
125 {
126    Float_t checkr = 0;
127    
128   TString hname[10];
129    TH1*hdata; 
130    const char *cname;
131    TH1 *fhRawEff[10];
132    Int_t nh=0;
133  
134
135    //   Int_t nnn[4] = { 420, 458, 459, 460};
136    Int_t nnn[4] = { 170, 208, 209, 210};
137    for (Int_t ir=0; ir<4; ir++)
138      {
139          hdata = (TH1*) listrec->UncheckedAt(nnn[ir]);
140          if(hdata) {
141            cname = hdata->GetName();
142            hname[ir] = cname;
143            fhRawEff[nh] = hdata;
144            nh++;
145          }
146     }
147      
148    TLine *linelowyellow = new TLine(0, 0.7, 24, 0.7);    
149    linelowyellow->SetLineColor(5);
150    linelowyellow->SetLineStyle(3);
151    linelowyellow->SetLineWidth(4);
152    TLine *linelowred = new TLine(0, 0.2, 24, 0.2);    
153    linelowred->SetLineColor(2);
154    linelowred->SetLineStyle(3);
155    linelowred->SetLineWidth(4);
156
157    Float_t thryell = 0.7;
158    //   TPaveText* text = new TPaveText(0.30,0.50,0.99,0.99,"NDC");    
159    Float_t thrred = 0.2;
160    Float_t chcont =0;
161     for (Int_t ih= 0; ih<4; ih++)
162      { 
163        fhRawEff[ih]->SetLineWidth(2);
164        fhRawEff[ih]->SetMaximum(2.);
165        fhRawEff[ih]->SetMinimum(0.);
166        fhRawEff[ih]->GetListOfFunctions()->Add(linelowyellow);
167        fhRawEff[ih]->GetListOfFunctions()->Add(linelowred);
168
169        Int_t nbins= fhRawEff[ih]->GetNbinsX();
170        Bool_t yell = kFALSE;
171        Bool_t red = kFALSE;
172        for (Int_t in=1; in<nbins-1; in++)
173          {
174            if(ih==0 && in==5) continue;
175            chcont=fhRawEff[ih]->GetBinContent(in);
176            if (chcont < thryell  ) yell = kTRUE;
177            if (chcont < thrred  ) red = kTRUE;
178          }
179        
180        if (! yell && !red) {
181          AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s  is good", fhRawEff[ih]->GetName() ));
182          checkr=1.;
183          //      text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
184          //      text->AddText(Form(" No problems "));
185          //      text->SetFillColor(3);
186        }
187        
188        if(red ) {
189          checkr = 0.;
190          AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s  is not so good", fhRawEff[ih]->GetName() ));
191          //      text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
192          //      text->AddText(Form("Very serious problem, call expert "));
193          //      text->SetFillColor(2);
194        }
195        
196        if ( yell && !red) {
197          AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s  is not so good", fhRawEff[ih]->GetName() ));
198          checkr=0.75;
199          //      text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
200          //      text->AddText(Form("Some problems "));
201          //      text->SetFillColor(5);
202       }
203        // fhRawEff[ih]->GetListOfFunctions()->Add(text);        
204
205      }
206   return checkr;
207   
208 }
209
210
211 //--------------------------------------------------------------------------
212 Double_t AliT0QAChecker::CheckESD(TObjArray *listrec ) const
213 {
214   Float_t checkr = 0;
215   TH1 *fhESD;
216  
217   fhESD  = (TH1*) listrec->UncheckedAt(2);
218   if(fhESD){
219     AliDebug(AliQAv1::GetQADebugLevel(), Form("count %s ", fhESD->GetName()) );
220      TF1 *f1 = new TF1("f1","gaus",-1,1);
221     fhESD->Fit("f1","R","Q", -1,1);
222     Double_t par[3];
223     f1->GetParameters(&par[0]);
224     
225     TPaveText* text = new TPaveText(0.30,0.50,0.99,0.99,"NDC");
226     
227     text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
228     
229     AliDebug(AliQAv1::GetQADebugLevel(), Form("numentries %d mean %f  #sigma %f", (int)fhESD->GetEntries(),par[1], par[2]));
230     
231     
232     if (par[2] > 0.07 && par[2] < 1.) {
233       checkr=0.5;
234        text->AddText(Form("not good resolution :\n %f ns\n", par[2] ));
235        text->SetFillColor(5);
236        printf("T0 detector resolution is not good enouph: %f ns\n",par[2] );
237     }
238     if(TMath::Abs(par[1])>0.05) {
239       checkr = 0.5;
240       text->AddText(Form(" Check clock shift on %f ns", par[1]));
241       text->SetFillColor(5);
242     }
243     if (par[2] >  1. || TMath::Abs(par[1])>0.1) {
244       checkr = 0.25;
245       text->AddText(Form(" Bad resolution:\n mean %f ns sigma %f ns", par[1], par[2]));
246       text->SetFillColor(2);
247       
248       fhESD->GetListOfFunctions()->Add(text);   
249        AliDebug(AliQAv1::GetQADebugLevel(),
250                 Form("Please, check calibration: shift= %f resolution %f test=%f\n",
251                      par[1], par[2], checkr) ) ; 
252     }
253   }
254   else
255     {
256       AliDebug(AliQAv1::GetQADebugLevel(),
257                Form("No ESD QA histogram found, nothing to check"));
258         checkr=0;
259     }
260   
261   
262   return checkr;
263 }