BfldLoanPool Class Reference

#include <BfldLoanPool.h>

Inheritance diagram for BfldLoanPool:
CfgConfigurable

List of all members.

Classes

struct  Cleaner

Public Member Functions

virtual void Config ()
virtual const RegistryDefaultConfig () const
virtual void SetConfigFromEnvironment ()
BfldMapGetMap (BfldGrid::Grid_t grid, Int_t variant)
BfldMeshGetMesh (BfldGrid::Grid_t grid, Int_t variant)
BfldCacheGetCache (VldContext &vldc)
Int_t GetDefaultRequireInZTest () const
Int_t GetDefaultDoLocalTransform () const
Int_t GetDefaultDoBHCorrection () const
Int_t GetDefaultDoSlotCorrection () const
Int_t GetDefaultDoInterPlaneField () const
Int_t GetDefaultDoSMGapAndEndField () const
Int_t GetDefaultUseDCSCoilDir () const
Int_t GetDefaultUseDCSCurrent () const
Int_t GetDefaultGapLineSrc () const
Int_t GetDefaultApplyBdotScale () const
Double_t GetDefaultOverallScale () const
Double_t GetDefaultZTolerance () const
Double_t GetDefaultNoFieldBeyondZ () const
Int_t GetForceUseEverywhere () const
Int_t GetIgnoreUseEverywhere () const
void ClearPool (Bool_t cache=true, Bool_t map=false, Bool_t mesh=false)
void Print (Option_t *option="") const

Static Public Member Functions

static BfldLoanPoolInstance ()

Private Member Functions

 BfldLoanPool ()
 BfldLoanPool (const BfldLoanPool &bfl)
virtual ~BfldLoanPool ()

Private Attributes

TObjArray fBfldMeshList
TObjArray fBfldMapList
TObjArray fBfldCacheList
Int_t fMaxUnrefCaches
Int_t fInZTest
Int_t fDoLocalTransform
Int_t fDoBHCorrection
Int_t fDoSlotCorrection
Int_t fDoInterPlaneField
Int_t fDoSMGapAndEndField
Int_t fUseDCSCoilDir
Int_t fUseDCSCurrent
Int_t fGapLineSrc
Int_t fApplyBdotScale
Double_t fOverallScale
Double_t fZTolerance
Double_t fNoFieldBeyondZ
Int_t fForceUseEverywhere
Int_t fIgnoreUseEverywhere
Int_t fBfldDbiPlaneMapTask

Static Private Attributes

static BfldLoanPoolfgInstance = 0

Friends

struct Cleaner

Detailed Description

Definition at line 31 of file BfldLoanPool.h.


Constructor & Destructor Documentation

BfldLoanPool::BfldLoanPool (  )  [private]

Definition at line 54 of file BfldLoanPool.cxx.

References Msg::kSynopsis, Msg::kWarning, and MSG.

00058   : fMaxUnrefCaches(1),     fInZTest(3),              fDoLocalTransform(0),
00059     fDoBHCorrection(0),     fDoSlotCorrection(0), 
00060     fDoInterPlaneField(1),  fDoSMGapAndEndField(1),   fUseDCSCoilDir(1),
00061     fUseDCSCurrent(0),      fGapLineSrc(3),           fApplyBdotScale(0),
00062     fOverallScale(1.0),
00063     fZTolerance(0.0),       fNoFieldBeyondZ(9999.), 
00064     fForceUseEverywhere(0), fIgnoreUseEverywhere(1),
00065     fBfldDbiPlaneMapTask(Dbi::kDefaultTask)
00066 {
00067   // Default ctor -- called by self only
00068 
00069    if (fgInstance && fgInstance != this) {
00070      MSG("Bfld",Msg::kWarning)
00071        << "BfldLoanPool ctor() called but global already exists"
00072        << " -- memory leak (existing one will be lost)"
00073        << endl;
00074    }
00075    fgInstance = this;
00076 
00077    MSG("Bfld",Msg::kSynopsis) << "BfldLoanPool ctor" << endl;
00078 
00079    const char* tmp = getenv("BFLDDBIPLANEMAP_TASK");
00080    if ( tmp ) { 
00081      fBfldDbiPlaneMapTask = atoi(tmp); 
00082      MSG("Bfld",Msg::kWarning) 
00083        << "BfldLoanPool use BFLDDBIPLANEMAP_TASK " 
00084        << tmp << " => " << fBfldDbiPlaneMapTask << endl;
00085    } else {
00086      MSG("Bfld",Msg::kWarning)
00087        << "BfldLoadPool no env, default task "
00088        << fBfldDbiPlaneMapTask << endl;
00089    }
00090 
00091    fBfldMeshList.SetOwner(true);
00092    fBfldMapList.SetOwner(true);
00093    fBfldCacheList.SetOwner(true);
00094 }

