]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDcalibDB.cxx
One header file for PYQUEN only.
[u/mrichter/AliRoot.git] / TRD / AliTRDcalibDB.cxx
index 94247d67d9bc0f7ce43fc9e1b3be52c36b5ffab4..6d047c89d624f68ffb7186f03e775849c1d9f9e5 100644 (file)
@@ -44,8 +44,8 @@
 #include "Cal/AliTRDCalROC.h"
 #include "Cal/AliTRDCalPad.h"
 #include "Cal/AliTRDCalDet.h"
-#include "Cal/AliTRDCalGlobals.h"
-#include "Cal/AliTRDCalPIDLQ.h"
+#include "Cal/AliTRDCalFEE.h"
+#include "Cal/AliTRDCalPID.h"
 #include "Cal/AliTRDCalMonitoring.h"
 #include "Cal/AliTRDCalChamberStatus.h"
 #include "Cal/AliTRDCalPadStatus.h"
@@ -121,7 +121,7 @@ AliTRDcalibDB::AliTRDcalibDB()
   
   // Create the sampled PRF
   SamplePRF();
-
+  
 }
 
 //_____________________________________________________________________________
@@ -241,9 +241,11 @@ const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
     case kIDMonitoringData : 
       return CacheCDBEntry(kIDMonitoringData    ,"TRD/Calib/MonitoringData"); 
       break;
-    case kIDGlobals : 
-      return CacheCDBEntry(kIDGlobals           ,"TRD/Calib/Globals"); 
+    case kIDFEE : 
+      return CacheCDBEntry(kIDFEE               ,"TRD/Calib/FEE"); 
       break;
+    case kIDPIDNN : 
+      return CacheCDBEntry(kIDPIDNN             ,"TRD/Calib/PIDNN");
     case kIDPIDLQ : 
       return CacheCDBEntry(kIDPIDLQ             ,"TRD/Calib/PIDLQ"); 
       break;
@@ -263,7 +265,7 @@ AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
     
   AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
   if (!entry) { 
-    AliError(Form("Failed to get entry: %s",cdbPath));
+    AliFatal(Form("Failed to get entry: %s",cdbPath));
     return 0; 
   }
   
@@ -357,6 +359,49 @@ Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
   return calChamber->GetValue(det) * roc->GetValue(col,row);
 
 }
+//_____________________________________________________________________________
+AliTRDCalROC *AliTRDcalibDB::GetVdriftROC(Int_t det)
+{
+  //
+  // Returns the Vdrift calibration object for a given ROC
+  // containing one number per pad 
+  //
+  
+  const AliTRDCalPad     *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                       (GetCachedCDBObject(kIDVdriftPad));
+  if (!calPad) {
+    return 0;
+  }
+
+  AliTRDCalROC           *roc        = calPad->GetCalROC(det);
+  if (!roc) {
+    return 0;
+  }
+  else {
+    return roc;
+  }
+
+}
+
+//_____________________________________________________________________________
+const AliTRDCalDet *AliTRDcalibDB::GetVdriftDet()
+{
+  //
+  // Returns the Vdrift calibration object
+  // containing one number per detector
+  //
+  
+  const AliTRDCalDet     *calChamber = dynamic_cast<const AliTRDCalDet *> 
+                                       (GetCachedCDBObject(kIDVdriftChamber));
+  if (!calChamber) {
+    return 0;
+  }
+  else {
+    return calChamber;
+  }
+
+}
 
 //_____________________________________________________________________________
 Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
@@ -382,24 +427,67 @@ Float_t AliTRDcalibDB::GetT0(Int_t det, Int_t col, Int_t row)
   // Returns t0 for the given pad.
   //
   
-  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
-                                   (GetCachedCDBObject(kIDT0Pad));
+  const AliTRDCalPad     *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                       (GetCachedCDBObject(kIDT0Pad));
   if (!calPad) {
     return -1;
   }
 
-  AliTRDCalROC       *roc        = calPad->GetCalROC(det);
+  AliTRDCalROC           *roc        = calPad->GetCalROC(det);
   if (!roc) {
     return -1;
   }
 
-  const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> 
-                                   (GetCachedCDBObject(kIDT0Chamber));
+  const AliTRDCalDet     *calChamber = dynamic_cast<const AliTRDCalDet *> 
+                                       (GetCachedCDBObject(kIDT0Chamber));
   if (!calChamber) {
     return -1;
   }
 
