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 ---
32 #include <TClonesArray.h>
33 #include <TParameter.h>
45 // --- Standard library ---
47 // --- AliRoot header files ---
49 #include "AliQADataMaker.h"
50 #include "AliQAChecker.h"
51 #include "AliESDEvent.h"
52 #include "AliRawReader.h"
53 #include "AliDetectorRecoParam.h"
56 ClassImp(AliQADataMaker)
58 //____________________________________________________________________________
59 AliQADataMaker::AliQADataMaker(const Char_t * name, const Char_t * title) :
68 fParameterList(new TList*[AliRecoParam::kNSpecies]),
70 fEventSpecie(AliRecoParam::kDefault),
74 fDetectorDirName = GetName() ;
75 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
76 fParameterList[specie] = NULL ;
80 //____________________________________________________________________________
81 AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) :
82 TNamed(qadm.GetName(), qadm.GetTitle()),
83 fOutput(qadm.fOutput),
84 fDetectorDir(qadm.fDetectorDir),
85 fDetectorDirName(qadm.fDetectorDirName),
86 fCurrentCycle(qadm.fCurrentCycle),
88 fCycleCounter(qadm.fCycleCounter),
89 fWriteExpert(qadm.fWriteExpert),
90 fParameterList(qadm.fParameterList),
92 fEventSpecie(qadm.fEventSpecie),
96 fDetectorDirName = GetName() ;
97 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
98 fParameterList[specie] = qadm.fParameterList[specie] ;
99 // fImage[specie] = qadm.fImage[specie] ;
103 //____________________________________________________________________________
104 AliQADataMaker::~AliQADataMaker()
106 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
107 if (fParameterList[esIndex] )
108 delete fParameterList[esIndex] ;
110 delete[] fParameterList ;
113 fDigitsArray->Clear() ;
114 delete fDigitsArray ;
118 //____________________________________________________________________________
119 Int_t AliQADataMaker::Add2List(TH1 * hist, const Int_t index, TObjArray ** list, const Bool_t expert, const Bool_t image, const Bool_t saveForCorr)
121 // Set histograms memory resident and add to the list
122 // Maximm allowed is 10000
125 TClass * classType = hist->Class() ;
126 TString className(classType->GetName()) ;
127 if( ! className.BeginsWith("T") && ! classType->InheritsFrom("TH1") ) {
128 AliError(Form("QA data Object must be a generic ROOT object and derive fom TH1 and not %s", className.Data())) ;
129 } else if ( index > AliQAv1::GetMaxQAObj() ) {
130 AliError(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ;
132 hist->SetDirectory(0) ;
134 hist->SetBit(AliQAv1::GetExpertBit()) ;
136 hist->SetBit(AliQAv1::GetImageBit()) ;
137 const Char_t * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(fEventSpecie), hist->GetName()) ;
138 hist->SetName(name) ;
140 const Char_t * cname = Form("%s_%s", list[AliRecoParam::AConvert(AliRecoParam::kDefault)]->GetName(), hist->GetName()) ;
141 TParameter<double> * p = new TParameter<double>(cname, 9999.9999) ;
142 if ( fParameterList[AliRecoParam::AConvert(fEventSpecie)] == NULL )
143 fParameterList[AliRecoParam::AConvert(fEventSpecie)] = new TList() ;
144 fParameterList[AliRecoParam::AConvert(fEventSpecie)]->Add(p) ;
146 TObject* old = list[AliRecoParam::AConvert(fEventSpecie)]->At(index);
148 AliError(Form("%s - OUPS ! Already got an object (%p,%s) for index=%d => will most probably get a memory leak by replacing it with (%p,%s) !",
149 GetName(),old,old->GetName(),index,hist,hist->GetName()));
151 list[AliRecoParam::AConvert(fEventSpecie)]->AddAtAndExpand(hist, index) ;
152 rv = list[AliRecoParam::AConvert(fEventSpecie)]->GetLast() ;
157 //____________________________________________________________________________
158 TH1 * AliQADataMaker::CloneMe(TH1 * hist, Int_t specie) const
160 // clones a histogram
161 const Char_t * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(specie), hist->GetName()) ;
162 TH1 * hClone = static_cast<TH1 *>(hist->Clone(name)) ;
163 if ( hist->TestBit(AliQAv1::GetExpertBit()) )
164 hClone->SetBit(AliQAv1::GetExpertBit()) ;
165 if ( hist->TestBit(AliQAv1::GetImageBit()) )
166 hClone->SetBit(AliQAv1::GetImageBit()) ;
170 //____________________________________________________________________________
171 void AliQADataMaker::DefaultEndOfDetectorCycle(AliQAv1::TASKINDEX_t task)
173 // this method must be oveloaded by detectors
174 // sets the QA result to Fatal
175 AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) ;
176 AliQAv1 * qa = AliQAv1::Instance(task) ;
177 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
178 qa->Set(AliQAv1::kFATAL, specie) ;
179 AliQAv1::GetQAResultFile()->cd() ;
180 qa->Write(AliQAv1::GetQAName(), kWriteDelete) ;
181 AliQAv1::GetQAResultFile()->Close() ;
184 //____________________________________________________________________________
185 void AliQADataMaker::Finish() const
187 // write to the output File
192 //____________________________________________________________________________
193 TObject * AliQADataMaker::GetData(TObjArray ** list, const Int_t index)
195 // Returns the QA object at index. Limit is AliQAv1::GetMaxQAObj()
197 AliError("Data list is NULL !!") ;
201 SetEventSpecie(fEventSpecie) ;
202 Int_t esindex = AliRecoParam::AConvert(fEventSpecie) ;
203 TH1 * histClone = NULL ;
204 TObjArray * arr = list[esindex] ;
206 if ( ! arr->GetEntriesFast() ) {
207 // Initializes the histograms
208 TString arrName(arr->GetName()) ;
209 if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kRAWS)))
211 else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kHITS)))
213 else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kSDIGITS)))
215 else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kDIGITS)))
217 else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kDIGITSR)))
219 else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kRECPOINTS)))
221 else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kESDS)))
224 if ( index > AliQAv1::GetMaxQAObj() ) {
225 AliError(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ;
227 if ( arr->At(index) ) {
228 histClone = static_cast<TH1*>(arr->At(index)) ;
235 //____________________________________________________________________________
236 TObjArray* AliQADataMaker::Init(AliQAv1::TASKINDEX_t task, AliRecoParam::EventSpecie_t es, Int_t cycles)
238 // Initialializes and returns the QAData list for a given event specie
239 TObjArray ** ar = Init(task, cycles) ;
240 return ar[AliRecoParam::AConvert(es)] ;
243 //____________________________________________________________________________
244 Bool_t AliQADataMaker::IsValidEventSpecie(Int_t eventSpecieIndex, TObjArray ** list)
246 // check if event specie was present in current run or
247 // if histograms of this event specie have been created
248 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(eventSpecieIndex)) || ! list[eventSpecieIndex]->GetEntriesFast() )