]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | // | |
25 | ||
26 | // --- ROOT system --- | |
27 | #include <TROOT.h> | |
28 | #include <TSystem.h> | |
29 | #include <TFile.h> | |
30 | #include <TList.h> | |
31 | #include <TTree.h> | |
32 | #include <TClonesArray.h> | |
33 | #include <TParameter.h> | |
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> | |
44 | ||
45 | // --- Standard library --- | |
46 | ||
47 | // --- AliRoot header files --- | |
48 | #include "AliLog.h" | |
49 | #include "AliQADataMaker.h" | |
50 | #include "AliQAChecker.h" | |
51 | #include "AliESDEvent.h" | |
52 | #include "AliRawReader.h" | |
53 | #include "AliDetectorRecoParam.h" | |
54 | ||
55 | ||
56 | ClassImp(AliQADataMaker) | |
57 | ||
58 | //____________________________________________________________________________ | |
59 | AliQADataMaker::AliQADataMaker(const Char_t * name, const Char_t * title) : | |
60 | TNamed(name, title), | |
61 | fOutput(0x0), | |
62 | fDetectorDir(0x0), | |
63 | fDetectorDirName(""), | |
64 | fCurrentCycle(0), | |
65 | fCycle(9999999), | |
66 | fCycleCounter(0), | |
67 | fWriteExpert(kFALSE), | |
68 | fParameterList(new TList*[AliRecoParam::kNSpecies]), | |
69 | fRun(0), | |
70 | fEventSpecie(AliRecoParam::kDefault), | |
71 | fDigitsArray(NULL) | |
72 | { | |
73 | // ctor | |
74 | fDetectorDirName = GetName() ; | |
75 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
76 | fParameterList[specie] = NULL ; | |
77 | } | |
78 | } | |
79 | ||
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), | |
87 | fCycle(qadm.fCycle), | |
88 | fCycleCounter(qadm.fCycleCounter), | |
89 | fWriteExpert(qadm.fWriteExpert), | |
90 | fParameterList(qadm.fParameterList), | |
91 | fRun(qadm.fRun), | |
92 | fEventSpecie(qadm.fEventSpecie), | |
93 | fDigitsArray(NULL) | |
94 | { | |
95 | //copy ctor | |
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] ; | |
100 | } | |
101 | } | |
102 | ||
103 | //____________________________________________________________________________ | |
104 | AliQADataMaker::~AliQADataMaker() | |
105 | { | |
106 | for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) { | |
107 | if (fParameterList[esIndex] ) | |
108 | delete fParameterList[esIndex] ; | |
109 | } | |
110 | delete[] fParameterList ; | |
111 | ||
112 | if (fDigitsArray) { | |
113 | fDigitsArray->Clear() ; | |
114 | delete fDigitsArray ; | |
115 | } | |
116 | } | |
117 | ||
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) | |
120 | { | |
121 | // Set histograms memory resident and add to the list | |
122 | // Maximm allowed is 10000 | |
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())) ; | |
129 | } else if ( index > AliQAv1::GetMaxQAObj() ) { | |
130 | AliError(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ; | |
131 | } else { | |
132 | hist->SetDirectory(0) ; | |
133 | if (expert) | |
134 | hist->SetBit(AliQAv1::GetExpertBit()) ; | |
135 | if (image) | |
136 | hist->SetBit(AliQAv1::GetImageBit()) ; | |
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) ; | |
145 | } | |
146 | list[AliRecoParam::AConvert(fEventSpecie)]->AddAtAndExpand(hist, index) ; | |
147 | rv = list[AliRecoParam::AConvert(fEventSpecie)]->GetLast() ; | |
148 | } | |
149 | return rv ; | |
150 | } | |
151 | ||
152 | //____________________________________________________________________________ | |
153 | TH1 * AliQADataMaker::CloneMe(TH1 * hist, Int_t specie) const | |
154 | { | |
155 | // clones a histogram | |
156 | const Char_t * name = Form("%s_%s", AliRecoParam::GetEventSpecieName(specie), hist->GetName()) ; | |
157 | TH1 * hClone = static_cast<TH1 *>(hist->Clone(name)) ; | |
158 | if ( hist->TestBit(AliQAv1::GetExpertBit()) ) | |
159 | hClone->SetBit(AliQAv1::GetExpertBit()) ; | |
160 | if ( hist->TestBit(AliQAv1::GetImageBit()) ) | |
161 | hClone->SetBit(AliQAv1::GetImageBit()) ; | |
162 | return hClone ; | |
163 | } | |
164 | ||
165 | //____________________________________________________________________________ | |
166 | void AliQADataMaker::DefaultEndOfDetectorCycle(AliQAv1::TASKINDEX_t task) | |
167 | { | |
168 | // this method must be oveloaded by detectors | |
169 | // sets the QA result to Fatal | |
170 | AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) ; | |
171 | AliQAv1 * qa = AliQAv1::Instance(task) ; | |
172 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) | |
173 | qa->Set(AliQAv1::kFATAL, specie) ; | |
174 | AliQAv1::GetQAResultFile()->cd() ; | |
175 | qa->Write(AliQAv1::GetQAName(), kWriteDelete) ; | |
176 | AliQAv1::GetQAResultFile()->Close() ; | |
177 | } | |
178 | ||
179 | //____________________________________________________________________________ | |
180 | void AliQADataMaker::Finish() const | |
181 | { | |
182 | // write to the output File | |
183 | if (fOutput) | |
184 | fOutput->Close() ; | |
185 | } | |
186 | ||
187 | //____________________________________________________________________________ | |
188 | TObject * AliQADataMaker::GetData(TObjArray ** list, const Int_t index) | |
189 | { | |
190 | // Returns the QA object at index. Limit is AliQAv1::GetMaxQAObj() | |
191 | if ( ! list ) { | |
192 | AliError("Data list is NULL !!") ; | |
193 | return NULL ; | |
194 | } | |
195 | ||
196 | SetEventSpecie(fEventSpecie) ; | |
197 | Int_t esindex = AliRecoParam::AConvert(fEventSpecie) ; | |
198 | TH1 * histClone = NULL ; | |
199 | TObjArray * arr = list[esindex] ; | |
200 | if (arr) { | |
201 | if ( ! arr->GetEntriesFast() ) { | |
202 | // Initializes the histograms | |
203 | TString arrName(arr->GetName()) ; | |
204 | if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kRAWS))) | |
205 | InitRaws() ; | |
206 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kHITS))) | |
207 | InitHits() ; | |
208 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kSDIGITS))) | |
209 | InitSDigits() ; | |
210 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kDIGITS))) | |
211 | InitDigits() ; | |
212 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kDIGITSR))) | |
213 | InitDigits() ; | |
214 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kRECPOINTS))) | |
215 | InitRecPoints() ; | |
216 | else if (arrName.Contains(AliQAv1::GetTaskName(AliQAv1::kESDS))) | |
217 | InitESDs() ; | |
218 | } | |
219 | if ( index > AliQAv1::GetMaxQAObj() ) { | |
220 | AliError(Form("Max number of authorized QA objects is %d", AliQAv1::GetMaxQAObj())) ; | |
221 | } else { | |
222 | if ( arr->At(index) ) { | |
223 | histClone = static_cast<TH1*>(arr->At(index)) ; | |
224 | } | |
225 | } | |
226 | } | |
227 | return histClone ; | |
228 | } | |
229 | ||
230 | //____________________________________________________________________________ | |
231 | TObjArray* AliQADataMaker::Init(AliQAv1::TASKINDEX_t task, AliRecoParam::EventSpecie_t es, Int_t cycles) | |
232 | { | |
233 | // Initialializes and returns the QAData list for a given event specie | |
234 | TObjArray ** ar = Init(task, cycles) ; | |
235 | return ar[AliRecoParam::AConvert(es)] ; | |
236 | } | |
237 | ||
238 | //____________________________________________________________________________ | |
239 | Bool_t AliQADataMaker::IsValidEventSpecie(Int_t eventSpecieIndex, TObjArray ** list) | |
240 | { | |
241 | // check if event specie was present in current run or | |
242 | // if histograms of this event specie have been created | |
243 | if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(eventSpecieIndex)) || ! list[eventSpecieIndex]->GetEntriesFast() ) | |
244 | return kFALSE ; | |
245 | else | |
246 | return kTRUE ; | |
247 | } |