BfldLoanPool::BfldLoanPool ( const BfldLoanPool bfl  )  [private]
BfldLoanPool::~BfldLoanPool (  )  [private, virtual]

Definition at line 97 of file BfldLoanPool.cxx.

References fBfldCacheList, fBfldMapList, fBfldMeshList, fgInstance, Msg::kSynopsis, and MSG.

00098 {
00099   // dtor
00100   // delete all the owned sub-objects
00101 
00102    MSG("Bfld",Msg::kSynopsis) << "BfldLoanPool shutdown" << endl;
00103 
00104    fgInstance = 0;
00105    fBfldMeshList.Delete();
00106    fBfldMapList.Delete();
00107    fBfldCacheList.Delete();
00108 }


Member Function Documentation

void BfldLoanPool::ClearPool ( Bool_t  cache = true,
Bool_t  map = false,
Bool_t  mesh = false 
)

Definition at line 579 of file BfldLoanPool.cxx.

References fBfldCacheList, fBfldMapList, and fBfldMeshList.

00580 {
00581   if (cache) fBfldCacheList.Delete();
00582   if (map)   fBfldMapList.Delete();
00583   if (mesh)  fBfldMeshList.Delete();
00584 }

void BfldLoanPool::Config ( void   )  [virtual]

Implements CfgConfigurable.

Definition at line 138 of file BfldLoanPool.cxx.

References fApplyBdotScale, fBfldDbiPlaneMapTask, fDoBHCorrection, fDoInterPlaneField, fDoLocalTransform, fDoSlotCorrection, fDoSMGapAndEndField, fForceUseEverywhere, fGapLineSrc, fIgnoreUseEverywhere, fInZTest, fMaxUnrefCaches, fNoFieldBeyondZ, fOverallScale, fUseDCSCoilDir, fUseDCSCurrent, fZTolerance, Registry::Get(), CfgConfigurable::GetConfig(), Nav::kBoth, Msg::kInfo, Munits::mm, and MSG.

00139 {
00140   //  Reconfigure after internal registry update.
00141 
00142   Registry& r = GetConfig();
00143 
00144   int    tmpi;
00145   double tmpd;
00146   const char* tmps;
00147 
00148   if (r.Get("MaxUnrefCaches",     tmpi)) fMaxUnrefCaches     = tmpi;
00149 
00150   if (r.Get("RequireInZTest",     tmpi)) fInZTest            = tmpi;
00151   if (r.Get("DoLocalTransform",   tmpi)) fDoLocalTransform   = tmpi;
00152 
00153   if (r.Get("DoBHCorrection",     tmpi)) fDoBHCorrection     = tmpi;
00154   if (r.Get("DoSlotCorrection",   tmpi)) fDoSlotCorrection   = tmpi;
00155   if (r.Get("DoInterPlaneField",  tmpi)) fDoInterPlaneField  = tmpi;
00156   if (r.Get("DoSMGapAndEndField", tmpi)) fDoSMGapAndEndField = tmpi;
00157   if (r.Get("UseDCSCoilDir",      tmpi)) fUseDCSCoilDir      = tmpi;
00158   if (r.Get("UseDCSCurrent",      tmpi)) fUseDCSCurrent      = tmpi;
00159   if (r.Get("GapLineSrc",         tmpi)) fGapLineSrc         = tmpi;
00160   if (r.Get("ApplyBdotScale",     tmpi)) fApplyBdotScale     = tmpi;
00161   if (r.Get("OverallScale",       tmpd)) fOverallScale       = tmpd;
00162 
00163   if (r.Get("ZTolerance",         tmpd)) fZTolerance         = tmpd;
00164 
00165   if (r.Get("NoFieldBeyondZ",     tmpd)) fNoFieldBeyondZ     = tmpd;
00166 
00167   if (r.Get("ForceUseEverywhere", tmpi)) fForceUseEverywhere = tmpi;
00168   if (r.Get("IgnoreUseEverywhere",tmpi)) fIgnoreUseEverywhere= tmpi;
00169 
00170   if (r.Get("BfldDbiPlaneMapTask",tmpi)) {
00171     fBfldDbiPlaneMapTask = Dbi::Task(tmpi);
00172   }
00173 
00174   if (r.Get("AllBellsAndWhistles",tmpi) && tmpi != 0 ) {
00175     // maximum enhancements! damn the torpedos
00176     MSG("Bfld",Msg::kInfo)
00177       << "BfldLoanPool configured for AllBellsAndWhistles! (toot)! (toot)!"
00178       << endl;
00179     fInZTest             =   3; // this is needed for InterPlaneField
00180     fDoLocalTransform    =   2;
00181     fDoInterPlaneField   =   1;
00182     fDoBHCorrection      =  -1;
00183     fDoSlotCorrection    =   1;
00184     fApplyBdotScale      =   1;
00185   }
00186 
00187   if (r.Get("SwimmerChoice",tmps) && tmps != 0 ) {
00188     TString swimname(tmps);
00189     swimname.Remove(TString::kBoth,' ').ToLower();
00190     bool handled = false;
00191 
00192     if ("old" == swimname) {
00193       // old swimmer behaviour
00194       MSG("Bfld",Msg::kInfo)
00195         << "BfldLoanPool configured for old Swimmer"
00196         << endl;
00197       fForceUseEverywhere  =   0;
00198       fIgnoreUseEverywhere =   0;
00199       fInZTest             =   1;  // steel within tolerance, complain outside
00200       fDoInterPlaneField   =   0;
00201       fDoSMGapAndEndField  =   0;
00202       fZTolerance          =  0.25*Munits::mm;
00203       handled = true;
00204     }
00205     if ("geo" == swimname) {
00206       // GeoSwimmer behaviour
00207       MSG("Bfld",Msg::kInfo)
00208         << "BfldLoanPool configured for GeoSwimmer"
00209         << endl;
00210       fForceUseEverywhere  =   0;
00211       fIgnoreUseEverywhere =   1;
00212       fInZTest             =   3;  // steel within tolerance, complain outside
00213       fDoInterPlaneField   =   1;
00214       fDoSMGapAndEndField  =   1;
00215       fZTolerance          =  0.0*Munits::mm;
00216       handled = true;
00217     } 
00218 
00219     if ( ! handled && swimname != "" ) {
00220       MSG("Bfld",Msg::kInfo)
00221         << "BfldLoanPool doesn't know how to configure for Swimmer: "
00222         << "\"" << swimname << "\""
00223         << endl;
00224     }
00225   } // non-zero SwimmerChoice
00226 
00227 }

