Introduce DCS FXS data into preprocessor (Frederick)
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Jun 2008 13:40:10 +0000 (13:40 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Jun 2008 13:40:10 +0000 (13:40 +0000)
TRD/AliTRDPreprocessor.cxx
TRD/AliTRDPreprocessor.h
TRD/AliTRDSaxHandler.cxx [new file with mode: 0644]
TRD/AliTRDSaxHandler.h [new file with mode: 0644]
TRD/TRDbaseLinkDef.h
TRD/libTRDbase.pkg

index 5b303e2..9df5084 100644 (file)
@@ -38,6 +38,7 @@
 #include <TString.h>
 #include <TList.h>
 #include <TCollection.h>
+#include "TSAXParser.h"
 
 #include "AliCDBMetaData.h"
 #include "AliLog.h"
 #include "AliTRDCalibraFit.h"
 #include "AliTRDCalibraMode.h"
 #include "AliTRDCalibPadStatus.h"
+#include "AliTRDSaxHandler.h"
 #include "Cal/AliTRDCalDet.h"
 #include "Cal/AliTRDCalPadStatus.h"
+#include "Cal/AliTRDCalDCS.h"
 
 ClassImp(AliTRDPreprocessor)
 
@@ -96,7 +99,12 @@ UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
 
   TString runType = GetRunType();
   Log(Form("runtype %s\n",runType.Data()));
-  
+
+  // always process the configuration data
+  Int_t resultDCSC = ProcessDCSConfigData();
+  // if there was an error, return with its code
+  if (resultDCSC != 0) return resultDCSC;
+
   if (runType=="PEDESTAL"){
     if(ExtractPedestals()) return 1;
     return 0;
@@ -677,3 +685,61 @@ Bool_t AliTRDPreprocessor::ExtractHLT()
   return error;
   
 }
+
+//_____________________________________________________________________________
+UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
+{
+  // 
+  // process the configuration of FEE, PTR and GTU
+  // reteive XML file from the DCS FXS
+  // parse it and store TObjArrays in the CDB
+  // return 0 for success, otherwise:
+  // 5: could not get the file from the FXS
+  // 6: ERROR in XML validation: something wrong with the file
+  // 7: ERROR while creating calibration objects in the handler
+  // 8: error while storing data in the CDB
+  //
+
+  Log("Processing the DCS config summary file.");
+
+  // get the XML file
+  const char * nameFile = GetFile(kDCS,"CONFIGSUMMARY","");
+  if (nameFile == NULL) {
+    return 5;
+    Log(Form("File %s not found!",nameFile));
+  }
+
+  // create parser and parse
+  TSAXParser saxParser;
+  AliTRDSaxHandler saxHandler;
+  saxParser.ConnectToHandler("AliTRDSaxHandler", &saxHandler);
+  saxParser.ParseFile(nameFile);
+
+  // report errors if present
+  if (saxParser.GetParseCode() == 0) {
+    Log("XML file validation OK");
+  } else {
+    Log(Form("ERROR in XML file validation. Parsecode: %s", saxParser.GetParseCode()));
+    return 6;
+  }
+  if (saxHandler.GetHandlerStatus() != 0) {
+    Log(Form("ERROR while creating calibration objects. Error code: %s", saxHandler.GetHandlerStatus()));
+    return 7;
+  }
+
+  // get the calibration object storing the data from the handler
+  AliTRDCalDCS* fCalDCSObj = saxHandler.GetCalDCSObj();
+
+  // store the DCS calib data in the CDB
+  AliCDBMetaData metaData1;
+  metaData1.SetBeamPeriod(0);
+  metaData1.SetResponsible("Frederick Kramer");
+  metaData1.SetComment("DCS configuration data in one AliTRDCalDCS object.");
+  if (!Store("Calib", "DCSCONFIG", fCalDCSObj, &metaData1, 0, kTRUE)) {
+    Log("problems while storing DCS config data object");
+    return 8;
+  }
+
+  return 0;
+}
+
index 2148875..3049514 100644 (file)
@@ -38,9 +38,10 @@ class AliTRDPreprocessor : public AliPreprocessor
 
  private:
 
-          Bool_t  fVdriftHLT;       // HLT Vdrift
+          Bool_t  fVdriftHLT;             // HLT Vdrift
+         UInt_t  ProcessDCSConfigData(); // process DCS configuration
 
-  ClassDef(AliTRDPreprocessor,1)    // The SHUTTLE preprocessor for TRD
+  ClassDef(AliTRDPreprocessor,1)          // The SHUTTLE preprocessor for TRD
 
 };
 #endif
