1 /*************************************************************************
2 * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * * Author: The ALICE Off-line Project. *
5 * * Contributors are mentioned in the code where appropriate. *
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 * **************************************************************************/
16 /* $Id: AliTRDSaxHandler.cxx 26327 2008-06-02 15:36:18Z cblume $ */
18 ////////////////////////////////////////////////////////////////////////////
20 // The SAX XML file handler used in the preprocessor //
23 // Frederick Kramer (kramer@ikf.uni-frankfurt.de) //
25 ////////////////////////////////////////////////////////////////////////////
28 #include <Riostream.h>
31 #include <TSAXParser.h>
32 #include <TObjArray.h>
36 #include "AliTRDSaxHandler.h"
37 #include "AliTRDgeometry.h"
39 #include "Cal/AliTRDCalDCS.h"
40 #include "Cal/AliTRDCalDCSFEE.h"
41 #include "Cal/AliTRDCalDCSPTR.h"
42 #include "Cal/AliTRDCalDCSGTU.h"
44 ClassImp(AliTRDSaxHandler)
46 //_____________________________________________________________________________
47 AliTRDSaxHandler::AliTRDSaxHandler()
52 ,fFEEArr(new TObjArray(540))
53 ,fPTRArr(new TObjArray(6))
54 ,fGTUArr(new TObjArray(19))
62 ,fCalDCSObj(new AliTRDCalDCS())
65 // AliTRDSaxHandler default constructor
72 //_____________________________________________________________________________
73 AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)
91 // AliTRDSaxHandler copy constructor
95 //_____________________________________________________________________________
96 AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)
99 // Assignment operator
101 if (&sh == this) return *this;
103 new (this) AliTRDSaxHandler(sh);
107 //_____________________________________________________________________________
108 AliTRDSaxHandler::~AliTRDSaxHandler()
111 // AliTRDSaxHandler destructor
133 //_____________________________________________________________________________
134 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
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);
144 //_____________________________________________________________________________
145 void AliTRDSaxHandler::OnStartDocument()
147 // if something should happen right at the beginning of the
148 // XML document, this must happen here
151 //_____________________________________________________________________________
152 void AliTRDSaxHandler::OnEndDocument()
154 // if something should happen at the end of the XML document
155 // this must be done here
158 //_____________________________________________________________________________
159 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
161 // when a new XML element is found, it is processed here
164 TString strName = name;
165 TString dcsTitle = "";
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;
172 // get the attributes of the element
174 TIter next(attributes);
175 while ((attr = (TXMLAttr*) next())) {
176 TString attribName = attr->GetName();
177 if (attribName.Contains("id") && strName.Contains("DCS")) {
179 dcsId = atoi(attr->GetValue());
181 if (attribName.Contains("sm") && strName.Contains("DCS")) {
182 fCurrentSM = atoi(attr->GetValue());
184 if (attribName.Contains("id") && strName.Contains("STACK")) {
185 fCurrentStack = atoi(attr->GetValue());
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);
195 if (fSystem == kInsidePTR) {
196 fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
197 fDCSPTRObj->SetDCSid(dcsId);
199 if (fSystem == kInsideGTU) {
200 fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
201 fDCSGTUObj->SetDCSid(dcsId);
206 //_____________________________________________________________________________
207 void AliTRDSaxHandler::OnEndElement(const char *name)
209 // do everything that needs to be done when an end tag of an element is found
210 TString strName = name;
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);
221 if (fSystem == kInsidePTR) {
222 fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
225 if (fSystem == kInsideGTU) {
226 fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
229 fCurrentSM = 99; // 99 for no SM set
230 fDCSFEEObj = 0; // just to be sure
234 // done with this stack?
235 if (strName.Contains("STACK")) {
236 fCurrentStack = 99; // 99 for no stack set
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());
253 // store pretrigger informations
254 if (fSystem == kInsidePTR) {
255 // no informations available yet
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());
270 //_____________________________________________________________________________
271 void AliTRDSaxHandler::OnCharacters(const char *characters)
273 // copy the the text content of an XML element
274 fContent = characters;
277 //_____________________________________________________________________________
278 void AliTRDSaxHandler::OnComment(const char* /*text*/)
280 // comments within the XML file are ignored
283 //_____________________________________________________________________________
284 void AliTRDSaxHandler::OnWarning(const char *text)
286 // process warnings here
287 AliInfo(Form("Warning: %s",text));
290 //_____________________________________________________________________________
291 void AliTRDSaxHandler::OnError(const char *text)
293 // process errors here
294 AliError(Form("Error: %s",text));
297 //_____________________________________________________________________________
298 void AliTRDSaxHandler::OnFatalError(const char *text)
300 // process fatal errors here
301 AliError(Form("Fatal error: %s",text)); // use AliFatal?
304 //_____________________________________________________________________________
305 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
307 // process character data blocks here
308 // not implemented and should not be used here