ATLAS Offline Software
Classes | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Trk::GeantFollowerHelper Class Reference

#include <GeantFollowerHelper.h>

Inheritance diagram for Trk::GeantFollowerHelper:
Collaboration diagram for Trk::GeantFollowerHelper:

Classes

struct  TreeData
 Ntuple variables : initial parameters Split this out into a separate, dynamically-allocated block. More...
 

Public Member Functions

 GeantFollowerHelper (const std::string &, const std::string &, const IInterface *)
 
virtual ~GeantFollowerHelper ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual void beginEvent () override
 
virtual void trackParticle (const G4ThreeVector &pos, const G4ThreeVector &mom, int pdg, double charge, float t, float X0) override
 
virtual void endEvent () override
 

Static Public Attributes

static constexpr int MAXPROBES {50000}
 

Private Attributes

ToolHandle< IExtrapolatorm_extrapolator
 
bool m_extrapolateDirectly
 
bool m_extrapolateIncrementally
 
const TrackParametersm_parameterCache
 
float m_tX0Cache
 
std::string m_validationTreeName
 validation tree name - to be acessed by this from root More...
 
std::string m_validationTreeDescription
 validation tree description - second argument in TTree More...
 
std::string m_validationTreeFolder
 stream/folder to for the TTree to be written out More...
 
TTree * m_validationTree
 Root Validation Tree. More...
 
std::unique_ptr< TreeDatam_treeData
 

Detailed Description

Definition at line 24 of file GeantFollowerHelper.h.

Constructor & Destructor Documentation

◆ GeantFollowerHelper()

Trk::GeantFollowerHelper::GeantFollowerHelper ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 24 of file GeantFollowerHelper.cxx.

24  :
25  base_class(t,n,p),
26  m_extrapolator(""),
29  m_parameterCache(nullptr),
30  m_tX0Cache(0.),
31  m_validationTreeName("G4Follower_"+n),
32  m_validationTreeDescription("Output of the G4Follower_"),
33  m_validationTreeFolder("/val/G4Follower_"+n),
34  m_validationTree(nullptr)
35 {
36  // properties
37  declareProperty("Extrapolator", m_extrapolator);
38  declareProperty("ExtrapolateDirectly", m_extrapolateDirectly);
39  declareProperty("ExtrapolateIncrementally", m_extrapolateIncrementally);
40 }

◆ ~GeantFollowerHelper()

Trk::GeantFollowerHelper::~GeantFollowerHelper ( )
virtualdefault

Member Function Documentation

◆ beginEvent()

void Trk::GeantFollowerHelper::beginEvent ( )
overridevirtual

Definition at line 113 of file GeantFollowerHelper.cxx.

114 {
115  m_treeData->m_t_x = 0.;
116  m_treeData->m_t_y = 0.;
117  m_treeData->m_t_z = 0.;
118  m_treeData->m_t_theta = 0.;
119  m_treeData->m_t_eta = 0.;
120  m_treeData->m_t_phi = 0.;
121  m_treeData->m_t_p = 0.;
122  m_treeData->m_t_charge = 0.;
123  m_treeData->m_t_pdg = 0;
124  m_treeData->m_g4_steps = 0;
125  m_tX0Cache = 0.;
126 }

◆ endEvent()

void Trk::GeantFollowerHelper::endEvent ( )
overridevirtual

Definition at line 215 of file GeantFollowerHelper.cxx.

216 {
217  // fill the validation tree
218  m_validationTree->Fill();
219  delete m_parameterCache;
220 }

◆ finalize()

StatusCode Trk::GeantFollowerHelper::finalize ( )
overridevirtual

Definition at line 108 of file GeantFollowerHelper.cxx.

109 {
110  return StatusCode::SUCCESS;
111 }

◆ initialize()

StatusCode Trk::GeantFollowerHelper::initialize ( )
overridevirtual

Definition at line 48 of file GeantFollowerHelper.cxx.

