BfldCache Class Reference

#include <BfldCache.h>

List of all members.

Public Member Functions

 BfldCache ()
 BfldCache (const VldContext &vldc, Dbi::Task task=Dbi::kDefaultTask)
virtual ~BfldCache ()
VldRange GetVldRange () const
const BfldDbiPlaneMapFindPlaneMap (TVector3 &position, Bool_t isUVZ=false)
Bool_t FindWasInSteel (Bool_t lie=true) const
 the next three methods should only be called after FindPlaneMap()
TVector3 GetPositionInSteel () const
UgliSteelPlnHandle GetCurrentSteelPlnHandle () const
Ugli::SMRegion_t InSMRegion (const TVector3 &pos, Bool_t isUVZ)
Ugli::XYRegion_t InXYRegion (const TVector3 &pos, Bool_t isUVZ)
Int_t GetDoLocalTransform () const
Int_t GetRequireInZTest () const
Double_t GetZTolerance () const
void SetDoLocalTransform (Int_t flg)
void SetRequireInZTest (Int_t ival)
void SetZTolerance (Double_t zeps)
virtual void Print (Option_t *option="") const
void IncrementRef ()
void DecrementRef ()
Int_t CountRef ()

Static Public Member Functions

static Int_t GetDefaultMapVariant (const VldContext &vldc)
static Double_t GetDefaultScale (const VldContext &vldc)

Protected Member Functions

void InitFlags ()
void SetSteelAndPlaneMapCache (TVector3 &position, Bool_t isUVZ=false)
void SetSteelLimits ()
void SetPlaneMapCache (PlexPlaneId steelid)
void InvalidateCaches ()
void FillSMZLimits ()

Private Attributes

Detector::Detector_t fDetector
VldRange fVldRange
Int_t fRef
UgliGeomHandle fUgliGeomHandle
 outstanding references
UgliSteelPlnHandle fSteelCache
 reference geometry
Double_t fSteelZmin
 last steel used
Double_t fSteelZmax
 zmin last steel
Int_t fDoLocalTransform
 zmax last steel
Int_t fInZTest
Double_t fZTolerance
DbiResultPtr< BfldDbiPlaneMapfPlaneMaps
 dz tolerance
Int_t fDbiMapEntries
 specifics about each plane
const BfldDbiPlaneMapfPlaneMapCache
 avoid GetNumRows
Bool_t fFindWasInSteel
 last planemap used
TVector3 fPosInSteel
 last position in steel?
Double_t fSMZLimits [4]
 last position in steel
Int_t fWasHigh
Int_t fWasLow
Double_t fSumHigh
Double_t fSumLow

Detailed Description

Definition at line 28 of file BfldCache.h.


Constructor & Destructor Documentation

BfldCache::BfldCache (  ) 

Definition at line 55 of file BfldCache.cxx.

References InitFlags(), Msg::kDebug, and MSG.

00056   : fRef(0), fSteelCache(), fSteelZmin(+9999.), fSteelZmax(-9999.),
00057     fDbiMapEntries(0), fPlaneMapCache(0)
00058 {
00059    MSG("Bfld",Msg::kDebug) << "BfldCache - default ctor" << endl;
00060    InitFlags();
00061 }

BfldCache::BfldCache ( const VldContext vldc,
Dbi::Task  task = Dbi::kDefaultTask 
)

Definition at line 64 of file BfldCache.cxx.

References fDetector, FillSMZLimits(), fPlaneMaps, fUgliGeomHandle, fVldRange, VldContext::GetSimFlag(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), UgliGeomHandle::GetVldRange(), InitFlags(), Msg::kDebug, Msg::kError, Detector::kUnknown, MSG, and VldRange::TrimTo().

