]>
Commit | Line | Data |
---|---|---|
6b36d985 | 1 | /*************************************************************************\r |
2 | * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *\r | |
3 | * * *\r | |
4 | * * Author: The ALICE Off-line Project. *\r | |
5 | * * Contributors are mentioned in the code where appropriate. *\r | |
6 | * * *\r | |
7 | * * Permission to use, copy, modify and distribute this software and its *\r | |
8 | * * documentation strictly for non-commercial purposes is hereby granted *\r | |
9 | * * without fee, provided that the above copyright notice appears in all *\r | |
10 | * * copies and that both the copyright notice and this permission notice *\r | |
11 | * * appear in the supporting documentation. The authors make no claims *\r | |
12 | * * about the suitability of this software for any purpose. It is *\r | |
13 | * * provided "as is" without express or implied warranty. *\r | |
14 | * **************************************************************************/\r | |
15 | \r | |
16 | /* $Id: AliTRDSaxHandler.cxx 26327 2008-06-02 15:36:18Z cblume $ */\r | |
17 | \r | |
18 | ////////////////////////////////////////////////////////////////////////////\r | |
19 | // //\r | |
20 | // The SAX XML file handler used in the preprocessor //\r | |
21 | // //\r | |
22 | // Author: //\r | |
23 | // Frederick Kramer (kramer@ikf.uni-frankfurt.de) //\r | |
24 | // //\r | |
25 | ////////////////////////////////////////////////////////////////////////////\r | |
26 | \r | |
27 | #include <cstdlib>\r | |
28 | #include <Riostream.h>\r | |
29 | #include <TList.h>\r | |
30 | #include <TXMLAttr.h>\r | |
31 | #include <TSAXParser.h>\r | |
32 | #include <TObjArray.h>\r | |
33 | \r | |
34 | #include "AliLog.h"\r | |
35 | \r | |
36 | #include "AliTRDSaxHandler.h"\r | |
37 | #include "AliTRDgeometry.h"\r | |
38 | \r | |
39 | #include "Cal/AliTRDCalDCS.h"\r | |
40 | #include "Cal/AliTRDCalDCSFEE.h"\r | |
41 | #include "Cal/AliTRDCalDCSPTR.h"\r | |
42 | #include "Cal/AliTRDCalDCSGTU.h"\r | |
43 | \r | |
44 | ClassImp(AliTRDSaxHandler)\r | |
45 | \r | |
6af58a56 | 46 | \r |
6b36d985 | 47 | //_____________________________________________________________________________\r |
48 | AliTRDSaxHandler::AliTRDSaxHandler()\r | |
49 | :TObject()\r | |
50 | ,fHandlerStatus(0)\r | |
51 | ,fNDCSPTR(0)\r | |
52 | ,fNDCSGTU(0)\r | |
53 | ,fFEEArr(new TObjArray(540))\r | |
54 | ,fPTRArr(new TObjArray(6))\r | |
55 | ,fGTUArr(new TObjArray(19))\r | |
56 | ,fSystem(0)\r | |
6af58a56 | 57 | ,fInsideRstate(0)\r |
6b36d985 | 58 | ,fCurrentSM(0)\r |
59 | ,fCurrentStack(0)\r | |
6af58a56 | 60 | ,fCurrentROB(-1)\r |
61 | ,fCurrentMCM(-1)\r | |
6b36d985 | 62 | ,fContent(0)\r |
63 | ,fDCSFEEObj(0)\r | |
64 | ,fDCSPTRObj(0)\r | |
65 | ,fDCSGTUObj(0)\r | |
66 | ,fCalDCSObj(new AliTRDCalDCS())\r | |
67 | {\r | |
68 | //\r | |
69 | // AliTRDSaxHandler default constructor\r | |
70 | //\r | |
71 | fFEEArr->SetOwner();\r | |
72 | fPTRArr->SetOwner();\r | |
73 | fGTUArr->SetOwner();\r | |
74 | }\r | |
75 | \r | |
76 | //_____________________________________________________________________________\r | |
77 | AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)\r | |
78 | :TObject(sh)\r | |
79 | ,fHandlerStatus(0)\r | |
80 | ,fNDCSPTR(0)\r | |
81 | ,fNDCSGTU(0)\r | |
82 | ,fFEEArr(0)\r | |
83 | ,fPTRArr(0)\r | |
84 | ,fGTUArr(0)\r | |
85 | ,fSystem(0)\r | |
6af58a56 | 86 | ,fInsideRstate(0)\r |
6b36d985 | 87 | ,fCurrentSM(0)\r |
88 | ,fCurrentStack(0)\r | |
6af58a56 | 89 | ,fCurrentROB(-1)\r |
90 | ,fCurrentMCM(-1)\r | |
6b36d985 | 91 | ,fContent(0)\r |
92 | ,fDCSFEEObj(0)\r | |
93 | ,fDCSPTRObj(0)\r | |
94 | ,fDCSGTUObj(0)\r | |
95 | ,fCalDCSObj(0)\r | |
96 | {\r | |
97 | //\r | |
98 | // AliTRDSaxHandler copy constructor\r | |
99 | //\r | |
100 | }\r | |
101 | \r | |
102 | //_____________________________________________________________________________\r | |
103 | AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)\r | |
104 | {\r | |
105 | //\r | |
106 | // Assignment operator\r | |
107 | //\r | |
108 | if (&sh == this) return *this;\r | |
109 | \r | |
110 | new (this) AliTRDSaxHandler(sh);\r | |
111 | return *this;\r | |
112 | }\r | |
113 | \r | |
114 | //_____________________________________________________________________________\r | |
115 | AliTRDSaxHandler::~AliTRDSaxHandler()\r | |
116 | {\r | |
117 | //\r | |
118 | // AliTRDSaxHandler destructor\r | |
119 | //\r | |
120 | \r | |
121 | if (fFEEArr) {\r | |
122 | delete fFEEArr;\r | |
123 | fFEEArr = 0x0;\r | |
124 | }\r | |
125 | if (fPTRArr) {\r | |
126 | delete fPTRArr;\r | |
127 | fPTRArr = 0x0;\r | |
128 | }\r | |
129 | if (fGTUArr) {\r | |
130 | delete fGTUArr;\r | |
131 | fGTUArr = 0x0;\r | |
132 | }\r | |
133 | if (fCalDCSObj) {\r | |
134 | delete fCalDCSObj;\r | |
135 | fCalDCSObj = 0x0;\r | |
136 | }\r | |
137 | \r | |
138 | }\r | |
139 | \r | |
140 | //_____________________________________________________________________________\r | |
141 | AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()\r | |
142 | {\r | |
143 | // put the arrays in the global calibration object and return this\r | |
6b36d985 | 144 | fCalDCSObj->SetFEEArr(fFEEArr);\r |
145 | fCalDCSObj->SetPTRArr(fPTRArr);\r | |
146 | fCalDCSObj->SetGTUArr(fGTUArr);\r | |
147 | return fCalDCSObj;\r | |
148 | }\r | |
149 | \r | |
150 | //_____________________________________________________________________________\r | |
151 | void AliTRDSaxHandler::OnStartDocument()\r | |
152 | {\r | |
153 | // if something should happen right at the beginning of the\r | |
154 | // XML document, this must happen here\r | |
155 | }\r | |
156 | \r | |
157 | //_____________________________________________________________________________\r | |
158 | void AliTRDSaxHandler::OnEndDocument()\r | |
159 | {\r | |
160 | // if something should happen at the end of the XML document\r | |
161 | // this must be done here\r | |
162 | }\r | |
163 | \r | |
164 | //_____________________________________________________________________________\r | |
165 | void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)\r | |
166 | {\r | |
167 | // when a new XML element is found, it is processed here\r | |
168 | fContent = "";\r | |
169 | Int_t dcsId = 0;\r | |
170 | TString strName = name;\r | |
171 | TString dcsTitle = "";\r | |
172 | \r | |
173 | // set the current system if necessary\r | |
174 | if (strName.Contains("FEE")) fSystem = kInsideFEE;\r | |
175 | if (strName.Contains("PTR")) fSystem = kInsidePTR;\r | |
176 | if (strName.Contains("GTU")) fSystem = kInsideGTU;\r | |
177 | \r | |
6af58a56 | 178 | // set if we are inside rstate \r |
179 | // (in principle not necessary - just to be more safe against stupid tags)\r | |
180 | if (strName.Contains("rstate")) fInsideRstate = 1;\r | |
181 | \r | |
6b36d985 | 182 | // get the attributes of the element\r |
183 | TXMLAttr *attr;\r | |
184 | TIter next(attributes);\r | |
185 | while ((attr = (TXMLAttr*) next())) {\r | |
186 | TString attribName = attr->GetName();\r | |
187 | if (attribName.Contains("id") && strName.Contains("DCS")) {\r | |
188 | dcsTitle = name;\r | |
189 | dcsId = atoi(attr->GetValue());\r | |
190 | }\r | |
191 | if (attribName.Contains("roc") && strName.Contains("ack")) {\r | |
192 | if (atoi(attr->GetValue()) != fDCSFEEObj->GetDCSid())\r | |
193 | fDCSFEEObj->SetStatusBit(3); // consistence check\r | |
194 | }\r | |
6af58a56 | 195 | if (attribName.Contains("rob") && (fInsideRstate == 1)) {\r |
196 | fCurrentROB = atoi(attr->GetValue());\r | |
197 | }\r | |
198 | if (attribName.Contains("mcm") && (fInsideRstate == 1)) {\r | |
199 | fCurrentMCM = atoi(attr->GetValue());\r | |
200 | }\r | |
6b36d985 | 201 | if (attribName.Contains("sm") && strName.Contains("DCS")) {\r |
202 | fCurrentSM = atoi(attr->GetValue()); // only for GTU/PTR\r | |
203 | }\r | |
204 | if (attribName.Contains("id") && strName.Contains("STACK")) {\r | |
205 | fCurrentStack = atoi(attr->GetValue()); // only for GTU/PTR\r | |
206 | }\r | |
207 | }\r | |
208 | \r | |
209 | // if there is a new DCS element put it in the correct array\r | |
210 | if (strName.Contains("DCS")) {\r | |
211 | if (fSystem == kInsideFEE) {\r | |
212 | fDCSFEEObj = new AliTRDCalDCSFEE(name,dcsTitle);\r | |
213 | fDCSFEEObj->SetDCSid(dcsId);\r | |
214 | }\r | |
215 | if (fSystem == kInsidePTR) {\r | |
216 | fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);\r | |
217 | fDCSPTRObj->SetDCSid(dcsId);\r | |
218 | }\r | |
219 | if (fSystem == kInsideGTU) {\r | |
220 | fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);\r | |
221 | fDCSGTUObj->SetDCSid(dcsId);\r | |
222 | }\r | |
223 | }\r | |
224 | }\r | |
225 | \r | |
226 | //_____________________________________________________________________________\r | |
227 | void AliTRDSaxHandler::OnEndElement(const char *name)\r | |
228 | {\r | |
229 | // do everything that needs to be done when an end tag of an element is found\r | |
230 | TString strName = name;\r | |
231 | \r | |
232 | // if done with this DCS board, put it in the correct array\r | |
233 | // no check for </ack> necessary since this check is done during XML validation\r | |
234 | if (strName.Contains("DCS")) {\r | |
235 | if (fSystem == kInsideFEE) {\r | |
236 | Int_t detID = 0;\r | |
237 | if (fDCSFEEObj->GetStatusBit() == 0) {\r | |
238 | // if there were no errors (StatusBit==0) the following should match\r | |
239 | detID = fDCSFEEObj->GetDCSid();\r | |
240 | AliTRDgeometry aliGeo;\r | |
241 | Int_t calDetID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(),\r | |
242 | fDCSFEEObj->GetStack(),\r | |
243 | fDCSFEEObj->GetSM());\r | |
244 | if (detID != calDetID) fDCSFEEObj->SetStatusBit(4);\r | |
245 | } else {\r | |
246 | // if the dcs board didn't properly respond, don't compare\r | |
247 | detID = fDCSFEEObj->GetDCSid();\r | |
248 | }\r | |
249 | fFEEArr->AddAt(fDCSFEEObj,detID);\r | |
250 | }\r | |
251 | if (fSystem == kInsidePTR) {\r | |
252 | fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);\r | |
253 | fNDCSPTR++;\r | |
254 | }\r | |
255 | if (fSystem == kInsideGTU) {\r | |
256 | fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);\r | |
257 | fNDCSGTU++;\r | |
258 | }\r | |
259 | fCurrentSM = 99; // 99 for no SM set\r | |
260 | fDCSFEEObj = 0; // just to be sure\r | |
261 | return;\r | |
262 | }\r | |
263 | \r | |
264 | // done with this stack?\r | |
265 | if (strName.Contains("STACK")) {\r | |
266 | fCurrentStack = 99; // 99 for no stack set\r | |
267 | }\r | |
268 | \r | |
6af58a56 | 269 | // outside of rstate again?\r |
270 | if (strName.Contains("rstate")) {\r | |
271 | fInsideRstate = 0;\r | |
272 | fCurrentROB = -1;\r | |
273 | fCurrentMCM = -1;\r | |
274 | }\r | |
275 | if (strName.Contains("ro-board")) fCurrentROB = -1;\r | |
276 | \r | |
6b36d985 | 277 | // store informations of the FEE DCS-Board\r |
278 | if (fSystem == kInsideFEE) {\r | |
6af58a56 | 279 | if (strName.Contains("DNR")) fDCSFEEObj->SetStatusBit(fContent.Atoi());\r |
280 | if (strName.Contains("CFGNME")) fDCSFEEObj->SetConfigName(fContent);\r | |
281 | if (strName.Contains("CFGTAG")) fDCSFEEObj->SetConfigTag(fContent.Atoi());\r | |
282 | if (strName.Contains("CFGVRSN")) fDCSFEEObj->SetConfigVersion(fContent);\r | |
283 | if (strName.Contains("NTB")) fDCSFEEObj->SetNumberOfTimeBins(fContent.Atoi());\r | |
284 | if (strName.Contains("SM-ID")) fDCSFEEObj->SetSM(fContent.Atoi());\r | |
285 | if (strName.Contains("STACK-ID")) fDCSFEEObj->SetStack(fContent.Atoi());\r | |
286 | if (strName.Contains("LAYER-ID")) fDCSFEEObj->SetLayer(fContent.Atoi());\r | |
6b36d985 | 287 | if (strName.Contains("SINGLEHITTHRES")) fDCSFEEObj->SetSingleHitThres(fContent.Atoi());\r |
6af58a56 | 288 | if (strName.Contains("THRPADCLSTHRS")) fDCSFEEObj->SetThreePadClustThres(fContent.Atoi());\r |
289 | if (strName.Contains("SELNOZS")) fDCSFEEObj->SetSelectiveNoZS(fContent.Atoi());\r | |
290 | if (strName.Contains("FASTSTATNOISE")) fDCSFEEObj->SetFastStatNoise(fContent.Atoi());\r | |
291 | if (strName.Contains("FILTWEIGHT")) fDCSFEEObj->SetTCFilterWeight(fContent.Atoi());\r | |
6b36d985 | 292 | if (strName.Contains("FILTSHRTDCYPRM")) fDCSFEEObj->SetTCFilterShortDecPar(fContent.Atoi());\r |
6af58a56 | 293 | if (strName.Contains("FILTLNGDCYPRM")) fDCSFEEObj->SetTCFilterLongDecPar(fContent.Atoi());\r |
294 | if (strName.Contains("FLTR")) fDCSFEEObj->SetFilterType(fContent);\r | |
295 | if (strName.Contains("READOUTPAR")) fDCSFEEObj->SetReadoutParam(fContent);\r | |
296 | if (strName.Contains("TESTPATTERN")) fDCSFEEObj->SetTestPattern(fContent);\r | |
297 | if (strName.Contains("TRCKLTMODE")) fDCSFEEObj->SetTrackletMode(fContent);\r | |
298 | if (strName.Contains("TRCKLTDEF")) fDCSFEEObj->SetTrackletDef(fContent);\r | |
299 | if (strName.Contains("TRIGGERSETUP")) fDCSFEEObj->SetTriggerSetup(fContent);\r | |
300 | if (strName.Contains("ADDOPTIONS")) fDCSFEEObj->SetAddOptions(fContent);\r | |
301 | if (fInsideRstate == 1) {\r | |
302 | if (fCurrentROB>=0 && fCurrentMCM>=0) {\r | |
303 | if (strName.Contains("gsm")) fDCSFEEObj->SetMCMGlobalState(fCurrentROB, fCurrentMCM, fContent.Atoi());\r | |
304 | if (strName.Contains("ni")) fDCSFEEObj->SetMCMStateNI(fCurrentROB, fCurrentMCM, fContent.Atoi());\r | |
305 | if (strName.Contains("ev")) fDCSFEEObj->SetMCMEventCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());\r | |
306 | if (strName.Contains("ptrg")) fDCSFEEObj->SetMCMPtCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());\r | |
307 | }\r | |
308 | }\r | |
6b36d985 | 309 | }\r |
310 | \r | |
311 | \r | |
312 | // store pretrigger informations\r | |
313 | if (fSystem == kInsidePTR) {\r | |
314 | // no informations available yet\r | |
315 | }\r | |
316 | // store GTU informations\r | |
317 | if (fSystem == kInsideGTU) {\r | |
318 | if (strName.Contains("SMMASK"))\r | |
319 | fHandlerStatus = fDCSGTUObj->SetSMMask(fContent);\r | |
320 | if (strName.Contains("LINKMASK")) \r | |
321 | fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent);\r | |
322 | if (strName.Contains("STMASK"))\r | |
323 | fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi());\r | |
324 | }\r | |
325 | }\r | |
326 | \r | |
327 | //_____________________________________________________________________________\r | |
328 | void AliTRDSaxHandler::OnCharacters(const char *characters)\r | |
329 | {\r | |
330 | // copy the the text content of an XML element\r | |
331 | fContent = characters;\r | |
332 | }\r | |
333 | \r | |
334 | //_____________________________________________________________________________\r | |
335 | void AliTRDSaxHandler::OnComment(const char* /*text*/)\r | |
336 | {\r | |
337 | // comments within the XML file are ignored\r | |
338 | }\r | |
339 | \r | |
340 | //_____________________________________________________________________________\r | |
341 | void AliTRDSaxHandler::OnWarning(const char *text)\r | |
342 | {\r | |
343 | // process warnings here\r | |
344 | AliInfo(Form("Warning: %s",text));\r | |
345 | }\r | |
346 | \r | |
347 | //_____________________________________________________________________________\r | |
348 | void AliTRDSaxHandler::OnError(const char *text)\r | |
349 | {\r | |
350 | // process errors here\r | |
351 | AliError(Form("Error: %s",text));\r | |
352 | }\r | |
353 | \r | |
354 | //_____________________________________________________________________________\r | |
355 | void AliTRDSaxHandler::OnFatalError(const char *text)\r | |
356 | {\r | |
357 | // process fatal errors here\r | |
358 | AliError(Form("Fatal error: %s",text)); // use AliFatal?\r | |
359 | }\r | |
360 | \r | |
361 | //_____________________________________________________________________________\r | |
362 | void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)\r | |
363 | {\r | |
364 | // process character data blocks here\r | |
365 | // not implemented and should not be used here\r | |
366 | }\r | |
367 | \r |