const Registry & BfldLoanPool::DefaultConfig ( void   )  const [virtual]

Reimplemented from CfgConfigurable.

Definition at line 230 of file BfldLoanPool.cxx.

References fBfldDbiPlaneMapTask, Nav::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

Referenced by Instance().

00231 {
00232   //======================================================================
00233   // The default configuration for this framework component
00234   //======================================================================
00235   //int itrue  = 1; // Work around for Registry's lack of bool
00236   //int ifalse = 0; // Work around for Registry's lack of bool
00237   static Registry r;
00238   
00239   std::string name = this->GetName();
00240   name += ".config.default";
00241   r.SetName(name.c_str());
00242   
00243   r.UnLockValues();
00244 
00245   // Limit # of spare caches (depends on geometry)
00246   r.Set("MaxUnrefCaches",         1);
00247     
00248   // Require (even if UseEverywhere) that we only compute BField 
00249   // inside z boundary of steel
00250   //  0 = no test
00251   //  1 = complain if problems
00252   //  2 = complain and return B=0 if outside any steel z range
00253   //  3 = use gap map or line current when outside steel
00254   r.Set("RequireInZTest",         3);
00255 
00256   // do coordinate transformation local <--> global for steel
00257   // 0 = none:  assume x0-y0 global = x0-y0 map, no rotation
00258   // 1 = transform position before lookup
00259   // 2 = transform resulting field back (account for rotation)
00260   r.Set("DoLocalTransform",       0);
00261 
00262   // configurable additions to the basic map interpolation
00263   r.Set("DoBHCorrection",     0);  // -1 = use BHFactor/BHCutoff method
00264   r.Set("DoSlotCorrection",   0);
00265 
00266   // 0 = no field outside steel
00267   // 1 = use detail map if in that region
00268   //     use full map if it exists, or line current if not
00269   // 2 = like 1, except always use line current outside detail
00270   // 3 = use detail map if in that region, otherwise zero
00271   r.Set("DoInterPlaneField",  1);
00272 
00273   r.Set("DoSMGapAndEndField", 1);
00274 
00275   r.Set("UseDCSCoilDir",      1);
00276   r.Set("UseDCSCurrent",      0);  // don't use CoilTools::CoilCurrent()
00277   r.Set("GapLineSrc",         3);  // 3= central + return line src
00278 
00279   r.Set("ApplyBdotScale",     0);  // for now have this off ...
00280                                    // until numbers have been validated
00281 
00282   r.Set("OverallScale",     1.0);  // multiplicative factor
00283 
00284   // turn on all the above flags in one go or based on swimmer
00285   r.Set("AllBellsAndWhistles",    0);
00286   r.Set("SwimmerChoice",         "");  // "old", "geo"
00287 
00288   // Limit on the out-of-steel tolerance in z position
00289   r.Set("ZTolerance",      0.0);   // was 0.25*Munits::mm
00290 
00291   // Force B=0 for positions beyond this z.
00292   // Useful for UseEverywhere with 2nd SuperModule not energizied.
00293   r.Set("NoFieldBeyondZ",      9999.0);
00294 
00295   // Force a particular map?
00296   // Even overrides any value passed to BField ctor, but in turn 
00297   // overridden by IgnoreUseEverywhere.
00298   r.Set("ForceUseEverywhere",     0);
00299   // Ignore the UseEverywhere flag in favor of the geometry?
00300   // Use BfldDbiPlaneMap for determining which map to use for each plane
00301   r.Set("IgnoreUseEverywhere",    1);
00302 
00303   // use the one set by the constructor for the default
00304   r.Set("BfldDbiPlaneMapTask", fBfldDbiPlaneMapTask);
00305 
00306   r.LockValues();
00307 
00308   return r;
00309 
00310 }

