Add online gain calibration tables (Annika)
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 28 Jun 2011 20:29:02 +0000 (20:29 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 28 Jun 2011 20:29:02 +0000 (20:29 +0000)
TRD/CMakelibTRDbase.pkg
TRD/Cal/AliTRDCalOnlineGainTable.cxx [new file with mode: 0644]
TRD/Cal/AliTRDCalOnlineGainTable.h [new file with mode: 0644]
TRD/Cal/AliTRDCalOnlineGainTableMCM.cxx [new file with mode: 0644]
TRD/Cal/AliTRDCalOnlineGainTableMCM.h [new file with mode: 0644]
TRD/Cal/AliTRDCalOnlineGainTableROC.cxx [new file with mode: 0644]
TRD/Cal/AliTRDCalOnlineGainTableROC.h [new file with mode: 0644]
TRD/TRDbaseLinkDef.h

index 03b3c0fcc68976b7d6bce73dfd4d4d1a050909c5..f3b6c4240ebf7faf8a18822d64a5da811c2f3e52 100644 (file)
@@ -61,6 +61,12 @@ set ( SRCS
     Cal/AliTRDCalSingleChamberStatus.cxx
     Cal/AliTRDCalPID.cxx
     Cal/AliTRDCalTrkAttach.cxx
+    Cal/AliTRDCalOnlineGainTable.cxx
+    Cal/AliTRDCalOnlineGainTableMCM.h
+    Cal/AliTRDCalOnlineGainTable.h  
+    Cal/AliTRDCalOnlineGainTableROC.cxx
+    Cal/AliTRDCalOnlineGainTableMCM.cxx
+    Cal/AliTRDCalOnlineGainTableROC.h
     AliTRDCalibraFit.cxx
     AliTRDCalibraMode.cxx
     AliTRDCalibraVector.cxx
diff --git a/TRD/Cal/AliTRDCalOnlineGainTable.cxx b/TRD/Cal/AliTRDCalOnlineGainTable.cxx
new file mode 100644 (file)
index 0000000..6dee087
--- /dev/null
@@ -0,0 +1,275 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+#include "AliTRDCalOnlineGainTable.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Data structure to store gaintables of the online calibration in the OCDB
+// consisting of three classes:
+// AliTRDCalOnlineGainTable 
+// AliTRDCalOnlineGainTableROC 
+// AliTRDCalOnlineGainTableMCM
+//
+// AliTRDCalOnlineGainTable is the main class from which all stored data can be accessed.
+// The two sub-classes AliTRDCalOnlineGainTableROC and AliTRDCalOnlineGainTableMCM
+// contain the gaintables on ROC level and on the MCM level respectively.
+//
+// The online calibration is used to compensate gain deviations on the pad level.
+// For the offline reconstruction the online calibration has to be undone. 
+// The corresponding gain correction factor that was used by the online gain filter can be accessed 
+// via the functions AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col) 
+// and AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col).
+//
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+ClassImp(AliTRDCalOnlineGainTable);
+
+const Float_t AliTRDCalOnlineGainTable::UnDef=-999.;
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTable::AliTRDCalOnlineGainTable()
+  :TObject()
+{
+  //
+  // constructor
+  //
+
+  for (int i=0; i<540; i++) {
+    fROCGainTables[i] = 0;
+  }
+
+}
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTable::AliTRDCalOnlineGainTable(const AliTRDCalOnlineGainTable& other)
+  :TObject(other)
+{
+  //
+  // copy constructor
+  //
+
+  for (int i=0; i<540; i++) {
+    if (other.GetGainTableROC(i)) {
+      fROCGainTables[i] = new AliTRDCalOnlineGainTableROC( *(other.GetGainTableROC(i)) );
+    } else {
+      fROCGainTables[i] = 0;
+    }
+  }
+
+}
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTable& AliTRDCalOnlineGainTable::operator=(const AliTRDCalOnlineGainTable& other)
+{
+  //
+  // assignment operator
+  //
+
+  for (int i=0; i<540; i++) {
+
+    if (fROCGainTables[i]) {
+      delete fROCGainTables[i];
+    }
+
+    if (other.GetGainTableROC(i)) {
+      fROCGainTables[i] = new AliTRDCalOnlineGainTableROC( *(other.GetGainTableROC(i)) );
+    } else {
+      fROCGainTables[i] = 0;
+    }
+  }
+
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTable::~AliTRDCalOnlineGainTable()
+{
+  //
+  // destructor
+  //
+
+  for (int i=0; i<540; i++) {
+    if (fROCGainTables[i]) {
+      delete fROCGainTables[i];
+    }
+  }
+
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col)
+{
+  //
+  // returns the Gain Correction Factor of the channel
+  // given by det, row, col
+  //
+
+  AliTRDCalOnlineGainTableROC* gtbl = GetGainTableROC(det);
+
+  if (gtbl) {
+    return gtbl->GetGainCorrectionFactor(row,col);
+  } else {
+    return AliTRDCalOnlineGainTable::UnDef;
+  }
+
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, 
+                                               Int_t row, Int_t col)
+{ 
+  //
+  // returns the Gain Correction Factor of the channel
+  // given by sector, stack, layer, row, col
+  //
+
+  return GetGainCorrectionFactor(30*sector + 6*stack + layer, row, col);
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTable::GetAdcdac(Int_t det, Int_t row, Int_t col)
+{
+  //
+  // returns the ADC's reference voltage of the channel 
+  // given by det, row, col
+  //
+
+  AliTRDCalOnlineGainTableROC* gtbl = GetGainTableROC(det);
+
+  if (gtbl) {
+    return gtbl->GetAdcdac(row,col);
+  } else {
+    return -999;
+  }
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTable::GetAdcdac(Int_t sector, Int_t stack, Int_t layer, 
+                                               Int_t row, Int_t col)
+{ 
+  //
+  // returns the ADC's reference voltage of the channel 
+  // given by sector, stack, layer, row, col
+  //
+
+  return GetAdcdac(30*sector + 6*stack + layer, row, col);
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTable::GetMCMGain(Int_t det, Int_t row, Int_t col)
+{ 
+  //
+  // returns the Gain Factor which would lead to a Correction Factor of 1.0  
+  // within the MCM given by det, row, col
+  //
+
+  AliTRDCalOnlineGainTableROC* gtbl = GetGainTableROC(det);
+
+  if (gtbl) {
+    return gtbl->GetMCMGain(row,col);
+  } else {
+    return AliTRDCalOnlineGainTable::UnDef;
+  }
+
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTable::GetMCMGain(Int_t sector, Int_t stack, Int_t layer, 
+                                               Int_t row, Int_t col)
+{  
+  //
+  // returns the Gain Factor which would lead to a Correction Factor of 1.0  
+  // within the MCM given by sector, stack, layer, row, col
+  //
+
+  return GetMCMGain(30*sector + 6*stack + layer, row, col);
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTable::GetFGAN(Int_t det, Int_t row, Int_t col)
+{
+  //
+  // returns the Gain Correction Filter Additive of the channel
+  // given by det, row, col
+  //
+
+  AliTRDCalOnlineGainTableROC* gtbl = GetGainTableROC(det);
+
+  if (gtbl) {
+    return gtbl->GetFGAN(row,col);
+  } else {
+    return -999;
+  }
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTable::GetFGAN(Int_t sector, Int_t stack, Int_t layer, 
+                                               Int_t row, Int_t col)
+{ 
+  //
+  // returns the Gain Correction Filter Additive of the channel
+  // given by sector, stack, layer, row, col
+  //
+
+  return GetFGAN(30*sector + 6*stack + layer, row, col);
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTable::GetFGFN(Int_t det, Int_t row, Int_t col)
+{  
+  //
+  // returns the Gain Correction Filter Factor of the channel
+  // given by det, row, col
+  //
+
+  AliTRDCalOnlineGainTableROC* gtbl = GetGainTableROC(det);
+
+  if (gtbl) {
+    return gtbl->GetFGFN(row,col);
+  } else {
+    return -999;
+  }
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTable::GetFGFN(Int_t sector, Int_t stack, Int_t layer, 
+                                               Int_t row, Int_t col)
+{  
+  //
+  // returns the Gain Correction Filter Factor of the channel
+  // given by sector, stack, layer, row, col
+  //
+
+  return GetFGFN(30*sector + 6*stack + layer, row, col);
+}
+
+//_____________________________________________________________________________
+void AliTRDCalOnlineGainTable::AllocateGainTableROC(Int_t det)
+{ 
+  //
+  // allocates a Gain Table for the given detector
+  //
+
+  if (fROCGainTables[det]) {
+    delete fROCGainTables[det];
+  }
+
+  fROCGainTables[det] = new AliTRDCalOnlineGainTableROC;
+}
+
diff --git a/TRD/Cal/AliTRDCalOnlineGainTable.h b/TRD/Cal/AliTRDCalOnlineGainTable.h
new file mode 100644 (file)
index 0000000..08bb889
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef ALITRDCALONLINEGAINTABLE_H
+#define ALITRDCALONLINEGAINTABLE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#include <TObject.h>
+#include "AliTRDCalOnlineGainTableROC.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Data structure to store gaintables of the online calibration in the OCDB
+// consisting of three classes:
+// AliTRDCalOnlineGainTable 
+// AliTRDCalOnlineGainTableROC 
+// AliTRDCalOnlineGainTableMCM
+//
+// AliTRDCalOnlineGainTable is the main class from which all stored data can be accessed.
+// The two sub-classes AliTRDCalOnlineGainTableROC and AliTRDCalOnlineGainTableMCM
+// contain the gaintables on ROC level and on the MCM level respectively.
+//
+// The online calibration is used to compensate gain deviations on the pad level.
+// For the offline reconstruction the online calibration has to be undone. 
+// The corresponding gain correction factor that was used by the online gain filter can be accessed 
+// via the functions AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col) 
+// and AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col).
+//
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+class AliTRDCalOnlineGainTable: public TObject
+{
+public:
+
+  AliTRDCalOnlineGainTable();
+  AliTRDCalOnlineGainTable(const AliTRDCalOnlineGainTable& other);
+  AliTRDCalOnlineGainTable& operator=(const AliTRDCalOnlineGainTable& other);
+  ~AliTRDCalOnlineGainTable();
+
+  Float_t GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col);
+  Float_t GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col);
+
+  Short_t GetAdcdac(Int_t det, Int_t row, Int_t col);
+  Short_t GetAdcdac(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col);
+
+  Float_t GetMCMGain(Int_t det, Int_t row, Int_t col);
+  Float_t GetMCMGain(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col);
+
+  Short_t GetFGAN(Int_t det, Int_t row, Int_t col);
+  Short_t GetFGAN(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col);
+
+  Short_t GetFGFN(Int_t det, Int_t row, Int_t col);
+  Short_t GetFGFN(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col);
+
+  void AllocateGainTableROC(Int_t det);
+
+  AliTRDCalOnlineGainTableROC *GetGainTableROC(Int_t det) const
+  {
+    // returns the Gain Table for the given detector
+    return fROCGainTables[det];
+  }
+
+  AliTRDCalOnlineGainTableROC *GetGainTableROC(Int_t sector, Int_t stack, Int_t layer) const
+  {
+    // returns the Gain Table for the given detector
+    return GetGainTableROC(sector*30 + stack*6 + layer);
+  } 
+
+  static const Float_t UnDef;
+
+protected:
+
+  AliTRDCalOnlineGainTableROC* fROCGainTables[540]; // Array of gain tables for all ROCs
+  
+  ClassDef(AliTRDCalOnlineGainTable,1);             // TRD online gain tables
+
+};
+
+#endif
diff --git a/TRD/Cal/AliTRDCalOnlineGainTableMCM.cxx b/TRD/Cal/AliTRDCalOnlineGainTableMCM.cxx
new file mode 100644 (file)
index 0000000..eb4ffcd
--- /dev/null
@@ -0,0 +1,172 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+#include "AliTRDCalOnlineGainTableMCM.h"
+#include "AliTRDCalOnlineGainTable.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Data structure to store gaintables of the online calibration in the OCDB
+// consisting of three classes:
+// AliTRDCalOnlineGainTable 
+// AliTRDCalOnlineGainTableROC 
+// AliTRDCalOnlineGainTableMCM
+//
+// AliTRDCalOnlineGainTable is the main class from which all stored data can be accessed.
+// The two sub-classes AliTRDCalOnlineGainTableROC and AliTRDCalOnlineGainTableMCM
+// contain the gaintables on ROC level and on the MCM level respectively.
+//
+// The online calibration is used to compensate gain deviations on the pad level.
+// For the offline reconstruction the online calibration has to be undone. 
+// The corresponding gain correction factor that was used by the online gain filter can be accessed 
+// via the functions AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col) 
+// and AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col).
+//
+// With the class AliTRDCalOnlineGainTablesMCM all values used for the 
+// online calibration can be set and accessed on the MCM/channel level
+//
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+ClassImp(AliTRDCalOnlineGainTableMCM);
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTableMCM::AliTRDCalOnlineGainTableMCM()
+  :TObject()
+  ,fAdcdac(0)
+  ,fMCMGain(0.0)
+{
+  //
+  // constructor
+  //
+
+  fAdcdac = -1;
+  fMCMGain = AliTRDCalOnlineGainTable::UnDef;
+  
+  for (int i=0; i<21;i++) {
+
+    fFGFN[i] = -1;
+    fFGAN[i] = -1;
+  }
+
+}
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTableMCM::~AliTRDCalOnlineGainTableMCM()
+{
+  //
+  // destructor
+  //
+
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTableMCM::GetGainCorrectionFactor(Int_t channel)
+{
+  //
+  // returns the Gain Correction Factor of the given channel that was used by the online gain filter
+  // 1.0 means no correction
+  // 0.9 means a correction of -10%
+  // 1.1 means a correction of +10% etc.
+  //
+
+  if (fAdcdac == 0){
+    if (fFGFN[channel] < 0){
+      return -1.;
+    }
+    else if(fFGFN[channel] > 511){
+      return -999.;
+    }
+    else{
+      return (fFGFN[channel]/2048.)+0.875;
+    }
+  }
+  else{
+    // if the reference voltage of the ADC is not the default value 
+    // this taken into account for the Gain Correction Factor
+    Float_t fAdcdac_Correction = ( 1./(1.+((Float_t)fAdcdac/31.)*(0.4/1.05))); 
+    return (fAdcdac_Correction*((fFGFN[channel]/2048.)+0.875));
+  }
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTableMCM::GetAdcdac()
+{
+  //
+  // returns an integer between 0 and 31 which corresponds to an ADC reference voltage between 1.05V and 1.45V
+  // U_Ref =  (1.05V + (fAdcdac/31)*0.4V
+  // fAdcdac is the same value for all ADCs within one MCM
+  //
+
+  return fAdcdac;
+
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTableMCM::GetMCMGain()
+{
+  //
+  // returns the Gain Factor which would lead to a Gain Correction Factor of 1.0
+  // this value is the same for all channels within one MCM
+  // this value is used for the online PID
+  //
+
+  return fMCMGain;
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTableMCM::GetFGAN(Int_t channel)
+{
+  //
+  // returns the Gain Correction Filter Additive as an interger between 0 and 15 
+  // as it is loaded into the TRAP
+  //
+
+  if (fFGAN[channel] < 0){
+    return -1;
+  }
+  else if(fFGAN[channel] > 511){
+    return -999;
+  }
+  else{
+    return fFGAN[channel];
+      
+  }
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTableMCM::GetFGFN(Int_t channel)
+{
+  //
+  // returns the Gain Correction Filter Factors as an interger between 0 and 511 
+  // as it is loaded into the TRAP 
+  //
+
+  if (fFGFN[channel] < 0){
+    return -1;
+  }
+  else if(fFGFN[channel] > 511){
+    return -999;
+  }
+  else{
+    return fFGFN[channel];
+      
+  }
+
+}
+
diff --git a/TRD/Cal/AliTRDCalOnlineGainTableMCM.h b/TRD/Cal/AliTRDCalOnlineGainTableMCM.h
new file mode 100644 (file)
index 0000000..341ae50
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef ALITRDCALONLINEGAINTABLEMCM_H
+#define ALITRDCALONLINEGAINTABLEMCM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#include <TObject.h>
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Data structure to store gaintables of the online calibration in the OCDB
+// consisting of three classes:
+// AliTRDCalOnlineGainTable 
+// AliTRDCalOnlineGainTableROC 
+// AliTRDCalOnlineGainTableMCM
+//
+// AliTRDCalOnlineGainTable is the main class from which all stored data can be accessed.
+// The two sub-classes AliTRDCalOnlineGainTableROC and AliTRDCalOnlineGainTableMCM
+// contain the gaintables on ROC level and on the MCM level respectively.
+//
+// The online calibration is used to compensate gain deviations on the pad level.
+// For the offline reconstruction the online calibration has to be undone. 
+// The corresponding gain correction factor that was used by the online gain filter can be accessed 
+// via the functions AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col) 
+// and AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col).
+//
+// With the class AliTRDCalOnlineGainTablesMCM all values used for the 
+// online calibration can be set and accessed on the MCM/channel level
+//
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+class AliTRDCalOnlineGainTableMCM: public TObject
+{
+public:
+
+  AliTRDCalOnlineGainTableMCM();
+  ~AliTRDCalOnlineGainTableMCM();
+
+  Float_t GetGainCorrectionFactor(Int_t channel);
+  Float_t GetMCMGain();
+  Short_t GetAdcdac();
+  Short_t GetFGAN(Int_t channel);
+  Short_t GetFGFN(Int_t channel);
+  
+  void SetAdcdac(Short_t x) {fAdcdac = x;} // Sets fAdcdac to the given value
+  void SetMCMGain(Float_t x) {fMCMGain = x;} // Sets fMCMGain to the given value
+
+  void SetFGFN(Short_t ch, Short_t x) {fFGFN[ch] = x;} // Sets fFGFN to the given value
+  void SetFGAN(Short_t ch, Short_t x) {fFGAN[ch] = x;} // Sets fFGAN to the given value
+
+protected:
+
+  Short_t fAdcdac;   // Reference voltage of the ADCs  U_Ref =  (1.05V + (fAdcdac/31)*0.4V
+
+  Short_t fFGFN[21]; // Gain Correction Filter Factor
+  Short_t fFGAN[21]; // Gain Correction Filter Additive
+
+  Float_t fMCMGain;  // Gain Factor which would lead to a Correction Factor of 1.0 within the MCM
+
+
+  ClassDef(AliTRDCalOnlineGainTableMCM,1); // TRD online gain table of a MCM
+
+};
+
+#endif
diff --git a/TRD/Cal/AliTRDCalOnlineGainTableROC.cxx b/TRD/Cal/AliTRDCalOnlineGainTableROC.cxx
new file mode 100644 (file)
index 0000000..68beff2
--- /dev/null
@@ -0,0 +1,248 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+#include <AliTRDfeeParam.h>
+#include "AliTRDCalOnlineGainTableROC.h"
+#include "AliTRDCalOnlineGainTable.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Data structure to store gaintables of the online calibration in the OCDB
+// consisting of three classes:
+// AliTRDCalOnlineGainTable 
+// AliTRDCalOnlineGainTableROC 
+// AliTRDCalOnlineGainTableMCM
+//
+// AliTRDCalOnlineGainTable is the main class from which all stored data can be accessed.
+// The two sub-classes AliTRDCalOnlineGainTableROC and AliTRDCalOnlineGainTableMCM
+// contain the gaintables on ROC level and on the MCM level respectively.
+//
+// The online calibration is used to compensate gain deviations on the pad level.
+// For the offline reconstruction the online calibration has to be undone. 
+// The corresponding gain correction factor that was used by the online gain filter can be accessed 
+// via the functions AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col) 
+// and AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col).
+//
+// AliTRDCalOnlineGainTableROC is a class to allocate MCM Gain Tables 
+// and to access all stored calibration values from the ROC level by indicating row and col
+//
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+ClassImp(AliTRDCalOnlineGainTableROC);
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTableROC::AliTRDCalOnlineGainTableROC()
+  :TObject()
+{
+  //
+  // constructor
+  //
+
+  for (int i=0; i<128; i++) {
+    fMCMGainTables[i] = 0;
+  }
+}
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTableROC::AliTRDCalOnlineGainTableROC(const AliTRDCalOnlineGainTableROC& other)
+  :TObject(other)
+{
+  //
+  // copy constructor
+  //
+
+  for (int i=0; i<128; i++) {
+    if (other.GetGainTableMCM(i)) {
+      fMCMGainTables[i] = new AliTRDCalOnlineGainTableMCM( *(other.GetGainTableMCM(i)) );
+    } else {
+      fMCMGainTables[i] = 0;
+    }
+  }
+
+}
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTableROC& AliTRDCalOnlineGainTableROC::operator=(const AliTRDCalOnlineGainTableROC& other)
+{
+  //
+  // assignment operator
+  //
+
+  for (int i=0; i<128; i++) {
+
+    if (fMCMGainTables[i]) {
+      delete fMCMGainTables[i];
+    }
+
+    if (other.GetGainTableMCM(i)) {
+      fMCMGainTables[i] = new AliTRDCalOnlineGainTableMCM( *(other.GetGainTableMCM(i)) );
+    } else {
+      fMCMGainTables[i] = 0;
+    }
+  }
+
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+AliTRDCalOnlineGainTableROC::~AliTRDCalOnlineGainTableROC()
+{
+  //
+  // destructor
+  //
+
+  for (int i=0; i<128; i++) {
+    if (fMCMGainTables[i]) {
+      delete fMCMGainTables[i];
+    }
+  }
+
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTableROC::GetGainCorrectionFactor(Int_t row, Int_t col)
+{
+  //
+  // chooses ROB/MCM/channel from row/col
+  // returns the Gain Correction Factor of the given channel
+  //
+
+  AliTRDfeeParam * para = AliTRDfeeParam::Instance(); 
+
+  Int_t rob = para->GetROBfromPad(row,col);
+  Int_t mcm = para->GetMCMfromPad(row,col);
+  Int_t channel =19-(col%18);
+
+  AliTRDCalOnlineGainTableMCM* gtbl=GetGainTableMCM(rob,mcm);
+
+  if (gtbl) {
+    return gtbl->GetGainCorrectionFactor(channel);
+  } else {
+    return AliTRDCalOnlineGainTable::UnDef;
+  }
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTableROC::GetAdcdac(Int_t row, Int_t col)
+{
+  //
+  // chooses ROB/MCM/channel from row/col
+  // returns the ADC's reference voltage of the given MCM
+  //
+
+  AliTRDfeeParam * para = AliTRDfeeParam::Instance(); 
+
+  Int_t rob = para->GetROBfromPad(row,col);
+  Int_t mcm = para->GetMCMfromPad(row,col);
+
+  AliTRDCalOnlineGainTableMCM* gtbl=GetGainTableMCM(rob,mcm);
+
+  if (gtbl) {
+    return gtbl->GetAdcdac();
+  } else {
+    return -999;
+  }
+
+}
+
+//_____________________________________________________________________________
+Float_t AliTRDCalOnlineGainTableROC::GetMCMGain(Int_t row, Int_t col)
+{
+  //
+  // chooses ROB/MCM/channel from row/col
+  // returns the Gain Factor which would lead to a Correction Factor of 1.0 within the given MCM
+  //
+
+  AliTRDfeeParam * para = AliTRDfeeParam::Instance(); 
+
+  Int_t rob = para->GetROBfromPad(row,col);
+  Int_t mcm = para->GetMCMfromPad(row,col);
+
+  AliTRDCalOnlineGainTableMCM* gtbl=GetGainTableMCM(rob,mcm);
+
+  if (gtbl) {
+    return gtbl->GetMCMGain();
+  } else {
+    return AliTRDCalOnlineGainTable::UnDef;
+  }
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTableROC::GetFGAN(Int_t row, Int_t col)
+{
+  //
+  // chooses ROB/MCM/channel from row/col
+  // returns the Gain Correction Filter Factor of the given channel
+  //
+
+  AliTRDfeeParam * para = AliTRDfeeParam::Instance(); 
+
+  Int_t rob = para->GetROBfromPad(row,col);
+  Int_t mcm = para->GetMCMfromPad(row,col);
+  Int_t channel =19-(col%18);
+
+  AliTRDCalOnlineGainTableMCM* gtbl=GetGainTableMCM(rob,mcm);
+
+  if (gtbl) {
+    return gtbl->GetFGAN(channel);
+  } else {
+    return -999;
+  }
+
+}
+
+//_____________________________________________________________________________
+Short_t AliTRDCalOnlineGainTableROC::GetFGFN(Int_t row, Int_t col)
+{
+  //
+  // chooses ROB/MCM/channel from row/col
+  // returns the Gain Correction Filter Additive of the given channel
+  //
+
+  AliTRDfeeParam * para = AliTRDfeeParam::Instance(); 
+
+  Int_t rob = para->GetROBfromPad(row,col);
+  Int_t mcm = para->GetMCMfromPad(row,col);
+  Int_t channel =19-(col%18);
+
+  AliTRDCalOnlineGainTableMCM* gtbl=GetGainTableMCM(rob,mcm);
+
+  if (gtbl) {
+    return gtbl->GetFGFN(channel);
+  } else {
+    return -999;
+  }
+
+}  
+
+//_____________________________________________________________________________
+void AliTRDCalOnlineGainTableROC::AllocateGainTableMCM(Int_t rob, Int_t mcm)
+{
+  //
+  // allocates a Gain Table for the given MCM
+  //
+
+  Int_t index = rob*16 + mcm;
+
+  if (fMCMGainTables[index]) {
+    delete fMCMGainTables[index];
+  }
+
+  fMCMGainTables[index] = new AliTRDCalOnlineGainTableMCM;
+}
+
diff --git a/TRD/Cal/AliTRDCalOnlineGainTableROC.h b/TRD/Cal/AliTRDCalOnlineGainTableROC.h
new file mode 100644 (file)
index 0000000..419ccfe
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef ALITRDCALONLINEGAINTABLEROC_H
+#define ALITRDCALONLINEGAINTABLEROC_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#include <TObject.h>
+#include "AliTRDCalOnlineGainTableMCM.h"
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+//
+// Data structure to store gaintables of the online calibration in the OCDB
+// consisting of three classes:
+// AliTRDCalOnlineGainTable 
+// AliTRDCalOnlineGainTableROC 
+// AliTRDCalOnlineGainTableMCM
+//
+// AliTRDCalOnlineGainTable is the main class from which all stored data can be accessed.
+// The two sub-classes AliTRDCalOnlineGainTableROC and AliTRDCalOnlineGainTableMCM
+// contain the gaintables on ROC level and on the MCM level respectively.
+//
+// The online calibration is used to compensate gain deviations on the pad level.
+// For the offline reconstruction the online calibration has to be undone. 
+// The corresponding gain correction factor that was used by the online gain filter can be accessed 
+// via the functions AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t det, Int_t row, Int_t col) 
+// and AliTRDCalOnlineGainTable::GetGainCorrectionFactor(Int_t sector, Int_t stack, Int_t layer, Int_t row, Int_t col).
+//
+// AliTRDCalOnlineGainTableROC is a class to allocate MCM Gain Tables 
+// and to access all stored calibration values from the ROC level by indicating row and col
+//
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+class AliTRDCalOnlineGainTableROC: public TObject
+{
+public:
+
+  AliTRDCalOnlineGainTableROC(); 
+   AliTRDCalOnlineGainTableROC(const AliTRDCalOnlineGainTableROC& other);
+   AliTRDCalOnlineGainTableROC& operator=(const AliTRDCalOnlineGainTableROC& other);
+  ~AliTRDCalOnlineGainTableROC();
+
+  Float_t GetGainCorrectionFactor(Int_t row, Int_t col); 
+  Short_t GetAdcdac(Int_t row, Int_t col);
+  Float_t GetMCMGain(Int_t row, Int_t col); 
+  Short_t GetFGAN(Int_t row, Int_t col);
+  Short_t GetFGFN(Int_t row, Int_t col);
+
+  void AllocateGainTableMCM(Int_t rob, Int_t mcm);
+
+  AliTRDCalOnlineGainTableMCM* GetGainTableMCM(Int_t index) const
+  { 
+    //returns the Gain Table of the given MCM
+    return fMCMGainTables[index]; 
+  }
+
+  AliTRDCalOnlineGainTableMCM* GetGainTableMCM(Int_t rob, Int_t mcm) const
+  { 
+    //returns the Gain Table of the given MCM
+    return GetGainTableMCM(16*rob+mcm); 
+  }
+
+protected:
+  
+  AliTRDCalOnlineGainTableMCM* fMCMGainTables[128]; // Array of gain tables for MCMs
+  
+  ClassDef(AliTRDCalOnlineGainTableROC,1);          // TRD online gain table of a ROC
+
+};
+
+#endif
index 47a1e05b2d4c817de1ccb213e4ced0cb043f6ab8..aea236f199f314140588554ac568b75a5528c5a9 100644 (file)
@@ -51,6 +51,9 @@
 #pragma link C++ class  AliTRDCalDCSGTUTmu+;
 #pragma link C++ class  AliTRDCalDCSGTU+;
 #pragma link C++ class  AliTRDCalMonitoring+;
+#pragma link C++ class  AliTRDCalOnlineGainTable+;
+#pragma link C++ class  AliTRDCalOnlineGainTableROC+;
+#pragma link C++ class  AliTRDCalOnlineGainTableMCM+;
 
 #pragma link C++ class  AliTRDCalChamberStatus+;
 #pragma link C++ class  AliTRDCalPadStatus+;