Add classes for TOF Calibration (C.Zampolli)
authorarcelli <arcelli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Feb 2006 16:10:48 +0000 (16:10 +0000)
committerarcelli <arcelli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Feb 2006 16:10:48 +0000 (16:10 +0000)
31 files changed:
TOF/AliTOFCal.cxx [new file with mode: 0644]
TOF/AliTOFCal.h [new file with mode: 0644]
TOF/AliTOFCalPadZ.cxx [new file with mode: 0644]
TOF/AliTOFCalPadZ.h [new file with mode: 0644]
TOF/AliTOFCalPlateA.cxx [new file with mode: 0644]
TOF/AliTOFCalPlateA.h [new file with mode: 0644]
TOF/AliTOFCalPlateB.cxx [new file with mode: 0644]
TOF/AliTOFCalPlateB.h [new file with mode: 0644]
TOF/AliTOFCalPlateC.cxx [new file with mode: 0644]
TOF/AliTOFCalPlateC.h [new file with mode: 0644]
TOF/AliTOFCalSector.cxx [new file with mode: 0644]
TOF/AliTOFCalSector.h [new file with mode: 0644]
TOF/AliTOFCalStrip.cxx [new file with mode: 0644]
TOF/AliTOFCalStrip.h [new file with mode: 0644]
TOF/AliTOFChSim.cxx [new file with mode: 0644]
TOF/AliTOFChSim.h [new file with mode: 0644]
TOF/AliTOFChannel.cxx [new file with mode: 0644]
TOF/AliTOFChannel.h [new file with mode: 0644]
TOF/AliTOFClusterFinder.cxx
TOF/AliTOFDigitizer.cxx
TOF/AliTOFDigitizer.h
TOF/AliTOFcalib.cxx [new file with mode: 0644]
TOF/AliTOFcalib.h [new file with mode: 0644]
TOF/AliTOFcalibESD.cxx [new file with mode: 0644]
TOF/AliTOFcalibESD.h [new file with mode: 0644]
TOF/AliTOFcluster.cxx
TOF/AliTOFcluster.h
TOF/AliTOFdigit.cxx
TOF/AliTOFdigit.h
TOF/TOFsimLinkDef.h
TOF/libTOFsim.pkg

