]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDcalibDB.cxx
Added new classes TPointSelector and TPointSelectorConsumer allowing more natural...
[u/mrichter/AliRoot.git] / TRD / AliTRDcalibDB.cxx
index 2bbd584d49c7c09e73b90cbf27921cddce6236b6..46de3e4b747ba20fd9d1544dfd48a3208d4c94ca 100644 (file)
 
 #include "Cal/AliTRDCalROC.h"
 
-#include "Cal/AliTRDCalChamberPos.h"
-#include "Cal/AliTRDCalStackPos.h"
-#include "Cal/AliTRDCalSuperModulePos.h"
-
 #include "Cal/AliTRDCalPad.h"
 #include "Cal/AliTRDCalDet.h"
 #include "Cal/AliTRDCalGlobals.h"
@@ -70,7 +66,7 @@ AliTRDcalibDB* AliTRDcalibDB::Instance()
 
   if (fgInstance == 0)
     fgInstance = new AliTRDcalibDB();
-  
+
   return fgInstance;
 }
 
@@ -100,7 +96,7 @@ AliTRDcalibDB::AliTRDcalibDB()
   
   // TODO Default runnumber is set to 0, this should be changed later to an invalid value (e.g. -1) to prevent
   // TODO invalid calibration data to be used.
-  fRun = 0;
+  fRun = -1;
   
   fPadResponse.fPRFbin             = 0;
   fPadResponse.fPRFlo              = 0.0;
@@ -108,16 +104,7 @@ AliTRDcalibDB::AliTRDcalibDB()
   fPadResponse.fPRFwid             = 0.0;
   fPadResponse.fPRFpad             = 0;
   fPadResponse.fPRFsmp             = 0;
-    
-  AliCDBManager* manager = AliCDBManager::Instance();
-  if (!manager)
-  {
-    std::cout << "AliTRDcalibDB: CRITICAL: Failed to get instance of AliCDBManager." << std::endl;
-    fLocator = 0;
-  }
-  else
-    fLocator = manager->GetStorage("local://$ALICE_ROOT");
-  
+
   for (Int_t i=0; i<kCDBCacheSize; ++i)
   {
     fCDBCache[i] = 0;
@@ -183,9 +170,6 @@ const TObject* AliTRDcalibDB::GetCachedCDBObject(Int_t id)
       // global parameters
       case kIDMonitoringData : return CacheCDBEntry(kIDMonitoringData, "TRD/Calib/MonitoringData"); break;
       case kIDGlobals : return CacheCDBEntry(kIDGlobals, "TRD/Calib/Globals"); break;
-      case kIDSuperModulePos : return CacheCDBEntry(kIDSuperModulePos, "TRD/Calib/SuperModulePos"); break;
-      case kIDChamberPos : return CacheCDBEntry(kIDChamberPos, "TRD/Calib/ChamberPos"); break;
-      case kIDStackPos : return CacheCDBEntry(kIDStackPos, "TRD/Calib/StackPos"); break;
       case kIDPIDLQ : return CacheCDBEntry(kIDPIDLQ, "TRD/Calib/PIDLQ"); break;
     }
     return 0;
@@ -198,19 +182,8 @@ AliCDBEntry* AliTRDcalibDB::GetCDBEntry(const char* cdbPath)
   // Retrieves an entry with path <cdbPath> from the CDB.
   //
     
-  if (fRun < 0)
-  {
-    AliFatal("AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun.");
-    //std::cerr << "AliTRDcalibDB: Run number not set! Use AliTRDcalibDB::SetRun." << std::endl;
-    return 0;
-  }
-  if (!fLocator) 
-  { 
-    std::cerr << "AliTRDcalibDB: Storage Locator not available." << std::endl; 
-    return 0; 
-  } 
-  AliCDBEntry* entry = fLocator->Get(cdbPath, fRun); 
-  if (!entry) 
+  AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun);
+  if (!entry)
   { 
     std::cerr << "AliTRDcalibDB: Failed to get entry: " << cdbPath << std::endl; 
     return 0; 
@@ -262,148 +235,19 @@ void AliTRDcalibDB::Invalidate()
   {
     if (fCDBEntries[i])
     {
-      if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i])
-        delete fCDBCache[i];
-      
-      delete fCDBEntries[i];
+      if (AliCDBManager::Instance()->GetCacheFlag() == kFALSE)
+      {
+        if (fCDBEntries[i]->IsOwner() == kFALSE && fCDBCache[i])
+          delete fCDBCache[i];
+
+        delete fCDBEntries[i];
+      }
       fCDBEntries[i] = 0;
       fCDBCache[i] = 0;
     }
   }
 }
 