00065   : fDetector(vldc.GetDetector()), fRef(0), fUgliGeomHandle(vldc),
00066     fSteelCache(), fSteelZmin(+9999.), fSteelZmax(-9999.), 
00067     fDoLocalTransform(0), fInZTest(0), fZTolerance(0),
00068     fPlaneMaps(vldc,task,Dbi::kDisabled),
00069     fDbiMapEntries(fPlaneMaps.GetNumRows()),
00070     fPlaneMapCache(0), 
00071     fFindWasInSteel(false), fPosInSteel(-999.,-999.,-9999.),
00072     fWasHigh(0), fWasLow(0), fSumHigh(0), fSumLow(0)
00073 {
00074    InitFlags();
00075    fVldRange = fUgliGeomHandle.GetVldRange();
00076    MSG("Bfld",Msg::kError) << " BfldCache vldc " << vldc << " task " << task
00077                           << "  geometry " << fVldRange 
00078                           << endl;
00079    const DbiValidityRec* dbivrec = fPlaneMaps.GetValidityRec();
00080    if (dbivrec) {
00081      fVldRange.TrimTo(dbivrec->GetVldRange());
00082      MSG("Bfld",Msg::kDebug) << "BfldCache range trimed to " 
00083                              << fVldRange << endl;
00084    }
00085 
00086    if ( Detector::kUnknown == fDetector ) {
00087      // this happens for the case of UseEverywhere
00088      VldTimeStamp start = VldTimeStamp(1970, 1, 1, 0, 0, 0);
00089      VldTimeStamp end   = VldTimeStamp(2038, 1,18,19,14, 6);
00090      fVldRange = VldRange(fDetector,
00091                           vldc.GetSimFlag(),
00092                           start,
00093                           end,
00094                           "fake");
00095      MSG("Bfld",Msg::kDebug) << "BfldCache ctor with no detector "  << endl;
00096    }
00097    
00098    FillSMZLimits(); 
00099 }

BfldCache::~BfldCache (  )  [virtual]

Definition at line 121 of file BfldCache.cxx.

References fRef, fSumHigh, fSumLow, fUgliGeomHandle, fWasHigh, fWasLow, UgliGeomHandle::GetVldRange(), Msg::kDebug, Msg::kInfo, and MSG.

00122 {
00123   if (fRef) {
00124     MSG("Bfld",Msg::kInfo) << "~BfldCache with " << fRef 
00125                            << " outstanding references." << endl
00126                            << "     using geometry" 
00127                            << fUgliGeomHandle.GetVldRange() << endl;
00128 
00129   }
00130   MSG("Bfld",Msg::kDebug) << "~BfldCache geometry" 
00131                           << fUgliGeomHandle.GetVldRange() << endl;
00132 
00133   Double_t avgHigh = 0;
00134   if (fWasHigh) avgHigh = fSumHigh/fWasHigh;
00135   Double_t avgLow = 0;
00136   if (fWasLow) avgLow = fSumLow/fWasLow;
00137 
00138   MSG("Bfld",Msg::kInfo) << "~BfldCache " 
00139                          << " z outside steel " 
00140                          << fWasHigh << " high avg=" << avgHigh << ", " 
00141                          << fWasLow << " low avg=" << avgLow << endl;
00142 
00143 
00144 }


Member Function Documentation

Int_t BfldCache::CountRef (  )  [inline]

Definition at line 64 of file BfldCache.h.

References fRef.

Referenced by BfldLoanPool::GetCache().

00064 { return fRef; }

void BfldCache::DecrementRef (  )  [inline]

Definition at line 63 of file BfldCache.h.

References fRef.

Referenced by BField::operator=(), BField::ResetVldContext(), and BField::~BField().

00063 { fRef--; }

void BfldCache::FillSMZLimits (  )  [protected]

Definition at line 306 of file BfldCache.cxx.

References fDetector, fSMZLimits, fUgliGeomHandle, UgliSteelPlnHandle::GetHalfThickness(), UgliGeomHandle::GetSteelPlnHandle(), UgliSteelPlnHandle::GetZ0(), UgliSteelPlnHandle::IsValid(), Detector::kFar, Detector::kNear, PlexPlaneId::LastPlaneFarSM0(), PlexPlaneId::LastPlaneFarSM1(), and PlexPlaneId::LastPlaneNearSpect().

Referenced by BfldCache().