49 {
50  m_treeData = std::make_unique<TreeData>();
51 
52  if (m_extrapolator.retrieve().isFailure()){
53  ATH_MSG_ERROR("Could not retrieve Extrapolator " << m_extrapolator << " . Abort.");
54  return StatusCode::FAILURE;
55  }
56 
57  // create the new Tree
59 
60  m_validationTree->Branch("InitX", &m_treeData->m_t_x, "initX/F");
61  m_validationTree->Branch("InitY", &m_treeData->m_t_y, "initY/F");
62  m_validationTree->Branch("InitZ", &m_treeData->m_t_z, "initZ/F");
63  m_validationTree->Branch("InitTheta", &m_treeData->m_t_theta, "initTheta/F");
64  m_validationTree->Branch("InitEta", &m_treeData->m_t_eta, "initEta/F");
65  m_validationTree->Branch("InitPhi", &m_treeData->m_t_phi, "initPhi/F");
66  m_validationTree->Branch("InitP", &m_treeData->m_t_p, "initP/F");
67  m_validationTree->Branch("InitPdg", &m_treeData->m_t_pdg, "initPdg/I");
68  m_validationTree->Branch("InitCharge", &m_treeData->m_t_charge, "initQ/F");
69 
70  m_validationTree->Branch("G4Steps", &m_treeData->m_g4_steps, "g4steps/I");
71  m_validationTree->Branch("G4StepP", m_treeData->m_g4_p, "g4stepP[g4steps]/F");
72  m_validationTree->Branch("G4StepEta", m_treeData->m_g4_eta, "g4stepEta[g4steps]/F");
73  m_validationTree->Branch("G4StepTheta", m_treeData->m_g4_theta, "g4stepTheta[g4steps]/F");
74  m_validationTree->Branch("G4StepPhi", m_treeData->m_g4_phi, "g4stepPhi[g4steps]/F");
75  m_validationTree->Branch("G4StepX", m_treeData->m_g4_x, "g4stepX[g4steps]/F");
76  m_validationTree->Branch("G4StepY", m_treeData->m_g4_y, "g4stepY[g4steps]/F");
77  m_validationTree->Branch("G4StepZ", m_treeData->m_g4_z, "g4stepZ[g4steps]/F");
78  m_validationTree->Branch("G4AccumTX0", m_treeData->m_g4_tX0, "g4stepAccTX0[g4steps]/F");
79  m_validationTree->Branch("G4StepT", m_treeData->m_g4_t, "g4stepTX[g4steps]/F");
80  m_validationTree->Branch("G4StepX0", m_treeData->m_g4_X0, "g4stepX0[g4steps]/F");
81 
82  m_validationTree->Branch("TrkStepStatus",m_treeData->m_trk_status, "trkstepStatus[g4steps]/I");
83  m_validationTree->Branch("TrkStepP", m_treeData->m_trk_p, "trkstepP[g4steps]/F");
84  m_validationTree->Branch("TrkStepEta", m_treeData->m_trk_eta, "trkstepEta[g4steps]/F");
85  m_validationTree->Branch("TrkStepTheta", m_treeData->m_trk_theta, "trkstepTheta[g4steps]/F");
86  m_validationTree->Branch("TrkStepPhi", m_treeData->m_trk_phi, "trkstepPhi[g4steps]/F");
87  m_validationTree->Branch("TrkStepX", m_treeData->m_trk_x, "trkstepX[g4steps]/F");
88  m_validationTree->Branch("TrkStepY", m_treeData->m_trk_y, "trkstepY[g4steps]/F");
89  m_validationTree->Branch("TrkStepZ", m_treeData->m_trk_z, "trkstepZ[g4steps]/F");
90  m_validationTree->Branch("TrkStepLocX", m_treeData->m_trk_lx, "trkstepLX[g4steps]/F");
91  m_validationTree->Branch("TrkStepLocY", m_treeData->m_trk_ly, "trkstepLY[g4steps]/F");
92 
93  // now register the Tree
94  SmartIF<ITHistSvc> tHistSvc{Gaudi::svcLocator()->service("THistSvc")};
95  if ( !tHistSvc ) {
96  ATH_MSG_ERROR( "Could not find Hist Service -> Switching ValidationMode Off !" );
97  delete m_validationTree; m_validationTree = nullptr;
98  }
99  if ((tHistSvc->regTree(m_validationTreeFolder, m_validationTree)).isFailure()) {
100  ATH_MSG_ERROR( "Could not register the validation Tree -> Switching ValidationMode Off !" );
101  delete m_validationTree; m_validationTree = nullptr;
102  }
103 
104  ATH_MSG_INFO("initialize() successful" );
105  return StatusCode::SUCCESS;
106 }

◆ trackParticle()

void Trk::GeantFollowerHelper::trackParticle ( const G4ThreeVector &  pos,
const G4ThreeVector &  mom,
int  pdg,
double  charge,
float  t,
float  X0 
)
overridevirtual

Definition at line 128 of file GeantFollowerHelper.cxx.

