Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BfldHandler.cxx

Go to the documentation of this file.
00001 
00002 // $Id: BfldHandler.cxx,v 1.10 2007/12/13 16:58:42 rhatcher Exp $
00003 // 
00004 // BfldHandler 
00005 // 
00006 // BfldHandler searches and interpolates BfldMesh (position info) structures
00007 // (field values are in BfldMap).
00008 //
00009 // Author:  R. Hatcher 2000.06.20
00010 //
00012 
00013 #include "BField/BfldHandler.h"
00014 
00015 #include "BField/BfldMap.h"
00016 #include "BField/BfldMesh.h"
00017 
00018 #include "TMath.h"
00019 
00020 #include "MessageService/MsgService.h"
00021 CVSID("$Id: BfldHandler.cxx,v 1.10 2007/12/13 16:58:42 rhatcher Exp $");
00022 
00023 ClassImp(BfldHandler)
00024 
00025 //_____________________________________________________________________________
00026 BfldHandler::BfldHandler()
00027    : fInterpMethod(BfldInterpMethod::kDefault), fUseLastAsSeed(kTRUE),
00028      fCache(0), fMap(0), fMesh(0)
00029 {
00030    // base handler ctor
00031    // clear basic components
00032 }
00033 
00034 //_____________________________________________________________________________
00035 BfldHandler::~BfldHandler()
00036 {
00037    // tell the held map and mesh that this handler no longer 
00038    // has need of them
00039    if (fMap)  fMap->DecrementRef();
00040    if (fMesh) fMesh->DecrementRef();
00041 }
00042 
00043 //_____________________________________________________________________________
00044 TVector3 BfldHandler::GetBField(const TVector3& position, Bool_t isUVZ)
00045 {
00046    // Return the field for the requested position.
00047    // Translate (if necessary) the position before passing it
00048    // to the workhorse routine, translate back if necessary.
00049 
00050    //MAXMSG("Bfld",Msg::kVerbose,5)
00051    //  << "GetBField pos=(" << position.x() << "," << position.y() << ")" << endl;
00052    if ( isUVZ == fMesh->GetIsUVZ() ) return GetBFieldMeshCoord(position);
00053 
00054    // mismatch ... do some work
00055    // we don't need to know the detector since only both NearDet & FarDet
00056    // use the same rotation .
00057    // (only CalDet doesn't and it has UVZ=XYZ, but it never has a field)
00058 
00059    MAXMSG("Bfld",Msg::kVerbose,5)
00060      << "BfldHandler::GetBField passed isUVZ= "
00061      << (isUVZ?"yes":"no")
00062      << " which didn't match Mesh."
00063      << endl;
00064 
00065    static const double kInvSqrt2 = TMath::Sqrt(0.5);
00066    if ( isUVZ ) {
00067      // position is UVZ, so mesh must be XYZ, but return B_uvz
00068      Double_t  u = position[0];
00069      Double_t  v = position[1];
00070      Double_t  z = position[2];
00071      TVector3  xyz(kInvSqrt2*(u-v),kInvSqrt2*(u+v),z);
00072      TVector3 bxyz = GetBFieldMeshCoord(xyz);
00073      Double_t bx = bxyz[0];
00074      Double_t by = bxyz[1];
00075      Double_t bz = bxyz[2];
00076      return TVector3(kInvSqrt2*(by+bx),kInvSqrt2*(by-bx),bz);
00077    }
00078    else {
00079      // position is XYZ, so mesh must be UVZ, but return B_xyz
00080      Double_t  x = position[0];
00081      Double_t  y = position[1];
00082      Double_t  z = position[2];
00083      TVector3  uvz(kInvSqrt2*(x+y),kInvSqrt2*(y-x),z);
00084      TVector3 buvz = GetBFieldMeshCoord(uvz);
00085      Double_t bu = buvz[0];
00086      Double_t bv = buvz[1];
00087      Double_t bz = buvz[2];
00088      return TVector3(kInvSqrt2*(bu-bv),kInvSqrt2*(bu+bv),bz);
00089    }
00090 }
00091 
00092 //_____________________________________________________________________________
00093 void BfldHandler::SetInterpMethod(const BfldInterpMethod::InterpMethod_t method) 
00094 {
00095    // set the interpolation method for this handler
00096    // specialized handler versions should override the 
00097    // translation of "kDefault" to their optimal choice
00098    // and should also disallow illegal choices
00099 
00100    BfldInterpMethod::InterpMethod_t chosen = method;
00101 
00102    if (BfldInterpMethod::kDefault == chosen) {
00103       // pick a default method
00104       // for the generic case we'll choose "kClosest" because
00105       // all approaches should easily support this
00106       chosen = BfldInterpMethod::kClosest;
00107    }
00108 
00109    fInterpMethod = chosen;
00110 }
00111 
00112 //_____________________________________________________________________________
00113 void BfldHandler::SetMap(BfldMap* bmap)
00114 {
00115    // tell this handler about the map
00116 
00117    if (fMap) fMap->DecrementRef();
00118    fMap = bmap;
00119    fMap->IncrementRef();
00120 }
00121 
00122 //_____________________________________________________________________________
00123 void BfldHandler::SetMesh(BfldMesh* mesh)
00124 {
00125    // tell this handler about the map
00126 
00127    if (fMesh) fMesh->DecrementRef();
00128    fMesh = mesh;
00129    fMesh->IncrementRef();
00130 }
00131 
00132 //_____________________________________________________________________________

Generated on Mon Feb 15 11:06:25 2010 for loon by  doxygen 1.3.9.1