]>
Commit | Line | Data |
---|---|---|
197b835e | 1 | /************************************************************************* |
2 | * * Copyright(c) 1998-2008, 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 | /* $Id: AliTRDSaxHandler.cxx 26327 2008-06-02 15:36:18Z cblume $ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // The SAX XML file handler used in the preprocessor // | |
21 | // // | |
3d8c1d84 | 22 | // Author: // |
197b835e | 23 | // Frederick Kramer (kramer@ikf.uni-frankfurt.de) // |
24 | // // | |
25 | //////////////////////////////////////////////////////////////////////////// | |
26 | ||
7aa82ff8 | 27 | #include <cstdlib> |
197b835e | 28 | #include <Riostream.h> |
29 | #include <TList.h> | |
197b835e | 30 | #include <TXMLAttr.h> |
fdfee371 | 31 | #include <TSAXParser.h> |
32 | #include <TObjArray.h> | |
3d8c1d84 | 33 | |
34 | #include "AliLog.h" | |
35 | ||
36 | #include "AliTRDSaxHandler.h" | |
37 | #include "AliTRDgeometry.h" | |
38 | ||
197b835e | 39 | #include "Cal/AliTRDCalDCS.h" |
40 | #include "Cal/AliTRDCalDCSFEE.h" | |
41 | #include "Cal/AliTRDCalDCSPTR.h" | |
42 | #include "Cal/AliTRDCalDCSGTU.h" | |
197b835e | 43 | |
44 | ClassImp(AliTRDSaxHandler) | |
45 | ||
197b835e | 46 | //_____________________________________________________________________________ |
47 | AliTRDSaxHandler::AliTRDSaxHandler() | |
48 | :TObject() | |
49 | ,fHandlerStatus(0) | |
50 | ,fNDCSPTR(0) | |
51 | ,fNDCSGTU(0) | |
52 | ,fFEEArr(new TObjArray(540)) | |
53 | ,fPTRArr(new TObjArray(6)) | |
54 | ,fGTUArr(new TObjArray(19)) | |
55 | ,fSystem(0) | |
56 | ,fCurrentSM(0) | |
57 | ,fCurrentStack(0) | |
58 | ,fContent(0) | |
59 | ,fDCSFEEObj(0) | |
60 | ,fDCSPTRObj(0) | |
61 | ,fDCSGTUObj(0) | |
62 | ,fCalDCSObj(new AliTRDCalDCS()) | |
63 | { | |
64 | // | |
65 | // AliTRDSaxHandler default constructor | |
66 | // | |
67 | fFEEArr->SetOwner(); | |
68 | fPTRArr->SetOwner(); | |
69 | fGTUArr->SetOwner(); | |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh) | |
74 | :TObject(sh) | |
75 | ,fHandlerStatus(0) | |
76 | ,fNDCSPTR(0) | |
77 | ,fNDCSGTU(0) | |
78 | ,fFEEArr(0) | |
79 | ,fPTRArr(0) | |
80 | ,fGTUArr(0) | |
81 | ,fSystem(0) | |
82 | ,fCurrentSM(0) | |
83 | ,fCurrentStack(0) | |
84 | ,fContent(0) | |
85 | ,fDCSFEEObj(0) | |
86 | ,fDCSPTRObj(0) | |
87 | ,fDCSGTUObj(0) | |
88 | ,fCalDCSObj(0) | |
89 | { | |
90 | // | |
91 | // AliTRDSaxHandler copy constructor | |
92 | // | |
93 | } | |
94 | ||
95 | //_____________________________________________________________________________ | |
96 | AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh) | |
97 | { | |
98 | // | |
99 | // Assignment operator | |
100 | // | |
101 | if (&sh == this) return *this; | |
102 | ||
103 | new (this) AliTRDSaxHandler(sh); | |
104 | return *this; | |
105 | } | |
106 | ||
107 | //_____________________________________________________________________________ | |
108 | AliTRDSaxHandler::~AliTRDSaxHandler() | |
109 | { | |
110 | // | |
111 | // AliTRDSaxHandler destructor | |
112 | // | |
fdfee371 | 113 | |
114 | if (fFEEArr) { | |
115 | delete fFEEArr; | |
116 | fFEEArr = 0x0; | |
117 | } | |
118 | if (fPTRArr) { | |
119 | delete fPTRArr; | |
120 | fPTRArr = 0x0; | |
121 | } | |
122 | if (fGTUArr) { | |
123 | delete fGTUArr; | |
124 | fGTUArr = 0x0; | |
125 | } | |
126 | if (fCalDCSObj) { | |
127 | delete fCalDCSObj; | |
128 | fCalDCSObj = 0x0; | |
129 | } | |
130 | ||
197b835e | 131 | } |
132 | ||
133 | //_____________________________________________________________________________ | |
134 | AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj() | |
135 | { | |
136 | // put the arrays in the global calibration object and return this | |
137 | fCalDCSObj->SetNumberOfTimeBins(22); //test test test | |
138 | fCalDCSObj->SetFEEArr(fFEEArr); | |
139 | fCalDCSObj->SetPTRArr(fPTRArr); | |
140 | fCalDCSObj->SetGTUArr(fGTUArr); | |
141 | return fCalDCSObj; | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | void AliTRDSaxHandler::OnStartDocument() | |
146 | { | |
147 | // if something should happen right at the beginning of the | |
148 | // XML document, this must happen here | |
149 | } | |
150 | ||
151 | //_____________________________________________________________________________ | |
152 | void AliTRDSaxHandler::OnEndDocument() | |
153 | { | |
154 | // if something should happen at the end of the XML document | |
155 | // this must be done here | |
156 | } | |
157 | ||
158 | //_____________________________________________________________________________ | |
159 | void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes) | |
160 | { | |
161 | // when a new XML element is found, it is processed here | |
162 | fContent = ""; | |
163 | Int_t dcsId = 0; | |
164 | TString strName = name; | |
165 | TString dcsTitle = ""; | |
166 | ||
167 | // set the current system if necessary | |
168 | if (strName.Contains("FEE")) fSystem = kInsideFEE; | |
169 | if (strName.Contains("PTR")) fSystem = kInsidePTR; | |
170 | if (strName.Contains("GTU")) fSystem = kInsideGTU; | |
171 | ||
172 | // get the attributes of the element | |
173 | TXMLAttr *attr; | |
174 | TIter next(attributes); | |
175 | while ((attr = (TXMLAttr*) next())) { | |
176 | TString attribName = attr->GetName(); | |
177 | if (attribName.Contains("id") && strName.Contains("DCS")) { | |
178 | dcsTitle = name; | |
179 | dcsId = atoi(attr->GetValue()); | |
180 | } | |
181 | if (attribName.Contains("sm") && strName.Contains("DCS")) { | |
182 | fCurrentSM = atoi(attr->GetValue()); | |
183 | } | |
184 | if (attribName.Contains("id") && strName.Contains("STACK")) { | |
185 | fCurrentStack = atoi(attr->GetValue()); | |
186 | } | |
187 | } | |
188 | ||
189 | // if there is a new DCS element put it in the correct array | |
190 | if (strName.Contains("DCS")) { | |
191 | if (fSystem == kInsideFEE) { | |
192 | fDCSFEEObj = new AliTRDCalDCSFEE(name,dcsTitle); | |
193 | fDCSFEEObj->SetDCSid(dcsId); | |
194 | } | |
195 | if (fSystem == kInsidePTR) { | |
196 | fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle); | |
197 | fDCSPTRObj->SetDCSid(dcsId); | |
198 | } | |
199 | if (fSystem == kInsideGTU) { | |
200 | fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle); | |
201 | fDCSGTUObj->SetDCSid(dcsId); | |
202 | } | |
203 | } | |
204 | } | |
205 | ||
206 | //_____________________________________________________________________________ | |
207 | void AliTRDSaxHandler::OnEndElement(const char *name) | |
208 | { | |
209 | // do everything that needs to be done when an end tag of an element is found | |
210 | TString strName = name; | |
211 | ||
212 | // if done with this DCS board, put it in the correct array | |
213 | if (strName.Contains("DCS")) { | |
214 | if (fSystem == kInsideFEE) { | |
215 | AliTRDgeometry aliGeo; | |
216 | Int_t detID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(), | |
217 | fDCSFEEObj->GetStack(), | |
218 | fDCSFEEObj->GetSM()); | |
219 | fFEEArr->AddAt(fDCSFEEObj,detID); | |
220 | } | |
221 | if (fSystem == kInsidePTR) { | |
222 | fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR); | |
223 | fNDCSPTR++; | |
224 | } | |
225 | if (fSystem == kInsideGTU) { | |
226 | fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU); | |
227 | fNDCSGTU++; | |
228 | } | |
229 | fCurrentSM = 99; // 99 for no SM set | |
230 | fDCSFEEObj = 0; // just to be sure | |
231 | return; | |
232 | } | |
233 | ||
234 | // done with this stack? | |
235 | if (strName.Contains("STACK")) { | |
236 | fCurrentStack = 99; // 99 for no stack set | |
237 | } | |
238 | ||
239 | // store informations of the FEE DCS-Board | |
240 | if (fSystem == kInsideFEE) { | |
241 | if (strName.Contains("CONFIG-ID")) | |
242 | fDCSFEEObj->SetConfigID(fContent); | |
243 | if (strName.Contains("NTBIN")) | |
244 | fDCSFEEObj->SetNumberOfTimeBins(fContent.Atoi()); | |
245 | if (strName.Contains("SM-ID")) | |
246 | fDCSFEEObj->SetSM(fContent.Atoi()); | |
247 | if (strName.Contains("STACK-ID")) | |
248 | fDCSFEEObj->SetStack(fContent.Atoi()); | |
249 | if (strName.Contains("LAYER-ID")) | |
250 | fDCSFEEObj->SetLayer(fContent.Atoi()); | |
251 | } | |
252 | ||
253 | // store pretrigger informations | |
254 | if (fSystem == kInsidePTR) { | |
255 | // no informations available yet | |
256 | } | |
257 | // store GTU informations | |
258 | if (fSystem == kInsideGTU) { | |
259 | if (strName.Contains("SMMASK")) | |
260 | fHandlerStatus = fDCSGTUObj->SetSMMask(fContent); | |
261 | if (strName.Contains("LINKMASK")) | |
262 | fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent); | |
263 | if (strName.Contains("STMASK")) | |
264 | fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi()); | |
265 | } | |
266 | ||
267 | ||
268 | } | |
269 | ||
270 | //_____________________________________________________________________________ | |
271 | void AliTRDSaxHandler::OnCharacters(const char *characters) | |
272 | { | |
273 | // copy the the text content of an XML element | |
274 | fContent = characters; | |
275 | } | |
276 | ||
277 | //_____________________________________________________________________________ | |
278 | void AliTRDSaxHandler::OnComment(const char* /*text*/) | |
279 | { | |
280 | // comments within the XML file are ignored | |
281 | } | |
282 | ||
283 | //_____________________________________________________________________________ | |
284 | void AliTRDSaxHandler::OnWarning(const char *text) | |
285 | { | |
286 | // process warnings here | |
287 | AliInfo(Form("Warning: %s",text)); | |
288 | } | |
289 | ||
290 | //_____________________________________________________________________________ | |
291 | void AliTRDSaxHandler::OnError(const char *text) | |
292 | { | |
293 | // process errors here | |
294 | AliError(Form("Error: %s",text)); | |
295 | } | |
296 | ||
297 | //_____________________________________________________________________________ | |
fdfee371 | 298 | void AliTRDSaxHandler::OnFatalError(const char *text) |
197b835e | 299 | { |
300 | // process fatal errors here | |
301 | AliError(Form("Fatal error: %s",text)); // use AliFatal? | |
302 | } | |
303 | ||
304 | //_____________________________________________________________________________ | |
305 | void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/) | |
306 | { | |
307 | // process character data blocks here | |
308 | // not implemented and should not be used here | |
309 | } | |
310 |