BfldCache * BfldLoanPool::GetCache ( VldContext vldc  ) 

Definition at line 428 of file BfldLoanPool.cxx.

References BfldCache::CountRef(), fBfldCacheList, fBfldDbiPlaneMapTask, fMaxUnrefCaches, BfldCache::GetVldRange(), VldRange::IsCompatible(), Msg::kDebug, Dbi::kDefaultTask, Msg::kWarning, and MSG.

Referenced by BField::ResetVldContext().

00429 {
00430    // Get a shared cache 
00431    //
00432    BfldCache *cache;
00433 
00434    // Look in the list for a match
00435    // Count # of unreferenced caches in case we don't find a match
00436    Int_t todelete = -fMaxUnrefCaches;   
00437    TIter iter(&fBfldCacheList);
00438    while ( ( cache = (BfldCache *)iter.Next() ) ) {
00439      // Check if it is compatible
00440      if ( cache->GetVldRange().IsCompatible(vldc) ) return cache;
00441      if ( cache->CountRef() <= 0 ) todelete++;
00442    }
00443 
00444    // Nothing in the list matches
00445 
00446    // Purge extraneous unref'd caches
00447    // Iterate from the front (default) so oldest gets cleaned out first
00448    if (todelete > 0) {
00449      TObjArrayIter iter_rm(&fBfldCacheList);
00450      BfldCache* other_cache = 0;
00451      while ( ( other_cache = (BfldCache *)iter_rm.Next() ) &&
00452              todelete > 0 ) {
00453        if ( other_cache->CountRef() <= 0 ) {
00454          fBfldCacheList.Remove(other_cache);
00455          delete other_cache;
00456          todelete--;
00457        }
00458      }
00459      // remove the spaces we freed up
00460      fBfldCacheList.Compress();
00461    }
00462 
00463    // Create an appropriate entry
00464    Dbi::Task task = Dbi::Task(fBfldDbiPlaneMapTask);
00465    MSG("Bfld",Msg::kDebug) << "BfldLoanPool task " << task 
00466                              << " "<< fBfldDbiPlaneMapTask << endl;
00467    if ( task != Dbi::kDefaultTask ) {
00468      MSG("Bfld",Msg::kWarning) 
00469        << "GetCache created a new BfldCache with task = " << task << endl;
00470    } else {
00471      MSG("Bfld",Msg::kDebug) << "GetCache created a new BfldCache" << endl;
00472    }
00473    cache = new BfldCache(vldc,task);
00474    fBfldCacheList.Add(cache);
00475 
00476    return cache;
00477 }

Int_t BfldLoanPool::GetDefaultApplyBdotScale (  )  const [inline]

Definition at line 55 of file BfldLoanPool.h.

References fApplyBdotScale.

Referenced by BField::InitFlagsFromLoanPool().

00055 {return fApplyBdotScale;    }

Int_t BfldLoanPool::GetDefaultDoBHCorrection (  )  const [inline]

Definition at line 47 of file BfldLoanPool.h.

References fDoBHCorrection.

Referenced by BField::InitFlagsFromLoanPool().

00047 {return fDoBHCorrection;    }

Int_t BfldLoanPool::GetDefaultDoInterPlaneField (  )  const [inline]

Definition at line 49 of file BfldLoanPool.h.

References fDoInterPlaneField.

Referenced by BField::InitFlagsFromLoanPool().

00049 {return fDoInterPlaneField; }

Int_t BfldLoanPool::GetDefaultDoLocalTransform (  )  const [inline]

