]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDcalibDB.cxx
Inserting TMath.h where required by the new version of ROOT
[u/mrichter/AliRoot.git] / TRD / AliTRDcalibDB.cxx
index ddb16c1fb91557597a0f21587245fa6cc6e8b83a..13cf5526e83a28c250e7792fb9390d8e810608dd 100644 (file)
@@ -28,6 +28,7 @@
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <TMath.h>
 #include <TRandom.h>
 
 #include "AliCDBManager.h"
@@ -74,6 +75,7 @@ AliTRDcalibDB* AliTRDcalibDB::Instance()
   }
 
   return fgInstance;
+
 }
 
 //_____________________________________________________________________________
@@ -81,7 +83,8 @@ void AliTRDcalibDB::Terminate()
 {
   //
   // Singleton implementation
-  // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
+  // Deletes the instance of this class and sets the terminated flag,
+  // instances cannot be requested anymore
   // This function can be called several times.
   //
   
@@ -113,7 +116,7 @@ AliTRDcalibDB::AliTRDcalibDB()
   // TODO invalid calibration data to be used.
   //
 
-  for (Int_t i=0; i<kCDBCacheSize; ++i) {
+  for (Int_t i = 0; i < kCDBCacheSize; ++i) {
     fCDBCache[i]   = 0;
     fCDBEntries[i] = 0;
   }
@@ -138,7 +141,7 @@ AliTRDcalibDB::AliTRDcalibDB(const AliTRDcalibDB &c)
   // Copy constructor (not that it make any sense for a singleton...)
   //
 
-  for (Int_t i=0; i<kCDBCacheSize; ++i) {
+  for (Int_t i = 0; i < kCDBCacheSize; ++i) {
     fCDBCache[i]   = 0;
     fCDBEntries[i] = 0;
   }
@@ -158,6 +161,7 @@ AliTRDcalibDB &AliTRDcalibDB::operator=(const AliTRDcalibDB &c)
   if (this != &c) {
     AliFatal("No assignment operator defined");
   }
+
   return *this;
 
 }
@@ -179,7 +183,7 @@ AliTRDcalibDB::~AliTRDcalibDB()
 }
 
 //_caching functions____________________________________________________________
-const TObjectAliTRDcalibDB::GetCachedCDBObject(Int_t id)
+const TObject *AliTRDcalibDB::GetCachedCDBObject(Int_t id)
 {
   //
   // Retrieves a cdb object with the given id. The objects are cached as
@@ -259,26 +263,24 @@ const TObject* AliTRDcalibDB::GetCachedCDBObject(Int_t id)
 }
 
 //_____________________________________________________________________________
-AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath)
+AliCDBEntry *AliTRDcalibDB::GetCDBEntry(const char *cdbPath)
 {
   // 
   // Retrieves an entry with path <cdbPath> from the CDB.
   //
     
-  AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
+  AliCDBEntry *entry = AliCDBManager::Instance()->Get(cdbPath,fRun);
   if (!entry) { 
     AliError(Form("Failed to get entry: %s",cdbPath));
     return 0; 
   }
   
-  AliInfo(Form("AliTRDcalibDB: Retrieved object: %s",cdbPath));
-
   return entry;
 
 }
 
 //_____________________________________________________________________________
-const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath)
+const TObject *AliTRDcalibDB::CacheCDBEntry(Int_t id, const char *cdbPath)
 {
   //
   // Caches the entry <id> with cdb path <cdbPath>
@@ -286,9 +288,11 @@ const TObject* AliTRDcalibDB::CacheCDBEntry(Int_t id, const char* cdbPath)
   
   if (!fCDBCache[id]) {
     fCDBEntries[id] = GetCDBEntry(cdbPath);
-    if (fCDBEntries[id])
+    if (fCDBEntries[id]) {
       fCDBCache[id] = fCDBEntries[id]->GetObject();
+    }
   }
+
   return fCDBCache[id];
 
 }
