]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCExBBShape.cxx
Added some extra scripts.
[u/mrichter/AliRoot.git] / TPC / AliTPCExBBShape.cxx
index 09ffbd5bad69967dd248108927884a43d4fcd105..9f95e82321c1a69fd663394e65d0a248c9078a8a 100644 (file)
  **************************************************************************/
 
 ////////////////////////////////////////////////////////////////////////////
-//                                                                        //
-// AliExBBShape class                                                     //
-// The class calculates the space point distortions due to the B field    //
-// shape imperfections using a second order technique based on integrals  //
-// over Bz (e.g. int By/Bz) obtained via the AliMagF class                //
-// The class allows "effective Omega Tau" corrections.                    //
-//                                                                        //
-// date: 27/04/2010                                                       //
-// Authors: Magnus Mager, Jim Thomas, Stefan Rossegger                    //
-//                                                                        //
-// Example usage:                                                         //
-//  AliMagF mag("mag","mag");                                             //
-//  AliTPCExBBShape exb;                                                  //
-//  exb.SetBField(&mag);             // use Bfield from AliMagF           //
-//  exb.SetOmegaTauT1T2(0.32,1.,1.); // values ideally from OCDB          //
-//  // plot dRPhi distortions ...                                         //
-//  exb.CreateHistoDRPhiinZR(0,100,100)->Draw("surf2");                   //
+// AliTPCExBBShape class                                                  //
 ////////////////////////////////////////////////////////////////////////////
 
 #include <AliMagF.h>
+#include "TGeoGlobalMagField.h"
+#include "AliTPCcalibDB.h"
+#include "AliTPCParam.h"
+#include "AliLog.h"
 
 #include "AliTPCExBBShape.h"
 
@@ -55,27 +43,20 @@ AliTPCExBBShape::~AliTPCExBBShape() {
 
 void AliTPCExBBShape::Init() {
   //
-  // Initialization funtion (not used at the moment)
+  // Initialization funtion
   //
   
-  // Set default parameters
-  // FIXME: Ask the database for these entries
-  
-
-  AliMagF * mag = new AliMagF("mag","mag"); // from database (GRP?)
-  SetBField(mag);
-
-  Double_t vdrift = 2.6; // [cm/us]   // From dataBase: to be updated: per second (ideally)
-  Double_t bzField = -0.5; // [Tesla] // From dataBase: to be updated: per run
-
+  AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+  if (!magF) AliError("Magneticd field - not initialized");
+  Double_t bzField = magF->SolenoidField()/10.; //field in T
+  SetBField(magF);
+  AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
+  if (!param) AliError("Parameters - not initialized");
+  Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us]   // From dataBase: to be updated: per second (ideally)
   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
   Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ; 
-
   // Correction Terms for effective omegaTau; obtained by a laser calibration run
-  Double_t t1 = 0.9;   // ideally from database
-  Double_t t2 = 1.5;   // ideally from database
-
-  SetOmegaTauT1T2(wt,t1,t2);
+  SetOmegaTauT1T2(wt,fT1,fT2);
 
 
 }
@@ -84,18 +65,17 @@ void AliTPCExBBShape::Update(const TTimeStamp &/*timeStamp*/) {
   //
   // Update function 
   //
-
-  Double_t vdrift = 2.6; // [cm/us]   // From dataBase: to be updated: per second (ideally)
-  Double_t bzField = -0.5; // [Tesla] // From dataBase: to be updated: per run
-
+  AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+  if (!magF) AliError("Magneticd field - not initialized");
+  Double_t bzField = magF->SolenoidField()/10.; //field in T
+  SetBField(magF);
+  AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
+  if (!param) AliError("Parameters - not initialized");
+  Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us]   // From dataBase: to be updated: per second (ideally)
   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
   Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ; 
-
   // Correction Terms for effective omegaTau; obtained by a laser calibration run
-  Double_t t1 = 0.9;   // ideally from database
-  Double_t t2 = 1.5;   // ideally from database
-
-  SetOmegaTauT1T2(wt,t1,t2);
+  SetOmegaTauT1T2(wt,fT1,fT2);
 
 
 }
@@ -113,7 +93,7 @@ void AliTPCExBBShape::GetCorrection(const Float_t x[],const Short_t roc,Float_t
   }
 
   const Double_t xStart[3]={ x[0], x[1], x[2] };
-  const Double_t xEnd[3]={ x[0],  x[1],  roc%36<18?fgkTPC_Z0:-fgkTPC_Z0 };
+  const Double_t xEnd[3]={ x[0],  x[1],  roc%36<18?fgkTPCZ0:-fgkTPCZ0 };
 
   Double_t intBStart[3];
   Double_t intBEnd[3];
@@ -143,7 +123,7 @@ void AliTPCExBBShape::GetBxAndByOverBz(const Float_t x[],const Short_t roc,Float
   }
 
   const Double_t xStart[3]={ x[0], x[1], x[2] };
-  const Double_t xEnd[3]={ x[0],  x[1],  roc%36<18?fgkTPC_Z0:-fgkTPC_Z0 };
+  const Double_t xEnd[3]={ x[0],  x[1],  roc%36<18?fgkTPCZ0:-fgkTPCZ0 };
 
   Double_t intBStart[3];
   Double_t intBEnd[3];
@@ -166,11 +146,36 @@ void AliTPCExBBShape::Print(Option_t* option) const {
   // C0 and C1 coefficents (for calibration purposes)
   //
   TString opt = option; opt.ToLower();
-  printf("%s\n - B field settings:\n",GetTitle());
+  printf("%s\t%s\n - B field settings:\n",GetTitle(),GetName());
   fBField->Print(option);
   //  printf(" - B field: X-Twist: %1.5lf rad, Y-Twist: %1.5lf rad \n",fBField->Print(option));
-  if (opt.Contains("a")) { // Print all details
+  if (opt.Contains("a")) { // Print all details  
+    printf(" - T1: %1.4f, T2: %1.4f \n",fT1,fT2);
     printf(" - C1: %1.4f, C2: %1.4f \n",fC1,fC2);
   }    
+}
+
+Double_t AliTPCExBBShape::GetBFieldXYZ(Double_t gx, Double_t gy, Double_t gz, Int_t axisType){
+  //
+  // return B field at given x,y,z
+  // 
+  AliMagF* field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+  if (!field) return 0;
+  Double_t xyz[3]={gx,gy,gz};
+  Double_t bxyz[3]={0};
+  field->Field(xyz,bxyz);
+  //
+  Double_t r=TMath::Sqrt(gx*gx+gy*gy);
+  //  Double_t b=TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
+  if (axisType==0) {
+    return (xyz[0]*bxyz[1]-xyz[1]*bxyz[0])/(bxyz[2]*r);
+  }
+  if (axisType==1){
+    return (xyz[0]*bxyz[0]+xyz[1]*bxyz[1])/(bxyz[2]*r);
+  }
+  if (axisType==2) return bxyz[2];
+  if (axisType==3) return bxyz[0];
+  if (axisType==4) return bxyz[1];
+  if (axisType==5) return bxyz[2];
+  return bxyz[2];
 }