00307 {
00308    // Determine z range of SM
00309 
00310    fSMZLimits[0] = fSMZLimits[2] = -1.0e6;
00311    fSMZLimits[1] = fSMZLimits[3] = +1.0e6;
00312 
00313    int ipln[4] = { 0, 0, 0, 0};
00314 
00315    switch (fDetector) {
00316    case Detector::kFar: 
00317      {
00318        ipln[0] = 0;
00319        ipln[1] = PlexPlaneId::LastPlaneFarSM0();
00320        ipln[2] = PlexPlaneId::LastPlaneFarSM0()+1;
00321        ipln[3] = PlexPlaneId::LastPlaneFarSM1();
00322        break;
00323      }
00324    case Detector::kNear:
00325      {
00326        ipln[0] = 0;
00327        ipln[1] = PlexPlaneId::LastPlaneNearSpect();
00328        ipln[2] = PlexPlaneId::LastPlaneNearSpect();
00329        ipln[3] = PlexPlaneId::LastPlaneNearSpect();
00330        break;
00331      }
00332    default:
00333      {
00334        return; // ! no SM at all, use defaults
00335      }
00336    }
00337 
00338    for (int indx = 0; indx < 4; ++indx) {
00339      PlexPlaneId steelid(fDetector,ipln[indx],true);
00340      UgliSteelPlnHandle uph = fUgliGeomHandle.GetSteelPlnHandle(steelid);
00341      if ( ! uph.IsValid() ) continue; // in case of no geometry
00342      Double_t dz = uph.GetHalfThickness();
00343      if ( 0 == indx || 2 == indx ) dz = -dz;
00344      fSMZLimits[indx] = uph.GetZ0() + dz;
00345    }
00346 
00347 }

const BfldDbiPlaneMap * BfldCache::FindPlaneMap ( TVector3 &  position,
Bool_t  isUVZ = false 
)

Definition at line 147 of file BfldCache.cxx.

References fPlaneMapCache, and SetSteelAndPlaneMapCache().

Referenced by BField::GetBField().

00149 {
00150    SetSteelAndPlaneMapCache(position,isUVZ);
00151    return fPlaneMapCache;
00152 }

Bool_t BfldCache::FindWasInSteel ( Bool_t  lie = true  )  const [inline]

the next three methods should only be called after FindPlaneMap()

Definition at line 107 of file BfldCache.h.

References fFindWasInSteel, and fInZTest.

Referenced by BField::GetBField().

00108 { 
00109   if ( lie && fInZTest < 2 ) return true;
00110   return fFindWasInSteel; 
00111 }

UgliSteelPlnHandle BfldCache::GetCurrentSteelPlnHandle (  )  const [inline]

Definition at line 41 of file BfldCache.h.

References fSteelCache.

Referenced by BField::GetBField().

00041                                                             { return fSteelCache; 
00042 }

Int_t BfldCache::GetDefaultMapVariant ( const VldContext vldc  )  [static]

Definition at line 446 of file BfldCache.cxx.

References VldContext::GetDetector(), VldContext::GetSimFlag(), Detector::kFar, SimFlag::kMC, Detector::kNear, and SimFlag::kReroot.

Referenced by BField::BField(), and BField::GetBField().

00447 {
00448    // Return default map (for context)
00449 
00450   // no real data ...
00451   Int_t indx = 0;
00452   Int_t variant;
00453   switch (vldc.GetDetector()) {
00454   case (Detector::kNear):
00455     {
00456       switch (vldc.GetSimFlag()) {
00457       case (SimFlag::kMC):
00458       case (SimFlag::kReroot):
00459         variant = (indx==0) ? 160 : 0; break;
00460       default:
00461         variant = (indx==0) ? 160 : 0; break;
00462       }
00463       break;
00464     }
00465   case (Detector::kFar):
00466     {
00467       switch (vldc.GetSimFlag()) {
00468       case (SimFlag::kMC):
00469       case (SimFlag::kReroot):
00470         variant = (indx==0) ? 208 : 0; break;
00471       default:
00472         variant = (indx==0) ? 208 : 0; break;
00473       }
00474       break;
00475     }
00476   default:                      variant =    0; break;
00477   } 
00478 
00479   return variant;
00480 }

Double_t BfldCache::GetDefaultScale ( const VldContext vldc  )  [static]

Definition at line 483 of file BfldCache.cxx.

References VldContext::GetDetector(), Detector::kFar, and Detector::kNear.