-  return calChamber->GetValue(det) * roc->GetValue(col,row);
+  return calChamber->GetValue(det) + roc->GetValue(col,row);
+
+}
+//_____________________________________________________________________________
+AliTRDCalROC *AliTRDcalibDB::GetT0ROC(Int_t det)
+{
+  //
+  // Returns the t0 calibration object for a given ROC
+  // containing one number per pad 
+  //
+  
+  const AliTRDCalPad     *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                       (GetCachedCDBObject(kIDT0Pad));
+  if (!calPad) {
+    return 0;
+  }
+
+  AliTRDCalROC           *roc        = calPad->GetCalROC(det);
+  if (!roc) {
+    return 0;
+  }
+  else {
+    return roc;
+  }
+
+}
+
+//_____________________________________________________________________________
+const AliTRDCalDet *AliTRDcalibDB::GetT0Det()
+{
+  //
+  // Returns the t0 calibration object
+  // containing one number per detector
+  //
+  
+  const AliTRDCalDet     *calChamber = dynamic_cast<const AliTRDCalDet *> 
+                                       (GetCachedCDBObject(kIDT0Chamber));
+  if (!calChamber) {
+    return 0;
+  }
+  else {
+    return calChamber;
+  }
 
 }
 
@@ -410,13 +498,29 @@ Float_t AliTRDcalibDB::GetT0Average(Int_t det)
   // Returns the average t0 for the given detector
   //
 
+  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                   (GetCachedCDBObject(kIDT0Pad));
+  if (!calPad) {
+    return -1;
+  }
+
+  AliTRDCalROC       *roc        = calPad->GetCalROC(det);
+  if (!roc) {
+    return -1;
+  }
+
   const AliTRDCalDet *calDet     = dynamic_cast<const AliTRDCalDet *> 
                                    (GetCachedCDBObject(kIDT0Chamber));
   if (!calDet) {
     return -1;
   }
 
-  return calDet->GetValue(det);
+  Double_t mean = 0.0; 
+  for (Int_t channel = 0; channel < roc->GetNchannels(); ++channel) {
+    mean += (calDet->GetValue(det) + roc->GetValue(channel)) / roc->GetNchannels();
+  }
+
+  return mean;
 
 }
 
@@ -434,8 +538,9 @@ Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
   }
 
   AliTRDCalROC       *roc        = calPad->GetCalROC(det);
-  if (!roc)
+  if (!roc) {
     return -1;
+  }
 
   const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> 
                                    (GetCachedCDBObject(kIDGainFactorChamber));
@@ -447,6 +552,49 @@ Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
 
 }
 
+//_____________________________________________________________________________
+AliTRDCalROC *AliTRDcalibDB::GetGainFactorROC(Int_t det)
+{
+  //
+  // Returns the gain factor calibration object for a given ROC
+  // containing one number per pad 
+  //
+  
+  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                   (GetCachedCDBObject(kIDGainFactorPad));
+  if (!calPad) {
+    return 0;
+  }
+
+  AliTRDCalROC       *roc        = calPad->GetCalROC(det);
+  if (!roc) {
+    return 0;
+  }
+  else {
+    return roc;
+  }
+
+}
+
+//_____________________________________________________________________________
+const AliTRDCalDet *AliTRDcalibDB::GetGainFactorDet()
+{
+  //
+  // Returns the gain factor calibration object
+  // containing one number per detector
+  //
+
+  const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> 
+                                   (GetCachedCDBObject(kIDGainFactorChamber));
+  if (!calChamber) {
+    return 0;
+  }
+  else {
+    return calChamber;
+  }
+
+}
+
 //_____________________________________________________________________________
 Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
 {
@@ -465,41 +613,48 @@ Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
 }
 
 //_____________________________________________________________________________
-Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
+AliTRDCalROC *AliTRDcalibDB::GetPRFROC(Int_t det)
 {
   //
-  // Returns the PRF width for the given pad.
+  // Returns the PRF calibration object for a given ROC
+  // containing one number per pad 
   //
   
-  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
-                                   (GetCachedCDBObject(kIDPRFWidth));
+  const AliTRDCalPad     *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                       (GetCachedCDBObject(kIDPRFWidth));
   if (!calPad) {
-    return -1;
+    return 0;
   }
 
-  AliTRDCalROC       *roc        = calPad->GetCalROC(det);
+  AliTRDCalROC           *roc        = calPad->GetCalROC(det);
   if (!roc) {
-    return -1;
+    return 0;
+  }
+  else {
+    return roc;
   }
-
-  return roc->GetValue(col,row);
 
 }
 
 //_____________________________________________________________________________