132 {
133  // construct the initial parameters
134  Amg::Vector3D npos(pos.x(),pos.y(),pos.z());
135  Amg::Vector3D nmom(mom.x(),mom.y(),mom.z());
136  if (!m_treeData->m_g4_steps){
137  ATH_MSG_INFO("Initial step ... preparing event cache.");
138  m_treeData->m_t_x = pos.x();
139  m_treeData->m_t_y = pos.y();
140  m_treeData->m_t_z = pos.z();
141  m_treeData->m_t_theta = mom.theta();
142  m_treeData->m_t_eta = mom.eta();
143  m_treeData->m_t_phi = mom.phi();
144  m_treeData->m_t_p = mom.mag();
145  m_treeData->m_t_charge = charge;
146  m_treeData->m_t_pdg = pdg;
147  m_treeData->m_g4_steps = -1;
148  m_tX0Cache = 0.;
150  return;
151  }
152 
153  // jumping over inital step
154  m_treeData->m_g4_steps = (m_treeData->m_g4_steps == -1) ? 0 : m_treeData->m_g4_steps;
155 
156  if (!m_parameterCache){
157  ATH_MSG_WARNING("No Parameters available. Bailing out.");
158  return;
159  }
160 
161  if ( m_treeData->m_g4_steps >= MAXPROBES) {
162  ATH_MSG_WARNING("Maximum number of " << MAXPROBES << " reached, step is ignored.");
163  return;
164  }
165  // parameters of the G4 step point
166  Trk::CurvilinearParameters* g4Parameters = new Trk::CurvilinearParameters(npos, nmom, m_treeData->m_t_charge);
167  // destination surface
168  const Trk::PlaneSurface& destinationSurface = g4Parameters->associatedSurface();
169  // extrapolate to the destination surface
170  const EventContext& ctx = Gaudi::Hive::currentContext();
171  const Trk::TrackParameters* trkParameters = m_extrapolateDirectly ?
172  m_extrapolator->extrapolateDirectly(ctx,
174  destinationSurface,
175  Trk::alongMomentum,false).release() :
176  m_extrapolator->extrapolate(ctx,
178  destinationSurface,
179  Trk::alongMomentum,false).release();
180  // fill the geant information and the trk information
181  m_treeData->m_g4_p[m_treeData->m_g4_steps] = mom.mag();
182  m_treeData->m_g4_eta[m_treeData->m_g4_steps] = mom.eta();
183  m_treeData->m_g4_theta[m_treeData->m_g4_steps] = mom.theta();
184  m_treeData->m_g4_phi[m_treeData->m_g4_steps] = mom.phi();
185  m_treeData->m_g4_x[m_treeData->m_g4_steps] = pos.x();
186  m_treeData->m_g4_y[m_treeData->m_g4_steps] = pos.y();
187  m_treeData->m_g4_z[m_treeData->m_g4_steps] = pos.z();
188  float tX0 = X0 > 10e-5 ? t/X0 : 0.;
189  m_tX0Cache += tX0;
190  m_treeData->m_g4_tX0[m_treeData->m_g4_steps] = m_tX0Cache;
191  m_treeData->m_g4_t[m_treeData->m_g4_steps] = t;
192  m_treeData->m_g4_X0[m_treeData->m_g4_steps] = X0;
193 
194  m_treeData->m_trk_status[m_treeData->m_g4_steps] = trkParameters ? 1 : 0;
195  m_treeData->m_trk_p[m_treeData->m_g4_steps] = trkParameters ? trkParameters->momentum().mag() : 0.;
196  m_treeData->m_trk_eta[m_treeData->m_g4_steps] = trkParameters ? trkParameters->momentum().eta() : 0.;
197  m_treeData->m_trk_theta[m_treeData->m_g4_steps] = trkParameters ? trkParameters->momentum().theta() : 0.;
198  m_treeData->m_trk_phi[m_treeData->m_g4_steps] = trkParameters ? trkParameters->momentum().phi() : 0.;
199  m_treeData->m_trk_x[m_treeData->m_g4_steps] = trkParameters ? trkParameters->position().x() : 0.;
200  m_treeData->m_trk_y[m_treeData->m_g4_steps] = trkParameters ? trkParameters->position().y() : 0.;
201  m_treeData->m_trk_z[m_treeData->m_g4_steps] = trkParameters ? trkParameters->position().z() : 0.;
202  m_treeData->m_trk_lx[m_treeData->m_g4_steps] = trkParameters ? trkParameters->parameters()[Trk::locX] : 0.;
203  m_treeData->m_trk_ly[m_treeData->m_g4_steps] = trkParameters ? trkParameters->parameters()[Trk::locY] : 0.;
204 
205  // update the parameters if needed/configured
206  if (m_extrapolateIncrementally && trkParameters) {
207  delete m_parameterCache;
208  m_parameterCache = trkParameters;
209  }
210  // delete cache and increment
211  delete g4Parameters;
212  ++m_treeData->m_g4_steps;
213 }