diff --git a/TOF/AliTOFCal.cxx b/TOF/AliTOFCal.cxx
new file mode 100644 (file)
index 0000000..2ea4612
--- /dev/null
@@ -0,0 +1,93 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration : array of AliTOFChannels                       //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFCalSector.h"
+#include "AliTOFCal.h"
+#include "AliTOFChannel.h"
+
+extern TROOT *gROOT;
+
+ClassImp(AliTOFCal)
+
+//________________________________________________________________
+
+AliTOFCal::AliTOFCal():TObject(){
+  // fCalp = 0;
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNStripC = 20;
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+  fnpad = 0;
+  fPads = 0x0;
+  gROOT->GetListOfBrowsables()->Add(this);
+}
+//________________________________________________________________
+
+AliTOFCal::AliTOFCal(const AliTOFCal& cal):
+  TObject(cal)
+  {
+    fNSector = cal.fNSector;
+    fNPlate = cal.fNPlate;
+    fNStripA = cal.fNStripA;
+    fNStripB = cal.fNStripB;
+    fNStripC = cal.fNStripC;
+    fNpadZ = cal.fNpadZ;
+    fNpadX = cal.fNpadX;
+    fnpad = cal.fnpad;
+    for (Int_t i = 0; i<fnpad; i++){
+      fPads[i]=cal.fPads[i];
+    }
+    gROOT->GetListOfBrowsables()->Add(this);
+  }
+//____________________________________________________________________________ 
+AliTOFCal::~AliTOFCal()
+{
+  delete [] fPads;
+}
+//________________________________________________________________
+
+void AliTOFCal::Browse(TBrowser *b)
+{
+  char name[10];
+  for(Int_t i=0; i<fNSector; ++i) {
+    snprintf(name,sizeof(name),"Sector %2.2d",i);
+    b->Add(new AliTOFCalSector(&fPads[i*fnpad/fNSector]),name);
+  }
+}
+//________________________________________________________________
+
+void AliTOFCal::CreateArray(){
+  fnpad = AliTOFGeometryV4::NSectors()*(2*(20+AliTOFGeometryV4::NStripB())+AliTOFGeometryV4::NStripA())*AliTOFGeometryV4::NpadZ()*AliTOFGeometryV4::NpadX();
+  fPads= new AliTOFChannel[fnpad];
+}
diff --git a/TOF/AliTOFCal.h b/TOF/AliTOFCal.h
new file mode 100644 (file)
index 0000000..061066d
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef ALITOFCAL_H
+#define ALITOFCAL_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//     class for TOF calibration:: array of AliTOFChannels      //
+//////////////////////////////////////////////////////////////////
+
+//_____________________________________________________________
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+
+
+class AliTOFCal: public TObject 
+{
+ public:
+  AliTOFCal();
+  AliTOFCal(const AliTOFCal& cal);
+  virtual ~AliTOFCal();
+  void Browse(TBrowser *b);
+  Bool_t IsFolder() const{return kTRUE;}
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  Int_t NPads()const {return fnpad;}
+ //void PlotPad(Int_t n) {} // *MENU*
+  AliTOFChannel* GetChannel(Int_t i) {return &fPads[i];}
+  AliTOFChannel* GetArray() {return fPads;}
+  void CreateArray();
+private:
+
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF platess
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+  Int_t fnpad;     // number of TOF channels
+
+  AliTOFChannel* fPads;  //[fnpad]  
+                         // array of AliTOFChannels storing the calib parameters
+  ClassDef(AliTOFCal,1)
+};
+
+#endif
+
+
diff --git a/TOF/AliTOFCalPadZ.cxx b/TOF/AliTOFCalPadZ.cxx
new file mode 100644 (file)
index 0000000..f997707
--- /dev/null
@@ -0,0 +1,80 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration : PadZ                                          //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+#include "AliTOFCalPadZ.h"
+
+ClassImp(AliTOFCalPadZ)
+
+//________________________________________________________________
+
+AliTOFCalPadZ::AliTOFCalPadZ(){
+  fCh = 0;
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+
+}
+//________________________________________________________________
+
+AliTOFCalPadZ::AliTOFCalPadZ(AliTOFChannel *ch):
+  fCh(ch)
+{  
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNStripC = 20;
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+
+}
+//________________________________________________________________
+
+AliTOFCalPadZ::~AliTOFCalPadZ()
+  {
+    delete[] fCh;
+  }
+//________________________________________________________________
+
+void AliTOFCalPadZ::Browse(TBrowser *b)
+{
+  char name[10];
+  for(Int_t i=0; i<fNpadX; ++i) {
+    snprintf(name,sizeof(name),"PadX %2.2d",i);
+    b->Add(new AliTOFChannel(fCh[i]),name);
+  }
+}
diff --git a/TOF/AliTOFCalPadZ.h b/TOF/AliTOFCalPadZ.h
new file mode 100644 (file)
index 0000000..4d62b7b
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef ALITOFCALPADZ_H
+#define ALITOFCALPADZ_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//              class for TOF calibration:: PadZ                //
+//////////////////////////////////////////////////////////////////
+
+//_____________________________________________________________
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+
+
+class AliTOFCalPadZ: public TObject 
+{
+ public:
+  AliTOFCalPadZ();
+  AliTOFCalPadZ(AliTOFChannel *ch);
+  virtual ~AliTOFCalPadZ();
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  void Browse(TBrowser *b);
+  Bool_t IsFolder() const{return kTRUE;}
+private:
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF plates
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+
+  AliTOFChannel *fCh; //array of AliTOFChannel storing calib parameters
+  ClassDef(AliTOFCalPadZ,1)
+};
+
+#endif //AliTOFPadZ
+
+
diff --git a/TOF/AliTOFCalPlateA.cxx b/TOF/AliTOFCalPlateA.cxx
new file mode 100644 (file)
index 0000000..019b106
--- /dev/null
@@ -0,0 +1,96 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration : PlateA                                        //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFCalStrip.h"
+#include "AliTOFCalPlateA.h"
+#include "AliTOFChannel.h"
+
+ClassImp(AliTOFCalPlateA)
+
+//________________________________________________________________
+
+AliTOFCalPlateA::AliTOFCalPlateA(){
+  fCh = 0;
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+}
+//________________________________________________________________
+
+AliTOFCalPlateA::AliTOFCalPlateA(AliTOFChannel *ch):
+  fCh(ch)
+{
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+}
+//________________________________________________________________
+
+AliTOFCalPlateA::~AliTOFCalPlateA()
+{
+  delete[] fCh;
+}
+
+//________________________________________________________________
+
+AliTOFCalPlateA::AliTOFCalPlateA(const AliTOFCalPlateA& pl):
+  TObject(pl)
+  {
+    fCh = pl.fCh;
+    fCh = pl.fCh;
+    fNSector = pl.fNSector;
+    fNPlate = pl.fNPlate;
+    fNStripA = pl.fNStripA;
+    fNStripB = pl.fNStripB;
+    fNStripC = pl.fNStripC;
+    fNpadZ = pl.fNpadZ;
+    fNpadX = pl.fNpadX;
+
+  }
+//________________________________________________________________
+
+void AliTOFCalPlateA::Browse(TBrowser *b){
+
+  char name[10];
+  for(Int_t i=0; i<fNStripA; ++i) {
+    snprintf(name,sizeof(name),"Strip %2.2d",i);
+    b->Add(new AliTOFCalStrip(&fCh[i*fNpadZ*fNpadX]),name);
+  }
+}
diff --git a/TOF/AliTOFCalPlateA.h b/TOF/AliTOFCalPlateA.h
new file mode 100644 (file)
index 0000000..3c4845e
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef ALITOFCALPLATEA_H
+#define ALITOFCALPLATEA_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//              class for TOF calibration:: PlateA              //
+//////////////////////////////////////////////////////////////////
+
+//_____________________________________________________________
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+
+class AliTOFCalPlateA: public TObject 
+{
+ public:
+  AliTOFCalPlateA();
+  AliTOFCalPlateA(AliTOFChannel *ch);
+  AliTOFCalPlateA(const AliTOFCalPlateA& pl);
+  virtual ~AliTOFCalPlateA();
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  void Browse(TBrowser *b);
+  Bool_t IsFolder() const{return kTRUE;}
+private:
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF plates
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+
+  AliTOFChannel *fCh;  //array of AliTOFChannel storing calib parameters
+  ClassDef(AliTOFCalPlateA,1)
+};
+
+#endif
+
+
diff --git a/TOF/AliTOFCalPlateB.cxx b/TOF/AliTOFCalPlateB.cxx
new file mode 100644 (file)
index 0000000..5486a08
--- /dev/null
@@ -0,0 +1,98 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration : PlateB                                        //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFCalStrip.h"
+#include "AliTOFCalPlateB.h"
+#include "AliTOFChannel.h"
+
+ClassImp(AliTOFCalPlateB)
+
+//________________________________________________________________
+
+AliTOFCalPlateB::AliTOFCalPlateB(){
+  fCh = 0;
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+
+}
+//________________________________________________________________
+
+AliTOFCalPlateB::AliTOFCalPlateB(AliTOFChannel *ch):
+  fCh(ch)
+{
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+}
+//________________________________________________________________
+
+AliTOFCalPlateB::~AliTOFCalPlateB()
+{
+  delete[] fCh;
+}
+
+//________________________________________________________________
+
+AliTOFCalPlateB::AliTOFCalPlateB(const AliTOFCalPlateB& pl):
+  TObject(pl)
+  {
+    fCh = pl.fCh;
+    fCh = pl.fCh;
+    fCh = pl.fCh;
+    fNSector = pl.fNSector;
+    fNPlate = pl.fNPlate;
+    fNStripA = pl.fNStripA;
+    fNStripB = pl.fNStripB;
+    fNStripC = pl.fNStripC;
+    fNpadZ = pl.fNpadZ;
+    fNpadX = pl.fNpadX;
+
+  }
+//________________________________________________________________
+
+void AliTOFCalPlateB::Browse(TBrowser *b){
+
+  char name[10];
+  for(Int_t i=0; i<fNStripB; ++i) {
+    snprintf(name,sizeof(name),"Strip %2.2d",i);
+    b->Add(new AliTOFCalStrip(&fCh[i*fNpadZ*fNpadX]),name);
+  }
+}
diff --git a/TOF/AliTOFCalPlateB.h b/TOF/AliTOFCalPlateB.h
new file mode 100644 (file)
index 0000000..5af65c4
--- /dev/null
@@ -0,0 +1,52 @@
+#ifndef ALITOFCALPLATEB_H
+#define ALITOFCALPLATEB_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//              class for TOF calibration:: PlateB              //
+//////////////////////////////////////////////////////////////////
+
+//_____________________________________________________________
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+
+
+class AliTOFCalPlateB: public TObject 
+{
+ public:
+  AliTOFCalPlateB();
+  AliTOFCalPlateB(AliTOFChannel *ch);
+  AliTOFCalPlateB(const AliTOFCalPlateB& pl);
+  virtual ~AliTOFCalPlateB();
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  void Browse(TBrowser *b);
+  Bool_t IsFolder() const{return kTRUE;}
+private:
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF plates
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+
+  AliTOFChannel *fCh;  //array of AliTOFChannel storing calib parameters
+  ClassDef(AliTOFCalPlateB,1)
+};
+
+#endif
+
+
diff --git a/TOF/AliTOFCalPlateC.cxx b/TOF/AliTOFCalPlateC.cxx
new file mode 100644 (file)
index 0000000..76de245
--- /dev/null
@@ -0,0 +1,101 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration : PlateC                                        //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFCalStrip.h"
+#include "AliTOFCalPlateC.h"
+#include "AliTOFChannel.h"
+#include <Riostream.h>
+#include <stdlib.h>
+
+ClassImp(AliTOFCalPlateC)
+
+//________________________________________________________________
+
+AliTOFCalPlateC::AliTOFCalPlateC(){
+  fCh = 0;
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+}
+//________________________________________________________________
+
+AliTOFCalPlateC::AliTOFCalPlateC(AliTOFChannel *ch):
+  fCh(ch)
+{  
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+
+}
+//________________________________________________________________
+
+AliTOFCalPlateC::~AliTOFCalPlateC()
+{
+  delete[] fCh;
+}
+
+//________________________________________________________________
+
+AliTOFCalPlateC::AliTOFCalPlateC(const AliTOFCalPlateC& pl):
+  TObject(pl)
+
+  {
+    fCh = pl.fCh;
+    fCh = pl.fCh;
+    fCh = pl.fCh;
+    fNSector = pl.fNSector;
+    fNPlate = pl.fNPlate;
+    fNStripA = pl.fNStripA;
+    fNStripB = pl.fNStripB;
+    fNStripC = pl.fNStripC;
+    fNpadZ = pl.fNpadZ;
+    fNpadX = pl.fNpadX;
+
+  }
+//________________________________________________________________
+
+void AliTOFCalPlateC::Browse(TBrowser *b){
+
+  char name[10];
+  for(Int_t i=0; i<fNStripC; ++i) {
+    snprintf(name,sizeof(name),"Strip %2.2d",i);
+    b->Add(new AliTOFCalStrip(&fCh[i*fNpadZ*fNpadX]),name);
+  }
+}
diff --git a/TOF/AliTOFCalPlateC.h b/TOF/AliTOFCalPlateC.h
new file mode 100644 (file)
index 0000000..6c3e73b
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef ALITOFCALPLATEC_H
+#define ALITOFCALPLATEC_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//              class for TOF calibration:: PlateC              //
+//////////////////////////////////////////////////////////////////
+
+//_____________________________________________________________
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+
+class AliTOFCalPlateC: public TObject 
+{
+ public:
+  AliTOFCalPlateC();
+  AliTOFCalPlateC(AliTOFChannel *ch);
+  AliTOFCalPlateC(const AliTOFCalPlateC& pl);
+  virtual ~AliTOFCalPlateC();
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  void Browse(TBrowser *b);
+  Bool_t IsFolder() const{return kTRUE;}
+private:
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF plates
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+
+  AliTOFChannel *fCh; //array of AliTOFChannel storing calib parameters
+  ClassDef(AliTOFCalPlateC,1)
+};
+
+#endif
+
+
diff --git a/TOF/AliTOFCalSector.cxx b/TOF/AliTOFCalSector.cxx
new file mode 100644 (file)
index 0000000..f7e2aeb
--- /dev/null
@@ -0,0 +1,102 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration : Sectors                                       //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFCalPlateA.h"
+#include "AliTOFCalPlateB.h"
+#include "AliTOFCalPlateC.h"
+#include "AliTOFCalSector.h"
+#include "AliTOFChannel.h"
+
+extern TROOT *gROOT;
+
+ClassImp(AliTOFCalSector)
+
+//________________________________________________________________
+
+AliTOFCalSector::AliTOFCalSector(){
+  fCh = 0;
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+  gROOT->GetListOfBrowsables()->Add(this);
+
+}
+//________________________________________________________________
+
+AliTOFCalSector::AliTOFCalSector(AliTOFChannel *ch):
+  fCh(ch)
+{
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+}
+//________________________________________________________________
+
+AliTOFCalSector::AliTOFCalSector(const AliTOFCalSector& sec):
+  TObject(sec)
+  {
+    fCh = sec.fCh;
+    fNSector = sec.fNSector;
+    fNPlate = sec.fNPlate;
+    fNStripA = sec.fNStripA;
+    fNStripB = sec.fNStripB;
+    fNStripC = sec.fNStripC;
+    fNpadZ = sec.fNpadZ;
+    fNpadX = sec.fNpadX;
+    gROOT->GetListOfBrowsables()->Add(this);
+  }
+//________________________________________________________________
+
+AliTOFCalSector::~AliTOFCalSector()
+{
+  delete[] fCh;
+}
+
+//________________________________________________________________
+
+void AliTOFCalSector::Browse(TBrowser *b){
+
+  b->Add(new AliTOFCalPlateC(fCh),        "Plate0");
+  b->Add(new AliTOFCalPlateB(&fCh[fNStripC*96]),"Plate1");
+  b->Add(new AliTOFCalPlateA(&fCh[(fNStripC+fNStripB)*fNpadZ*fNpadX]),"Plate2");
+  b->Add(new AliTOFCalPlateB(&fCh[(fNStripC+2*fNStripB)*fNpadZ*fNpadX]),"Plate3");
+  b->Add(new AliTOFCalPlateC(&fCh[2*(fNStripC+fNStripB)*fNpadZ*fNpadX]),"Plate4");
+}
diff --git a/TOF/AliTOFCalSector.h b/TOF/AliTOFCalSector.h
new file mode 100644 (file)
index 0000000..c835b0b
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef ALITOFCALSECTOR_H
+#define ALITOFCALSECTOR_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//              class for TOF calibration:: Sectors             //
+//////////////////////////////////////////////////////////////////
+
+//_____________________________________________________________
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometry.h"
+#include "AliTOFChannel.h"
+#include "AliTOFCalPlateA.h"
+#include "AliTOFCalPlateB.h"
+#include "AliTOFCalPlateC.h"
+
+
+class AliTOFCalSector: public TObject 
+{
+public:
+  AliTOFCalSector();
+  AliTOFCalSector(AliTOFChannel *ch);
+  AliTOFCalSector(const AliTOFCalSector& sec);
+  virtual ~AliTOFCalSector();
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  void Browse(TBrowser *b);
+  Bool_t IsFolder() const{return kTRUE;}
+private:
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF plates
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+
+  AliTOFChannel *fCh; //array of AliTOFChannel storing calib parameters
+  ClassDef(AliTOFCalSector,1)
+};
+
+#endif
diff --git a/TOF/AliTOFCalStrip.cxx b/TOF/AliTOFCalStrip.cxx
new file mode 100644 (file)
index 0000000..feae7b0
--- /dev/null
@@ -0,0 +1,96 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration : strips                                        //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+#include "AliTOFCalStrip.h"
+#include "AliTOFCalPadZ.h"
+
+ClassImp(AliTOFCalStrip)
+
+//________________________________________________________________
+
+AliTOFCalStrip::AliTOFCalStrip(){
+  fCh = 0;
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+}
+//________________________________________________________________
+
+AliTOFCalStrip::AliTOFCalStrip(AliTOFChannel *ch):
+  fCh(ch)
+{
+  fNSector = AliTOFGeometryV4::NSectors();
+  fNPlate = AliTOFGeometryV4::NPlates();
+  fNStripA = AliTOFGeometryV4::NStripA();
+  fNStripB = AliTOFGeometryV4::NStripB();
+  fNStripC = 20;
+  //  fNStripC = AliTOFGeometryV4::NStripC();
+  fNpadZ = AliTOFGeometryV4::NpadZ();
+  fNpadX = AliTOFGeometryV4::NpadX();
+
+}
+//________________________________________________________________
+
+AliTOFCalStrip::~AliTOFCalStrip()
+{
+  delete[] fCh;
+}
+
+//________________________________________________________________
+
+AliTOFCalStrip::AliTOFCalStrip(const AliTOFCalStrip& strip):
+  TObject(strip)
+  {
+    fCh = strip.fCh;
+    fNSector = strip.fNSector;
+    fNPlate = strip.fNPlate;
+    fNStripA = strip.fNStripA;
+    fNStripB = strip.fNStripB;
+    fNStripC = strip.fNStripC;
+    fNpadZ = strip.fNpadZ;
+    fNpadX = strip.fNpadX;
+
+  }
+//________________________________________________________________
+
+void AliTOFCalStrip::Browse(TBrowser *b){
+
+  char name[10];
+  for(Int_t i=0; i<fNpadZ; ++i) {
+    snprintf(name,sizeof(name),"PadZ %2.2d",i);
+    b->Add(new AliTOFCalPadZ(&fCh[i*fNpadX]),name);
+  }
+}
diff --git a/TOF/AliTOFCalStrip.h b/TOF/AliTOFCalStrip.h
new file mode 100644 (file)
index 0000000..b5d6f25
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef ALITOFCALSTRIP_H
+#define ALITOFCALSTRIP_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//              class for TOF calibration:: strips              //
+//////////////////////////////////////////////////////////////////
+
+//_____________________________________________________________
+
+#include "TObject.h"
+#include "TROOT.h"
+#include "TBrowser.h"
+#include "TClass.h"
+#include "AliTOFGeometryV4.h"
+#include "AliTOFChannel.h"
+
+class AliTOFCalStrip: public TObject 
+{
+ public:
+  AliTOFCalStrip();
+  AliTOFCalStrip(AliTOFChannel *ch);
+  AliTOFCalStrip(const AliTOFCalStrip& strip);
+  virtual ~AliTOFCalStrip();
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  void Browse(TBrowser *b);
+  Bool_t IsFolder() const{return kTRUE;}
+private:
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF plates
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+
+  AliTOFChannel *fCh; //array of AliTOFChannel storing calib parameters
+  ClassDef(AliTOFCalStrip,1)
+};
+
+#endif
+
+
diff --git a/TOF/AliTOFChSim.cxx b/TOF/AliTOFChSim.cxx
new file mode 100644 (file)
index 0000000..d42d8dd
--- /dev/null
@@ -0,0 +1,56 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration                                                 //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliTOFChSim.h"
+
+ClassImp(AliTOFChSim)
+
+//________________________________________________________________
+AliTOFChSim::AliTOFChSim():
+fSlewedStatus(kFALSE),
+fSpectrum(-1)
+{}
+//________________________________________________________________
+AliTOFChSim::AliTOFChSim(const AliTOFChSim& channel) :
+  TObject(channel)
+{
+// copy constructor
+  fSlewedStatus = channel.fSlewedStatus;
+  fSpectrum= channel.fSpectrum;
+}
+
+
+//________________________________________________________________
+AliTOFChSim &AliTOFChSim::operator =(const AliTOFChSim& channel)
+{
+// assignment operator
+  fSlewedStatus = channel.IsSlewed();
+  fSpectrum= channel.GetSpectrum();
+  return *this;
+}
+
+
+
+
diff --git a/TOF/AliTOFChSim.h b/TOF/AliTOFChSim.h
new file mode 100644 (file)
index 0000000..3d825c5
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef ALITOFCHSIM_H
+#define ALITOFCHSIM_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+////////////////////////////////////////////////
+//  class for TOF calibration                 //
+////////////////////////////////////////////////
+
+#include "TNamed.h"
+
+class AliTOFChSim: public TObject {
+
+public:
+  AliTOFChSim();
+  AliTOFChSim(const AliTOFChSim &chan);
+  AliTOFChSim& operator= (const AliTOFChSim &chan);
+  virtual ~AliTOFChSim(){};
+  //
+  Bool_t  IsSlewed() const {return fSlewedStatus;}
+  void    SetSlewedStatus(Bool_t status) { fSlewedStatus = status;}
+  void           SetSpectrum(Int_t ispectrum) {fSpectrum = ispectrum;}
+  Int_t   GetSpectrum() const {return fSpectrum;}
+
+private:
+  Bool_t   fSlewedStatus;  // flag for decalibration status
+  Int_t    fSpectrum;      // index of the spectrum used during decalibration
+
+  ClassDef(AliTOFChSim,1)    // TOF Sensor Calibration object
+};
+
+#endif
diff --git a/TOF/AliTOFChannel.cxx b/TOF/AliTOFChannel.cxx
new file mode 100644 (file)
index 0000000..7e50f13
--- /dev/null
@@ -0,0 +1,80 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration                                                 //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliTOFChannel.h"
+
+ClassImp(AliTOFChannel)
+
+//________________________________________________________________
+AliTOFChannel::AliTOFChannel():
+fStatus(kFALSE),
+fDelay(0)
+{
+  for(Int_t i=0;i<6;i++) fSlewPar[i]=0.;
+}
+
+//________________________________________________________________
+AliTOFChannel::AliTOFChannel(Bool_t status, Float_t delay, Float_t* slewingPar):
+fStatus(status),
+fDelay(delay)
+{
+  for(Int_t i = 0; i<6;i++) fSlewPar[i]=slewingPar[i];
+}
+
+//________________________________________________________________
+AliTOFChannel::AliTOFChannel(const AliTOFChannel& channel) :
+  TObject(channel)
+{
+// copy constructor
+
+}
+
+
+//________________________________________________________________
+AliTOFChannel &AliTOFChannel::operator =(const AliTOFChannel& channel)
+{
+// assignment operator
+  fStatus= channel.GetStatus();
+  fDelay=channel.GetDelay();
+  return *this;
+}
+
+//
+//________________________________________________________________
+//virtual AliTOFChannel::~AliTOFChannel()/
+//{
+
+//}
+//*/
+
+//________________________________________________________________
+void AliTOFChannel::SetSlewPar(Float_t* slewingPar)
+{
+  if(slewingPar) for(Int_t i = 0; i<6;i++) fSlewPar[i]=slewingPar[i];
+  else for(int t=0; t<6; t++) fSlewPar[t] = 0.;
+}
+
+
+
diff --git a/TOF/AliTOFChannel.h b/TOF/AliTOFChannel.h
new file mode 100644 (file)
index 0000000..b01eef3
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef ALITOFChannel_H
+#define ALITOFChannel_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+////////////////////////////////////////////////
+//  class for TOF calibration                 //
+////////////////////////////////////////////////
+
+#include "TNamed.h"
+
+class AliTOFChannel: public TObject {
+
+public:
+  AliTOFChannel();
+  AliTOFChannel(Bool_t status, Float_t delay, Float_t* slewingPar);
+  AliTOFChannel(const AliTOFChannel &chan);
+  AliTOFChannel& operator= (const AliTOFChannel &chan);
+  virtual ~AliTOFChannel(){};
+  Bool_t   GetStatus()         const {return fStatus;}
+  Float_t  GetDelay()          const {return fDelay;}
+  Float_t  GetSlewPar(Int_t index)     const {return fSlewPar[index];}
+  Float_t* GetSlewPar()   const {return (float*)fSlewPar;}
+  void    SetStatus(Bool_t status) {fStatus=status;}
+  void     SetDelay(Float_t val) {fDelay=val;}
+  void     SetSlewPar(Int_t index, Float_t val) {fSlewPar[index]=val;}
+  void            SetSlewPar(Float_t* SlewPar);
+
+private:
+  Bool_t   fStatus;     // Status of the channel (0:on 1:off)
+  Float_t  fDelay;     // Delay
+  Float_t  fSlewPar[6];        // Time slewing parameters
+  //
+  ClassDef(AliTOFChannel,1)    // TOF Sensor Calibration object
+};
+
+#endif
index 8d71d48..21d25bf 100644 (file)
@@ -178,6 +178,8 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
   Int_t dig[5];
   Float_t g[3];
   Double_t h[5];
