1 /*************************************************************************
\r
2 * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
\r
4 * * Author: The ALICE Off-line Project. *
\r
5 * * Contributors are mentioned in the code where appropriate. *
\r
7 * * Permission to use, copy, modify and distribute this software and its *
\r
8 * * documentation strictly for non-commercial purposes is hereby granted *
\r
9 * * without fee, provided that the above copyright notice appears in all *
\r
10 * * copies and that both the copyright notice and this permission notice *
\r
11 * * appear in the supporting documentation. The authors make no claims *
\r
12 * * about the suitability of this software for any purpose. It is *
\r
13 * * provided "as is" without express or implied warranty. *
\r
14 * **************************************************************************/
\r
16 /* $Id: AliTRDSaxHandler.cxx 26327 2008-06-02 15:36:18Z cblume $ */
\r
18 ////////////////////////////////////////////////////////////////////////////
\r
20 // The SAX XML file handler used in the preprocessor //
\r
23 // Frederick Kramer (kramer@ikf.uni-frankfurt.de) //
\r
25 ////////////////////////////////////////////////////////////////////////////
\r
28 #include <Riostream.h>
\r
30 #include <TXMLAttr.h>
\r
31 #include <TSAXParser.h>
\r
32 #include <TObjArray.h>
\r
36 #include "AliTRDSaxHandler.h"
\r
37 #include "AliTRDgeometry.h"
\r
39 #include "Cal/AliTRDCalDCS.h"
\r
40 #include "Cal/AliTRDCalDCSFEE.h"
\r
41 #include "Cal/AliTRDCalDCSPTR.h"
\r
42 #include "Cal/AliTRDCalDCSGTU.h"
\r
44 ClassImp(AliTRDSaxHandler)
\r
47 //_____________________________________________________________________________
\r
48 AliTRDSaxHandler::AliTRDSaxHandler()
\r
53 ,fFEEArr(new TObjArray(540))
\r
54 ,fPTRArr(new TObjArray(6))
\r
55 ,fGTUArr(new TObjArray(19))
\r
66 ,fCalDCSObj(new AliTRDCalDCS())
\r
69 // AliTRDSaxHandler default constructor
\r
71 fFEEArr->SetOwner();
\r
72 fPTRArr->SetOwner();
\r
73 fGTUArr->SetOwner();
\r
76 //_____________________________________________________________________________
\r
77 AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)
\r
98 // AliTRDSaxHandler copy constructor
\r
102 //_____________________________________________________________________________
\r
103 AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)
\r
106 // Assignment operator
\r
108 if (&sh == this) return *this;
\r
110 new (this) AliTRDSaxHandler(sh);
\r
114 //_____________________________________________________________________________
\r
115 AliTRDSaxHandler::~AliTRDSaxHandler()
\r
118 // AliTRDSaxHandler destructor
\r
140 //_____________________________________________________________________________
\r
141 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
\r
143 // put the arrays in the global calibration object and return this
\r
144 fCalDCSObj->SetFEEArr(fFEEArr);
\r
145 fCalDCSObj->SetPTRArr(fPTRArr);
\r
146 fCalDCSObj->SetGTUArr(fGTUArr);
\r
150 //_____________________________________________________________________________
\r
151 void AliTRDSaxHandler::OnStartDocument()
\r
153 // if something should happen right at the beginning of the
\r
154 // XML document, this must happen here
\r
157 //_____________________________________________________________________________
\r
158 void AliTRDSaxHandler::OnEndDocument()
\r
160 // if something should happen at the end of the XML document
\r
161 // this must be done here
\r
164 //_____________________________________________________________________________
\r
165 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
\r
167 // when a new XML element is found, it is processed here
\r
170 TString strName = name;
\r
171 TString dcsTitle = "";
\r
173 // set the current system if necessary
\r
174 if (strName.Contains("FEE")) fSystem = kInsideFEE;
\r
175 if (strName.Contains("PTR")) fSystem = kInsidePTR;
\r
176 if (strName.Contains("GTU")) fSystem = kInsideGTU;
\r
178 // set if we are inside rstate
\r
179 // (in principle not necessary - just to be more safe against stupid tags)
\r
180 if (strName.Contains("rstate")) fInsideRstate = 1;
\r
182 // get the attributes of the element
\r
184 TIter next(attributes);
\r
185 while ((attr = (TXMLAttr*) next())) {
\r
186 TString attribName = attr->GetName();
\r
187 if (attribName.Contains("id") && strName.Contains("DCS")) {
\r
189 dcsId = atoi(attr->GetValue());
\r
191 if (attribName.Contains("roc") && strName.Contains("ack")) {
\r
192 if (atoi(attr->GetValue()) != fDCSFEEObj->GetDCSid())
\r
193 fDCSFEEObj->SetStatusBit(3); // consistence check
\r
195 if (attribName.Contains("rob") && (fInsideRstate == 1)) {
\r
196 fCurrentROB = atoi(attr->GetValue());
\r
198 if (attribName.Contains("mcm") && (fInsideRstate == 1)) {
\r
199 fCurrentMCM = atoi(attr->GetValue());
\r
201 if (attribName.Contains("sm") && strName.Contains("DCS")) {
\r
202 fCurrentSM = atoi(attr->GetValue()); // only for GTU/PTR
\r
204 if (attribName.Contains("id") && strName.Contains("STACK")) {
\r
205 fCurrentStack = atoi(attr->GetValue()); // only for GTU/PTR
\r
209 // if there is a new DCS element put it in the correct array
\r
210 if (strName.Contains("DCS")) {
\r
211 if (fSystem == kInsideFEE) {
\r
212 fDCSFEEObj = new AliTRDCalDCSFEE(name,dcsTitle);
\r
213 fDCSFEEObj->SetDCSid(dcsId);
\r
215 if (fSystem == kInsidePTR) {
\r
216 fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
\r
217 fDCSPTRObj->SetDCSid(dcsId);
\r
219 if (fSystem == kInsideGTU) {
\r
220 fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
\r
221 fDCSGTUObj->SetDCSid(dcsId);
\r
226 //_____________________________________________________________________________
\r
227 void AliTRDSaxHandler::OnEndElement(const char *name)
\r
229 // do everything that needs to be done when an end tag of an element is found
\r
230 TString strName = name;
\r
232 // if done with this DCS board, put it in the correct array
\r
233 // no check for </ack> necessary since this check is done during XML validation
\r
234 if (strName.Contains("DCS")) {
\r
235 if (fSystem == kInsideFEE) {
\r
237 if (fDCSFEEObj->GetStatusBit() == 0) {
\r
238 // if there were no errors (StatusBit==0) the following should match
\r
239 detID = fDCSFEEObj->GetDCSid();
\r
240 AliTRDgeometry aliGeo;
\r
241 Int_t calDetID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(),
\r
242 fDCSFEEObj->GetStack(),
\r
243 fDCSFEEObj->GetSM());
\r
244 if (detID != calDetID) fDCSFEEObj->SetStatusBit(4);
\r
246 // if the dcs board didn't properly respond, don't compare
\r
247 detID = fDCSFEEObj->GetDCSid();
\r
249 fFEEArr->AddAt(fDCSFEEObj,detID);
\r
251 if (fSystem == kInsidePTR) {
\r
252 fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
\r
255 if (fSystem == kInsideGTU) {
\r
256 fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
\r
259 fCurrentSM = 99; // 99 for no SM set
\r
260 fDCSFEEObj = 0; // just to be sure
\r
264 // done with this stack?
\r
265 if (strName.Contains("STACK")) {
\r
266 fCurrentStack = 99; // 99 for no stack set
\r
269 // outside of rstate again?
\r
270 if (strName.Contains("rstate")) {
\r
275 if (strName.Contains("ro-board")) fCurrentROB = -1;
\r
277 // store informations of the FEE DCS-Board
\r
278 if (fSystem == kInsideFEE) {
\r
279 if (strName.Contains("DNR")) fDCSFEEObj->SetStatusBit(fContent.Atoi());
\r
280 if (strName.Contains("CFGNME")) fDCSFEEObj->SetConfigName(fContent);
\r
281 if (strName.Contains("CFGTAG")) fDCSFEEObj->SetConfigTag(fContent.Atoi());
\r
282 if (strName.Contains("CFGVRSN")) fDCSFEEObj->SetConfigVersion(fContent);
\r
283 if (strName.Contains("NTB")) fDCSFEEObj->SetNumberOfTimeBins(fContent.Atoi());
\r
284 if (strName.Contains("SM-ID")) fDCSFEEObj->SetSM(fContent.Atoi());
\r
285 if (strName.Contains("STACK-ID")) fDCSFEEObj->SetStack(fContent.Atoi());
\r
286 if (strName.Contains("LAYER-ID")) fDCSFEEObj->SetLayer(fContent.Atoi());
\r
287 if (strName.Contains("SINGLEHITTHRES")) fDCSFEEObj->SetSingleHitThres(fContent.Atoi());
\r
288 if (strName.Contains("THRPADCLSTHRS")) fDCSFEEObj->SetThreePadClustThres(fContent.Atoi());
\r
289 if (strName.Contains("SELNOZS")) fDCSFEEObj->SetSelectiveNoZS(fContent.Atoi());
\r
290 if (strName.Contains("FASTSTATNOISE")) fDCSFEEObj->SetFastStatNoise(fContent.Atoi());
\r
291 if (strName.Contains("FILTWEIGHT")) fDCSFEEObj->SetTCFilterWeight(fContent.Atoi());
\r
292 if (strName.Contains("FILTSHRTDCYPRM")) fDCSFEEObj->SetTCFilterShortDecPar(fContent.Atoi());
\r
293 if (strName.Contains("FILTLNGDCYPRM")) fDCSFEEObj->SetTCFilterLongDecPar(fContent.Atoi());
\r
294 if (strName.Contains("FLTR")) fDCSFEEObj->SetFilterType(fContent);
\r
295 if (strName.Contains("READOUTPAR")) fDCSFEEObj->SetReadoutParam(fContent);
\r
296 if (strName.Contains("TESTPATTERN")) fDCSFEEObj->SetTestPattern(fContent);
\r
297 if (strName.Contains("TRCKLTMODE")) fDCSFEEObj->SetTrackletMode(fContent);
\r
298 if (strName.Contains("TRCKLTDEF")) fDCSFEEObj->SetTrackletDef(fContent);
\r
299 if (strName.Contains("TRIGGERSETUP")) fDCSFEEObj->SetTriggerSetup(fContent);
\r
300 if (strName.Contains("ADDOPTIONS")) fDCSFEEObj->SetAddOptions(fContent);
\r
301 if (fInsideRstate == 1) {
\r
302 if (fCurrentROB>=0 && fCurrentMCM>=0) {
\r
303 if (strName.Contains("gsm")) fDCSFEEObj->SetMCMGlobalState(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
304 if (strName.Contains("ni")) fDCSFEEObj->SetMCMStateNI(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
305 if (strName.Contains("ev")) fDCSFEEObj->SetMCMEventCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
306 if (strName.Contains("ptrg")) fDCSFEEObj->SetMCMPtCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
312 // store pretrigger informations
\r
313 if (fSystem == kInsidePTR) {
\r
314 // no informations available yet
\r
316 // store GTU informations
\r
317 if (fSystem == kInsideGTU) {
\r
318 if (strName.Contains("SMMASK"))
\r
319 fHandlerStatus = fDCSGTUObj->SetSMMask(fContent);
\r
320 if (strName.Contains("LINKMASK"))
\r
321 fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent);
\r
322 if (strName.Contains("STMASK"))
\r
323 fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi());
\r
327 //_____________________________________________________________________________
\r
328 void AliTRDSaxHandler::OnCharacters(const char *characters)
\r
330 // copy the the text content of an XML element
\r
331 fContent = characters;
\r
334 //_____________________________________________________________________________
\r
335 void AliTRDSaxHandler::OnComment(const char* /*text*/)
\r
337 // comments within the XML file are ignored
\r
340 //_____________________________________________________________________________
\r
341 void AliTRDSaxHandler::OnWarning(const char *text)
\r
343 // process warnings here
\r
344 AliInfo(Form("Warning: %s",text));
\r
347 //_____________________________________________________________________________
\r
348 void AliTRDSaxHandler::OnError(const char *text)
\r
350 // process errors here
\r
351 AliError(Form("Error: %s",text));
\r
354 //_____________________________________________________________________________
\r
355 void AliTRDSaxHandler::OnFatalError(const char *text)
\r
357 // process fatal errors here
\r
358 AliError(Form("Fatal error: %s",text)); // use AliFatal?
\r
361 //_____________________________________________________________________________
\r
362 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
\r
364 // process character data blocks here
\r
365 // not implemented and should not be used here
\r