@@ -306,6 +310,7 @@ void AliTRDcalibDB::SetRun(Long64_t run)
   }
 
   fRun = run;
+
   Invalidate();
 
 }
@@ -317,10 +322,10 @@ void AliTRDcalibDB::Invalidate()
   // Invalidates cache (when run number is changed).
   //
   
-  for (Int_t i=0; i<kCDBCacheSize; ++i) {
+  for (Int_t i = 0; i < kCDBCacheSize; ++i) {
     if (fCDBEntries[i]) {
       if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE) {
-        if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i]) {
+        if ((fCDBEntries[i]->IsOwner() == kFALSE) && fCDBCache[i]) {
           delete fCDBCache[i];
        }
         delete fCDBEntries[i];
@@ -339,24 +344,24 @@ Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
   // Returns the drift velocity for the given pad.
   //
 
-  const AliTRDCalPad* calPad     = dynamic_cast<const AliTRDCalPad*> 
+  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
                                    (GetCachedCDBObject(kIDVdriftPad));
   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*> 
+  const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> 
                                    (GetCachedCDBObject(kIDVdriftChamber));
   if (!calChamber) {
     return -1;
   }
 
-  return calChamber->GetValue(det) * roc->GetValue(col, row);
+  return calChamber->GetValue(det) * roc->GetValue(col,row);
 
 }
 
@@ -367,7 +372,7 @@ Float_t AliTRDcalibDB::GetVdriftAverage(Int_t det)
   // Returns the average drift velocity for the given detector
   //
 
-  const AliTRDCalDet* calDet     = dynamic_cast<const AliTRDCalDet*> 
+  const AliTRDCalDet *calDet     = dynamic_cast<const AliTRDCalDet *> 
                                    (GetCachedCDBObject(kIDVdriftChamber));
   if (!calDet) {
     return -1;
@@ -384,24 +389,24 @@ 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*> 
+  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*> 
+  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);
 
 }
 
@@ -412,7 +417,7 @@ Float_t AliTRDcalibDB::GetT0Average(Int_t det)
   // Returns the average t0 for the given detector
   //
 
-  const AliTRDCalDet* calDet     = dynamic_cast<const AliTRDCalDet*> 
+  const AliTRDCalDet *calDet     = dynamic_cast<const AliTRDCalDet *> 
                                    (GetCachedCDBObject(kIDT0Chamber));
   if (!calDet) {
     return -1;
@@ -429,23 +434,23 @@ Float_t AliTRDcalibDB::GetGainFactor(Int_t det, Int_t col, Int_t row)
   // Returns the gain factor for the given pad.
   //
   
-  const AliTRDCalPad* calPad     = dynamic_cast<const AliTRDCalPad*> 
+  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
                                    (GetCachedCDBObject(kIDGainFactorPad));
   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*> 
+  const AliTRDCalDet *calChamber = dynamic_cast<const AliTRDCalDet *> 
                                    (GetCachedCDBObject(kIDGainFactorChamber));
   if (!calChamber) {
     return -1;
   }
 
-  return calChamber->GetValue(det) * roc->GetValue(col, row);
+  return calChamber->GetValue(det) * roc->GetValue(col,row);
 
 }
 
@@ -456,7 +461,7 @@ Float_t AliTRDcalibDB::GetGainFactorAverage(Int_t det)
   // Returns the average gain factor for the given detector
   //
 
-  const AliTRDCalDet* calDet     = dynamic_cast<const AliTRDCalDet*> 
+  const AliTRDCalDet *calDet     = dynamic_cast<const AliTRDCalDet *> 
                                    (GetCachedCDBObject(kIDGainFactorChamber));
   if (!calDet) {
     return -1;
@@ -473,18 +478,18 @@ Float_t AliTRDcalibDB::GetPRFWidth(Int_t det, Int_t col, Int_t row)
   // Returns the PRF width for the given pad.
   //
   
-  const AliTRDCalPad* calPad     = dynamic_cast<const AliTRDCalPad*> 
+  const AliTRDCalPad *calPad     = dynamic_cast<const AliTRDCalPad *> 
                                    (GetCachedCDBObject(kIDPRFWidth));
   if (!calPad) {
     return -1;
   }
 
-  AliTRDCalROC* roc = calPad->GetCalROC(det);
+  AliTRDCalROC       *roc        = calPad->GetCalROC(det);
   if (!roc) {
     return -1;
   }
 
-  return roc->GetValue(col, row);
+  return roc->GetValue(col,row);
 
 }
 