Definition at line 46 of file BfldLoanPool.h.

References fDoLocalTransform.

Referenced by BfldCache::InitFlags().

00046 {return fDoLocalTransform;  }

Int_t BfldLoanPool::GetDefaultDoSlotCorrection (  )  const [inline]

Definition at line 48 of file BfldLoanPool.h.

References fDoSlotCorrection.

Referenced by BField::InitFlagsFromLoanPool().

00048 {return fDoSlotCorrection;  }

Int_t BfldLoanPool::GetDefaultDoSMGapAndEndField (  )  const [inline]

Definition at line 50 of file BfldLoanPool.h.

References fDoSMGapAndEndField.

Referenced by BField::InitFlagsFromLoanPool().

00050 {return fDoSMGapAndEndField;}

Int_t BfldLoanPool::GetDefaultGapLineSrc (  )  const [inline]

Definition at line 53 of file BfldLoanPool.h.

References fGapLineSrc.

Referenced by BField::InitFlagsFromLoanPool().

00053 {return fGapLineSrc;        }

Double_t BfldLoanPool::GetDefaultNoFieldBeyondZ (  )  const [inline]

Definition at line 59 of file BfldLoanPool.h.

References fNoFieldBeyondZ.

Referenced by BField::InitFlagsFromLoanPool().

00059 {return fNoFieldBeyondZ;    }

Double_t BfldLoanPool::GetDefaultOverallScale (  )  const [inline]

Definition at line 56 of file BfldLoanPool.h.

References fOverallScale.

Referenced by BField::InitFlagsFromLoanPool().

00056 {return fOverallScale;      }

Int_t BfldLoanPool::GetDefaultRequireInZTest (  )  const [inline]

Definition at line 45 of file BfldLoanPool.h.

References fInZTest.

Referenced by BfldCache::InitFlags().

00045 {return fInZTest;           }

Int_t BfldLoanPool::GetDefaultUseDCSCoilDir (  )  const [inline]

Definition at line 51 of file BfldLoanPool.h.

References fUseDCSCoilDir.

Referenced by BField::InitFlagsFromLoanPool().

00051 {return fUseDCSCoilDir;     }

Int_t BfldLoanPool::GetDefaultUseDCSCurrent (  )  const [inline]

Definition at line 52 of file BfldLoanPool.h.

References fUseDCSCurrent.

Referenced by BField::InitFlagsFromLoanPool().

00052 {return fUseDCSCurrent;     }

Double_t BfldLoanPool::GetDefaultZTolerance (  )  const [inline]

Definition at line 57 of file BfldLoanPool.h.

References fZTolerance.

Referenced by BfldCache::InitFlags().

00057 {return fZTolerance;        }

Int_t BfldLoanPool::GetForceUseEverywhere (  )  const [inline]

Definition at line 61 of file BfldLoanPool.h.

References fForceUseEverywhere.

Referenced by BField::BField().

00061 {return fForceUseEverywhere; }

Int_t BfldLoanPool::GetIgnoreUseEverywhere (  )  const [inline]

Definition at line 62 of file BfldLoanPool.h.

References fIgnoreUseEverywhere.

Referenced by BField::BField().

00062 {return fIgnoreUseEverywhere;}

BfldMap * BfldLoanPool::GetMap ( BfldGrid::Grid_t  grid,
Int_t  variant 
)

Definition at line 335 of file BfldLoanPool.cxx.

References BfldGrid::AsString(), fBfldMapList, BfldMap::GetGrid(), BfldMap::GetVariant(), Msg::kInfo, BfldGrid::kRect2dGrid, and MSG.

Referenced by BfldCanvasRect2d::BfldCanvasRect2d(), GetMesh(), and BField::SetupHandlerForMap().

00336 {
00337    // Get the requested magnetic field map
00338    //
00339    // Assumes that "BfldMap" structure supports a query about
00340    // what type of grid it is (returns BfldGrid::Grid_t) and
00341    // what variant it is.
00342 
00343    BfldMap *bmap;
00344 
00345    // Look in the list for a match
00346    TIter iter(&fBfldMapList);
00347    while ( ( bmap = (BfldMap *)iter.Next() ) ) {
00348      // Check if it is compatible
00349      if ( bmap->GetGrid()    == grid && 
00350           bmap->GetVariant() == variant ) return bmap;
00351    }
00352 
00353    // Nothing in the list matches
00354 
00355    // actual code for retrieving a copy of the appropriate BFieldMap
00356    // appropriate for this grid and variant (which might specify
00357    // plane chemistry or an end-plane variation)
00358 
00359    MSG("Bfld",Msg::kInfo) 
00360      << "BfldLoanPool::GetMap new map, type " 
00361      << (int)grid << " '" << BfldGrid::AsString(grid)
00362      << "', variant " << variant << endl;
00363 
00364    if (BfldGrid::kRect2dGrid == grid) {
00365       bmap = new BfldMapRect2d(grid,variant);
00366    } else {
00367       bmap = new BfldMapVoronoi(grid,variant);
00368    }
00369    // add it to the list
00370    fBfldMapList.Add(bmap);
00371 
00372    return bmap;
00373 }

