Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

BfldValidate Class Reference

#include <BfldValidate.h>

Collaboration diagram for BfldValidate:

Collaboration graph
[legend]
List of all members.

Public Methods

 BfldValidate ()
virtual ~BfldValidate ()
void SetDetectorType (DetectorType::Detector_t detector=DetectorType::kNear)
void TestLoanPool ()
void TestInterpMethods (Int_t coarseness=-1, Float_t x=22.5 *Munits::cm, Float_t y=22.5 *Munits::cm)
void DrawMap (Int_t coarseness=-1, Int_t mapid=142, Float_t x0=0.*Munits::cm, Float_t y0=0.*Munits::cm, Float_t half=420.*Munits::cm, Float_t spacing=5.*Munits::cm, Int_t interpolant=1)

Protected Methods

void PrintPair (const Char_t *tag, TVector3 &xyz, TVector3 &bxyz)
void DrawOutline (const DetectorType::Detector_t detector)
void DrawNearOutline ()
void DrawFarOutline ()

Protected Attributes

DetectorType::Detector_t fDetector
VldContext fVldContext

Constructor & Destructor Documentation

BfldValidate::BfldValidate  
 

BfldValidate::~BfldValidate   [virtual]
 

Definition at line 52 of file BfldValidate.cxx.

00053 {
00054 
00055 }


Member Function Documentation

void BfldValidate::DrawFarOutline   [protected]
 

Definition at line 343 of file BfldValidate.cxx.

Referenced by DrawOutline().

00344 {
00345 
00346    const Int_t color = 10;
00347    const Short_t width = 1;
00348 
00349    TPolyLine farOutline(33);
00350    
00351    farOutline.SetPoint( 0, 421.8893*Munits::cm,-142.8867*Munits::cm);
00352    farOutline.SetPoint( 1, 421.8893*Munits::cm,-138.3342*Munits::cm);
00353    farOutline.SetPoint( 2, 400.1614*Munits::cm,-115.9855*Munits::cm);
00354    farOutline.SetPoint( 3, 400.7823*Munits::cm,  87.6358*Munits::cm);
00355    farOutline.SetPoint( 4, 406.9902*Munits::cm,  94.0507*Munits::cm);
00356    farOutline.SetPoint( 5, 429.1319*Munits::cm, 101.5003*Munits::cm);
00357    farOutline.SetPoint( 6, 447.1350*Munits::cm, 101.5003*Munits::cm);
00358    farOutline.SetPoint( 7, 454.7915*Munits::cm,  94.2577*Munits::cm);
00359    farOutline.SetPoint( 8, 457.6886*Munits::cm,  94.2577*Munits::cm);
00360    farOutline.SetPoint( 9, 457.6886*Munits::cm, 109.3637*Munits::cm);
00361    farOutline.SetPoint(10, 143.7724*Munits::cm, 423.2799*Munits::cm);
00362    farOutline.SetPoint(11, 139.4268*Munits::cm, 423.2799*Munits::cm);
00363    farOutline.SetPoint(12, 117.2850*Munits::cm, 401.1382*Munits::cm);
00364    farOutline.SetPoint(13,-116.9622*Munits::cm, 401.1382*Munits::cm);
00365    farOutline.SetPoint(14,-139.1040*Munits::cm, 423.2799*Munits::cm);
00366    farOutline.SetPoint(15,-143.4496*Munits::cm, 423.2799*Munits::cm);
00367    farOutline.SetPoint(16,-457.3658*Munits::cm, 109.3637*Munits::cm);
00368    farOutline.SetPoint(17,-457.3658*Munits::cm,  94.2577*Munits::cm);
00369    farOutline.SetPoint(18,-454.4687*Munits::cm,  94.2577*Munits::cm);
00370    farOutline.SetPoint(19,-439.9834*Munits::cm, 101.9141*Munits::cm);
00371    farOutline.SetPoint(20,-429.8438*Munits::cm, 101.9141*Munits::cm);
00372    farOutline.SetPoint(21,-406.6674*Munits::cm,  94.2577*Munits::cm);
00373    farOutline.SetPoint(22,-399.8386*Munits::cm,  84.7388*Munits::cm);
00374    farOutline.SetPoint(23,-399.8386*Munits::cm,-115.9855*Munits::cm);
00375    farOutline.SetPoint(24,-421.5665*Munits::cm,-137.7134*Munits::cm);
00376    farOutline.SetPoint(25,-421.5665*Munits::cm,-142.8867*Munits::cm);
00377    farOutline.SetPoint(26,-143.4496*Munits::cm,-421.0036*Munits::cm);
00378    farOutline.SetPoint(27,-139.1040*Munits::cm,-421.0036*Munits::cm);
00379    farOutline.SetPoint(28,-116.9622*Munits::cm,-398.8619*Munits::cm);
00380    farOutline.SetPoint(29, 116.8712*Munits::cm,-398.8619*Munits::cm);
00381    farOutline.SetPoint(30, 139.4268*Munits::cm,-421.0036*Munits::cm);
00382    farOutline.SetPoint(31, 143.7724*Munits::cm,-421.0036*Munits::cm);
00383    farOutline.SetPoint(32, 421.8893*Munits::cm,-142.8867*Munits::cm);
00384    
00385    farOutline.SetLineWidth(width);
00386    farOutline.SetLineColor(color);
00387    // use DrawClone so that when this stack based on goes away 
00388    // the outline remains on the picture
00389    farOutline.DrawClone();
00390    
00391    TArc coilOutline(0.,0.,15.);
00392    
00393    coilOutline.SetLineWidth(width);
00394    coilOutline.SetLineColor(color);
00395    coilOutline.DrawClone();
00396 
00397 }