@@ -495,7 +500,7 @@ Float_t AliTRDcalibDB::GetSamplingFrequency()
   // Returns the sampling frequency of the TRD read-out.
   //
   
-  const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> 
+  const AliTRDCalGlobals *calGlobal = dynamic_cast<const AliTRDCalGlobals *> 
                                       (GetCachedCDBObject(kIDGlobals));
   if (!calGlobal) {
     return -1;  
@@ -512,7 +517,7 @@ Int_t AliTRDcalibDB::GetNumberOfTimeBins()
   // Returns the number of time bins which are read-out.
   //
 
-  const AliTRDCalGlobals* calGlobal = dynamic_cast<const AliTRDCalGlobals*> 
+  const AliTRDCalGlobals *calGlobal = dynamic_cast<const AliTRDCalGlobals *> 
                                       (GetCachedCDBObject(kIDGlobals));
   if (!calGlobal) {
     return -1;
@@ -529,18 +534,18 @@ 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*> 
+  const AliTRDCalPadStatus *cal     = dynamic_cast<const AliTRDCalPadStatus *> 
                                       (GetCachedCDBObject(kIDPadStatus));
   if (!cal) {
     return -1;
   }
 
-  const AliTRDCalSingleChamberStatusroc = cal->GetCalROC(det);
+  const AliTRDCalSingleChamberStatus *roc = cal->GetCalROC(det);
   if (!roc) {
     return -1;
   }
 
-  return roc->GetStatus(col, row);
+  return roc->GetStatus(col,row);
 
 }
 
@@ -551,21 +556,13 @@ Char_t AliTRDcalibDB::GetMCMStatus(Int_t det, Int_t col, Int_t row)
   // Returns the status of the given MCM
   //
 
-  // To translate pad column number into MCM number
-  Int_t mcm = ((Int_t) col / 18);
-
-  const AliTRDCalMCMStatus* cal     = dynamic_cast<const AliTRDCalMCMStatus*> 
+  const AliTRDCalMCMStatus *cal     = dynamic_cast<const AliTRDCalMCMStatus *> 
                                       (GetCachedCDBObject(kIDMCMStatus));
   if (!cal) {
     return -1;
   }
 
-  const AliTRDCalSingleChamberStatus* roc = cal->GetCalROC(det);
-  if (!roc) {
-    return -1;
-  }
-
-  return roc->GetStatus(mcm, row);
+  return cal->GetStatus(det,col,row);
 
 }
 
@@ -576,7 +573,7 @@ Char_t AliTRDcalibDB::GetChamberStatus(Int_t det)
   // Returns the status of the given chamber
   //
 
