#include <Magnet/BIntegrator.h>
Inheritance diagram for BIntegrator:
Public Member Functions | |
BIntegrator (const std::string &type, const std::string &name, const IInterface *parent) | |
Standard constructor. | |
virtual | ~BIntegrator () |
Destructor. | |
StatusCode | initialize () |
Initialization. | |
StatusCode | calculateBdlAndCenter (const Gaudi::XYZPoint &beginPoint, const Gaudi::XYZPoint &endPoint, const double tX, const double tY, double &zCenter, Gaudi::XYZVector &Bdl) const |
Get the z of center and the total Bdl. | |
virtual StatusCode | finalize () |
INTupleSvc * | ntupleSvc () const |
INTupleSvc * | evtColSvc () const |
IDataProviderSvc * | detSvc () const |
IDataProviderSvc * | evtSvc () const |
IIncidentSvc * | incSvc () const |
IChronoStatSvc * | chronoSvc () const |
IHistogramSvc * | histoSvc () const |
IAlgContextSvc * | contextSvc () const |
DataObject * | put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const |
DataObject * | put (DataObject *object, const std::string &address, const bool useRootInTES=true) const |
Gaudi::Utils::GetData< TYPE >::return_type | get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
Gaudi::Utils::GetData< TYPE >::return_type | get (const std::string &location, const bool useRootInTES=true) const |
TYPE * | getDet (IDataProviderSvc *svc, const std::string &location) const |
TYPE * | getDet (const std::string &location) const |
bool | exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
bool | exist (const std::string &location, const bool useRootInTES=true) const |
bool | existDet (IDataProviderSvc *svc, const std::string &location) const |
bool | existDet (const std::string &location) const |
TYPE * | getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
TYPE * | getOrCreate (const std::string &location, const bool useRootInTES=true) const |
TOOL * | tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const |
TOOL * | tool (const std::string &type, const IInterface *parent=0, bool create=true) const |
SERVICE * | svc (const std::string &name, const bool create=true) const |
IUpdateManagerSvc * | updMgrSvc () const |
IDataProviderSvc * | fastContainersSvc () const |
StatusCode | Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const |
StatusCode | Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const |
StatusCode | Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const |
StatusCode | Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
MsgStream & | msgStream (const MSG::Level level) const |
MsgStream & | always () const |
MsgStream & | fatal () const |
MsgStream & | err () const |
MsgStream & | error () const |
MsgStream & | warning () const |
MsgStream & | info () const |
MsgStream & | debug () const |
MsgStream & | verbose () const |
MsgStream & | msg () const |
const Statistics & | counters () const |
StatEntity & | counter (const std::string &tag) const |
MSG::Level | msgLevel () const |
bool | msgLevel (const MSG::Level level) const |
void | resetMsgStream () const |
bool | typePrint () const |
bool | propsPrint () const |
bool | statPrint () const |
bool | errorsPrint () const |
long | printStat (const MSG::Level level=MSG::ALWAYS) const |
long | printErrors (const MSG::Level level=MSG::ALWAYS) const |
long | printProps (const MSG::Level level=MSG::ALWAYS) const |
void | registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL) |
StatusCode | runUpdate () |
TransientFastContainer< T > * | getFastContainer (const std::string &location, typename TransientFastContainer< T >::size_type initial=0) |
StatusCode | release (const IInterface *interface) const |
virtual unsigned long | release () |
const std::string & | context () const |
const std::string & | rootInTES () const |
double | globalTimeOffset () const |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
virtual unsigned long | addRef () |
virtual const std::string & | name () const |
virtual const std::string & | type () const |
virtual const IInterface * | parent () const |
virtual StatusCode | configure () |
virtual StatusCode | start () |
virtual StatusCode | stop () |
virtual StatusCode | terminate () |
virtual StatusCode | reinitialize () |
virtual StatusCode | restart () |
virtual Gaudi::StateMachine::State | FSMState () const |
virtual Gaudi::StateMachine::State | targetFSMState () const |
virtual StatusCode | sysInitialize () |
virtual StatusCode | sysStart () |
virtual StatusCode | sysStop () |
virtual StatusCode | sysFinalize () |
virtual StatusCode | sysReinitialize () |
virtual StatusCode | sysRestart () |
virtual StatusCode | setProperty (const Property &p) |
virtual StatusCode | setProperty (const std::string &s) |
virtual StatusCode | setProperty (const std::string &n, const std::string &v) |
StatusCode | setProperty (const std::string &name, const TYPE &value) |
virtual StatusCode | getProperty (Property *p) const |
virtual const Property & | getProperty (const std::string &name) const |
virtual StatusCode | getProperty (const std::string &n, std::string &v) const |
virtual const std::vector< Property * > & | getProperties () const |
PropertyMgr * | getPropertyMgr () |
ISvcLocator * | serviceLocator () const |
ISvcLocator * | svcLoc () const |
IMessageSvc * | msgSvc () const |
IToolSvc * | toolSvc () const |
StatusCode | setProperties () |
StatusCode | service (const std::string &name, T *&svc, bool createIf=true) const |
StatusCode | service (const std::string &type, const std::string &name, T *&svc) const |
void | declInterface (const InterfaceID &, void *) |
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const |
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const |
IAuditorSvc * | auditorSvc () const |
IMonitorSvc * | monitorSvc () const |
void | declareInfo (const std::string &name, const T &var, const std::string &desc) const |
void | declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const |
Static Public Member Functions | |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
Public Attributes | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
Protected Types | |
typedef std::map< std::string, StatEntity > | Statistics |
typedef std::map< std::string, unsigned int > | Counter |
typedef std::vector< IAlgTool * > | AlgTools |
typedef std::pair< IInterface *, std::string > | ServiceEntry |
typedef std::vector< ServiceEntry > | Services |
Protected Member Functions | |
StatusCode | releaseTool (const IAlgTool *tool) const |
StatusCode | releaseSvc (const IInterface *svc) const |
int | outputLevel () const |
virtual unsigned long | refCount () const |
IntegerProperty & | outputLevelProperty () |
void | initOutputLevel (Property &prop) |
Static Protected Attributes | |
static const bool | IgnoreRootInTES |
static const bool | UseRootInTES |
Private Member Functions | |
StatusCode | calculateBdlCenter () |
Private Attributes | |
IMagneticFieldSvc * | m_pIMF |
int | m_nSteps |
Gaudi::XYZPoint | m_centerZ |
double | m_firstZ |
double | m_lastZ |
Definition at line 25 of file BIntegrator.h.
BIntegrator::BIntegrator | ( | const std::string & | type, | |
const std::string & | name, | |||
const IInterface * | parent | |||
) |
Standard constructor.
Definition at line 29 of file BIntegrator.cpp.
00032 : GaudiTool ( type, name , parent ) 00033 { 00034 declareInterface<IBIntegrator>(this); 00035 00036 declareProperty( "NSteps", m_nSteps = 101 ); 00037 declareProperty( "FirstZ", m_firstZ = 0.1*Gaudi::Units::mm ); 00038 declareProperty( "LastZ", m_lastZ = 9400.*Gaudi::Units::mm ); 00039 }
BIntegrator::~BIntegrator | ( | ) | [virtual] |
StatusCode BIntegrator::initialize | ( | ) | [virtual] |
Initialization.
Reimplemented from GaudiTool.
Definition at line 48 of file BIntegrator.cpp.
00049 { 00050 StatusCode sc = GaudiTool::initialize(); 00051 if (sc.isFailure()) return sc; // error already reported by base class 00052 00053 // Retrieve a pointer to the magnetic field service 00054 m_pIMF = svc<IMagneticFieldSvc>( "MagneticFieldSvc", true ); 00055 00056 sc = calculateBdlCenter(); 00057 info() << "Center of the field is at the z positions " 00058 << m_centerZ << endreq; 00059 00060 return sc; 00061 }
StatusCode BIntegrator::calculateBdlAndCenter | ( | const Gaudi::XYZPoint & | beginPoint, | |
const Gaudi::XYZPoint & | endPoint, | |||
const double | tX, | |||
const double | tY, | |||
double & | zCenter, | |||
Gaudi::XYZVector & | Bdl | |||
) | const |
Get the z of center and the total Bdl.
Now do the steps again but find the half of the magnetic field....
Definition at line 66 of file BIntegrator.cpp.
00072 { 00073 // Point where field should be calculated 00074 Gaudi::XYZPoint point(0.001,0.001,0.0001); 00075 Gaudi::XYZVector bField; // returned field 00076 Bdl.SetXYZ(0.,0.,0.); 00077 00078 //First get the Center by walking in two rays.. 00079 double zCen = m_centerZ.x(); // the Bdlx is the important component 00080 double xCen = endPoint.x() + tX*(zCen-endPoint.z()); 00081 double yCen = endPoint.y() + tY*(zCen-endPoint.z()); 00082 if (xCen/zCen>0.3) { 00083 xCen = 0.3*zCen; 00084 } 00085 else if (xCen/zCen< -0.3) { 00086 xCen = -0.3*zCen; 00087 } 00088 if( yCen/zCen>0.25) { 00089 yCen = 0.25*zCen; 00090 } 00091 else if (yCen/zCen< -0.25){ 00092 yCen = -0.25*zCen; 00093 } 00094 00095 double angleX = xCen/zCen; 00096 double angleY = yCen/zCen; 00097 double stepSize = (endPoint.z()-beginPoint.z())/(double)m_nSteps; 00098 int iStep; 00099 StatusCode sc; 00100 for(iStep=0;iStep<m_nSteps;iStep++) { 00101 00102 if(point.z()>zCen) { 00103 angleX = tX; 00104 angleY = tY; 00105 } 00106 double dX = angleX*stepSize; 00107 double dY = angleY*stepSize; 00108 double dZ = stepSize; 00109 point.SetX( point.x()+ dX); 00110 point.SetY( point.y()+ dY); 00111 point.SetZ( point.z()+ dZ); 00112 sc = m_pIMF->fieldVector(point,bField); 00113 if( !sc.isSuccess() ) warning() << "field vector not calculated" << endmsg; 00114 00115 //Cacluate the Bdl 00116 Bdl.SetX( Bdl.x() + dY* bField.z()- dZ*bField.y() ); 00117 Bdl.SetY( Bdl.y() + dZ*bField.x() -dX*bField.z()); 00118 Bdl.SetZ( Bdl.z() + dX*bField.y() -dY*bField.x()); 00119 00120 } // iStep 00121 00123 00124 double Bdlx_half =0.5*Bdl.x(); 00125 double Bdly_half =0.5*Bdl.y(); 00126 double Bdlz_half =0.5*Bdl.z(); 00127 00128 Bdl.SetXYZ( 0., 0., 0. ); 00129 00130 double min_Bdlx =10000.; 00131 double min_Bdly =10000.; 00132 double min_Bdlz =10000.; 00133 Gaudi::XYZPoint centerZ(0.,0.,0.); 00134 //reset al the variables used 00135 angleX = xCen/zCen; 00136 angleY = yCen/zCen; 00137 point.SetXYZ( 0., 0., 0. ); 00138 for(iStep=0;iStep<m_nSteps;iStep++) { 00139 00140 if(point.z()>zCen) { 00141 angleX = tX; 00142 angleY = tY; 00143 } 00144 double dX = angleX*stepSize; 00145 double dY = angleY*stepSize; 00146 double dZ = stepSize; 00147 point.SetX( point.x()+ dX); 00148 point.SetY( point.y()+ dY); 00149 point.SetZ( point.z()+ dZ); 00150 sc = m_pIMF->fieldVector(point,bField); 00151 if( !sc.isSuccess() ) warning() << "field vector not calculated" << endmsg; 00152 00153 //Cacluate the Bdl 00154 Bdl.SetX( Bdl.x() + dY* bField.z()- dZ*bField.y() ); 00155 Bdl.SetY( Bdl.y() + dZ*bField.x() -dX*bField.z()); 00156 Bdl.SetZ( Bdl.z() + dX*bField.y() -dY*bField.x()); 00157 00158 if(fabs(Bdl.x()-Bdlx_half)< min_Bdlx){ 00159 min_Bdlx=fabs(Bdl.x()-Bdlx_half); 00160 centerZ.SetX(point.z()); 00161 } 00162 if(fabs(Bdl.y()-Bdly_half)< min_Bdly){ 00163 min_Bdly=fabs(Bdl.y()-Bdly_half); 00164 centerZ.SetY(point.z()); 00165 } 00166 if(fabs(Bdl.z()-Bdlz_half)< min_Bdlz){ 00167 min_Bdlz=fabs(Bdl.z()-Bdlz_half); 00168 centerZ.SetZ(point.z()); 00169 } 00170 00171 } 00172 00173 //take the x component of the zcenter..... 00174 zCenter = centerZ.x(); 00175 00176 return StatusCode::SUCCESS; 00177 }
StatusCode BIntegrator::calculateBdlCenter | ( | ) | [private] |
Definition at line 182 of file BIntegrator.cpp.
00183 { 00184 // Centre of the field 00185 Gaudi::XYZVector bField; 00186 00187 Gaudi::XYZVector BdlTotal(0.,0.,0.); 00188 Gaudi::XYZPoint position = Gaudi::XYZPoint(0.0,0.0,0.); 00189 00190 double stepSize = (m_lastZ-m_firstZ) / (double)m_nSteps; 00191 00192 // Get the integral field 00193 int iStep; 00194 StatusCode sc; 00195 00196 for( iStep=0;iStep < m_nSteps;iStep++) { 00197 position.SetXYZ( 0.1, 0.1, m_firstZ+((double)iStep+0.5)*stepSize ); 00198 sc = m_pIMF -> fieldVector( position,bField ); 00199 if( !sc.isSuccess() ) warning() << "field vector not calculated" << endmsg; 00200 00201 //Calculate the Bdl 00202 BdlTotal.SetX( BdlTotal.x() - stepSize*bField.y() ); 00203 BdlTotal.SetY( BdlTotal.y() + stepSize*bField.x() ); 00204 BdlTotal.SetZ( BdlTotal.z() + 0.); 00205 } // iStep 00206 00207 double Bdlx_half = 0.5*BdlTotal.x(); 00208 double Bdly_half = 0.5*BdlTotal.y(); 00209 double Bdlz_half = 0.5*BdlTotal.z(); 00210 00211 BdlTotal.SetXYZ( 0., 0., 0. ); 00212 00213 double min_Bdlx = 10000.; 00214 double min_Bdly = 10000.; 00215 double min_Bdlz = 10000.; 00216 00217 //Loop again and find the middle of each of the components 00218 for ( iStep=0; iStep < m_nSteps; iStep++ ) { 00219 double z = m_firstZ+ (iStep+0.5)*stepSize; 00220 position.SetXYZ( 0.1, 0.1, z ); 00221 sc = m_pIMF -> fieldVector( position,bField ); 00222 if( !sc.isSuccess() ) warning() << "field vector not calculated" << endmsg; 00223 //Cacluate the Bdl 00224 BdlTotal.SetX( BdlTotal.x() - stepSize*bField.y() ); 00225 BdlTotal.SetY( BdlTotal.y() + stepSize*bField.x() ); 00226 BdlTotal.SetZ( BdlTotal.z() + 0.); 00227 if ( fabs(BdlTotal.x()-Bdlx_half) < min_Bdlx ) { 00228 min_Bdlx = fabs( BdlTotal.x()-Bdlx_half ); 00229 m_centerZ.SetX(z); 00230 } 00231 if ( fabs(BdlTotal.y()-Bdly_half)< min_Bdly ) { 00232 min_Bdly = fabs( BdlTotal.y()-Bdly_half ); 00233 m_centerZ.SetY(z); 00234 } 00235 if ( fabs(BdlTotal.z()-Bdlz_half)< min_Bdlz ) { 00236 min_Bdlz = fabs( BdlTotal.z()-Bdlz_half ); 00237 m_centerZ.SetZ(z); 00238 } 00239 } 00240 00241 return StatusCode::SUCCESS; 00242 }
IMagneticFieldSvc* BIntegrator::m_pIMF [private] |
Definition at line 50 of file BIntegrator.h.
int BIntegrator::m_nSteps [private] |
Definition at line 52 of file BIntegrator.h.
Gaudi::XYZPoint BIntegrator::m_centerZ [private] |
Definition at line 53 of file BIntegrator.h.
double BIntegrator::m_firstZ [private] |
Definition at line 54 of file BIntegrator.h.
double BIntegrator::m_lastZ [private] |
Definition at line 55 of file BIntegrator.h.