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
46 //_____________________________________________________________________________
\r
47 AliTRDSaxHandler::AliTRDSaxHandler()
\r
52 ,fFEEArr(new TObjArray(540))
\r
53 ,fPTRArr(new TObjArray(6))
\r
54 ,fGTUArr(new TObjArray(19))
\r
62 ,fCalDCSObj(new AliTRDCalDCS())
\r
65 // AliTRDSaxHandler default constructor
\r
67 fFEEArr->SetOwner();
\r
68 fPTRArr->SetOwner();
\r
69 fGTUArr->SetOwner();
\r
72 //_____________________________________________________________________________
\r
73 AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)
\r
91 // AliTRDSaxHandler copy constructor
\r
95 //_____________________________________________________________________________
\r
96 AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)
\r
99 // Assignment operator
\r
101 if (&sh == this) return *this;
\r
103 new (this) AliTRDSaxHandler(sh);
\r
107 //_____________________________________________________________________________
\r
108 AliTRDSaxHandler::~AliTRDSaxHandler()
\r
111 // AliTRDSaxHandler destructor
\r
133 //_____________________________________________________________________________
\r
134 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
\r
136 // put the arrays in the global calibration object and return this
\r
137 fCalDCSObj->SetNumberOfTimeBins(0); //test test test
\r
138 fCalDCSObj->SetFEEArr(fFEEArr);
\r
139 fCalDCSObj->SetPTRArr(fPTRArr);
\r
140 fCalDCSObj->SetGTUArr(fGTUArr);
\r
144 //_____________________________________________________________________________
\r
145 void AliTRDSaxHandler::OnStartDocument()
\r
147 // if something should happen right at the beginning of the
\r
148 // XML document, this must happen here
\r
151 //_____________________________________________________________________________
\r
152 void AliTRDSaxHandler::OnEndDocument()
\r
154 // if something should happen at the end of the XML document
\r
155 // this must be done here
\r
158 //_____________________________________________________________________________
\r
159 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
\r
161 // when a new XML element is found, it is processed here
\r
164 TString strName = name;
\r
165 TString dcsTitle = "";
\r
167 // set the current system if necessary
\r
168 if (strName.Contains("FEE")) fSystem = kInsideFEE;
\r
169 if (strName.Contains("PTR")) fSystem = kInsidePTR;
\r
170 if (strName.Contains("GTU")) fSystem = kInsideGTU;
\r
172 // get the attributes of the element
\r
174 TIter next(attributes);
\r
175 while ((attr = (TXMLAttr*) next())) {
\r
176 TString attribName = attr->GetName();
\r
177 if (attribName.Contains("id") && strName.Contains("DCS")) {
\r
179 dcsId = atoi(attr->GetValue());
\r
181 if (attribName.Contains("roc") && strName.Contains("ack")) {
\r
182 if (atoi(attr->GetValue()) != fDCSFEEObj->GetDCSid())
\r
183 fDCSFEEObj->SetStatusBit(3); // consistence check
\r
185 if (attribName.Contains("sm") && strName.Contains("DCS")) {
\r
186 fCurrentSM = atoi(attr->GetValue()); // only for GTU/PTR
\r
188 if (attribName.Contains("id") && strName.Contains("STACK")) {
\r
189 fCurrentStack = atoi(attr->GetValue()); // only for GTU/PTR
\r
193 // if there is a new DCS element put it in the correct array
\r
194 if (strName.Contains("DCS")) {
\r
195 if (fSystem == kInsideFEE) {
\r
196 fDCSFEEObj = new AliTRDCalDCSFEE(name,dcsTitle);
\r
197 fDCSFEEObj->SetDCSid(dcsId);
\r
199 if (fSystem == kInsidePTR) {
\r
200 fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
\r
201 fDCSPTRObj->SetDCSid(dcsId);
\r
203 if (fSystem == kInsideGTU) {
\r
204 fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
\r
205 fDCSGTUObj->SetDCSid(dcsId);
\r
210 //_____________________________________________________________________________
\r
211 void AliTRDSaxHandler::OnEndElement(const char *name)
\r
213 // do everything that needs to be done when an end tag of an element is found
\r
214 TString strName = name;
\r
216 // if done with this DCS board, put it in the correct array
\r
217 // no check for </ack> necessary since this check is done during XML validation
\r
218 if (strName.Contains("DCS")) {
\r
219 if (fSystem == kInsideFEE) {
\r
221 if (fDCSFEEObj->GetStatusBit() == 0) {
\r
222 // if there were no errors (StatusBit==0) the following should match
\r
223 detID = fDCSFEEObj->GetDCSid();
\r
224 AliTRDgeometry aliGeo;
\r
225 Int_t calDetID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(),
\r
226 fDCSFEEObj->GetStack(),
\r
227 fDCSFEEObj->GetSM());
\r
228 if (detID != calDetID) fDCSFEEObj->SetStatusBit(4);
\r
230 // if the dcs board didn't properly respond, don't compare
\r
231 detID = fDCSFEEObj->GetDCSid();
\r
233 fFEEArr->AddAt(fDCSFEEObj,detID);
\r
235 if (fSystem == kInsidePTR) {
\r
236 fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
\r
239 if (fSystem == kInsideGTU) {
\r
240 fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
\r
243 fCurrentSM = 99; // 99 for no SM set
\r
244 fDCSFEEObj = 0; // just to be sure
\r
248 // done with this stack?
\r
249 if (strName.Contains("STACK")) {
\r
250 fCurrentStack = 99; // 99 for no stack set
\r
253 // store informations of the FEE DCS-Board
\r
254 if (fSystem == kInsideFEE) {
\r
255 if (strName.Contains("DNR")) fDCSFEEObj->SetStatusBit(fContent.Atoi());
\r
256 if (strName.Contains("CFGNME")) fDCSFEEObj->SetConfigName(fContent);
\r
257 if (strName.Contains("CFGTAG")) fDCSFEEObj->SetConfigTag(fContent.Atoi());
\r
258 if (strName.Contains("CFGVRSN")) fDCSFEEObj->SetConfigVersion(fContent);
\r
259 if (strName.Contains("NTB")) fDCSFEEObj->SetNumberOfTimeBins(fContent.Atoi());
\r
260 if (strName.Contains("SM-ID")) fDCSFEEObj->SetSM(fContent.Atoi());
\r
261 if (strName.Contains("STACK-ID")) fDCSFEEObj->SetStack(fContent.Atoi());
\r
262 if (strName.Contains("LAYER-ID")) fDCSFEEObj->SetLayer(fContent.Atoi());
\r
263 if (strName.Contains("SINGLEHITTHRES")) fDCSFEEObj->SetSingleHitThres(fContent.Atoi());
\r
264 if (strName.Contains("THRPADCLSTHRS")) fDCSFEEObj->SetThreePadClustThres(fContent.Atoi());
\r
265 if (strName.Contains("SELNOZS")) fDCSFEEObj->SetSelectiveNoZS(fContent.Atoi());
\r
266 if (strName.Contains("FASTSTATNOISE")) fDCSFEEObj->SetFastStatNoise(fContent.Atoi());
\r
267 if (strName.Contains("FILTWEIGHT")) fDCSFEEObj->SetTCFilterWeight(fContent.Atoi());
\r
268 if (strName.Contains("FILTSHRTDCYPRM")) fDCSFEEObj->SetTCFilterShortDecPar(fContent.Atoi());
\r
269 if (strName.Contains("FILTLNGDCYPRM")) fDCSFEEObj->SetTCFilterLongDecPar(fContent.Atoi());
\r
270 if (strName.Contains("FLTR")) fDCSFEEObj->SetFilterType(fContent);
\r
271 if (strName.Contains("READOUTPAR")) fDCSFEEObj->SetReadoutParam(fContent);
\r
272 if (strName.Contains("TESTPATTERN")) fDCSFEEObj->SetTestPattern(fContent);
\r
273 if (strName.Contains("TRCKLTMODE")) fDCSFEEObj->SetTrackletMode(fContent);
\r
274 if (strName.Contains("TRCKLTDEF")) fDCSFEEObj->SetTrackletDef(fContent);
\r
275 if (strName.Contains("TRIGGERSETUP")) fDCSFEEObj->SetTriggerSetup(fContent);
\r
276 if (strName.Contains("ADDOPTIONS")) fDCSFEEObj->SetAddOptions(fContent);
\r
280 // store pretrigger informations
\r
281 if (fSystem == kInsidePTR) {
\r
282 // no informations available yet
\r
284 // store GTU informations
\r
285 if (fSystem == kInsideGTU) {
\r
286 if (strName.Contains("SMMASK"))
\r
287 fHandlerStatus = fDCSGTUObj->SetSMMask(fContent);
\r
288 if (strName.Contains("LINKMASK"))
\r
289 fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent);
\r
290 if (strName.Contains("STMASK"))
\r
291 fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi());
\r
295 //_____________________________________________________________________________
\r
296 void AliTRDSaxHandler::OnCharacters(const char *characters)
\r
298 // copy the the text content of an XML element
\r
299 fContent = characters;
\r
302 //_____________________________________________________________________________
\r
303 void AliTRDSaxHandler::OnComment(const char* /*text*/)
\r
305 // comments within the XML file are ignored
\r
308 //_____________________________________________________________________________
\r
309 void AliTRDSaxHandler::OnWarning(const char *text)
\r
311 // process warnings here
\r
312 AliInfo(Form("Warning: %s",text));
\r
315 //_____________________________________________________________________________
\r
316 void AliTRDSaxHandler::OnError(const char *text)
\r
318 // process errors here
\r
319 AliError(Form("Error: %s",text));
\r
322 //_____________________________________________________________________________
\r
323 void AliTRDSaxHandler::OnFatalError(const char *text)
\r
325 // process fatal errors here
\r
326 AliError(Form("Fatal error: %s",text)); // use AliFatal?
\r
329 //_____________________________________________________________________________
\r
330 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
\r
332 // process character data blocks here
\r
333 // not implemented and should not be used here
\r