Referenced by BField::GetBField().

00484 {
00485    // Lookup scale factor for this plane
00486 
00487   // no real data ...
00488   Double_t scale;
00489   switch (vldc.GetDetector()) {
00490   case (Detector::kNear):   scale =  1.0; break;
00491   case (Detector::kFar):    scale =  1.0; break;
00492   default:                      scale =    0; break;
00493   } 
00494 
00495   return scale;
00496 }

Int_t BfldCache::GetDoLocalTransform (  )  const [inline]

Definition at line 53 of file BfldCache.h.

References fDoLocalTransform.

Referenced by BField::GetBField(), and BField::GetDoLocalTransform().

00053 { return fDoLocalTransform; }

TVector3 BfldCache::GetPositionInSteel (  )  const [inline]

Definition at line 40 of file BfldCache.h.

References fPosInSteel.

Referenced by BField::GetBField().

00040 { return fPosInSteel; }

Int_t BfldCache::GetRequireInZTest (  )  const [inline]

Definition at line 54 of file BfldCache.h.

References fInZTest.

Referenced by BField::GetRequireInZTest().

00054 { return fInZTest; }

VldRange BfldCache::GetVldRange (  )  const [inline]

Definition at line 35 of file BfldCache.h.

References fVldRange.

Referenced by BfldLoanPool::GetCache(), and BField::ResetVldContext().

00035 { return fVldRange; }

Double_t BfldCache::GetZTolerance (  )  const [inline]

Definition at line 55 of file BfldCache.h.

References fZTolerance.

Referenced by BField::GetZTolerance().

00055 { return fZTolerance; }

void BfldCache::IncrementRef (  )  [inline]

Definition at line 62 of file BfldCache.h.

References fRef.

Referenced by BField::operator=(), and BField::ResetVldContext().

00062 { fRef++; }

void BfldCache::InitFlags (  )  [protected]

Definition at line 102 of file BfldCache.cxx.

References fDoLocalTransform, fInZTest, fZTolerance, BfldLoanPool::GetDefaultDoLocalTransform(), BfldLoanPool::GetDefaultRequireInZTest(), BfldLoanPool::GetDefaultZTolerance(), BfldLoanPool::Instance(), Msg::kSynopsis, Munits::mm, and MSG.

Referenced by BfldCache().

00103 {
00104    // Initialize configuration flags from BfldLoanPool
00105 
00106    // get access to the BfldLoanPool
00107    BfldLoanPool *loanpool = BfldLoanPool::Instance();
00108 
00109    fDoLocalTransform = loanpool->GetDefaultDoLocalTransform();
00110    fInZTest          = loanpool->GetDefaultRequireInZTest();
00111    fZTolerance       = loanpool->GetDefaultZTolerance();
00112    MSG("Bfld",Msg::kSynopsis)
00113      << "BfldCache DoLocalTransform=" << fDoLocalTransform 
00114      << " InZTest=" << fInZTest
00115      << " ZTolerance=" << (fZTolerance/Munits::mm) << "mm"
00116      << endl;
00117 
00118 }

Ugli::SMRegion_t BfldCache::InSMRegion ( const TVector3 &  pos,
Bool_t  isUVZ 
)

Definition at line 350 of file BfldCache.cxx.

References Munits::cm, fDetector, fSMZLimits, InXYRegion(), Ugli::kDownstream, Ugli::kFlange, Ugli::kInSM1, Ugli::kInSM2, Detector::kNear, Ugli::kSMGap, and Ugli::kUpstream.

Referenced by BField::GetBField().

