Adding macros to create Calibration objects
[u/mrichter/AliRoot.git] / TRD / TRDbase / AliTRDSaxHandler.cxx
1 /*************************************************************************
2  * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3  * *                                                                        *
4  * * Author: The ALICE Off-line Project.                                    *
5  * * Contributors are mentioned in the code where appropriate.              *
6  * *                                                                        *
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  * **************************************************************************/
15
16 /* $Id: AliTRDSaxHandler.cxx 26327 2008-06-02 15:36:18Z cblume $ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //                                                                        //
20 //  The SAX XML file handler used in the TRD preprocessor                 //
21 //                                                                        //
22 //  Authors:                                                              //
23 //    Frederick Kramer (kramer@ikf.uni-frankfurt.de)                      //
24 //    Thomas Bird      (thomas@thomasbird.com)                            //
25 //                                                                        //
26 ////////////////////////////////////////////////////////////////////////////
27
28
29 #include <TList.h>
30 #include <TMath.h>
31 #include "AliLog.h"
32 #include "AliTRDCalDCSGTUTgu.h"
33 #include "AliTRDCalDCSPTR.h"
34
35 #include <TXMLAttr.h>
36 #include <TObjArray.h>
37 #include "AliTRDSaxHandler.h"
38 #include "AliTRDgeometry.h"
39 #include "AliTRDcalibDB.h"
40 #include "AliTRDCalDCSv2.h"
41 #include "AliTRDCalDCSFEEv2.h"
42 #include "AliTRDCalDCSGTU.h"
43
44 ClassImp(AliTRDSaxHandler)
45   
46 //_____________________________________________________________________________
47 AliTRDSaxHandler::AliTRDSaxHandler()
48   :TObject()
49   ,fHandlerStatus(0)
50   ,fNDCSPTR(0)
51   ,fNDCSGTU(0)
52   ,fFEEArr(new TObjArray(540))
53   ,fPTRArr(new TObjArray(6))
54   ,fSystem(0)
55   ,fInsideRstate(0)
56   ,fCurrentSM(0)
57   ,fCurrentStack(0)
58   ,fCurrentROB(-1)
59   ,fCurrentMCM(-1)
60   ,fCurrentADC(-1)
61   ,fContent(0)
62   ,fDCSFEEObj(0)
63   ,fDCSPTRObj(0)
64   ,fDCSGTUObj(0)
65   ,fCalDCSObj(new AliTRDCalDCSv2())
66   ,fLevel1Tag(-2)
67   ,fLevel2Tag(-2)
68   ,fInsideBoardInfo(false)
69   ,fTmu(0)
70   ,fCtpOpc(0)
71   ,fSegment(0)
72   ,fBoardInfo(0)
73 {
74   // AliTRDSaxHandler default constructor
75   fFEEArr->SetOwner();
76   fPTRArr->SetOwner();
77 }
78
79 //_____________________________________________________________________________
80 AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)
81   :TObject(sh)
82   ,fHandlerStatus(0)
83   ,fNDCSPTR(0)
84   ,fNDCSGTU(0)
85   ,fFEEArr(0)
86   ,fPTRArr(0)
87   ,fSystem(0)
88   ,fInsideRstate(0)
89   ,fCurrentSM(0)
90   ,fCurrentStack(0)
91   ,fCurrentROB(-1)
92   ,fCurrentMCM(-1)
93   ,fCurrentADC(-1)
94   ,fContent(0)
95   ,fDCSFEEObj(0)
96   ,fDCSPTRObj(0)
97   ,fDCSGTUObj(0)
98   ,fCalDCSObj(0)
99   ,fLevel1Tag(-2)
100   ,fLevel2Tag(-2)
101   ,fInsideBoardInfo(false)
102   ,fTmu(0)
103   ,fCtpOpc(0)
104   ,fSegment(0)
105   ,fBoardInfo(0)
106 {
107   // AliTRDSaxHandler copy constructor
108 }
109
110 //_____________________________________________________________________________
111 AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)
112 {
113   // Assignment operator
114   if (&sh == this) return *this;
115   new (this) AliTRDSaxHandler(sh);
116   return *this;
117 }
118
119 //_____________________________________________________________________________
120 AliTRDSaxHandler::~AliTRDSaxHandler()
121 {
122   // AliTRDSaxHandler destructor
123   if (fFEEArr) {
124     delete fFEEArr;
125     fFEEArr    = 0x0;
126   }
127   if (fPTRArr) {
128     delete fPTRArr;
129     fPTRArr    = 0x0;
130   }
131   if (fDCSGTUObj) {
132     delete fDCSGTUObj;
133     fDCSGTUObj    = 0x0;
134   }
135   if (fCalDCSObj) {
136     delete fCalDCSObj;
137     fCalDCSObj = 0x0;
138   }
139 }
140
141 //_____________________________________________________________________________
142 AliTRDCalDCSv2* AliTRDSaxHandler::GetCalDCSObj()
143 {
144   // put the arrays in the global calibration object and return this
145
146   fCalDCSObj->SetFEEArr(fFEEArr);
147   fCalDCSObj->SetPTRArr(fPTRArr);
148   fCalDCSObj->SetGTUObj(fDCSGTUObj);
149   return fCalDCSObj;
150 }
151
152 //_____________________________________________________________________________
153 void AliTRDSaxHandler::ParseConfigName(TString cfgname) const
154 {
155   // Evaluate the config name and set the individual parameters
156
157   // protect
158   if (!AliTRDcalibDB::Instance()) {
159     AliError("Could not create an instance of AliTRDcalibDB!");
160     return;
161   }
162
163   TString cfg = "", par = "", pars = "";
164   Int_t nPar = AliTRDcalibDB::Instance()->GetNumberOfParsDCS(cfgname);
165   if (nPar == 0) return;
166
167   for (Int_t i=1; i<=nPar; i++) {
168     // Get the configuration parameter
169     AliTRDcalibDB::Instance()->GetDCSConfigParOption(cfgname, i, 0, cfg);
170
171     // Set Parameters accordingly
172     if (i == AliTRDcalibDB::kFltrSet) fDCSFEEObj->SetFilterType(cfg);
173     if (i == AliTRDcalibDB::kTrigSet) fDCSFEEObj->SetTriggerSetup(cfg);
174     if (i == AliTRDcalibDB::kAddOpti) fDCSFEEObj->SetAddOptions(cfg);
175     if (i == AliTRDcalibDB::kTimebin) fDCSFEEObj->SetNumberOfTimeBins(AliTRDcalibDB::Instance()->ExtractTimeBinsFromString(cfg));
176     if (i == AliTRDcalibDB::kReadout) fDCSFEEObj->SetReadoutParam(cfg);
177     if (i == AliTRDcalibDB::kTrkMode) fDCSFEEObj->SetTrackletMode(cfg);
178
179     // Set options of parameters accordingly
180     Int_t nOpt = AliTRDcalibDB::Instance()->GetNumberOfOptsDCS(cfgname, i);
181     if (nOpt == 0) continue;
182
183     for (Int_t j=1; j<=nOpt; j++) {
184       // Get the parameter option
185       AliTRDcalibDB::Instance()->GetDCSConfigParOption(cfgname, i, j, par);
186
187       if (i == AliTRDcalibDB::kReadout) {
188         if (par.EqualTo("stat")) fDCSFEEObj->SetFastStatNoise(1);
189       }
190       if (i == AliTRDcalibDB::kTrkMode) {
191         if ((j > 1) && (par.Length() != 0)) pars += "-";
192         pars += par;
193       }
194       // SetTCFilterWeight, SetTCFilterShortDecPar, SetTCFilterLongDecPar might be filled here, too
195       // SetSingleHitThres, SetThreePadClustThres, SetSelectiveNoZS, SetTestPattern might be filled here, too
196     }
197
198     fDCSFEEObj->SetTrackletDef(pars);
199   }
200 }
201
202 //_____________________________________________________________________________
203 void AliTRDSaxHandler::OnStartDocument() const
204 {
205   // if something should happen right at the beginning of the
206   // XML document, this must happen here
207 }
208
209 //_____________________________________________________________________________
210 void AliTRDSaxHandler::OnEndDocument() const
211 {
212   // if something should happen at the end of the XML document
213   // this must be done here
214 }
215
216 //_____________________________________________________________________________
217 bool AliTRDSaxHandler::CompareString(TString str, const char *str2)
218 {
219   // compre strings, ignoring case
220   // returns true if they are the same, else false
221   return !(bool)str.CompareTo(str2,str.kIgnoreCase);
222 }
223
224
225 //_____________________________________________________________________________
226 void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
227 {
228   // when a new XML element is found, it is processed here
229   fContent    = ""; // Technically <p> This <em>is</em> ok but would be a problem here</p>
230   Int_t dcsId = 0;
231   TString tagName  = name;
232   TString dcsTitle = "";
233
234   // set the current system if necessary
235   if (CompareString(tagName, "FEE")) fSystem = kInsideFEE;
236   if (CompareString(tagName, "PTR")) fSystem = kInsidePTR;
237   if (CompareString(tagName, "GTU")) {
238     fSystem = kInsideGTU;
239     fDCSGTUObj = new AliTRDCalDCSGTU(tagName,tagName);
240   }
241
242   if (fSystem == kInsideGTU) {
243     if (CompareString(tagName, "tgu")) fLevel1Tag = kInsideTgu;
244     if (CompareString(tagName, "board_info")) {
245       fInsideBoardInfo = true;
246       fBoardInfo = new AliTRDCalDCSGTUBoardInfo(tagName,tagName);
247     }
248     if (CompareString(tagName(0,tagName.Length()-3), "segment")) { 
249       fSegment = new AliTRDCalDCSGTUSegment(tagName,tagName);
250       fSegment->SetId(TString(tagName(8,2)).Atoi());
251       fLevel1Tag = kInsideSegment;
252     }
253     if (fLevel1Tag == kInsideTgu) {
254       if (CompareString(tagName, "ctp_opc"))   fCtpOpc = new AliTRDCalDCSGTUCtpOpc(tagName,tagName);
255     } else if (fLevel1Tag == kInsideSegment) {
256       if (CompareString(tagName, "smu")) {
257         fLevel2Tag = kInsideSmu;
258       }
259       if (CompareString(tagName(0,3), "tmu")) {
260         fTmu = new AliTRDCalDCSGTUTmu(tagName,tagName);
261         fTmu->SetId(TString(tagName(4,2)).Atoi());
262         fLevel2Tag = kInsideTmu;
263       }
264     }
265   } else if (fSystem == kInsideFEE) {
266     if (CompareString(tagName, "gaintbl")) fLevel1Tag = kInsideGainTable;
267   }
268
269   // set if we are inside rstate 
270   // (in principle not necessary - just to be more safe against stupid tags)
271   if (CompareString(tagName, "rstate")) fInsideRstate = 1;
272
273   // get the attributes of the element
274   TXMLAttr *attr;
275   TIter next(attributes);
276   while ((attr = (TXMLAttr*) next())) {
277     TString attribName = attr->GetName();
278     TString attribValue = attr->GetValue();
279     if (fSystem == kInsideFEE && fLevel1Tag == kInsideNone) {
280       if (CompareString(attribName, "id") && CompareString(tagName, "DCS")) {
281         dcsTitle = name;
282         dcsId = atoi(attr->GetValue());
283       }
284       if (CompareString(attribName, "roc") && CompareString(tagName, "ack")) {
285         if (attribValue.Atoi() != fDCSFEEObj->GetDCSid())
286           fDCSFEEObj->SetStatusBit(4); // consistency check
287       }
288       if (CompareString(attribName, "rob") && CompareString(tagName, "ro-board") && (fInsideRstate == 1)) {
289         fCurrentROB = attribValue.Atoi();
290       }
291       if (CompareString(attribName, "mcm") && CompareString(tagName, "m") && (fInsideRstate == 1)) {
292         fCurrentMCM = attribValue.Atoi();
293       }
294       if (CompareString(attribName, "sm") && CompareString(tagName, "DCS")) {
295         fCurrentSM = attribValue.Atoi(); // only for GTU/PTR
296       }
297       if (CompareString(attribName, "id") && CompareString(tagName, "STACK")) {// hmmmm not exist?
298         fCurrentStack = attribValue.Atoi(); // only for GTU/PTR
299       }
300     } else if (fSystem == kInsideFEE && fLevel1Tag == kInsideGainTable) {
301       if (CompareString(tagName, "roc") && CompareString(attribName, "type"))    fDCSFEEObj->SetGainTableRocType(attribValue);
302       if (CompareString(tagName, "roc") && CompareString(attribName, "serial"))  fDCSFEEObj->SetGainTableRocSerial(attribValue.Atoi());
303       if (CompareString(tagName, "mcm") && CompareString(attribName, "rob"))     fCurrentROB = attribValue.Atoi();
304       if (CompareString(tagName, "mcm") && CompareString(attribName, "pos"))     fCurrentMCM = attribValue.Atoi();
305       if (CompareString(tagName, "adc") && CompareString(attribName, "id"))      fCurrentADC = attribValue.Atoi();
306       
307     } else if (fSystem == kInsideGTU && fLevel1Tag == kInsideNone) {
308       if (CompareString(tagName, "publisher")) {
309         if (CompareString(attribName, "at"))         fDCSGTUObj->SetSORFlag(attribValue.Atoi());
310         if (CompareString(attribName, "serial"))     fDCSGTUObj->SetSerial(attribValue.Atoi());
311         if (CompareString(attribName, "runnr"))      fDCSGTUObj->SetRunNumber(attribValue.Atoi());
312       }
313     } else if (fSystem == kInsideGTU && fLevel1Tag == kInsideTgu) {
314       if (CompareString(tagName, "from")) {
315         if (CompareString(attribName, "at"))         fDCSGTUObj->GetTgu()->SetFromSORFlag(attribValue.Atoi());
316         if (CompareString(attribName, "runnr"))      fDCSGTUObj->GetTgu()->SetFromRunNumber(attribValue.Atoi());
317         if (CompareString(attribName, "child"))      fDCSGTUObj->GetTgu()->SetFromChild(attribValue.Atoi());
318       }
319       if (CompareString(tagName, "segmentmask") && CompareString(attribName, "value"))  fDCSGTUObj->GetTgu()->SetSegmentMask(attribValue);
320       if (CompareString(tagName, "busymask") && CompareString(attribName, "value"))     fDCSGTUObj->GetTgu()->SetBusyMask(attribValue);
321       if (CompareString(tagName, "contribmask") && CompareString(attribName, "value"))  fDCSGTUObj->GetTgu()->SetContribMask(attribValue);
322       
323       if (CompareString(tagName, "ctp_opc") && CompareString(attribName, "id"))         fCtpOpc->SetId(attribValue.Atoi());
324       if (CompareString(tagName, "ctp_opc") && CompareString(attribName, "opcode"))     fCtpOpc->SetOpcode(attribValue.Atoi());
325       if (CompareString(tagName, "ctp_opc") && CompareString(attribName, "direction"))  fCtpOpc->SetDirection(attribValue.Atoi());
326       if (CompareString(tagName, "ctp_opc") && CompareString(attribName, "inverted"))   fCtpOpc->SetInverted(attribValue.Atoi());
327       if (CompareString(tagName, "ctp_opc") && CompareString(attribName, "delay"))      fCtpOpc->SetDelay(attribValue.Atoi());
328       if (CompareString(tagName, "ctp_opc") && CompareString(attribName, "connected"))  fCtpOpc->SetConnected(attribValue.Atoi());
329       
330     } else if (fSystem == kInsideGTU && fLevel1Tag == kInsideSegment) {
331       if (CompareString(tagName, "from")) {
332         if (CompareString(attribName, "at"))         fSegment->SetFromSORFlag(attribValue.Atoi());
333         if (CompareString(attribName, "runnr"))      fSegment->SetFromRunNumber(attribValue.Atoi());
334         if (CompareString(attribName, "child"))      fSegment->SetFromChild(attribValue.Atoi());
335       }
336       if (fLevel2Tag == kInsideSmu) {
337         if (CompareString(tagName, "stackmask") && CompareString(attribName, "value"))     fSegment->SetSmuStackMask(attribValue);
338         if (CompareString(tagName, "tracklets") && CompareString(attribName, "send"))      fSegment->SetSmuTracklets(attribValue.Atoi());
339         if (CompareString(tagName, "tracks") && CompareString(attribName, "send"))         fSegment->SetSmuTracks(attribValue.Atoi());
340         if (CompareString(tagName, "idelay") && CompareString(attribName, "value"))        fSegment->SetSmuIdelay(attribValue.Atoi());
341         if (CompareString(tagName, "ttc_emulator") && CompareString(attribName, "enable")) fSegment->SetSmuTtcEmulatorEnable(attribValue.Atoi());
342         
343         if (CompareString(tagName, "trigger_window") && CompareString(attribName, "l1_low"))  
344           fSegment->SetSmuTriggerWindowL1Low(attribValue.Atoi());
345         if (CompareString(tagName, "trigger_window") && CompareString(attribName, "l1_high"))  
346           fSegment->SetSmuTriggerWindowL1High(attribValue.Atoi());
347         if (CompareString(tagName, "trigger_window") && CompareString(attribName, "l2_low"))  
348           fSegment->SetSmuTriggerWindowL2Low(attribValue.Atoi());
349         if (CompareString(tagName, "trigger_window") && CompareString(attribName, "l2_high"))  
350           fSegment->SetSmuTriggerWindowL2High(attribValue.Atoi());
351         
352       } else if (fLevel2Tag == kInsideTmu) {
353         if (CompareString(tagName, "linkmask") && CompareString(attribName, "value"))      fTmu->SetLinkMask(attribValue);
354         if (CompareString(tagName, "pattern_generator") && CompareString(attribName, "enable")) 
355           fTmu->SetPatternGeneratorEnable(attribValue.Atoi());
356         if (CompareString(tagName, "pattern_generator") && CompareString(attribName, "datawords")) 
357           fTmu->SetPatternGeneratorDataWords(attribValue.Atoi());
358         if (CompareString(tagName, "pattern_generator") && CompareString(attribName, "trackletwords")) 
359           fTmu->SetPatternGeneratorTrackletWords(attribValue.Atoi());
360       }
361     }
362     
363     if (fInsideBoardInfo) {
364       if (CompareString(tagName, "board_info") && CompareString(attribName, "board_id"))    fBoardInfo->SetId(attribValue);
365       if (CompareString(tagName, "board_info") && CompareString(attribName, "design_type")) fBoardInfo->SetType(attribValue.Atoi());
366       if (CompareString(tagName, "board_info") && CompareString(attribName, "pci_ga"))      fBoardInfo->SetPciGa(attribValue.Atoi());
367       if (CompareString(tagName, "hardware") && CompareString(attribName, "date"))          fBoardInfo->SetHwDate(attribValue);
368       if (CompareString(tagName, "hardware") && CompareString(attribName, "rev"))           fBoardInfo->SetHwRev(attribValue.Atoi());
369       if (CompareString(tagName, "hardware") && CompareString(attribName, "clean"))         fBoardInfo->SetHwClean(attribValue.Atoi());
370       if (CompareString(tagName, "software") && CompareString(attribName, "date"))          fBoardInfo->SetSwDate(attribValue);
371       if (CompareString(tagName, "software") && CompareString(attribName, "rev"))           fBoardInfo->SetSwRev(attribValue.Atoi());
372       if (CompareString(tagName, "software") && CompareString(attribName, "clean"))         fBoardInfo->SetSwClean(attribValue.Atoi());
373     }
374   }
375
376   // if there is a new DCS element put it in the correct array
377   if (CompareString(tagName, "DCS")) {
378     if (fSystem == kInsideFEE) {
379       fDCSFEEObj = new AliTRDCalDCSFEEv2();
380       fDCSFEEObj->SetDCSid(dcsId);
381     }
382     if (fSystem == kInsidePTR) {
383 //       fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
384 //       fDCSPTRObj->SetDCSid(dcsId);
385     }
386     if (fSystem == kInsideGTU) {
387 //       fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
388 //       fDCSGTUObj->SetDCSid(dcsId);
389     }
390   }
391 }
392
393 //_____________________________________________________________________________
394 void AliTRDSaxHandler::OnEndElement(const char *name)
395 {
396   // do everything that needs to be done when an end tag of an element is found
397   TString tagName = name;
398   
399   // if done with this DCS board, put it in the correct array
400   // no check for </ack> necessary since this check is done during XML validation
401   if (CompareString(tagName, "DCS")) {
402     if (fSystem == kInsideFEE) {
403       Int_t detID = 0;
404       if (fDCSFEEObj->GetStatusBit() == 0) {
405         // if there were no errors (StatusBit==0) the following should match
406         detID = fDCSFEEObj->GetDCSid();
407         AliTRDgeometry aliGeo;
408         Int_t calDetID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(),
409                                             fDCSFEEObj->GetStack(),
410                                             fDCSFEEObj->GetSM());
411         if (detID != calDetID) fDCSFEEObj->SetStatusBit(4);
412       } else {
413         // if the dcs board didn't properly respond, don't compare
414         detID = fDCSFEEObj->GetDCSid();
415       }
416       fFEEArr->AddAt(fDCSFEEObj,detID);
417     }
418     if (fSystem == kInsidePTR) {
419       fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
420       fNDCSPTR++;
421     }
422 //     if (fSystem == kInsideGTU) {
423 //       fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
424 //       fNDCSGTU++;
425 //     }
426     fCurrentSM = 99; // 99 for no SM set
427     fDCSFEEObj = 0;  // just to be sure
428     return;
429   }
430
431   // done with this stack? 
432   if (CompareString(tagName, "STACK")) {// TODO: errrrm ???? always 99?
433     fCurrentStack = 99; // 99 for no stack set
434   }
435
436   // outside of rstate again?
437   if (CompareString(tagName, "rstate")) {
438     fInsideRstate = 0;
439     fCurrentROB   = -1;
440     fCurrentMCM   = -1;
441   }
442   if (CompareString(tagName, "ro-board")) fCurrentROB = -1;
443   
444   // store informations of the FEE DCS-Board
445   if (fSystem == kInsideFEE) {
446     if (CompareString(tagName, "DNR"))            fDCSFEEObj->SetStatusBit(fContent.Atoi());
447     if (CompareString(tagName, "CFGTAG"))         fDCSFEEObj->SetConfigTag(fContent.Atoi());
448     if (CompareString(tagName, "CFGVRSN"))        fDCSFEEObj->SetConfigVersion(fContent);
449     if (CompareString(tagName, "SM-ID"))          fDCSFEEObj->SetSM(fContent.Atoi());
450     if (CompareString(tagName, "STACK-ID"))       fDCSFEEObj->SetStack(fContent.Atoi());
451     if (CompareString(tagName, "LAYER-ID"))       fDCSFEEObj->SetLayer(fContent.Atoi());
452     if (CompareString(tagName, "CFGNME")) {
453       fDCSFEEObj->SetConfigName(fContent);
454       ParseConfigName(fContent);
455     }
456     if (CompareString(tagName, "gaintbl")) {
457       fLevel1Tag = kInsideNone;
458       fCurrentROB = -1;
459       fCurrentMCM = -1;
460       fCurrentADC = -1;
461     }
462     if (fLevel1Tag == kInsideGainTable) {
463       if (CompareString(tagName, "name"))   fDCSFEEObj->SetGainTableName(fContent);
464       if (CompareString(tagName, "desc"))   fDCSFEEObj->SetGainTableDesc(fContent);
465       if (fCurrentROB>=0 && fCurrentMCM>=0) {
466         if (CompareString(tagName, "adcdac")) fDCSFEEObj->SetGainTableAdcdac(fCurrentROB, fCurrentMCM, fContent.Atoi());
467         if (fCurrentADC>=0) {
468           if (CompareString(tagName, "fgfn"))   fDCSFEEObj->SetGainTableFgfn(fCurrentROB, fCurrentMCM, fCurrentADC, fContent.Atoi());
469           if (CompareString(tagName, "fgan"))   fDCSFEEObj->SetGainTableFgan(fCurrentROB, fCurrentMCM, fCurrentADC, fContent.Atoi());
470         }
471       }
472     }
473     if (fInsideRstate == 1) {
474       if (fCurrentROB>=0 && fCurrentMCM>=0) {
475         if (CompareString(tagName, "gsm")) fDCSFEEObj->SetMCMGlobalState(fCurrentROB, fCurrentMCM, fContent.Atoi());
476         if (CompareString(tagName, "ni")) fDCSFEEObj->SetMCMStateNI(fCurrentROB, fCurrentMCM, fContent.Atoi());
477         if (CompareString(tagName, "ev")) fDCSFEEObj->SetMCMEventCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());
478         if (CompareString(tagName, "ptrg")) fDCSFEEObj->SetMCMPtCnt(fCurrentROB, fCurrentMCM, fContent.Atoi());
479       }
480     }
481   }
482
483   if (fSystem == kInsideGTU) {
484 //     if (CompareString(tagName, "run")) { 
485 //       fDCSGTUObj->SetSORFlag(TString(fContent(fContent.Length()-1,1)).Atoi());
486 //       fDCSGTUObj->SetRunNumber(TString(fContent(0,fContent.Length()-2)).Atoi());
487 //     }
488 //     if (CompareString(tagName, "serial"))         fDCSGTUObj->SetSerial(fContent.Atoi());
489     if (CompareString(tagName, "board_info")) {
490       fInsideBoardInfo = false;
491       if (fLevel1Tag == kInsideTgu)                                  fDCSGTUObj->GetTgu()->SetBoardInfo(fBoardInfo);
492       if (fLevel1Tag == kInsideSegment && fLevel2Tag == kInsideSmu)  fSegment->SetSmuBoardInfo(fBoardInfo);
493       if (fLevel1Tag == kInsideSegment && fLevel2Tag == kInsideTmu)  fTmu->SetBoardInfo(fBoardInfo);
494     }
495     if (CompareString(tagName, "dnr"))            fDCSGTUObj->SetDNR(fContent.Atoi());
496     if (CompareString(tagName, "tgu"))            fLevel1Tag = kInsideNone;
497     if (CompareString(tagName(0,tagName.Length()-3), "segment")) { 
498       fDCSGTUObj->GetSegmentArray()->Add(fSegment);
499       fLevel1Tag = kInsideNone;
500     }
501     if (fLevel1Tag == kInsideTgu) {
502       if (CompareString(tagName, "ctp_opc"))        fDCSGTUObj->GetTgu()->GetCtpOpcArray()->Add(fCtpOpc);
503     } else if (fLevel1Tag == kInsideSegment) {
504       if (CompareString(tagName, "smu"))          fLevel2Tag = kInsideNone;
505       if (CompareString(tagName(0,3), "tmu")) {
506         fSegment->GetTmuArray()->Add(fTmu);
507         fLevel2Tag = kInsideNone;
508       }
509     }
510   }
511
512   
513   // store pretrigger informations
514   if (fSystem == kInsidePTR) {
515     // no informations available yet
516   }
517 //   // store GTU informations
518 //   if (fSystem == kInsideGTU) {
519 //     if (CompareString(tagName, "SMMASK"))
520 //       fHandlerStatus = fDCSGTUObj->SetSMMask(fContent);
521 //     if (CompareString(tagName, "LINKMASK")) 
522 //       fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent);
523 //     if (CompareString(tagName, "STMASK"))
524 //       fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi());
525 //   }
526 }
527
528 //_____________________________________________________________________________
529 void AliTRDSaxHandler::OnCharacters(const char *characters)
530 {
531   // copy the the text content of an XML element
532   fContent = characters;
533 }
534
535 //_____________________________________________________________________________
536 void AliTRDSaxHandler::OnComment(const char* /*text*/) const
537 {
538   // comments within the XML file are ignored
539 }
540
541 //_____________________________________________________________________________
542 void AliTRDSaxHandler::OnWarning(const char *text)
543 {
544   // process warnings here
545   AliInfo(Form("Warning: %s",text));
546 }
547
548 //_____________________________________________________________________________
549 void AliTRDSaxHandler::OnError(const char *text)
550 {
551   // process errors here
552   AliError(Form("Error: %s",text));
553 }
554
555 //_____________________________________________________________________________
556 void AliTRDSaxHandler::OnFatalError(const char *text)
557 {
558   // process fatal errors here
559   AliError(Form("Fatal error: %s",text)); // use AliFatal?
560 }
561
562 //_____________________________________________________________________________
563 void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/) const
564 {
565   // process character data blocks here
566   // not implemented and should not be used here
567 }
568