Member Data Documentation

◆ m_extrapolateDirectly

bool Trk::GeantFollowerHelper::m_extrapolateDirectly
private

Definition at line 50 of file GeantFollowerHelper.h.

◆ m_extrapolateIncrementally

bool Trk::GeantFollowerHelper::m_extrapolateIncrementally
private

Definition at line 51 of file GeantFollowerHelper.h.

◆ m_extrapolator

ToolHandle<IExtrapolator> Trk::GeantFollowerHelper::m_extrapolator
private

Definition at line 49 of file GeantFollowerHelper.h.

◆ m_parameterCache

const TrackParameters* Trk::GeantFollowerHelper::m_parameterCache
private

Definition at line 53 of file GeantFollowerHelper.h.

◆ m_treeData

std::unique_ptr<TreeData> Trk::GeantFollowerHelper::m_treeData
private

Definition at line 100 of file GeantFollowerHelper.h.

◆ m_tX0Cache

float Trk::GeantFollowerHelper::m_tX0Cache
private

Definition at line 54 of file GeantFollowerHelper.h.

◆ m_validationTree

TTree* Trk::GeantFollowerHelper::m_validationTree
private

Root Validation Tree.

Definition at line 61 of file GeantFollowerHelper.h.

◆ m_validationTreeDescription

std::string Trk::GeantFollowerHelper::m_validationTreeDescription
private

validation tree description - second argument in TTree

Definition at line 58 of file GeantFollowerHelper.h.

◆ m_validationTreeFolder

std::string Trk::GeantFollowerHelper::m_validationTreeFolder
private

stream/folder to for the TTree to be written out

Definition at line 59 of file GeantFollowerHelper.h.

◆ m_validationTreeName

std::string Trk::GeantFollowerHelper::m_validationTreeName
private

validation tree name - to be acessed by this from root

Definition at line 57 of file GeantFollowerHelper.h.

◆ MAXPROBES

constexpr int Trk::GeantFollowerHelper::MAXPROBES {50000}
staticconstexpr

Definition at line 29 of file GeantFollowerHelper.h.


The documentation for this class was generated from the following files:
Trk::GeantFollowerHelper::m_validationTreeFolder
std::string m_validationTreeFolder
stream/folder to for the TTree to be written out
Definition: GeantFollowerHelper.h:59
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
Trk::GeantFollowerHelper::m_validationTreeDescription
std::string m_validationTreeDescription
validation tree description - second argument in TTree
Definition: GeantFollowerHelper.h:58
Trk::GeantFollowerHelper::m_extrapolateIncrementally
bool m_extrapolateIncrementally
Definition: GeantFollowerHelper.h:51
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
Trk::CurvilinearParameters
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:29
Trk::GeantFollowerHelper::m_parameterCache
const TrackParameters * m_parameterCache
Definition: GeantFollowerHelper.h:53
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
Trk::GeantFollowerHelper::m_validationTree
TTree * m_validationTree
Root Validation Tree.
Definition: GeantFollowerHelper.h:61
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::GeantFollowerHelper::m_extrapolateDirectly
bool m_extrapolateDirectly
Definition: GeantFollowerHelper.h:50
pdg_comparison.X0
X0
Definition: pdg_comparison.py:314
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
Trk::GeantFollowerHelper::m_treeData
std::unique_ptr< TreeData > m_treeData
Definition: GeantFollowerHelper.h:100
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::GeantFollowerHelper::m_tX0Cache
float m_tX0Cache
Definition: GeantFollowerHelper.h:54
beamspotman.n
n
Definition: beamspotman.py:731
Trk::GeantFollowerHelper::m_extrapolator
ToolHandle< IExtrapolator > m_extrapolator
Definition: GeantFollowerHelper.h:49
Trk::GeantFollowerHelper::MAXPROBES
static constexpr int MAXPROBES
Definition: GeantFollowerHelper.h:29
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::CurvilinearParametersT
Definition: CurvilinearParametersT.h:48
Trk::CurvilinearParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::PlaneSurface
Definition: PlaneSurface.h:64
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
Trk::GeantFollowerHelper::m_validationTreeName
std::string m_validationTreeName
validation tree name - to be acessed by this from root
Definition: GeantFollowerHelper.h:57