+  Float_t ToT;
+  Double_t TdcND;
   for (ii=0; ii<nDigits; ii++) {
     AliTOFdigit *d = (AliTOFdigit*)digits->UncheckedAt(ii);
     dig[0]=d->GetSector();
@@ -194,8 +196,10 @@ void AliTOFClusterFinder::Digits2RecPoints(Int_t iEvent)
     h[2] = g[2];
     h[3] = d->GetTdc();
     h[4] = d->GetAdc();
+    ToT = d->GetToT();
+    TdcND = d->GetTdcND();
 
-    AliTOFcluster *tofCluster = new AliTOFcluster(h,d->GetTracks(),dig,ii);
+    AliTOFcluster *tofCluster = new AliTOFcluster(h,d->GetTracks(),dig,ii,ToT, TdcND);
     InsertCluster(tofCluster);
 
   }
@@ -482,6 +486,8 @@ void AliTOFClusterFinder::FillRecPoint()
   Double_t cylindricalPosition[5];
   Int_t trackLabels[3];
   Int_t digitIndex = -1;
+  Float_t ToT;
+  Double_t TdcND;
 
   TClonesArray &lRecPoints = *fRecPoints;
   
@@ -495,8 +501,10 @@ void AliTOFClusterFinder::FillRecPoint()
     cylindricalPosition[2] = fTofClusters[ii]->GetZ();
     cylindricalPosition[3] = fTofClusters[ii]->GetTDC();
     cylindricalPosition[4] = fTofClusters[ii]->GetADC();
+    ToT = fTofClusters[ii]->GetToT();
+    TdcND = fTofClusters[ii]->GetTDCND();
 
-    new(lRecPoints[ii]) AliTOFcluster(cylindricalPosition, trackLabels, detectorIndex, digitIndex);
+    new(lRecPoints[ii]) AliTOFcluster(cylindricalPosition, trackLabels, detectorIndex, digitIndex, ToT, TdcND);
 
     //AliInfo(Form("%3i  %3i  %f %f %f %f %f  %2i %2i %2i %1i %2i",ii,digitIndex, cylindricalPosition[2],cylindricalPosition[0],cylindricalPosition[1],cylindricalPosition[3],cylindricalPosition[4],detectorIndex[0],detectorIndex[1],detectorIndex[2],detectorIndex[3],detectorIndex[4]));
 
index 5c54a3e..660b767 100644 (file)
@@ -48,6 +48,7 @@
 #include "AliTOFdigit.h"
 #include "AliTOFSDigit.h"
 #include "AliTOFHitMap.h"
+#include "AliTOFcalib.h"
 
 ClassImp(AliTOFDigitizer)
 
@@ -172,7 +173,7 @@ void AliTOFDigitizer::Exec(Option_t* /*option*/)
 
 //---------------------------------------------------------------------
 
-void AliTOFDigitizer::CreateDigits()
+void AliTOFDigitizer::CreateDigits(Option_t *option)
 {
   // loop on sdigits container to fill the AliTOFdigit TClonesArray
   // start digitizing all the collected sdigits 
@@ -245,7 +246,11 @@ void AliTOFDigitizer::CreateDigits()
     }
     
   } // end loop on sdigits - end digitizing all collected sdigits
-
+  if(strstr(option,"DECALIB")){
+    AliTOFcalib * cal = new AliTOFcalib();
+    cal->Init();
+    cal->DecalibrateDigits(fDigits);
+  }    
 }
 
 //---------------------------------------------------------------------
