ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
SwitchingFieldManager Class Reference

G4FieldManager that sets tight stepping for muons; disables magnetic field for other particles. More...

#include <SwitchingFieldManager.h>

Inheritance diagram for SwitchingFieldManager:
Collaboration diagram for SwitchingFieldManager:

Public Member Functions

 SwitchingFieldManager (G4Field *field)
 
 ~SwitchingFieldManager ()
 
void ConfigureForTrack (const G4Track *) override
 
G4FieldManager * Clone () const override
 

Private Attributes

G4Field * m_savedField = nullptr
 
G4double m_radiusXYmax = 1900
 
G4double m_radiusXYmin = 1500
 
G4double m_Zmax = 2000
 
G4double m_offset = 0.0
 

Detailed Description

G4FieldManager that sets tight stepping for muons; disables magnetic field for other particles.

Authors
Evangelos Kourlitis, John Apostolakis
Date
2021-06-07

Definition at line 19 of file SwitchingFieldManager.h.

Constructor & Destructor Documentation

◆ SwitchingFieldManager()

SwitchingFieldManager::SwitchingFieldManager ( G4Field *  field)

Definition at line 19 of file SwitchingFieldManager.cxx.

20  : G4FieldManager( detectorField ),
21  m_savedField( detectorField )
22 {}

◆ ~SwitchingFieldManager()

SwitchingFieldManager::~SwitchingFieldManager ( )

Definition at line 24 of file SwitchingFieldManager.cxx.

25 {}

Member Function Documentation

◆ Clone()

G4FieldManager * SwitchingFieldManager::Clone ( ) const
override

Definition at line 55 of file SwitchingFieldManager.cxx.

56 {
57  G4Field* cloneField = m_savedField->Clone();
58  auto clone= new SwitchingFieldManager( cloneField );
59 
60  G4FieldManagerHelper::SetMinAndMaxEpsilonStep( clone, this->GetMinimumEpsilonStep(), this->GetMaximumEpsilonStep() );
61  clone->SetDeltaOneStep( this->GetDeltaOneStep() );
62  clone->SetDeltaIntersection( this->GetDeltaIntersection() );
63 
64  clone->GetChordFinder()->SetDeltaChord( this->GetChordFinder()->GetDeltaChord() );
65  // This lives in our chord finder ...
66 
67  return clone;
68 }

◆ ConfigureForTrack()

void SwitchingFieldManager::ConfigureForTrack ( const G4Track *  track)
override

Definition at line 29 of file SwitchingFieldManager.cxx.

30 {
31  assert( GetDetectorField() == m_savedField
32  || GetDetectorField() == nullptr );
33  // Must ensure that SetDetectorField() has NOT been called to establish
34  // a different field by an inside entity
35  // ... it would invalidate our assumptions !
36 
37  const bool isMuonTrack = (track->GetDefinition()==G4MuonPlus::Definition() ||
38  track->GetDefinition()==G4MuonMinus::Definition() ||
39  track->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition());
40 
41  const G4ThreeVector position = track->GetPosition();
42  const G4double r2XY = position.x()*position.x() + position.y()*position.y();
43  const G4double Z = position.z();
44  const G4double r2Min = (m_radiusXYmin + m_offset)*(m_radiusXYmin + m_offset);
45  const G4double r2Max = (m_radiusXYmax - m_offset)*(m_radiusXYmax - m_offset);
46 
47  const bool inSide = (r2XY > r2Min) && (r2XY < r2Max) && (fabs(Z) < m_Zmax - m_offset);
48 
49  if ( inSide && DoesFieldExist() && !isMuonTrack )
50  ChangeDetectorField( nullptr );
51  else if ( !inSide && !DoesFieldExist() )
52  ChangeDetectorField( m_savedField );
53 }

Member Data Documentation

◆ m_offset

G4double SwitchingFieldManager::m_offset = 0.0
private

Definition at line 39 of file SwitchingFieldManager.h.

◆ m_radiusXYmax

G4double SwitchingFieldManager::m_radiusXYmax = 1900
private

Definition at line 36 of file SwitchingFieldManager.h.

◆ m_radiusXYmin

G4double SwitchingFieldManager::m_radiusXYmin = 1500
private

Definition at line 37 of file SwitchingFieldManager.h.

◆ m_savedField

G4Field* SwitchingFieldManager::m_savedField = nullptr
private

Definition at line 34 of file SwitchingFieldManager.h.

◆ m_Zmax

G4double SwitchingFieldManager::m_Zmax = 2000
private

Definition at line 38 of file SwitchingFieldManager.h.


The documentation for this class was generated from the following files:
SwitchingFieldManager::m_radiusXYmax
G4double m_radiusXYmax
Definition: SwitchingFieldManager.h:36
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
SwitchingFieldManager::m_radiusXYmin
G4double m_radiusXYmin
Definition: SwitchingFieldManager.h:37
SwitchingFieldManager::m_Zmax
G4double m_Zmax
Definition: SwitchingFieldManager.h:38
python.Utilities.clone
clone
Definition: Utilities.py:134
SwitchingFieldManager::m_savedField
G4Field * m_savedField
Definition: SwitchingFieldManager.h:34
SwitchingFieldManager::m_offset
G4double m_offset
Definition: SwitchingFieldManager.h:39
G4FieldManagerHelper::SetMinAndMaxEpsilonStep
G4bool SetMinAndMaxEpsilonStep(G4FieldManager *fieldMgr, double eps_min, double eps_max)
Set epsilon step range for a G4FieldManager instance accounting for Geant4 sanity checks.
Definition: G4FieldManagerHelper.h:23
SwitchingFieldManager::SwitchingFieldManager
SwitchingFieldManager(G4Field *field)
Definition: SwitchingFieldManager.cxx:19
xAOD::track
@ track
Definition: TrackingPrimitives.h:512