Adding configuration file for TOF da running during Physics runs.
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 8 Jul 2009 15:05:39 +0000 (15:05 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 8 Jul 2009 15:05:39 +0000 (15:05 +0000)
The configuration file sets the debug level of the printouts,
and the flag to decide whether to use or not the T0 data
to calculate the time of flight.

TOF/AliTOFDaConfigHandler.cxx [new file with mode: 0644]
TOF/AliTOFDaConfigHandler.h [new file with mode: 0644]
TOF/AliTOFNoiseConfigHandler.h
TOF/TOFPhysicsConfig.xml [new file with mode: 0644]
TOF/TOFbaseLinkDef.h
TOF/TOFda.cxx
TOF/libTOFbase.pkg

diff --git a/TOF/AliTOFDaConfigHandler.cxx b/TOF/AliTOFDaConfigHandler.cxx
new file mode 100644 (file)
index 0000000..3a9f54b
--- /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 TOFda                            //\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 "AliTOFDaConfigHandler.h"\r
+\r
+ClassImp(AliTOFDaConfigHandler)\r
+\r
+  \r
+//_____________________________________________________________________________\r
+AliTOFDaConfigHandler::AliTOFDaConfigHandler()\r
+       :TObject(),\r
+        fDebugFlag(0),\r
+        fT0Flag(0)\r
+{\r
+       //\r
+       // AliTOFDaConfigHandler default constructor\r
+       //\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTOFDaConfigHandler::AliTOFDaConfigHandler(const AliTOFDaConfigHandler &sh)\r
+       :TObject(sh),\r
+        fDebugFlag(sh.fDebugFlag),\r
+        fT0Flag(sh.fT0Flag)\r
+{\r
+       //\r
+       // AliTOFDaConfigHandler copy constructor\r
+       //\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTOFDaConfigHandler &AliTOFDaConfigHandler::operator=(const AliTOFDaConfigHandler &sh)\r
+{\r
+       //\r
+       // Assignment operator\r
+       //\r
+       if (&sh == this) return *this;\r
+       \r
+       new (this) AliTOFDaConfigHandler(sh);\r
+       return *this;\r
+}\r
+\r
+//_____________________________________________________________________________\r
+AliTOFDaConfigHandler::~AliTOFDaConfigHandler()\r
+{\r
+       //\r
+       // AliTOFDaConfigHandler destructor\r
+       //      \r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFDaConfigHandler::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 TOF da Config");\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFDaConfigHandler::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 AliTOFDaConfigHandler::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
+                       fDebugFlag = ((TString)(attr->GetValue())).Atoi();\r
+               }\r
+               if (attrName == "t0Flag"){\r
+                       TString t0Flag = (TString)(attr->GetValue());\r
+                       if (t0Flag == "ON" || t0Flag == "On" || t0Flag == "on"){        \r
+                               fT0Flag = 1;\r
+                       }\r
+                       else if (t0Flag == "OFF" || t0Flag == "Off"|| t0Flag == "off"){\r
+                               fT0Flag = 0;\r
+                       }\r
+                       else {\r
+                               AliWarning("Invalid T0 Flag. Keeping t0 off");\r
+                               fT0Flag = 0;\r
+                       }\r
+               }\r
+       }       \r
+       AliDebug(2,Form("Debug Flag = %i",fDebugFlag)); \r
+       AliDebug(2,Form("T0 Flag = %i",fT0Flag)); \r
+       return;\r
+}\r
+//_____________________________________________________________________________\r
+void AliTOFDaConfigHandler::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 AliTOFDaConfigHandler::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 AliTOFDaConfigHandler::OnComment(const char* /*text*/)\r
+{\r
+       // comments within the XML file are ignored\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFDaConfigHandler::OnWarning(const char *text)\r
+{\r
+       // process warnings here\r
+       AliInfo(Form("Warning: %s",text));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFDaConfigHandler::OnError(const char *text)\r
+{\r
+       // process errors here\r
+       AliError(Form("Error: %s",text));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFDaConfigHandler::OnFatalError(const char *text)\r
+{\r
+       // process fatal errors here\r
+       AliFatal(Form("Fatal error: %s",text));\r
+}\r
+\r
+//_____________________________________________________________________________\r
+void AliTOFDaConfigHandler::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/AliTOFDaConfigHandler.h b/TOF/AliTOFDaConfigHandler.h
new file mode 100644 (file)
index 0000000..8894e30
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALITOFDACONFIGHANDLER_H
+#define ALITOFDACONFIGHANDLER_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 DA for PHYSICS runs          //
+//  to get the necessary flags to run (e.g. debug flag)                   //
+//                                                                        //
+//  Chiara.Zampolli (Chiara.Zampolli@cern.ch)                             //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+class TString;
+
+class AliTOFDaConfigHandler : public TObject {
+
+public:
+
+  AliTOFDaConfigHandler();
+  AliTOFDaConfigHandler(const AliTOFDaConfigHandler &sh);
+  virtual ~AliTOFDaConfigHandler();
+  AliTOFDaConfigHandler &operator=(const AliTOFDaConfigHandler &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 GetT0Flag() const {return fT0Flag;}
+
+ private:
+  Int_t fDebugFlag;          // debug flag: 0-->off, 1-->first level of debug, 2-->second level of debug, 3-->third level of debug
+  Int_t fT0Flag;             // flag for using T0: 0-->off, 1-->on
+
+  ClassDef(AliTOFDaConfigHandler,0);  
+};
+#endif
+
index 671a9a2..58c896d 100644 (file)
@@ -42,7 +42,7 @@ public:
  private:
   Int_t fDebugFlag;          // debug flag: 0-->off, 1-->on
 
-  ClassDef(AliTOFNoiseConfigHandler,0);    // The XML file handler for the OCDB
+  ClassDef(AliTOFNoiseConfigHandler,0);   
 };
 #endif
 
diff --git a/TOF/TOFPhysicsConfig.xml b/TOF/TOFPhysicsConfig.xml
new file mode 100644 (file)
index 0000000..9528f02
--- /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 t0Flag CDATA #REQUIRED>
+]>
+<TOFConfig>
+<Folder DebugFlag="2" t0Flag="On">
+</Folder>
+</TOFConfig>
index c52f523..ba98c45 100644 (file)
@@ -33,6 +33,7 @@
 #pragma link C++ class  AliTOFNoiseConfigHandler+;
 #pragma link C++ class  AliTOFcalibHisto+;
 #pragma link C++ class  AliTOFArray+;
+#pragma link C++ class  AliTOFDaConfigHandler+;
 
 
 #endif
index 5b1b155..95c996b 100644 (file)
@@ -33,7 +33,7 @@ Trigger types used: PHYSICS_EVENT
 #include <AliDAQ.h>
 #include <AliTOFHitData.h>
 #include <AliTOFHitDataBuffer.h>
-#include <AliTOFNoiseConfigHandler.h>
+#include <AliTOFDaConfigHandler.h>
 
 //ROOT
 #include <TFile.h>
@@ -82,22 +82,24 @@ int main(int argc, char **argv) {
   }
 
   /* retrieve config file */
-  int getConfigFile = daqDA_DB_getFile("TOFNoiseConfig.xml","TOFNoiseConfig.xml");
+  int getConfigFile = daqDA_DB_getFile("TOFPhysicsConfig.xml","TOFPhysicsConfig.xml");
   if (getConfigFile != 0){
     printf("Failed to retrieve config file from DB! returning...\n");
     return -1;
   }
 
-  AliTOFNoiseConfigHandler* tofHandler = new AliTOFNoiseConfigHandler();
+  AliTOFDaConfigHandler* tofHandler = new AliTOFDaConfigHandler();
   TSAXParser *parser = new TSAXParser();
-  parser->ConnectToHandler("AliTOFNoiseConfigHandler", tofHandler);  
-  if (parser->ParseFile("./TOFNoiseConfig.xml") != 0) {
+  parser->ConnectToHandler("AliTOFDaConfigHandler", tofHandler);  
+  if (parser->ParseFile("./TOFPhysicsConfig.xml") != 0) {
     printf("Failed parsing config file! retunring... \n");
     return -1;
   }
 
   Int_t debugFlag = tofHandler->GetDebugFlag();
   printf("the debug flag is %i\n",debugFlag);
+  Int_t t0Flag = tofHandler->GetT0Flag();
+  printf("the debug flag is %i\n",t0Flag);
 
   /* init some counters */
   int nevents_physics=0;
@@ -197,7 +199,10 @@ int main(int argc, char **argv) {
        */
         //meantime = rawReaderT0->GetData(49,0); //OLD
         meantime = (Int_t)((rawReaderT0->GetData(51,0)+rawReaderT0->GetData(52,0))/2.); //Alla
-       //        printf("time zero (ns) = %i (%f) \n", meantime, (meantime*24.4-200)*1E-3);   // debugging purpose
+       if (debugFlag > 0) {
+               printf("time zero = %i (TDC bin)\n", meantime);   // debugging purpose
+               printf("time zero (ns) = %i (%f) \n", meantime, (meantime*24.4-200)*1E-3);   // debugging purpose
+       }
       }
       
       delete rawReaderT0;
@@ -248,7 +253,10 @@ int main(int argc, char **argv) {
            dummy = Volume[3];
            Volume[3] = Volume[4];
            Volume[4] = dummy;
-           Int_t tof = (Int_t)((Double_t)HitData->GetTime()*1E3/AliTOFGeometry::TdcBinWidth());
+           Int_t tofRaw = (Int_t)((Double_t)HitData->GetTime()*1E3/AliTOFGeometry::TdcBinWidth());
+           Int_t tof;
+           if (!t0Flag) tof = tofRaw;
+           else tof = tofRaw - meantime;
            Int_t index = geom->GetIndex(Volume);
            Float_t pos[3];
            geom->GetPosPar(Volume,pos);
@@ -257,14 +265,17 @@ int main(int argc, char **argv) {
            Int_t deltabin = tof-TMath::Nint(texpBin);   //to be used with real data; rounding expected time to Int_t
            htofPartial->Fill(index,deltabin); //channel index start from 0, bin index from 1
            //debugging printings
-           //if (debugFlag) {
-           //  printf("sector %2d, plate %1d, strip %2d, padz %1d, padx %2d \n",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]); // too verbose
-           //  printf("pos x = %f, pos y = %f, pos z = %f \n",pos[0],pos[1],pos[2]); // too verbose
-           //  printf("expected time = %f (ns)\n",texp); // too verbose
-           //  printf("expected time bin = %f (TDC bin)\n",texpBin); // too verbose
-           //  printf("measured time bin = %i (TDC bin) with %f (ns) and ACQ bit = %i \n",tof, HitData->GetTime(), HitData->GetACQ()); // too verbose
-           //  printf("index = %6d, deltabin = %d , filling index = %6d, and bin = %d\n",index, deltabin, index, deltabin); // too verbose
-           //}
+           if (debugFlag > 1) {
+                   printf("tofRaw = %i, tof = %i \n",tofRaw,tof);
+           }
+           if (debugFlag > 2) {
+                   printf("sector %2d, plate %1d, strip %2d, padz %1d, padx %2d \n",Volume[0],Volume[1],Volume[2],Volume[3],Volume[4]); // too verbose
+                   printf("pos x = %f, pos y = %f, pos z = %f \n",pos[0],pos[1],pos[2]); // too verbose
+                   printf("expected time = %f (ns)\n",texp); // too verbose
+                   printf("expected time bin = %f (TDC bin)\n",texpBin); // too verbose
+                   printf("measured time bin = %i (TDC bin) with %f (ns) and ACQ bit = %i \n",tof, HitData->GetTime(), HitData->GetACQ()); // too verbose
+                   printf("index = %6d, deltabin = %d , filling index = %6d, and bin = %d\n",index, deltabin, index, deltabin); // too verbose
+           }
 
          }
          /* reset buffer */
index ddffd6b..d548466 100644 (file)
@@ -25,7 +25,8 @@ SRCS  = AliTOFGeometry.cxx  \
        AliTOFCableLengthMap.cxx \
        AliTOFNoiseConfigHandler.cxx \
        AliTOFcalibHisto.cxx \
-       AliTOFArray.cxx
+       AliTOFArray.cxx \
+       AliTOFDaConfigHandler.cxx
 
 
 HDRS:= $(SRCS:.cxx=.h)