]>
Commit | Line | Data |
---|---|---|
421ab0fb | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | /* $Id$ */ | |
18 | ||
202374b1 | 19 | // |
20 | // Base Class | |
21 | // Produces the data needed to calculate the quality assurance. | |
22 | // All data must be mergeable objects. | |
23 | // Y. Schutz CERN July 2007 | |
24 | // | |
421ab0fb | 25 | |
26 | // --- ROOT system --- | |
eca4fa66 | 27 | #include <TROOT.h> |
421ab0fb | 28 | #include <TSystem.h> |
29 | #include <TFile.h> | |
6c18591a | 30 | #include <TList.h> |
d76c31f4 | 31 | #include <TTree.h> |
d5cf81bd | 32 | #include <TClonesArray.h> |
a2b64fbd | 33 | #include <TParameter.h> |
57acd2d2 | 34 | #include <TH1K.h> |
35 | #include <TH2C.h> | |
36 | #include <TH2D.h> | |
37 | #include <TH2F.h> | |
38 | #include <TH2I.h> | |
39 | #include <TH3C.h> | |
40 | #include <TH3D.h> | |
41 | #include <TH3F.h> | |
42 | #include <TH3I.h> | |
43 | #include <TH3S.h> | |
421ab0fb | 44 | |
45 | // --- Standard library --- | |
46 | ||
47 | // --- AliRoot header files --- | |
48 | #include "AliLog.h" | |
2e42b4d4 | 49 | #include "AliQADataMaker.h" |
50 | #include "AliQAChecker.h" | |
d76c31f4 | 51 | #include "AliESDEvent.h" |
d5cf81bd | 52 | #include "AliRawReader.h" |
5e232cd6 | 53 | #include "AliDetectorRecoParam.h" |
54 | ||
421ab0fb | 55 | |
2e42b4d4 | 56 | ClassImp(AliQADataMaker) |
312e6f8d | 57 | |
421ab0fb | 58 | //____________________________________________________________________________ |
fec0891b | 59 | AliQADataMaker::AliQADataMaker(const Char_t * name, const Char_t * title) : |
421ab0fb | 60 | TNamed(name, title), |
61 | fOutput(0x0), | |
6c18591a | 62 | fDetectorDir(0x0), |
312e6f8d | 63 | fDetectorDirName(""), |
930e6e3e | 64 | fCurrentCycle(0), |
5b188f2f | 65 | fCycle(9999999), |
66 | fCycleCounter(0), | |
b1af1125 | 67 | fWriteExpert(kFALSE), |
57acd2d2 | 68 | fParameterList(new TList*[AliRecoParam::kNSpecies]), |
69 | fRun(0), | |
71f27f1f | 70 | fEventSpecie(AliRecoParam::kDefault), |
6252ceeb | 71 | fDigitsArray(NULL) |
421ab0fb | 72 | { |
73 | // ctor | |
421ab0fb | 74 | fDetectorDirName = GetName() ; |
71f27f1f | 75 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
76 | fParameterList[specie] = NULL ; | |
71f27f1f | 77 | } |
421ab0fb | 78 | } |
79 | ||
80 | //____________________________________________________________________________ | |
2e42b4d4 | 81 | AliQADataMaker::AliQADataMaker(const AliQADataMaker& qadm) : |
421ab0fb | 82 | TNamed(qadm.GetName(), qadm.GetTitle()), |
83 | fOutput(qadm.fOutput), | |
6c18591a | 84 | fDetectorDir(qadm.fDetectorDir), |
312e6f8d | 85 | fDetectorDirName(qadm.fDetectorDirName), |
5b188f2f | 86 | fCurrentCycle(qadm.fCurrentCycle), |
87 | fCycle(qadm.fCycle), | |
88 | fCycleCounter(qadm.fCycleCounter), | |
b1af1125 | 89 | fWriteExpert(qadm.fWriteExpert), |
a2b64fbd | 90 | fParameterList(qadm.fParameterList), |
57acd2d2 | 91 | fRun(qadm.fRun), |
634696f5 | 92 | fEventSpecie(qadm.fEventSpecie), |
6252ceeb | 93 | fDigitsArray(NULL) |
421ab0fb | 94 | { |
95 | //copy ctor | |
96 | fDetectorDirName = GetName() ; | |
eca4fa66 | 97 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
98 | fParameterList[specie] = qadm.fParameterList[specie] ; | |
634696f5 | 99 | // fImage[specie] = qadm.fImage[specie] ; |
eca4fa66 | 100 | } |
421ab0fb | 101 | } |
102 | ||
71f27f1f | 103 | //____________________________________________________________________________ |
104 | AliQADataMaker::~AliQADataMaker() | |
105 | { | |
106 | for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) { | |
71f27f1f | 107 | if (fParameterList[esIndex] ) |
108 | delete fParameterList[esIndex] ; | |
109 | } | |
71f27f1f | 110 | delete[] fParameterList ; |
6252ceeb | 111 | |
112 | if (fDigitsArray) { | |
113 | fDigitsArray->Clear() ; | |
114 | delete fDigitsArray ; | |
115 | } | |
71f27f1f | 116 | } |
117 | ||
ba7aca7d | 118 | //____________________________________________________________________________ |
7d297381 | 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) |
ba7aca7d | 120 | { |
04236e67 | 121 | // Set histograms memory resident and add to the list |
ab4351aa | 122 | // Maximm allowed is 10000 |
57acd2d2 | 123 | |
124 | Int_t rv = -1 ; | |
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())) ; | |
49466ea2 | 129 | } else if ( index > AliQAv1::GetMaxQAObj() ) { |
130 | AliError(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ; | |
eca4fa66 | 131 | } else { |
132 | hist->SetDirectory(0) ; | |
750730d8 | 133 | if (expert) |
7d297381 | 134 | hist->SetBit(AliQAv1::GetExpertBit()) ; |
135 | if (image) | |
136 | hist->SetBit(AliQAv1::GetImageBit()) ; | |
eca4fa66 | 137 | const Char_t * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(fEventSpecie), hist->GetName()) ; |
138 | hist->SetName(name) ; | |
139 | if(saveForCorr) { | |
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) ; | |
a2b64fbd | 145 | } |
8db8be00 | 146 | TObject* old = list[AliRecoParam::AConvert(fEventSpecie)]->At(index); |
147 | if (old) { | |
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())); | |
150 | } | |
eca4fa66 | 151 | list[AliRecoParam::AConvert(fEventSpecie)]->AddAtAndExpand(hist, index) ; |
152 | rv = list[AliRecoParam::AConvert(fEventSpecie)]->GetLast() ; | |
a2b64fbd | 153 | } |
57acd2d2 | 154 | return rv ; |
155 | } | |
156 | ||
157 | //____________________________________________________________________________ | |
158 | TH1 * AliQADataMaker::CloneMe(TH1 * hist, Int_t specie) const | |
159 | { | |
160 | // clones a histogram | |
fec0891b | 161 | const Char_t * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(specie), hist->GetName()) ; |
eca4fa66 | 162 | TH1 * hClone = static_cast<TH1 *>(hist->Clone(name)) ; |
4e25ac79 | 163 | if ( hist->TestBit(AliQAv1::GetExpertBit()) ) |
b2db43c5 | 164 | hClone->SetBit(AliQAv1::GetExpertBit()) ; |
165 | if ( hist->TestBit(AliQAv1::GetImageBit()) ) | |
166 | hClone->SetBit(AliQAv1::GetImageBit()) ; | |
75373542 | 167 | return hClone ; |
421ab0fb | 168 | } |
169 | ||
96d67a8d | 170 | //____________________________________________________________________________ |
4e25ac79 | 171 | void AliQADataMaker::DefaultEndOfDetectorCycle(AliQAv1::TASKINDEX_t task) |
96d67a8d | 172 | { |
173 | // this method must be oveloaded by detectors | |
174 | // sets the QA result to Fatal | |
4e25ac79 | 175 | AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) ; |
176 | AliQAv1 * qa = AliQAv1::Instance(task) ; | |
57acd2d2 | 177 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) |
4e25ac79 | 178 | qa->Set(AliQAv1::kFATAL, specie) ; |
179 | AliQAv1::GetQAResultFile()->cd() ; | |
180 | qa->Write(AliQAv1::GetQAName(), kWriteDelete) ; | |
181 | AliQAv1::GetQAResultFile()->Close() ; | |
96d67a8d | 182 | } |
183 | ||
421ab0fb | 184 | //____________________________________________________________________________ |
c65c502a | 185 | void AliQADataMaker::Finish() const |
421ab0fb | 186 | { |
96d67a8d | 187 | // write to the output File |
d9cbd8fd | 188 | if (fOutput) |
189 | fOutput->Close() ; | |
421ab0fb | 190 | } |
191 | ||
192 | //____________________________________________________________________________ | |
57acd2d2 | 193 | TObject * AliQADataMaker::GetData(TObjArray ** list, const Int_t index) |
04236e67 | 194 | { |
49466ea2 | 195 | // Returns the QA object at index. Limit is AliQAv1::GetMaxQAObj() |
76c42cb4 | 196 | if ( ! list ) { |
197 | AliError("Data list is NULL !!") ; | |
198 | return NULL ; | |
199 | } | |
5e232cd6 | 200 | |
201 | SetEventSpecie(fEventSpecie) ; | |
eca4fa66 | 202 | Int_t esindex = AliRecoParam::AConvert(fEventSpecie) ; |
203 | TH1 * histClone = NULL ; | |
49466ea2 | 204 | TObjArray * arr = list[esindex] ; |
205 | if (arr) { | |
6252ceeb | 206 | if ( ! arr->GetEntriesFast() ) { |
207 | // Initializes the histograms | |
208 | TString arrName(arr->GetName()) ; | |
209 | if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kRAWS))) | |
210 | InitRaws() ; | |
211 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kHITS))) | |
212 | InitHits() ; | |
213 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kSDIGITS))) | |
214 | InitSDigits() ; | |
215 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kDIGITS))) | |
216 | InitDigits() ; | |
217 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kDIGITSR))) | |
7f0f88e7 | 218 | InitDigits() ; |
6252ceeb | 219 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kRECPOINTS))) |
220 | InitRecPoints() ; | |
221 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kESDS))) | |
222 | InitESDs() ; | |
223 | } | |
49466ea2 | 224 | if ( index > AliQAv1::GetMaxQAObj() ) { |
225 | AliError(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ; | |
27773260 | 226 | } else { |
49466ea2 | 227 | if ( arr->At(index) ) { |
228 | histClone = static_cast<TH1*>(arr->At(index)) ; | |
eca4fa66 | 229 | } |
230 | } | |
231 | } | |
232 | return histClone ; | |
27773260 | 233 | } |
7d297381 | 234 | |
211a7313 | 235 | //____________________________________________________________________________ |
236 | TObjArray* AliQADataMaker::Init(AliQAv1::TASKINDEX_t task, AliRecoParam::EventSpecie_t es, Int_t cycles) | |
237 | { | |
238 | // Initialializes and returns the QAData list for a given event specie | |
239 | TObjArray ** ar = Init(task, cycles) ; | |
240 | return ar[AliRecoParam::AConvert(es)] ; | |
241 | } | |
242 | ||
6252ceeb | 243 | //____________________________________________________________________________ |
244 | Bool_t AliQADataMaker::IsValidEventSpecie(Int_t eventSpecieIndex, TObjArray ** list) | |
245 | { | |
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() ) | |
249 | return kFALSE ; | |
250 | else | |
251 | return kTRUE ; | |
252 | } | |
9ac91920 | 253 |