BfldMesh * BfldLoanPool::GetMesh ( BfldGrid::Grid_t  grid,
Int_t  variant 
)

Definition at line 376 of file BfldLoanPool.cxx.

References fBfldMeshList, BfldMesh::GetGrid(), GetMap(), BfldMesh::GetVariant(), Msg::kError, BfldGrid::kRect2dGrid, and MSG.

Referenced by BfldCanvasRect2d::BfldCanvasRect2d(), BFLInterpolation::BilinearInterpolation(), BFLInterpolation::IsInsideANSYSCell(), and BField::SetupHandlerForMap().

00377 {
00378    // Get the requested Mesh Diagram
00379    //
00380    // Assumes that "Mesh" structure supports a query about
00381    // what type of grid it is (returns BfldGrid::Grid_t)
00382    // Rect2d mesh's are particular for a given map variant
00383 
00384    BfldMesh *mesh;
00385    Bool_t isRect2d = ( BfldGrid::kRect2dGrid == grid );
00386 
00387    // Look in the list for a match
00388    TIter iter(&fBfldMeshList);
00389    while ( ( mesh = (BfldMesh *)iter.Next() ) ) {
00390       // Check if it is compatible
00391      if ( isRect2d ) {
00392        if ( mesh->GetGrid()    == grid && 
00393             mesh->GetVariant() == variant ) return mesh;
00394      }  // voronoi doesn't care about variant like rect2d
00395      else if ( mesh->GetGrid() == grid )    return mesh;
00396    }
00397 
00398    // Nothing in the list matches
00399 
00400    // actual code for retrieving a copy of the appropriate Mesh diagram
00401    // pass back a pointer to the object
00402   
00403    if ( isRect2d ) {
00404       // the associated mesh should have been created when the map was
00405       // perhaps we're calling them out of order
00406       BfldMapRect2d* bmap2d = 
00407         dynamic_cast<BfldMapRect2d*>(GetMap(grid,variant));
00408       if ( ! bmap2d ) {
00409         MSG("Bfld",Msg::kError)
00410           << "BfldLoanPool::GetMap for Rect2d variant " << variant
00411           << " failed, building mesh is going to fail."
00412           << endl;
00413         // caller probably isn't going to expect this
00414         // but the BfldMeshRect2d ctor will definitely SEGV
00415         return 0;  
00416       }
00417       mesh = new BfldMeshRect2d(bmap2d);
00418    } else {
00419       mesh = new BfldMeshVoronoi(grid,variant);
00420    }
00421    // add it to the list
00422    fBfldMeshList.Add(mesh);
00423    
00424    return mesh;
00425 }

BfldLoanPool * BfldLoanPool::Instance (  )  [static]

Definition at line 111 of file BfldLoanPool.cxx.

References BfldLoanPool::Cleaner::ClassIsUsed(), DefaultConfig(), fgInstance, CfgConfigurable::GetConfig(), Msg::kSynopsis, Registry::LockKeys(), Registry::Merge(), MSG, SetConfigFromEnvironment(), and CfgConfigurable::Update().

Referenced by BfldCanvasRect2d::BfldCanvasRect2d(), BFLInterpolation::BilinearInterpolation(), far_cosmic_mc_configure(), far_mc_configure(), BField::Init(), BfldCache::InitFlags(), BField::InitFlagsFromLoanPool(), BFLInterpolation::IsInsideANSYSCell(), near_mc_configure(), set_sm2_bfield(), and BfldValidate::TestLoanPool().

00112 {
00113   // protect Singleton to ensure there is only one
00114   if (fgInstance == 0) {
00115      MSG("Bfld",Msg::kSynopsis) << "BfldLoanPool instance creation" << endl;
00116 
00117      // before creating the first & only instance make sure that
00118      // there is a UgliLoanPool instance to ensure that the
00119      // singleton dtor's happen in the right order ( first ctor, last dtor )
00120      UgliLoanPool::Instance();
00121 
00122      static BfldLoanPool::Cleaner c; // end-of-run clean up
00123      c.ClassIsUsed();
00124 
00125      fgInstance = new BfldLoanPool;
00126 
00127      // initialize initial (default) configuration
00128      Registry& r = fgInstance->GetConfig();
00129      r.SetName("BfldLoanPool Registry");
00130      r.Merge(fgInstance->DefaultConfig());
00131      r.LockKeys();
00132      fgInstance->SetConfigFromEnvironment();
00133      fgInstance->Update();
00134   }
00135   return fgInstance;
00136 }