diff --git a/TRD/AliTRDSaxHandler.cxx b/TRD/AliTRDSaxHandler.cxx
new file mode 100644 (file)
index 0000000..6993104
--- /dev/null
@@ -0,0 +1,296 @@
+/*************************************************************************
+ * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+ * *                                                                        *
+ * * Author: The ALICE Off-line Project.                                    *
+ * * Contributors are mentioned in the code where appropriate.              *
+ * *                                                                        *
+ * * Permission to use, copy, modify and distribute this software and its   *
+ * * documentation strictly for non-commercial purposes is hereby granted   *
+ * * without fee, provided that the above copyright notice appears in all   *
+ * * copies and that both the copyright notice and this permission notice   *
+ * * appear in the supporting documentation. The authors make no claims     *
+ * * about the suitability of this software for any purpose. It is          *
+ * * provided "as is" without express or implied warranty.                  *
+ * **************************************************************************/
+
+/* $Id: AliTRDSaxHandler.cxx 26327 2008-06-02 15:36:18Z cblume $ */
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  The SAX XML file handler used in the preprocessor                     //
+//                                                                        //
+//  Authors:                                                              //
+//    Frederick Kramer (kramer@ikf.uni-frankfurt.de)                      //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include <Riostream.h>
+#include <TList.h>
+#include <TObjArray.h>
+#include <TXMLParser.h>
+#include <TSAXParser.h>
+#include "AliTRDSaxHandler.h"
+#include <TXMLAttr.h>
+#include "Cal/AliTRDCalDCS.h"
+#include "Cal/AliTRDCalDCSFEE.h"
+#include "Cal/AliTRDCalDCSPTR.h"
+#include "Cal/AliTRDCalDCSGTU.h"
+#include "AliTRDgeometry.h"
+#include <AliLog.h>
+
+
+ClassImp(AliTRDSaxHandler)
+
+
+
+//_____________________________________________________________________________
+AliTRDSaxHandler::AliTRDSaxHandler()
+  :TObject()
+  ,fHandlerStatus(0)
+  ,fNDCSPTR(0)
+  ,fNDCSGTU(0)
+  ,fFEEArr(new TObjArray(540))
+  ,fPTRArr(new TObjArray(6))
+  ,fGTUArr(new TObjArray(19))
+  ,fSystem(0)
+  ,fCurrentSM(0)
+  ,fCurrentStack(0)
+  ,fContent(0)
+  ,fDCSFEEObj(0)
+  ,fDCSPTRObj(0)
+  ,fDCSGTUObj(0)
+  ,fCalDCSObj(new AliTRDCalDCS())
+{
+  //
+  // AliTRDSaxHandler default constructor
+  //
+  fFEEArr->SetOwner();
+  fPTRArr->SetOwner();
+  fGTUArr->SetOwner();
+}
+
+//_____________________________________________________________________________
+AliTRDSaxHandler::AliTRDSaxHandler(const AliTRDSaxHandler &sh)
+  :TObject(sh)
+  ,fHandlerStatus(0)
+  ,fNDCSPTR(0)
+  ,fNDCSGTU(0)
+  ,fFEEArr(0)
+  ,fPTRArr(0)
+  ,fGTUArr(0)
+  ,fSystem(0)
+  ,fCurrentSM(0)
+  ,fCurrentStack(0)
+  ,fContent(0)
+  ,fDCSFEEObj(0)
+  ,fDCSPTRObj(0)
+  ,fDCSGTUObj(0)
+  ,fCalDCSObj(0)
+{
+  //
+  // AliTRDSaxHandler copy constructor
+  //
+}
+
+//_____________________________________________________________________________
+AliTRDSaxHandler &AliTRDSaxHandler::operator=(const AliTRDSaxHandler &sh)
+{
+  //
+  // Assignment operator
+  //
+  if (&sh == this) return *this;
+
+  new (this) AliTRDSaxHandler(sh);
+  return *this;
+}
+
+//_____________________________________________________________________________
+AliTRDSaxHandler::~AliTRDSaxHandler()
+{
+  //
+  // AliTRDSaxHandler destructor
+  //
+  delete fFEEArr;
+  delete fPTRArr;
+  delete fGTUArr;
+  delete fCalDCSObj;
+}
+
+//_____________________________________________________________________________
+AliTRDCalDCS* AliTRDSaxHandler::GetCalDCSObj()
+{
+  // put the arrays in the global calibration object and return this
+  fCalDCSObj->SetNumberOfTimeBins(22); //test test test
+  fCalDCSObj->SetFEEArr(fFEEArr);
+  fCalDCSObj->SetPTRArr(fPTRArr);
+  fCalDCSObj->SetGTUArr(fGTUArr);
+  return fCalDCSObj;
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnStartDocument()
+{
+  // if something should happen right at the beginning of the
+  // XML document, this must happen here
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnEndDocument()
+{
+  // if something should happen at the end of the XML document
+  // this must be done here
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnStartElement(const char *name, const TList *attributes)
+{
+  // when a new XML element is found, it is processed here
+  fContent    = "";
+  Int_t dcsId = 0;
+  TString strName  = name;
+  TString dcsTitle = "";
+
+  // set the current system if necessary
+  if (strName.Contains("FEE")) fSystem = kInsideFEE;
+  if (strName.Contains("PTR")) fSystem = kInsidePTR;
+  if (strName.Contains("GTU")) fSystem = kInsideGTU;
+
+  // get the attributes of the element
+  TXMLAttr *attr;
+  TIter next(attributes);
+  while ((attr = (TXMLAttr*) next())) {
+    TString attribName = attr->GetName();
+    if (attribName.Contains("id") && strName.Contains("DCS")) {
+      dcsTitle = name;
+      dcsId = atoi(attr->GetValue());
+    }
+    if (attribName.Contains("sm") && strName.Contains("DCS")) {
+      fCurrentSM = atoi(attr->GetValue());
+    }
+    if (attribName.Contains("id") && strName.Contains("STACK")) {
+      fCurrentStack = atoi(attr->GetValue());
+    }
+  }
+
+  // if there is a new DCS element put it in the correct array
+  if (strName.Contains("DCS")) {
+    if (fSystem == kInsideFEE) {
+      fDCSFEEObj = new AliTRDCalDCSFEE(name,dcsTitle);
+      fDCSFEEObj->SetDCSid(dcsId);
+    }
+    if (fSystem == kInsidePTR) {
+      fDCSPTRObj = new AliTRDCalDCSPTR(name,dcsTitle);
+      fDCSPTRObj->SetDCSid(dcsId);
+    }
+    if (fSystem == kInsideGTU) {
+      fDCSGTUObj = new AliTRDCalDCSGTU(name,dcsTitle);
+      fDCSGTUObj->SetDCSid(dcsId);
+    }
+  }
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnEndElement(const char *name)
+{
+  // do everything that needs to be done when an end tag of an element is found
+  TString strName = name;
+  
+  // if done with this DCS board, put it in the correct array
+  if (strName.Contains("DCS")) {
+    if (fSystem == kInsideFEE) {
+      AliTRDgeometry aliGeo;
+      Int_t detID = aliGeo.GetDetector(fDCSFEEObj->GetLayer(),
+                                       fDCSFEEObj->GetStack(),
+                                       fDCSFEEObj->GetSM());
+      fFEEArr->AddAt(fDCSFEEObj,detID);
+    }
+    if (fSystem == kInsidePTR) {
+      fPTRArr->AddAt(fDCSPTRObj,fNDCSPTR);
+      fNDCSPTR++;
+    }
+    if (fSystem == kInsideGTU) {
+      fGTUArr->AddAt(fDCSGTUObj,fNDCSGTU);
+      fNDCSGTU++;
+    }
+    fCurrentSM = 99; // 99 for no SM set
+    fDCSFEEObj = 0;  // just to be sure
+    return;
+  }
+
+  // done with this stack?
+  if (strName.Contains("STACK")) {
+    fCurrentStack = 99; // 99 for no stack set
+  }
+
+  // store informations of the FEE DCS-Board
+  if (fSystem == kInsideFEE) {
+    if (strName.Contains("CONFIG-ID"))
+      fDCSFEEObj->SetConfigID(fContent);
+    if (strName.Contains("NTBIN"))
+      fDCSFEEObj->SetNumberOfTimeBins(fContent.Atoi());
+    if (strName.Contains("SM-ID"))
+      fDCSFEEObj->SetSM(fContent.Atoi());
+    if (strName.Contains("STACK-ID"))
+      fDCSFEEObj->SetStack(fContent.Atoi());
+    if (strName.Contains("LAYER-ID"))
+      fDCSFEEObj->SetLayer(fContent.Atoi());
+  }
+
+  // store pretrigger informations
+  if (fSystem == kInsidePTR) {
+    // no informations available yet
+  }
+  // store GTU informations
+  if (fSystem == kInsideGTU) {
+    if (strName.Contains("SMMASK"))
+      fHandlerStatus = fDCSGTUObj->SetSMMask(fContent);
+    if (strName.Contains("LINKMASK")) 
+      fHandlerStatus = fDCSGTUObj->SetLinkMask(fCurrentSM, fCurrentStack, fContent);
+    if (strName.Contains("STMASK"))
+      fDCSGTUObj->SetStackMaskBit(fCurrentSM, fCurrentStack, fContent.Atoi());
+  }
+
+
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnCharacters(const char *characters)
+{
+  // copy the the text content of an XML element
+  fContent = characters;
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnComment(const char* /*text*/)
+{
+  // comments within the XML file are ignored
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnWarning(const char *text)
+{
+  // process warnings here
+  AliInfo(Form("Warning: %s",text));
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnError(const char *text)
+{
+  // process errors here
+  AliError(Form("Error: %s",text));
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnFatalError(const char *text)
+{
+  // process fatal errors here
+  AliError(Form("Fatal error: %s",text)); // use AliFatal?
+}
+
+//_____________________________________________________________________________
+void AliTRDSaxHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
+{
+  // process character data blocks here
+  // not implemented and should not be used here
+}
+
diff --git a/TRD/AliTRDSaxHandler.h b/TRD/AliTRDSaxHandler.h
new file mode 100644 (file)
index 0000000..a16f622
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef AliTRDSaxHandler_H
+#define AliTRDSaxHandler_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * * See cxx source for full Copyright notice */
+/* $Id$ */
+
+
+#include "TObject.h"
+#include "Cal/AliTRDCalDCS.h"
+#include "Cal/AliTRDCalDCSFEE.h"
+#include "Cal/AliTRDCalDCSPTR.h"
+#include "Cal/AliTRDCalDCSGTU.h"
+#include <TObjArray.h>
+#include <TList.h>
+
+
+class AliTRDSaxHandler : public TObject {
+public:
+  enum { kInsideFEE = 1, kInsidePTR = 2, kInsideGTU = 3 };
+
+  AliTRDSaxHandler();
+  AliTRDSaxHandler(const AliTRDSaxHandler &sh);
+  virtual ~AliTRDSaxHandler();
+  AliTRDSaxHandler &operator=(const AliTRDSaxHandler &sh);
+
+  TObjArray*    GetDCSFEEDataArray()  { return fFEEArr;        }
+  TObjArray*    GetDCSPTRDataArray()  { return fPTRArr;        }
+  TObjArray*    GetDCSGTUDataArray()  { return fGTUArr;        }
+  AliTRDCalDCS* GetCalDCSObj(); // to be called by the preprocessor
+
+  Int_t         GetHandlerStatus() const { return fHandlerStatus; }
+
+  // functions for all possible events
+  void          OnStartDocument();
+  void          OnEndDocument();
+  void          OnStartElement(const char *name, const TList *attributes);
+  void          OnEndElement(const char *name);
+  void          OnCharacters(const char *name);
+  void          OnComment(const char *name);
+  void          OnWarning(const char *name);
+  void          OnError(const char *name);
+  void          OnFatalError(const char *name);
+  void          OnCdataBlock(const char *name, Int_t len);
+
+private:
+
+  Int_t            fHandlerStatus; // 0: everything OK, >0: error
+  Int_t            fNDCSPTR;       // number of current PTR unit (to be abandonned soon)
+  Int_t            fNDCSGTU;       // number of current GTU unit (to be abandonned soon)
+  TObjArray*       fFEEArr;        // array of AliTRDCalDCSFEE objects
+  TObjArray*       fPTRArr;        // array of AliTRDCalDCSPTR objects
+  TObjArray*       fGTUArr;        // array of AliTRDCalDCSGTU objects
+  Int_t            fSystem;        // current system (FEE/PTR/GTU)
+  Int_t            fCurrentSM;     // current supermodule
+  Int_t            fCurrentStack;  // current stack
+  TString          fContent;       // content of the xml element (text) 
+  AliTRDCalDCSFEE* fDCSFEEObj;     // the calib object for one FEE DCS board
+  AliTRDCalDCSPTR* fDCSPTRObj;     // the calib object for one PTR DCS board
+  AliTRDCalDCSGTU* fDCSGTUObj;     // the calib object for one GTU DCS board
+  AliTRDCalDCS*    fCalDCSObj;     // the complete calib obj containing all inform.
+
+  ClassDef(AliTRDSaxHandler,1);
+};
+#endif
index c2bd343..c050816 100644 (file)
 #pragma link C++ class  AliTRDCalPad+;
 #pragma link C++ class  AliTRDCalDet+;
 #pragma link C++ class  AliTRDCalFEE+;
+#pragma link C++ class  AliTRDCalDCS+;
+#pragma link C++ class  AliTRDCalDCSFEE+;
+#pragma link C++ class  AliTRDCalDCSPTR+;
+#pragma link C++ class  AliTRDCalDCSGTU+;
 #pragma link C++ class  AliTRDCalPID+;
 #pragma link C++ class  AliTRDCalPIDLQ+;
 #pragma link C++ class  AliTRDCalPIDNN+;
@@ -65,6 +69,7 @@
 #pragma link C++ class  AliTRDCalibPadStatus+;
 
 #pragma link C++ class  AliTRDPreprocessor+;
+#pragma link C++ class  AliTRDSaxHandler+;
 
 #pragma link C++ class  AliTRDDataDCS+;
 #pragma link C++ class  AliTRDSensor+;
index 27c1939..6e7be5c 100644 (file)
@@ -28,6 +28,10 @@ SRCS= AliTRDarrayI.cxx \
       Cal/AliTRDCalPad.cxx \
       Cal/AliTRDCalDet.cxx \
       Cal/AliTRDCalFEE.cxx \
+      Cal/AliTRDCalDCS.cxx \
+      Cal/AliTRDCalDCSFEE.cxx \
+      Cal/AliTRDCalDCSPTR.cxx \
+      Cal/AliTRDCalDCSGTU.cxx \
       Cal/AliTRDCalPID.cxx \
       Cal/AliTRDCalPIDLQ.cxx \
       Cal/AliTRDCalPIDNN.cxx \
@@ -43,6 +47,7 @@ SRCS= AliTRDarrayI.cxx \
       AliTRDCalibPadStatus.cxx \
       AliTRDQAChecker.cxx \
       AliTRDPreprocessor.cxx \
+      AliTRDSaxHandler.cxx \
       AliTRDDataDCS.cxx \
       AliTRDSensor.cxx \
       AliTRDSensorArray.cxx \