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>
30 #include <TSAXParser.h>
31 #include <TObjArray.h>
35 #include "AliTRDSaxHandler.h"
36 #include "AliTRDgeometry.h"
38 #include "Cal/AliTRDCalDCS.h"
39 #include "Cal/AliTRDCalDCSFEE.h"
40 #include "Cal/AliTRDCalDCSPTR.h"
41 #include "Cal/AliTRDCalDCSGTU.h"
43 ClassImp(AliTRDSaxHandler)
45 //_____________________________________________________________________________
46 AliTRDSaxHandler::AliTRDSaxHandler()
51 ,fFEEArr(new TObjArray(540))
52 ,fPTRArr(new TObjArray(6))
53 ,fGTUArr(new TObjArray(19))
61 ,fCalDCSObj(new AliTRDCalDCS())
64 // AliTRDSaxHandler default constructor
71 //_____________________________________________________________________________
72 AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)
90 // AliTRDSaxHandler copy constructor
94 //_____________________________________________________________________________
95 AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)
98 // Assignment operator
100 if (&sh == this) return *this;
102 new (this) AliTRDSaxHandler(sh);
106 //_____________________________________________________________________________
107 AliTRDSaxHandler::~AliTRDSaxHandler()
110 // AliTRDSaxHandler destructor
132 //_____________________________________________________________________________
133 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
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);
143 //_____________________________________________________________________________
144 void AliTRDSaxHandler::OnStartDocument()
146 // if something should happen right at the beginning of the
147 // XML document, this must happen here
150 //_____________________________________________________________________________
151 void AliTRDSaxHandler::OnEndDocument()
153 // if something should happen at the end of the XML document
154 // this must be done here
157 //_____________________________________________________________________________
158 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
160 // when a new XML element is found, it is processed here
163 TString strName = name;
164 TString dcsTitle = "";
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;
171 // get the attributes of the element
173 TIter next(attributes);
174 while ((attr = (TXMLAttr*) next())) {
175 TString attribName = attr->GetName();
176 if (attribName.Contains("id") && strName.Contains("DCS")) {
178 dcsId = atoi(attr->GetValue());
180 if (attribName.Contains("sm") && strName.Contains("DCS")) {
181 fCurrentSM = atoi(attr->GetValue());
183 if (attribName.Contains("id") && strName.Contains("STACK")) {
184 fCurrentStack = atoi(attr->GetValue());
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);
194 if (fSystem == kInsidePTR) {
195 fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
196 fDCSPTRObj->SetDCSid(dcsId);
198 if (fSystem == kInsideGTU) {
199 fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
200 fDCSGTUObj->SetDCSid(dcsId);
205 //_____________________________________________________________________________
206 void AliTRDSaxHandler::OnEndElement(const char *name)
208 // do everything that needs to be done when an end tag of an element is found
209 TString strName = name;
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);
220 if (fSystem == kInsidePTR) {
221 fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
224 if (fSystem == kInsideGTU) {
225 fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
228 fCurrentSM = 99; // 99 for no SM set
229 fDCSFEEObj = 0; // just to be sure
233 // done with this stack?
234 if (strName.Contains("STACK")) {
235 fCurrentStack = 99; // 99 for no stack set
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());
252 // store pretrigger informations
253 if (fSystem == kInsidePTR) {
254 // no informations available yet
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());
269 //_____________________________________________________________________________
270 void AliTRDSaxHandler::OnCharacters(const char *characters)
272 // copy the the text content of an XML element
273 fContent = characters;
276 //_____________________________________________________________________________
277 void AliTRDSaxHandler::OnComment(const char* /*text*/)
279 // comments within the XML file are ignored
282 //_____________________________________________________________________________
283 void AliTRDSaxHandler::OnWarning(const char *text)
285 // process warnings here
286 AliInfo(Form("Warning: %s",text));
289 //_____________________________________________________________________________
290 void AliTRDSaxHandler::OnError(const char *text)
292 // process errors here
293 AliError(Form("Error: %s",text));
296 //_____________________________________________________________________________
297 void AliTRDSaxHandler::OnFatalError(const char *text)
299 // process fatal errors here
300 AliError(Form("Fatal error: %s",text)); // use AliFatal?
303 //_____________________________________________________________________________
304 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
306 // process character data blocks here
307 // not implemented and should not be used here