]>
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 | // // | |
22 | // Authors: // | |
23 | // Frederick Kramer (kramer@ikf.uni-frankfurt.de) // | |
24 | // // | |
25 | //////////////////////////////////////////////////////////////////////////// | |
26 | ||
27 | #include <Riostream.h> | |
28 | #include <TList.h> | |
29 | #include <TObjArray.h> | |
30 | #include <TXMLParser.h> | |
31 | #include <TSAXParser.h> | |
32 | #include "AliTRDSaxHandler.h" | |
33 | #include <TXMLAttr.h> | |
34 | #include "Cal/AliTRDCalDCS.h" | |
35 | #include "Cal/AliTRDCalDCSFEE.h" | |
36 | #include "Cal/AliTRDCalDCSPTR.h" | |
37 | #include "Cal/AliTRDCalDCSGTU.h" | |
38 | #include "AliTRDgeometry.h" | |
39 | #include <AliLog.h> | |
40 | ||
41 | ||
42 | ClassImp(AliTRDSaxHandler) | |
43 | ||
44 | ||
45 | ||
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 | // | |
113 | delete fFEEArr; | |
114 | delete fPTRArr; | |
115 | delete fGTUArr; | |
116 | delete fCalDCSObj; | |
117 | } | |
118 | ||
119 | //_____________________________________________________________________________ | |
120 | AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj() | |
121 | { | |
122 | // put the arrays in the global calibration object and return this | |
123 | fCalDCSObj->SetNumberOfTimeBins(22); //test test test | |
124 | fCalDCSObj->SetFEEArr(fFEEArr); | |
125 | fCalDCSObj->SetPTRArr(fPTRArr); | |
126 | fCalDCSObj->SetGTUArr(fGTUArr); | |
127 | return fCalDCSObj; | |
128 | } | |
129 | ||
130 | //_____________________________________________________________________________ | |
131 | void AliTRDSaxHandler::OnStartDocument() | |
132 | { | |
133 | // if something should happen right at the beginning of the | |
134 | // XML document, this must happen here | |
135 | } | |
136 | ||
137 | //_____________________________________________________________________________ | |
138 | void AliTRDSaxHandler::OnEndDocument() | |
139 | { | |
140 | // if something should happen at the end of the XML document | |
141 | // this must be done here | |
142 | } | |
143 | ||
144 | //_____________________________________________________________________________ | |
145 | void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes) | |
146 | { | |
147 | // when a new XML element is found, it is processed here | |
148 | fContent = ""; | |
149 | Int_t dcsId = 0; | |
150 | TString strName = name; | |
151 | TString dcsTitle = ""; | |
152 | ||
153 | // set the current system if necessary | |
154 | if (strName.Contains("FEE")) fSystem = kInsideFEE; | |
155 | if (strName.Contains("PTR")) fSystem = kInsidePTR; | |
156 | if (strName.Contains("GTU")) fSystem = kInsideGTU; | |
157 | ||
158 | // get the attributes of the element | |
159 | TXMLAttr *attr; | |
160 | TIter next(attributes); | |
161 | while ((attr = (TXMLAttr*) next())) { | |
162 | TString attribName = attr->GetName(); | |
163 | if (attribName.Contains("id") && strName.Contains("DCS")) { | |
164 | dcsTitle = name; | |
165 | dcsId = atoi(attr->GetValue()); | |
166 | } | |
167 | if (attribName.Contains("sm") && strName.Contains("DCS")) { | |
168 | fCurrentSM = atoi(attr->GetValue()); | |
169 | } | |
170 | if (attribName.Contains("id") && strName.Contains("STACK")) { | |
171 | fCurrentStack = atoi(attr->GetValue()); | |
172 | } | |
173 | } | |
174 | ||
175 | // if there is a new DCS element put it in the correct array | |
176 | if (strName.Contains("DCS")) { | |
177 | if (fSystem == kInsideFEE) { | |
178 | fDCSFEEObj = new AliTRDCalDCSFEE(name,dcsTitle); | |
179 | fDCSFEEObj->SetDCSid(dcsId); | |
180 | } | |
181 | if (fSystem == kInsidePTR) { | |
182 | fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle); | |
183 | fDCSPTRObj->SetDCSid(dcsId); | |
184 | } | |
185 | if (fSystem == kInsideGTU) { | |
186 | fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle); | |
187 | fDCSGTUObj->SetDCSid(dcsId); | |
188 | } | |
189 | } | |
190 | } | |
191 | ||
192 | //_____________________________________________________________________________ | |
193 | void AliTRDSaxHandler::OnEndElement(const char *name) | |
194 | { | |
195 | // do everything that needs to be done when an end tag of an element is found | |
196 | TString strName = name; | |
197 | ||
198 | // if done with this DCS board, put it in the correct array | |
199 | if (strName.Contains("DCS")) { | |
200 | if (fSystem == kInsideFEE) { | |
201 | AliTRDgeometry aliGeo; | |
202 | Int_t detID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(), | |
203 | fDCSFEEObj->GetStack(), | |
204 | fDCSFEEObj->GetSM()); | |
205 | fFEEArr->AddAt(fDCSFEEObj,detID); | |
206 | } | |
207 | if (fSystem == kInsidePTR) { | |
208 | fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR); | |
209 | fNDCSPTR++; | |
210 | } | |
211 | if (fSystem == kInsideGTU) { | |
212 | fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU); | |
213 | fNDCSGTU++; | |
214 | } | |
215 | fCurrentSM = 99; // 99 for no SM set | |
216 | fDCSFEEObj = 0; // just to be sure | |
217 | return; | |
218 | } | |
219 | ||
220 | // done with this stack? | |
221 | if (strName.Contains("STACK")) { | |
222 | fCurrentStack = 99; // 99 for no stack set | |
223 | } | |
224 | ||
225 | // store informations of the FEE DCS-Board | |
226 | if (fSystem == kInsideFEE) { | |
227 | if (strName.Contains("CONFIG-ID")) | |
228 | fDCSFEEObj->SetConfigID(fContent); | |
229 | if (strName.Contains("NTBIN")) | |
230 | fDCSFEEObj->SetNumberOfTimeBins(fContent.Atoi()); | |
231 | if (strName.Contains("SM-ID")) | |
232 | fDCSFEEObj->SetSM(fContent.Atoi()); | |
233 | if (strName.Contains("STACK-ID")) | |
234 | fDCSFEEObj->SetStack(fContent.Atoi()); | |
235 | if (strName.Contains("LAYER-ID")) | |
236 | fDCSFEEObj->SetLayer(fContent.Atoi()); | |
237 | } | |
238 | ||
239 | // store pretrigger informations | |
240 | if (fSystem == kInsidePTR) { | |
241 | // no informations available yet | |
242 | } | |
243 | // store GTU informations | |
244 | if (fSystem == kInsideGTU) { | |
245 | if (strName.Contains("SMMASK")) | |
246 | fHandlerStatus = fDCSGTUObj->SetSMMask(fContent); | |
247 | if (strName.Contains("LINKMASK")) | |
248 | fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent); | |
249 | if (strName.Contains("STMASK")) | |
250 | fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi()); | |
251 | } | |
252 | ||
253 | ||
254 | } | |
255 | ||
256 | //_____________________________________________________________________________ | |
257 | void AliTRDSaxHandler::OnCharacters(const char *characters) | |
258 | { | |
259 | // copy the the text content of an XML element | |
260 | fContent = characters; | |
261 | } | |
262 | ||
263 | //_____________________________________________________________________________ | |
264 | void AliTRDSaxHandler::OnComment(const char* /*text*/) | |
265 | { | |
266 | // comments within the XML file are ignored | |
267 | } | |
268 | ||
269 | //_____________________________________________________________________________ | |
270 | void AliTRDSaxHandler::OnWarning(const char *text) | |
271 | { | |
272 | // process warnings here | |
273 | AliInfo(Form("Warning: %s",text)); | |
274 | } | |
275 | ||
276 | //_____________________________________________________________________________ | |
277 | void AliTRDSaxHandler::OnError(const char *text) | |
278 | { | |
279 | // process errors here | |
280 | AliError(Form("Error: %s",text)); | |
281 | } | |
282 | ||
283 | //_____________________________________________________________________________ | |
284 | void AliTRDSaxHandler::OnFatalError(const char *text) | |
285 | { | |
286 | // process fatal errors here | |
287 | AliError(Form("Fatal error: %s",text)); // use AliFatal? | |
288 | } | |
289 | ||
290 | //_____________________________________________________________________________ | |
291 | void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/) | |
292 | { | |
293 | // process character data blocks here | |
294 | // not implemented and should not be used here | |
295 | } | |
296 |