-Float_t AliTRDcalibDB::GetSamplingFrequency()
+Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
 {
   //
-  // Returns the sampling frequency of the TRD read-out.
+  // Returns the PRF width for the given pad.
   //
   
-  const AliTRDCalGlobals *calGlobal = dynamic_cast<const AliTRDCalGlobals *> 
-                                      (GetCachedCDBObject(kIDGlobals));
-  if (!calGlobal) {
-    return -1;  
-  }  
+  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
+                                   (GetCachedCDBObject(kIDPRFWidth));
+  if (!calPad) {
+    return -1;
+  }
 
-  return calGlobal->GetSamplingFrequency();
+  AliTRDCalROC       *roc        = calPad->GetCalROC(det);
+  if (!roc) {
+    return -1;
+  }
+
+  return roc->GetValue(col,row);
 
 }
   
@@ -510,13 +665,13 @@ Int_t AliTRDcalibDB::GetNumberOfTimeBins()
   // Returns the number of time bins which are read-out.
   //
 
-  const AliTRDCalGlobals *calGlobal = dynamic_cast<const AliTRDCalGlobals *> 
-                                      (GetCachedCDBObject(kIDGlobals));
-  if (!calGlobal) {
+  const AliTRDCalFEE *calFEE     = dynamic_cast<const AliTRDCalFEE *> 
+                                   (GetCachedCDBObject(kIDFEE));
+  if (!calFEE) {
     return -1;
   }
 
-  return calGlobal->GetNumberOfTimeBins();
+  return calFEE->GetNumberOfTimeBins();
 
 }
 
@@ -527,8 +682,8 @@ Char_t AliTRDcalibDB::GetPadStatus(Int_t det, Int_t col, Int_t row)
   // Returns the status of the given pad
   //
 
-  const AliTRDCalPadStatus *cal     = dynamic_cast<const AliTRDCalPadStatus *> 
-                                      (GetCachedCDBObject(kIDPadStatus));
+  const AliTRDCalPadStatus *cal  = dynamic_cast<const AliTRDCalPadStatus *> 
+                                   (GetCachedCDBObject(kIDPadStatus));
   if (!cal) {
     return -1;
   }
@@ -645,24 +800,32 @@ Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
 }
 
 //_____________________________________________________________________________
-const AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject()
+const AliTRDCalPID *AliTRDcalibDB::GetPIDObject(const Int_t method)
 {
   //
   // Returns the object storing the distributions for PID with likelihood
   //
 
-  return dynamic_cast<const AliTRDCalPIDLQ *> (GetCachedCDBObject(kIDPIDLQ));
+  switch(method) {
+    case 0: return dynamic_cast<const AliTRDCalPID *> 
+                              (GetCachedCDBObject(kIDPIDNN));
+    case 1: return dynamic_cast<const AliTRDCalPID *>
+                              (GetCachedCDBObject(kIDPIDLQ));
+  }
+
+  return 0;
 
 }
 
 //_____________________________________________________________________________
-const AliTRDCalMonitoringAliTRDcalibDB::GetMonitoringObject()
+const AliTRDCalMonitoring *AliTRDcalibDB::GetMonitoringObject()
 {
   //
   // Returns the object storing the monitoring data
   //
 
-  return dynamic_cast<const AliTRDCalMonitoring *> (GetCachedCDBObject(kIDMonitoringData));
+  return dynamic_cast<const AliTRDCalMonitoring *> 
+         (GetCachedCDBObject(kIDMonitoringData));
    
 }
 
@@ -875,6 +1038,8 @@ Int_t AliTRDcalibDB::PadResponse(Double_t signal, Double_t dist
 {
   //
   // Applies the pad response
+  // So far this is the fixed parametrization and should be replaced by
+  // something dependent on calibration values
   //
 
   Int_t iBin  = ((Int_t) (( - dist - fPRFlo) / fPRFwid));