| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

BIntegrator Class Reference

#include <Magnet/BIntegrator.h>

Inheritance diagram for BIntegrator:

[legend]
Collaboration diagram for BIntegrator:
[legend]
List of all members.

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 ()
INTupleSvcntupleSvc () const
INTupleSvcevtColSvc () const
IDataProviderSvcdetSvc () const
IDataProviderSvcevtSvc () const
IIncidentSvcincSvc () const
IChronoStatSvcchronoSvc () const
IHistogramSvchistoSvc () const
IAlgContextSvccontextSvc () const
DataObjectput (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const
DataObjectput (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
IUpdateManagerSvcupdMgrSvc () const
IDataProviderSvcfastContainersSvc () 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
MsgStreammsgStream (const MSG::Level level) const
MsgStreamalways () const
MsgStreamfatal () const
MsgStreamerr () const
MsgStreamerror () const
MsgStreamwarning () const
MsgStreaminfo () const
MsgStreamdebug () const
MsgStreamverbose () const
MsgStreammsg () const
const Statisticscounters () const
StatEntitycounter (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 IInterfaceparent () 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 PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
PropertyMgrgetPropertyMgr ()
ISvcLocatorserviceLocator () const
ISvcLocatorsvcLoc () const
IMessageSvcmsgSvc () const
IToolSvctoolSvc () 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 *)
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IAuditorSvcauditorSvc () const
IMonitorSvcmonitorSvc () 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 InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()

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< ServiceEntryServices

Protected Member Functions

StatusCode releaseTool (const IAlgTool *tool) const
StatusCode releaseSvc (const IInterface *svc) const
int outputLevel () const
virtual unsigned long refCount () const
IntegerPropertyoutputLevelProperty ()
void initOutputLevel (Property &prop)

Static Protected Attributes

static const bool IgnoreRootInTES
static const bool UseRootInTES

Private Member Functions

StatusCode calculateBdlCenter ()

Private Attributes

IMagneticFieldSvcm_pIMF
int m_nSteps
Gaudi::XYZPoint m_centerZ
double m_firstZ
double m_lastZ

Detailed Description

Author:
Rutger Hierck
Date:
2002-05-28

Definition at line 25 of file BIntegrator.h.


Constructor & Destructor Documentation

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]

Destructor.

Definition at line 43 of file BIntegrator.cpp.

00043 {}; 


Member Function Documentation

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 }


Member Data Documentation

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.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:04:55 2011 for Magnet by doxygen 1.4.7