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