-  const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> 
+  const AliTRDCalChamberStatus *cal = dynamic_cast<const AliTRDCalChamberStatus *> 
                                       (GetCachedCDBObject(kIDChamberStatus));
   if (!cal) {
     return -1;
@@ -593,7 +590,7 @@ Char_t AliTRDcalibDB::GetSuperModuleStatus(Int_t sm)
   // Returns the status of the given chamber
   //
 
-  const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> 
+  const AliTRDCalSuperModuleStatus *cal = dynamic_cast<const AliTRDCalSuperModuleStatus *> 
                                           (GetCachedCDBObject(kIDSuperModuleStatus));
   if (!cal) {
     return -1;
@@ -610,13 +607,13 @@ Bool_t AliTRDcalibDB::IsPadMasked(Int_t det, Int_t col, Int_t row)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalPadStatus* cal     = dynamic_cast<const AliTRDCalPadStatus*> 
-                                      (GetCachedCDBObject(kIDPadStatus));
+  const AliTRDCalPadStatus         *cal = dynamic_cast<const AliTRDCalPadStatus *> 
+                                          (GetCachedCDBObject(kIDPadStatus));
   if (!cal) {
     return -1;
   }
 
-  return cal->IsMasked(det, col, row);
+  return cal->IsMasked(det,col,row);
 
 }
 
@@ -627,13 +624,13 @@ Bool_t AliTRDcalibDB::IsPadBridgedLeft(Int_t det, Int_t col, Int_t row)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalPadStatus* cal     = dynamic_cast<const AliTRDCalPadStatus*> 
-                                      (GetCachedCDBObject(kIDPadStatus));
+  const AliTRDCalPadStatus         *cal = dynamic_cast<const AliTRDCalPadStatus *> 
+                                          (GetCachedCDBObject(kIDPadStatus));
   if (!cal) {
     return -1;
   }
 
-  return cal->IsBridgedLeft(det, col, row);
+  return cal->IsBridgedLeft(det,col,row);
 
 }
 
@@ -644,13 +641,13 @@ Bool_t AliTRDcalibDB::IsPadBridgedRight(Int_t det, Int_t col, Int_t row)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalPadStatus* cal     = dynamic_cast<const AliTRDCalPadStatus*> 
-                                      (GetCachedCDBObject(kIDPadStatus));
+  const AliTRDCalPadStatus         * cal = dynamic_cast<const AliTRDCalPadStatus *> 
+                                           (GetCachedCDBObject(kIDPadStatus));
   if (!cal) {
     return -1;
   }
 
-  return cal->IsBridgedRight(det, col, row);
+  return cal->IsBridgedRight(det,col,row);
 
 }
 
@@ -661,13 +658,13 @@ Bool_t AliTRDcalibDB::IsMCMMasked(Int_t det, Int_t col, Int_t row)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalMCMStatus* cal     = dynamic_cast<const AliTRDCalMCMStatus*> 
-                                      (GetCachedCDBObject(kIDMCMStatus));
+  const AliTRDCalMCMStatus         * cal = dynamic_cast<const AliTRDCalMCMStatus *> 
+                                           (GetCachedCDBObject(kIDMCMStatus));
   if (!cal) {
     return -1;
   }
 
-  return cal->IsMasked(det, col, row);
+  return cal->IsMasked(det,col,row);
 
 }
 
@@ -678,8 +675,8 @@ Bool_t AliTRDcalibDB::IsChamberInstalled(Int_t det)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> 
-                                      (GetCachedCDBObject(kIDChamberStatus));
+  const AliTRDCalChamberStatus     * cal = dynamic_cast<const AliTRDCalChamberStatus *> 
+                                           (GetCachedCDBObject(kIDChamberStatus));
   if (!cal) {
     return -1;
   }
@@ -695,8 +692,8 @@ Bool_t AliTRDcalibDB::IsChamberMasked(Int_t det)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalChamberStatus* cal = dynamic_cast<const AliTRDCalChamberStatus*> 
-                                      (GetCachedCDBObject(kIDChamberStatus));
+  const AliTRDCalChamberStatus     * cal = dynamic_cast<const AliTRDCalChamberStatus *> 
+                                           (GetCachedCDBObject(kIDChamberStatus));
   if (!cal) {
     return -1;
   }
@@ -712,8 +709,8 @@ Bool_t AliTRDcalibDB::IsSuperModuleInstalled(Int_t det)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> 
-                                          (GetCachedCDBObject(kIDSuperModuleStatus));
+  const AliTRDCalSuperModuleStatus * cal = dynamic_cast<const AliTRDCalSuperModuleStatus *> 
+                                           (GetCachedCDBObject(kIDSuperModuleStatus));
   if (!cal) {
     return -1;
   }