index 0346432..ed27516 100644 (file)
@@ -28,7 +28,7 @@ class AliTOFDigitizer : public AliDigitizer {
   void Exec(Option_t* option=0) ;
   TClonesArray* SDigits() const {return fSDigitsArray;}
   void ReadSDigit(Int_t);
-  void CreateDigits();
+  void CreateDigits(Option_t *option="");
   
  private:
   void CollectSDigit(AliTOFSDigit * sdigit) ;
diff --git a/TOF/AliTOFcalib.cxx b/TOF/AliTOFcalib.cxx
new file mode 100644 (file)
index 0000000..2f4de78
--- /dev/null
@@ -0,0 +1,927 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration                                                 //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliTOFcalib.h"
+#include "AliRun.h"
+#include <TTask.h>
+#include <TFile.h>
+#include <TROOT.h>
+#include <TSystem.h>
+#include "AliTOF.h"
+#include "AliTOFcalibESD.h"
+#include "AliESD.h"
+#include <TObject.h>
+#include "TF1.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "AliESDtrack.h"
+#include "AliTOFChannel.h"
+#include "AliTOFChSim.h"
+#include "AliTOFGeometry.h"
+#include "AliTOFdigit.h"
+#include "TClonesArray.h"
+#include "AliTOFCal.h"
+#include "TRandom.h"
+#include "AliTOFcluster.h"
+#include "TList.h"
+#include "AliCDBManager.h"
+#include "AliCDBMetaData.h"
+#include "AliCDBStorage.h"
+#include "AliCDBId.h"
+#include "AliCDBEntry.h"
+
+extern TROOT *gROOT;
+extern TStyle *gStyle;
+
+ClassImp(AliTOFcalib)
+
+const Int_t AliTOFcalib::fgkchannel = 5000;
+const Char_t* AliTOFcalib::ffile[6]={"$ALICE_ROOT/TOF/Spectra/spectrum0_1.root","$ALICE_ROOT/TOF/Spectra/spectrum0_2.root","$ALICE_ROOT/TOF/Spectra/spectrum1_1.root","$ALICE_ROOT/TOF/Spectra/spectrum1_2.root","$ALICE_ROOT/TOF/Spectra/spectrum2_1.root","$ALICE_ROOT/TOF/Spectra/spectrum2_2.root"};
+//_______________________________________________________________________
+AliTOFcalib::AliTOFcalib():TTask("AliTOFcalib",""){ 
+  fNSector = 0;
+  fNPlate  = 0;
+  fNStripA = 0;
+  fNStripB = 0;
+  fNStripC = 0;
+  fNpadZ = 0;
+  fNpadX = 0;
+  fsize = 0; 
+  fArrayToT = 0x0;
+  fArrayTime = 0x0;
+  flistFunc = 0x0;
+  fTOFCal = 0x0;
+  fESDsel = 0x0;
+  for (Int_t i = 0;i<6;i++){
+    fhToT[i]=0x0;
+  }
+  fGeom=0x0; 
+}
+//____________________________________________________________________________ 
+
+AliTOFcalib::AliTOFcalib(char* headerFile, Int_t nEvents):TTask("AliTOFcalib","") 
+{
+  AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");  
+  rl->CdGAFile();
+  TFile *in=(TFile*)gFile;
+  in->cd();
+  fGeom = (AliTOFGeometry*)in->Get("TOFgeometry");
+  fNSector = fGeom->NSectors();
+  fNPlate  = fGeom->NPlates();
+  fNStripA = fGeom->NStripA();
+  fNStripB = fGeom->NStripB();
+  fNStripC = fGeom->NStripC();
+  fNpadZ = fGeom->NpadZ();
+  fNpadX = fGeom->NpadX();
+  fsize = 2*(fNStripC+fNStripB) + fNStripA; 
+  for (Int_t i = 0;i<6;i++){
+    fhToT[i]=0x0;
+  }
+  fArrayToT = 0x0;
+  fArrayTime = 0x0;
+  flistFunc = 0x0;
+  fNevents=nEvents;
+  fHeadersFile=headerFile;
+  fTOFCal = 0x0;
+  fESDsel = 0x0;
+  TFile* file = (TFile*) gROOT->GetFile(fHeadersFile.Data()) ;
+  if(file == 0){
+    if(fHeadersFile.Contains("rfio"))
+      file = TFile::Open(fHeadersFile,"update") ;
+    else
+      file = new TFile(fHeadersFile.Data(),"update") ;
+    gAlice = (AliRun*)file->Get("gAlice") ;
+  }
+  
+  TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ; 
+  roottasks->Add(this) ; 
+}
+//____________________________________________________________________________ 
+
+AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):TTask("AliTOFcalib","")
+{
+  fNSector = calib.fNSector;
+  fNPlate = calib.fNPlate;
+  fNStripA = calib.fNStripA;
+  fNStripB = calib.fNStripB;
+  fNStripC = calib.fNStripC;
+  fNpadZ = calib.fNpadZ;
+  fNpadX = calib.fNpadX;
+  fsize = calib.fsize;
+  fArrayToT = calib.fArrayToT;
+  fArrayTime = calib.fArrayTime;
+  flistFunc = calib.flistFunc;
+  for (Int_t i = 0;i<6;i++){
+    fhToT[i]=calib.fhToT[i];
+  }
+  fTOFCal=calib.fTOFCal;
+  fESDsel = calib.fESDsel;
+  fGeom = calib.fGeom;
+}
+
+//____________________________________________________________________________ 
+
+AliTOFcalib::~AliTOFcalib()
+{
+  delete fArrayToT;
+  delete fArrayTime;
+  delete flistFunc;
+  delete[] fhToT; 
+  delete fTOFCal;
+  delete fESDsel;
+}
+//____________________________________________________________________________
+
+void AliTOFcalib::Init(){
+  SetHistos();
+  SetFitFunctions();
+  fTOFCal = new AliTOFCal();
+  fTOFCal->CreateArray();
+  fNSector = 18;
+  fNPlate  = 5;
+  fNStripA = 15;
+  fNStripB = 19;
+  fNStripC = 20;
+  fNpadZ = 2;
+  fNpadX = 96;
+  fsize = 1; 
+  //fsize = fNSector*(2*(fNStripC+fNStripB)+fNStripA())*fNpadZ*fNpadX; //generalized version
+}
+//____________________________________________________________________________
+
+void AliTOFcalib::SetHistos(){
+  TFile * spFile;
+  TH1F * hToT;
+  for (Int_t i =0;i<6;i++){
+    //for the time being, only one spectrum is used
+    spFile = new TFile("$ALICE_ROOT/TOF/Spectra/spectrumtest0_1.root","read");
+    //otherwise
+    //spFile = new TFile(ffile[i],"read");
+    spFile->GetObject("ToT",hToT);
+    fhToT[i]=hToT;
+    Int_t nbins = hToT->GetNbinsX();
+    Float_t Delta = hToT->GetBinWidth(1);
+    Float_t maxch = hToT->GetBinLowEdge(nbins)+Delta;
+    Float_t minch = hToT->GetBinLowEdge(1);
+    Float_t max=0,min=0; //maximum and minimum value of the distribution
+    Int_t maxbin=0,minbin=0; //maximum and minimum bin of the distribution
+    for (Int_t ii=nbins; ii>0; ii--){
+      if (hToT->GetBinContent(ii)!= 0) {
+       max = maxch - (nbins-ii-1)*Delta;
+       maxbin = ii; 
+       break;}
+    }
+    for (Int_t j=1; j<nbins; j++){
+      if (hToT->GetBinContent(j)!= 0) {
+       min = minch + (j-1)*Delta;
+       minbin = j; 
+       break;}
+    }
+    fMaxToT[i]=max;
+    fMinToT[i]=min;
+    fMaxToTDistr[i]=hToT->GetMaximum();
+  }
+}
+//__________________________________________________________________________
+
+void AliTOFcalib::SetFitFunctions(){
+  TFile * spFile;
+  flistFunc = new TList();
+  for (Int_t i =0;i<6;i++){
+    //only one type of spectrum used for the time being
+    spFile = new TFile("$ALICE_ROOT/TOF/Spectra/spectrumtest0_1.root","read");
+    //otherwise
+    //spFile = new TFile(ffile[i],"read");
+    TH1F * h = (TH1F*)spFile->Get("TimeToTFit");
+    TList * list = (TList*)h->GetListOfFunctions();
+    TF1* f = (TF1*)list->At(0);
+    Double_t par[6] = {0,0,0,0,0,0};
+    Int_t npar=f->GetNpar();
+    for (Int_t ipar=0;ipar<npar;ipar++){
+      par[ipar]=f->GetParameter(ipar);
+    }
+    flistFunc->AddLast(f);
+  }
+  return;
+}
+//__________________________________________________________________________
+
+TF1* AliTOFcalib::SetFitFunctions(TH1F *histo){
+  TF1 * fpol[3];
+  const Int_t nbins = histo->GetNbinsX();
+  Float_t Delta = histo->GetBinWidth(1);  //all the bins have the same width
+  Double_t max = histo->GetBinLowEdge(nbins)+Delta;
+  max = 15;
+  fpol[0]=new TF1("poly3","pol3",5,max);
+  fpol[1]=new TF1("poly4","pol4",5,max);
+  fpol[2]=new TF1("poly5","pol5",5,max);
+  char npoly[10];
+  Double_t chi[3]={1E6,1E6,1E6};
+  Int_t ndf[3]={-1,-1,-1};
+  Double_t Nchi[3]={1E6,1E6,1E6};
+  Double_t bestchi=1E6;
+  TF1 * fGold=0x0;
+  Int_t nonzero =0;
+  Int_t numberOfpar =0;
+  for (Int_t j=0; j<nbins; j++){
+    if (histo->GetBinContent(j)!=0) {
+      nonzero++;
+    }
+  }
+  Int_t norderfit = 0;
+  if (nonzero<=4) {
+    AliError(" Too few points in the histo. No fit performed.");
+    return 0x0;
+  }
+  else if (nonzero<=5) {
+    norderfit = 3;
+    AliInfo(" Only 3rd order polynomial fit possible.");
+  }
+  else if (nonzero<=6) {
+    norderfit = 4;
+    AliInfo(" Only 3rd and 4th order polynomial fit possible.");
+  }
+  else {
+    norderfit = 5;
+    AliInfo(" All 3rd, 4th and 5th order polynomial fit possible.");
+  }
+  for (Int_t ifun=norderfit-3;ifun<norderfit-2;ifun++){
+    sprintf(npoly,"poly%i",ifun+3);
+    histo->Fit(npoly, "ERN", " ", 5.,14.);
+    chi[ifun] = fpol[ifun]->GetChisquare();
+    ndf[ifun] = fpol[ifun]->GetNDF();
+    Nchi[ifun] = (Double_t)chi[ifun]/ndf[ifun];
+    if (Nchi[ifun]<bestchi) {
+      bestchi=Nchi[ifun];
+      fGold = fpol[ifun];
+      numberOfpar = fGold->GetNpar();
+    }
+  }
+  fGold=fpol[2];  //Gold fit function set to pol5 in any case
+  histo->Fit(fGold,"ER " ," ",5.,15.);
+  return fGold;
+}
+//____________________________________________________________________________
+
+TClonesArray* AliTOFcalib::DecalibrateDigits(TClonesArray * digits){
+
+  TObjArray ChArray(fsize);
+  ChArray.SetOwner();
+  for (Int_t kk = 0 ; kk < fsize; kk++){
+    AliTOFChSim * channel = new AliTOFChSim();
+    ChArray.Add(channel);
+  }
+  Int_t ndigits = digits->GetEntriesFast();    
+  for (Int_t i=0;i<ndigits;i++){
+    Float_t trix = 0;
+    Float_t triy = 0;
+    Float_t SimToT = 0;
+    AliTOFdigit * element = (AliTOFdigit*)digits->At(i);
+    /*
+    Int_t *detId[5];
+    detId[0] = element->GetSector();
+    detId[1] = element->GetPlate();
+    detId[2] = element->GetStrip();
+    detId[3] = element->GetPadz();
+    detId[4] = element->GetPadx();
+    Int_t index = GetIndex(detId);
+    */
+    //select the corresponding channel with its simulated ToT spectrum
+    //summing up everything, index = 0 for all channels:
+    Int_t index = 0;
+    AliTOFChSim *ch = (AliTOFChSim*)ChArray.At(index);
+    Int_t itype = -1;
+    if (!ch->IsSlewed()){
+      Double_t rand = gRandom->Uniform(0,6);
+      itype = (Int_t)(6-rand);
+      ch->SetSpectrum(itype);
+      ch->SetSlewedStatus(kTRUE);
+    }
+    else itype = ch->GetSpectrum();
+    TH1F * hToT = fhToT[itype];
+    TF1 * f = (TF1*)flistFunc->At(itype);
+    while (SimToT <= triy){
+      trix = gRandom->Rndm(i);
+      triy = gRandom->Rndm(i);
+      trix = (fMaxToT[itype]-fMinToT[itype])*trix + fMinToT[itype]; 
+      triy = fMaxToTDistr[itype]*triy;
+      Int_t binx=hToT->FindBin(trix);
+      SimToT=hToT->GetBinContent(binx);
+    }
+    
+    Float_t par[6];    
+    for(Int_t kk=0;kk<6;kk++){
+      par[kk]=0;
+    }
+    element->SetToT(trix);
+    Int_t nfpar = f->GetNpar();
+    for (Int_t kk = 0; kk< nfpar; kk++){
+      par[kk]=f->GetParameter(kk);
+    }
+    Float_t ToT = element->GetToT();
+    element->SetTdcND(element->GetTdc());
+    Float_t tdc = ((element->GetTdc())*AliTOFGeometry::TdcBinWidth()+32)*1.E-3; //tof signal in ns
+    Float_t timeoffset=par[0] + ToT*par[1] +ToT*ToT*par[2] +ToT*ToT*ToT*par[3] +ToT*ToT*ToT*ToT*par[4] +ToT*ToT*ToT*ToT*ToT*par[5]; 
+    timeoffset=0;
+    Float_t timeSlewed = tdc + timeoffset;
+    element->SetTdc((timeSlewed*1E3-32)/AliTOFGeometry::TdcBinWidth());   
+  }
+  TFile * file = new TFile("ToT.root", "recreate");
+  file->cd();
+  ChArray.Write("ToT",TObject::kSingleKey);
+  file->Close();
+  delete file;
+  ChArray.Clear();
+  return digits;
+}
+//____________________________________________________________________________
+
+void AliTOFcalib::SelectESD(AliESD *event, AliRunLoader *rl) 
+{
+  AliLoader *tofl = rl->GetLoader("TOFLoader");
+  if (tofl == 0x0) {
+    AliError("Can not get the TOF Loader");
+    delete rl;
+  }
+  tofl->LoadRecPoints("read");
+  TClonesArray *fClusters =new TClonesArray("AliTOFcluster",  1000);
+  TTree *rTree=tofl->TreeR();
+  if (rTree == 0) {
+    cerr<<"Can't get the Rec Points tree !\n";
+    delete rl;
+  }
+  TBranch *branch=rTree->GetBranch("TOF");
+  if (!branch) {
+    cerr<<"Cant' get the branch !\n";
+    delete rl;
+  }
+  branch->SetAddress(&fClusters);
+  rTree->GetEvent(0);
+  Float_t LowerMomBound=0.8; // [GeV/c] default value Pb-Pb
+  Float_t UpperMomBound=1.8 ; // [GeV/c] default value Pb-Pb
+  Int_t ntrk =0;
+  Int_t ngoodtrkfinalToT = 0;
+  ntrk=event->GetNumberOfTracks();
+  fESDsel = new TObjArray(ntrk);
+  fESDsel->SetOwner();
+  TObjArray  UCdatatemp(ntrk);
+  Int_t ngoodtrk = 0;
+  Int_t ngoodtrkfinal = 0;
+  Float_t mintime =1E6;
+  for (Int_t itrk=0; itrk<ntrk; itrk++) {
+    AliESDtrack *t=event->GetTrack(itrk);
+    //track selection: reconstrution to TOF:
+    if ((t->GetStatus()&AliESDtrack::kTOFout)==0) {
+      continue;
+    }
+    //IsStartedTimeIntegral
+    if ((t->GetStatus()&AliESDtrack::kTIME)==0) {
+      continue;
+    }
+    Double_t time=t->GetTOFsignal();   
+    time*=1.E-3; // tof given in nanoseconds
+    if(time <= mintime)mintime=time;
+    Double_t mom=t->GetP();
+    if (!(mom<=UpperMomBound && mom>=LowerMomBound))continue;
+    UInt_t AssignedTOFcluster=t->GetTOFcluster();//index of the assigned TOF cluster, >0 ?
+    if(AssignedTOFcluster==0){ // not matched
+      continue;
+    }
+    AliTOFcluster * tofcl = (AliTOFcluster *)fClusters->UncheckedAt(AssignedTOFcluster);       
+    Int_t isector = tofcl->GetDetInd(0);
+    Int_t iplate = tofcl->GetDetInd(1);
+    Int_t istrip = tofcl->GetDetInd(2);
+    Int_t ipadz = tofcl->GetDetInd(3);
+    Int_t ipadx = tofcl->GetDetInd(4);
+    Float_t ToT = tofcl->GetToT();
+    AliTOFcalibESD *unc = new AliTOFcalibESD;
+    unc->CopyFromAliESD(t);
+    unc->SetSector(isector);
+    unc->SetPlate(iplate);
+    unc->SetStrip(istrip);
+    unc->SetPadz(ipadz);
+    unc->SetPadx(ipadx);
+    unc->SetToT(ToT);
+    Double_t c1[15]; 
+    unc->GetExternalCovariance(c1);
+    UCdatatemp.Add(unc);
+    ngoodtrk++;
+  }
+  for (Int_t i = 0; i < ngoodtrk ; i ++){
+    AliTOFcalibESD *unc = (AliTOFcalibESD*)UCdatatemp.At(i);
+    if((unc->GetTOFsignal()-mintime*1.E3)<5.E3){
+      fESDsel->Add(unc);
+      ngoodtrkfinal++;
+      ngoodtrkfinalToT++;
+    }
+  }
+  fESDsel->Sort();
+}
+//_____________________________________________________________________________
+
+void AliTOFcalib::CombESDId(){
+  Float_t t0offset=0;
+  Float_t loffset=0;
+  Int_t   ntracksinset=6;
+  Float_t exptof[6][3];
+  Float_t momentum[6]={0.,0.,0.,0.,0.,0.};
+  Int_t   assparticle[6]={3,3,3,3,3,3};
+  Float_t massarray[3]={0.13957,0.493677,0.9382723};
+  Float_t timeofflight[6]={0.,0.,0.,0.,0.,0.};
+  Float_t beta[6]={0.,0.,0.,0.,0.,0.};
+  Float_t texp[6]={0.,0.,0.,0.,0.,0.};
+  Float_t sqMomError[6]={0.,0.,0.,0.,0.,0.};
+  Float_t sqTrackError[6]={0.,0.,0.,0.,0.,0.};
+  Float_t tracktoflen[6]={0.,0.,0.,0.,0.,0.};
+  Float_t TimeResolution   = 0.90e-10; // 90 ps by default     
+  Float_t timeresolutioninns=TimeResolution*(1.e+9); // convert in [ns]
+  Float_t timezero[6]={0.,0.,0.,0.,0.,0.};
+  Float_t weightedtimezero[6]={0.,0.,0.,0.,0.,0.};
+  Float_t besttimezero[6]={0.,0.,0.,0.,0.,0.};
+  Float_t bestchisquare[6]={0.,0.,0.,0.,0.,0.};
+  Float_t bestweightedtimezero[6]={0.,0.,0.,0.,0.,0.};
+  Float_t bestsqTrackError[6]={0.,0.,0.,0.,0.,0.};
+
+  Int_t nelements = fESDsel->GetEntries();
+  Int_t nset= (Int_t)(nelements/ntracksinset);
+  for (Int_t i=0; i< nset; i++) {   
+
+    AliTOFcalibESD **unc=new AliTOFcalibESD*[ntracksinset];
+    for (Int_t itrk=0; itrk<ntracksinset; itrk++) {
+      Int_t index = itrk+i*ntracksinset;
+      AliTOFcalibESD *element=(AliTOFcalibESD*)fESDsel->At(index);
+      unc[itrk]=element;
+    }
+    
+    for (Int_t j=0; j<ntracksinset; j++) {
+      AliTOFcalibESD *element=unc[j];
+      Double_t mom=element->GetP();
+      Double_t time=element->GetTOFsignal()*1.E-3; // in ns    
+      Double_t exptime[10]; 
+      element->GetIntegratedTimes(exptime);
+      Double_t toflen=element->GetIntegratedLength()/100.;  // in m
+      timeofflight[j]=time+t0offset;
+      tracktoflen[j]=toflen+loffset;
+      exptof[j][0]=exptime[2]*1.E-3+0.005;
+      exptof[j][1]=exptime[3]*1.E-3+0.005;
+      exptof[j][2]=exptime[4]*1.E-3+0.005;
+      momentum[j]=mom;
+    }
+    Float_t t0best=999.;
+    Float_t Et0best=999.;
+    Float_t chisquarebest=999.;
+    for (Int_t i1=0; i1<3;i1++) {
+      beta[0]=momentum[0]/sqrt(massarray[i1]*massarray[i1]+momentum[0]*momentum[0]);
+      texp[0]=exptof[0][i1];
+      for (Int_t i2=0; i2<3;i2++) { 
+       beta[1]=momentum[1]/sqrt(massarray[i2]*massarray[i2]+momentum[1]*momentum[1]);
+       texp[1]=exptof[1][i2];
+       for (Int_t i3=0; i3<3;i3++) {
+         beta[2]=momentum[2]/sqrt(massarray[i3]*massarray[i3]+momentum[2]*momentum[2]);
+         texp[2]=exptof[2][i3];
+         for (Int_t i4=0; i4<3;i4++) {
+           beta[3]=momentum[3]/sqrt(massarray[i4]*massarray[i4]+momentum[3]*momentum[3]);
+           texp[3]=exptof[3][i4];
+           
+           for (Int_t i5=0; i5<3;i5++) {
+             beta[4]=momentum[4]/sqrt(massarray[i5]*massarray[i5]+momentum[4]*momentum[4]);
+             texp[4]=exptof[4][i5];
+             for (Int_t i6=0; i6<3;i6++) {
+               beta[5]=momentum[5]/sqrt(massarray[i6]*massarray[i6]+momentum[5]*momentum[5]);
+               texp[5]=exptof[5][i6];
+       
+               Float_t sumAllweights=0.;
+               Float_t meantzero=0.;
+               Float_t Emeantzero=0.;
+               
+               for (Int_t itz=0; itz<ntracksinset;itz++) {
+                 sqMomError[itz]=
+                   ((1.-beta[itz]*beta[itz])*0.025)*
+                   ((1.-beta[itz]*beta[itz])*0.025)*
+                   (tracktoflen[itz]/
+                    (0.299792*beta[itz]))*
+                   (tracktoflen[itz]/
+                    (0.299792*beta[itz])); 
+                 sqTrackError[itz]=
+                   (timeresolutioninns*
+                    timeresolutioninns
+                    +sqMomError[itz]); 
+                 
+                 timezero[itz]=texp[itz]-timeofflight[itz];                
+                 weightedtimezero[itz]=timezero[itz]/sqTrackError[itz];
+                 sumAllweights+=1./sqTrackError[itz];
+                 meantzero+=weightedtimezero[itz];
+                 
+               } // end loop for (Int_t itz=0; itz<15;itz++)
+               
+               meantzero=meantzero/sumAllweights; // it is given in [ns]
+               Emeantzero=sqrt(1./sumAllweights); // it is given in [ns]
+               
+               // calculate chisquare
+               
+               Float_t chisquare=0.;           
+               for (Int_t icsq=0; icsq<ntracksinset;icsq++) {
+                 chisquare+=(timezero[icsq]-meantzero)*(timezero[icsq]-meantzero)/sqTrackError[icsq];
+               } // end loop for (Int_t icsq=0; icsq<15;icsq++) 
+               //              cout << " chisquare " << chisquare << endl;
+               
+               Int_t npion=0;
+               if(i1==0)npion++;
+               if(i2==0)npion++;
+               if(i3==0)npion++;
+               if(i4==0)npion++;
+               if(i5==0)npion++;
+               if(i6==0)npion++;
+               
+               if(chisquare<=chisquarebest  && ((Float_t) npion/ ((Float_t) ntracksinset)>0.3)){
+                 //  if(chisquare<=chisquarebest){
+                 
+                 for(Int_t iqsq = 0; iqsq<ntracksinset; iqsq++) {
+                   bestsqTrackError[iqsq]=sqTrackError[iqsq]; 
+                   besttimezero[iqsq]=timezero[iqsq]; 
+                   bestweightedtimezero[iqsq]=weightedtimezero[iqsq]; 
+                   bestchisquare[iqsq]=(timezero[iqsq]-meantzero)*(timezero[iqsq]-meantzero)/sqTrackError[iqsq]; 
+                 }
+                 
+                 assparticle[0]=i1;
+                 assparticle[1]=i2;
+                 assparticle[2]=i3;
+                 assparticle[3]=i4;
+                 assparticle[4]=i5;
+                 assparticle[5]=i6;
+                 
+                 chisquarebest=chisquare;
+                 t0best=meantzero;
+                 Et0best=Emeantzero;
+               } // close if(dummychisquare<=chisquare)
+             } // end loop on i6
+           } // end loop on i5
+         } // end loop on i4
+       } // end loop on i3
+      } // end loop on i2
+    } // end loop on i1
+
+
+    Float_t confLevel=999;
+    if(chisquarebest<999.){
+      Double_t dblechisquare=(Double_t)chisquarebest;
+      confLevel=(Float_t)TMath::Prob(dblechisquare,ntracksinset-1); 
+    }
+    // assume they are all pions for fake sets
+    if(confLevel<0.01 || confLevel==999. ){
+      for (Int_t itrk=0; itrk<ntracksinset; itrk++)assparticle[itrk]=0;
+    }
+    for (Int_t itrk=0; itrk<ntracksinset; itrk++) {
+      Int_t index = itrk+i*ntracksinset;
+      AliTOFcalibESD *element=(AliTOFcalibESD*)fESDsel->At(index);
+      element->SetCombID(assparticle[itrk]);
+    }
+  }
+}
+
+//_____________________________________________________________________________
+
+void AliTOFcalib::CalibrateESD(){
+  Int_t nelements = fESDsel->GetEntries();
+  Int_t *number=new Int_t[fsize];
+  fArrayToT = new AliTOFArray(fsize);
+  fArrayTime = new AliTOFArray(fsize);
+  for (Int_t i=0; i<fsize; i++){
+    number[i]=0;
+    fArrayToT->AddArray(i, new TArrayF(fgkchannel));
+    TArrayF * parrToT = fArrayToT->GetArray(i);
+    TArrayF & refaToT = * parrToT;
+    fArrayTime->AddArray(i, new TArrayF(fgkchannel));
+    TArrayF * parrTime = fArrayToT->GetArray(i);
+    TArrayF & refaTime = * parrTime;
+    for (Int_t j = 0;j<AliTOFcalib::fgkchannel;j++){
+      refaToT[j]=0.;      //ToT[i][j]=j;
+      refaTime[j]=0.;      //Time[i][j]=j;
+    }
+  }
+  
+  for (Int_t i=0; i< nelements; i++) {
+    AliTOFcalibESD *element=(AliTOFcalibESD*)fESDsel->At(i);
+    Int_t ipid = element->GetCombID();
+    Double_t etime = 0;   //expected time
+    Double_t expTime[10]; 
+    element->GetIntegratedTimes(expTime);
+    if (ipid == 0) etime = expTime[2]*1E-3; //ns
+    else if (ipid == 1) etime = expTime[3]*1E-3; //ns
+    else if (ipid == 2) etime = expTime[4]*1E-3; //ns
+    else AliError("No pid from combinatorial algo for this track");
+    Double_t mtime = (Double_t)element->GetTOFsignal()*1E-3;  //measured time
+    Double_t mToT = (Double_t) element->GetToT();  //measured ToT, ns
+    /*
+    Int_t *detId[5];
+    detId[0] = element->GetSector();
+    detId[1] = element->GetPlate();
+    detId[2] = element->GetStrip();
+    detId[3] = element->GetPadz();
+    detId[4] = element->GetPadx();
+    Int_t index = GetIndex(detId);
+    */
+    //select the correspondent channel with its simulated ToT spectrum
+    //summing up everything, index = 0 for all channels:
+    Int_t index = 0;
+    Int_t index2 = number[index];
+    TArrayF * parrToT = fArrayToT->GetArray(index);
+    TArrayF & refaToT = * parrToT;
+    refaToT[index2] = (Float_t)mToT;
+    TArrayF * parrTime = fArrayTime->GetArray(index);
+    TArrayF & refaTime = * parrTime;
+    refaTime[index2] = (Float_t)(mtime-etime);
+    number[index]++;
+  }
+
+  for (Int_t i=0;i<1;i++){
+    TH1F * hProf = Profile(i);
+    TF1* fGold = SetFitFunctions(hProf);
+    Int_t nfpar = fGold->GetNpar();
+    Float_t par[6];    
+    for(Int_t kk=0;kk<6;kk++){
+      par[kk]=0;
+    }
+    for (Int_t kk = 0; kk< nfpar; kk++){
+      par[kk]=fGold->GetParameter(kk);
+    }
+    AliTOFChannel * CalChannel = fTOFCal->GetChannel(i);
+    CalChannel->SetSlewPar(par);
+  }
+  delete[] number;
+}
+
+//___________________________________________________________________________
+
+TH1F* AliTOFcalib::Profile(Int_t ich){
+  const Int_t nbinToT = 650;
+  Int_t nbinTime = 400;
+  Float_t minTime = -10.5; //ns
+  Float_t maxTime = 10.5; //ns
+  Float_t minToT = 7.5; //ns
+  Float_t maxToT = 40.; //ns
+  Float_t DeltaToT = (maxToT-minToT)/nbinToT;
+  Double_t mTime[nbinToT+1],mToT[nbinToT+1],meanTime[nbinToT+1], meanTime2[nbinToT+1],ToT[nbinToT+1], ToT2[nbinToT+1],meanToT[nbinToT+1],meanToT2[nbinToT+1],Time[nbinToT+1],Time2[nbinToT+1],xlow[nbinToT+1],sigmaTime[nbinToT+1];
+  Int_t n[nbinToT+1], nentrx[nbinToT+1];
+  Double_t sigmaToT[nbinToT+1];
+  for (Int_t i = 0; i < nbinToT+1 ; i++){
+    mTime[i]=0;
+    mToT[i]=0;
+    n[i]=0;
+    meanTime[i]=0;
+    meanTime2[i]=0;
+    ToT[i]=0;
+    ToT2[i]=0;
+    meanToT[i]=0;
+    meanToT2[i]=0;
+    Time[i]=0;
+    Time2[i]=0;
+    xlow[i]=0;
+    sigmaTime[i]=0;
+    sigmaToT[i]=0;
+    n[i]=0;
+    nentrx[i]=0;
+  }
+  TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", nbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
+  TArrayF * parrToT = fArrayToT->GetArray(ich);
+  TArrayF & refaToT = * parrToT;
+  TArrayF * parrTime = fArrayTime->GetArray(ich);
+  TArrayF & refaTime = * parrTime;
+  for (Int_t j = 0; j < AliTOFcalib::fgkchannel; j++){
+    if (refaToT[j] == 0) continue; 
+    Int_t nx = (Int_t)((refaToT[j]-minToT)/DeltaToT)+1;
+    if ((refaToT[j] != 0) && (refaTime[j] != 0)){
+      Time[nx]+=refaTime[j];
+      Time2[nx]+=(refaTime[j])*(refaTime[j]);
+      ToT[nx]+=refaToT[j];
+      ToT2[nx]+=refaToT[j]*refaToT[j];
+      nentrx[nx]++;
+      hSlewing->Fill(refaToT[j],refaTime[j]);
+    }
+  }
+  Int_t nbinsToT=hSlewing->GetNbinsX();
+  if (nbinsToT != nbinToT) {
+    AliError("Profile :: incompatible numbers of bins");
+    return 0x0;
+  }
+
+  Int_t usefulBins=0;
+  TH1F *histo = new TH1F("histo", "1D Time vs ToT", nbinsToT, minToT, maxToT);
+  for (Int_t i=1;i<=nbinsToT;i++){
+    if (nentrx[i]!=0){
+    n[usefulBins]+=nentrx[i];
+    if (n[usefulBins]==0 && i == nbinsToT) {
+      break;
+    }
+    meanTime[usefulBins]+=Time[i];
+    meanTime2[usefulBins]+=Time2[i];
+    meanToT[usefulBins]+=ToT[i];
+    meanToT2[usefulBins]+=ToT2[i];
+    if (n[usefulBins]<20 && i!=nbinsToT) continue; 
+    mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins];
+    mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins];
+    sigmaTime[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
+                                  *(meanTime2[usefulBins]-meanTime[usefulBins]
+                                    *meanTime[usefulBins]/n[usefulBins]));
+    if ((1./n[usefulBins]/n[usefulBins]
+        *(meanToT2[usefulBins]-meanToT[usefulBins]
+          *meanToT[usefulBins]/n[usefulBins]))< 0) {
+      AliError(" too small radical" );
+      sigmaToT[usefulBins]=0;
+    }
+    else{       
+      sigmaToT[usefulBins]=TMath::Sqrt(1./n[usefulBins]/n[usefulBins]
+                                    *(meanToT2[usefulBins]-meanToT[usefulBins]
+                                      *meanToT[usefulBins]/n[usefulBins]));
+    }
+    usefulBins++;
+    }
+  }
+  for (Int_t i=0;i<usefulBins;i++){
+    Int_t binN = (Int_t)((mToT[i]-minToT)/DeltaToT)+1;
+    histo->Fill(mToT[i],mTime[i]);
+    histo->SetBinError(binN,sigmaTime[i]);
+  } 
+  return histo;
+}
+//_____________________________________________________________________________
+
+void AliTOFcalib::CorrectESDTime(){
+  Int_t nelements = fESDsel->GetEntries();
+  for (Int_t i=0; i< nelements; i++) {
+    AliTOFcalibESD *element=(AliTOFcalibESD*)fESDsel->At(i);
+    /*
+    Int_t *detId[5];
+    detId[0] = element->GetSector();
+    detId[1] = element->GetPlate();
+    detId[2] = element->GetStrip();
+    detId[3] = element->GetPadz();
+    detId[4] = element->GetPadx();
+    Int_t index = GetIndex(detId);
+    */
+    //select the correspondent channel with its simulated ToT spectrum
+    //summing up everything, index = 0 for all channels:
+    Int_t index = 0;
+    Int_t ipid = element->GetCombID();
+    Double_t etime = 0;   //expected time
+    Double_t expTime[10]; 
+    element->GetIntegratedTimes(expTime);
+    if (ipid == 0) etime = expTime[2]*1E-3; //ns
+    else if (ipid == 1) etime = expTime[3]*1E-3; //ns
+    else if (ipid == 2) etime = expTime[4]*1E-3; //ns
+    Float_t par[6];
+    AliTOFChannel * CalChannel = fTOFCal->GetChannel(index);
+    for (Int_t j = 0; j<6; j++){
+      par[j]=CalChannel->GetSlewPar(j);
+    }
+    //Float_t TimeCorr=par[0]+par[1]*ToT+par[2]*ToT*ToT+par[3]*ToT*ToT*ToT+par[4]*ToT*ToT*ToT*ToT+par[5]*ToT*ToT*ToT*ToT*ToT;
+  }
+}
+//_____________________________________________________________________________
+
+void AliTOFcalib::CorrectESDTime(AliESD *event, AliRunLoader *rl ){
+  AliLoader *tofl = rl->GetLoader("TOFLoader");
+  if (tofl == 0x0) {
+    AliError("Can not get the TOF Loader");
+    delete rl;
+  }
+  tofl->LoadRecPoints("read");
+  TClonesArray *fClusters =new TClonesArray("AliTOFcluster",  1000);
+  TTree *rTree=tofl->TreeR();
+  if (rTree == 0) {
+    cerr<<"Can't get the Rec Points tree !\n";
+    delete rl;
+  }
+  TBranch *branch=rTree->GetBranch("TOF");
+  if (!branch) {
+    cerr<<"Cant' get the branch !\n";
+    delete rl;
+  }
+  branch->SetAddress(&fClusters);
+  rTree->GetEvent(0);
+  Int_t ntrk =0;
+  ntrk=event->GetNumberOfTracks();
+  for (Int_t itrk=0; itrk<ntrk; itrk++) {
+    AliESDtrack *t=event->GetTrack(itrk);
+    if ((t->GetStatus()&AliESDtrack::kTOFout)==0) {
+      continue;
+    }
+    //IsStartedTimeIntegral
+    if ((t->GetStatus()&AliESDtrack::kTIME)==0) {
+      continue;
+    }
+    UInt_t AssignedTOFcluster=t->GetTOFcluster();//index of the assigned TOF cluster, >0 ?
+    if(AssignedTOFcluster==0){ // not matched
+      continue;
+    }
+    AliTOFcluster * tofcl = (AliTOFcluster *)fClusters->UncheckedAt(AssignedTOFcluster);       
+    /*
+    Int_t *detId[5];
+    detId[0] = tofcl->GetSector();
+    detId[1] = tofcl->GetPlate();
+    detId[2] = tofcl->GetStrip();
+    detId[3] = tofcl->GetPadz();
+    detId[4] = tofcl->GetPadx();
+    Int_t index = GetIndex(detId);
+    */
+    //select the correspondent channel with its simulated ToT spectrum
+    //summing up everything, index = 0 for all channels:
+    Int_t index = 0;
+    AliTOFChannel * CalChannel = fTOFCal->GetChannel(index);
+    Float_t par[6];
+    for (Int_t j = 0; j<6; j++){
+      par[j]=CalChannel->GetSlewPar(j);
+    }
+    Float_t ToT = tofcl->GetToT();
+    Float_t TimeCorr =0; 
+    TimeCorr=par[0]+par[1]*ToT+par[2]*ToT*ToT+par[3]*ToT*ToT*ToT+par[4]*ToT*ToT*ToT*ToT+par[5]*ToT*ToT*ToT*ToT*ToT;
+  }
+}
+//_____________________________________________________________________________
+
+void AliTOFcalib::WriteOnCDB(){
+  AliCDBManager *man = AliCDBManager::Instance();
+  AliCDBId id("TOF/Calib/Constants",1,100);
+  AliCDBMetaData *md = new AliCDBMetaData();
+  md->SetResponsible("Shimmize");
+  man->Put(fTOFCal,id,md);
+}
+//_____________________________________________________________________________
+
+void AliTOFcalib::ReadFromCDB(Char_t *sel, Int_t nrun){
+  AliCDBManager *man = AliCDBManager::Instance();
+  AliCDBEntry *entry = man->Get(sel,nrun);
+  if (!entry){
+    AliError("Retrivial failed");
+    AliCDBStorage *origSto =man->GetDefaultStorage();
+    man->SetDefaultStorage("local://$ALICE_ROOT");
+    entry = man->Get("TOF/Calib/Constants",nrun);
+    man->SetDefaultStorage(origSto);
+  }
+  AliTOFCal *cal =(AliTOFCal*)entry->GetObject();
+  fTOFCal = cal;
+}
+//_____________________________________________________________________________
+
+Int_t AliTOFcalib::GetIndex(Int_t *detId){
+  Int_t isector = detId[0];
+  if (isector >= fNSector)
+    AliError(Form("Wrong sector number in TOF (%d) !",isector));
+  Int_t iplate = detId[1];
+  if (iplate >= fNPlate)
+    AliError(Form("Wrong plate number in TOF (%d) !",iplate));
+  Int_t istrip = detId[2];
+  Int_t ipadz = detId[3];
+  Int_t ipadx = detId[4];
+  Int_t stripOffset = 0;
+  switch (iplate) {
+  case 0:
+    stripOffset = 0;
+    break;
+  case 1:
+    stripOffset = fNStripC;
+    break;
+  case 2:
+    stripOffset = fNStripC+fNStripB;
+    break;
+  case 3:
+    stripOffset = fNStripC+fNStripB+fNStripA;
+    break;
+  case 4:
+    stripOffset = fNStripC+fNStripB+fNStripA+fNStripB;
+    break;
+  default:
+    AliError(Form("Wrong plate number in TOF (%d) !",iplate));
+    break;
+  };
+
+  Int_t idet = ((2*(fNStripC+fNStripB)+fNStripA)*fNpadZ*fNpadX)*isector +
+               (stripOffset*fNpadZ*fNpadX)+
+               (fNpadZ*fNpadX)*istrip+
+              (fNpadX)*ipadz+
+               ipadx;
+  return idet;
+}
+
diff --git a/TOF/AliTOFcalib.h b/TOF/AliTOFcalib.h
new file mode 100644 (file)
index 0000000..4b99162
--- /dev/null
@@ -0,0 +1,116 @@
+#ifndef ALITOFCALIB_H
+#define ALITOFCALIB_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//  class for TOF calibration:: simulation of uncalibrated data //
+//////////////////////////////////////////////////////////////////
+
+#include "TTask.h"
+#include "TH1F.h"
+#include "AliTOFChannel.h"
+#include "TClonesArray.h"
+#include "TList.h"
+#include "AliTOFCal.h"
+#include "AliTOFGeometry.h"
+#include "AliESD.h"
+#include "AliRunLoader.h"
+
+class AliTOFcalib:public TTask{
+public:
+  AliTOFcalib();          // ctor
+  AliTOFcalib(char* headerFile, Int_t nEvents=0) ; 
+  AliTOFcalib(const AliTOFcalib & calib);
+  void Init();
+  virtual ~AliTOFcalib() ; // dtor
+  Int_t NSector()const {return fNSector;}
+  Int_t NPlate()const {return fNPlate;}
+  Int_t NStripA()const {return fNStripA;}
+  Int_t NStripB()const {return fNStripB;}
+  Int_t NStripC()const {return fNStripC;}
+  Int_t NpadZ()const {return fNpadZ;}
+  Int_t NpadX()const {return fNpadX;}
+  TClonesArray * DecalibrateDigits(TClonesArray *digits);
+  void SelectESD(AliESD *event, AliRunLoader * rl); 
+  void CombESDId();
+  void CalibrateESD();
+  TH1F* Profile(Int_t i); 
+  Int_t Size()const{return fsize;}
+  void SetFitFunctions();
+  TF1* SetFitFunctions(TH1F* histo);
+  TList* GetFitFunctions() {return flistFunc;}
+  TH1F** GetHistosToT() {return fhToT;}
+  void SetHistos();
+  void CorrectESDTime();
+  void CorrectESDTime(AliESD *event, AliRunLoader *rl);
+  void WriteOnCDB();
+  void ReadFromCDB(Char_t *sel, Int_t nrun);
+  Int_t GetIndex(Int_t *detId);
+
+ public: 
+  class AliTOFArray : public TObject {
+  public:
+    AliTOFArray(): TObject(),fSize(0),fArray(0x0){}
+    AliTOFArray(Int_t size) :
+      TObject(),
+      fSize(size),
+      fArray(new TArrayF*[size]) {
+    } 
+    Int_t GetSize() const {return fSize;}
+    void AddArray(Int_t pos, TArrayF * parr) {
+      if (pos>-1 && pos < fSize)
+       fArray[pos] = parr;
+      //else
+      //AliError("Index  out of range");  
+    }
+    TArrayF * GetArray(Int_t pos) {
+      TArrayF * parr = 0x0;
+      if  (pos>-1 && pos < fSize)
+       parr = fArray[pos];
+      //else
+        //AliError("Index out of range");  
+      return parr;
+    }
+    virtual ~AliTOFArray() {
+      delete [] fArray;
+    }
+    
+  private:
+    
+    Int_t fSize;       // Size of the array of TArrayFs
+    TArrayF ** fArray; //[fSize]};
+    
+  };
+
+
+private:
+  static const Int_t fgkchannel;  // max number of entries per channel 
+  static const Char_t * ffile[6]; // spectra
+  Int_t fsize;     // number of channels
+  Int_t fNSector;  // number of TOF sectors
+  Int_t fNPlate;   // number of TOF plates
+  Int_t fNStripA;  // number of TOF strips A
+  Int_t fNStripB;  // number of TOF strips B
+  Int_t fNStripC;  // number of TOF strips C
+  Int_t fNpadZ;    // number of TOF pads Z
+  Int_t fNpadX;    // number of TOF pads X
+  TObjArray * fESDsel;   // selected ESD tracks for calibration
+  TList *flistFunc;      // functions for simulated Time Slewing spectra
+  TH1F* fhToT[6];           // simulated ToT distributions
+  Float_t fMaxToT[6];       // max simulated ToT
+  Float_t fMinToT[6];       // min simulated ToT
+  Float_t fMaxToTDistr[6];  // max value in the ToT distributions
+  AliTOFArray *fArrayToT;   // array for ToT values
+  AliTOFArray *fArrayTime;  // array for Time values
+  Int_t fNevents;           // number of events
+  AliTOFCal *fTOFCal;       // array of AliTOFChannels storing calib parameters
+  TString fT0File ;         // output file;
+  TString fHeadersFile;     // input file
+  AliTOFGeometry *fGeom;    // AliTOFgeometry pointer
+  ClassDef(AliTOFcalib,1);
+};
+
+#endif // AliTOFcalib_H
+
diff --git a/TOF/AliTOFcalibESD.cxx b/TOF/AliTOFcalibESD.cxx
new file mode 100644 (file)
index 0000000..507e1f9
--- /dev/null
@@ -0,0 +1,117 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+/*$Log$
+author: Chiara Zampolli, zampolli@bo.infn.it
+ */  
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// class for TOF calibration                                                 //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliTOFcalibESD.h"
+#include <Riostream.h>
+#include <stdlib.h>
+
+
+ClassImp(AliTOFcalibESD)
+
+//________________________________________________________________
+AliTOFcalibESD::AliTOFcalibESD():
+  fToT(0),
+  fIntLen(0),
+  fTOFtime(0),
+  fP(0),
+  fSector(-1),
+  fPlate(-1),
+  fStrip(-1),
+  fPadz(-1),
+  fPadx(-1),
+  fTOFsignalND(0)
+{
+  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
+}
+//________________________________________________________________
+
+AliTOFcalibESD::AliTOFcalibESD(const AliTOFcalibESD& UnCalib):
+  AliESDtrack(UnCalib),
+  fToT(UnCalib.fToT),
+  fIntLen(UnCalib.fIntLen),
+  fTOFtime(UnCalib.fTOFtime),
+  fP(UnCalib.fP),
+  fCombID(UnCalib.fCombID),
+  fSector(UnCalib.fSector),
+  fPlate(UnCalib.fPlate),
+  fStrip(UnCalib.fStrip),
+  fPadz(UnCalib.fPadz),
+  fPadx(UnCalib.fPadx),
+  fTOFsignalND(UnCalib.fTOFsignalND)
+{
+  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = UnCalib.fTrackTime[i];
+  for (Int_t i = 0;i<15;i++) fExtCov[i] = UnCalib.fExtCov[i];
+}
+//________________________________________________________________
+
+AliTOFcalibESD::~AliTOFcalibESD()
+{
+}
+//________________________________________________________________
+
+void AliTOFcalibESD::SetIntegratedTime(const Double_t *tracktime){
+  for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = tracktime[i];
+}
+//________________________________________________________________
+
+void AliTOFcalibESD::CopyFromAliESD(const AliESDtrack* track)
+{
+  fP = track->GetP();
+  fTOFtime = track->GetTOFsignal();
+  fIntLen = track->GetIntegratedLength();
+  Double_t exptime[10]; 
+  track->GetIntegratedTimes(exptime);
+  for (Int_t i=0;i<AliPID::kSPECIES;i++) {
+    fTrackTime[i] = exptime[i];
+  }
+  Double_t c[15];
+  track->GetExternalCovariance(c);
+  for (Int_t i = 0;i<15;i++){
+    fExtCov[i] = c[i];
+  }
+}
+//______________________________________________________________________
+
+void AliTOFcalibESD::GetExternalCovariance(Double_t cov[15]) const {
+  for (Int_t i=0; i<15; i++) cov[i]=fExtCov[i];
+}
+//______________________________________________________________________
+
+void AliTOFcalibESD::GetIntegratedTimes(Double_t exp[AliPID::kSPECIES]) const {
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) exp[i]=fTrackTime[i];
+}
+//______________________________________________________________________
+
+Int_t AliTOFcalibESD::Compare(const TObject* uncobj) const{
+  Double_t c1[15]; 
+  this->GetExternalCovariance(c1);
+  Double_t c2[15]; 
+  ((AliTOFcalibESD*)uncobj)->GetExternalCovariance(c2);
+  if (c1[0]*c1[2] <c2[0]*c2[2]) return -1;
+  if (c1[0]*c1[2]>c2[0]*c2[2]) return 1;
+  return 0;
+}
+
+
diff --git a/TOF/AliTOFcalibESD.h b/TOF/AliTOFcalibESD.h
new file mode 100644 (file)
index 0000000..45862c3
--- /dev/null
@@ -0,0 +1,66 @@
+#ifndef ALITOFCALIBESD_H
+#define ALITOFCALIBESD_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//////////////////////////////////////////////////////////////////
+//  class for TOF calibration:: simulation of uncalibrated data //
+//////////////////////////////////////////////////////////////////
+
+#include "AliPID.h"
+#include "AliESDtrack.h"
+#include "TObject.h"
+
+//class AliESDtrack;
+
+class AliTOFcalibESD:public AliESDtrack{
+public:
+  AliTOFcalibESD();
+  AliTOFcalibESD(const AliTOFcalibESD& UnCalib);
+  ~AliTOFcalibESD();
+  Float_t GetToT() const{return fToT;}         //Time Over Threshold
+  Float_t GetTOFsignal() const{return fTOFtime;}
+  Float_t GetTOFsignalND() const{return fTOFsignalND;}
+  Float_t GetIntegratedLength() const{return fIntLen;}
+  void GetExternalCovariance(Double_t cov[15]) const;
+  void GetIntegratedTimes(Double_t exp[AliPID::kSPECIES]) const;
+  Int_t GetCombID()const{return fCombID;}
+  Float_t GetP()const{return fP;}
+  Int_t GetSector() const {return fSector;}
+  Int_t GetPlate() const {return fPlate;}
+  Int_t GetStrip() const {return fStrip;}
+  Int_t GetPadz() const {return fPadz;}
+  Int_t GetPadx() const {return fPadz;}
+  void SetToT(Float_t ToT) {fToT=ToT;}
+  void SetTOFtime(Float_t TOFtime) {fTOFtime=TOFtime;}
+  void SetTOFsignalND(Float_t TOFtimeND) {fTOFsignalND=TOFtimeND;}
+  void SetP(Double_t p) {fP=p;}
+  void SetIntegratedTime(const Double_t *tracktime);
+  void SetCombID(Int_t ID){fCombID = ID;} // 0->pi, 1->K, 2->p
+  void CopyFromAliESD(const AliESDtrack* track);
+  Bool_t IsSortable() const {return kTRUE;}
+  Int_t Compare(const TObject *uncobj) const;
+  void SetSector(Int_t isector) {fSector=isector;}
+  void SetPlate(Int_t iplate) {fPlate=iplate;}
+  void SetStrip(Int_t istrip) {fStrip=istrip;}
+  void SetPadz(Int_t ipadz) {fPadz=ipadz;}
+  void SetPadx(Int_t ipadx) {fPadx=ipadx;}
+private:
+  Float_t  fToT;
+  Float_t  fIntLen;
+  Float_t  fTOFtime;
+  Double_t fP;
+  Double_t fTrackTime[AliPID::kSPECIES]; // TOFs estimated by the tracking
+  Double_t fExtCov[15];
+  Int_t    fCombID; 
+  Int_t    fSector;
+  Int_t    fPlate;
+  Int_t    fStrip;
+  Int_t    fPadz;
+  Int_t    fPadx;
+  Float_t  fTOFsignalND;
+
+  ClassDef(AliTOFcalibESD,1);
+};
+#endif // AliTOFcalibESD_H
index ed0c7f2..316f480 100644 (file)
@@ -41,6 +41,8 @@ AliTOFcluster::AliTOFcluster() {
   fZ   = 0.;
   fTDC = 0.;
   fADC = 0.;
+  fToT = 0.;
+  fTdcND = 0;
   for (ii=0; ii<3; ii++) fLab[ii]      = -1;
   fIdx = -1;
   for (ii=0; ii<5; ii++) fdetIndex[ii] = -1;
@@ -48,7 +50,7 @@ AliTOFcluster::AliTOFcluster() {
 }
 //-------------------------------------------------------------------------
 
-AliTOFcluster::AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx)
+AliTOFcluster::AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx, Float_t ToT, Double_t TdcND)
 :TObject() {
   //
   // constructor
@@ -60,6 +62,8 @@ AliTOFcluster::AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx)
   fZ   = h[2];
   fTDC = h[3];
   fADC = h[4];
