Skip to content
Snippets Groups Projects
Commit f3e4877a authored by Valerio Ippolito's avatar Valerio Ippolito Committed by Graeme Stewart
Browse files

removed BFieldStand dependency/support (BFieldAth-01-08-08)

parent 563904c3
No related branches found
No related tags found
No related merge requests found
Showing
with 1500 additions and 0 deletions
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef IMAGFIELDATHENASVC
#define IMAGFIELDATHENASVC
#include "GaudiKernel/IInterface.h"
#include "GaudiKernel/StatusCode.h"
#include "AthenaKernel/IOVSvcDefs.h"
#include "BFieldAth/MagFieldAthena.h"
static const InterfaceID IID_IMagFieldAthenaSvc(1001, 1, 0);
class IMagFieldAthenaSvc : virtual public IInterface {
public:
static const InterfaceID& interfaceID() { return IID_IMagFieldAthenaSvc; }
virtual MagFieldAthena* GetMagFieldAthena() = 0;
// retrieve through COOL callback - to be used in client callback method
virtual MagFieldAthena* GetUpdatedMagFieldAthena() = 0;
// check if field was really updated in callback, to be used in clients
virtual bool WasFieldUpdated() = 0;
virtual StatusCode initGeoModel(IOVSVC_CALLBACK_ARGS) = 0;
virtual StatusCode updateField(IOVSVC_CALLBACK_ARGS) = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
//
// Author : Saclay Muon Software Group SaMuSoG
// Date : 18/05/00
//
// MagFieldAthena is a class providing Magnetic Field in Athena
//
#ifndef MAGFIELDATHENA
#define MAGFIELDATHENA
#include <sstream>
#include "BFieldCore/AbstractMagneticField.h"
#define MagFieldAthena AbstractMagneticField
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MAGFIELDSVCWRAPPER_h
#define MAGFIELDSVCWRAPPER_h
#include "BFieldCore/AbstractMagneticField.h"
namespace MagField {
class IMagFieldSvc;
}
class MagFieldSvcWrapper: public AbstractMagneticField {
public:
// Constructor
MagFieldSvcWrapper( MagField::IMagFieldSvc& service );
// Destructor
virtual ~MagFieldSvcWrapper() {}
public:
// XYZ in cm => BXYZ in Tesla (Gradient Telsa/cm)
virtual void field_tesla_cm(float* XYZ,float* BXYZ);
virtual void fieldGradient_tesla_cm(float* XYZ,float* BXYZ);
// XYZ in mm => BXYZ in KiloGauss (G4) (Gradient kiloGauss/cm)
virtual void field_XYZ_in_mm(float* XYZ,float* BXYZ);
virtual void fieldGradient_XYZ_in_mm(float* XYZ,float* BXYZ);
// set Tilts extern parameters of b-field axis dx,dy,dz,dtheta,dphi,dpsi
void setSolenoidTilts( float* Dxyz_i, double theta, double phi, double psi );
// Where am I with respect to the Magnetic Field calculation
virtual void whereAmI(float* XYZ, int &iz);
virtual const char * whereAmI(float* XYZ);
private:
MagField::IMagFieldSvc* m_service;
};
#endif
package BFieldAth
#
author Marc Virchaux <virchaux@hep.saclay.cea.fr>
#
public
use AtlasPolicy AtlasPolicy-*
use AthenaKernel AthenaKernel-* Control
use GaudiInterface GaudiInterface-* External
use BFieldCore BFieldCore-* MagneticField
##################################################
private
use AthenaPoolUtilities AthenaPoolUtilities-* Database/AthenaPOOL
use AtlasCORAL AtlasCORAL-* External
#use BFieldStand BFieldStand-* MagneticField
use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel
use PathResolver PathResolver-* Tools
use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL
use StoreGate StoreGate-* Control
use MagFieldInterfaces * MagneticField
#
public
library BFieldAth *.F *.cxx components/*.cxx
apply_pattern component_library
apply_pattern declare_joboptions files="*.txt *.py"
from AthenaCommon.Logging import logging
logging.getLogger().error("BFieldAth/BFieldAth_jobOptions.py is OBSOLETE as the package is being DISCONTINUED")
logging.getLogger().error("please use import MagFieldServices.SetupField instead")
logging.getLogger().error("package BField will be removed from the release on June 13th, 2014")
raise RuntimeError('protectedInclude(\'BFieldAth/BFieldAth_jobOptions.py\') is OBSOLETE, use instead: import MagFieldServices.SetupField')
AllAlgs = False # if false, all algorithms are switched off by defaults
#DetDescrVersion = 'ATLAS-CSC-01-00-00'
#DetDescrVersion = 'ATLAS-CSC-01-01-00'
#DetDescrVersion = "ATLAS-CSC-01-02-00"
#DetDescrVersion = "ATLAS-CSC-02-01-00"
#DetDescrVersion = "ATLAS-CSC-02-00-00"
#DetDescrVersion = "ATLAS-CommNF-05-00-00"
#DetDescrVersion = "ATLAS-GEO-00-00-00"
#DetDescrVersion = "ATLAS-GEO-01-00-00"
#DetDescrVersion = "ATLAS-GEO-02-00-00"
#DetDescrVersion = "ATLAS-GEO-02-00-00"
#DetDescrVersion = "ATLAS-GEO-03-00-00"
#DetDescrVersion = "ATLAS-GEO-04-00-00"
#DetDescrVersion = "ATLAS-TEST"
DetDescrVersion = "ATLAS-GEO-08-00-00"
#DetDescrVersion = "ATLAS-GEONTF-05-00-00"
#
doWriteESD=False # uncomment if do not write ESD
doWriteAOD=False # uncomment if do not write AOD
doAOD=False # uncomment if do not run AOD making algorithms
doWriteTAG=False # uncomment if do not write TAG
#
doMissingET=False
#
doMoore=False
doMuonIDStandAlone=False
doMuonIDCombined=False
doMuGirl=False
doStaco=False
doMuTag=False
#
doCBNT=False
doTrigger = False # for example do not run trigger simulation
doESD=False # uncomment if do not run ESD making algorithms
doWriteESD=False # uncomment if do not write ESD
doAOD=False # uncomment if do not run AOD making algorithms
doWriteAOD=False # uncomment if do not write AOD
doWriteTAG=False # uncomment if do not write TAG
# DetFlags modifications are best set here (uncomment RecExCommon_flags first)
include ("RecExCommon/RecExCommon_flags.py")
# switch off ID, calo, or muons
DetFlags.ID_setOff()
DetFlags.Calo_setOff()
DetFlags.Muon_setOff()
PoolRDOInput=["/afs/cern.ch/atlas/project/muon/data/csc12/misal1_csc11.005145.PythiaZmumu.digit.RDO.v12003101_tid003501._00001.pool.root.1"]
# main jobOption
include ("RecExCommon/RecExCommon_topOptions.py")
#--------------------------------------------------------------
# MagField
# Ignore la diff entre tag simu et Tag reco
#GeoModelSvc.IgnoreTagDifference = True
ServiceMgr.GeoModelSvc.IgnoreTagDifference = True
#--------------------------------------------------------------
# BFieldAth
#--------------------------------------------------------------
include( "BFieldAth/BFieldAth_jobOptions.py" )
###MagFieldAthenaSvc.NameOfTheSource = "BYPYTH"
###MagFieldAthenaSvc.dx = 0.001
###MagFieldAthenaSvc.NameOfTheBfieldFile = "bmagatlas05_test2_10250Amp.data" ;
###MagFieldAthenaSvc.NameOfTheBfieldFile = "bmagatlas05_test2_NoSolenoid.data" ;
###MagFieldAthenaSvc.NameOfTheBfieldFile = "bmagatlas04_test1_WithNoToroid_OnlySolAndIron.data" ;
###MagFieldAthenaSvc.SetupCOOL=True
###MagFieldAthenaSvc.NameOfTheSource = "COOL"
#-----------------------------------------------------------------
# use DCS only if not running online
ServiceMgr.MagFieldAthenaSvc.NameOfTheSource='COOL'
from BFValidation.BFValidationConf import FastField
topSequence += FastField( "MyFastField" )
#--------------------------------------------------------------
# BFieldAth
#
if not 'MuonLayout' in dir():
# default value
MagFieldAthenaSvc.NameOfTheBfieldFile = "bmagatlas02.data"
else:
if ( MuonLayout == "P03-DC2" or MuonLayout == "P03-DC1" ):
MagFieldAthenaSvc.NameOfTheBfieldFile = "bmagatlas02.data"
else:
if (MuonLayout == "Q02_initial" or MuonLayout == "Q02") :
# MagFieldAthenaSvc.NameOfTheBfieldFile = "bmagatlas03_test.data"
MagFieldAthenaSvc.NameOfTheBfieldFile = "bmagatlas03_test2.data"
else:
if (MuonLayout == "CTB2004" ):
print " WARNING magnetic field map for testbeam !!!! "
MagFieldAthenaSvc.NameOfTheBfieldFile = "mbps1-all-id-800-mbps2-muons-800.data"
else:
raise RuntimeError, 'ERROR : Unknown MuonLayout allowed values are \nP03-DC1\nP03-DC2\nQ02_initial\nQ02\nCTB2004'
print "Selecting B field map ",MagFieldAthenaSvc.NameOfTheBfieldFile
This diff is collapsed.
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef MAGFIELDATHENASVC
#define MAGFIELDATHENASVC
#include "GaudiKernel/Service.h"
#include "GaudiKernel/StatusCode.h"
#include "GaudiKernel/ServiceHandle.h"
#include "StoreGate/StoreGateSvc.h"
/////////////////////////////////////////////////////////////////////////////
#include "BFieldCore/MagFieldParam.h"
#include "BFieldAth/MagFieldAthena.h"
#include "BFieldAth/IMagFieldAthenaSvc.h"
#include "MagFieldInterfaces/IMagFieldSvc.h"
template <class TYPE> class SvcFactory;
class IGeoModelSvc;
class IRDBAccessSvc;
class CondAttrListCollection;
class MagFieldAthenaSvc : public Service , virtual public IMagFieldAthenaSvc {
public:
///////////////////////////////////
static const InterfaceID& interfaceID() { return IID_IMagFieldAthenaSvc; }
virtual StatusCode initialize();
virtual StatusCode finalize();
virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
MagFieldAthena* GetMagFieldAthena();
// retrieve through COOL callback - to be used in client callback method
MagFieldAthena* GetUpdatedMagFieldAthena();
// check if field was really updated in callback, to be used in clients
bool WasFieldUpdated();
// Vakho: This method does mag field initialization. It gets called in two
// different ways:
// 1. When GeoModelSvc is configured from job options, then initGeoModel
// is called at initialization phase
// 2. When GeoModelSvc is configured automaticaly from TagInfo, then
// initGeoModelSvc is registered as callback and is called after GeoModelSvc
// initialization has been done
StatusCode initGeoModel(IOVSVC_CALLBACK_ARGS);
StatusCode initGeoModel2(IOVSVC_CALLBACK_ARGS);
StatusCode updateField(IOVSVC_CALLBACK_ARGS);
/// templated function for registering a callback
template <typename T1>
StatusCode regFcn( StatusCode (T1::*fcn)(IOVSVC_CALLBACK_ARGS),
const T1* obj);
friend class SvcFactory<MagFieldAthenaSvc>;
///////////////////////////////////
protected:
// Standard Constructor
MagFieldAthenaSvc(const std::string& name, ISvcLocator* svc);
// Standard Destructor
virtual ~MagFieldAthenaSvc();
///////////////////////////////////
private:
// private functions
// get stuff to run
void getTagOracle (StatusCode &Sc);
void getTagOracle2 (StatusCode &Sc);
void getBfieldFileName (const IGeoModelSvc * geoModel, IRDBAccessSvc * accessSvc);
void getBfieldFileName2(const IGeoModelSvc * geoModel, IRDBAccessSvc * accessSvc);
void getBfieldDisplacements (const IGeoModelSvc * geoModel, IRDBAccessSvc * accessSvc);
void getCurrent (const IGeoModelSvc * geoModel, IRDBAccessSvc * accessSvc);
bool isThatFileExists( const std::string & );
// Vakho: This method performs actuall initialization of the Magnetic field based
// on m_param values
const IGeoModelSvc* geoModel;
StatusCode initMagField();
bool checkTol(const double xo, const double xc);
std::string decodePath(const std::string& path);
StatusCode chooseParamFromCOOL(const float reqSolCur,const float reqTorCur,
MagFieldParam& param);
// job option parameters
MagFieldParam par_param; // managed by PropertySvc
std::string m_alreadyReadFile;
// currents set by HLT framework for online running
double par_onlineSolCur;
double par_onlineTorCur;
bool par_setupcool; // flag to setup COOL callback infrastructure
bool par_usedcs; // include DCS currents when using COOL
float par_scaletolerance; // minimum fractional deviation to scale field
float par_zerotolerance; // current below which considered zero (amps)
float par_currenttolerance; // absolute change in currents which
// triggers field update (amps)
float par_maptolerance; // maximum acceptable deviation (fractional, S+T)
// between map and real currents to accept map
bool par_crashmap; // crash (return FATAL) if acceptable deviation exceeded
// otherwise just print WARNING
// fixed parameters
const std::string m_coolBFieldMap;
const std::string m_coolCurrents;
const float m_refSolCur; // refsolenoid and toriod currents for norml
const float m_refTorCur;
// internal variables
StoreGateSvc* p_detStore;
MagFieldAthena* p_MagFieldAthena; // pointer to BField itself
// Datahandles for the conditions data objects
const DataHandle<CondAttrListCollection> h_coolBFieldMap;
const DataHandle<CondAttrListCollection> h_coolCurrents;
MagFieldParam m_param; // parameters in use for actual field
bool alreadyReadFile;
int semiAnSol;
bool m_gotcooldata; // COOL-based field retrieve has been done
bool m_coolupdated; // Last callback actually updated the field
// counters to count number of retrievals of MagFieldAthena through
// old and new interfaces, at initialize and in event loop
int m_getbad; // counter number of bad retrievals at initialise, old int
int m_getgood; // counter number of good retrieves, old interface
int m_getcoolbad; // counter number of bad retrieves with COOL
int m_getcoolgood; // counter number of good retrives with COOL
bool m_useFieldService;
ServiceHandle<MagField::IMagFieldSvc> m_fieldService;
};
template <typename T>
StatusCode MagFieldAthenaSvc::regFcn(
StatusCode (T::*fcn)(IOVSVC_CALLBACK_ARGS),const T* obj) {
return p_detStore->regFcn(&MagFieldAthenaSvc::updateField,this,fcn,obj);
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "BFieldAth/MagFieldSvcWrapper.h"
#include "MagFieldInterfaces/IMagFieldSvc.h"
// Constructor
MagFieldSvcWrapper::MagFieldSvcWrapper( MagField::IMagFieldSvc& service )
: m_service(&service)
{
// copy magnet status from the underlying service
setSolenoidOn( m_service->solenoidOn() );
setToroidBarrelOn( m_service->toroidOn() );
setToroidECTAOn( m_service->toroidOn() );
setToroidECTCOn( m_service->toroidOn() );
setAllToroidOn( m_service->toroidOn() );
setFieldStatusOn( m_service->solenoidOn() && m_service->toroidOn() );
}
// XYZ[3] in cm -> BXYZ[3] in T
void MagFieldSvcWrapper::field_tesla_cm(float* XYZ,float* BXYZ) {
double xyz[3];
for( int i=0;i<3;++i ) xyz[i] = 10.*XYZ[i]; // cm -> mm
double bxyz[3];
m_service->getField(xyz, bxyz); // mm -> kT
for( int i=0;i<3;++i ) BXYZ[i] = 1000.*bxyz[i]; // kT -> T
}
// XYZ[3] in cm -> BXYZ[12] in T and T/cm
void MagFieldSvcWrapper::fieldGradient_tesla_cm(float* XYZ,float* BXYZ) {
double xyz[3];
for( int i=0;i<3;++i ) xyz[i] = 10.*XYZ[i]; // cm -> mm
double bxyz[3];
double deriv[9];
m_service->getField(xyz, bxyz, deriv); // mm -> kT and kT/mm
for( int i=0;i<3;++i ) BXYZ[i] = 1000.*bxyz[i]; // kT -> T
for( int i=0;i<9;++i ) BXYZ[i+3] = 10000.*deriv[i]; // kT/mm -> T/cm
}
// XYZ[3] in mm -> BXYZ[3] in kG
void MagFieldSvcWrapper::field_XYZ_in_mm(float* XYZ,float* BXYZ) {
double xyz[3];
for( int i=0;i<3;++i ) xyz[i] = XYZ[i]; // mm -> mm
double bxyz[3];
m_service->getField(xyz, bxyz); // mm -> kT
for( int i=0;i<3;++i ) BXYZ[i] = 10000.*bxyz[i]; // kT -> kG
}
// XYZ[3] in mm -> BXYZ[12] in kG and kG/mm
void MagFieldSvcWrapper::fieldGradient_XYZ_in_mm(float* XYZ,float* BXYZ) {
double xyz[3];
for( int i=0;i<3;++i ) xyz[i] = XYZ[i]; // mm -> mm
double bxyz[3];
double deriv[9];
m_service->getField(xyz, bxyz, deriv); // mm -> kT and kT/mm
for( int i=0;i<3;++i ) BXYZ[i] = 10000.*bxyz[i]; // kT -> kG
for( int i=0;i<9;++i ) BXYZ[i+3] = 10000.*deriv[i]; // kT/mm -> kG/mm
}
void MagFieldSvcWrapper::whereAmI(float* /*XYZ*/, int& /*iz*/ ){}
const char* MagFieldSvcWrapper::whereAmI(float* /*XYZ*/) { return "here"; }
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "../MagFieldAthenaSvc.h"
DECLARE_SERVICE_FACTORY( MagFieldAthenaSvc )
DECLARE_FACTORY_ENTRIES(BFieldAth) {
DECLARE_SERVICE( MagFieldAthenaSvc )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES(BFieldAth)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment