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