+  fToT = ToT;
+  fTdcND = TdcND;
   for (ii=0; ii<3; ii++) fLab[ii]      = l[ii];
   fIdx = idx;
   for (ii=0; ii<5; ii++) fdetIndex[ii] = ind[ii];
@@ -102,6 +106,8 @@ AliTOFcluster::AliTOFcluster(const AliTOFcluster & cluster)
   fIdx      = cluster.fIdx;
   for (ii=0; ii<5; ii++) fdetIndex[ii] = cluster.fdetIndex[ii];
   fQuality    = cluster.fQuality; 
+  fToT    = cluster.fToT; 
+  fTdcND    = cluster.fTdcND; 
 }
 //-------------------------------------------------------------------------
 
index 0de5bc6..d422f51 100644 (file)
@@ -13,7 +13,7 @@
 class AliTOFcluster : public TObject {
  public:
   AliTOFcluster(); // default ctor
-  AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx); // ctor
+  AliTOFcluster(Double_t *h, Int_t *l, Int_t *ind, Int_t idx, Float_t ToT, Double_t TdcND); // ctor
   AliTOFcluster(Double_t *h, Int_t *ind); // new ctor
   AliTOFcluster(const AliTOFcluster & cluster); // copy ctor
   virtual ~AliTOFcluster(); // dtor