void BfldValidate::DrawMap Int_t    coarseness = -1,
Int_t    mapid = 142,
Float_t    x0 = 0.*Munits::cm,
Float_t    y0 = 0.*Munits::cm,
Float_t    half = 420.*Munits::cm,
Float_t    spacing = 5.*Munits::cm,
Int_t    interpolant = 1
 

Definition at line 165 of file BfldValidate.cxx.

References BfldInterpMethod::AsString(), DrawOutline(), fVldContext, BField::GetBField(), VldContext::GetDetector(), MsgService::GetStream(), MsgService::Instance(), BfldInterpMethod::InterpMethod_t, Msg::kInfo, Msg::kName, Msg::kPriority, Msg::kWarning, MSG, MsgStream::SetFormat(), BField::SetInterpMethod(), and MsgStream::SetLogLevel().

00166 {
00167    // draw a color diagram of the field intensity
00168    // as a square window centered at (x0,y0) of half size "half"
00169    // and with unit elements of size "spacing"
00170    // "interpolant" allows different interpolation methods
00171 
00172    MsgService* msvc = MsgService::Instance();
00173    MsgStream*  mstr = msvc->GetStream("Bfld");
00174    
00175    //   mstr->SetLogLevel(Msg::kVerbose); // spew out everything for debugging
00176    // only put out priority & name fields for Info messages
00177    mstr->SetFormat(Msg::kInfo,Msg::kPriority|Msg::kName);
00178 
00179    BfldInterpMethod::InterpMethod_t interpMethod = 
00180       (BfldInterpMethod::InterpMethod_t) method;
00181    
00182    BField bfield(fVldContext,coarseness,mapid);
00183    MSG("Bfld",Msg::kInfo) << "BfldValidate::DrawRect2dMap created BField " << endl;
00184 
00185    bfield.SetInterpMethod(interpMethod);
00186    MSG("Bfld",Msg::kInfo) << "BfldValidate::DrawRect2dMap using " 
00187                           << BfldInterpMethod::AsString(interpMethod) << endl;
00188 
00189    TVector3 xyz(0.,0.,0.);
00190    TVector3 bxyz;
00191 
00192    mstr->SetLogLevel(Msg::kWarning);
00193 
00194    // Set the palette to a smooth blue-to-red sequence
00195    gStyle->SetPalette(1,(Int_t *)0);
00196 
00197    TCanvas *fCanvas = new TCanvas("BField","BField",600,600);
00198    TPad    *fPad    = new TPad("bpad","bpad",0.010,0.010,0.990,0.990);
00199    fPad->SetFillColor(10);
00200 
00201 
00202    //   Float_t half = 420 * Munits::cm;
00203    //   Float_t spacing = 5 * Munits::cm;
00204    Int_t ndiv = 2*((int)(half/spacing)) + 1;
00205    half = ndiv * spacing / 2;
00206 
00207    MSG("Bfld",Msg::kWarning) << " spacing " << spacing << " ndiv " << ndiv << " half " << half << endl;
00208 
00209    TH2F *fScat = new TH2F("Bmag","Bmag",ndiv,x0-half,x0+half,ndiv,y0-half,y0+half);
00210    fScat->SetStats(kFALSE);
00211    fScat->SetDirectory(0);
00212    TString xtitle("x (");  xtitle += Munits::base_length_name; xtitle += ")";
00213    fScat->SetXTitle(const_cast<char*>(xtitle.Data()));
00214    TString ytitle("y (");  ytitle += Munits::base_length_name; ytitle += ")";
00215    fScat->SetYTitle(const_cast<char*>(ytitle.Data()));
00216 
00217    static MsgFormat f8p3("f8.3");
00218 
00219    TStopwatch timer;
00220    timer.Start();
00221    Int_t count = 0;
00222 
00223    Float_t x, y;
00224    Float_t dx = half*2/ndiv;
00225    Float_t dy = half*2/ndiv;
00226    for (Int_t ix = 0; ix < ndiv; ix++) {
00227       x = x0 - half + ((float)ix + 0.5)*dx;
00228       for (Int_t iy = 0; iy < ndiv; iy++) {
00229          y = y0 - half + ((float)iy + 0.5)*dy;
00230          
00231          xyz.SetX(x); xyz.SetY(y);
00232          bxyz = bfield.GetBField(xyz);
00233          count++;
00234          if (bxyz.Mag() < 100.) {
00235             fScat->Fill(x,y,bxyz.Mag());
00236          } else {
00237             // bad value returned ...
00238             MSG("Bfld",Msg::kWarning) << " Bad B @ " <<
00239                " (x,y)=(" << f8p3(x) << "," << f8p3(y) << ")" <<
00240                "   B=(" << f8p3(bxyz.X()) << "," << 
00241                f8p3(bxyz.Y()) << "," << f8p3(bxyz.Z()) << ")" << endl;
00242          }
00243 
00244       }
00245 
00246    }
00247 
00248    timer.Stop();
00249    MSG("Bfld",Msg::kWarning) 
00250       << " Processed " << count << " call to GetBField() " 
00251       << " @ " << 1000.*timer.CpuTime()/(float)count << " ms/call" << endl;
00252    
00253    fCanvas->Draw();
00254    fPad->Draw();
00255    fScat->SetMaximum(20.0*Munits::kilogauss);
00256    fScat->SetMinimum(0.0);
00257    //   fScat->Draw("COLZ");
00258    //   fScat->Draw("SURF");
00259    fScat->Draw("BOX");
00260    fScat->Draw("COLZ");
00261 
00262    DrawOutline(fVldContext.GetDetector());
00263 
00264    // restore default level
00265    mstr->SetLogLevel(Msg::kInfo);
00266 }

