LCOV - code coverage report
Current view: top level - TPC/TPCbase - AliTPCExBBShape.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 16 89 18.0 %
Date: 2016-06-14 17:26:59 Functions: 3 12 25.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /// \class AliTPCExBBShape
      17             : /// \brief AliTPCExBBShape class
      18             : 
      19             : #include <AliMagF.h>
      20             : #include "TGeoGlobalMagField.h"
      21             : #include "AliTPCcalibDB.h"
      22             : #include "AliTPCParam.h"
      23             : #include "AliLog.h"
      24             : 
      25             : #include "AliTPCExBBShape.h"
      26             : 
      27             : AliTPCExBBShape::AliTPCExBBShape()
      28           3 :   : AliTPCCorrection("exb_bshape","ExB B-shape"),
      29           3 :     fC1(0.),fC2(0.),
      30           3 :     fScaling(1.),
      31           3 :     fBField(0)
      32          15 : {
      33             :   /// default constructor
      34             : 
      35           6 : }
      36             : 
      37           0 : AliTPCExBBShape::~AliTPCExBBShape() {
      38             :   /// virtual destructor
      39             : 
      40           0 : }
      41             : 
      42             : 
      43             : 
      44             : 
      45             : Bool_t AliTPCExBBShape::AddCorrectionCompact(AliTPCCorrection* corr, Double_t weight){
      46             :   /// Add correction  and make them compact
      47             :   /// Assumptions:
      48             :   ///  - origin of distortion/correction are additive
      49             :   ///  - only correction ot the same type supported ()
      50             : 
      51           0 :   if (corr==NULL) {
      52           0 :     AliError("Zerro pointer - correction");
      53           0 :     return kFALSE;
      54             :   }
      55           0 :   AliTPCExBBShape* corrC = dynamic_cast<AliTPCExBBShape *>(corr);
      56           0 :   if (corrC == NULL) {
      57           0 :     AliError(TString::Format("Inconsistent class types: %s\%s",IsA()->GetName(),corr->IsA()->GetName()).Data());
      58           0 :     return kFALSE;
      59             :   }
      60           0 :   fScaling= weight;
      61             :   //
      62           0 :   return kTRUE;
      63           0 : }
      64             : 
      65             : 
      66             : void AliTPCExBBShape::Init() {
      67             :   /// Initialization funtion
      68             : 
      69          18 :   AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
      70           9 :   if (!magF) AliError("Magneticd field - not initialized");
      71           9 :   Double_t bzField = magF->SolenoidField()/10.; //field in T
      72           9 :   SetBField(magF);
      73           9 :   AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
      74           9 :   if (!param) AliError("Parameters - not initialized");
      75           9 :   Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us]   // From dataBase: to be updated: per second (ideally)
      76             :   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
      77           9 :   Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
      78             :   // Correction Terms for effective omegaTau; obtained by a laser calibration run
      79           9 :   SetOmegaTauT1T2(wt,fT1,fT2);
      80             : 
      81             : 
      82           9 : }
      83             : 
      84             : void AliTPCExBBShape::Update(const TTimeStamp &/*timeStamp*/) {
      85             :   /// Update function
      86             : 
      87           0 :   AliMagF* magF= (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
      88           0 :   if (!magF) AliError("Magneticd field - not initialized");
      89           0 :   Double_t bzField = magF->SolenoidField()/10.; //field in T
      90           0 :   SetBField(magF);
      91           0 :   AliTPCParam *param= AliTPCcalibDB::Instance()->GetParameters();
      92           0 :   if (!param) AliError("Parameters - not initialized");
      93           0 :   Double_t vdrift = param->GetDriftV()/1000000.; // [cm/us]   // From dataBase: to be updated: per second (ideally)
      94             :   Double_t ezField = 400; // [V/cm]   // to be updated: never (hopefully)
      95           0 :   Double_t wt = -10.0 * (bzField*10) * vdrift / ezField ;
      96             :   // Correction Terms for effective omegaTau; obtained by a laser calibration run
      97           0 :   SetOmegaTauT1T2(wt,fT1,fT2);
      98             : 
      99             : 
     100           0 : }
     101             : 
     102             : 
     103             : 
     104             : void AliTPCExBBShape::GetCorrection(const Float_t x[],const Short_t roc,Float_t dx[]) {
     105             :   /// Calculates the space point corrections of the B field inperfections (B field shape)
     106             : 
     107           0 :   if (!fBField) {
     108           0 :     for (Int_t j=0;j<3;++j) dx[j]=0.;
     109           0 :     return;
     110             :   }
     111             : 
     112           0 :   const Double_t xStart[3]={ x[0], x[1], x[2] };
     113           0 :   const Double_t xEnd[3]={ x[0],  x[1],  roc%36<18?fgkTPCZ0:-fgkTPCZ0 };
     114             : 
     115           0 :   Double_t intBStart[3];
     116           0 :   Double_t intBEnd[3];
     117             : 
     118           0 :   fBField->GetTPCRatInt(xStart,intBStart);
     119           0 :   fBField->GetTPCRatInt(xEnd,  intBEnd  );
     120             : 
     121           0 :   const Float_t intBxOverBz=fScaling*(intBEnd[0]-intBStart[0]);
     122           0 :   const Float_t intByOverBz=fScaling*(intBEnd[1]-intBStart[1]);
     123             : 
     124           0 :   dx[0]=fC2*intBxOverBz-fC1*intByOverBz;
     125           0 :   dx[1]=fC1*intBxOverBz+fC2*intByOverBz;
     126           0 :   dx[2]=0.;
     127             : 
     128             : 
     129           0 : }
     130             : 
     131             : void AliTPCExBBShape::GetBxAndByOverBz(const Float_t x[],const Short_t roc,Float_t BxByOverBz[]) {
     132             :   /// This function is purely for calibration purposes
     133             :   /// Returns the via AliMagF obtaind B field integrals
     134             : 
     135           0 :   if (!fBField) {
     136           0 :     for (Int_t j=0;j<3;++j) BxByOverBz[j]=0.;
     137           0 :     return;
     138             :   }
     139             : 
     140           0 :   const Double_t xStart[3]={ x[0], x[1], x[2] };
     141           0 :   const Double_t xEnd[3]={ x[0],  x[1],  roc%36<18?fgkTPCZ0:-fgkTPCZ0 };
     142             : 
     143           0 :   Double_t intBStart[3];
     144           0 :   Double_t intBEnd[3];
     145             : 
     146           0 :   fBField->GetTPCRatInt(xStart,intBStart);
     147           0 :   fBField->GetTPCRatInt(xEnd,  intBEnd  );
     148             : 
     149           0 :   const Float_t intBxOverBz=fScaling*(intBEnd[0]-intBStart[0]);
     150           0 :   const Float_t intByOverBz=fScaling*(intBEnd[1]-intBStart[1]);
     151             : 
     152           0 :   BxByOverBz[0]=intBxOverBz;
     153           0 :   BxByOverBz[1]=intByOverBz;
     154             : 
     155           0 : }
     156             : 
     157             : void AliTPCExBBShape::Print(Option_t* option) const {
     158             :   /// Print function to check the settings (e.g. voltage offsets)
     159             :   /// option=="a" prints details of the B field settings and the
     160             :   /// C0 and C1 coefficents (for calibration purposes)
     161             : 
     162           0 :   TString opt = option; opt.ToLower();
     163           0 :   printf("%s\t%s\n - B field settings:\n",GetTitle(),GetName());
     164           0 :   fBField->Print(option);
     165             :   //  printf(" - B field: X-Twist: %1.5lf rad, Y-Twist: %1.5lf rad \n",fBField->Print(option));
     166           0 :   if (opt.Contains("a")) { // Print all details
     167           0 :     printf(" - T1: %1.4f, T2: %1.4f \n",fT1,fT2);
     168           0 :     printf(" - C1: %1.4f, C2: %1.4f \n",fC1,fC2);
     169             :   }
     170           0 : }
     171             : 
     172             : Double_t AliTPCExBBShape::GetBFieldXYZ(Double_t gx, Double_t gy, Double_t gz, Int_t axisType){
     173             :   /// return B field at given x,y,z
     174             : 
     175           0 :   AliMagF* field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
     176           0 :   if (!field) return 0;
     177           0 :   Double_t xyz[3]={gx,gy,gz};
     178           0 :   Double_t bxyz[3]={0};
     179           0 :   field->Field(xyz,bxyz);
     180             :   //
     181           0 :   Double_t r=TMath::Sqrt(gx*gx+gy*gy);
     182             :   //  Double_t b=TMath::Sqrt(bxyz[0]*bxyz[0]+bxyz[1]*bxyz[1]);
     183           0 :   if (axisType==0) {
     184           0 :     return (xyz[0]*bxyz[1]-xyz[1]*bxyz[0])/(bxyz[2]*r);
     185             :   }
     186           0 :   if (axisType==1){
     187           0 :     return (xyz[0]*bxyz[0]+xyz[1]*bxyz[1])/(bxyz[2]*r);
     188             :   }
     189           0 :   if (axisType==2) return bxyz[2];
     190           0 :   if (axisType==3) return bxyz[0];
     191           0 :   if (axisType==4) return bxyz[1];
     192           0 :   if (axisType==5) return bxyz[2];
     193             :   return bxyz[2];
     194           0 : }

Generated by: LCOV version 1.11