]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDQAChecker.cxx
Minor fix
[u/mrichter/AliRoot.git] / FMD / AliFMDQAChecker.cxx
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> 
34 #include <iostream>
35 #include <TCanvas.h>
36 #include <TPaveText.h>
37
38 // --- AliRoot header files ---
39 #include "AliLog.h"
40 #include "AliQAv1.h"
41 #include "AliQAChecker.h"
42 #include "AliFMDQAChecker.h"
43 #include "AliRecoParam.h"
44
45 ClassImp(AliFMDQAChecker)
46 #if 0
47 ; // This is for Emacs! - do not delete
48 #endif
49 //__________________________________________________________________
50 void 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   //
65   
66   // Double_t* rv = new Double_t[AliRecoParam::kNSpecies] ; 
67   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
68     // Int_t count   = 0;
69     rv[specie]    = 0.; 
70
71     if (!AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
72       continue ;
73     
74     if(!list[specie]) continue;
75     
76     TH1F* hist  = 0;
77     Int_t nHist = list[specie]->GetEntriesFast();
78     for(Int_t i= 0; i< nHist; i++) {
79       
80       if (!(hist = static_cast<TH1F*>(list[specie]->At(i)))) continue;
81       
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 ...)
91     // if (count != 0) rv[specie] /= count;
92   }
93   // return rv;
94 }
95
96
97 //____________________________________________________________________________ 
98 void 
99 AliFMDQAChecker::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++) {
115     if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))
116         ->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie))) 
117       continue;
118     // if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue ;
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));
126       if (hist && hist->TestBit(AliQAv1::GetImageBit())) {
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)); 
156     if (!fImage[specie]) fImage[specie] = new TCanvas(title, title) ;
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
170     Int_t nx = int(nImages + .5) / 2;
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));
180       if (!(hist && hist->TestBit(AliQAv1::GetImageBit()))) continue;
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 }
195
196 //__________________________________________________________________
197 //
198 // EOF
199 //