fixes
[u/mrichter/AliRoot.git] / FMD / AliFMDQAChecker.cxx
CommitLineData
c9dd1c4d 1/**************************************************************************
2 * Copyright(c) 2004, 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// Yves?
18// What
19// is
20// this
21// class
22// supposed
23// to
24// do?
25//__________________________________________________________________
26//
27// --- ROOT system ---
28#include <TClass.h>
29#include <TH1F.h>
30#include <TH1I.h>
31#include <TIterator.h>
32#include <TKey.h>
33#include <TFile.h>
6ceca4ef 34#include <iostream>
1706c710 35#include <TCanvas.h>
36#include <TPaveText.h>
c9dd1c4d 37
38// --- AliRoot header files ---
39#include "AliLog.h"
4e25ac79 40#include "AliQAv1.h"
c9dd1c4d 41#include "AliQAChecker.h"
42#include "AliFMDQAChecker.h"
6ceca4ef 43#include "AliRecoParam.h"
c9dd1c4d 44
45ClassImp(AliFMDQAChecker)
46#if 0
47; // This is for Emacs! - do not delete
48#endif
c9dd1c4d 49//__________________________________________________________________
fa5a224b 50void AliFMDQAChecker::Check(Double_t* rv,
51 AliQAv1::ALITASK_t what,
52 TObjArray** list,
53 const AliDetectorRecoParam* /*t*/)
54{
55 //
56 // Member function called to do the actual checking
57 //
58 // Parameters:
59 // rv Array of return values.
60 // what What to check
61 // list Array of arrays of histograms. There's one arrat for
62 // each 'specie'
63 // t Reconstruction parameters - not used.
64 //
6ceca4ef 65
fa5a224b 66 // Double_t* rv = new Double_t[AliRecoParam::kNSpecies] ;
6ceca4ef 67 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
83dbc5b8 68 // Int_t count = 0;
fa5a224b 69 rv[specie] = 0.;
70
1706c710 71 if (!AliQAv1::Instance()->IsEventSpecieSet(specie) )
6ceca4ef 72 continue ;
73
74 if(!list[specie]) continue;
75
584d4c54 76 TH1F* hist = 0;
77 Int_t nHist = list[specie]->GetEntriesFast();
78 for(Int_t i= 0; i< nHist; i++) {
6ceca4ef 79
584d4c54 80 if (!(hist = static_cast<TH1F*>(list[specie]->At(i)))) continue;
6ceca4ef 81
fa5a224b 82 if(what == AliQAv1::kESD)
83 rv[specie] += (hist->GetMean() > 0 ? 1 : 0);
84 if(what == AliQAv1::kRAW)
85 rv[specie] += (hist->GetMean() > 0 ? 1 : 0);
86 if(what == AliQAv1::kSIM)
87 rv[specie] += (hist->GetMean() > 0 ? 1 : 0);
88 if(what == AliQAv1::kREC)
89 rv[specie] += (hist->GetMean() > 0 ? 1 : 0);
90 } // for (int i ...)
83dbc5b8 91 // if (count != 0) rv[specie] /= count;
6ceca4ef 92 }
fa5a224b 93 // return rv;
6ceca4ef 94}
95
96
1706c710 97//____________________________________________________________________________
98void
99AliFMDQAChecker::MakeImage(TObjArray** list,
100 AliQAv1::TASKINDEX_t task,
101 AliQAv1::MODE_t mode)
102{
103 // makes the QA image for sim and rec
104 //
105 // Parameters:
106 // task What to check
107 // list Array of arrays of histograms. There's one array for
108 // each 'specie'
109 // t Reconstruction parameters - not used.
110 //
111 Int_t nImages = 0 ;
112 Double_t max = 0;
113 Double_t min = 10000;
114 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
544ed74f 115 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))
116 ->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)))
117 continue;
118 // if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue ;
1706c710 119
120 if(!list[specie]) continue;
121
122 TH1F* hist = 0;
123 Int_t nHist = list[specie]->GetEntriesFast();
124 for(Int_t i= 0; i< nHist; i++) {
125 hist = static_cast<TH1F*>(list[specie]->At(i));
ae559def 126 if (hist && hist->TestBit(AliQAv1::GetImageBit())) {
1706c710 127 nImages++;
128 max = TMath::Max(max, hist->GetMaximum());
129 min = TMath::Min(min, hist->GetMinimum());
130 }
131 }
132 break ;
133 }
134 min = TMath::Max(0.1, min);
135 max = TMath::Min(1.0, max);
136
137 if (nImages == 0) {
138 AliDebug(AliQAv1::GetQADebugLevel(),
139 Form("No histogram will be plotted for %s %s\n", GetName(),
140 AliQAv1::GetTaskName(task).Data()));
141 return;
142 }
143
144 AliDebug(AliQAv1::GetQADebugLevel(),
145 Form("%d histograms will be plotted for %s %s\n",
146 nImages, GetName(), AliQAv1::GetTaskName(task).Data()));
147
148 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
149 if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue ;
150
151 if(!list[specie]) continue;
152
153 const Char_t * title = Form("QA_%s_%s_%s", GetName(),
154 AliQAv1::GetTaskName(task).Data(),
155 AliRecoParam::GetEventSpecieName(specie));
544ed74f 156 if (!fImage[specie]) fImage[specie] = new TCanvas(title, title) ;
1706c710 157 fImage[specie]->Clear() ;
158 fImage[specie]->SetTitle(title) ;
159 fImage[specie]->cd() ;
160
161 TPaveText someText(0.015, 0.015, 0.98, 0.98) ;
162 someText.AddText(title) ;
163 someText.Draw() ;
164 fImage[specie]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(),
165 AliQAv1::GetModeName(mode),
166 AliQAChecker::Instance()->GetRunNumber(),
167 AliQAv1::GetImageFileFormat()), "ps") ;
168 fImage[specie]->Clear();
169
dbac3484 170 Int_t nx = int(nImages + .5) / 2;
1706c710 171 Int_t ny = 2;
172 fImage[specie]->Divide(nx, ny, 0, 0);
173
174
175 TH1F* hist = 0;
176 Int_t nHist = list[specie]->GetEntriesFast();
177 Int_t j = 0;
178 for (Int_t i = 0; i < nHist; i++) {
179 hist = static_cast<TH1F*>(list[specie]->At(i));
ae559def 180 if (!(hist && hist->TestBit(AliQAv1::GetImageBit()))) continue;
1706c710 181
182 TVirtualPad* pad = fImage[specie]->cd(++j);
183 pad->SetLogy();
184 hist->SetMinimum(min);
185 hist->SetMaximum(max);
186 hist->DrawCopy();
187 }
188
189 fImage[specie]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(),
190 AliQAv1::GetModeName(mode),
191 AliQAChecker::Instance()->GetRunNumber(),
192 AliQAv1::GetImageFileFormat()), "ps");
193 }
194}
c9dd1c4d 195
196//__________________________________________________________________
197//
198// EOF
199//