void BfldValidate::DrawNearOutline   [protected]
 

Definition at line 288 of file BfldValidate.cxx.

Referenced by DrawOutline().

00289 {
00290 
00291    const Int_t color = 10;
00292    const Short_t width = 1;
00293 
00294    const Float_t xoffset = 21.96*Munits::inch;
00295 
00296    TPolyLine nearOutline(23);
00297       
00298    nearOutline.SetPoint( 0, -121.43*Munits::inch-xoffset,   0.47*Munits::inch);
00299    nearOutline.SetPoint( 1, -120.25*Munits::inch-xoffset,   0.47*Munits::inch);
00300    nearOutline.SetPoint( 2, -115.14*Munits::inch-xoffset,   3.42*Munits::inch);
00301    nearOutline.SetPoint( 3, -110.24*Munits::inch-xoffset,   3.42*Munits::inch);
00302    nearOutline.SetPoint( 4,  -95.24*Munits::inch-xoffset,  -1.48*Munits::inch);
00303    nearOutline.SetPoint( 5,  -95.24*Munits::inch-xoffset, -35.47*Munits::inch);
00304    nearOutline.SetPoint( 6,  -69.80*Munits::inch-xoffset, -60.91*Munits::inch);
00305    nearOutline.SetPoint( 7,  -69.80*Munits::inch-xoffset, -75.04*Munits::inch);
00306    nearOutline.SetPoint( 8,   69.80*Munits::inch-xoffset, -75.04*Munits::inch);
00307    nearOutline.SetPoint( 9,   69.80*Munits::inch-xoffset, -60.91*Munits::inch);
00308    nearOutline.SetPoint(10,   95.24*Munits::inch-xoffset, -35.47*Munits::inch);
00309    nearOutline.SetPoint(11,   95.24*Munits::inch-xoffset,  -1.48*Munits::inch);
00310    nearOutline.SetPoint(12,  110.16*Munits::inch-xoffset,   3.42*Munits::inch);
00311    nearOutline.SetPoint(13,  117.30*Munits::inch-xoffset,   3.42*Munits::inch);
00312    nearOutline.SetPoint(14,  120.25*Munits::inch-xoffset,   0.47*Munits::inch);
00313    nearOutline.SetPoint(15,  121.43*Munits::inch-xoffset,   0.47*Munits::inch);
00314    nearOutline.SetPoint(16,  121.43*Munits::inch-xoffset,   9.28*Munits::inch);
00315    nearOutline.SetPoint(17,   69.80*Munits::inch-xoffset,  60.91*Munits::inch);
00316    nearOutline.SetPoint(18,   69.80*Munits::inch-xoffset,  75.04*Munits::inch);
00317    nearOutline.SetPoint(19,  -69.80*Munits::inch-xoffset,  75.04*Munits::inch);
00318    nearOutline.SetPoint(20,  -69.80*Munits::inch-xoffset,  60.91*Munits::inch);
00319    nearOutline.SetPoint(21, -121.43*Munits::inch-xoffset,   9.28*Munits::inch);
00320    nearOutline.SetPoint(22, -121.43*Munits::inch-xoffset,   0.47*Munits::inch);
00321    
00322    nearOutline.SetLineWidth(width);
00323    nearOutline.SetLineColor(color);
00324    // use DrawClone so that when this stack based on goes away 
00325    // the outline remains on the picture
00326    nearOutline.DrawClone();
00327    
00328    TPolyLine coilOutline(5);
00329    
00330    coilOutline.SetPoint( 0,  21.96*Munits::inch-xoffset,  8.35*Munits::inch);
00331    coilOutline.SetPoint( 1,  30.31*Munits::inch-xoffset,  0.00*Munits::inch);
00332    coilOutline.SetPoint( 2,  21.96*Munits::inch-xoffset, -8.35*Munits::inch);
00333    coilOutline.SetPoint( 3,  13.61*Munits::inch-xoffset,  0.00*Munits::inch);
00334    coilOutline.SetPoint( 4,  21.96*Munits::inch-xoffset,  8.35*Munits::inch);
00335    
00336    coilOutline.SetLineWidth(width);
00337    coilOutline.SetLineColor(color);
00338    coilOutline.DrawClone();
00339 
00340 }

