]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
software update:
authorrpreghen <rpreghen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Mar 2010 15:09:31 +0000 (15:09 +0000)
committerrpreghen <rpreghen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 1 Mar 2010 15:09:31 +0000 (15:09 +0000)
- TOF offline calibration tuned to fulfil time-slewing correction
  (cosmic calibration)
- PHYSICS DA and corresponding config file/class changed
- Preprocessor computes online T0-fill and doesn't compute online delays anymore in PHYSICS run

26 files changed:
OCDB/TOF/Calib/T0FillOnlineCalib/Run0_999999999_v0_s0.root [new file with mode: 0644]
TOF/AliTOFClusterFinder.cxx
TOF/AliTOFDaConfigHandler.cxx
TOF/AliTOFDaConfigHandler.h
TOF/AliTOFDaConfigHandler.old.cxx [new file with mode: 0644]
TOF/AliTOFDaConfigHandler.old.h [new file with mode: 0644]
TOF/AliTOFGeometry.cxx
TOF/AliTOFGeometry.h
TOF/AliTOFHitField.cxx [new file with mode: 0644]
TOF/AliTOFHitField.h [new file with mode: 0644]
TOF/AliTOFLvHvDataPoints.cxx
TOF/AliTOFPreprocessor.cxx
TOF/AliTOFPreprocessor.h
TOF/AliTOFT0FillOnlineCalib.cxx [new file with mode: 0644]
TOF/AliTOFT0FillOnlineCalib.h [new file with mode: 0644]
TOF/CreateCalibPars_CalibHisto.C
TOF/MakeCDBEntryT0FillOnlineCalib.C [new file with mode: 0644]
TOF/ShuttleInput/Hits.root [new file with mode: 0644]
TOF/TOFPhysicsConfig.xml
TOF/TOFPreprocessor.C
TOF/TOFPreprocessorLVHV.C [deleted file]
TOF/TOFbaseLinkDef.h
TOF/TOFda.cxx
TOF/TOFda.old.cxx [new file with mode: 0644]
TOF/data/AliTOFcalibPar.root
TOF/libTOFbase.pkg

diff --git a/OCDB/TOF/Calib/T0FillOnlineCalib/Run0_999999999_v0_s0.root b/OCDB/TOF/Calib/T0FillOnlineCalib/Run0_999999999_v0_s0.root
new file mode 100644 (file)
index 0000000..94d564b
Binary files /dev/null and b/OCDB/TOF/Calib/T0FillOnlineCalib/Run0_999999999_v0_s0.root differ
index 3b333c64ed9f2c400b0af1fc596c0c6a0d12070a..8386ae3284f4a7f54cf7aa2f1a82e0d7a118f291 100644 (file)
@@ -1094,6 +1094,11 @@ void AliTOFClusterFinder::CalibrateRecPoint()
       AliDebug(2,Form(" The ToT and Time, uncorr (counts) = %d , %d", fTofClusters[ii]->GetToT(),fTofClusters[ii]->GetTDC()));
       tToT = (Double_t)(fTofClusters[ii]->GetToT()*AliTOFGeometry::ToTBinWidth());    
       tToT*=1.E-3; //ToT in ns
+
+      /* check TOT limits and set new TOT in case */
+      if (tToT < AliTOFGeometry::SlewTOTMin()) tToT = AliTOFGeometry::SlewTOTMin();
+      if (tToT > AliTOFGeometry::SlewTOTMax()) tToT = AliTOFGeometry::SlewTOTMax();
+
       AliDebug(2,Form(" The ToT and Time, uncorr (ns)= %e, %e",fTofClusters[ii]->GetTDC()*AliTOFGeometry::TdcBinWidth()*1.E-3,tToT));
       timeCorr=par[0]+par[1]*tToT+par[2]*tToT*tToT+par[3]*tToT*tToT*tToT+par[4]*tToT*tToT*tToT*tToT+par[5]*tToT*tToT*tToT*tToT*tToT; // the time correction (ns)
     }
index 3a9f54b90ba34221db0ae40a0528be0de63e6bbb..a1202626aa652e9a8c130056f54e4608dae393ff 100644 (file)
-/*************************************************************************\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
+/*************************************************************************
+ * * 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.                  *
+ * **************************************************************************/
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+//  The SAX XML file handler used in the TOFda                            //
+//                                                                        //
+//  Author:                                                               //
+//    Chiara Zampolli (Chiara.Zampolli@cern.ch)                           //
+//    Roberto Preghenella (R+) (preghenella@bo.infn.it)                   //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include <cstdlib>
+#include <Riostream.h>
+
+#include <TList.h>
+#include <TObject.h>
+#include <TXMLAttr.h>
+#include <TSAXParser.h>
+
+#include "AliLog.h"
+#include "AliTOFDaConfigHandler.h"
+
+ClassImp(AliTOFDaConfigHandler)
+
+
+//_____________________________________________________________________________
+AliTOFDaConfigHandler::AliTOFDaConfigHandler()
+:TObject(),
+  fMeanMultiplicity(0),
+  fMaxHits(0)
+{
+       //
+       // AliTOFDaConfigHandler default constructor
+       //
+}
+
+//_____________________________________________________________________________
+AliTOFDaConfigHandler::AliTOFDaConfigHandler(const AliTOFDaConfigHandler &sh)
+       :TObject(sh),
+        fMeanMultiplicity(sh.fMeanMultiplicity),
+        fMaxHits(sh.fMaxHits)
+{
+       //
+       // AliTOFDaConfigHandler copy constructor
+       //
+}
+
+//_____________________________________________________________________________
+AliTOFDaConfigHandler &AliTOFDaConfigHandler::operator=(const AliTOFDaConfigHandler &sh)
+{
+       //
+       // Assignment operator
+       //
+       if (&sh == this) return *this;
+       
+       new (this) AliTOFDaConfigHandler(sh);
+       return *this;
+}
+
+//_____________________________________________________________________________
+AliTOFDaConfigHandler::~AliTOFDaConfigHandler()
+{
+       //
+       // AliTOFDaConfigHandler destructor
+       //      
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnStartDocument()
+{
+       // if something should happen right at the beginning of the
+       // XML document, this must happen here
+       AliInfo("Reading XML file for TOF da Config");
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnEndDocument()
+{
+       // if something should happen at the end of the XML document
+       // this must be done here
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnStartElement(const char *name, const TList *attributes)
+{
+       // when a new XML element is found, it is processed here
+
+       // set the current system if necessary
+       TString strName(name);
+       AliDebug(2,Form("name = %s",strName.Data()));
+       TXMLAttr* attr;
+       TIter next(attributes);
+       while ((attr = (TXMLAttr*) next())) {
+               TString attrName = attr->GetName();
+               AliDebug(2,Form("Name = %s",attrName.Data())); 
+               if (attrName == "MeanMultiplicity"){
+                 fMeanMultiplicity = ((TString)(attr->GetValue())).Atoi();
+               }
+               if (attrName == "MaxHits"){
+                 fMaxHits = ((TString)(attr->GetValue())).Atoi();
+               }
+       }       
+       AliDebug(2,Form("MeanMultiplicity = %d",fMeanMultiplicity)); 
+       AliDebug(2,Form("MaxHits = %d",fMaxHits)); 
+       return;
+}
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnEndElement(const char *name)
+{
+       // do everything that needs to be done when an end tag of an element is found
+       TString strName(name);
+       AliDebug(2,Form("name = %s",strName.Data()));
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnCharacters(const char *characters)
+{
+       // copy the text content of an XML element
+       //fContent = characters;
+       TString strCharacters(characters);
+       AliDebug(2,Form("characters = %s",strCharacters.Data()));
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnComment(const char* /*text*/)
+{
+       // comments within the XML file are ignored
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnWarning(const char *text)
+{
+       // process warnings here
+       AliInfo(Form("Warning: %s",text));
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnError(const char *text)
+{
+       // process errors here
+       AliError(Form("Error: %s",text));
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnFatalError(const char *text)
+{
+       // process fatal errors here
+       AliFatal(Form("Fatal error: %s",text));
+}
+
+//_____________________________________________________________________________
+void AliTOFDaConfigHandler::OnCdataBlock(const char* /*text*/, Int_t /*len*/)
+{
+       // process character data blocks here
+       // not implemented and should not be used here
+}
+
index 8894e304895032675f6bf17accf60a631cd9e013..86317f0b683c80ecff75e1b191c086d50d35cbad 100644 (file)
@@ -10,6 +10,8 @@
 //  to get the necessary flags to run (e.g. debug flag)                   //
 //                                                                        //
 //  Chiara.Zampolli (Chiara.Zampolli@cern.ch)                             //
+//  Roberto Preghenella (R+) (preghenella@bo.infn.it)                     //
+//                                                                        //
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 
@@ -37,14 +39,15 @@ public:
   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;}
+  Int_t GetMeanMultiplicity() const {return fMeanMultiplicity;};
+  Int_t GetMaxHits() const {return fMaxHits;};
 
  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);  
+  Int_t fMeanMultiplicity; // mean multiplicity
+  Int_t fMaxHits; // max hits 
+
+  ClassDef(AliTOFDaConfigHandler,1);  
 };
 #endif
 
diff --git a/TOF/AliTOFDaConfigHandler.old.cxx b/TOF/AliTOFDaConfigHandler.old.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.old.h b/TOF/AliTOFDaConfigHandler.old.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 b6f35d561c93a62dae692419af82d5a24892c81f..2231fe4c8469db0adfb02c1eb9d75575b8028e04 100644 (file)
@@ -151,6 +151,9 @@ const Float_t AliTOFGeometry::fgkTdcBin = 24.4;     // time-of-flight bin width
 const Float_t AliTOFGeometry::fgkToTBin = 48.8;     // time-over-threshold bin width [ps]
 const Float_t AliTOFGeometry::fgkBunchCrossingBin = fgkTdcBin * 1024; // bunch-crossing bin width [ps]
 
+const Float_t AliTOFGeometry::fgkSlewTOTMin = 10.; // min TOT for slewing correction [ns]
+const Float_t AliTOFGeometry::fgkSlewTOTMax = 16.; // max TOT for slewing correction [ns]
+
 const Float_t AliTOFGeometry::fgkDeadTime = 25E+03;        // Single channel dead time (ps)
 const Float_t AliTOFGeometry::fgkMatchingWindow = fgkTdcBin*TMath::Power(2,13); // Matching window  (ps)
 
index c36504e2128a6c0e5ff27b445aa9d56da56182b1..e8dcfec081ebffa0d205621d412ac531c3b12c74 100644 (file)
@@ -73,6 +73,9 @@ class AliTOFGeometry: public TObject{
   static Float_t ToTBinWidth() {return fgkToTBin;};
   static Float_t BunchCrossingBinWidth() {return fgkBunchCrossingBin;};
 
+  static Float_t SlewTOTMin() {return fgkSlewTOTMin;};
+  static Float_t SlewTOTMax() {return fgkSlewTOTMax;};
+
   virtual void    ImportGeometry();
   virtual void    SetHoles(Bool_t holes) {fHoles = holes;};
   virtual Bool_t  GetHoles() const {return fHoles;};
@@ -175,6 +178,9 @@ class AliTOFGeometry: public TObject{
   static const Float_t fgkToTBin;   // time-over-threshold bin width [ps]
   static const Float_t fgkBunchCrossingBin; // bunch-crossing bin width [ps]
 
+  static const Float_t fgkSlewTOTMin; // min TOT for slewing correction [ns]
+  static const Float_t fgkSlewTOTMax; // max TOT for slewing correction [ns]
+
   ClassDef(AliTOFGeometry,8) // TOF Geometry base class
 };
 
diff --git a/TOF/AliTOFHitField.cxx b/TOF/AliTOFHitField.cxx
new file mode 100644 (file)
index 0000000..38b6d7d
--- /dev/null
@@ -0,0 +1,83 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////
+//                                                           //
+//   This class provides the minimum-size TOF hit info       //
+//                                                           //
+//   author: Roberto Preghenella (R+)                        //
+//           preghenella@bo.infn.it                          //
+//                                                           //
+///////////////////////////////////////////////////////////////
+
+#include "AliTOFHitField.h"
+
+ClassImp(AliTOFHitField)
+
+//-----------------------------------------------------------------------------
+
+AliTOFHitField::AliTOFHitField() : 
+  fIndex(0),
+  fTimeBin(0),
+  fTOTBin(0),
+  fDeltaBC(0),
+  fL0L1Latency(0)
+{
+  /*
+   * default constructor
+   */
+}
+
+//-----------------------------------------------------------------------------
+
+AliTOFHitField::~AliTOFHitField()
+{
+  /*
+   * default destructor
+   */
+}
+
+//-----------------------------------------------------------------------------
+
+AliTOFHitField::AliTOFHitField(const AliTOFHitField &source) :
+  fIndex(source.fIndex),
+  fTimeBin(source.fTimeBin),
+  fTOTBin(source.fTOTBin),
+  fDeltaBC(source.fDeltaBC),
+  fL0L1Latency(source.fL0L1Latency)
+{ 
+  /*
+   * default constructor
+   */
+}
+
+//-----------------------------------------------------------------------------
+
+AliTOFHitField & 
+AliTOFHitField::operator=(const AliTOFHitField &source) 
+{ 
+  /*
+   * operator=
+   */
+
+  if(this==&source) return *this;
+  fIndex = source.fIndex;
+  fTimeBin = source.fTimeBin;
+  fTOTBin = source.fTOTBin;
+  fDeltaBC = source.fDeltaBC;
+  fL0L1Latency =source.fL0L1Latency;
+  return *this;
+}
+
diff --git a/TOF/AliTOFHitField.h b/TOF/AliTOFHitField.h
new file mode 100644 (file)
index 0000000..7d130bc
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef ALITOFHITFIELD_H
+#define ALITOFHITFIELD_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+///////////////////////////////////////////////////////////////
+//                                                           //
+//   This class provides the minimum-size TOF hit info       //
+//                                                           //
+//   author: Roberto Preghenella (R+)                        //
+//           preghenella@bo.infn.it                          //
+//                                                           //
+///////////////////////////////////////////////////////////////
+
+#include "TROOT.h"
+
+class AliTOFHitField
+{
+  
+ public:
+  
+  AliTOFHitField(); // default constructor
+  virtual ~AliTOFHitField(); // default destructor
+  AliTOFHitField(const AliTOFHitField &source); // copy constructor
+  AliTOFHitField &operator=(const AliTOFHitField &source); // operator=
+
+  UInt_t GetIndex() const {return fIndex;}; // get index
+  UShort_t GetTimeBin() const {return fTimeBin;}; // get time bin
+  UShort_t GetTOTBin() const {return fTOTBin;}; // get TOT bin
+  UChar_t GetDeltaBC() const {return fDeltaBC;}; // get delta BC
+  UShort_t GetL0L1Latency() const {return fL0L1Latency;}; // get L0-L1 latency
+
+  void SetIndex(UInt_t value) {fIndex = value;}; // set index
+  void SetTimeBin(UShort_t value) {fTimeBin = value;}; // set time bin
+  void SetTOTBin(UShort_t value) {fTOTBin = value;}; // set TOT bin
+  void SetDeltaBC(UChar_t value) {fDeltaBC = value;}; // set delta BC
+  void SetL0L1Latency(UShort_t value) {fL0L1Latency = value;}; // set L0-L1 latency
+  
+ private:
+  
+  UInt_t fIndex; // channel index
+  UShort_t fTimeBin; // time bin [24.4 ps]
+  UShort_t fTOTBin; // TOT bin [48.8 ps]
+  UChar_t fDeltaBC; // delta BC [BC bins]
+  UShort_t fL0L1Latency; // L0-L1 latency [BC bins]
+  
+  ClassDef(AliTOFHitField, 1);
+};
+
+#endif /* ALITOFHITFIELD_H */
index 2f96c535559108a8e3850f9c2db1564e2647c186..9c708e87fd5d6c45a318b4ede7e3f7d445668c68 100644 (file)
@@ -177,6 +177,7 @@ Bool_t AliTOFLvHvDataPoints::ProcessData(TMap& aliasMap) {
   AliDebug(1,Form(" Number of LV dps = %d",fNumberOfLVdataPoints));
 
   if (!MergeHVmap()) return kFALSE;
+  if (fNumberOfLVdataPoints==0) return kFALSE;
   if (!MergeLVmap()) return kFALSE;
 
   if (!MergeMaps()) return kFALSE;
@@ -401,6 +402,39 @@ Bool_t AliTOFLvHvDataPoints::ReadHVDataPoints(TMap& aliasMap) {
       }
     }
 
+  if (fNumberOfHVdataPoints==0) {
+    AliInfo("Valid LV dps not found. By default all HV TOF channels (except the ones in the PHOS holes) switched ON.");
+    for (int i=0; i<kNsectors; i++)
+      for (int j=0; j<kNplates; j++) {
+       for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
+       if ( (i==13 || i==14 || i==15) && j==2) {
+         FillHVarrayPerDataPoint(i,j,0,dummy);
+         AliTOFDCSmaps *object = new AliTOFDCSmaps(0,dummy);
+         InsertHVDataPoint(object);
+       }
+       else {
+         FillHVarrayPerDataPoint(i,j,1,dummy);
+         AliTOFDCSmaps *object = new AliTOFDCSmaps(0,dummy);
+         InsertHVDataPoint(object);
+       }
+      }
+
+    for (int i=0; i<kNsectors; i++)
+      for (int j=0; j<kNplates; j++) {
+       for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
+       if ( (i==13 || i==14 || i==15) && j==2) {
+         FillHVarrayPerDataPoint(i,j,0,dummy);
+         AliTOFDCSmaps *object = new AliTOFDCSmaps(999999,dummy);
+         InsertHVDataPoint(object);
+       }
+       else {
+         FillHVarrayPerDataPoint(i,j,1,dummy);
+         AliTOFDCSmaps *object = new AliTOFDCSmaps(999999,dummy);
+         InsertHVDataPoint(object);
+       }
+      }
+  }
+
   return kTRUE;
 
 }
@@ -463,6 +497,24 @@ Bool_t AliTOFLvHvDataPoints::ReadLVDataPoints(TMap& aliasMap) {
     }
   }
 
+  if (fNumberOfLVdataPoints==0) {
+    AliInfo("Valid LV dps not found. By default all LV TOF channels switched ON.");
+    for (int i=0; i<kNddl; i++) {
+      for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
+      FillLVarrayPerDataPoint(i,0,dummy);
+      AliTOFDCSmaps *object = new AliTOFDCSmaps(0,dummy);
+      InsertLVDataPoint(object);
+    }
+
+    for (int i=0; i<kNddl; i++) {
+      for (Int_t iBin=0; iBin<kNpads; iBin++) dummy[iBin]=-1;
+      FillLVarrayPerDataPoint(i,0,dummy);
+      AliTOFDCSmaps *object = new AliTOFDCSmaps(999999,dummy);
+      InsertLVDataPoint(object);
+    }
+
+  }
+
   return kTRUE;
 
 }
index 7e1119f4f201e495b7e68b9a7e8f6fb502bad53b..5b6d0a01e9bee3ea00f064b3a2d95e2543a9710e 100644 (file)
 #include "AliTOFCableLengthMap.h"
 #include "AliTOFcalibHisto.h"
 #include "AliTOFFEEDump.h"
-
+#include "TChain.h"
+#include "AliTOFDeltaBCOffset.h"
+#include "AliTOFCTPLatency.h"
+#include "AliTOFT0Fill.h"
+#include "AliTOFT0FillOnlineCalib.h"
+#include "AliTOFHitField.h"
+#include "AliTOFChannelOffline.h"
+#include "TF1.h"
+#include "TGeoManager.h"
+#include "AliGeomManager.h"
 
 // TOF preprocessor class.
 // It takes data from DCS and passes them to the class AliTOFDataDCS, which
@@ -142,7 +151,7 @@ Bool_t AliTOFPreprocessor::ProcessDCS(){
 }
 //_____________________________________________________________________________
 
-UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap * const dcsAliasMap)
+UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap *dcsAliasMap)
 {
   // Fills data into a AliTOFDataDCS object
 
@@ -205,7 +214,7 @@ UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap * const dcsAliasMap)
 }
 //_____________________________________________________________________________
 
-UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap * const dcsAliasMap)
+UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap *dcsAliasMap)
 {
   //
   //Fills data into a AliTOFLvHvDataPoints object
@@ -273,7 +282,7 @@ UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap * const dcsAliasMap)
          fIsStatusMapChanged=kTRUE;
        }
       }
-
+      
       // check with plots. Start...
       /*
       for (Int_t ii=0; ii<91*96*18; ii++) {
@@ -374,6 +383,7 @@ UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap * const dcsAliasMap)
   
   return 0;
 }
+
 //_____________________________________________________________________________
 
 UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
@@ -709,6 +719,255 @@ UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
 
   return 0;
 }
+
+//_____________________________________________________________________________
+
+UInt_t 
+AliTOFPreprocessor::ProcessT0Fill()
+{
+  // Processing data from DAQ for T0-fill measurement 
+
+  Log("Processing T0-fill");
+
+#if 0
+  /* instance and setup CDB manager */
+  AliCDBManager *cdb = AliCDBManager::Instance();
+  /* load geometry */
+  if (!gGeoManager) AliGeomManager::LoadGeometry();
+#endif
+
+  /* get params from OCDB */
+  AliCDBEntry *cdbe = NULL;
+
+  /* get T0-fill calibration params */
+  cdbe = GetFromOCDB("Calib", "T0FillOnlineCalib");
+  if (!cdbe) {
+    Log("cannot get \"T0FillOnlineCalib\" entry from OCDB");
+    return 21;
+  }
+  AliTOFT0FillOnlineCalib *t0FillOnlineCalibObject = (AliTOFT0FillOnlineCalib *)cdbe->GetObject();
+  if (!t0FillOnlineCalibObject) {
+    Log("cannot get \"T0FillOnlineCalib\" object from CDB entry");
+    return 21;
+  }
+  Float_t t0FillCalibOffset = t0FillOnlineCalibObject->GetOffset();
+  Float_t t0FillCalibCoefficient = t0FillOnlineCalibObject->GetCoefficient();
+  Log(Form("got \"T0FillOnlineCalib\" object: offset=%f coeff=%f", t0FillCalibOffset, t0FillCalibCoefficient));
+
+  /* get online status from OCDB */
+  cdbe = GetFromOCDB("Calib", "Status");
+  if (!cdbe) {
+    Log("cannot get \"Status\" entry from OCDB");
+    return 21;
+  }
+  AliTOFChannelOnlineStatusArray *statusArray = (AliTOFChannelOnlineStatusArray *)cdbe->GetObject();
+  if (!statusArray) {
+    Log("cannot get \"Status\" object from CDB entry");
+    return 21;
+  }
+  Log("got \"Status\" object");
+
+  /* get offline calibration from OCDB */
+  cdbe = GetFromOCDB("Calib", "ParOffline");
+  if (!cdbe) {
+    Log("cannot get \"ParOffline\" entry from OCDB");
+    return 21;
+  }
+  TObjArray *offlineArray = (TObjArray *)cdbe->GetObject();
+  AliTOFChannelOffline *channelOffline;
+  if (!offlineArray) {
+    Log("cannot get \"ParOffline\" object from CDB entry");
+    return 21;
+  }
+  Log("got \"ParOffline\" object");
+
+  /* get deltaBC offset from OCDB */
+  cdbe = GetFromOCDB("Calib", "DeltaBCOffset");
+  if (!cdbe) {
+    Log("cannot get \"DeltaBCOffset\" entry from OCDB");
+    return 21;
+  }
+  AliTOFDeltaBCOffset *deltaBCOffsetObject = (AliTOFDeltaBCOffset *)cdbe->GetObject();
+  if (!deltaBCOffsetObject) {
+    Log("cannot get \"DeltaBCOffset\" object from CDB entry");
+    return 21;
+  }
+  Int_t deltaBCOffset = deltaBCOffsetObject->GetDeltaBCOffset();
+  Log(Form("got \"DeltaBCOffset\" object: deltaBCOffset=%d (BC bins)", deltaBCOffset));
+
+  /* get CTP latency from OCDB */
+  cdbe = GetFromOCDB("Calib", "CTPLatency");
+  if (!cdbe) {
+    Log("cannot get \"CTPLatency\" entry from OCDB");
+    return 21;
+  }
+  AliTOFCTPLatency *ctpLatencyObject = (AliTOFCTPLatency *)cdbe->GetObject();
+  if (!ctpLatencyObject) {
+    Log("cannot get \"CTPLatency\" object from CDB entry");
+    return 21;
+  }
+  Float_t ctpLatency = ctpLatencyObject->GetCTPLatency();
+  Log(Form("got \"CTPLatency\" object: ctpLatency=%f (ps)", ctpLatency));
+  
+  /* get file sources from FXS */
+  TList *fileList = GetFileSources(kDAQ, "HITS");
+  if (!fileList || fileList->GetEntries() == 0) {
+    Log("cannot get DAQ source file list or empty list");
+    return 21;
+  }
+  Log(Form("got DAQ source file list: %d files", fileList->GetEntries()));
+  fileList->Print();
+  
+  /* create tree chain using file sources */
+  TChain chain("hitTree");
+  for (Int_t ifile = 0; ifile < fileList->GetEntries(); ifile++) {
+    TObjString *str = (TObjString *)fileList->At(ifile);
+    TString filename = GetFile(kDAQ, "HITS", str->GetName());
+    chain.Add(filename);
+    Log(Form("file added to input chain: source=%s, filename=%s", str->String().Data(), filename.Data()));
+  }
+  Int_t nhits = chain.GetEntries();
+  Log(Form("input chain ready: %d hits", nhits));
+
+  /* setup input chain */
+  AliTOFHitField *hit = new AliTOFHitField();
+  chain.SetBranchAddress("hit", &hit);
+
+  /* create calib histo and geometry */
+  AliTOFcalibHisto calibHisto;
+  calibHisto.LoadCalibHisto();
+  AliTOFGeometry tofGeo;
+
+  /* constants */
+  Float_t c = TMath::C() * 1.e2 / 1.e12; /* cm/ps */
+  Float_t c_1 = 1. / c;
+  /* variables */
+  Int_t index, timebin, totbin, deltaBC, l0l1latency, det[5];
+  Float_t timeps, totns, corrps, length, timeexp, timezero, pos[3], latencyWindow;
+
+  /* histos */
+  TH1F *hT0Fill = new TH1F("hT0Fill", "T0 fill;t - t_{exp}^{(c)} (ps);", 2000, -24400., 24400.);
+
+  /* loop over hits */
+  for (Int_t ihit = 0; ihit < nhits; ihit++) {
+
+    /* get entry */
+   chain.GetEntry(ihit);
+    
+    /* get hit info */
+    index = hit->GetIndex();
+    timebin = hit->GetTimeBin();
+    totbin = hit->GetTOTBin();
+    deltaBC = hit->GetDeltaBC();
+    l0l1latency = hit->GetL0L1Latency();
+    latencyWindow = statusArray->GetLatencyWindow(index) * 1.e3;
+    
+    /* convert time in ps and tot in ns */
+    timeps = timebin * AliTOFGeometry::TdcBinWidth();
+    totns = totbin * AliTOFGeometry::ToTBinWidth() * 1.e-3;
+    /* get calibration correction in ps */
+    channelOffline = (AliTOFChannelOffline *)offlineArray->At(index);
+    if (totns < AliTOFGeometry::SlewTOTMin()) totns = AliTOFGeometry::SlewTOTMin();
+    if (totns > AliTOFGeometry::SlewTOTMax()) totns = AliTOFGeometry::SlewTOTMax();
+    corrps = 0.;
+    for (Int_t ipar = 0; ipar < 6; ipar++) corrps += channelOffline->GetSlewPar(ipar) * TMath::Power(totns, ipar);
+    corrps *= 1.e3;
+    /* perform time correction */
+    timeps = timeps + (deltaBC - deltaBCOffset) * AliTOFGeometry::BunchCrossingBinWidth() + l0l1latency * AliTOFGeometry::BunchCrossingBinWidth() + ctpLatency - latencyWindow - corrps;
+    /* compute length and expected time */
+    tofGeo.GetVolumeIndices(index, det);
+    tofGeo.GetPosPar(det, pos);
+    length = 0.;
+    for (Int_t i = 0; i < 3; i++) length += pos[i] * pos[i];
+    length = TMath::Sqrt(length);
+    timeexp = length * c_1;
+    /* compute time zero */
+    timezero = timeps - timeexp;
+    
+    /* fill histos */
+    hT0Fill->Fill(timezero);
+  }
+
+  /* rebin until maximum bin has required minimum entries */
+  Int_t maxBin = hT0Fill->GetMaximumBin();
+  Int_t maxBinContent = hT0Fill->GetBinContent(maxBin);
+  Float_t binWidth = hT0Fill->GetBinWidth(maxBin);
+  while (maxBinContent < 400 && binWidth < 90.) {
+    hT0Fill->Rebin(2);
+    maxBin = hT0Fill->GetMaximumBin();
+    maxBinContent = hT0Fill->GetBinContent(maxBin);
+    binWidth = hT0Fill->GetBinWidth(maxBin);
+  }
+  Float_t maxBinCenter = hT0Fill->GetBinCenter(maxBin);
+
+  /* rough landau fit of the edge */
+  TF1 *landau = (TF1 *)gROOT->GetFunction("landau");
+  landau->SetParameter(1, maxBinCenter);
+  Float_t fitMin = maxBinCenter - 1000.; /* fit from 10 ns before max */
+  Float_t fitMax = maxBinCenter + binWidth; /* fit until a bin width above max */
+  hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
+  /* get rough landau mean and sigma to set a better fit range */
+  Float_t mean = landau->GetParameter(1);
+  Float_t sigma = landau->GetParameter(2);
+  /* better landau fit of the edge */
+  fitMin = maxBinCenter - 3. * sigma;
+  fitMax = mean;
+  hT0Fill->Fit("landau", "q0", "", fitMin, fitMax);
+  /* print params */
+  mean = landau->GetParameter(1);
+  sigma = landau->GetParameter(2);
+  Float_t meane = landau->GetParError(1);
+  Float_t sigmae = landau->GetParError(2);
+  Log(Form("edge fit: mean  = %f +- %f ps", mean, meane));
+  Log(Form("edge fit: sigma = %f +- %f ps", sigma, sigmae));
+  Float_t edge = mean - 3. * sigma;
+  Float_t edgee = TMath::Sqrt(meane * meane + 3. * sigmae * 3. * sigmae);
+  Log(Form("edge fit: edge = %f +- %f ps", edge, edgee));
+  /* apply calibration to get T0-fill from egde */
+  Float_t t0Fill = edge * t0FillCalibCoefficient + t0FillCalibOffset;
+  Log(Form("estimated T0-fill: %f ps", t0Fill));
+
+  /* create T0-fill object */
+  AliTOFT0Fill *t0FillObject = new AliTOFT0Fill();
+  t0FillObject->SetT0Fill(t0Fill);
+
+  /* store reference data */
+  if(fStoreRefData){
+    AliCDBMetaData metaDataHisto;
+    metaDataHisto.SetBeamPeriod(0);
+    metaDataHisto.SetResponsible("Roberto Preghenella");
+    metaDataHisto.SetComment("online T0-fill histogram");
+    if (!StoreReferenceData("Calib","T0Fill", hT0Fill, &metaDataHisto)) {
+      Log("error while storing reference data");
+      delete hT0Fill;
+      delete hit;
+      delete t0FillObject;
+      return 21;
+    }
+    Log("reference data successfully stored");
+  }
+  
+  AliCDBMetaData metaData;
+  metaData.SetBeamPeriod(0);
+  metaData.SetResponsible("Roberto Preghenella");
+  metaData.SetComment("online T0-fill measurement");
+  if (!Store("Calib", "T0Fill", t0FillObject, &metaData, 0, kFALSE)) {
+    Log("error while storing T0-fill object");
+    delete hT0Fill;
+    delete hit;
+    delete t0FillObject;
+    return 21;
+  }
+  Log("T0-fill object successfully stored");
+
+  delete hT0Fill;
+  delete hit;
+  delete t0FillObject;
+  return 0;
+
+}
+
 //_____________________________________________________________________________
 
 UInt_t AliTOFPreprocessor::ProcessPulserData()
@@ -1297,7 +1556,7 @@ UInt_t AliTOFPreprocessor::ProcessFEEData()
 
 //_____________________________________________________________________________
 
-UInt_t AliTOFPreprocessor::Process(TMap * const dcsAliasMap)
+UInt_t AliTOFPreprocessor::Process(TMap *dcsAliasMap)
 {
   //
   // Main AliTOFPreprocessor method called by SHUTTLE
@@ -1322,9 +1581,10 @@ UInt_t AliTOFPreprocessor::Process(TMap * const dcsAliasMap)
     Int_t iresultNoise = ProcessNoiseData();
     return iresultNoise; 
   }
-  
   if (runType == "PHYSICS") {
-    Int_t iresultDAQ = ProcessOnlineDelays();
+    //    Int_t iresultDAQ = ProcessOnlineDelays();
+    Int_t iresultDAQ = ProcessT0Fill();
     if (iresultDAQ != 0) {
       return iresultDAQ;
     }
index 809daf68df27f2c08e5b8d9bedf07f474cb6f9cf..d49b6e36c3773d78afd2600032edee7152efa268 100644 (file)
@@ -31,18 +31,19 @@ class AliTOFPreprocessor : public AliPreprocessor
 
   protected:
     virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
-    virtual UInt_t Process(TMap * const dcsAliasMap);
+    virtual UInt_t Process(TMap *dcsAliasMap);
     virtual Bool_t ProcessDCS();
 
   private:
     AliTOFPreprocessor(const AliTOFPreprocessor & proc); // copy constructor
     AliTOFPreprocessor& operator=(const AliTOFPreprocessor & proc);
-    UInt_t ProcessDCSDataPoints(TMap * const dcsAliasMap);
-    UInt_t ProcessHVandLVdps(TMap * const dcsAliasMap);
+    UInt_t ProcessDCSDataPoints(TMap *dcsAliasMap);
+    UInt_t ProcessHVandLVdps(TMap *dcsAliasMap);
     UInt_t ProcessOnlineDelays();
     UInt_t ProcessPulserData();
     UInt_t ProcessNoiseData();
     UInt_t ProcessFEEData(); // dummy, for the time being
+    UInt_t ProcessT0Fill();
 
     void FillWithCosmicCalibration(AliTOFChannelOnlineArray *cal); // fill with cosmic calibration
     void FillWithCableLengthMap(AliTOFChannelOnlineArray *cal); // fill with cable-lenght map
diff --git a/TOF/AliTOFT0FillOnlineCalib.cxx b/TOF/AliTOFT0FillOnlineCalib.cxx
new file mode 100644 (file)
index 0000000..e5348c3
--- /dev/null
@@ -0,0 +1,77 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, 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.                  *
+ **************************************************************************/
+
+/*
+ *
+ *
+ * this class defines the T0Fill online calibration object to be stored
+ * in OCDB in order to obtain a corrected T0Fill from online algorithm
+ *
+ *
+ */
+
+#include "AliTOFT0FillOnlineCalib.h"
+
+ClassImp(AliTOFT0FillOnlineCalib)
+
+//_________________________________________________________
+
+AliTOFT0FillOnlineCalib::AliTOFT0FillOnlineCalib() :
+  TObject(),
+  fOffset(0.),
+  fCoefficient(0.)
+{
+  /*
+   * default constructor
+   */
+}
+
+//_________________________________________________________
+
+AliTOFT0FillOnlineCalib::~AliTOFT0FillOnlineCalib()
+{
+  /*
+   * default destructor
+   */
+}
+
+//_________________________________________________________
+
+AliTOFT0FillOnlineCalib::AliTOFT0FillOnlineCalib(const AliTOFT0FillOnlineCalib &source) :
+  TObject(source),
+  fOffset(source.fOffset),
+  fCoefficient(source.fCoefficient)
+{
+  /*
+   * copy constructor
+   */
+}
+
+//_________________________________________________________
+
+AliTOFT0FillOnlineCalib &
+AliTOFT0FillOnlineCalib::operator=(const AliTOFT0FillOnlineCalib &source)
+{
+  /*
+   * operator=
+   */
+
+  if (this == &source) return *this;
+  TObject::operator=(source);
+  fOffset = source.fOffset;
+  fCoefficient = source.fCoefficient;
+  return *this;
+}
+
diff --git a/TOF/AliTOFT0FillOnlineCalib.h b/TOF/AliTOFT0FillOnlineCalib.h
new file mode 100644 (file)
index 0000000..1f6b00d
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef ALITOFT0FILLONLINECALIB_H
+#define ALITOFT0FILLONLINECALIB_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+/* $Id$ */
+
+/*
+ *
+ *
+ * this class defines the T0Fill online calibration object to be stored
+ * in OCDB in order to obtain a corrected T0Fill from online algorithm
+ * 
+ *
+ *
+ */
+
+#include "TObject.h"
+
+class AliTOFT0FillOnlineCalib :
+public TObject
+{
+
+ public:
+
+  AliTOFT0FillOnlineCalib(); // default constructor
+  virtual ~AliTOFT0FillOnlineCalib(); // default destructor
+  AliTOFT0FillOnlineCalib(const AliTOFT0FillOnlineCalib &source); // copy constructor
+  AliTOFT0FillOnlineCalib &operator=(const AliTOFT0FillOnlineCalib &source); // operator=
+  Float_t GetOffset() const {return fOffset;}; // getter
+  Float_t GetCoefficient() const {return fCoefficient;}; // getter
+  void SetOffset(Float_t value) {fOffset = value;}; // setter
+  void SetCoefficient(Float_t value) {fCoefficient = value;}; // setter
+
+ private:
+
+  Float_t fOffset; // offset (ps)
+  Float_t fCoefficient; // coefficient
+
+  ClassDef(AliTOFT0FillOnlineCalib, 1);
+};
+
+#endif /* ALITOFT0FILLOnlineCalib_H */
index cd20f0e341c8ad0500f61d7ac7e63b1396d15088..a9ea25118400f97ae63c9015a3b078a3c91c7bff 100644 (file)
@@ -14,19 +14,25 @@ void CreateCalibPars_CalibHisto(){
   calibHisto.SetFullCorrectionFlag(AliTOFcalibHisto::kTimeSlewingCorr, kFALSE);
 
   /* OCDB init */
+  Float_t slewPar[6] = {0.,0.,0.,0.,0.,0.};
   Float_t par[6] = {0.,0.,0.,0.,0.,0.};
   AliCDBManager *man = AliCDBManager::Instance();
   man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
   Int_t nChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
   
   /* common time-slewing params */
-  for (Int_t iSlew = 1; iSlew < 6; iSlew++) 
-    par[iSlew] = calibHisto.GetCalibPar(AliTOFcalibHisto::kTimeSlewingPar, iSlew);
+  for (Int_t iSlew = 0; iSlew < 6; iSlew++) 
+    slewPar[iSlew] = calibHisto.GetCalibPar(AliTOFcalibHisto::kTimeSlewingPar, iSlew);
   
   /* channel-related params */
   for (Int_t ipad = 0 ; ipad<nChannels; ipad++){
     AliTOFChannelOffline *calChannelOffline = (AliTOFChannelOffline*)tofCalOffline->At(ipad);
-    par[0] = calibHisto.GetFullCorrection(ipad);
+    par[0] = slewPar[0] + calibHisto.GetFullCorrection(ipad);
+    par[1] = slewPar[1];
+    par[2] = slewPar[2];
+    par[3] = slewPar[3];
+    par[4] = slewPar[4];
+    par[5] = slewPar[5];
     calChannelOffline->SetSlewPar(par);
   }
 
diff --git a/TOF/MakeCDBEntryT0FillOnlineCalib.C b/TOF/MakeCDBEntryT0FillOnlineCalib.C
new file mode 100644 (file)
index 0000000..29887ae
--- /dev/null
@@ -0,0 +1,22 @@
+MakeCDBEntryT0FillOnlineCalib(Float_t offset = 0., Float_t coefficient = 0., Int_t startRun = 0, Int_t endRun = AliCDBRunRange::Infinity())
+{
+
+  /* create object */
+  AliTOFT0FillOnlineCalib *obj = new AliTOFT0FillOnlineCalib();
+  obj->SetOffset(offset);
+  obj->SetCoefficient(coefficient);
+
+  /* create cdb info */
+  AliCDBId id("TOF/Calib/T0FillOnlineCalib", startRun, endRun);
+  AliCDBMetaData *md = new AliCDBMetaData();
+  md->SetResponsible("Roberto Preghenella");
+  md->SetComment("Online T0-fill calibration parameters");
+  md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+  md->SetBeamPeriod(0);
+
+  /* put object in cdb */
+  AliCDBManager *cdb = AliCDBManager::Instance();
+  cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  cdb->GetDefaultStorage()->Put(obj, id, md);
+
+}
diff --git a/TOF/ShuttleInput/Hits.root b/TOF/ShuttleInput/Hits.root
new file mode 100644 (file)
index 0000000..7fc72da
Binary files /dev/null and b/TOF/ShuttleInput/Hits.root differ
index 9528f0214b8793de617e00608e27617582ffa5cb..f5f4d79201dd8c74748c6c9237e2324a75252c30 100644 (file)
@@ -2,10 +2,10 @@
 <!DOCTYPE TOFConfig [
 <!ELEMENT TOFConfig (Folder)>
 <!ELEMENT Folder EMPTY>
-<!ATTLIST Folder DebugFlag CDATA #REQUIRED>
-<!ATTLIST Folder t0Flag CDATA #REQUIRED>
+<!ATTLIST Folder MeanMultiplicity CDATA #REQUIRED>
+<!ATTLIST Folder MaxMits CDATA #REQUIRED>
 ]>
 <TOFConfig>
-<Folder DebugFlag="2" t0Flag="On">
+<Folder MeanMultiplicity="20" MaxHits="10000000">
 </Folder>
 </TOFConfig>
index 4e27115ac3929f45518b6c776a8252b68d492642..5ef9f198fb85470bc93c929ad72b7cdafad4497d 100644 (file)
@@ -21,7 +21,7 @@ void TOFPreprocessor(Char_t * RunType="PHYSICS")
   AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference");
 
   // create AliTestShuttle instance
-  Int_t nrun = 7;
+  Int_t nrun = 104892;
   AliTestShuttle* shuttle = new AliTestShuttle(nrun, 30, 980);
   //setting run type to physiscs
   shuttle->SetInputRunType(RunType);
@@ -35,6 +35,7 @@ void TOFPreprocessor(Char_t * RunType="PHYSICS")
   shuttle->SetDCSInput(dcsAliasMap);   
 
   // processing files. for the time being, the files are local.
+  shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "HITS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Hits.root");
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
   shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
   shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeLightMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEElight.20090616.102605.8000");
@@ -64,22 +65,10 @@ void TOFPreprocessor(Char_t * RunType="PHYSICS")
   gBenchmark->Stop("process");
   gBenchmark->Print("process");
 
-  // checking the file which should have been created  
-  AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnlineDelay", nrun);
-  if (!chkEntry)
-  {
-    printf("The file is not there. Something went wrong.\n");
-    return;
-  }
-
-  AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
-  // If everything went fine, draw the result
-  if (output)
-    printf("Output found.\n");
-  //    output->Draw();
   
 }
 
+
 TMap* CreateDCSAliasMap()
 {
   // Creates a DCS structure
@@ -97,38 +86,35 @@ TMap* CreateDCSAliasMap()
   aliasMap->SetOwner(1);
 
   TRandom random;
+  /*
   TDatime *datime = new TDatime();
   Int_t time = datime->GetTime();
   Int_t date = datime->GetDate();
   Int_t pid  = gSystem->GetPid();
   delete datime;
   Int_t iseed = TMath::Abs(10000 * pid + time - date); 
+  */
 
-  //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5,
-  //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000;
-  //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5,
-  //  tentFEEthr=0.5, te    result=0;
-  //ntFEEt=20, tentTemp=25, tentPress=900;
-  //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25,
-  //  sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10;
 
   Float_t tentHVv=6500, tentHVi=80;
   Float_t sigmaHVv=10, sigmaHVi=10;
 
-  Float_t tent=0, sigma=0, thr=0;
+  Float_t tent=0, sigma=0;//, thr=0;
   // to have all the aliases, decomment the following line:
   Int_t NAliases=360, NHV=90;
 
+
   // if not all the aliases are there, use this:
   //Int_t NAliases=120, NHV=90;
 
+  TString sindex;
+  TString aliasName;
+
   for(int nAlias=0;nAlias<NAliases;nAlias++) {
 
     TObjArray* valueSet = new TObjArray;
     valueSet->SetOwner(1);
 
-    TString sindex;
-    TString aliasName;
     if (nAlias<NHV){
       aliasName = "tof_hv_vp_";
       sindex.Form("%02i",nAlias);
@@ -169,7 +155,7 @@ TMap* CreateDCSAliasMap()
       //thr=-thrHVc;
     }
     // gauss generation of values 
-    for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
+    for (int timeStamp=0;timeStamp<6000;timeStamp+=10){
     //for (int timeStamp=0;timeStamp<1;timeStamp++){
       Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
       if (TMath::Abs(gaussvalue-tent)>sigma){
@@ -179,11 +165,202 @@ TMap* CreateDCSAliasMap()
     }
 
     aliasMap->Add(new TObjString(aliasName), valueSet);
+
+  }
+
+
+
+
+  const Int_t kNsectors = 18;
+  const Int_t kNplates = 5;
+
+  UInt_t baseWord = 0;
+  UInt_t oldBaseWord = 0;
+
+  for(int i=0;i<kNsectors;i++)
+    for(int j=0;j<kNplates;j++) {
+
+      TObjArray* valueSetHV = new TObjArray;
+      valueSetHV->SetOwner(1);
+
+      aliasName = "TOF_HVSTATUS_";
+      sindex.Form("SM%02dMOD%1d",i,j);
+      aliasName += sindex;
+
+
+      //for (int timeStamp=0;timeStamp<6000;timeStamp+=600) {
+      for (int timeStamp=0;timeStamp<1201;timeStamp+=600) {
+       if (timeStamp==0 /*|| timeStamp==1200*/) {
+         baseWord = CreateHVword(i,j, kTRUE);
+         oldBaseWord = baseWord;
+         AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
+         valueSetHV->Add(dcsVal);
+       }
+       else {
+         if (random.Uniform(0.,1.)>=0.5) {
+           baseWord = CreateHVword(i,j, kFALSE);
+           if (baseWord<=oldBaseWord) {
+             oldBaseWord = baseWord;
+             AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
+             valueSetHV->Add(dcsVal);
+           }
+           else {
+             AliDCSValue* dcsVal = new AliDCSValue(oldBaseWord, timeStamp);
+             valueSetHV->Add(dcsVal);
+           }
+           //Info(Form(" %2d %1d %s %d %d",i,j,aliasName,timeStamp,baseWord));
+         }
+       }
+      }
+
+      /*
+      baseWord = CreateHVword(i,j, kTRUE);
+      AliDCSValue* dcsVal0 = new AliDCSValue(baseWord, 0);
+      valueSetHV->Add(dcsVal0);
+
+      if ((i==0 && j==2) || (i==9 && j==4)) {
+       baseWord = CreateHVword(i,j, kFALSE);
+       AliDCSValue* dcsVal1 = new AliDCSValue(baseWord, 600);
+       valueSetHV->Add(dcsVal1);
+      }
+
+      baseWord = CreateHVword(i,j, kTRUE);
+      AliDCSValue* dcsVal2 = new AliDCSValue(baseWord, 1200);
+      valueSetHV->Add(dcsVal2);
+      */
+
+      aliasMap->Add(new TObjString(aliasName), valueSetHV);
+
+    }
+
+
+  const Int_t kNddl = 72;
+  baseWord = 0;
+  oldBaseWord = 0;
+
+  for(int i=0;i<kNddl;i++) {
+
+    TObjArray* valueSetLV = new TObjArray;
+    valueSetLV->SetOwner(1);
+
+    aliasName = "TOF_FEACSTATUS_";
+    sindex.Form("%02d",i);
+    aliasName += sindex;
+
+
+    //for (int timeStamp=0;timeStamp<6000;timeStamp+=600) {
+    for (int timeStamp=0;timeStamp<1201;timeStamp+=400) {
+      if (timeStamp==0 /*|| timeStamp==1200*/) {
+       baseWord = CreateLVword(kTRUE);
+       AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
+       valueSetLV->Add(dcsVal);
+       oldBaseWord = baseWord;
+       //Info(Form(" %2d %s %d %d",i,aliasName,timeStamp,baseWord));
+       }
+      else {
+       if (random.Uniform(0.,1.)>=0.5) {
+         baseWord = CreateLVword(kFALSE);
+         if (baseWord<=oldBaseWord) {
+           oldBaseWord = baseWord;
+           AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
+           valueSetLV->Add(dcsVal);
+         }
+         else {
+           AliDCSValue* dcsVal = new AliDCSValue(oldBaseWord, timeStamp);
+           valueSetLV->Add(dcsVal);
+         }
+         //Info(Form(" %2d %1d %s %d %d",i,j,aliasName,timeStamp,baseWord));
+       }
+      }
+    }
+
+    /*
+    baseWord = CreateLVword(kTRUE);
+    AliDCSValue* dcsVal0 = new AliDCSValue(baseWord, 0);
+    valueSetLV->Add(dcsVal0);
+
+    if (i==7 || i==9) {
+      baseWord = CreateLVword(kFALSE);
+      AliDCSValue* dcsVal1 = new AliDCSValue(baseWord, 400);
+      valueSetLV->Add(dcsVal1);
+    }
+    else if (i==50 || i==35) {
+      baseWord = CreateLVword(kFALSE);
+      AliDCSValue* dcsVal2 = new AliDCSValue(baseWord, 800);
+      valueSetLV->Add(dcsVal2);
+    }
+
+    baseWord = CreateLVword(kTRUE);
+    AliDCSValue* dcsVal3 = new AliDCSValue(baseWord, 1200);
+    valueSetLV->Add(dcsVal3);
+    */
+
+    aliasMap->Add(new TObjString(aliasName), valueSetLV);
+
   }
 
+
   return aliasMap;
 }
 
+
+UInt_t CreateHVword(Int_t nSector, Int_t nPlate, Bool_t isAtBorder) {
+  //
+  //
+  //
+
+  UInt_t baseWord = 0;
+  UInt_t word = 0;
+  TRandom random;
+
+  for (Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(nPlate); iStrip++) {
+
+    if (isAtBorder) {
+      word = 1;
+      if (nPlate==2 && nSector>=13 && nSector<=15)
+       word = 0;
+    }
+    else {
+      random.Uniform(0.,1.)<0.5 ?   word = 0 : word = 1;
+      if (nPlate==2 && nSector>=13 && nSector<=15)
+       word = 0;
+      word = 0;
+    }
+
+    AliBitPacking::PackWord(word,baseWord,iStrip,iStrip);
+  }
+
+  return baseWord;
+
+}
+
+
+UInt_t CreateLVword(Bool_t isAtBorder) {
+  //
+  //
+  //
+
+  UInt_t baseWord = 0;
+  UInt_t word = 0;
+  TRandom random;
+
+  for (Int_t iFeac=0; iFeac<8; iFeac++) {
+
+    if (isAtBorder)
+      word = 1;
+    else {
+      random.Uniform(0.,1.)<0.5 ?   word = 0 : word = 1;
+      word = 0;
+    }
+
+    AliBitPacking::PackWord(word,baseWord,iFeac,iFeac);
+  }
+
+  return baseWord;
+
+}
+
+
 TMap* ReadDCSAliasMap()
 {
   // Open a file that contains DCS input data
@@ -214,3 +391,5 @@ void WriteDCSAliasMap()
 
   AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
 }
+
+
diff --git a/TOF/TOFPreprocessorLVHV.C b/TOF/TOFPreprocessorLVHV.C
deleted file mode 100644 (file)
index 6ed8f3b..0000000
+++ /dev/null
@@ -1,448 +0,0 @@
-/* 
-$Id: TOFPreprocessor.C 38207 2010-01-13 14:08:33Z rpreghen $ 
-*/
-
-// This class runs the test TOF preprocessor
-// It uses AliTestShuttle to simulate a full Shuttle process
-
-// The input data is created in the functions
-//   CreateDCSAliasMap() creates input that would in the same way come from DCS
-//   ReadDCSAliasMap() reads from a file
-//   CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
-
-
-#ifndef __CINT__
-#include "TDatime.h"
-#include "TMap.h"
-#include "TFile.h"
-#include "TObjString.h"
-#include "TRandom.h"
-#include "TBenchmark.h"
-#include "TString.h"
-
-#include "AliBitPacking.h"
-#include "AliCDBEntry.h"
-#include "AliCDBManager.h"
-#include "AliCDBStorage.h"
-#include "AliDCSValue.h"
-#include "AliLog.h"
-#include "AliTestShuttle.h"
-#include "AliShuttleInterface.h" 
-
-#include "AliTOFDataDCS.h"
-#include "AliTOFPreprocessor.h"
-#include "AliTOFGeometry.h"
-//#include "AliTOFChannelOnlineArray.h"
-#endif
-
-void TOFPreprocessorLVHV(Char_t * RunType="PHYSICS");
-TMap* CreateDCSAliasMap();
-TMap* ReadDCSAliasMap();
-//TMap* CreateInputFilesMap();
-UInt_t CreateHVword(Int_t sec, Int_t pla, Bool_t isAtBorder);
-UInt_t CreateLVword(Bool_t isAtBorder);
-
-
-
-extern TBenchmark *gBenchmark;
-void TOFPreprocessorLVHV(Char_t * RunType)
-{
-  gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
-
-  AliLog::SetClassDebugLevel("AliTOFPreprocessor",2);
-  // initialize location of CDB
-  AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
-  AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference");
-
-  // create AliTestShuttle instance
-  Int_t nrun = 7;
-  AliTestShuttle* shuttle = new AliTestShuttle(nrun, 30, 980);
-  //setting run type to physiscs
-  shuttle->SetInputRunType(RunType);
-  shuttle->SetTimeCreated(20);
-  shuttle->SetDCSQueryOffset(20);
-
-  // Generation of "fake" input DCS data
-  TMap* dcsAliasMap = CreateDCSAliasMap();  
-
-  TFile *file=TFile::Open("dcsMap.root","RECREATE");
-  file->cd();
-  dcsAliasMap->Write();
-  file->Close();
-
-
-  // now give the alias map to the shuttle
-  shuttle->SetDCSInput(dcsAliasMap);   
-
-  // processing files. for the time being, the files are local.
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root");
-  shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root");
-  shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeLightMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEElight.20090616.102605.8000");
-  shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20091217.194708.105517");
-
-  TString filename;
-  TString LDCname;
-  //char filename[100];
-  //char LDCname[5];
-
-  for (Int_t iLDC=0;iLDC<2;iLDC++){
-    filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2);
-    LDCname.Form("LDC%i",iLDC*2);
-    shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename);
-    filename.Form("$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2);
-    LDCname.Form("LDC%i",iLDC*2);
-    shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename);
-  }
-  
-
-  // instantiation of the preprocessor
-  AliPreprocessor* pp = new AliTOFPreprocessor(shuttle);
-  pp->Print();
-
-  // preprocessing
-  gBenchmark->Start("process");
-  shuttle->Process();
-  gBenchmark->Stop("process");
-  gBenchmark->Print("process");
-
-  // checking the file which should have been created  
-  AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnlineDelay", nrun);
-  if (!chkEntry)
-  {
-    printf("The file is not there. Something went wrong.\n");
-    return;
-  }
-
-  AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
-  // If everything went fine, draw the result
-  if (output)
-    printf("Output found.\n");
-  //    output->Draw();
-
-  //shuttle->Delete();
-}
-
-TMap* CreateDCSAliasMap()
-{
-  // Creates a DCS structure
-  // The structure is the following:
-  //   TMap (key --> value)
-  //     <DCSAlias> --> <valueList>
-  //     <DCSAlias> is a string
-  //     <valueList> is a TObjArray of AliDCSValue
-  //     An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
-
-  // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
-  // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
-
-  TMap* aliasMap = new TMap;
-  aliasMap->SetOwner(1);
-
-  TRandom random;
-  /*
-  TDatime *datime = new TDatime();
-  Int_t time = datime->GetTime();
-  Int_t date = datime->GetDate();
-  Int_t pid  = gSystem->GetPid();
-  delete datime;
-  Int_t iseed = TMath::Abs(10000 * pid + time - date); 
-  */
-
-
-  Float_t tentHVv=6500, tentHVi=80;
-  Float_t sigmaHVv=10, sigmaHVi=10;
-
-  Float_t tent=0, sigma=0;//, thr=0;
-  // to have all the aliases, decomment the following line:
-  Int_t NAliases=360, NHV=90;
-
-
-  // if not all the aliases are there, use this:
-  //Int_t NAliases=120, NHV=90;
-
-  TString sindex;
-  TString aliasName;
-
-  for(int nAlias=0;nAlias<NAliases;nAlias++) {
-
-    TObjArray* valueSet = new TObjArray;
-    valueSet->SetOwner(1);
-
-    if (nAlias<NHV){
-      aliasName = "tof_hv_vp_";
-      sindex.Form("%02i",nAlias);
-      aliasName += sindex;
-      //aliasName += nAlias;
-      tent=tentHVv;
-      sigma=sigmaHVv;
-      //      thr=thrHVv;
-    }
-    else if (nAlias<NHV*2){
-      //      aliasName = "HVvneg";
-      //aliasName += nAlias-NHV;
-      aliasName = "tof_hv_vn_";
-      sindex.Form("%02i",nAlias-NHV);
-      aliasName += sindex;
-      tent=-tentHVv;
-      sigma=-sigmaHVv;
-      //thr=-thrHVv;
-    }
-    else if (nAlias<NHV*3){
-      //      aliasName = "HVcpos";
-      //aliasName += nAlias-2*NHV;
-      aliasName = "tof_hv_ip_";
-      sindex.Form("%02i",nAlias-2*NHV);
-      aliasName += sindex;
-      tent=tentHVi;
-      sigma=sigmaHVi;
-      //thr=thrHVc;
-    }
-    else if (nAlias<NHV*4){
-      //      aliasName = "HVcneg";
-      //aliasName += nAlias-3*NHV;
-      aliasName = "tof_hv_in_";
-      sindex.Form("%02i",nAlias-3*NHV);
-      aliasName += sindex;
-      tent=-tentHVi;
-      sigma=-sigmaHVi;
-      //thr=-thrHVc;
-    }
-    // gauss generation of values 
-    for (int timeStamp=0;timeStamp<6000;timeStamp+=10){
-    //for (int timeStamp=0;timeStamp<1;timeStamp++){
-      Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
-      if (TMath::Abs(gaussvalue-tent)>sigma){
-       AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
-       valueSet->Add(dcsVal);
-      }
-    }
-
-    aliasMap->Add(new TObjString(aliasName), valueSet);
-
-  }
-
-
-
-
-  const Int_t kNsectors = 18;
-  const Int_t kNplates = 5;
-
-  UInt_t baseWord = 0;
-  UInt_t oldBaseWord = 0;
-
-  for(int i=0;i<kNsectors;i++)
-    for(int j=0;j<kNplates;j++) {
-
-      TObjArray* valueSetHV = new TObjArray;
-      valueSetHV->SetOwner(1);
-
-      aliasName = "TOF_HVSTATUS_";
-      sindex.Form("SM%02dMOD%1d",i,j);
-      aliasName += sindex;
-
-
-      //for (int timeStamp=0;timeStamp<6000;timeStamp+=600) {
-      for (int timeStamp=0;timeStamp<1201;timeStamp+=600) {
-       if (timeStamp==0 /*|| timeStamp==1200*/) {
-         baseWord = CreateHVword(i,j, kTRUE);
-         oldBaseWord = baseWord;
-         AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
-         valueSetHV->Add(dcsVal);
-       }
-       else {
-         if (random.Uniform(0.,1.)>=0.5) {
-           baseWord = CreateHVword(i,j, kFALSE);
-           if (baseWord<=oldBaseWord) {
-             oldBaseWord = baseWord;
-             AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
-             valueSetHV->Add(dcsVal);
-           }
-           else {
-             AliDCSValue* dcsVal = new AliDCSValue(oldBaseWord, timeStamp);
-             valueSetHV->Add(dcsVal);
-           }
-           //Info(Form(" %2d %1d %s %d %d",i,j,aliasName,timeStamp,baseWord));
-         }
-       }
-      }
-
-      /*
-      baseWord = CreateHVword(i,j, kTRUE);
-      AliDCSValue* dcsVal0 = new AliDCSValue(baseWord, 0);
-      valueSetHV->Add(dcsVal0);
-
-      if ((i==0 && j==2) || (i==9 && j==4)) {
-       baseWord = CreateHVword(i,j, kFALSE);
-       AliDCSValue* dcsVal1 = new AliDCSValue(baseWord, 600);
-       valueSetHV->Add(dcsVal1);
-      }
-
-      baseWord = CreateHVword(i,j, kTRUE);
-      AliDCSValue* dcsVal2 = new AliDCSValue(baseWord, 1200);
-      valueSetHV->Add(dcsVal2);
-      */
-
-      aliasMap->Add(new TObjString(aliasName), valueSetHV);
-
-    }
-
-
-  const Int_t kNddl = 72;
-  baseWord = 0;
-  oldBaseWord = 0;
-
-  for(int i=0;i<kNddl;i++) {
-
-    TObjArray* valueSetLV = new TObjArray;
-    valueSetLV->SetOwner(1);
-
-    aliasName = "TOF_FEACSTATUS_";
-    sindex.Form("%02d",i);
-    aliasName += sindex;
-
-
-    //for (int timeStamp=0;timeStamp<6000;timeStamp+=600) {
-    for (int timeStamp=0;timeStamp<1201;timeStamp+=400) {
-      if (timeStamp==0 /*|| timeStamp==1200*/) {
-       baseWord = CreateLVword(kTRUE);
-       AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
-       valueSetLV->Add(dcsVal);
-       oldBaseWord = baseWord;
-       //Info(Form(" %2d %s %d %d",i,aliasName,timeStamp,baseWord));
-       }
-      else {
-       if (random.Uniform(0.,1.)>=0.5) {
-         baseWord = CreateLVword(kFALSE);
-         if (baseWord<=oldBaseWord) {
-           oldBaseWord = baseWord;
-           AliDCSValue* dcsVal = new AliDCSValue(baseWord, timeStamp);
-           valueSetLV->Add(dcsVal);
-         }
-         else {
-           AliDCSValue* dcsVal = new AliDCSValue(oldBaseWord, timeStamp);
-           valueSetLV->Add(dcsVal);
-         }
-         //Info(Form(" %2d %1d %s %d %d",i,j,aliasName,timeStamp,baseWord));
-       }
-      }
-    }
-
-    /*
-    baseWord = CreateLVword(kTRUE);
-    AliDCSValue* dcsVal0 = new AliDCSValue(baseWord, 0);
-    valueSetLV->Add(dcsVal0);
-
-    if (i==7 || i==9) {
-      baseWord = CreateLVword(kFALSE);
-      AliDCSValue* dcsVal1 = new AliDCSValue(baseWord, 400);
-      valueSetLV->Add(dcsVal1);
-    }
-    else if (i==50 || i==35) {
-      baseWord = CreateLVword(kFALSE);
-      AliDCSValue* dcsVal2 = new AliDCSValue(baseWord, 800);
-      valueSetLV->Add(dcsVal2);
-    }
-
-    baseWord = CreateLVword(kTRUE);
-    AliDCSValue* dcsVal3 = new AliDCSValue(baseWord, 1200);
-    valueSetLV->Add(dcsVal3);
-    */
-
-    aliasMap->Add(new TObjString(aliasName), valueSetLV);
-
-  }
-
-
-  return aliasMap;
-}
-
-
-UInt_t CreateHVword(Int_t nSector, Int_t nPlate, Bool_t isAtBorder) {
-  //
-  //
-  //
-
-  UInt_t baseWord = 0;
-  UInt_t word = 0;
-  TRandom random;
-
-  for (Int_t iStrip=0; iStrip<AliTOFGeometry::NStrip(nPlate); iStrip++) {
-
-    if (isAtBorder) {
-      word = 1;
-      if (nPlate==2 && nSector>=13 && nSector<=15)
-       word = 0;
-    }
-    else {
-      random.Uniform(0.,1.)<0.5 ?   word = 0 : word = 1;
-      if (nPlate==2 && nSector>=13 && nSector<=15)
-       word = 0;
-      word = 0;
-    }
-
-    AliBitPacking::PackWord(word,baseWord,iStrip,iStrip);
-  }
-
-  return baseWord;
-
-}
-
-
-UInt_t CreateLVword(Bool_t isAtBorder) {
-  //
-  //
-  //
-
-  UInt_t baseWord = 0;
-  UInt_t word = 0;
-  TRandom random;
-
-  for (Int_t iFeac=0; iFeac<8; iFeac++) {
-
-    if (isAtBorder)
-      word = 1;
-    else {
-      random.Uniform(0.,1.)<0.5 ?   word = 0 : word = 1;
-      word = 0;
-    }
-
-    AliBitPacking::PackWord(word,baseWord,iFeac,iFeac);
-  }
-
-  return baseWord;
-
-}
-
-
-TMap* ReadDCSAliasMap()
-{
-  // Open a file that contains DCS input data
-  // The CDB framework is used to open the file, this means the file is located
-  // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
-  // The file contains an AliCDBEntry that contains a TMap with the DCS structure.
-  // An explanation of the structure can be found in CreateDCSAliasMap()
-
-  AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
-  return dynamic_cast<TMap*> (entry->GetObject());
-}
-
-void WriteDCSAliasMap()
-{
-  // This writes the output from CreateDCSAliasMap to a CDB file
-
-  TMap* dcsAliasMap = CreateDCSAliasMap();
-
-  AliCDBMetaData metaData;
-       metaData.SetBeamPeriod(0);
-       metaData.SetResponsible("Chiara");
-       metaData.SetComment("Test object for TOFPreprocessor.C");
-
-  AliCDBId id("TOF/DCS/Data", 0, 0);
-
-  // initialize location of CDB
-  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
-
-  AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
-}
index 04ff98b6a82d912bac3e6fcc28925c0f5dbe3687..b3777467d9c223833fda9be727aa81feaa6d32a4 100644 (file)
@@ -15,6 +15,7 @@
 #pragma link C++ class  AliTOFrawData+;
 #pragma link C++ class  AliTOFRawStream+;
 #pragma link C++ class  AliTOFHitData+;
