1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 // Produces the data needed to calculate the quality assurance.
22 // All data must be mergeable objects.
23 // Y. Schutz CERN July 2007
26 // --- ROOT system ---
28 #include <TPaveText.h>
33 #include <TClonesArray.h>
34 #include <TParameter.h>
46 // --- Standard library ---
48 // --- AliRoot header files ---
50 #include "AliQADataMaker.h"
51 #include "AliQAChecker.h"
52 #include "AliESDEvent.h"
53 #include "AliRawReader.h"
54 #include "AliDetectorRecoParam.h"
57 ClassImp(AliQADataMaker)
59 //____________________________________________________________________________
60 AliQADataMaker::AliQADataMaker(const Char_t * name, const Char_t * title) :
69 fParameterList(new TList*[AliRecoParam::kNSpecies]),
71 fEventSpecie(AliRecoParam::kDefault),
72 fImage(new TCanvas*[AliRecoParam::kNSpecies]),
76 fDetectorDirName = GetName() ;
77 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
78 fParameterList[specie] = NULL ;
79 fImage[specie] = NULL ;
83 //____________________________________________________________________________
84 AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
85 TNamed(qadm.GetName(), qadm.GetTitle()),
86 fOutput(qadm.fOutput),
87 fDetectorDir(qadm.fDetectorDir),
88 fDetectorDirName(qadm.fDetectorDirName),
89 fCurrentCycle(qadm.fCurrentCycle),
91 fCycleCounter(qadm.fCycleCounter),
92 fWriteExpert(qadm.fWriteExpert),
93 fParameterList(qadm.fParameterList),
95 fEventSpecie(qadm.fEventSpecie),
101 fDetectorDirName = GetName() ;
104 //____________________________________________________________________________
105 AliQADataMaker::~AliQADataMaker()
107 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
108 if ( fImage[esIndex] )
109 delete fImage[esIndex] ;
110 if (fParameterList[esIndex] )
111 delete fParameterList[esIndex] ;
114 delete[] fParameterList ;
117 //____________________________________________________________________________
118 Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray ** list, const Bool_t expert, const Bool_t image, const Bool_t saveForCorr)
120 // Set histograms memory resident and add to the list
121 // Maximm allowed is 10000
124 TClass * classType = hist->Class() ;
125 TString className(classType->GetName()) ;
126 if( ! className.BeginsWith("T") && ! classType->InheritsFrom("TH1") ) {
127 AliError(Form("QA data Object must be a generic ROOT object and derive fom TH1 and not %s", className.Data())) ;
128 } else if ( index > 10000 ) {
129 AliError("Max number of authorized QA objects is 10000") ;
132 hist->SetBit(AliQAv1::GetExpertBit()) ;
134 hist->SetBit(AliQAv1::GetImageBit()) ;
135 TH1 * histClone[AliRecoParam::kNSpecies] ;
136 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
137 histClone[specie] = CloneMe(hist, specie) ;
138 histClone[specie]->SetDirectory(0) ;
139 list[specie]->AddAtAndExpand(histClone[specie], index) ;
141 const Char_t * name = Form("%s_%s", list[AliRecoParam::AConvert(AliRecoParam::kDefault)]->GetName(), hist->GetName()) ;
142 TParameter<double> * p = new TParameter<double>(name, 9999.9999) ;
143 if ( fParameterList[specie] == NULL )
144 fParameterList[specie] = new TList() ;
145 fParameterList[specie]->Add(p) ;
148 rv = list[AliRecoParam::kDefault]->GetLast() ;
154 //____________________________________________________________________________
155 TH1 * AliQADataMaker::CloneMe(TH1 * hist, Int_t specie) const
157 // clones a histogram
158 const Char_t * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(specie), hist->GetName()) ;
159 TH1 * hClone = dynamic_cast<TH1 *>(hist->Clone(name)) ;
160 if ( hist->TestBit(AliQAv1::GetExpertBit()) )
161 hClone->SetBit(AliQAv1::GetExpertBit()) ;
162 if ( hist->TestBit(AliQAv1::GetImageBit()) )
163 hClone->SetBit(AliQAv1::GetImageBit()) ;
167 //____________________________________________________________________________
168 void AliQADataMaker::DefaultEndOfDetectorCycle(AliQAv1::TASKINDEX_t task)
170 // this method must be oveloaded by detectors
171 // sets the QA result to Fatal
172 AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) ;
173 AliQAv1 * qa = AliQAv1::Instance(task) ;
174 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
175 qa->Set(AliQAv1::kFATAL, specie) ;
176 AliQAv1::GetQAResultFile()->cd() ;
177 qa->Write(AliQAv1::GetQAName(), kWriteDelete) ;
178 AliQAv1::GetQAResultFile()->Close() ;
181 //____________________________________________________________________________
182 void AliQADataMaker::Finish() const
184 // write to the output File
189 //____________________________________________________________________________
190 TObject * AliQADataMaker::GetData(TObjArray ** list, const Int_t index)
192 // Returns the QA object at index. Limit is 100.
194 AliError("Data list is NULL !!") ;
198 SetEventSpecie(fEventSpecie) ;
199 if ( GetRecoParam() ) {
200 if ( AliRecoParam::Convert(GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) {
201 SetEventSpecie(GetRecoParam()->GetEventSpecie()) ;
203 AliError(Form("Event Specie from RecoParam of %s is = %d\n", GetName(), fEventSpecie));
206 if (list[AliRecoParam::AConvert(fEventSpecie)]) {
207 if ( index > 10000 ) {
208 AliError("Max number of authorized QA objects is 10000") ;
211 Int_t esindex = AliRecoParam::AConvert(fEventSpecie) ;
212 return list[esindex]->At(index) ;
215 AliError("Data list is NULL !!") ;
220 //____________________________________________________________________________
221 void AliQADataMaker::MakeTheImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, Char_t * mode)
223 // makes the QA image for sim and rec
224 TIter next(list[0]) ;
227 while ( (hdata=dynamic_cast<TH1 *>(next())) ) {
228 if ( hdata->TestBit(AliQAv1::GetImageBit()) )
231 if ( nImages == 0 ) {
232 AliWarning(Form("No histogram will be plotted for %s %s\n", GetName(), AliQAv1::GetTaskName(task).Data())) ;
234 AliDebug(AliQAv1::GetQADebugLevel(), Form("%d histograms will be plotted for %s %s\n", nImages, GetName(), AliQAv1::GetTaskName(task).Data())) ;
235 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
236 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) )
238 const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ;
239 if ( !fImage[esIndex] ) {
240 fImage[esIndex] = new TCanvas(title, title) ;
242 fImage[esIndex]->Clear() ;
243 fImage[esIndex]->SetTitle(title) ;
244 fImage[esIndex]->cd() ;
245 TPaveText someText(0.015, 0.015, 0.98, 0.98) ;
246 someText.AddText(title) ;
248 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), mode, fRun, AliQAv1::GetImageFileFormat())) ;
249 fImage[esIndex]->Clear() ;
250 Int_t nx = TMath::Sqrt(nImages) ;
252 if ( nx < TMath::Sqrt(nImages))
254 fImage[esIndex]->Divide(nx, ny) ;
255 TIter nexthist(list[esIndex]) ;
258 fImage[esIndex]->cd(npad) ;
259 while ( (hist=dynamic_cast<TH1*>(nexthist())) ) {
260 if(hist->TestBit(AliQAv1::GetImageBit())) {
262 fImage[esIndex]->cd(++npad) ;
265 fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), mode, fRun, AliQAv1::GetImageFileFormat())) ;