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

BField.h

Go to the documentation of this file.
00001 
00002 // $Id: BField.h,v 1.24 2009/09/16 16:55:44 rhatcher Exp $
00003 //
00004 // BField
00005 //
00006 // This is the code that the end-user would normally see
00007 // It takes care of dealing with geometry (in/out of steel), 
00008 // plane chemistry, getting coil current corrections applied, etc.
00009 // It uses BfldHandler to do the search of the node list (BfldMesh, which
00010 // might be a Voronoi structure) and interpolation of values (in the 
00011 // BfldMap structure).
00012 //
00013 // Author:  R. Hatcher 2000.06.20
00014 //
00016 #ifndef BFIELD_H
00017 #define BFIELD_H
00018 
00019 #include "TVector3.h"
00020 
00021 #include "BField/BfldGrid.h"
00022 #include "BField/BfldInterpMethod.h"
00023 
00024 #include "Validity/VldContext.h"
00025 #include "Validity/VldRange.h"
00026 #include "UgliGeometry/Ugli.h"
00027 
00028 class BfldHandler;
00029 class BfldCache;
00030 class BfldMap;
00031 class BfldLoanPool;
00032 class BfldDbiPlaneMap;
00033 
00034 class BField : public TObject {
00035 
00036  public:
00037    BField();
00038    BField(VldContext vldc, Int_t coarseness = -1, Int_t useEverywhere=0);
00039    // copy ctor and assignment
00040    BField(const BField& that);
00041    BField& operator=(const BField& that);
00042    // dtor
00043    virtual ~BField();
00044 
00046    virtual TVector3 GetBField(TVector3& position, Bool_t isUVZ=false);
00047 
00051    virtual void  ResetVldContext(const VldContext& vldc);
00052 
00053    virtual void  SetInterpMethod(BfldInterpMethod::InterpMethod_t method);
00054 
00055    virtual void  SetGridHandler(Detector::Detector_t detector, 
00056                                 Int_t coarseness);
00057 
00058    // NOTE: the DoLocalTranform,InZTest,ZTolerance are a properties 
00059    // of the BfldCache which might be shared amongst various BField objects. 
00060    Int_t         GetDoLocalTransform() const;
00061    Int_t         GetRequireInZTest() const;
00062    Double_t      GetZTolerance() const;
00063    void          SetDoLocalTransform(Int_t iflg);
00064    void          SetRequireInZTest(Int_t ival);
00065    void          SetZTolerance(Double_t zeps);
00066 
00067    // unshared configuration flags
00068    void  SetDoBHCorrection(Int_t ival)     { fDoBHCorrection     = ival; }
00069    void  SetDoSlotCorrection(Int_t ival)   { fDoSlotCorrection   = ival; }
00070    void  SetDoInterPlaneField(Int_t ival)  { fDoInterPlaneField  = ival; }
00071    void  SetDoSMGapAndEndField(Int_t ival) { fDoSMGapAndEndField = ival; }
00072    void  SetUseDCSCoilDir(Int_t ival)      { fUseDCSCoilDir      = ival; }
00073    void  SetUseDCSCurrent(Int_t ival)      { fUseDCSCurrent      = ival; }
00074 
00075    Int_t GetDoBHCorrection()     const { return fDoBHCorrection;     }
00076    Int_t GetDoSlotCorrection()   const { return fDoSlotCorrection;   }
00077    Int_t GetDoInterPlaneField()  const { return fDoInterPlaneField;  }
00078    Int_t GetDoSMGapAndEndField() const { return fDoSMGapAndEndField; }
00079    Int_t GetUseDCSCoilDir()      const { return fUseDCSCoilDir;      }
00080    Int_t GetUseDCSCurrent()      const { return fUseDCSCurrent;      }
00081 
00082    // ugly hack, shouldn't be needed anymore
00083    void          SetNoFieldBeyondZ(Double_t z) { fNoFieldBeyondZ = z; }
00084    Double_t      GetNoFieldBeyondZ()     const { return fNoFieldBeyondZ; }
00085 
00086    void  Print(Option_t *option="") const;
00087    VldContext GetVldContext() const { return fVldContext; }
00088    VldRange   GetVldRange() const { return fVldRange; }
00089 
00090  protected:
00091 
00092    void Init();
00093    void InitFlagsFromLoanPool();
00094    void FindSteelFromZ(Float_t z) const;
00095 
00096    BfldMap* SetupHandlerForMap(Int_t mapVariant);
00097 
00098    void ApplySlotFactorCorr(TVector3& b);
00099    void ApplyBHFactorCorr(TVector3& b);
00100    void ApplyBHCurveCorr(TVector3& b);
00101 
00102    TVector3 BFromLineSource(TVector3& posRelCoil, Double_t current);
00103 
00104    TVector3 SMGapAndEndField(const TVector3& pos, Ugli::SMRegion_t iregion);
00105    TVector3 SMGapAndEndFieldNear(const TVector3& pos, Ugli::SMRegion_t iregion);
00106    TVector3 SMGapAndEndFieldFar(const TVector3& pos, Ugli::SMRegion_t iregion);
00107    
00108    Bool_t                 fNoField;         // short cut for CalDet
00109    VldContext             fVldContext;      // validity used for ctor
00110    VldRange               fVldRange;        // validity parameters
00111    BfldGrid::Grid_t       fGrid;            // mesh grid to be used
00112 
00113    BfldLoanPool          *fLoanPool;        // look this up just once
00114    BfldHandler           *fHandler;         // created upon instantiation
00115    BfldCache             *fCache;           // owned by loanpool
00116                                             // various schemes might
00117                                             // have more than one of these
00118 
00119    // these may be needed by special case handling (coil, SM gap, interplane)
00120    Bool_t                 fPositionIsUVZ;   // passed into GetBField
00121    Bool_t                 fPowerOff;        // was power off?
00122    Bool_t                 fDegaussed;       // I=0 has two cases
00123    Double_t               fCoilCurrent;     // current current
00124 
00125    const BfldDbiPlaneMap *fCurrentPlaneMap; // last plane info
00126    BfldDbiPlaneMap       *fOwnedPlaneMap;   // scratch area
00127    Int_t                  fLastMapVariant;  // avoid any unnecessary re-init
00128 
00129    // various configuration flags
00130    Int_t                  fDoBHCorrection;
00131    Int_t                  fDoSlotCorrection;
00132    Int_t                  fDoInterPlaneField;
00133    // 0 = no field outside steel
00134    // 1 = use detail map if in that region
00135    //     use full map if it exists, or line current if not
00136    // 2 = like 1, except always use line current outside detail
00137    // 3 = use detail map if in that region, otherwise zero
00138 
00139    Int_t                  fDoSMGapAndEndField; 
00140    // if  0 no SM check just use gap map (if InterPlaneField)
00141    // if <0 do SM check, but return 0 always
00142    // if >0 do SM check, try some method for getting field
00143 
00144    Int_t                  fUseDCSCoilDir;
00145    //       CoilTools::IsReverse()    abs(BfldDbiPlaneMap scale signs)
00146    //   0       no                         no
00147    //   1       yes                        yes
00148    //   2       yes                        no
00149    //   3       no                         yes
00150    
00151    Int_t                  fUseDCSCurrent;
00152    //  scales field by DCS (ACNET for Near) current readback
00153    //  bypasses CoilTools::IsOK() test
00154 
00155    Int_t                  fGapLineSrc;
00156    // 0 = no line src,  1 = central line src,  3 = central + return line src
00157 
00158    Int_t                  fApplyBdotScale;
00159 
00160    // this is a temporary ruse used to bypass linkage to the geometry
00161    // during the development ... it should _not_ remain in final code
00162    // (nor should its use in the ctor).
00163    Int_t                  fUseEverywhere;   // which map to use everywhere
00164 
00165    // another crazy hack to deal with one SM w/ field and one without
00166    // and geometry lookup adding too much time
00167    Double_t               fNoFieldBeyondZ;
00168 
00169  private:
00170 
00171    ClassDef(BField,0)
00172 };
00173 
00174 inline TVector3 BField::SMGapAndEndField(const TVector3& pos, 
00175                                          Ugli::SMRegion_t iregion)
00176 {
00177   Detector::Detector_t det = fVldContext.GetDetector();
00178   switch (det) {
00179   case Detector::kNear: return SMGapAndEndFieldNear(pos,iregion);
00180   case Detector::kFar:  return SMGapAndEndFieldFar(pos,iregion);
00181   default:              return TVector3(0,0,0);
00182   }
00183 }
00184 
00185 #endif // BFIELD_H

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