void BfldLoanPool::Print ( Option_t *  option = ""  )  const

Definition at line 479 of file BfldLoanPool.cxx.

References BfldGrid::AsString(), BfldRefCnt::CountRef(), fApplyBdotScale, fBfldCacheList, fBfldMapList, fBfldMeshList, fDoBHCorrection, fDoInterPlaneField, fDoSlotCorrection, fDoSMGapAndEndField, fForceUseEverywhere, fGapLineSrc, fIgnoreUseEverywhere, fInZTest, fNoFieldBeyondZ, fOverallScale, fUseDCSCoilDir, fUseDCSCurrent, fZTolerance, CfgConfigurable::GetConfig(), BfldMesh::GetGrid(), BfldMap::GetGrid(), BfldMap::GetVariant(), Msg::kInfo, Msg::kVerbose, Munits::mm, MSG, BfldCache::Print(), and Registry::Print().

Referenced by BfldValidate::TestLoanPool().

00480 {
00481    // output info about what the loan pool has in stock
00482 
00483    MSG("Bfld",Msg::kVerbose) 
00484       << "BfldLoanPool::Print" << endl;
00485 
00486    MSG("Bfld",Msg::kInfo) 
00487      << "BfldLoanPool Configuration (local values):" << endl
00488      << " InZTest: " << fInZTest
00489      << ", ZTolerance: " << (fZTolerance/Munits::mm) << "mm"
00490      << ", NoFieldBeyondZ: " << fNoFieldBeyondZ
00491      << endl
00492      << " UseDCSCoilDir: " << fUseDCSCoilDir
00493      << ", UseDCSCurrent: " << fUseDCSCurrent
00494      << ", GapLineSrc: " << fGapLineSrc
00495      << ", InterPlaneField: " << fDoInterPlaneField
00496      << ", SMGapAndEndField: " << fDoSMGapAndEndField
00497      << ", ApplyBdotScale: " << (fApplyBdotScale?"yes":"no")
00498      << ", OverallScale: " << fOverallScale
00499      << endl
00500      << " BHCorr: " << fDoBHCorrection
00501      << ", SlotCorr: " << fDoSlotCorrection
00502      << ", ForceUseEverywhere: " << fForceUseEverywhere
00503      << ", IgnoreUseEverywhere: " << fIgnoreUseEverywhere
00504      << endl;
00505 
00506    GetConfig().Print();
00507 
00508    static MsgFormat i4("i4");
00509    Bool_t doheader;
00510 
00511 
00512    BfldGrid::Grid_t grid;
00513 
00514    BfldMesh *mesh;
00515 
00516    MSG("Bfld",Msg::kInfo) 
00517       << " --- Mesh list : " << fBfldMeshList.GetEntries() 
00518       << " entries ---" << endl;
00519 
00520    doheader = kTRUE;
00521    TIter itermesh(&fBfldMeshList);
00522    while ( ( mesh = (BfldMesh *)itermesh.Next() ) ) {
00523       if (doheader) {
00524          doheader = kFALSE;
00525          MSG("Bfld",Msg::kInfo) 
00526            << "   RefCnt  Grid " << endl;
00527       }
00528       grid = mesh->GetGrid();
00529       MSG("Bfld",Msg::kInfo) 
00530         << "     " << i4(mesh->CountRef())
00531         << "  " << BfldGrid::AsString(grid) << endl;
00532    }
00533 
00534    MSG("Bfld",Msg::kInfo) 
00535       << " --- Map list : " << fBfldMapList.GetEntries() 
00536       << " entries ---" << endl;
00537 
00538    BfldMap *bmap;
00539 
00540    doheader = kTRUE;
00541    TIter iterbmap(&fBfldMapList);
00542    while ( ( bmap = (BfldMap *)iterbmap.Next() ) ) {
00543       if (doheader) {
00544          doheader = kFALSE;
00545          MSG("Bfld",Msg::kInfo) 
00546            << "   RefCnt  Variant  Grid " << endl;
00547       }
00548       grid = bmap->GetGrid();
00549       MSG("Bfld",Msg::kInfo) 
00550         << "     " << i4(bmap->CountRef())
00551         << "     " << i4(bmap->GetVariant())
00552         << "  " << BfldGrid::AsString(grid) << endl;
00553    }
00554 
00555    BfldCache *cache;
00556    int icache=0;
00557 
00558    MSG("Bfld",Msg::kInfo) 
00559       << " --- Cache list : " << fBfldCacheList.GetEntries() 
00560       << " entries ---" << endl;
00561 
00562    doheader = kTRUE;
00563    TIter itercache(&fBfldCacheList);
00564    while ( ( cache = (BfldCache *)itercache.Next() ) ) {
00565       if (doheader) {
00566          doheader = kFALSE;
00567       }
00568       MSG("Bfld",Msg::kInfo) << " [" << setw(2) << icache << "] ";
00569       cache->Print();
00570       icache++;
00571    }
00572 
00573    MSG("Bfld",Msg::kInfo) 
00574      << " --- End of BfldLoanPool ---" 
00575      << endl;
00576 }

