Implementing XML configuration file for TOFnoiseda.
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 2 Apr 2009 15:37:32 +0000 (15:37 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 2 Apr 2009 15:37:32 +0000 (15:37 +0000)
So far, the configuration file contains the debug flag and the
acquisition window width.

TOF/AliTOFNoiseConfigHandler.cxx [new file with mode: 0644]
TOF/AliTOFNoiseConfigHandler.h [new file with mode: 0644]
TOF/TOFNoiseConfig.xml [new file with mode: 0644]
TOF/TOFbaseLinkDef.h
TOF/TOFnoiseda.cxx
TOF/libTOFbase.pkg

diff --git a/TOF/AliTOFNoiseConfigHandler.cxx b/TOF/AliTOFNoiseConfigHandler.cxx
new file mode 100644 (file)
index 0000000..a2b279b
--- /dev/null
@@ -0,0 +1,180 @@
+/*************************************************************************\r
+ * * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *\r
+ * *                                                                        *\r
+ * * Author: The ALICE Off-line Project.                                    *\r
+ * * Contributors are mentioned in the code where appropriate.              *\r
+ * *                                                                        *\r
+ * * Permission to use, copy, modify and distribute this software and its   *\r
+ * * documentation strictly for non-commercial purposes is hereby granted   *\r
+ * * without fee, provided that the above copyright notice appears in all   *\r
+ * * copies and that both the copyright notice and this permission notice   *\r
+ * * appear in the supporting documentation. The authors make no claims     *\r
+ * * about the suitability of this software for any purpose. It is          *\r
+ * * provided "as is" without express or implied warranty.                  *\r
+ * **************************************************************************/\r
+\r
+////////////////////////////////////////////////////////////////////////////\r
+//                                                                        //\r
+//  The SAX XML file handler used in the TOFnoiseda                       //\r
+//                                                                        //\r
+//  Author:                                                               //\r
+//    Chiara Zampolli (Chiara.Zampolli@cern.ch)                           //\r
+//                                                                        //\r
+////////////////////////////////////////////////////////////////////////////\r
+\r
+#include <cstdlib>\r
+#include <Riostream.h>\r
+\r
+#include <TList.h>\r
+#include <TObject.h>\r
+#include <TXMLAttr.h>\r
+#include <TSAXParser.h>\r
+\r
+#include "AliLog.h"\r
+#include "AliTOFNoiseConfigHandler.h"\r
+\r
+ClassImp(AliTOFNoiseConfigHandler)\r
+\r
+  \r
+//_____________________________________________________________________________\r
+AliTOFNoiseConfigHandler::AliTOFNoiseConfigHandler()\r
+       :TObject(),\r
+        fDebugFlag(0),\r
+        fAcquisitionWindow(0)\r
+{\r
+       //\r
+       // AliTOFNoiseConfigHandler default constructor\r
+       //\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTOFNoiseConfigHandler::AliTOFNoiseConfigHandler(const AliTOFNoiseConfigHandler &sh)\r
+       :TObject(sh),\r
+        fDebugFlag(sh.fDebugFlag),\r
+        fAcquisitionWindow(sh.fAcquisitionWindow)\r
+{\r
+       //\r
+       // AliTOFNoiseConfigHandler copy constructor\r
+       //\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTOFNoiseConfigHandler &AliTOFNoiseConfigHandler::operator=(const AliTOFNoiseConfigHandler &sh)\r
+{\r
+       //\r
+       // Assignment operator\r
+       //\r
+       if (&sh == this) return *this;\r
+       \r
+       new (this) AliTOFNoiseConfigHandler(sh);\r
+       return *this;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTOFNoiseConfigHandler::~AliTOFNoiseConfigHandler()\r
+{\r
+       //\r
+       // AliTOFNoiseConfigHandler destructor\r
+       //      \r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnStartDocument()\r
+{\r
+       // if something should happen right at the beginning of the\r
+       // XML document, this must happen here\r
+       AliInfo("Reading XML file for TOFnoiseda Config");\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnEndDocument()\r
+{\r
+       // if something should happen at the end of the XML document\r
+       // this must be done here\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnStartElement(const char *name, const TList *attributes)\r
+{\r
+       // when a new XML element is found, it is processed here\r
+\r
+       // set the current system if necessary\r
+       TString strName(name);\r
+       AliDebug(2,Form("name = %s",strName.Data()));\r
+       TXMLAttr* attr;\r
+       TIter next(attributes);\r
+       while ((attr = (TXMLAttr*) next())) {\r
+               TString attrName = attr->GetName();\r
+               AliDebug(2,Form("Name = %s",attrName.Data())); \r
+               if (attrName == "DebugFlag"){\r
+                       TString debugFlag = (TString)(attr->GetValue());\r
+                       if (debugFlag == "ON" || debugFlag == "On" || debugFlag == "on"){       \r
+                               fDebugFlag = 1;\r
+                       }\r
+                       else if (debugFlag == "OFF" || debugFlag == "Off"|| debugFlag == "off"){\r
+                               fDebugFlag = 0;\r
+                       }\r
+                       else {\r
+                               AliWarning("Invalid Debug Flag. Keeping debug off");\r
+                               fDebugFlag = 0;\r
+                       }\r
+               }\r
+               if (attrName == "AcquisitionWindow"){\r
+                       fAcquisitionWindow = (Int_t)(((TString)(attr->GetValue())).Atoi());\r
+               }\r
+       }       \r
+       AliDebug(2,Form("Debug Flag = %i",fDebugFlag)); \r
+       AliDebug(2,Form("Acquisition Window = %i",fAcquisitionWindow)); \r
+       return;\r
+}\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnEndElement(const char *name)\r
+{\r
+       // do everything that needs to be done when an end tag of an element is found\r
+       TString strName(name);\r
+       AliDebug(2,Form("name = %s",strName.Data()));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnCharacters(const char *characters)\r
+{\r
+       // copy the text content of an XML element\r
+       //fContent = characters;\r
+       TString strCharacters(characters);\r
+       AliDebug(2,Form("characters = %s",strCharacters.Data()));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnComment(const char* /*text*/)\r
+{\r
+       // comments within the XML file are ignored\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnWarning(const char *text)\r
+{\r
+       // process warnings here\r
+       AliInfo(Form("Warning: %s",text));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnError(const char *text)\r
+{\r
+       // process errors here\r
+       AliError(Form("Error: %s",text));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnFatalError(const char *text)\r
+{\r
+       // process fatal errors here\r
+       AliFatal(Form("Fatal error: %s",text));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFNoiseConfigHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)\r
+{\r
+       // process character data blocks here\r
+       // not implemented and should not be used here\r
+}\r
+\r
diff --git a/TOF/AliTOFNoiseConfigHandler.h b/TOF/AliTOFNoiseConfigHandler.h
new file mode 100644 (file)
index 0000000..a429d85
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALITOFNOISECONFIGHANDLER_H
+#define ALITOFNOISECONFIGHANDLER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * * See cxx source for full Copyright notice */
+/* $Id$ */
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  The SAX XML file handler used by the TOF noiseDA                      //
+//  to get the necessary flags to run (e.g. debug flag)                   //
+//                                                                        //
+//  Chiara.Zampolli (Chiara.Zampolli@cern.ch)                             //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+class TString;
+
+class AliTOFNoiseConfigHandler : public TObject {
+
+public:
+
+  AliTOFNoiseConfigHandler();
+  AliTOFNoiseConfigHandler(const AliTOFNoiseConfigHandler &sh);
+  virtual ~AliTOFNoiseConfigHandler();
+  AliTOFNoiseConfigHandler &operator=(const AliTOFNoiseConfigHandler &sh);
+
+  // functions to interface to TSAXHandler
+  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);
+
+  Int_t GetDebugFlag() const {return fDebugFlag;}
+  Int_t GetAcquisitionWindow() const {return fAcquisitionWindow;}
+
+ private:
+  Int_t fDebugFlag;          // debug flag: 0-->off, 1-->on
+  Int_t fAcquisitionWindow;  // acquisition window width in ns
+
+  ClassDef(AliTOFNoiseConfigHandler,0);    // The XML file handler for the OCDB
+};
+#endif
+
diff --git a/TOF/TOFNoiseConfig.xml b/TOF/TOFNoiseConfig.xml
new file mode 100644 (file)
index 0000000..4de03c7
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE TOFConfig [
+<!ELEMENT TOFConfig (Folder)>
+<!ELEMENT Folder EMPTY>
+<!ATTLIST Folder DebugFlag CDATA #REQUIRED>
+<!ATTLIST Folder AcquisitionWindow CDATA #REQUIRED>
+]>
+<TOFConfig>
+<Folder DebugFlag="On" AcquisitionWindow="200">
+</Folder>
+</TOFConfig>
index acc41f4..dd65700 100644 (file)
@@ -30,6 +30,7 @@
 #pragma link C++ class  AliTOFFormatDCS+;
 #pragma link C++ class  AliTOFFEEReader+;
 #pragma link C++ class  AliTOFCableLengthMap+;
+#pragma link C++ class  AliTOFNoiseConfigHandler+;
 
 
 #endif
index feea245..9ca0ce9 100644 (file)
@@ -30,6 +30,7 @@ Trigger types used: PHYSICS_EVENT (for the time being)
 #include <AliTOFHitData.h>
 #include <AliTOFHitDataBuffer.h>
 #include <AliTOFDecoder.h>
+#include <AliTOFNoiseConfigHandler.h>
 
 //ROOT
 #include <TFile.h>
@@ -40,6 +41,7 @@ Trigger types used: PHYSICS_EVENT (for the time being)
 #include <TSystem.h>
 #include "TROOT.h"
 #include "TPluginManager.h"
+#include "TSAXParser.h"
 
 /* Main routine
       Arguments: list of DATE raw data files
@@ -82,6 +84,29 @@ int main(int argc, char **argv) {
     return -1;
   }
 
+  /* retrieve config file */
+  int getConfigFile = daqDA_DB_getFile("TOFNoiseConfig.xml","TOFNoiseConfig.xml");
+  if (getConfigFile != 0){
+    printf("Failed to retrieve config file from DB! returning...\n");
+    return -1;
+  }
+
+  AliTOFNoiseConfigHandler* tofHandler = new AliTOFNoiseConfigHandler();
+  TSAXParser *parser = new TSAXParser();
+  parser->ConnectToHandler("AliTOFNoiseConfigHandler", tofHandler);  
+  if (parser->ParseFile("./TOFNoiseConfig.xml") != 0){
+         printf("Failed parsing config file! retunring... \n");
+         return -1;
+  }
+  Int_t debugFlag = tofHandler->GetDebugFlag();
+  Int_t acquisitionWindow = tofHandler->GetAcquisitionWindow();
+  if (acquisitionWindow == 0){
+         printf("Problems with the acquisition window, set to zero! returning...\n");
+         return -1;
+  }
+  printf("the debug flag is %i\n",debugFlag);
+  printf("the acquisition window is %i (ns)\n",acquisitionWindow);
+
   /* init some counters */
   int nevents_physics=0;
   int nevents_total=0;
@@ -218,7 +243,7 @@ int main(int argc, char **argv) {
              //printf ("index = %i \n",index);
              htofNoise->Fill(index); //channel index start from 0, bin index from 1
              //debugging printings
-             //printf("sector %i, plate %i, strip %i, padz %i, padx %i \n",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]);
+             if (debugFlag) printf("sector %i, plate %i, strip %i, padz %i, padx %i \n",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]);
            }
          }
          /* reset buffer */
@@ -256,17 +281,28 @@ int main(int argc, char **argv) {
   delete geom;
   geom = 0x0;
 
-  Float_t time = nevents_physics*200*1E-9; // acquisition time in s
+  Int_t noisyChannels = 0;
+  Int_t checkedChannels = 0;
+  Float_t time = nevents_physics*acquisitionWindow*1E-9; // acquisition time in s
   //printf(" Noise run lasted %f s \n",time);
   for (Int_t ibin =1;ibin<=size;ibin++){
     Float_t cont = htofNoise->GetBinContent(ibin);
     if (cont!=-1) {
+      checkedChannels++;
       //printf(" content = %f \n", cont); 
       htofNoise->SetBinContent(ibin,cont/time);
       //printf(" scaled content = %f \n", cont/time);
+      if (cont != 0){
+       noisyChannels++;
+      }
     } 
   }  
 
+  if (debugFlag){
+         printf("Number of checked channels = %i\n",checkedChannels);
+         printf("Number of noisy channels = %i\n",noisyChannels);
+  }
+
   //write the Run level file   
   char filename[100];
   sprintf(filename,"TOFoutNoiseLDC_%02i.root",ldcId);
index 800418e..d392039 100644 (file)
@@ -22,7 +22,8 @@ SRCS  = AliTOFGeometry.cxx  \
         AliTOFFormatDCS.cxx \
        AliTOFPreprocessorFDR.cxx \
        AliTOFFEEReader.cxx \
-       AliTOFCableLengthMap.cxx
+       AliTOFCableLengthMap.cxx \
+       AliTOFNoiseConfigHandler.cxx
 
 
 HDRS:= $(SRCS:.cxx=.h)