+#pragma link C++ class  AliTOFHitField+;
 #pragma link C++ class  AliTOFHitDataBuffer+;
 #pragma link C++ class  AliTOFDecoder+;
 #pragma link C++ class  AliTOFChannelOffline+;
@@ -38,6 +39,7 @@
 #pragma link C++ class  AliTOFDeltaBCOffset+;
 #pragma link C++ class  AliTOFCTPLatency+;
 #pragma link C++ class  AliTOFT0Fill+;
+#pragma link C++ class  AliTOFT0FillOnlineCalib+;
 #pragma link C++ class  AliTOFDCSmaps+;
 #pragma link C++ class  AliTOFLvHvDataPoints+;
 
index a221e7928f77ee33137c3cb62b8da58682e607a8..8e0b7e350e3f0eabcaf7c90f2b2045e2681e5fb5 100644 (file)
@@ -3,18 +3,18 @@
 TOF DA for online calibration
 
 Contact: Chiara.Zampolli@bo.infn.it
-Link: www.bo.infn.it/~zampolli
+         Roberto.Preghenella@bo.infn.it
+
 Run Type: PHYSICS
 DA Type: MON
-Number of events needed: depending on the run, being run-level
-Input Files: TOFdaTotal.root, to be updated if existing
-Output Files: TOFdaRun.root, TOFdaTotal.root, both to be exported to the DAQ FXS
-Trigger types used: PHYSICS_EVENT
+Number of events needed:
+Input Files: no input
+Output Files: TOFdaHits.root
+Event types used: PHYSICS_EVENT
 
 */
 