00351 {
00352    // Determine if the this position is within the SuperModules
00353    // If in XY region of "flange" then consider it part of SM if
00354    // within dz of SM.
00355    // Return:
00356    //      -1 = upstream
00357    //       1 = in SM1
00358    //       0 = in gap
00359    //       2 = in SM2
00360    //      -2 = downstream
00361 
00362    Double_t dz = 3.4 * Munits::cm;  // extra z in the area of the collar
00363 
00364    Double_t z = pos.Z();
00365 
00366    // definitely in a SM
00367    if ( z >= fSMZLimits[0] && z <= fSMZLimits[1] ) return Ugli::kInSM1; // 1
00368    if ( z >= fSMZLimits[2] && z <= fSMZLimits[3] ) return Ugli::kInSM2; // 2
00369 
00370    // definitely not in a SM
00371    if ( z < fSMZLimits[0]-dz ) return Ugli::kUpstream;   // -1
00372    if ( z > fSMZLimits[1]+dz && z < fSMZLimits[2]-dz ) return Ugli::kSMGap; // 0
00373    if ( z > fSMZLimits[3]+dz ) return Ugli::kDownstream; // -2
00374 
00375    // in region where flange might be part of SM
00376    bool inFlange = ( InXYRegion(pos,isUVZ) <= Ugli::kFlange );
00377    if ( z < fSMZLimits[0] ) {
00378      if ( inFlange ) return Ugli::kInSM1;      //  1
00379      else            return Ugli::kUpstream  ; // -1;
00380    }
00381    if ( Detector::kNear == fDetector ) {
00382      if ( inFlange ) return Ugli::kInSM1;      //  1
00383      else            return Ugli::kDownstream; // -2;
00384    } else { // far
00385      if ( z > fSMZLimits[3] ) {
00386        if ( inFlange ) return Ugli::kInSM2;      //  2;
00387        else            return Ugli::kDownstream; // -2;
00388      }
00389      // FarDet gap
00390      if ( ! inFlange ) return Ugli::kSMGap; // 0;
00391      if ( z < 0.5*(fSMZLimits[1]+fSMZLimits[2]) ) return Ugli::kInSM1; // 1
00392      else                                         return Ugli::kInSM2; // 2
00393    }
00394    return Ugli::kSMGap; // 0
00395 }

void BfldCache::InvalidateCaches (  )  [protected]

Definition at line 203 of file BfldCache.cxx.

References fPlaneMapCache, fSteelCache, fSteelZmax, and fSteelZmin.

00204 {
00205    // Invalidate fSteelCache, fSteelZmin/max, fPlaneMapCache
00206    fSteelCache    = UgliSteelPlnHandle();
00207    fSteelZmin     = +9999.;
00208    fSteelZmax     = -9999.;
00209    fPlaneMapCache = 0;
00210 
00211 }

Ugli::XYRegion_t BfldCache::InXYRegion ( const TVector3 &  pos,
Bool_t  isUVZ 
)

Definition at line 398 of file BfldCache.cxx.

References Munits::cm, fDetector, Ugli::kCoil, Detector::kFar, Ugli::kFlange, Detector::kNear, Ugli::kSteel, and Ugli::xy2uv().

Referenced by InSMRegion().

00399 {
00400   // Determine if x-y is outside flange area ...
00401   // NearDet is square in UV, diamond in XY
00402   // FarDet is round
00403 
00404   // this should really be part of UgliGeom
00405 
00406   // inside "coil" return 0... not implemented yet
00407   const Double_t rCoil    = 0.0;  // inside this return 0
00408   const Double_t rThroat  = 13.0 * Munits::cm; // inside this return 1
00409   const Double_t rNeck    = 14.0 * Munits::cm; // inside this return 2
00410   const Double_t rHole    = 15.0 * Munits::cm; // inside this return 3
00411   const Double_t rFlange  = 17.0 * Munits::cm; // inside this return 4
00412   // outside return 5
00413 
00414   Double_t rlimit[5] = { rCoil, rThroat, rNeck, rHole, rFlange };
00415   int indx;
00416 
00417   switch (fDetector) {
00418   case Detector::kNear:
00419     {
00420       Double_t u, v;
00421       if (isUVZ) {
00422         u = pos.X();
00423         v = pos.Y();
00424       } else {
00425         Ugli::xy2uv(fDetector,pos.X(),pos.Y(),u,v);
00426       }
00427       for ( indx = Ugli::kCoil; indx <= Ugli::kFlange; ++indx ) {
00428         if ( TMath::Abs(u) < rlimit[indx] &&
00429              TMath::Abs(v) < rlimit[indx]     ) return (Ugli::XYRegion_t)indx;
00430       }
00431       break;
00432     }
00433   case Detector::kFar:
00434     {
00435       Double_t r = pos.Perp();
00436       for ( indx = Ugli::kCoil; indx <= Ugli::kFlange; ++indx ) {
00437         if ( r < rlimit[indx] ) return (Ugli::XYRegion_t)indx;
00438       }
00439     }
00440   default:
00441     return Ugli::kSteel;
00442   }
00443   return Ugli::kSteel;
00444 }