void BfldValidate::DrawOutline const DetectorType::Detector_t    detector [protected]
 

Definition at line 269 of file BfldValidate.cxx.

References DetectorType::Detector_t, DrawFarOutline(), DrawNearOutline(), DetectorType::kFar, DetectorType::kNear, Msg::kWarning, and MSG.

Referenced by DrawMap().

00270 {
00271 
00272    switch (detector) {
00273    case DetectorType::kNear:
00274       DrawNearOutline();
00275       break;
00276    case DetectorType::kFar:
00277       DrawFarOutline();
00278       break;
00279    default:
00280       MSG("Bfld",Msg::kWarning) 
00281          << "BfldValidate::DrawOutline can't draw "
00282          << (int)detector << " type" << endl;
00283       break;
00284    }
00285 }

void BfldValidate::PrintPair const Char_t *    tag,
TVector3 &    xyz,
TVector3 &    bxyz
[protected]
 

Definition at line 155 of file BfldValidate.cxx.

References Msg::kWarning, and MSG.

Referenced by TestLoanPool().

00156 {
00157   MSG("Bfld",Msg::kWarning) 
00158     << tag << "  "
00159     << "( x, y, z)=(" <<  xyz.X() << "," <<  xyz.Y() << "," <<  xyz.Z() << ") "
00160     << "(bx,by,bz)=(" << bxyz.X() << "," << bxyz.Y() << "," << bxyz.Z() << ") "
00161     << endl;
00162 }

void BfldValidate::SetDetectorType DetectorType::Detector_t    detector = DetectorType::kNear
 

Definition at line 58 of file BfldValidate.cxx.

References DetectorType::Detector_t, fDetector, fVldContext, Msg::kInfo, SimFlag::kReroot, MSG, and VldContext::Print().

00059 {
00060    // set the detector type and build a VldContext for use in tests
00061    
00062    fDetector = detector;
00063    fVldContext = VldContext(detector,SimFlag::kReroot,VldTimeStamp());
00064 
00065    MSG("Bfld",Msg::kInfo) << "BfldValidate::SetDetectorType " << endl;
00066    fVldContext.Print();
00067 
00068 }

void BfldValidate::TestInterpMethods Int_t    coarseness = -1,
Float_t    x = 22.5 *Munits::cm,
Float_t    y = 22.5 *Munits::cm
 

Definition at line 104 of file BfldValidate.cxx.

References BfldInterpMethod::AsString(), fVldContext, BField::GetBField(), MsgService::GetStream(), i, MsgService::Instance(), BfldInterpMethod::InterpMethod_t, Msg::kInfo, Msg::kWarning, MSG, BField::SetInterpMethod(), and MsgStream::SetLogLevel().