void BfldLoanPool::SetConfigFromEnvironment (  )  [virtual]

Definition at line 313 of file BfldLoanPool.cxx.

References gSystem(), Msg::kInfo, MSG, CfgConfigurable::Set(), and UtilString::StringTok().

Referenced by Instance().

00314 {
00315   // Setup configuration from ENV_BFLD environment variable
00316   // which consists of a semi-colon separated list of 
00317   // configuration requests
00318 
00319   const char* strENV_BFLD = gSystem->Getenv("ENV_BFLD");
00320   if ( strENV_BFLD == 0 || strlen(strENV_BFLD) == 0 ) return;
00321   
00322   MSG("Plex",Msg::kInfo) 
00323     << "Configuring BField from the environment variable ENV_BFLD:" << endl
00324     << "   " << strENV_BFLD << endl;
00325 
00326   std::vector<std::string> configRequests;
00327   UtilString::StringTok(configRequests, strENV_BFLD, ";");
00328 
00329   for (unsigned entry = 0; entry < configRequests.size(); ++entry)
00330     this->Set(configRequests[entry].c_str());
00331 
00332 }


Friends And Related Function Documentation

friend struct Cleaner [friend]

Definition at line 82 of file BfldLoanPool.h.


Member Data Documentation

Definition at line 109 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultApplyBdotScale(), and Print().

TObjArray BfldLoanPool::fBfldCacheList [private]

Definition at line 93 of file BfldLoanPool.h.

Referenced by ClearPool(), GetCache(), Print(), and ~BfldLoanPool().

Definition at line 118 of file BfldLoanPool.h.

Referenced by Config(), DefaultConfig(), and GetCache().

TObjArray BfldLoanPool::fBfldMapList [private]

Definition at line 92 of file BfldLoanPool.h.

Referenced by ClearPool(), GetMap(), Print(), and ~BfldLoanPool().

TObjArray BfldLoanPool::fBfldMeshList [private]

Definition at line 91 of file BfldLoanPool.h.

Referenced by ClearPool(), GetMesh(), Print(), and ~BfldLoanPool().

Definition at line 102 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultDoBHCorrection(), and Print().

Definition at line 104 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultDoInterPlaneField(), and Print().

Definition at line 101 of file BfldLoanPool.h.

Referenced by Config(), and GetDefaultDoLocalTransform().

Definition at line 103 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultDoSlotCorrection(), and Print().

Definition at line 105 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultDoSMGapAndEndField(), and Print().

Definition at line 115 of file BfldLoanPool.h.

Referenced by Config(), GetForceUseEverywhere(), and Print().

Int_t BfldLoanPool::fGapLineSrc [private]

Definition at line 108 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultGapLineSrc(), and Print().

BfldLoanPool * BfldLoanPool::fgInstance = 0 [static, private]

Definition at line 84 of file BfldLoanPool.h.

Referenced by Instance(), ~BfldLoanPool(), and BfldLoanPool::Cleaner::~Cleaner().

Definition at line 116 of file BfldLoanPool.h.

Referenced by Config(), GetIgnoreUseEverywhere(), and Print().

Int_t BfldLoanPool::fInZTest [private]

Definition at line 100 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultRequireInZTest(), and Print().

Definition at line 95 of file BfldLoanPool.h.

Referenced by Config(), and GetCache().

Double_t BfldLoanPool::fNoFieldBeyondZ [private]

Definition at line 113 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultNoFieldBeyondZ(), and Print().

Double_t BfldLoanPool::fOverallScale [private]

Definition at line 110 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultOverallScale(), and Print().

Definition at line 106 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultUseDCSCoilDir(), and Print().

Definition at line 107 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultUseDCSCurrent(), and Print().

Double_t BfldLoanPool::fZTolerance [private]

Definition at line 112 of file BfldLoanPool.h.

Referenced by Config(), GetDefaultZTolerance(), and Print().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1