00001 #include <iostream>
00002 using std::cout;
00003 using std::endl;
00004 #include <string>
00005 #include <cassert>
00006
00007 #include "BField/BField.h"
00008 #include "CandFitTrackMS/BFieldMS.h"
00009 #include "Conventions/Detector.h"
00010 #include "Validity/VldContext.h"
00011
00012 BFieldMS::BFieldMS(const VldContext *vldc)
00013 {
00014 assert (vldc);
00015
00016
00017 bf = 0;
00018 switch (vldc->GetDetector()) {
00019 case Detector::kFar:
00020 bf = new BField(*vldc);
00021 break;
00022 case Detector::kNear:
00023 bf = new BField(*vldc);
00024 break;
00025 default:
00026 cout << "BFieldMS can not handle " << *vldc << endl;
00027 assert(0);
00028 }
00029 }
00030
00031 BFieldMS::~BFieldMS()
00032 {
00033 if (bf) {
00034 delete bf;
00035 }
00036 }
00037
00038 TVector3 BFieldMS::GetBField(TVector3 &xyz)
00039 {
00040 TVector3 bxyz;
00041 if (!bf) {
00042 cout << "no bf!" << endl;
00043 bxyz(0) = 0.;
00044 bxyz(1) = 0.;
00045 bxyz(2) = 0.;
00046 }
00047 else {
00048 bxyz = bf->GetBField(xyz);
00049 }
00050 return bxyz;
00051 }