]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASPDChecker.cxx
Updates for pile-up vertex (F. Prino)
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDChecker.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, 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 /* $Id $ */
17
18 // *****************************************
19 //  Checks the quality assurance 
20 //  by comparing with reference data
21 //  P. Cerello Apr 2008
22 //  INFN Torino
23
24 // --- ROOT system ---
25 #include "TH1.h"
26 #include "TString.h"
27
28 // --- AliRoot header files ---
29 #include "AliITSQASPDChecker.h"
30 #include "AliITSQADataMakerRec.h"
31 #include "AliLog.h"
32
33 ClassImp(AliITSQASPDChecker)
34 //__________________________________________________________________
35 AliITSQASPDChecker& AliITSQASPDChecker::operator = (const AliITSQASPDChecker& qac ) 
36 {
37   // Equal operator.
38   this->~AliITSQASPDChecker();
39   new(this) AliITSQASPDChecker(qac);
40   return *this;
41 }
42
43
44 //__________________________________________________________________
45 Double_t AliITSQASPDChecker::Check(AliQAv1::ALITASK_t index, TObjArray * list, const AliDetectorRecoParam * /*recoParam*/)
46 {
47 //
48 // General methods for SPD Cheks to be used in RAWS and REC ALITASK_t
49 //
50
51   AliDebug(2, Form("AliITSQASPDChecker called with offset: %d\n", fSubDetOffset));
52
53   Double_t test = 0.0;
54   Int_t count = 0;
55   // Checks for ALITASK_t AliQAv1::kRAW
56   if(index == AliQAv1::kRAW) {
57   return CheckRawData(list);
58   } else {
59   if (list->GetEntries() == 0) {
60     test = 1.; // nothing to check
61   }
62   else {
63     TIter next(list);
64     TH1 * hdata;
65     count = 0;
66     while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
67       if (hdata) {
68         TString histName = hdata->GetName();
69         if (!histName.Contains("_SPD")) continue;
70         Double_t rv = 0.;
71         if (hdata->GetEntries()>0) rv = 1;
72         if (histName.Contains("LayPattern")) {
73          if (hdata->GetBinContent(1)) {
74            Double_t ratio=hdata->GetBinContent(2)/hdata->GetBinContent(1);
75            AliDebug(2, Form("%s: ratio RecPoints lay2 / lay1 = %f", hdata->GetName(), ratio));
76          }
77          else
78            AliDebug(AliQAv1::GetQADebugLevel(), "No RecPoints in lay1");
79        }
80         else if(histName.Contains("ModPattern")) {
81            Int_t ndead=0;
82            for(Int_t ibin=0;ibin<hdata->GetNbinsX();ibin++) {
83              if(histName.Contains("SPD1") && ibin<80 && hdata->GetBinContent(ibin+1)>0) ndead++;
84              if(histName.Contains("SPD2") && ibin>79 && hdata->GetBinContent(ibin+1)>0) ndead++;
85            }
86            AliDebug(2, Form("%s: Entries = %d  number of empty modules = %d", 
87                         hdata->GetName(),(Int_t)hdata->GetEntries(),ndead));
88         }
89         else if(histName.Contains("SizeYvsZ")) {
90            Double_t meanz=hdata->GetMean(1);
91            Double_t meany=hdata->GetMean(2);
92            Double_t rmsz=hdata->GetRMS(1);
93            Double_t rmsy=hdata->GetRMS(2);
94            AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeY mean = %f  rms = %f", hdata->GetName(),meany,rmsy));
95            AliDebug(AliQAv1::GetQADebugLevel(), Form("%s: Cluster sizeZ mean = %f  rms = %f", hdata->GetName(),meanz,rmsz));
96         }
97         else if(histName.Contains("SPDMultiplicity")) {
98            AliDebug(2, Form("%s: Events = %d  mean = %f  rms = %f",
99                         hdata->GetName(),(Int_t)hdata->GetEntries(),hdata->GetMean(),hdata->GetRMS()));}
100
101        // else AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv));
102         count++;
103         test += rv;
104       }
105       else {
106         AliError("Data type cannot be processed") ;
107       }
108     }
109
110     if (count != 0) {
111       if (AliITSQADataMakerRec::AreEqual(test,0)) {
112         AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
113         test = fHighSPDValue[AliQAv1::kWARNING];  //upper limit value to set kWARNING flag for a task
114       }
115       else {
116         test /= count;
117       }
118     }
119   }
120 }
121   AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test));
122   return test ;
123
124 }
125 //__________________________________________________________________
126 Double_t AliITSQASPDChecker::CheckRawData(const TObjArray * list) {
127 //
128 // Checks on the raw data histograms [ preliminary version ]
129 // The output of this method is the fraction of SPD histograms which are processed by the checker. 
130 // The methods returns fHighSPDValue[AliQAv1::kFATAL] in case of data format errors or MEB errors
131 // 
132 // A. Mastroserio
133
134 Double_t test =0;
135
136 // basic checks on input data
137 if(!list) {
138  AliError("NO histogram list for RAWS");
139  return test;
140  }
141
142  if(list->GetEntries() == 0) {
143  AliWarning("No histograms in RAW list \n");
144  return test;
145  }
146
147 // loop over the raw data histograms
148 TIter next(list);
149 TH1 * hdata;
150 Double_t totalHistos = 0;
151 Double_t goodHistos = 0; // number of histograms which passed the checks
152 Double_t response =0;
153 Bool_t fatalProblem = kFALSE;
154
155 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
156 if (hdata) {
157         TString histName = hdata->GetName();
158         if(!histName.Contains("SPD")) continue;
159         totalHistos++;
160         // data format error
161         if(histName.Contains("SPDErrorsAll")){
162         if(hdata->Integral(0,hdata->GetNbinsX())>0){
163            response = fHighSPDValue[AliQAv1::kFATAL];
164            fatalProblem=kTRUE;
165            break;
166          }
167         }
168         // MEB error
169         if(histName.Contains("MEB")){
170           if(hdata->GetEntries()>0){
171            AliWarning("************* MEB ERROR!!!! ****************\n");
172            response = fHighSPDValue[AliQAv1::kFATAL];
173            fatalProblem=kTRUE;
174            break;
175           }
176          }
177         goodHistos++;
178         }
179 }
180     if(!fatalProblem) response = goodHistos/totalHistos;
181    // printf("n histos %f - good ones %f ----> ratio %f , fatal response %i\n",totalHistos,goodHistos,goodHistos/totalHistos,(Int_t)fatalProblem);
182     return response;
183 }
184
185 //__________________________________________________________________
186 void AliITSQASPDChecker::SetTaskOffset(Int_t TaskOffset)
187 {
188 // Offset for SPD within ITS QA
189   fSubDetOffset = TaskOffset;
190 }
191
192 //__________________________________________________________________
193 void AliITSQASPDChecker::SetStepBit(const Double_t *steprange) 
194 {
195 // Step bit for SPD within ITS QA
196   fStepBitSPD = new Double_t[AliQAv1::kNBIT];
197   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
198     {
199       fStepBitSPD[bit]=steprange[bit];
200     }
201 }
202
203
204 //__________________________________________________________________
205 void  AliITSQASPDChecker::SetSPDLimits(const Float_t *lowvalue, const Float_t * highvalue)
206 {
207 // SPD limints for QA bit within general ITS QA
208   fLowSPDValue = new Float_t[AliQAv1::kNBIT];
209   fHighSPDValue= new Float_t[AliQAv1::kNBIT];
210
211   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
212     {
213       fLowSPDValue[bit]=lowvalue[bit];
214       fHighSPDValue[bit]= highvalue[bit];
215     }
216
217 }
218