@@ -22,7 +22,9 @@ class AliTOFcluster : public TObject {
   Double_t GetPhi() const {return fPhi;} // Cluster Phi
   Double_t GetZ()   const {return fZ;}   // Cluster Z
   Double_t GetTDC() const {return fTDC;} // Cluster ToF
+  Double_t GetTDCND() const {return fTdcND;} // Cluster ToF
   Double_t GetADC() const {return TMath::Abs(fADC);}  // Cluster Charge
+  Double_t GetToT() const {return fToT;}  // Cluster Charge
   Int_t    IsUsed() const {return (fADC<0) ? 1 : 0;}  // Flagging
   Int_t    GetLabel(Int_t n) const  {return fLab[n];} // Labels of tracks in Cluster
   Int_t    GetDetInd(Int_t n) const {return fdetIndex[n];} // Cluster Detector Indeces
@@ -30,6 +32,7 @@ class AliTOFcluster : public TObject {
   void     Use() {fADC=-fADC;}
   Double_t GetQuality() const {return fQuality;}
   void     SetQuality(Double_t quality) {fQuality = quality;}
+  void     SetToT(Float_t ToT) {fToT = ToT;}
  private:
 
   Int_t fLab[3];      // track labels
@@ -41,7 +44,10 @@ class AliTOFcluster : public TObject {
   Double_t fTDC;      // TDC count
   Double_t fADC;      // ADC count
   Double_t fQuality;  // quality of the best track 
-  ClassDef(AliTOFcluster, 1) // TOF cluster
+  Float_t  fToT;       // ToT
+  Double_t fTdcND;      // TDC count
+
+  ClassDef(AliTOFcluster, 2) // TOF cluster
 };
 
 #endif
index 7ff76ab..04d74a9 100644 (file)
@@ -54,7 +54,9 @@ AliTOFdigit::AliTOFdigit(Int_t *tracks, Int_t *vol,Float_t *digit)
   fPadx   = vol[3];
   fPadz   = vol[4];
   fTdc    = digit[0];
+  fTdcND  =0;
   fAdc    = digit[1];
+  fToT = 0;
 }
 
 //____________________________________________________________________________
@@ -74,7 +76,9 @@ AliTOFdigit::AliTOFdigit(const AliTOFdigit & digit)
   fPadx   = digit.fPadx;
   fPadz   = digit.fPadz;
   fTdc    = digit.fTdc;
+  fTdcND    = digit.fTdcND;
   fAdc    = digit.fAdc;
+  fToT = digit.fToT;
 
 }
 
