00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00040 BField(const BField& that);
00041 BField& operator=(const BField& that);
00042
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
00059
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
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
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;
00109 VldContext fVldContext;
00110 VldRange fVldRange;
00111 BfldGrid::Grid_t fGrid;
00112
00113 BfldLoanPool *fLoanPool;
00114 BfldHandler *fHandler;
00115 BfldCache *fCache;
00116
00117
00118
00119
00120 Bool_t fPositionIsUVZ;
00121 Bool_t fPowerOff;
00122 Bool_t fDegaussed;
00123 Double_t fCoilCurrent;
00124
00125 const BfldDbiPlaneMap *fCurrentPlaneMap;
00126 BfldDbiPlaneMap *fOwnedPlaneMap;
00127 Int_t fLastMapVariant;
00128
00129
00130 Int_t fDoBHCorrection;
00131 Int_t fDoSlotCorrection;
00132 Int_t fDoInterPlaneField;
00133
00134
00135
00136
00137
00138
00139 Int_t fDoSMGapAndEndField;
00140
00141
00142
00143
00144 Int_t fUseDCSCoilDir;
00145
00146
00147
00148
00149
00150
00151
00152 Int_t fUseDCSCurrent;
00153
00154
00155
00156 Int_t fGapLineSrc;
00157
00158
00159 Int_t fApplyBdotScale;
00160
00161 Double_t fOverallScale;
00162
00163
00164
00165
00166
00167 Int_t fUseEverywhere;
00168
00169
00170
00171 Double_t fNoFieldBeyondZ;
00172
00173 private:
00174
00175 ClassDef(BField,0)
00176 };
00177
00178 inline TVector3 BField::SMGapAndEndField(const TVector3& pos,
00179 Ugli::SMRegion_t iregion)
00180 {
00181 Detector::Detector_t det = fVldContext.GetDetector();
00182 switch (det) {
00183 case Detector::kNear: return SMGapAndEndFieldNear(pos,iregion);
00184 case Detector::kFar: return SMGapAndEndFieldFar(pos,iregion);
00185 default: return TVector3(0,0,0);
00186 }
00187 }
00188
00189 #endif // BFIELD_H