|
ATLAS Offline Software
|
#include <MagFieldTestbedAlg.h>
|
| MagFieldTestbedAlg (const std::string &name, ISvcLocator *pSvcLocator) |
|
virtual | ~MagFieldTestbedAlg () |
| Destructor. More...
|
|
StatusCode | initialize () |
| Athena algorithm's interface method initialize() More...
|
|
StatusCode | execute () |
| Athena algorithm's interface method execute() More...
|
|
StatusCode | finalize () |
| Athena algorithm's interface method finalize() More...
|
|
virtual StatusCode | sysInitialize () override |
| Override sysInitialize. More...
|
|
virtual const DataObjIDColl & | extraOutputDeps () const override |
| Return the list of extra output dependencies. More...
|
|
ServiceHandle< StoreGateSvc > & | evtStore () |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | evtStore () const |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | detStore () const |
| The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
virtual StatusCode | sysStart () override |
| Handle START transition. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. More...
|
|
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T > &t) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| Declare a new Gaudi property. More...
|
|
void | updateVHKA (Gaudi::Details::PropertyBase &) |
|
MsgStream & | msg () const |
|
MsgStream & | msg (const MSG::Level lvl) const |
|
bool | msgLvl (const MSG::Level lvl) const |
|
Definition at line 33 of file MagFieldTestbedAlg.h.
◆ StoreGateSvc_t
◆ MagFieldTestbedAlg()
MagField::MagFieldTestbedAlg::MagFieldTestbedAlg |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
pSvcLocator |
|
) |
| |
Definition at line 57 of file MagFieldTestbedAlg.cxx.
71 "Name of the THistSvc output stream");
75 "Name of the TTree object in the output file.");
86 "Number of steps along x-direction (granularity)");
88 "Number of steps along x-direction (granularity)");
90 "Number of steps along x-direction (granularity)");
94 "Filename of a reference file to compare the output with");
96 "TTree object name in the reference file");
98 "Numerical tolerance when comparing against reference.");
100 "Numerical tolerance when comparing against reference.");
◆ ~MagFieldTestbedAlg()
MagField::MagFieldTestbedAlg::~MagFieldTestbedAlg |
( |
| ) |
|
|
virtual |
◆ checkWithReference()
bool MagField::MagFieldTestbedAlg::checkWithReference |
( |
| ) |
|
|
private |
check current field with reference field
Definition at line 416 of file MagFieldTestbedAlg.cxx.
419 TFile *refF = TFile::Open(
m_refFile.c_str());
420 TTree *refT = (refF) ? (TTree*) refF->Get(
m_refTreeName.c_str()) :
nullptr;
433 refT->SetBranchStatus(
"*", 1);
436 for (
int i = 0;
i < 4;
i++)
438 double refField[3] = { 0., 0., 0. };
439 double refDerivatives[9] = { 0., 0., 0., 0., 0., 0., 0., 0., 0. };
441 refT->SetBranchAddress(
"pos", &
m_xyzt);
442 refT->SetBranchAddress(
"field", &refField);
444 refT->SetBranchAddress(
"derivatives", &refDerivatives);
448 Long64_t
nentries = refT->GetEntries();
456 m_tree->Branch(
"ReferenceField", &refField,
"x/D:y/D:z/D");
457 m_tree->Branch(
"fieldAbsDiff", &fieldAbsDiff,
"diff/D");
458 m_tree->Branch(
"fieldRelDiff", &fieldRelDiff,
"diff/D");
461 m_tree->Branch(
"ReferenceDerivatives", &refDerivatives,
462 "d1/D:d2/D:d3/D:d4/D:d5/D:d6/D:d7/D:d8/D:d9/D");
473 double biggestAbsDiff = 0.;
474 double biggestRelDiff = 0.;
488 double mFieldTotal = 0;
489 double refFieldTotal = 0;
490 for (
int i = 0;
i < 3;
i++) {
492 refFieldTotal += refField[
i] * refField[
i];
494 mFieldTotal = sqrt(mFieldTotal);
495 refFieldTotal = sqrt(refFieldTotal);
497 fieldAbsDiff = fabs(mFieldTotal - refFieldTotal);
498 if (refFieldTotal != 0) {
499 fieldRelDiff = fieldAbsDiff / refFieldTotal;
503 if (fabs((
m_deriv[0] - refDerivatives[0]) / refDerivatives[0])
506 (
m_deriv[1] - refDerivatives[1])
509 (
m_deriv[2] - refDerivatives[2])
512 (
m_deriv[3] - refDerivatives[3])
515 (
m_deriv[4] - refDerivatives[4])
518 (
m_deriv[5] - refDerivatives[5])
521 (
m_deriv[6] - refDerivatives[6])
524 (
m_deriv[7] - refDerivatives[7])
527 (
m_deriv[8] - refDerivatives[8])
530 "referenceDerivatives 1-9: " << refDerivatives[0]
531 <<
", " << refDerivatives[1] <<
", "
532 << refDerivatives[2] <<
", "
533 << refDerivatives[3] <<
", "
534 << refDerivatives[4] <<
", "
535 << refDerivatives[5] <<
", "
536 << refDerivatives[6] <<
", "
537 << refDerivatives[7] <<
", "
538 << refDerivatives[8]);
540 "derivatives 1-9: " <<
m_deriv[0] <<
", "
546 "relative differences: "
547 << ((
m_deriv[0] - refDerivatives[0])
548 / refDerivatives[0]) <<
", "
549 << ((
m_deriv[1] - refDerivatives[1])
550 / refDerivatives[1]) <<
", "
551 << ((
m_deriv[2] - refDerivatives[2])
552 / refDerivatives[2]) <<
", "
553 << ((
m_deriv[3] - refDerivatives[3])
554 / refDerivatives[3]) <<
", "
555 << ((
m_deriv[4] - refDerivatives[4])
556 / refDerivatives[4]) <<
", "
557 << ((
m_deriv[5] - refDerivatives[5])
558 / refDerivatives[5]) <<
", "
559 << ((
m_deriv[6] - refDerivatives[6])
560 / refDerivatives[6]) <<
", "
561 << ((
m_deriv[7] - refDerivatives[7])
562 / refDerivatives[7]) <<
", "
563 << ((
m_deriv[8] - refDerivatives[8])
564 / refDerivatives[8]));
581 "reference reading" << refField[0] <<
" " << refField[1]
582 <<
" " << refField[2]);
584 "coordinates: " <<
m_xyzt[0] <<
", " <<
m_xyzt[1] <<
", "
589 if (fieldAbsDiff > biggestAbsDiff) {
590 biggestAbsDiff = fieldAbsDiff;
592 if (fieldRelDiff > biggestRelDiff) {
593 biggestRelDiff = fieldRelDiff;
610 std::setprecision(20)
611 <<
"1) biggest absolute difference in the mag field comparison: "
613 <<
")." <<
endmsg <<
"2) biggest relative difference: "
615 <<
")" << std::setprecision(-1));
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey
. It just forwards to the base class version of declareProperty
.
Definition at line 333 of file AthCommonDataStore.h.
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This dispatches to either the generic declareProperty
or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ execute()
StatusCode MagField::MagFieldTestbedAlg::execute |
( |
| ) |
|
Athena algorithm's interface method execute()
Definition at line 179 of file MagFieldTestbedAlg.cxx.
185 return StatusCode::FAILURE;
203 return StatusCode::FAILURE;
213 std::vector < CLHEP::Hep3Vector > coordinatesToBeChecked;
218 maxRadius = solenoidRadius;
219 maxZ = solenoidZhalf;
228 CLHEP::Hep3Vector temp;
234 maxRadius = solenoidRadius;
235 maxZ = solenoidZhalf;
237 temp.setX(ran.Uniform(maxRadius * (-1), maxRadius));
238 temp.setY(ran.Uniform(maxRadius * (-1), maxRadius));
239 temp.setZ(ran.Uniform(maxZ * (-1), maxZ));
243 pow(temp.getX(), 2) +
pow(temp.getY(), 2));
248 coordinatesToBeChecked.push_back(temp);
254 CLHEP::Hep3Vector temp;
260 maxRadius = solenoidRadius;
261 maxZ = solenoidZhalf;
265 temp.setZ(ran.Uniform(maxZ * (-1), maxZ));
269 pow(temp.getX(), 2) +
pow(temp.getY(), 2));
274 coordinatesToBeChecked.push_back(temp);
282 CLHEP::Hep3Vector temp;
287 phi =
rand.Uniform(3.14 * (-1), 3.14);
289 while (
r < maxRadius) {
295 coordinatesToBeChecked.push_back(temp);
307 m_xyzt[0] = coordinatesToBeChecked.at(
i).getX();
308 m_xyzt[1] = coordinatesToBeChecked.at(
i).getY();
309 m_xyzt[2] = coordinatesToBeChecked.at(
i).getZ();
319 for (
int stepx = 0; stepx <
m_stepsX; stepx++) {
323 for (
int stepy = 0; stepy < maxRadius; stepy++) {
325 + (2 * maxRadius) / maxRadius * stepy;
328 for (
int stepz = 0; stepz < maxZ; stepz++) {
349 <<
" random readings took " <<
seconds
354 <<
" values in a grid took " <<
seconds
366 "will now run comparison against given reference file: "
369 ATH_MSG_INFO(
"comparison against reference file successful!");
371 ATH_MSG_ERROR(
"comparison against reference file FAILED!!!!");
372 return StatusCode::FAILURE;
380 return StatusCode::SUCCESS;
◆ extraDeps_update_handler()
Add StoreName to extra input/output deps as needed.
use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given
◆ extraOutputDeps()
const DataObjIDColl & AthAlgorithm::extraOutputDeps |
( |
| ) |
const |
|
overridevirtualinherited |
Return the list of extra output dependencies.
This list is extended to include symlinks implied by inheritance relations.
Definition at line 50 of file AthAlgorithm.cxx.
57 return Algorithm::extraOutputDeps();
◆ fetchEnvironment()
StatusCode MagField::MagFieldTestbedAlg::fetchEnvironment |
( |
| ) |
|
|
private |
get environment either for g4 or for magFieldSvc
Definition at line 383 of file MagFieldTestbedAlg.cxx.
386 G4TransportationManager *transm =
387 G4TransportationManager::GetTransportationManager();
388 G4FieldManager *fieldm = (transm) ? transm->GetFieldManager() :
nullptr;
389 p_g4field = (fieldm) ? fieldm->GetDetectorField() :
nullptr;
392 return StatusCode::FAILURE;
395 return StatusCode::SUCCESS;
◆ finalize()
StatusCode MagField::MagFieldTestbedAlg::finalize |
( |
| ) |
|
◆ getFieldValue()
void MagField::MagFieldTestbedAlg::getFieldValue |
( |
| ) |
|
|
private |
get Field value either by G4 or by MagFieldSvc
Definition at line 398 of file MagFieldTestbedAlg.cxx.
410 "at least one Derivative was NaN at: " <<
m_xyzt[0] <<
", "
◆ initialize()
StatusCode MagField::MagFieldTestbedAlg::initialize |
( |
| ) |
|
Athena algorithm's interface method initialize()
Definition at line 120 of file MagFieldTestbedAlg.cxx.
125 return StatusCode::FAILURE;
149 "d1/D:d2/D:d3/D:d4/D:d5/D:d6/D:d7/D:d8/D:d9/D");
154 return StatusCode::FAILURE;
159 return StatusCode::FAILURE;
167 return StatusCode::SUCCESS;
◆ inputHandles()
Return this algorithm's input handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ msg() [1/2]
◆ msg() [2/2]
◆ msgLvl()
◆ outputHandles()
Return this algorithm's output handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ renounce()
◆ renounceArray()
◆ sysInitialize()
StatusCode AthAlgorithm::sysInitialize |
( |
| ) |
|
|
overridevirtualinherited |
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
◆ m_absTolerance
double MagField::MagFieldTestbedAlg::m_absTolerance |
|
private |
◆ m_chronoSvc
ServiceHandle<IChronoStatSvc> MagField::MagFieldTestbedAlg::m_chronoSvc |
|
private |
◆ m_complete
bool MagField::MagFieldTestbedAlg::m_complete |
|
private |
◆ m_coordsAlongBeam
bool MagField::MagFieldTestbedAlg::m_coordsAlongBeam |
|
private |
◆ m_deriv
double MagField::MagFieldTestbedAlg::m_deriv[9] {} |
|
private |
stores derivatives TODO: currently only useMagFieldSvc = true
Definition at line 90 of file MagFieldTestbedAlg.h.
◆ m_detStore
◆ m_evtStore
◆ m_explicitCoords
bool MagField::MagFieldTestbedAlg::m_explicitCoords |
|
private |
◆ m_explicitX
double MagField::MagFieldTestbedAlg::m_explicitX |
|
private |
◆ m_explicitY
double MagField::MagFieldTestbedAlg::m_explicitY |
|
private |
◆ m_explicitZ
double MagField::MagFieldTestbedAlg::m_explicitZ |
|
private |
◆ m_extendedExtraObjects
DataObjIDColl AthAlgorithm::m_extendedExtraObjects |
|
privateinherited |
◆ m_field
double MagField::MagFieldTestbedAlg::m_field[3] |
|
private |
◆ m_generateBox
bool MagField::MagFieldTestbedAlg::m_generateBox |
|
private |
◆ m_halfX
double MagField::MagFieldTestbedAlg::m_halfX |
|
private |
◆ m_halfY
double MagField::MagFieldTestbedAlg::m_halfY |
|
private |
◆ m_halfZ
double MagField::MagFieldTestbedAlg::m_halfZ |
|
private |
◆ m_histStream
std::string MagField::MagFieldTestbedAlg::m_histStream |
|
private |
◆ m_magFieldSvc
◆ m_minX
double MagField::MagFieldTestbedAlg::m_minX |
|
private |
◆ m_numberOfReadings
long MagField::MagFieldTestbedAlg::m_numberOfReadings |
|
private |
◆ m_onlyCheckSolenoid
bool MagField::MagFieldTestbedAlg::m_onlyCheckSolenoid |
|
private |
◆ m_recordReadings
bool MagField::MagFieldTestbedAlg::m_recordReadings |
|
private |
record readings (for reproducability) or not (for speed tests)
Definition at line 98 of file MagFieldTestbedAlg.h.
◆ m_referenceCount
int MagField::MagFieldTestbedAlg::m_referenceCount = 0 |
|
private |
◆ m_refFile
std::string MagField::MagFieldTestbedAlg::m_refFile |
|
private |
◆ m_refTreeName
std::string MagField::MagFieldTestbedAlg::m_refTreeName |
|
private |
◆ m_relTolerance
double MagField::MagFieldTestbedAlg::m_relTolerance |
|
private |
◆ m_stepsX
int MagField::MagFieldTestbedAlg::m_stepsX |
|
private |
◆ m_stepsY
int MagField::MagFieldTestbedAlg::m_stepsY |
|
private |
◆ m_stepsZ
int MagField::MagFieldTestbedAlg::m_stepsZ |
|
private |
◆ m_thistSvc
ServiceHandle<ITHistSvc> MagField::MagFieldTestbedAlg::m_thistSvc |
|
private |
◆ m_tree
TTree* MagField::MagFieldTestbedAlg::m_tree |
|
private |
◆ m_treeName
std::string MagField::MagFieldTestbedAlg::m_treeName |
|
private |
◆ m_useDerivatives
bool MagField::MagFieldTestbedAlg::m_useDerivatives |
|
private |
◆ m_useG4Field
bool MagField::MagFieldTestbedAlg::m_useG4Field |
|
private |
◆ m_varHandleArraysDeclared
◆ m_vhka
◆ m_xyzt
double MagField::MagFieldTestbedAlg::m_xyzt[4] |
|
private |
◆ p_g4field
const G4Field* MagField::MagFieldTestbedAlg::p_g4field = nullptr |
|
private |
The documentation for this class was generated from the following files:
bool m_useDerivatives
only outer detector values will be tested
double m_halfZ
the half-length along y
double m_absTolerance
absolute tolerance in field against reference
bool checkWithReference()
check current field with reference field
bool m_onlyCheckSolenoid
only scan solenoid field
bool m_recordReadings
record readings (for reproducability) or not (for speed tests)
Scalar phi() const
phi method
int m_stepsZ
the number of steps in Z
int m_stepsY
the number of steps in Y
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
TTree * m_tree
the ROOT tree containing the output
const G4Field * p_g4field
field service from G4
Scalar theta() const
theta method
ServiceHandle< ITHistSvc > m_thistSvc
the histogram service
double m_relTolerance
relative tolerance in field against reference
long m_numberOfReadings
random readings instead of grid
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_explicitCoords
give values to check explicitly
double m_halfX
the half-lenght along x
bool m_generateBox
generate box
virtual void setOwner(IDataHandleHolder *o)=0
double m_field[3]
stores the field components
double m_explicitZ
if value to check is given explicitly
ServiceHandle< IChronoStatSvc > m_chronoSvc
the chrono service
double m_deriv[9]
stores derivatives TODO: currently only useMagFieldSvc = true
std::string m_refFile
reference field file name
virtual StatusCode sysInitialize() override
Override sysInitialize.
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
::StatusCode StatusCode
StatusCode definition for legacy code.
StatusCode fetchEnvironment()
get environment either for g4 or for magFieldSvc
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
std::string m_treeName
name of the Tree object
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
double m_minX
the minimum x for box generation
double m_halfY
the half-length along y
ServiceHandle< MagField::IMagFieldSvc > m_magFieldSvc
service to get vanilla field svc
DataObjIDColl m_extendedExtraObjects
std::string m_refTreeName
TTree object in reference file.
def time(flags, cells_name, *args, **kw)
#define ATH_MSG_WARNING(x)
void getFieldValue()
get Field value either by G4 or by MagFieldSvc
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
double m_explicitY
if value to check is given explicitly
AthAlgorithm()
Default constructor:
int m_stepsX
the number of steps in X
std::string m_histStream
THistSvc stream name.
double m_explicitX
if value to check is given explicitly
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
bool m_complete
validation completed already?
bool m_coordsAlongBeam
coordinates on a beams in random directions
double m_xyzt[4]
stores the current xyzt position