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>
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
118 //_____________________________________________________________________________
119 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
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);
129 //_____________________________________________________________________________
130 void AliTRDSaxHandler::OnStartDocument()
132 // if something should happen right at the beginning of the
133 // XML document, this must happen here
136 //_____________________________________________________________________________
137 void AliTRDSaxHandler::OnEndDocument()
139 // if something should happen at the end of the XML document
140 // this must be done here
143 //_____________________________________________________________________________
144 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
146 // when a new XML element is found, it is processed here
149 TString strName = name;
150 TString dcsTitle = "";
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;
157 // get the attributes of the element
159 TIter next(attributes);
160 while ((attr = (TXMLAttr*) next())) {
161 TString attribName = attr->GetName();
162 if (attribName.Contains("id") && strName.Contains("DCS")) {
164 dcsId = atoi(attr->GetValue());
166 if (attribName.Contains("sm") && strName.Contains("DCS")) {
167 fCurrentSM = atoi(attr->GetValue());
169 if (attribName.Contains("id") && strName.Contains("STACK")) {
170 fCurrentStack = atoi(attr->GetValue());
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);
180 if (fSystem == kInsidePTR) {
181 fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
182 fDCSPTRObj->SetDCSid(dcsId);
184 if (fSystem == kInsideGTU) {
185 fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
186 fDCSGTUObj->SetDCSid(dcsId);
191 //_____________________________________________________________________________
192 void AliTRDSaxHandler::OnEndElement(const char *name)
194 // do everything that needs to be done when an end tag of an element is found
195 TString strName = name;
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);
206 if (fSystem == kInsidePTR) {
207 fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
210 if (fSystem == kInsideGTU) {
211 fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
214 fCurrentSM = 99; // 99 for no SM set
215 fDCSFEEObj = 0; // just to be sure
219 // done with this stack?
220 if (strName.Contains("STACK")) {
221 fCurrentStack = 99; // 99 for no stack set
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());
238 // store pretrigger informations
239 if (fSystem == kInsidePTR) {
240 // no informations available yet
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());
255 //_____________________________________________________________________________
256 void AliTRDSaxHandler::OnCharacters(const char *characters)
258 // copy the the text content of an XML element
259 fContent = characters;
262 //_____________________________________________________________________________
263 void AliTRDSaxHandler::OnComment(const char* /*text*/)
265 // comments within the XML file are ignored
268 //_____________________________________________________________________________
269 void AliTRDSaxHandler::OnWarning(const char *text)
271 // process warnings here
272 AliInfo(Form("Warning: %s",text));
275 //_____________________________________________________________________________
276 void AliTRDSaxHandler::OnError(const char *text)
278 // process errors here
279 AliError(Form("Error: %s",text));
282 //_____________________________________________________________________________
283 vois AliTRDSaxHandler::OnFatalError(const char *text)
285 // process fatal errors here
286 AliError(Form("Fatal error: %s",text)); // use AliFatal?
289 //_____________________________________________________________________________
290 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
292 // process character data blocks here
293 // not implemented and should not be used here