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 ////////////////////////////////////////////////////////////////////////////
27 #include <Riostream.h>
29 #include <TObjArray.h>
30 #include <TXMLParser.h>
31 #include <TSAXParser.h>
32 #include "AliTRDSaxHandler.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"
42 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
119 //_____________________________________________________________________________
120 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
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);
130 //_____________________________________________________________________________
131 void AliTRDSaxHandler::OnStartDocument()
133 // if something should happen right at the beginning of the
134 // XML document, this must happen here
137 //_____________________________________________________________________________
138 void AliTRDSaxHandler::OnEndDocument()
140 // if something should happen at the end of the XML document
141 // this must be done here
144 //_____________________________________________________________________________
145 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
147 // when a new XML element is found, it is processed here
150 TString strName = name;
151 TString dcsTitle = "";
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;
158 // get the attributes of the element
160 TIter next(attributes);
161 while ((attr = (TXMLAttr*) next())) {
162 TString attribName = attr->GetName();
163 if (attribName.Contains("id") && strName.Contains("DCS")) {
165 dcsId = atoi(attr->GetValue());
167 if (attribName.Contains("sm") && strName.Contains("DCS")) {
168 fCurrentSM = atoi(attr->GetValue());
170 if (attribName.Contains("id") && strName.Contains("STACK")) {
171 fCurrentStack = atoi(attr->GetValue());
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);
181 if (fSystem == kInsidePTR) {
182 fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
183 fDCSPTRObj->SetDCSid(dcsId);
185 if (fSystem == kInsideGTU) {
186 fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
187 fDCSGTUObj->SetDCSid(dcsId);
192 //_____________________________________________________________________________
193 void AliTRDSaxHandler::OnEndElement(const char *name)
195 // do everything that needs to be done when an end tag of an element is found
196 TString strName = name;
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);
207 if (fSystem == kInsidePTR) {
208 fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
211 if (fSystem == kInsideGTU) {
212 fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
215 fCurrentSM = 99; // 99 for no SM set
216 fDCSFEEObj = 0; // just to be sure
220 // done with this stack?
221 if (strName.Contains("STACK")) {
222 fCurrentStack = 99; // 99 for no stack set
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());
239 // store pretrigger informations
240 if (fSystem == kInsidePTR) {
241 // no informations available yet
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());
256 //_____________________________________________________________________________
257 void AliTRDSaxHandler::OnCharacters(const char *characters)
259 // copy the the text content of an XML element
260 fContent = characters;
263 //_____________________________________________________________________________
264 void AliTRDSaxHandler::OnComment(const char* /*text*/)
266 // comments within the XML file are ignored
269 //_____________________________________________________________________________
270 void AliTRDSaxHandler::OnWarning(const char *text)
272 // process warnings here
273 AliInfo(Form("Warning: %s",text));
276 //_____________________________________________________________________________
277 void AliTRDSaxHandler::OnError(const char *text)
279 // process errors here
280 AliError(Form("Error: %s",text));
283 //_____________________________________________________________________________
284 void AliTRDSaxHandler::OnFatalError(const char *text)
286 // process fatal errors here
287 AliError(Form("Fatal error: %s",text)); // use AliFatal?
290 //_____________________________________________________________________________
291 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
293 // process character data blocks here
294 // not implemented and should not be used here