00106 {
00107    // exercise the interpolation methods
00108 
00109    MsgService* msvc = MsgService::Instance();
00110    MsgStream*  mstr = msvc->GetStream("Bfld");
00111    
00112    mstr->SetLogLevel(Msg::kWarning); 
00113    // only put out priority & name fields for Info messages
00114    //   mstr->SetFormat(Msg::kInfo,Msg::kPriority|Msg::kName);
00115 
00116 
00117    MSG("Bfld",Msg::kInfo) << "BfldValidate::TestLoanPool" << endl;
00118 
00119    TVector3 xyz(x,y,0.);
00120    TVector3 bxyz;
00121 
00122    static MsgFormat f8p3("f8.3");
00123 
00124    BField bfield(fVldContext,coarseness,142);
00125 
00126    MSG("Bfld",Msg::kWarning) <<
00127       " (x,y) = (" << f8p3(x) << "," << f8p3(y) << ")" << endl;
00128 
00129    for (Int_t i=-1; i<5; i++) {
00130       
00131       BfldInterpMethod::InterpMethod_t method = 
00132          (BfldInterpMethod::InterpMethod_t) i;
00133 
00134       Char_t mname[30]; mname[29] = 0;
00135       sprintf(mname,"%29s",BfldInterpMethod::AsString(method));
00136 
00137       //      MSG("Bfld",Msg::kWarning) << "SetInterpMethod " 
00138       //                                << i << " " << (int)method 
00139       //                                << " " <<mname << endl;
00140       bfield.SetInterpMethod(method);
00141       //      MSG("Bfld",Msg::kWarning) << "GetBField" << endl;
00142       bxyz = bfield.GetBField(xyz);
00143       MSG("Bfld",Msg::kWarning) 
00144          << " B(" 
00145          << mname //BfldInterpMethod::AsString(method) 
00146          << ") = (" 
00147          << f8p3(bxyz.X()) << "," 
00148          << f8p3(bxyz.Y()) << "," 
00149          << f8p3(bxyz.Z()) << ")" << endl;
00150    }
00151    
00152    mstr->SetLogLevel(Msg::kInfo); // back to default level   
00153 }

void BfldValidate::TestLoanPool  
 

Definition at line 70 of file BfldValidate.cxx.

References fVldContext, BField::GetBField(), BfldLoanPool::Instance(), BfldInterpMethod::kDefault, Msg::kInfo, MSG, BfldLoanPool::Print(), PrintPair(), and BField::SetInterpMethod().

00071 {
00072    // exercise the BfldLoanPool by using different maps
00073 
00074    MSG("Bfld",Msg::kInfo) << "BfldValidate::TestLoanPool" << endl;
00075 
00076    TVector3 xyz(20.*Munits::cm,20.*Munits::cm,0.);
00077    TVector3 bxyz;
00078 
00079    Int_t coarseness = -1;
00080 
00081    BField bfield100(fVldContext,coarseness,100);
00082    bfield100.SetInterpMethod(BfldInterpMethod::kDefault);
00083    bxyz = bfield100.GetBField(xyz);
00084    PrintPair("Map 100",xyz,bxyz);
00085 
00086    BField bfield142(fVldContext,coarseness,142);
00087    bfield142.SetInterpMethod(BfldInterpMethod::kDefault);
00088    bxyz = bfield142.GetBField(xyz);
00089    PrintPair("Map 142",xyz,bxyz);   
00090 
00091    BField bfield120(fVldContext,coarseness,120);
00092    bfield120.SetInterpMethod(BfldInterpMethod::kDefault);
00093    bxyz = bfield120.GetBField(xyz);
00094    PrintPair("Map 120",xyz,bxyz);
00095 
00096    bxyz = bfield100.GetBField(xyz);
00097    PrintPair("Map 100",xyz,bxyz);
00098 
00099    BfldLoanPool *loanpool = BfldLoanPool::Instance();
00100    loanpool->Print();
00101 }


Member Data Documentation

DetectorType::Detector_t BfldValidate::fDetector [protected]
 

Definition at line 47 of file BfldValidate.h.

Referenced by SetDetectorType().

VldContext BfldValidate::fVldContext [protected]
 

Definition at line 48 of file BfldValidate.h.

Referenced by DrawMap(), SetDetectorType(), TestInterpMethods(), and TestLoanPool().


The documentation for this class was generated from the following files:
Generated on Wed Sep 4 19:21:34 2002 for loon by doxygen1.2.16