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 <TXMLAttr.h>
\r
29 #include <TObjArray.h>
\r
34 #include "AliTRDSaxHandler.h"
\r
35 #include "AliTRDgeometry.h"
\r
37 #include "Cal/AliTRDCalDCS.h"
\r
38 #include "Cal/AliTRDCalDCSFEE.h"
\r
39 #include "Cal/AliTRDCalDCSPTR.h"
\r
40 #include "Cal/AliTRDCalDCSGTU.h"
\r
42 ClassImp(AliTRDSaxHandler)
\r
44 //_____________________________________________________________________________
\r
45 AliTRDSaxHandler::AliTRDSaxHandler()
\r
50 ,fFEEArr(new TObjArray(540))
\r
51 ,fPTRArr(new TObjArray(6))
\r
52 ,fGTUArr(new TObjArray(19))
\r
63 ,fCalDCSObj(new AliTRDCalDCS())
\r
66 // AliTRDSaxHandler default constructor
\r
68 fFEEArr->SetOwner();
\r
69 fPTRArr->SetOwner();
\r
70 fGTUArr->SetOwner();
\r
73 //_____________________________________________________________________________
\r
74 AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)
\r
95 // AliTRDSaxHandler copy constructor
\r
99 //_____________________________________________________________________________
\r
100 AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)
\r
103 // Assignment operator
\r
105 if (&sh == this) return *this;
\r
107 new (this) AliTRDSaxHandler(sh);
\r
111 //_____________________________________________________________________________
\r
112 AliTRDSaxHandler::~AliTRDSaxHandler()
\r
115 // AliTRDSaxHandler destructor
\r
137 //_____________________________________________________________________________
\r
138 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
\r
140 // put the arrays in the global calibration object and return this
\r
141 fCalDCSObj->SetFEEArr(fFEEArr);
\r
142 fCalDCSObj->SetPTRArr(fPTRArr);
\r
143 fCalDCSObj->SetGTUArr(fGTUArr);
\r
147 //_____________________________________________________________________________
\r
148 void AliTRDSaxHandler::OnStartDocument()
\r
150 // if something should happen right at the beginning of the
\r
151 // XML document, this must happen here
\r
154 //_____________________________________________________________________________
\r
155 void AliTRDSaxHandler::OnEndDocument()
\r
157 // if something should happen at the end of the XML document
\r
158 // this must be done here
\r
161 //_____________________________________________________________________________
\r
162 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
\r
164 // when a new XML element is found, it is processed here
\r
167 TString strName = name;
\r
168 TString dcsTitle = "";
\r
170 // set the current system if necessary
\r
171 if (strName.Contains("FEE")) fSystem = kInsideFEE;
\r
172 if (strName.Contains("PTR")) fSystem = kInsidePTR;
\r
173 if (strName.Contains("GTU")) fSystem = kInsideGTU;
\r
175 // set if we are inside rstate
\r
176 // (in principle not necessary - just to be more safe against stupid tags)
\r
177 if (strName.Contains("rstate")) fInsideRstate = 1;
\r
179 // get the attributes of the element
\r
181 TIter next(attributes);
\r
182 while ((attr = (TXMLAttr*) next())) {
\r
183 TString attribName = attr->GetName();
\r
184 if (attribName.Contains("id") && strName.Contains("DCS")) {
\r
186 dcsId = atoi(attr->GetValue());
\r
188 if (attribName.Contains("roc") && strName.Contains("ack")) {
\r
189 if (atoi(attr->GetValue()) != fDCSFEEObj->GetDCSid())
\r
190 fDCSFEEObj->SetStatusBit(3); // consistence check
\r
192 if (attribName.Contains("rob") && (fInsideRstate == 1)) {
\r
193 fCurrentROB = atoi(attr->GetValue());
\r
195 if (attribName.Contains("mcm") && (fInsideRstate == 1)) {
\r
196 fCurrentMCM = atoi(attr->GetValue());
\r
198 if (attribName.Contains("sm") && strName.Contains("DCS")) {
\r
199 fCurrentSM = atoi(attr->GetValue()); // only for GTU/PTR
\r
201 if (attribName.Contains("id") && strName.Contains("STACK")) {
\r
202 fCurrentStack = atoi(attr->GetValue()); // only for GTU/PTR
\r
206 // if there is a new DCS element put it in the correct array
\r
207 if (strName.Contains("DCS")) {
\r
208 if (fSystem == kInsideFEE) {
\r
209 fDCSFEEObj = new AliTRDCalDCSFEE(name,dcsTitle);
\r
210 fDCSFEEObj->SetDCSid(dcsId);
\r
212 if (fSystem == kInsidePTR) {
\r
213 fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
\r
214 fDCSPTRObj->SetDCSid(dcsId);
\r
216 if (fSystem == kInsideGTU) {
\r
217 fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
\r
218 fDCSGTUObj->SetDCSid(dcsId);
\r
223 //_____________________________________________________________________________
\r
224 void AliTRDSaxHandler::OnEndElement(const char *name)
\r
226 // do everything that needs to be done when an end tag of an element is found
\r
227 TString strName = name;
\r
229 // if done with this DCS board, put it in the correct array
\r
230 // no check for </ack> necessary since this check is done during XML validation
\r
231 if (strName.Contains("DCS")) {
\r
232 if (fSystem == kInsideFEE) {
\r
234 if (fDCSFEEObj->GetStatusBit() == 0) {
\r
235 // if there were no errors (StatusBit==0) the following should match
\r
236 detID = fDCSFEEObj->GetDCSid();
\r
237 AliTRDgeometry aliGeo;
\r
238 Int_t calDetID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(),
\r
239 fDCSFEEObj->GetStack(),
\r
240 fDCSFEEObj->GetSM());
\r
241 if (detID != calDetID) fDCSFEEObj->SetStatusBit(4);
\r
243 // if the dcs board didn't properly respond, don't compare
\r
244 detID = fDCSFEEObj->GetDCSid();
\r
246 fFEEArr->AddAt(fDCSFEEObj,detID);
\r
248 if (fSystem == kInsidePTR) {
\r
249 fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
\r
252 if (fSystem == kInsideGTU) {
\r
253 fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
\r
256 fCurrentSM = 99; // 99 for no SM set
\r
257 fDCSFEEObj = 0; // just to be sure
\r
261 // done with this stack?
\r
262 if (strName.Contains("STACK")) {
\r
263 fCurrentStack = 99; // 99 for no stack set
\r
266 // outside of rstate again?
\r
267 if (strName.Contains("rstate")) {
\r
272 if (strName.Contains("ro-board")) fCurrentROB = -1;
\r
274 // store informations of the FEE DCS-Board
\r
275 if (fSystem == kInsideFEE) {
\r
276 if (strName.Contains("DNR")) fDCSFEEObj->SetStatusBit(fContent.Atoi());
\r
277 if (strName.Contains("CFGNME")) fDCSFEEObj->SetConfigName(fContent);
\r
278 if (strName.Contains("CFGTAG")) fDCSFEEObj->SetConfigTag(fContent.Atoi());
\r
279 if (strName.Contains("CFGVRSN")) fDCSFEEObj->SetConfigVersion(fContent);
\r
280 if (strName.Contains("NTB")) fDCSFEEObj->SetNumberOfTimeBins(fContent.Atoi());
\r
281 if (strName.Contains("SM-ID")) fDCSFEEObj->SetSM(fContent.Atoi());
\r
282 if (strName.Contains("STACK-ID")) fDCSFEEObj->SetStack(fContent.Atoi());
\r
283 if (strName.Contains("LAYER-ID")) fDCSFEEObj->SetLayer(fContent.Atoi());
\r
284 if (strName.Contains("SINGLEHITTHRES")) fDCSFEEObj->SetSingleHitThres(fContent.Atoi());
\r
285 if (strName.Contains("THRPADCLSTHRS")) fDCSFEEObj->SetThreePadClustThres(fContent.Atoi());
\r
286 if (strName.Contains("SELNOZS")) fDCSFEEObj->SetSelectiveNoZS(fContent.Atoi());
\r
287 if (strName.Contains("FASTSTATNOISE")) fDCSFEEObj->SetFastStatNoise(fContent.Atoi());
\r
288 if (strName.Contains("FILTWEIGHT")) fDCSFEEObj->SetTCFilterWeight(fContent.Atoi());
\r
289 if (strName.Contains("FILTSHRTDCYPRM")) fDCSFEEObj->SetTCFilterShortDecPar(fContent.Atoi());
\r
290 if (strName.Contains("FILTLNGDCYPRM")) fDCSFEEObj->SetTCFilterLongDecPar(fContent.Atoi());
\r
291 if (strName.Contains("FLTR")) fDCSFEEObj->SetFilterType(fContent);
\r
292 if (strName.Contains("READOUTPAR")) fDCSFEEObj->SetReadoutParam(fContent);
\r
293 if (strName.Contains("TESTPATTERN")) fDCSFEEObj->SetTestPattern(fContent);
\r
294 if (strName.Contains("TRCKLTMODE")) fDCSFEEObj->SetTrackletMode(fContent);
\r
295 if (strName.Contains("TRCKLTDEF")) fDCSFEEObj->SetTrackletDef(fContent);
\r
296 if (strName.Contains("TRIGGERSETUP")) fDCSFEEObj->SetTriggerSetup(fContent);
\r
297 if (strName.Contains("ADDOPTIONS")) fDCSFEEObj->SetAddOptions(fContent);
\r
298 if (fInsideRstate == 1) {
\r
299 if (fCurrentROB>=0 && fCurrentMCM>=0) {
\r
300 if (strName.Contains("gsm")) fDCSFEEObj->SetMCMGlobalState(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
301 if (strName.Contains("ni")) fDCSFEEObj->SetMCMStateNI(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
302 if (strName.Contains("ev")) fDCSFEEObj->SetMCMEventCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
303 if (strName.Contains("ptrg")) fDCSFEEObj->SetMCMPtCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());
\r
309 // store pretrigger informations
\r
310 if (fSystem == kInsidePTR) {
\r
311 // no informations available yet
\r
313 // store GTU informations
\r
314 if (fSystem == kInsideGTU) {
\r
315 if (strName.Contains("SMMASK"))
\r
316 fHandlerStatus = fDCSGTUObj->SetSMMask(fContent);
\r
317 if (strName.Contains("LINKMASK"))
\r
318 fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent);
\r
319 if (strName.Contains("STMASK"))
\r
320 fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi());
\r
324 //_____________________________________________________________________________
\r
325 void AliTRDSaxHandler::OnCharacters(const char *characters)
\r
327 // copy the the text content of an XML element
\r
328 fContent = characters;
\r
331 //_____________________________________________________________________________
\r
332 void AliTRDSaxHandler::OnComment(const char* /*text*/)
\r
334 // comments within the XML file are ignored
\r
337 //_____________________________________________________________________________
\r
338 void AliTRDSaxHandler::OnWarning(const char *text)
\r
340 // process warnings here
\r
341 AliInfo(Form("Warning: %s",text));
\r
344 //_____________________________________________________________________________
\r
345 void AliTRDSaxHandler::OnError(const char *text)
\r
347 // process errors here
\r
348 AliError(Form("Error: %s",text));
\r
351 //_____________________________________________________________________________
\r
352 void AliTRDSaxHandler::OnFatalError(const char *text)
\r
354 // process fatal errors here
\r
355 AliError(Form("Fatal error: %s",text)); // use AliFatal?
\r
358 //_____________________________________________________________________________
\r
359 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
\r
361 // process character data blocks here
\r
362 // not implemented and should not be used here
\r