-//_____________________________________________________________________________
-Bool_t AliTRDcalibDB::GetChamberPos(Int_t det, Float_t* xyz)
-{
-  //
-  // Returns the deviation of the chamber position from the nominal position.
-  //
-  
-  const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamberPos));
-  if (!chamber)
-    return kFALSE;
-  
-  const Float_t* kvalues = chamber->GetPos(det);
-  if (!kvalues)
-    return kFALSE;
-
-  xyz[0] = kvalues[0];
-  xyz[1] = kvalues[1];
-  xyz[2] = kvalues[2];
-  
-  return kTRUE;
-}
-
-//_____________________________________________________________________________
-Bool_t AliTRDcalibDB::GetChamberRot(Int_t det, Float_t* xyz)
-{
-  //
-  // Returns the rotation of the chamber from the nominal position.
-  //
-  
-  const AliTRDCalChamberPos* chamber = dynamic_cast<const AliTRDCalChamberPos*>(GetCachedCDBObject(kIDChamberPos));
-  if (!chamber)
-    return kFALSE;
-  
-  const Float_t* kvalues = chamber->GetRot(det);
-  if (!kvalues)
-    return kFALSE;
-  
-  xyz[0] = kvalues[0];
-  xyz[1] = kvalues[1];
-  xyz[2] = kvalues[2];
-  
-  return kTRUE;
-}
-
-//_____________________________________________________________________________
-Bool_t AliTRDcalibDB::GetStackPos(Int_t chamber, Int_t sector, Float_t* xyz)
-{
-  //
-  // Returns the deviation of the stack position from the nominal position.
-  //
-  
-  const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStackPos));
-  if (!stack)
-    return kFALSE;
-  
-  const Float_t* kvalues = stack->GetPos(chamber, sector);
-  if (!kvalues)
-    return kFALSE;
-  
-  xyz[0] = kvalues[0];
-  xyz[1] = kvalues[1];
-  xyz[2] = kvalues[2];
-  
-  return kTRUE;
-}
-
-//_____________________________________________________________________________
-Bool_t AliTRDcalibDB::GetStackRot(Int_t chamber, Int_t sector, Float_t* xyz)
-{
-  //
-  // Returns the rotation of the stack from the nominal position.
-  //
-  
-  const AliTRDCalStackPos* stack = dynamic_cast<const AliTRDCalStackPos*>(GetCachedCDBObject(kIDStackPos));
-  if (!stack)
-    return kFALSE;
-  
-  const Float_t* kvalues = stack->GetRot(chamber, sector);
-  if (!kvalues)
-    return kFALSE;
-
-  xyz[0] = kvalues[0];
-  xyz[1] = kvalues[1];
-  xyz[2] = kvalues[2];
-  
-  return kTRUE;
-}
-
-//_____________________________________________________________________________
-Bool_t AliTRDcalibDB::GetSuperModulePos(Int_t sm, Float_t* xyz)
-{
-  //
-  // Returns the deviation of the supermodule position from the nominal position.
-  //
-  
-  const AliTRDCalSuperModulePos* smPos = dynamic_cast<const AliTRDCalSuperModulePos*>(GetCachedCDBObject(kIDSuperModulePos));
-  if (!smPos)
-    return kFALSE;
-  
-  const Float_t* kvalues = smPos->GetPos(sm);
-  if (!kvalues)
-    return kFALSE;
-  
-  xyz[0] = kvalues[0];
-  xyz[1] = kvalues[1];
-  xyz[2] = kvalues[2];
-  
-  return kTRUE;
-}
-
-//_____________________________________________________________________________
-Bool_t AliTRDcalibDB::GetSuperModuleRot(Int_t sm, Float_t* xyz)
-{
-  //
-  // Returns the rotation of the supermodule from the nominal position.
-  //
-  
-  const AliTRDCalSuperModulePos* smPos = dynamic_cast<const AliTRDCalSuperModulePos*>(GetCachedCDBObject(kIDSuperModulePos));
-  if (!smPos)
-    return kFALSE;
-  
-  const Float_t* kvalues = smPos->GetRot(sm);
-  if (!kvalues)
-    return kFALSE;
-  
-  xyz[0] = kvalues[0];
-  xyz[1] = kvalues[1];
-  xyz[2] = kvalues[2];
-  
-  return kTRUE;
-}
-
 //_____________________________________________________________________________
 Float_t AliTRDcalibDB::GetVdrift(Int_t det, Int_t col, Int_t row)
 {
@@ -769,7 +613,11 @@ Float_t AliTRDcalibDB::GetOmegaTau(Float_t vdrift)
   AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
   if (!commonParam)
     return -1;
-  Float_t field = commonParam->GetField();
+  Float_t fieldAbs = TMath::Abs(commonParam->GetField());
+  Float_t fieldSgn = 1.0;
+  if (fieldAbs > 0.0) {
+    fieldSgn = commonParam->GetField() / fieldAbs;
+  }
 
   const Int_t kNb = 5;
   Float_t p0[kNb] = {  0.004810,  0.007412,  0.010252,  0.013409,  0.016888 };
@@ -777,16 +625,17 @@ 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 * (field - 0.15)));
+  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;
+                 + p1[ib] * vdrift
+                 + p2[ib] * vdrift*vdrift
+                 + p3[ib] * vdrift*vdrift*vdrift;
+
+  return TMath::Tan(fieldSgn * alphaL);
 
-  return TMath::Tan(alphaL);
 }
 
 //_____________________________________________________________________________