@@ -91,7 +95,9 @@ Int_t padz, Float_t tdc, Float_t adc)
   fPadx   = padx;
   fPadz   = padz;  
   fTdc    = tdc;   
+  fTdcND    = 0;   
   fAdc    = adc;     
+  fToT = 0;
 }
    
 //______________________________________________________________________________
@@ -175,7 +181,9 @@ Bool_t AliTOFdigit::operator==(AliTOFdigit const &digit) const
      fPadx==digit.fPadx &&
      fPadz==digit.fPadz &&
      fTdc==digit.fTdc &&
-     fAdc==digit.fAdc) return kTRUE;
+     fTdcND==digit.fTdcND &&
+     fAdc==digit.fAdc &&
+     fToT==digit.fToT ) return kTRUE;
      else return kFALSE;
 }
 
index 11ba9c8..7bab7fa 100644 (file)
@@ -36,16 +36,20 @@ friend ostream& operator << ( ostream& , const AliTOFdigit&) ;
   void            AddTrack(Int_t track);
   // getters for AliTOFdigit object 
   Float_t GetTdc()    const     {return fTdc;}
+  Float_t GetTdcND()  const     {return fTdcND;}
   Float_t GetAdc()    const     {return fAdc;}
   Int_t   GetSector() const     {return fSector;}
   Int_t   GetPlate()  const     {return fPlate;}
   Int_t   GetStrip()  const     {return fStrip;}
   Int_t   GetPadx()   const     {return fPadx;}
   Int_t   GetPadz()   const     {return fPadz;}