-#define FILE_TOTAL "TOFdaTotal.root"
-#define FILE_RUN "TOFdaRun.root"
+#define FILE_HITS "TOFdaHits.root"
 
 // DATE
 #include "event.h"
@@ -25,69 +25,66 @@ Trigger types used: PHYSICS_EVENT
 #include <stdlib.h>
 
 //AliRoot
-#include <AliTOFRawStream.h>
-#include <AliRawReaderDate.h>
-#include <AliRawReader.h>
-#include <AliTOFGeometry.h>
-#include <AliT0RawReader.h>
-#include <AliDAQ.h>
-#include <AliTOFHitData.h>
-#include <AliTOFHitDataBuffer.h>
-#include <AliTOFDaConfigHandler.h>
+#include "TROOT.h"
+#include "AliTOFRawStream.h"
+#include "AliRawReaderDate.h"
+#include "AliRawReader.h"
+#include "AliDAQ.h"
+#include "AliTOFHitData.h"
+#include "AliTOFHitDataBuffer.h"
+#include "AliTOFDaConfigHandler.h"
+#include "AliTOFHitField.h"
+#include "AliTOFcalibHisto.h"
+#include "AliLog.h"
 
 //ROOT
-#include <TFile.h>
-#include <TKey.h>
-#include <TH2S.h>
-#include <TObject.h>
-#include <TMath.h>
-#include <TSystem.h>
+#include "TFile.h"
+#include "TKey.h"
+#include "TH2S.h"
+#include "TObject.h"
+#include "TMath.h"
+#include "TSystem.h"
 #include "TROOT.h"
 #include "TPluginManager.h"
 #include "TSAXParser.h"
+#include "TTree.h"
 
 /* Main routine
       Arguments: 
       1- monitoring data source
 */
-int main(int argc, char **argv) {
-
+int 
+main(int argc, char **argv) 
+{
+  
   /* magic line from Rene */
   gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
-                    "*",
-                    "TStreamerInfo",
-                    "RIO",
-                    "TStreamerInfo()");
-
-  AliTOFGeometry * geom = new AliTOFGeometry();
-
-  static const Int_t size = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
-  static const Int_t nbins = 500;
-  static const Int_t binmin = -20;
-  const Float_t c = 2.99792458E10; //speed of light [cm/s]
-  TH1F::AddDirectory(0);
-  TH2S * htofPartial = new TH2S("htof","histo with delays",
-                               size,-0.5,size*1.-0.5,
-                               nbins,binmin-0.5,nbins*1.+binmin-0.5);
+                                       "*",
+                                       "TStreamerInfo",
+                                       "RIO",
+                                       "TStreamerInfo()");
   
-  int status;
 
   /* log start of process */
   printf("TOF DA started\n");  
-
+  
   /* check that we got some arguments = list of files */
   if (argc!=2) {
     printf("Wrong number of arguments\n");
     return -1;
   }
 
+  /*
+   * CONFIG
+   */
+  
   /* retrieve config file */
   int getConfigFile = daqDA_DB_getFile("TOFPhysicsConfig.xml","TOFPhysicsConfig.xml");
   if (getConfigFile != 0){
     printf("Failed to retrieve config file from DB! returning...\n");
     return -1;
   }
-
+  /* parse config file */
   AliTOFDaConfigHandler* tofHandler = new AliTOFDaConfigHandler();
   TSAXParser *parser = new TSAXParser();
   parser->ConnectToHandler("AliTOFDaConfigHandler", tofHandler);  