@@ -729,8 +726,8 @@ Bool_t AliTRDcalibDB::IsSuperModuleMasked(Int_t det)
   // Returns status, see name of functions for details ;-)
   //
 
-  const AliTRDCalSuperModuleStatus* cal = dynamic_cast<const AliTRDCalSuperModuleStatus*> 
-                                          (GetCachedCDBObject(kIDSuperModuleStatus));
+  const AliTRDCalSuperModuleStatus * cal = dynamic_cast<const AliTRDCalSuperModuleStatus *> 
+                                           (GetCachedCDBObject(kIDSuperModuleStatus));
   if (!cal) {
     return -1;
   }
@@ -746,7 +743,7 @@ const AliTRDCalPIDLQ* AliTRDcalibDB::GetPIDLQObject()
   // Returns the object storing the distributions for PID with likelihood
   //
 
-  return dynamic_cast<const AliTRDCalPIDLQ*> (GetCachedCDBObject(kIDPIDLQ));
+  return dynamic_cast<const AliTRDCalPIDLQ *> (GetCachedCDBObject(kIDPIDLQ));
 
 }
 
@@ -757,30 +754,25 @@ 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));
+   
 }
 
 //_____________________________________________________________________________
-Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift)
+Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift, Float_t bz)
 {
   //
-  // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vd> 
-  // and a B-field <b> for Xe/CO2 (15%).
+  // Returns omega*tau (tan(Lorentz-angle)) for a given drift velocity <vdrift
+  // and a B-field <bz> for Xe/CO2 (15%).
   // The values are according to a GARFIELD simulation.
   //
-  // This function basically does not belong to the calibration class. It should be moved somewhere else. 
+  // This function basically does not belong to the calibration class.
+  // It should be moved somewhere else. 
   // However, currently it is in use by simulation and reconstruction.
   //
   
-  AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
-  if (!commonParam)
-    return -1;
-  Float_t fieldAbs = TMath::Abs(commonParam->GetField());
-  Float_t fieldSgn = 1.0;
-  if (fieldAbs > 0.0) {
-    fieldSgn = commonParam->GetField() / fieldAbs;
-  }
+  Float_t fieldAbs = TMath::Abs(bz);
+  Float_t fieldSgn = (bz > 0.0) ? 1.0 : -1.0;
 
   const Int_t kNb = 5;
   Float_t p0[kNb] = {  0.004810,  0.007412,  0.010252,  0.013409,  0.016888 };
@@ -788,16 +780,27 @@ Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift)
   Float_t p2[kNb] = { -0.008682, -0.012896, -0.016987, -0.020880, -0.024623 };
   Float_t p3[kNb] = {  0.000155,  0.000238,  0.000330,  0.000428,  0.000541 };
 
-  Int_t ib = ((Int_t) (10 * (fieldAbs - 0.15)));
-  ib       = TMath::Max(  0,ib);
-  ib       = TMath::Min(kNb,ib);
+  // No ExB if field is too small (or zero)
+  if (fieldAbs < 0.01) {
 
-  Float_t alphaL = p0[ib] 
-                 + p1[ib] * vdrift
-                 + p2[ib] * vdrift*vdrift
-                 + p3[ib] * vdrift*vdrift*vdrift;
+    return 0.0;
 
-  return TMath::Tan(fieldSgn * alphaL);
+  }
+  // Calculate ExB from parametrization
+  else {
+
+    Int_t ib = ((Int_t) (10 * (fieldAbs - 0.15)));
+    ib       = TMath::Max(  0,ib);
+    ib       = TMath::Min(kNb,ib);
+
+    Float_t alphaL = p0[ib] 
+                   + p1[ib] * vdrift
+                   + p2[ib] * vdrift*vdrift
+                   + p3[ib] * vdrift*vdrift*vdrift;
+
+    return TMath::Tan(fieldSgn * alphaL);
+
+  }
 
 }