+  Float_t GetToT() const{return fToT;}         //Time Over Threshold
 
   // setters for AliTOFdigit object
   void    SetTdc(Float_t TDC){fTdc = TDC;}
+  void    SetTdcND(Float_t TDCND){fTdcND = TDCND;}
   void    SetAdc(Float_t ADC){fAdc = ADC;}
+  void    SetToT(Float_t ToT) {fToT=ToT;}
 
   //overloading of ==, + operators (summable digits)
   
@@ -62,11 +66,13 @@ protected:
   Float_t fTdc;     // tdc channel value, to be multiplied by
                    // AliTOFGeometry::TdcBinWidth() to have the
                    // time-of-flight measurement
+  Float_t fTdcND;   // simulated (non slewed) time signal
   Float_t fAdc;     // adc channel value, to be multiplie by
                    // AliTOFSDigitizer::GetAdcBin() to have the
                    // 'charge' measurement
+  Float_t  fToT;    // simulated ToT
 
-  ClassDef(AliTOFdigit,2)  // Digit for Time Of Flight
+  ClassDef(AliTOFdigit,3)  // Digit for Time Of Flight
 };
 
 #endif /* ALITOFDIGIT_H */
index ccd9c59..8fc4576 100644 (file)
 #pragma link C++ class  AliTOFHitMap+;
 #pragma link C++ class  AliTOFSDigit+;
 #pragma link C++ class  AliTOFSDigitizer+;
+#pragma link C++ class  AliTOFChannel+;
+#pragma link C++ class  AliTOFChSim+;
+#pragma link C++ class  AliTOFcalibESD+;
+#pragma link C++ class  AliTOFcalib+;
+#pragma link C++ class  AliTOFCalPadZ+;
+#pragma link C++ class  AliTOFCalStrip+;
+#pragma link C++ class  AliTOFCalPlateA+;
+#pragma link C++ class  AliTOFCalPlateB+;
+#pragma link C++ class  AliTOFCalPlateC+;
+#pragma link C++ class  AliTOFCalSector+;
+#pragma link C++ class  AliTOFCal+;
 #pragma link C++ class  AliTOFDigitizer+;
 
 #pragma link C++ class  AliTOFDigitMap+;
index 087bf09..f12a938 100644 (file)
@@ -5,6 +5,13 @@ SRCS  = AliTOF.cxx  AliTOFv5T0.cxx  AliTOFv4T0.cxx  \
        AliTOFhit.cxx  AliTOFhitT0.cxx  \
        AliTOFHitMap.cxx  \
        AliTOFSDigit.cxx  AliTOFSDigitizer.cxx  \
+       AliTOFChannel.cxx  \
+       AliTOFChSim.cxx  \
+       AliTOFcalibESD.cxx AliTOFcalib.cxx \
+       AliTOFCalPadZ.cxx \
+        AliTOFCalStrip.cxx  AliTOFCalPlateA.cxx \
+       AliTOFCalPlateB.cxx AliTOFCalPlateC.cxx   AliTOFCalSector.cxx \
+       AliTOFCal.cxx \
        AliTOFDigitizer.cxx  \
        AliTOFDigitMap.cxx  \
        AliTOFDDLRawData.cxx  \