@@ -95,300 +92,228 @@ int main(int argc, char **argv) {
     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 T0 flag is %i\n\n",t0Flag);
-  if (t0Flag) {
-         printf("The T0 time will be subtracted from the measured TOF time. So, in TDC bins: \n");
-         printf("tof = tofRaw - (rawReaderT0->GetData(51,0)+rawReaderT0->GetData(52,0))/2) \n\n");
+  /* setup config params */
+  Int_t meanMultiplicity = tofHandler->GetMeanMultiplicity(); /* average expected TOF multiplicity */
+  Int_t maxHits = tofHandler->GetMaxHits(); /* max number of hits to be collected */
+  printf("current settings:\n");
+  printf(" - meanMultiplicity = %d\n", meanMultiplicity);
+  printf(" - maxHits          = %d\n", maxHits);
+  /* constants */
+  const Int_t nChannels = 157248;
+  Int_t noiseCheckTrigger = 10; /* first noise check after 10 events */
+        Float_t meanChannelRate = (Float_t)meanMultiplicity / (Float_t)nChannels; /* average expected channel rate (hits/event) */
+  Float_t noiseThreshold = 10. * meanChannelRate; /* noise threshold (hits/event) */
+  Int_t minNoiseHits = 10; /* min number of channel hits to check noise */
+  /* counters and flags */
+  Int_t nEvents, totHits;
+  Int_t nChHits[nChannels];
+  Bool_t noiseFlag[nChannels];
+  /* variables */
+  Int_t nhits, ddl, slot, trm, chain, tdc, channel, indexEO, index, timebin, totbin, deltaBC, l0l1latency;
+  Float_t noiseHitThreshold;
+
+  /*
+   * INIT 
+   */
+
+  /* init counters and flags */
+  nEvents = 0;
+  totHits = 0;
+  for (Int_t ich = 0; ich < nChannels; ich++) {
+    nChHits[ich] = 0;
+    noiseFlag[ich] = 0;
   }
-  else {
-         printf("The T0 time will not be used.\n");
-         printf("tof = tofRaw \n\n");
-  }
-
-  /* init some counters */
-  int nevents_physics=0;
-  int nevents_total=0;
-
-  Int_t iev=0;
 
-  Int_t nPDBEntriesToT = 0;
-  Int_t nDBEntriesToT = 0;
-  AliTOFHitData *HitData;
-  Int_t dummy = -1;
-  Int_t Volume[5];
-  for (Int_t i=0;i<5;i++) Volume[i]=-1;
-  AliTOFRawStream *rawStreamTOF = new AliTOFRawStream();
-  AliTOFHitDataBuffer *DataBuffer;
-  AliTOFHitDataBuffer *PackedDataBuffer;
-  Int_t nDBEntries = 0;
-  Int_t nPDBEntries = 0;
+  /* TOF raw data handling */
+  AliTOFRawStream *rawStream = new AliTOFRawStream();
+  AliTOFHitDataBuffer *pdb = NULL;
+  AliTOFHitData *hit = NULL;
+  /* calib histo */
+  AliTOFcalibHisto calibHisto;
+  calibHisto.LoadCalibHisto();
   
+  /* open output file */
+  TFile *fileOut = new TFile(FILE_HITS, "RECREATE"); 
+  /* create hit field data structure */
+  AliTOFHitField *hitField = new AliTOFHitField();
+  /* create temporary tree */
+  TTree *tempTree = new TTree("tempTree", "temporary tree");
+  tempTree->Branch("hit", "AliTOFHitField", &hitField);
+  /* create output tree */
+  TTree *outTree = new TTree("hitTree", "hit tree");
+  outTree->Branch("hit", "AliTOFHitField", &hitField);
+
+  /*
+   * ONLINE MONITOR
+   */
+
+  AliLog::SetGlobalLogLevel(AliLog::kFatal);
   struct eventHeaderStruct *event;
-  eventTypeType eventT;
-
+  int ret;
   /* define data source : this is argument 1 */  
-  status=monitorSetDataSource( argv[1] );
-  if (status!=0) {
-    printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
+  ret = monitorSetDataSource(argv[1]);
+  if (ret != 0) {
+    printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(ret));
     return -1;
   }
-
   /* declare monitoring program */
-  status=monitorDeclareMp( __FILE__ );
-  if (status!=0) {
-    printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
+  ret = monitorDeclareMp("tofDA");
+  if (ret != 0) {
+    printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(ret));
     return -1;
   }
-
   /* define wait event timeout - 1s max */
   monitorSetNowait();
   monitorSetNoWaitNetworkTimeout(1000);
-  
-  /* main loop (infinite) */
-  for(;;) {
+
+  /* loop over events */
+  while (1) {
     
     /* check shutdown condition */
     if (daqDA_checkShutdown()) break;
     
+    /*
+     * NOISE CHECK
+     */
+
+    /* check number of events and check noise */
+    if (nEvents >= noiseCheckTrigger || totHits >= maxHits) {
+      noiseHitThreshold = noiseThreshold * nEvents;
+      printf("noise check triggered after %d events: threshold is %f hits\n", nEvents, noiseHitThreshold);
+      /* loop over all channels */
+      for (Int_t ich = 0; ich < nChannels; ich++) {
+       /* check */
+       if (nChHits[ich] < minNoiseHits || noiseFlag[ich] || nChHits[ich] < noiseHitThreshold) continue;
+       printf("channel %d tagged as noisy (%d hits): disabled\n", ich, nChHits[ich]);
+       noiseFlag[ich] = kTRUE;
+       totHits -= nChHits[ich];
+      } /* end of loop over all channels */
+      /* set new noise check trigger value */
+      noiseCheckTrigger *= 10;
+    } /* end of noise check */    
+
+    /* break loop when maximum number of hits exceeded */
+    if (totHits >= maxHits) {
+      printf("maximum number of hits exceeded (%d): stop hit collection\n", maxHits);
+      break;
+    }
+    
+    /*
+     * GET EVENT
+     */
+
     /* get next event (blocking call until timeout) */
-    status=monitorGetEventDynamic((void **)&event);
-    if (status==MON_ERR_EOF) {
+    ret = monitorGetEventDynamic((void **)&event);
+    if (ret == MON_ERR_EOF) {
       printf ("End of File detected\n");
       break; /* end of monitoring file has been reached */
     }
-    
-    if (status!=0) {
-      printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
+    if (ret != 0) {
+      printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(ret));
       break;
     }
-    
     /* retry if got no event */
     if (event==NULL) continue;
-
-    iev++; 
-
-   /* use event - here, just write event id to result file */
-    nevents_total++;
-    eventT=event->eventType;
-    switch (event->eventType) {
-      
-      /* START OF RUN */
-    case START_OF_RUN:
-      break;
-      /* END START OF RUN */
-      
-      /* END OF RUN */
-    case END_OF_RUN:
-      break;
-      /* END END OF RUN */
-      
-    case PHYSICS_EVENT:
-      nevents_physics++;
-      AliRawReader *rawReader = new AliRawReaderDate((void*)event);
-      //rawReader->RequireHeader(kFALSE);
-
-      //T0 event
-      Int_t meantime = 0;     
-      AliT0RawReader *rawReaderT0 = new AliT0RawReader(rawReader,kTRUE);
-      if (!rawReaderT0->Next()) {
-        printf("T0: no raw data found!\n");
-      } 
-      else {
-       /*
-        Int_t allData[105][5];
-        for (Int_t i=0; i<105; i++) {
-         allData[i][0]=rawReaderT0->GetData(i,0);
-       }
-        meantime = allData[49][0];
-       */
-        //meantime = rawReaderT0->GetData(49,0); //OLD
-        meantime = (Int_t)((rawReaderT0->GetData(51,0)+rawReaderT0->GetData(52,0))/2.); //Alla
-       if (debugFlag > 0) {
-               printf("\nT0 for the current event:\n");   // debugging purpose
-               printf("time zero = %i (TDC bin)\n", meantime);   // debugging purpose
-               printf("time zero = %f (ns)\n\n", (Float_t)(meantime)*24.4*1E-3);   // debugging purpose
-       }
-      }
-      
-      delete rawReaderT0;
-      rawReaderT0 = 0x0;
-      rawReader->Reset();
-      
-      //TOF event
-      dummy = -1;
-      for (Int_t ii=0; ii<5; ii++) Volume[ii]=-1;
-      rawStreamTOF->SetRawReader(rawReader);
-      //rawReader->ReadHeader();
-      rawStreamTOF->ResetBuffers();
-      rawStreamTOF->DecodeDDL(0, AliDAQ::NumberOfDdls("TOF") - 1,0);
-      nPDBEntriesToT = 0;
-      nDBEntriesToT = 0;
-      for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++) {
-
-       /* read decoded data */
-       DataBuffer = rawStreamTOF->GetDataBuffer(iDDL);
-       PackedDataBuffer = rawStreamTOF->GetPackedDataBuffer(iDDL);
-       
-       /* get buffer entries */
-       nDBEntries = DataBuffer->GetEntries();
-       nPDBEntries = PackedDataBuffer->GetEntries();
-       nPDBEntriesToT+=nPDBEntries;
-       nDBEntriesToT+=nDBEntries;
-
-       //for (Int_t iHit = 0; iHit < nDBEntries; iHit++) {
-       // HitData = DataBuffer->GetHit(iHit);
-         /* store volume information */
-       // rawStreamTOF->EquipmentId2VolumeId(HitData, Volume);
-       //}
-       /* reset buffer */
-       DataBuffer->Reset();
-
-       /* read data buffer hits */
-       for (Int_t iHit = 0; iHit < nPDBEntries; iHit++) {
-         HitData = PackedDataBuffer->GetHit(iHit);
-         /* add volume information */
-         HitData->SetDDLID(iDDL);
-         rawStreamTOF->EquipmentId2VolumeId(HitData, Volume);
-         if (Volume[0]==-1 ||
-             Volume[1]==-1 ||
-             Volume[2]==-1 ||
-             Volume[3]==-1 ||
-             Volume[4]==-1) continue;
-         else {
-           dummy = Volume[3];
-           Volume[3] = Volume[4];
-           Volume[4] = dummy;
-           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);
-           Float_t texp = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2])/c*1E9; //expected time in ns
-           Float_t texpBin = texp*1E3/AliTOFGeometry::TdcBinWidth(); //expected time in number of TDC bin
-           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 > 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 */
-         PackedDataBuffer->Reset();
-       }
-      }
-      //if (debugFlag) {
-      //  printf(" Packed Hit Buffer Entries = %i \n",nPDBEntriesToT); // too verbose
-      //  printf(" Hit Buffer Entries = %i \n",nDBEntriesToT); // too verbose
-      //}
-
-      delete rawReader;
-      rawReader = 0x0;
-    }
+    /* check event type */
+    if (event->eventType != PHYSICS_EVENT) continue;
+    /* increment number of events */
+    nEvents++;
     
-    /* free resources */
-    free(event);
+    /*
+     * DECODE EVENT
+     */
+
+    /* create raw reader */
+    AliRawReader *rawReader = new AliRawReaderDate((void *)event);
+    /* setup raw stream */
+    rawStream->SetRawReader(rawReader);
+    /* reset buffers */
+    rawStream->ResetBuffers();
+    /* decode */
+    rawStream->DecodeDDL(0, AliDAQ::NumberOfDdls("TOF") - 1, 0);
+
+    /*
+     * HIT MANIPULATION
+     */
+
+    /* loop over DDLs */
+    for (Int_t iddl = 0; iddl < AliDAQ::NumberOfDdls("TOF"); iddl++) {
+      /* get packed-data buffer */
+      pdb = rawStream->GetPackedDataBuffer(iddl);
+      nhits = pdb->GetEntries();
+      /* loop over hits in buffer */
+      for (Int_t ihit = 0; ihit < nhits; ihit++) {
+       /* get hit */
+       hit = pdb->GetHit(ihit);
+       /* get channel info */
+       ddl = iddl;
+       slot = hit->GetSlotID();
+       trm = slot - 3;
+       chain = hit->GetChain();
+       tdc = hit->GetTDC();
+       channel = hit->GetChan();
+       indexEO = calibHisto.GetIndexEO(ddl, trm, chain, tdc, channel);
+       index = calibHisto.GetCalibMap(AliTOFcalibHisto::kIndex, indexEO);
+       if (index < 0) continue;
+       /* check noise flag */
+       if (noiseFlag[index]) continue;
+       /* increment number of channel hits and total hits */
+       nChHits[index]++;
+       totHits++;
+       /* get signal info */
+       timebin = hit->GetTimeBin();
+       totbin = hit->GetTOTBin();
+       deltaBC = hit->GetDeltaBunchID();
+       l0l1latency = hit->GetL0L1Latency();
+       /* set hit field data */
+       hitField->SetIndex(index);
+       hitField->SetTimeBin(timebin);
+       hitField->SetTOTBin(totbin);
+       hitField->SetDeltaBC(deltaBC);
+       hitField->SetL0L1Latency(l0l1latency);
+       /* fill temp tree */
+       tempTree->Fill();
+      } /* end of loop over hits in buffer */
+    } /* end of loop over DDLs */
     
-    /* exit when last event received, no need to wait for TERM signal */
-    if (eventT==END_OF_RUN) {
-      printf("EOR event detected\n");
-      break;
-    }
-
-  }
-
-  delete rawStreamTOF;
-  rawStreamTOF = 0x0;
-
-  delete geom;
-  geom = 0x0;
-
-  //write the Run level file   
-  TFile * fileRun = new TFile (FILE_RUN,"RECREATE"); 
-  htofPartial->Write();
-  fileRun->Close();
-
-  //write the Total file
-  TH2S *htoftot = 0x0;
-  TFile * filetot = 0x0;
-  Bool_t isThere=kFALSE;
-  const char *dirname = "./";
-  TString filename = FILE_TOTAL;
-  if((gSystem->FindFile(dirname,filename))!=NULL){
-    isThere=kTRUE;
-    printf("%s found \n",FILE_TOTAL);
-  }
-  if (isThere) {
-
-    TFile * filetot1 = new TFile (FILE_TOTAL,"READ"); 
-    //look for the file
-    if (!filetot1->IsZombie()){
-      printf("updating file %s \n",FILE_TOTAL);
-      TIter next(filetot1->GetListOfKeys());
-      TKey *key;
-      //look for the histogram
-      while ((key=(TKey*)next())){
-       const char * namekey = key->GetName();
-       if (strcmp(namekey,"htoftot")==0) {
-         printf(" histo found \n");
-         htoftot = (TH2S*) filetot1->Get("htoftot");
-         htoftot->AddDirectory(0);
-         htoftot->Add(htofPartial);
-         break;
-       }
-      }
-    }
-    filetot1->Close();
-    delete filetot1;
-    filetot1=0x0;
-  }
-  else {
-    printf(" no %s file found \n",FILE_TOTAL);
-    htoftot = new TH2S(*htofPartial);
-    htoftot->SetName("htoftot");
-    htoftot->AddDirectory(0);
-  }
-
-  filetot = new TFile (FILE_TOTAL,"RECREATE");
-  filetot->cd();
-  htoftot->Write();
-  filetot->Close();
+    /* delete raw reader */
+    delete rawReader;
+    
+  } /* end of loop over events */
+
+  /* final noise check */
+  noiseHitThreshold = noiseThreshold * nEvents;
+  printf("final noise check after %d events: threshold is %f hits\n", nEvents, noiseHitThreshold);
+  /* loop over all channels */
+  for (Int_t ich = 0; ich < nChannels; ich++) {
+    /* check */
+    if (nChHits[ich] < minNoiseHits || noiseFlag[ich] || nChHits[ich] < noiseHitThreshold) continue;
+    printf("channel %d tagged as noisy (%d hits): disabled\n", ich, nChHits[ich]);
+    noiseFlag[ich] = kTRUE;
+    totHits -= nChHits[ich];
+  } /* end of loop over all channels */
   
-  delete fileRun;
-  delete filetot;
-  delete htofPartial;
-  delete htoftot;
-
-  fileRun = 0x0;
-  filetot = 0x0;
-  htofPartial = 0x0;
-  htoftot = 0x0;
-
-  /* write report */
-  printf("Run #%s, received %d physics events out of %d\n",
-        getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
-
-  status = 0;
+  /* copy hits into output tree from temp tree */
+  printf("copy hits from temporary tree into output tree\n");
+  printf("temporary tree contains %d hits\n", (Int_t)tempTree->GetEntries());
+  for (Int_t ihit = 0; ihit < tempTree->GetEntries(); ihit++) {
+    /* get entry */
+    tempTree->GetEntry(ihit);
+    /* check noise flag */
+    if (noiseFlag[hitField->GetIndex()]) continue;
+    /* fill output tree */
+    outTree->Fill();
+  } /* end of copy hits into output tree from temp tree */
+  printf("output tree contains %d hits\n", (Int_t)outTree->GetEntries());
+  
+  /* write output tree on file */
+  fileOut->cd();
+  outTree->Write();
+  fileOut->Close();
 
   /* export file to FXS */
-  if (daqDA_FES_storeFile(FILE_RUN, "RUNLevel"))
-    status=-2;
-  if (daqDA_FES_storeFile(FILE_TOTAL, "DELAYS"))
-    status=-2;
+  if (daqDA_FES_storeFile(FILE_HITS, "HITS"))
+    return -2;
 
-  return status;
+  return 0;
 }