void BfldCache::Print ( Option_t *  option = ""  )  const [virtual]

Definition at line 499 of file BfldCache.cxx.

References fDoLocalTransform, fInZTest, fRef, fVldRange, fZTolerance, Msg::kInfo, Munits::mm, and MSG.

Referenced by BfldLoanPool::Print(), and BField::Print().

00500 {
00501   MSG("Bfld",Msg::kInfo) 
00502     << " RefCnt=" << setw(2) << fRef
00503     << " " << fVldRange << endl
00504     << "       DoLocalTransform=" << fDoLocalTransform
00505     << "    InZTest=" << fInZTest
00506     << "    ZTolerance=" << (fZTolerance/Munits::mm) << "mm"
00507     << endl;
00508 }

void BfldCache::SetDoLocalTransform ( Int_t  flg  )  [inline]

Definition at line 56 of file BfldCache.h.

References fDoLocalTransform.

Referenced by BField::SetDoLocalTransform().

00056 { fDoLocalTransform = flg; }

void BfldCache::SetPlaneMapCache ( PlexPlaneId  steelid  )  [protected]

Definition at line 185 of file BfldCache.cxx.

References fDbiMapEntries, fPlaneMapCache, fPlaneMaps, PlexPlaneId::GetPlane(), BfldDbiPlaneMap::GetPlaneId(), and DbiResultPtr< T >::GetRowByIndex().

Referenced by SetSteelAndPlaneMapCache().

00186 {
00187    // Fill fPlaneMapCache entry for this steel
00188 
00189    // avoid DBI lookup if possible
00190    if ( fPlaneMapCache && fPlaneMapCache->GetPlaneId() == steelid) return;
00191 
00192    fPlaneMapCache = 0;
00193 
00194    if (fDbiMapEntries > 0) {
00195      const BfldDbiPlaneMap* planemap = 
00196        fPlaneMaps.GetRowByIndex(steelid.GetPlane());
00197     
00198      if (planemap) fPlaneMapCache = planemap;
00199    }
00200 }

void BfldCache::SetRequireInZTest ( Int_t  ival  )  [inline]

Definition at line 57 of file BfldCache.h.

References fInZTest.

Referenced by BField::SetRequireInZTest().

00057 { fInZTest = ival; }

void BfldCache::SetSteelAndPlaneMapCache ( TVector3 &  position,
Bool_t  isUVZ = false 
) [protected]

Definition at line 214 of file BfldCache.cxx.

References BFieldOutsideZ(), BFieldWithinZ(), fDoLocalTransform, fFindWasInSteel, fInZTest, fPosInSteel, fSteelCache, fSteelZmax, fSteelZmin, fSumHigh, fSumLow, fUgliGeomHandle, fWasHigh, fWasLow, fZTolerance, UgliSteelPlnHandle::GetHalfThickness(), UgliGeomHandle::GetNearestSteelPlnHandle(), UgliPlnHandle::GetPlexPlaneId(), UgliSteelPlnHandle::GetZ0(), UgliSteelPlnHandle::GlobalToLocal(), UgliSteelPlnHandle::IsValid(), Msg::kDebug, Msg::kError, Msg::kWarning, MAXMSG, MSG, SetPlaneMapCache(), and SetSteelLimits().

Referenced by FindPlaneMap().

