]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDSaxHandler.cxx
Slight change of tags
[u/mrichter/AliRoot.git] / TRD / AliTRDSaxHandler.cxx
1 /*************************************************************************\r
2  * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *\r
3  * *                                                                        *\r
4  * * Author: The ALICE Off-line Project.                                    *\r
5  * * Contributors are mentioned in the code where appropriate.              *\r
6  * *                                                                        *\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
15 \r
16 /* $Id: AliTRDSaxHandler.cxx 26327 2008-06-02 15:36:18Z cblume $ */\r
17 \r
18 ////////////////////////////////////////////////////////////////////////////\r
19 //                                                                        //\r
20 //  The SAX XML file handler used in the preprocessor                     //\r
21 //                                                                        //\r
22 //  Author:                                                               //\r
23 //    Frederick Kramer (kramer@ikf.uni-frankfurt.de)                      //\r
24 //                                                                        //\r
25 ////////////////////////////////////////////////////////////////////////////\r
26 \r
27 #include <cstdlib>\r
28 #include <Riostream.h>\r
29 #include <TList.h>\r
30 #include <TXMLAttr.h>\r
31 #include <TSAXParser.h>\r
32 #include <TObjArray.h>\r
33 \r
34 #include "AliLog.h"\r
35 \r
36 #include "AliTRDSaxHandler.h"\r
37 #include "AliTRDgeometry.h"\r
38 \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
43 \r
44 ClassImp(AliTRDSaxHandler)\r
45 \r
46 //_____________________________________________________________________________\r
47 AliTRDSaxHandler::AliTRDSaxHandler()\r
48   :TObject()\r
49   ,fHandlerStatus(0)\r
50   ,fNDCSPTR(0)\r
51   ,fNDCSGTU(0)\r
52   ,fFEEArr(new TObjArray(540))\r
53   ,fPTRArr(new TObjArray(6))\r
54   ,fGTUArr(new TObjArray(19))\r
55   ,fSystem(0)\r
56   ,fCurrentSM(0)\r
57   ,fCurrentStack(0)\r
58   ,fContent(0)\r
59   ,fDCSFEEObj(0)\r
60   ,fDCSPTRObj(0)\r
61   ,fDCSGTUObj(0)\r
62   ,fCalDCSObj(new AliTRDCalDCS())\r
63 {\r
64   //\r
65   // AliTRDSaxHandler default constructor\r
66   //\r
67   fFEEArr->SetOwner();\r
68   fPTRArr->SetOwner();\r
69   fGTUArr->SetOwner();\r
70 }\r
71 \r
72 //_____________________________________________________________________________\r
73 AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)\r
74   :TObject(sh)\r
75   ,fHandlerStatus(0)\r
76   ,fNDCSPTR(0)\r
77   ,fNDCSGTU(0)\r
78   ,fFEEArr(0)\r
79   ,fPTRArr(0)\r
80   ,fGTUArr(0)\r
81   ,fSystem(0)\r
82   ,fCurrentSM(0)\r
83   ,fCurrentStack(0)\r
84   ,fContent(0)\r
85   ,fDCSFEEObj(0)\r
86   ,fDCSPTRObj(0)\r
87   ,fDCSGTUObj(0)\r
88   ,fCalDCSObj(0)\r
89 {\r
90   //\r
91   // AliTRDSaxHandler copy constructor\r
92   //\r
93 }\r
94 \r
95 //_____________________________________________________________________________\r
96 AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)\r
97 {\r
98   //\r
99   // Assignment operator\r
100   //\r
101   if (&sh == this) return *this;\r
102 \r
103   new (this) AliTRDSaxHandler(sh);\r
104   return *this;\r
105 }\r
106 \r
107 //_____________________________________________________________________________\r
108 AliTRDSaxHandler::~AliTRDSaxHandler()\r
109 {\r
110   //\r
111   // AliTRDSaxHandler destructor\r
112   //\r
113 \r
114   if (fFEEArr) {\r
115     delete fFEEArr;\r
116     fFEEArr    = 0x0;\r
117   }\r
118   if (fPTRArr) {\r
119     delete fPTRArr;\r
120     fPTRArr    = 0x0;\r
121   }\r
122   if (fGTUArr) {\r
123     delete fGTUArr;\r
124     fGTUArr    = 0x0;\r
125   }\r
126   if (fCalDCSObj) {\r
127     delete fCalDCSObj;\r
128     fCalDCSObj = 0x0;\r
129   }\r
130 \r
131 }\r
132 \r
133 //_____________________________________________________________________________\r
134 AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()\r
135 {\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
141   return fCalDCSObj;\r
142 }\r
143 \r
144 //_____________________________________________________________________________\r
145 void AliTRDSaxHandler::OnStartDocument()\r
146 {\r
147   // if something should happen right at the beginning of the\r
148   // XML document, this must happen here\r
149 }\r
150 \r
151 //_____________________________________________________________________________\r
152 void AliTRDSaxHandler::OnEndDocument()\r
153 {\r
154   // if something should happen at the end of the XML document\r
155   // this must be done here\r
156 }\r
157 \r
158 //_____________________________________________________________________________\r
159 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)\r
160 {\r
161   // when a new XML element is found, it is processed here\r
162   fContent    = "";\r
163   Int_t dcsId = 0;\r
164   TString strName  = name;\r
165   TString dcsTitle = "";\r
166 \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
171 \r
172   // get the attributes of the element\r
173   TXMLAttr *attr;\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
178       dcsTitle = name;\r
179       dcsId = atoi(attr->GetValue());\r
180     }\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
184     }\r
185     if (attribName.Contains("sm") && strName.Contains("DCS")) {\r
186       fCurrentSM = atoi(attr->GetValue()); // only for GTU/PTR\r
187     }\r
188     if (attribName.Contains("id") && strName.Contains("STACK")) {\r
189       fCurrentStack = atoi(attr->GetValue()); // only for GTU/PTR\r
190     }\r
191   }\r
192 \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
198     }\r
199     if (fSystem == kInsidePTR) {\r
200       fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);\r
201       fDCSPTRObj->SetDCSid(dcsId);\r
202     }\r
203     if (fSystem == kInsideGTU) {\r
204       fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);\r
205       fDCSGTUObj->SetDCSid(dcsId);\r
206     }\r
207   }\r
208 }\r
209 \r
210 //_____________________________________________________________________________\r
211 void AliTRDSaxHandler::OnEndElement(const char *name)\r
212 {\r
213   // do everything that needs to be done when an end tag of an element is found\r
214   TString strName = name;\r
215   \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
220       Int_t detID = 0;\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
229       } else {\r
230         // if the dcs board didn't properly respond, don't compare\r
231         detID = fDCSFEEObj->GetDCSid();\r
232       }\r
233       fFEEArr->AddAt(fDCSFEEObj,detID);\r
234     }\r
235     if (fSystem == kInsidePTR) {\r
236       fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);\r
237       fNDCSPTR++;\r
238     }\r
239     if (fSystem == kInsideGTU) {\r
240       fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);\r
241       fNDCSGTU++;\r
242     }\r
243     fCurrentSM = 99; // 99 for no SM set\r
244     fDCSFEEObj = 0;  // just to be sure\r
245     return;\r
246   }\r
247 \r
248   // done with this stack?\r
249   if (strName.Contains("STACK")) {\r
250     fCurrentStack = 99; // 99 for no stack set\r
251   }\r
252 \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
277   }\r
278 \r
279   \r
280   // store pretrigger informations\r
281   if (fSystem == kInsidePTR) {\r
282     // no informations available yet\r
283   }\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
292   }\r
293 }\r
294 \r
295 //_____________________________________________________________________________\r
296 void AliTRDSaxHandler::OnCharacters(const char *characters)\r
297 {\r
298   // copy the the text content of an XML element\r
299   fContent = characters;\r
300 }\r
301 \r
302 //_____________________________________________________________________________\r
303 void AliTRDSaxHandler::OnComment(const char* /*text*/)\r
304 {\r
305   // comments within the XML file are ignored\r
306 }\r
307 \r
308 //_____________________________________________________________________________\r
309 void AliTRDSaxHandler::OnWarning(const char *text)\r
310 {\r
311   // process warnings here\r
312   AliInfo(Form("Warning: %s",text));\r
313 }\r
314 \r
315 //_____________________________________________________________________________\r
316 void AliTRDSaxHandler::OnError(const char *text)\r
317 {\r
318   // process errors here\r
319   AliError(Form("Error: %s",text));\r
320 }\r
321 \r
322 //_____________________________________________________________________________\r
323 void AliTRDSaxHandler::OnFatalError(const char *text)\r
324 {\r
325   // process fatal errors here\r
326   AliError(Form("Fatal error: %s",text)); // use AliFatal?\r
327 }\r
328 \r
329 //_____________________________________________________________________________\r
330 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)\r
331 {\r
332   // process character data blocks here\r
333   // not implemented and should not be used here\r
334 }\r
335 \r