00001
00002
00003
00004
00005
00006
00007
00008
00009
00011 #include "BField/BField.h"
00012
00013 #include "BField/BfldLoanPool.h"
00014 #include "BField/BfldHandlerRect2d.h"
00015 #include "BField/BfldHandlerVoronoi.h"
00016 #include "BField/BfldCache.h"
00017 #include "BField/BfldMap.h"
00018 #include "DcsUser/CoilTools.h"
00019
00020 #include "TMath.h"
00021
00022 #include "MessageService/MsgService.h"
00023 CVSID("$Id: BField.cxx,v 1.39 2009/09/16 16:55:44 rhatcher Exp $");
00024
00025 ClassImp(BField)
00026
00027 #include <cassert>
00028 #include <iomanip>
00029
00030 const Int_t kNoMapUsed = -9999;
00031 static const TVector3 zeroBfld(0.,0.,0.);
00032
00033 #if 0
00034 static std::ostream& operator<<(std::ostream& os, const TVector3& tv3)
00035 {
00036 int w=9, p=4;
00037 int prec = os.precision();
00038 os << "[" << setw(w) << setprecision(p) << tv3.x()
00039 << "," << setw(w) << setprecision(p) << tv3.y()
00040 << "," << setw(w+1) << setprecision(p) << tv3.z()
00041 << "]";
00042 os << resetiosflags(ios::floatfield);
00043 os << setprecision(prec);
00044 return os;
00045 }
00046 #endif
00047
00048
00049 BField::BField()
00050 : fLoanPool(0), fHandler(0), fCache(0),
00051 fCurrentPlaneMap(0), fOwnedPlaneMap(0)
00052
00053 {
00054
00055 Init();
00056 InitFlagsFromLoanPool();
00057 fNoField = true;
00058 }
00059
00060
00061 BField::BField(VldContext vldc, Int_t coarseness, Int_t useEverywhere)
00062 : fNoField(false), fVldContext(vldc), fLoanPool(0), fHandler(0), fCache(0),
00063 fPowerOff(false), fDegaussed(false), fCoilCurrent(0),
00064 fCurrentPlaneMap(0), fOwnedPlaneMap(0)
00065 {
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 Init();
00076 InitFlagsFromLoanPool();
00077 fUseEverywhere = useEverywhere;
00078
00079
00080 VldTimeStamp start = VldTimeStamp::GetBOT();
00081 VldTimeStamp end = VldTimeStamp::GetEOT();
00082 fVldRange = VldRange(vldc.GetDetector(),
00083 vldc.GetSimFlag(),
00084 start,
00085 end,
00086 "fake");
00087
00088 if (vldc.GetDetector() == Detector::kCalDet) {
00089 fNoField = true;
00090 return;
00091 }
00092
00093
00094
00095
00096 SetGridHandler(vldc.GetDetector(),coarseness);
00097
00098
00099
00100 int forceEverywhere = fLoanPool->GetForceUseEverywhere();
00101 if (forceEverywhere) {
00102 if ( forceEverywhere == 1 ) {
00103
00104
00105 forceEverywhere = BfldCache::GetDefaultMapVariant(fVldContext);
00106 MAXMSG("Bfld",Msg::kInfo,5)
00107 << "Bfield::ctor BfldLoanPool forceUseEverywhere=1"
00108 << " yields map " << forceEverywhere << " for "
00109 << endl << " " << vldc.AsString("c") << "."
00110 << endl;
00111 }
00112 MAXMSG("Bfld",Msg::kInfo,5)
00113 << "BField::ctor useEverywhere was " << fUseEverywhere
00114 << ", forced by BfldLoanPool config to use "
00115 << forceEverywhere << "."
00116 << endl;
00117 fUseEverywhere = forceEverywhere;
00118 }
00119
00120
00121
00122
00123 if (fUseEverywhere) {
00124 int ignore = fLoanPool->GetIgnoreUseEverywhere();
00125 MAXMSG("Bfld",Msg::kInfo,5)
00126 << "BField::ctor useEverywhere=" << fUseEverywhere
00127 << ((ignore)?" (now ignored)":" (active)") << "."
00128 << endl;
00129 if (ignore) fUseEverywhere = 0;
00130 else {
00131
00132 fOwnedPlaneMap->SetMapVariant(0,fUseEverywhere);
00133 fOwnedPlaneMap->SetScale(0,1.0);
00134 fVldContext = VldContext();
00135 MAXMSG("Bfld",Msg::kInfo,5)
00136 << "BField::ctor setting fake VldContext to avoid "
00137 << "pulling geometry tables from DBI."
00138 << endl;
00139 }
00140 }
00141
00142
00143
00144 ResetVldContext(vldc);
00145
00146 }
00147
00148
00149 BField::BField(const BField& that)
00150 : TObject(that)
00151 {
00152
00153 *this = that;
00154 }
00155
00156
00157 BField& BField::operator=(const BField& that)
00158 {
00159
00160
00161 if ( this == &that ) return *this;
00162 TObject::operator=(that);
00163
00164
00165 fLoanPool = 0;
00166 if (fHandler) { delete fHandler; fHandler = 0; }
00167 if (fCache) { fCache->DecrementRef(); fCache = 0; }
00168
00169 Init();
00170
00171
00172 fNoField = that.fNoField;
00173 fVldContext = that.fVldContext;
00174 fVldRange = that.fVldRange;
00175 fLastMapVariant = that.fLastMapVariant;
00176
00177 fDoBHCorrection = that.fDoBHCorrection;
00178 fDoSlotCorrection = that.fDoSlotCorrection;
00179 fDoInterPlaneField = that.fDoInterPlaneField;
00180 fDoSMGapAndEndField = that.fDoSMGapAndEndField;
00181
00182 fUseDCSCoilDir = that.fUseDCSCoilDir;
00183 fUseDCSCurrent = that.fUseDCSCurrent;
00184 fGapLineSrc = that.fGapLineSrc;
00185 fApplyBdotScale = that.fApplyBdotScale;
00186
00187 fUseEverywhere = that.fUseEverywhere;
00188 fNoFieldBeyondZ = that.fNoFieldBeyondZ;
00189
00190
00191 if ( that.fCache ) {
00192 fCache = that.fCache;
00193 fCache->IncrementRef();
00194 }
00195 else {
00196
00197 assert(0);
00198 }
00199
00200
00201 Int_t coarseness = BfldGrid::GetCoarseness(that.fGrid);
00202
00203
00204 SetGridHandler(fVldContext.GetDetector(),coarseness);
00205
00206 fHandler->SetCache(fCache);
00207 fHandler->SetLastPolygAsSeed();
00208
00209 return *this;
00210 }
00211
00212
00213 void BField::ResetVldContext(const VldContext& vldc)
00214 {
00215
00216
00217 fVldContext = vldc;
00218 Detector::Detector_t det = vldc.GetDetector();
00219
00220 VldTimeStamp start = VldTimeStamp::GetBOT();
00221 VldTimeStamp end = VldTimeStamp::GetEOT();
00222 fVldRange = VldRange(det,vldc.GetSimFlag(),start,end,"");
00223
00224 if (!fHandler) SetGridHandler(vldc.GetDetector(),-1);
00225
00226 if (fCache) fCache->DecrementRef();
00227
00228
00229 fCache = fLoanPool->GetCache(fVldContext);
00230 fCache->IncrementRef();
00231 fVldRange.TrimTo(fCache->GetVldRange());
00232
00233 fHandler->SetCache(fCache);
00234 fHandler->SetLastPolygAsSeed();
00235
00236 fNoField = false;
00237 fPowerOff = false;
00238 fDegaussed = false;
00239
00240
00241
00242
00243
00244
00245 switch (fVldContext.GetDetector()) {
00246
00247 case Detector::kNear:
00248 fCoilCurrent = 40.0 * 1000.;
00249 if ( fUseDCSCurrent ) {
00250 std::pair<Float_t,Float_t> currents = CoilTools::CoilCurrent(vldc);
00251 fCoilCurrent = 8.0 * TMath::Abs(currents.first);
00252 }
00253 break;
00254 case Detector::kFar:
00255 fCoilCurrent = 15.2 * 1000.;
00256 if ( fUseDCSCurrent ) {
00257 std::pair<Float_t,Float_t> currents = CoilTools::CoilCurrent(vldc);
00258 Float_t avg_cur = 0.5 * (currents.first+currents.second);
00259 fCoilCurrent = 190 * TMath::Abs(avg_cur);
00260 }
00261 break;
00262 default:
00263 fCoilCurrent = 0.0;
00264 fNoField = true;
00265 }
00266
00267
00268
00269 if (fUseDCSCoilDir == 1 || fUseDCSCoilDir == 2 ) {
00270 if ( ! fUseDCSCurrent && ! CoilTools::IsOK(vldc)) fCoilCurrent = 0.0;
00271 else if (CoilTools::IsReverse(vldc)) fCoilCurrent = -fCoilCurrent;
00272 }
00273 }
00274
00275
00276 void BField::Init()
00277 {
00278
00279 fNoField = false;
00280 fVldRange = VldRange();
00281 fGrid = BfldGrid::kUndefined;
00282 fLastMapVariant = kNoMapUsed;
00283 fUseEverywhere = 0;
00284
00285
00286 if (!fLoanPool) fLoanPool = BfldLoanPool::Instance();
00287
00288 if (fOwnedPlaneMap) { delete fOwnedPlaneMap; fOwnedPlaneMap = 0; }
00289 fOwnedPlaneMap = new BfldDbiPlaneMap;
00290 }
00291
00292
00293 void BField::InitFlagsFromLoanPool()
00294 {
00295
00296
00297
00298 if (!fLoanPool) fLoanPool = BfldLoanPool::Instance();
00299
00300 fDoBHCorrection = fLoanPool->GetDefaultDoBHCorrection();
00301 fDoSlotCorrection = fLoanPool->GetDefaultDoSlotCorrection();
00302 fDoInterPlaneField = fLoanPool->GetDefaultDoInterPlaneField();
00303 fDoSMGapAndEndField = fLoanPool->GetDefaultDoSMGapAndEndField();
00304
00305 fUseDCSCoilDir = fLoanPool->GetDefaultUseDCSCoilDir();
00306 fUseDCSCurrent = fLoanPool->GetDefaultUseDCSCurrent();
00307 fGapLineSrc = fLoanPool->GetDefaultGapLineSrc();
00308 fApplyBdotScale = fLoanPool->GetDefaultApplyBdotScale();
00309
00310 fNoFieldBeyondZ = fLoanPool->GetDefaultNoFieldBeyondZ();
00311 }
00312
00313
00314 BField::~BField()
00315 {
00316
00317
00318 if (fHandler) { delete fHandler; fHandler = 0; }
00319
00320 if (fCache) { fCache->DecrementRef(); fCache = 0; }
00321 if (fOwnedPlaneMap) { delete fOwnedPlaneMap; fOwnedPlaneMap = 0; }
00322
00323 }
00324
00325
00326 void BField::SetInterpMethod(BfldInterpMethod::InterpMethod_t method)
00327 {
00328
00329 if (fHandler) fHandler->SetInterpMethod(method);
00330 }
00331
00332
00333 void BField::SetGridHandler(Detector::Detector_t detector, Int_t coarseness)
00334 {
00335
00336 fGrid = BfldGrid::GetGrid(detector,coarseness);
00337
00338
00339 if (fHandler) { delete fHandler; fHandler = 0; }
00340
00341
00342 if ( BfldGrid::kRect2dGrid == fGrid ) {
00343
00344 fHandler = new BfldHandlerRect2d;
00345 } else {
00346 fHandler = new BfldHandlerVoronoi;
00347 }
00348
00349
00350
00351 SetInterpMethod(BfldInterpMethod::kDefault);
00352
00353 fLastMapVariant = kNoMapUsed;
00354
00355 }
00356
00357
00358 TVector3 BField::GetBField(TVector3& posGlobal, Bool_t isUVZ)
00359 {
00360
00361
00362
00363
00364 if (fNoField) return zeroBfld;
00365
00366 if (posGlobal.Z() > fNoFieldBeyondZ ) return zeroBfld;
00367
00368
00369 fPositionIsUVZ = isUVZ;
00370
00371 bool isPosSteelUVZ = isUVZ;
00372 int doLocalTransform = 0;
00373
00374 if ( fDegaussed && fCoilCurrent == 0 ) return zeroBfld;
00375
00376 bool was_in_steel = true;
00377
00378
00379 if (fUseEverywhere) {
00380
00381 MAXMSG("Bfld",Msg::kWarning,4)
00382 << "BField::GetBField no coil region handling or " << endl
00383 << "map selection based on plane with useEverywhere="
00384 << fUseEverywhere << "."
00385 << endl;
00386 fCurrentPlaneMap = fOwnedPlaneMap;
00387
00388 } else {
00389
00390
00391
00392
00393
00394
00395 if ( fDoSMGapAndEndField ) {
00396 Ugli::SMRegion_t ismregion = fCache->InSMRegion(posGlobal,isUVZ);
00397 if ( ismregion != Ugli::kInSM1 && ismregion != Ugli::kInSM2 ) {
00398
00399 if ( fDoSMGapAndEndField < 0 ) return zeroBfld;
00400 return SMGapAndEndField(posGlobal,ismregion);
00401 }
00402 }
00403
00404
00405 fCurrentPlaneMap = fCache->FindPlaneMap(posGlobal);
00406 was_in_steel = fCache->FindWasInSteel(true);
00407
00408
00409 if ( ! fCurrentPlaneMap ) {
00410
00411
00412 Int_t imap = BfldCache::GetDefaultMapVariant(fVldContext);
00413 Double_t scale = BfldCache::GetDefaultScale(fVldContext);
00414 MAXMSG("Bfld",Msg::kWarning,5)
00415 << "GetDefault(MapVariant,Scale) returned ("
00416 << imap << "," << scale << ")"
00417 << ", called because missing BfldDbiPlaneMap?"
00418 << endl;
00419 fOwnedPlaneMap->SetMapVariant(0,imap);
00420 fOwnedPlaneMap->SetScale(0,scale);
00421 fCurrentPlaneMap = fOwnedPlaneMap;
00422 }
00423 }
00424
00425
00426 Int_t indxpair = BfldDbiPlaneMap::kFullSteelA;
00427
00428 TVector3 posSteel(posGlobal);
00429 doLocalTransform = fCache->GetDoLocalTransform();
00430 if (doLocalTransform > 0) {
00431 posSteel = fCache->GetPositionInSteel();
00432
00433 }
00434 bool indetail = fCurrentPlaneMap->IsInDetail(posSteel.x(),posSteel.y());
00435
00436 if ( ! was_in_steel ) {
00437
00438
00439
00440
00441 if ( 0 == fDoInterPlaneField ) return zeroBfld;
00442 indxpair = BfldDbiPlaneMap::kDetailGapA;
00443 if ( ! indetail ) {
00444
00445 if ( 3 == fDoInterPlaneField ) return zeroBfld;
00446 indxpair = BfldDbiPlaneMap::kFullGapA;
00447
00448 if (fCurrentPlaneMap->IsPairNull(indxpair) ||
00449 2 == fDoInterPlaneField) {
00450 TVector3 blinesrc(0,0,0);
00451 if ( fGapLineSrc & 1 ) {
00452 TVector3 posCoil = posSteel;
00453 blinesrc += BFromLineSource(posCoil,fCoilCurrent);
00454 }
00455 if ( fGapLineSrc & 2 ) {
00456 TVector3 posRelRtnCoil = posGlobal;
00457
00458 switch ( fVldContext.GetDetector() ) {
00459 case Detector::kNear:
00460 posRelRtnCoil -= TVector3(-1.9,-1.9,0);
00461 break;
00462 case Detector::kFar:
00463 posRelRtnCoil -= TVector3( 0.0,-4.8,0);
00464 break;
00465 default:
00466 posRelRtnCoil = TVector3(999.,999.,999.);
00467 break;
00468 }
00469
00470 blinesrc += BFromLineSource(posRelRtnCoil,-fCoilCurrent);
00471 }
00472 return blinesrc;
00473 }
00474 }
00475 } else {
00476
00477
00478
00479
00480 if ( fPowerOff ) indxpair = BfldDbiPlaneMap::kPowerOffA;
00481 else if ( indetail ) {
00482 indxpair = BfldDbiPlaneMap::kDetailSteelA;
00483 if (fCurrentPlaneMap->IsPairNull(indxpair))
00484 indxpair = BfldDbiPlaneMap::kFullSteelA;
00485 }
00486 }
00487
00488 Bool_t isnull[2];
00489 isnull[0] = fCurrentPlaneMap->IsNull(indxpair);
00490 isnull[1] = fCurrentPlaneMap->IsNull(indxpair+1);
00491
00492 Double_t coilCurrMap[2] = { 0, 0 };
00493
00494 if ( isnull[0] && isnull[1] ) return zeroBfld;
00495
00496 TVector3 bfieldSum(zeroBfld);
00497
00498 for (UInt_t iv = 0; iv<2; ++iv) {
00499
00500 if ( isnull[iv] ) continue;
00501
00502
00503
00504 Int_t mapVariant = fCurrentPlaneMap->GetMapVariant(indxpair+iv);
00505 Double_t scaleMap = fCurrentPlaneMap->GetScale(indxpair+iv);
00506
00507 if ( (fUseDCSCoilDir&1) ) scaleMap = TMath::Abs(scaleMap);
00508
00509
00510 if (mapVariant == 0) {
00511 MAXMSG("Bfld",Msg::kInfo,5)
00512 << "BField mapVariant=0 indxpair=" << indxpair << " iv=" << iv
00513 << " isnull=" << (isnull[iv]?"true":"false")
00514 << " scaleMap=" << scaleMap
00515 << endl;
00516 MAXMSG("Bfld",Msg::kInfo,5) << *fCurrentPlaneMap << endl;
00517 continue;
00518 }
00519
00520 BfldMap* bmap = SetupHandlerForMap(mapVariant);
00521
00522 coilCurrMap[iv] = bmap->GetGeneratedCoilCurrent();
00523 Double_t scaleCoil = fCoilCurrent/coilCurrMap[iv];
00524
00525 Double_t scale = scaleCoil * scaleMap;
00526
00527
00528
00529
00530
00531 bfieldSum += (scale*fHandler->GetBField(posSteel,isPosSteelUVZ));
00532
00533 }
00534
00535 if ( was_in_steel && doLocalTransform > 1 ) {
00536
00537
00538
00539 UgliSteelPlnHandle usph = fCache->GetCurrentSteelPlnHandle();
00540 bfieldSum = usph.LocalToGlobalVect(bfieldSum,true);
00541 }
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551 if ( fDoSlotCorrection ) ApplySlotFactorCorr(bfieldSum);
00552 if ( fDoBHCorrection < 0 ) ApplyBHFactorCorr(bfieldSum);
00553 else if ( fDoBHCorrection > 0 ) ApplyBHCurveCorr(bfieldSum);
00554
00555 if ( fApplyBdotScale ) {
00556
00557 if ( indxpair < BfldDbiPlaneMap::kDetailGapA ) {
00558 Double_t bdot = fCurrentPlaneMap->GetBdotScale();
00559
00560 if (bdot == 0.0) {
00561 MAXMSG("Bfld",Msg::kWarning,5)
00562 << " BdotScale was zero for plane " << fCurrentPlaneMap->GetPlaneId()
00563 << "." << endl;
00564 } else {
00565 bfieldSum *= bdot;
00566 }
00567 }
00568 }
00569
00570 return bfieldSum;
00571 }
00572
00573
00574 BfldMap* BField::SetupHandlerForMap(Int_t mapVariant)
00575 {
00576
00577
00578 if ( fLastMapVariant != mapVariant ) {
00579
00580
00581
00582
00583
00584 BfldMap *bmap = fLoanPool->GetMap(fGrid,mapVariant);
00585 fHandler->SetMap(bmap);
00586
00587
00588
00589 BfldMesh *mesh = fLoanPool->GetMesh(fGrid,mapVariant);
00590 fHandler->SetMesh(mesh);
00591
00592
00593 fLastMapVariant = mapVariant;
00594
00595 }
00596
00597 return fHandler->GetMap();
00598 }
00599
00600
00601 void BField::ApplySlotFactorCorr(TVector3& b)
00602 {
00603
00604
00605
00606
00607
00608
00609
00610
00611 #ifdef DEBUG
00612 MAXMSG("Bfld",Msg::kInfo,20)
00613 << "ApplySlotFactorCorr "
00614 << " SlotFactor " << fCurrentPlaneMap->GetSlotFactor()
00615 << " SlotCutoff " << fCurrentPlaneMap->GetSlotCutoff()
00616 << " mag " << b.Mag()
00617 << endl;
00618 #endif
00619
00620 Double_t slotfactor = fCurrentPlaneMap->GetSlotFactor();
00621 if ( slotfactor == 0 ) return;
00622
00623 Double_t slotcutoff = fCurrentPlaneMap->GetSlotCutoff();
00624 if ( slotcutoff == 0 ) return;
00625
00626 Double_t magbfld = b.Mag();
00627 if ( magbfld > slotcutoff ) return;
00628
00629 Double_t inner = 1.0 - magbfld/slotcutoff;
00630 Double_t slotscale = 1.0 - slotfactor * inner*inner;
00631
00632 #ifdef DEBUG
00633 MAXMSG("Bfld",Msg::kInfo,20)
00634 << "ApplySlotFactorCorr " << magbfld << " " << slotscale << endl;
00635 #endif
00636
00637
00638 b *= slotscale;
00639 }
00640
00641
00642 void BField::ApplyBHFactorCorr(TVector3& b)
00643 {
00644
00645
00646
00647
00648
00649
00650
00651
00652 #ifdef DEBUG
00653 MAXMSG("Bfld",Msg::kInfo,20)
00654 << "ApplyBHFactorCorr "
00655 << " BHFactor " << fCurrentPlaneMap->GetBHFactor()
00656 << " BHCutoff " << fCurrentPlaneMap->GetBHCutoff()
00657 << " mag " << b.Mag()
00658 << endl;
00659 #endif
00660
00661 Double_t bhfactor = fCurrentPlaneMap->GetBHFactor();
00662 if ( bhfactor == 0 ) return;
00663
00664 Double_t bhcutoff = fCurrentPlaneMap->GetBHCutoff();
00665 if ( bhcutoff == 0 ) return;
00666
00667 Double_t magbfld = b.Mag();
00668 if ( magbfld > bhcutoff) return;
00669
00670 Double_t bhscale = 1.0;
00671 if ( magbfld > bhcutoff/3.0 ) {
00672 bhscale = 1.0 + bhfactor * ( 1.0 - magbfld/bhcutoff );
00673 }
00674 else {
00675 bhscale = 1.0 + (2.0/3.0)*bhfactor*magbfld/bhcutoff;
00676 }
00677
00678 #ifdef DEBUG
00679 MAXMSG("Bfld",Msg::kInfo,20)
00680 << "ApplyBhFactorCorr " << bhscale << endl;
00681 #endif
00682
00683
00684 b *= bhscale;
00685 }
00686
00687
00688 void BField::ApplyBHCurveCorr(TVector3& )
00689 {
00690
00691 MAXMSG("Bfld",Msg::kWarning,20)
00692 << "BField::ApplyBHCurveCorr not yet implemented!"
00693 << endl;
00694
00695 }
00696
00697
00698 TVector3 BField::BFromLineSource(TVector3& posRelCoil, Double_t current)
00699 {
00700
00701
00702 static double lastcurrent = 9999;
00703 if (lastcurrent != current) {
00704 MAXMSG("Bfld",Msg::kInfo,5)
00705 << "BFromLineSource current is " << current << endl;
00706 lastcurrent = current;
00707 }
00708
00709
00710 const Double_t u0by2pi = 12.566370614e-7 / (2.0 * TMath::Pi());
00711
00712 Double_t r = posRelCoil.Perp();
00713
00714 r = TMath::Max(r,Munits::cm);
00715 Double_t brbyr = ( u0by2pi * current / r )/r;
00716 Double_t bx = posRelCoil.Y() * brbyr;
00717 Double_t by = -posRelCoil.X() * brbyr;
00718 return TVector3(bx,by,0.0);
00719
00720 }
00721
00722
00723 TVector3 BField::SMGapAndEndFieldNear(const TVector3& position,
00724 Ugli::SMRegion_t iregion)
00725 {
00726
00727
00728
00729 int w=9, p=4;
00730 int prec = cout.precision();
00731 MAXMSG("Bfld",Msg::kWarning,20)
00732 << "BField::SMGapAndEndFieldNear "
00733 << endl
00734 << "not yet implemented for SMRegion " << Ugli::AsString(iregion) << " @ "
00735 << "[" << setw(w) << setprecision(p) << position.x()
00736 << "," << setw(w) << setprecision(p) << position.y()
00737 << "," << setw(w+1) << setprecision(p) << position.z()
00738 << "]"
00739 << resetiosflags(ios::floatfield)
00740 << setprecision(prec)
00741 << endl;
00742 return zeroBfld;
00743
00744 }
00745
00746
00747 TVector3 BField::SMGapAndEndFieldFar(const TVector3& position,
00748 Ugli::SMRegion_t iregion)
00749 {
00750
00751
00752
00753
00754 int w=9, p=4;
00755 int prec = cout.precision();
00756 MAXMSG("Bfld",Msg::kWarning,20)
00757 << "BField::SMGapAndEndFieldFar "
00758 << endl
00759 << "not yet implemented for SMRegion " << Ugli::AsString(iregion) << " @ "
00760 << "[" << setw(w) << setprecision(p) << position.x()
00761 << "," << setw(w) << setprecision(p) << position.y()
00762 << "," << setw(w+1) << setprecision(p) << position.z()
00763 << "]"
00764 << resetiosflags(ios::floatfield)
00765 << setprecision(prec)
00766 << endl;
00767 return zeroBfld;
00768
00769 }
00770
00771
00772
00773 Int_t BField::GetDoLocalTransform() const
00774 { return fCache->GetDoLocalTransform(); }
00775
00776 Int_t BField::GetRequireInZTest() const
00777 { return fCache->GetRequireInZTest(); }
00778
00779 Double_t BField::GetZTolerance() const
00780 { return fCache->GetZTolerance(); }
00781
00782 void BField::SetDoLocalTransform(Int_t iflg)
00783 {
00784
00785
00786 fCache->SetDoLocalTransform(iflg);
00787 }
00788
00789 void BField::SetRequireInZTest(Int_t ival)
00790 {
00791
00792
00793 fCache->SetRequireInZTest(ival);
00794 }
00795
00796 void BField::SetZTolerance(Double_t zeps)
00797 {
00798
00799
00800 fCache->SetZTolerance(zeps);
00801 }
00802
00803
00804
00805 void BField::Print(Option_t * ) const
00806 {
00807
00808
00809 MSG("Bfld",Msg::kInfo)
00810 << "BField: created from VldContext " << fVldContext
00811 << endl << " VldRange: " << fVldRange << endl;
00812 MSG("Bfld",Msg::kInfo)
00813 << " Co-ords: " << (fPositionIsUVZ?"UVZ":"XYZ")
00814 << ", NoField: " << (fNoField?"yes":"no")
00815 << endl
00816 << " Power: " << (fPowerOff?"off":"on")
00817 << ", Degaussed: " << (fDegaussed?"yes":"no")
00818 << ", Current: " << fCoilCurrent
00819 << endl
00820 << " UseDCSCoilDir: " << fUseDCSCoilDir
00821 << ", UseDCSCurrent: " << fUseDCSCurrent
00822 << ", GapLineSrc: " << fGapLineSrc
00823 << ", InterPlaneField: " << fDoInterPlaneField
00824 << ", SMGapAndEndField: " << fDoSMGapAndEndField
00825 << ", ApplyBdotScale: " << (fApplyBdotScale?"yes":"no")
00826 << endl
00827 << " BHCorr: " << fDoBHCorrection
00828 << ", SlotCorr: " << fDoSlotCorrection
00829 << endl;
00830 if (fGrid)
00831 MSG("Bfld",Msg::kInfo)
00832 << " Grid: " << BfldGrid::AsString(fGrid) << endl;
00833 if (fCache) {
00834 MSG("Bfld",Msg::kInfo) << " BfldCache: ";
00835 fCache->Print();
00836 }
00837 if (fHandler) {
00838 MSG("Bfld",Msg::kInfo) << " Handler: ";
00839 fHandler->Print();
00840 }
00841 }
00842
00843