00215 {
00216    // Fill fSteelCache and PlaneMap entry for this position.
00217    // Assumes that B is only important within steel
00218    // Assumes that the plane is perpendicular to z direction
00219    // i.e. no rotation out of the x-y plane
00220 
00221    fFindWasInSteel = true;
00222    Double_t z = posGlobal.z();
00223 
00224    // Try the cache first
00225    if ( fSteelCache.IsValid() && BFieldWithinZ(z,fSteelZmin,fSteelZmax) ) {
00226      //MSG("Bfld",Msg::kVerbose) 
00227      //  << "SetSteelAndPlaneMapCacheFromZ hit cache!" << endl;
00228    }
00229    else {
00230      // Ask the geometry
00231      fSteelCache = fUgliGeomHandle.GetNearestSteelPlnHandle(z);
00232      SetSteelLimits();
00233      SetPlaneMapCache(fSteelCache.GetPlexPlaneId());
00234      MSG("Bfld",Msg::kDebug) << "Asked geometry for NearestSteelPln " << endl;
00235 
00236      if ( ! fSteelCache.IsValid() ) {
00237        MSG("Bfld",Msg::kError) 
00238          << "Asked geometry for NearestSteelPln for z= " << z 
00239          << ", got invalid UgliGeomSteelPln" 
00240          << endl;
00241      }
00242    }
00243 
00244    //MSG("Bfld",Msg::kInfo)
00245    //    << " posGlobal " << posGlobal << " fPosInSteel " 
00246    //    << fPosInSteel << endl;
00247 
00248 
00249    // InZTest:
00250    //   0 = no test that z is within range of a plane
00251    //   1 = return (nearest) valid UgliSteelPlnHandle, but complain
00252    //  >1 = return (nearest) valid UgliSteelPlnHandle (quietly)
00253    //       in this case set fPositionInSteel = false
00254    if ( fInZTest == 0) return;
00255    // DoLocalTransform:
00256    //   0 = no Global <--> Local transform
00257    //   1 = do only for shifts (ie.  Global->Local position but not field)
00258    //   2 = do for shifts and rotations (ie. transform returned field)
00259    if ( fDoLocalTransform <= 0 ) {
00260      fPosInSteel = posGlobal;
00261      if ( ! BFieldOutsideZ(z,fSteelZmin,fSteelZmax) ) return;
00262    } else {
00263      // use the in-the-steel local coord to determine if we're in "z"
00264      // note Ugli uses globalInXYZ, while BField uses isUVZ
00265      fPosInSteel = fSteelCache.GlobalToLocal(posGlobal,!isUVZ);
00266      Double_t hdzlimit = fSteelCache.GetHalfThickness()+FLT_EPSILON+fZTolerance;
00267      if ( TMath::Abs(fPosInSteel.z()) <= hdzlimit )  return;
00268    }
00269 
00270    // currently this returns "nearest steel" when outside the steel
00271    // but for coil we should always return either upstream or downstream
00272    // steel depending on Near/Far (which is which ... think hard)
00273    // be careful of falling off the ends
00274    fFindWasInSteel = false;
00275    
00276    if ( fInZTest < 2 ) {
00277      
00278      Double_t z0 = fSteelCache.GetZ0();
00279      Double_t ht = fSteelCache.GetHalfThickness();
00280      //Double_t dz = (z>z0) ? z-(z0+ht) : (z0-ht)-z;
00281      Double_t dz = 0;
00282      const char* side;
00283      if ( z > z0 ) {
00284        side = "high";
00285        dz = z-(z0+ht);
00286        fWasHigh++;
00287        fSumHigh += dz;
00288      } else {
00289        side = "low";
00290        dz = (z0-ht)-z;
00291        fWasLow++;
00292        fSumLow += dz;
00293      }
00294      
00295      MAXMSG("Bfld",Msg::kWarning,10) 
00296        << "Geom returned plane " << fSteelCache.GetPlexPlaneId() << endl
00297        << " but z " << z << " is not within " << ht << " of " << z0
00298        << " (" << dz << " too " << side << ")" << endl;
00299      
00300    }
00301    //if (fInZTest>1) InvalidateCaches();
00302 
00303 }   

void BfldCache::SetSteelLimits (  )  [protected]

Definition at line 169 of file BfldCache.cxx.

References fSteelCache, fSteelZmax, fSteelZmin, fZTolerance, UgliSteelPlnHandle::GetHalfThickness(), UgliSteelPlnHandle::GetZ0(), and UgliSteelPlnHandle::IsValid().

Referenced by SetSteelAndPlaneMapCache().