diff --git a/TOF/TOFda.old.cxx b/TOF/TOFda.old.cxx
new file mode 100644 (file)
index 0000000..a221e79
--- /dev/null
@@ -0,0 +1,394 @@
+/*
+
+TOF DA for online calibration
+
+Contact: Chiara.Zampolli@bo.infn.it
+Link: www.bo.infn.it/~zampolli
+Run Type: PHYSICS
+DA Type: MON
+Number of events needed: depending on the run, being run-level
+Input Files: TOFdaTotal.root, to be updated if existing
+Output Files: TOFdaRun.root, TOFdaTotal.root, both to be exported to the DAQ FXS
+Trigger types used: PHYSICS_EVENT
+
+*/
+
+#define FILE_TOTAL "TOFdaTotal.root"
+#define FILE_RUN "TOFdaRun.root"
+
+// DATE
+#include "event.h"
+#include "monitor.h"
+#include "daqDA.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+//AliRoot
+#include <AliTOFRawStream.h>
+#include <AliRawReaderDate.h>
+#include <AliRawReader.h>
+#include <AliTOFGeometry.h>
+#include <AliT0RawReader.h>
+#include <AliDAQ.h>
+#include <AliTOFHitData.h>
+#include <AliTOFHitDataBuffer.h>
+#include <AliTOFDaConfigHandler.h>
+
+//ROOT
+#include <TFile.h>
+#include <TKey.h>
+#include <TH2S.h>
+#include <TObject.h>
+#include <TMath.h>
+#include <TSystem.h>
+#include "TROOT.h"
+#include "TPluginManager.h"
+#include "TSAXParser.h"
+
+/* Main routine
+      Arguments: 
+      1- monitoring data source
+*/
+int main(int argc, char **argv) {
+
+  /* magic line from Rene */
+  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
+                    "*",
+                    "TStreamerInfo",
+                    "RIO",
+                    "TStreamerInfo()");
+
+  AliTOFGeometry * geom = new AliTOFGeometry();
+
+  static const Int_t size = AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors();
+  static const Int_t nbins = 500;
+  static const Int_t binmin = -20;
+  const Float_t c = 2.99792458E10; //speed of light [cm/s]
+  TH1F::AddDirectory(0);
+  TH2S * htofPartial = new TH2S("htof","histo with delays",
+                               size,-0.5,size*1.-0.5,
+                               nbins,binmin-0.5,nbins*1.+binmin-0.5);
+  
+  int status;
+
+  /* log start of process */
+  printf("TOF DA started\n");  
+
+  /* check that we got some arguments = list of files */
+  if (argc!=2) {
+    printf("Wrong number of arguments\n");
+    return -1;
+  }
+
+  /* retrieve config file */
+  int getConfigFile = daqDA_DB_getFile("TOFPhysicsConfig.xml","TOFPhysicsConfig.xml");
+  if (getConfigFile != 0){
+    printf("Failed to retrieve config file from DB! returning...\n");
+    return -1;
+  }
+
+  AliTOFDaConfigHandler* tofHandler = new AliTOFDaConfigHandler();
+  TSAXParser *parser = new TSAXParser();
+  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 T0 flag is %i\n\n",t0Flag);
+  if (t0Flag) {
+         printf("The T0 time will be subtracted from the measured TOF time. So, in TDC bins: \n");
+         printf("tof = tofRaw - (rawReaderT0->GetData(51,0)+rawReaderT0->GetData(52,0))/2) \n\n");
+  }
+  else {
+         printf("The T0 time will not be used.\n");
+         printf("tof = tofRaw \n\n");
+  }
+
+  /* init some counters */
+  int nevents_physics=0;
+  int nevents_total=0;
+
+  Int_t iev=0;
+
+  Int_t nPDBEntriesToT = 0;
+  Int_t nDBEntriesToT = 0;
+  AliTOFHitData *HitData;
+  Int_t dummy = -1;
+  Int_t Volume[5];
+  for (Int_t i=0;i<5;i++) Volume[i]=-1;
+  AliTOFRawStream *rawStreamTOF = new AliTOFRawStream();
+  AliTOFHitDataBuffer *DataBuffer;
+  AliTOFHitDataBuffer *PackedDataBuffer;
+  Int_t nDBEntries = 0;
+  Int_t nPDBEntries = 0;
+  
+  struct eventHeaderStruct *event;
+  eventTypeType eventT;
+
+  /* define data source : this is argument 1 */  
+  status=monitorSetDataSource( argv[1] );
+  if (status!=0) {
+    printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
+    return -1;
+  }
+
+  /* declare monitoring program */
+  status=monitorDeclareMp( __FILE__ );
+  if (status!=0) {
+    printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
+    return -1;
+  }
+
+  /* define wait event timeout - 1s max */
+  monitorSetNowait();
+  monitorSetNoWaitNetworkTimeout(1000);
+  
+  /* main loop (infinite) */
+  for(;;) {
+    
+    /* check shutdown condition */
+    if (daqDA_checkShutdown()) break;
+    
+    /* get next event (blocking call until timeout) */
+    status=monitorGetEventDynamic((void **)&event);
+    if (status==MON_ERR_EOF) {
+      printf ("End of File detected\n");
+      break; /* end of monitoring file has been reached */
+    }
+    
+    if (status!=0) {
+      printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
+      break;
+    }
+    
+    /* retry if got no event */
+    if (event==NULL) continue;
+
+    iev++; 
+
+   /* use event - here, just write event id to result file */
+    nevents_total++;
+    eventT=event->eventType;
+    switch (event->eventType) {
+      
+      /* START OF RUN */
+    case START_OF_RUN:
+      break;
+      /* END START OF RUN */
+      
+      /* END OF RUN */
+    case END_OF_RUN:
+      break;
+      /* END END OF RUN */
+      
+    case PHYSICS_EVENT:
+      nevents_physics++;
+      AliRawReader *rawReader = new AliRawReaderDate((void*)event);
+      //rawReader->RequireHeader(kFALSE);
+
+      //T0 event
+      Int_t meantime = 0;     
+      AliT0RawReader *rawReaderT0 = new AliT0RawReader(rawReader,kTRUE);
+      if (!rawReaderT0->Next()) {
+        printf("T0: no raw data found!\n");
+      } 
+      else {
+       /*
+        Int_t allData[105][5];
+        for (Int_t i=0; i<105; i++) {
+         allData[i][0]=rawReaderT0->GetData(i,0);
+       }
+        meantime = allData[49][0];
+       */
+        //meantime = rawReaderT0->GetData(49,0); //OLD
+        meantime = (Int_t)((rawReaderT0->GetData(51,0)+rawReaderT0->GetData(52,0))/2.); //Alla
+       if (debugFlag > 0) {
+               printf("\nT0 for the current event:\n");   // debugging purpose
+               printf("time zero = %i (TDC bin)\n", meantime);   // debugging purpose
+               printf("time zero = %f (ns)\n\n", (Float_t)(meantime)*24.4*1E-3);   // debugging purpose
+       }
+      }
+      
+      delete rawReaderT0;
+      rawReaderT0 = 0x0;
+      rawReader->Reset();
+      
+      //TOF event
+      dummy = -1;
+      for (Int_t ii=0; ii<5; ii++) Volume[ii]=-1;
+      rawStreamTOF->SetRawReader(rawReader);
+      //rawReader->ReadHeader();
+      rawStreamTOF->ResetBuffers();
+      rawStreamTOF->DecodeDDL(0, AliDAQ::NumberOfDdls("TOF") - 1,0);
+      nPDBEntriesToT = 0;
+      nDBEntriesToT = 0;
+      for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++) {
+
+       /* read decoded data */
+       DataBuffer = rawStreamTOF->GetDataBuffer(iDDL);
+       PackedDataBuffer = rawStreamTOF->GetPackedDataBuffer(iDDL);
+       
+       /* get buffer entries */
+       nDBEntries = DataBuffer->GetEntries();
+       nPDBEntries = PackedDataBuffer->GetEntries();
+       nPDBEntriesToT+=nPDBEntries;
+       nDBEntriesToT+=nDBEntries;
+
+       //for (Int_t iHit = 0; iHit < nDBEntries; iHit++) {
+       // HitData = DataBuffer->GetHit(iHit);
+         /* store volume information */
+       // rawStreamTOF->EquipmentId2VolumeId(HitData, Volume);
+       //}
+       /* reset buffer */
+       DataBuffer->Reset();
+
+       /* read data buffer hits */
+       for (Int_t iHit = 0; iHit < nPDBEntries; iHit++) {
+         HitData = PackedDataBuffer->GetHit(iHit);
+         /* add volume information */
+         HitData->SetDDLID(iDDL);
+         rawStreamTOF->EquipmentId2VolumeId(HitData, Volume);
+         if (Volume[0]==-1 ||
+             Volume[1]==-1 ||
+             Volume[2]==-1 ||
+             Volume[3]==-1 ||
+             Volume[4]==-1) continue;
+         else {
+           dummy = Volume[3];
+           Volume[3] = Volume[4];
+           Volume[4] = dummy;
+           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);
+           Float_t texp = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2])/c*1E9; //expected time in ns
+           Float_t texpBin = texp*1E3/AliTOFGeometry::TdcBinWidth(); //expected time in number of TDC bin
+           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 > 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 */
+         PackedDataBuffer->Reset();
+       }
+      }
+      //if (debugFlag) {
+      //  printf(" Packed Hit Buffer Entries = %i \n",nPDBEntriesToT); // too verbose
+      //  printf(" Hit Buffer Entries = %i \n",nDBEntriesToT); // too verbose
+      //}
+
+      delete rawReader;
+      rawReader = 0x0;
+    }
+    
+    /* free resources */
+    free(event);
+    
+    /* exit when last event received, no need to wait for TERM signal */
+    if (eventT==END_OF_RUN) {
+      printf("EOR event detected\n");
+      break;
+    }
+
+  }
+
+  delete rawStreamTOF;
+  rawStreamTOF = 0x0;
+
+  delete geom;
+  geom = 0x0;
+
+  //write the Run level file   
+  TFile * fileRun = new TFile (FILE_RUN,"RECREATE"); 
+  htofPartial->Write();
+  fileRun->Close();
+
+  //write the Total file
+  TH2S *htoftot = 0x0;
+  TFile * filetot = 0x0;
+  Bool_t isThere=kFALSE;
+  const char *dirname = "./";
+  TString filename = FILE_TOTAL;
+  if((gSystem->FindFile(dirname,filename))!=NULL){
+    isThere=kTRUE;
+    printf("%s found \n",FILE_TOTAL);
+  }
+  if (isThere) {
+
+    TFile * filetot1 = new TFile (FILE_TOTAL,"READ"); 
+    //look for the file
+    if (!filetot1->IsZombie()){
+      printf("updating file %s \n",FILE_TOTAL);
+      TIter next(filetot1->GetListOfKeys());
+      TKey *key;
+      //look for the histogram
+      while ((key=(TKey*)next())){
+       const char * namekey = key->GetName();
+       if (strcmp(namekey,"htoftot")==0) {
+         printf(" histo found \n");
+         htoftot = (TH2S*) filetot1->Get("htoftot");
+         htoftot->AddDirectory(0);
+         htoftot->Add(htofPartial);
+         break;
+       }
+      }
+    }
+    filetot1->Close();
+    delete filetot1;
+    filetot1=0x0;
+  }
+  else {
+    printf(" no %s file found \n",FILE_TOTAL);
+    htoftot = new TH2S(*htofPartial);
+    htoftot->SetName("htoftot");
+    htoftot->AddDirectory(0);
+  }
+
+  filetot = new TFile (FILE_TOTAL,"RECREATE");
+  filetot->cd();
+  htoftot->Write();
+  filetot->Close();
+  
+  delete fileRun;
+  delete filetot;
+  delete htofPartial;
+  delete htoftot;
+
+  fileRun = 0x0;
+  filetot = 0x0;
+  htofPartial = 0x0;
+  htoftot = 0x0;
+
+  /* write report */
+  printf("Run #%s, received %d physics events out of %d\n",
+        getenv("DATE_RUN_NUMBER"),nevents_physics,nevents_total);
+
+  status = 0;
+
+  /* export file to FXS */
+  if (daqDA_FES_storeFile(FILE_RUN, "RUNLevel"))
+    status=-2;
+  if (daqDA_FES_storeFile(FILE_TOTAL, "DELAYS"))
+    status=-2;
+
+  return status;
+}
index 1ab7bf3484e340c4aef1b1b19073f74d3f66cb5b..dc81d75aa7686aa2755393143dfb04cef06faf88 100644 (file)
Binary files a/TOF/data/AliTOFcalibPar.root and b/TOF/data/AliTOFcalibPar.root differ
index f43673a686e8a1e793232e83a77329620ca55c25..295868aa7ca18384ba58f609f83f37bd0e43fa53 100644 (file)
@@ -8,6 +8,7 @@ SRCS  = AliTOFGeometry.cxx  \
         AliTOFrawData.cxx\
         AliTOFRawStream.cxx\
         AliTOFHitData.cxx\
+       AliTOFHitField.cxx\
         AliTOFHitDataBuffer.cxx\
         AliTOFDecoder.cxx\
        AliTOFChannelOffline.cxx  \
@@ -31,6 +32,7 @@ SRCS  = AliTOFGeometry.cxx  \
        AliTOFDeltaBCOffset.cxx \
        AliTOFCTPLatency.cxx \
        AliTOFT0Fill.cxx \
+       AliTOFT0FillOnlineCalib.cxx \
        AliTOFLvHvDataPoints.cxx \
        AliTOFDCSmaps.cxx