00170 {
00171    // Fill fSteelZmin/fSteelZmax for given fSteelCache
00172    if (fSteelCache.IsValid()) {
00173      Double_t z0 = fSteelCache.GetZ0();
00174      Double_t dz = fSteelCache.GetHalfThickness() + FLT_EPSILON + fZTolerance;
00175      fSteelZmin = z0 - dz;
00176      fSteelZmax = z0 + dz;
00177    }
00178    else {
00179      fSteelZmin = +9999.;
00180      fSteelZmax = -9999.;
00181    }
00182 }

void BfldCache::SetZTolerance ( Double_t  zeps  )  [inline]

Definition at line 58 of file BfldCache.h.

References fZTolerance.

Referenced by BField::SetZTolerance().

00058 { fZTolerance = zeps; }


Member Data Documentation

Int_t BfldCache::fDbiMapEntries [private]

specifics about each plane

Definition at line 91 of file BfldCache.h.

Referenced by SetPlaneMapCache().

Definition at line 77 of file BfldCache.h.

Referenced by BfldCache(), FillSMZLimits(), InSMRegion(), and InXYRegion().

zmax last steel

Definition at line 86 of file BfldCache.h.

Referenced by GetDoLocalTransform(), InitFlags(), Print(), SetDoLocalTransform(), and SetSteelAndPlaneMapCache().

Bool_t BfldCache::fFindWasInSteel [private]

last planemap used

Definition at line 94 of file BfldCache.h.

Referenced by FindWasInSteel(), and SetSteelAndPlaneMapCache().

Int_t BfldCache::fInZTest [private]

avoid GetNumRows

Definition at line 92 of file BfldCache.h.

Referenced by FindPlaneMap(), InvalidateCaches(), and SetPlaneMapCache().

dz tolerance

Definition at line 90 of file BfldCache.h.

Referenced by BfldCache(), and SetPlaneMapCache().

TVector3 BfldCache::fPosInSteel [private]

last position in steel?

Definition at line 95 of file BfldCache.h.

Referenced by GetPositionInSteel(), and SetSteelAndPlaneMapCache().

Int_t BfldCache::fRef [mutable, private]

Definition at line 79 of file BfldCache.h.

Referenced by CountRef(), DecrementRef(), IncrementRef(), Print(), and ~BfldCache().

Double_t BfldCache::fSMZLimits[4] [private]

last position in steel

Definition at line 97 of file BfldCache.h.

Referenced by FillSMZLimits(), and InSMRegion().

reference geometry

Definition at line 82 of file BfldCache.h.

Referenced by GetCurrentSteelPlnHandle(), InvalidateCaches(), SetSteelAndPlaneMapCache(), and SetSteelLimits().

Double_t BfldCache::fSteelZmax [private]

zmin last steel

Definition at line 84 of file BfldCache.h.

Referenced by InvalidateCaches(), SetSteelAndPlaneMapCache(), and SetSteelLimits().

Double_t BfldCache::fSteelZmin [private]

last steel used

Definition at line 83 of file BfldCache.h.

Referenced by InvalidateCaches(), SetSteelAndPlaneMapCache(), and SetSteelLimits().

Double_t BfldCache::fSumHigh [private]

Definition at line 101 of file BfldCache.h.

Referenced by SetSteelAndPlaneMapCache(), and ~BfldCache().

Double_t BfldCache::fSumLow [private]

Definition at line 102 of file BfldCache.h.

Referenced by SetSteelAndPlaneMapCache(), and ~BfldCache().

outstanding references

Definition at line 81 of file BfldCache.h.

Referenced by BfldCache(), FillSMZLimits(), SetSteelAndPlaneMapCache(), and ~BfldCache().

Definition at line 78 of file BfldCache.h.

Referenced by BfldCache(), GetVldRange(), and Print().

Int_t BfldCache::fWasHigh [private]

Definition at line 99 of file BfldCache.h.

Referenced by SetSteelAndPlaneMapCache(), and ~BfldCache().

Int_t BfldCache::fWasLow [private]

Definition at line 100 of file BfldCache.h.

Referenced by SetSteelAndPlaneMapCache(), and ~BfldCache().

Double_t BfldCache::fZTolerance [private]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1