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

#include <ForwardTransportModel.h>

Inheritance diagram for ForwardTransportModel:
Collaboration diagram for ForwardTransportModel:

Public Member Functions

 ForwardTransportModel (const std::string &name, const int verboseLevel, const std::string &FwdTrSvcName)
 
G4bool IsApplicable (const G4ParticleDefinition &) override final
 
G4bool ModelTrigger (const G4FastTrack &) override final
 
void DoIt (const G4FastTrack &, G4FastStep &) override final
 

Private Member Functions

void KillPrimaryTrack (const G4FastTrack &, G4FastStep &)
 
PrimaryParticleInformationgetPrimaryParticleInformation (const G4FastTrack &fastTrack) const
 

Private Attributes

ServiceHandle< IForwardTransportSvcm_fwdSvc
 
ForwardTrack m_fwdTrack
 
ForwardTracker::Particle m_fwdParticle
 
const int m_verboseLevel {0}
 

Detailed Description

Definition at line 15 of file ForwardTransportModel.h.

Constructor & Destructor Documentation

◆ ForwardTransportModel()

ForwardTransportModel::ForwardTransportModel ( const std::string &  name,
const int  verboseLevel,
const std::string &  FwdTrSvcName 
)

Definition at line 26 of file ForwardTransportModel.cxx.

27  : G4VFastSimulationModel(name)
28  , m_fwdSvc(FwdTrSvcName, "ForwardTransportModel")
29  , m_verboseLevel(verboseLevel)
30 {
31  if (m_fwdSvc.retrieve().isFailure()) {
32  G4ExceptionDescription description;
33  description << "ForwardTransportModel::ForwardTransportModel Attempt to access ForwardTransportSvc failed.";
34  G4Exception("ForwardTransportModel", "ForwardTransportModel01", FatalException, description);
35  abort(); // to keep Coverity happy
36  }
37 
38  m_fwdTrack.initialize(m_fwdSvc->getConfigData());
39 
40  if (m_verboseLevel>5) {
41  G4cout << " transportFlag " << m_fwdSvc->getTransportFlag() << G4endl;
42  G4cout << " etaCut " << m_fwdSvc->getEtaCut() << G4endl;
43  G4cout << " xiCut " << m_fwdSvc->getXiCut() << G4endl;
44  }
45  return;
46 }

Member Function Documentation

◆ DoIt()

void ForwardTransportModel::DoIt ( const G4FastTrack &  fastTrack,
G4FastStep &  fastStep 
)
finaloverride

Special cases for Geantinos

Standard particles

Definition at line 65 of file ForwardTransportModel.cxx.

65  {
66  // Depending on particle type and kinematics one can decide to kill the track,
67  // modify it or change it into something else (e.g. a parameterised shower).
68  if (m_verboseLevel>4) {
69  G4cout <<"ForwardTransportModel::DoIt" << G4endl;
70  }
71 
72  const int pdgcode = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGEncoding();
73  const G4ThreeVector& initialMomentum = fastTrack.GetPrimaryTrack()->GetMomentum();
74  if (!m_fwdSvc->selectedParticle(initialMomentum, pdgcode)) { // FIXME Move method to this class?
75  KillPrimaryTrack(fastTrack, fastStep);
76  return;
77  }
78 
79  const double charge = fastTrack.GetPrimaryTrack()->GetDefinition()->GetPDGCharge();
80  const G4ThreeVector& initialPosition = fastTrack.GetPrimaryTrack()->GetPosition();
81  const double time = fastTrack.GetPrimaryTrack()->GetGlobalTime();
82  const double energy = fastTrack.GetPrimaryTrack()->GetTotalEnergy();
83 
84  if (m_verboseLevel>5) {
85  G4cout <<" pdgCode: " << pdgcode << " energy[GeV]: " << energy/CLHEP::GeV << " charge: " << charge << G4endl;
86  }
87  ForwardTracker::Particle fParticle = ForwardTracker::Particle(initialPosition.x()/CLHEP::m,
88  initialPosition.y()/CLHEP::m,
89  initialPosition.z()/CLHEP::m,
90  initialMomentum.x()/CLHEP::GeV,
91  initialMomentum.y()/CLHEP::GeV,
92  initialMomentum.z()/CLHEP::GeV,
93  std::abs(charge)>0);
94  if (m_verboseLevel>5) {
95  G4cout << fParticle << G4endl;
96  }
97 
98  bool isTransported = m_fwdTrack.TrackParticle(fParticle);
99  if (!isTransported) {
100  KillPrimaryTrack(fastTrack, fastStep);
101  return;
102  }
103 
104  if (m_verboseLevel>5) {
105  G4cout << m_fwdTrack.fPar() << G4endl;
106  }
107 
109  G4ThreeVector postTransportPosition(fPos.x()*CLHEP::m, fPos.y()*CLHEP::m, fPos.z()*CLHEP::m);
110 
112  G4ThreeVector postTransportMomentum(fMom.x()*CLHEP::GeV, fMom.y()*CLHEP::GeV, fMom.z()*CLHEP::GeV);
113 
116  HepMC::GenEvent* gEvent = (part) ? const_cast<HepMC::GenEvent*>(part->parent_event()) : nullptr;
117  if (!gEvent) {
118  G4ExceptionDescription description;
119  description << "ForwardTransportModel::DoIt Cannot get HepMC::GenEvent pointer";
120  G4Exception("ForwardTransportModel", "ForwardTransportModel03", FatalException, description);
121  abort(); // to keep Coverity happy
122  }
123  // Update HepMC::GenEvent
125  HepMC::FourVector(
126  postTransportPosition.x(),
127  postTransportPosition.y(),
128  postTransportPosition.z(),
129  time)); // TODO Update this value?
130  gEvent->add_vertex(gVertex);
131  gVertex->add_particle_in(part);
133  HepMC::FourVector(
134  postTransportMomentum.x(),
135  postTransportMomentum.y(),
136  postTransportMomentum.z(),
137  energy),
138  pdgcode,
139  part->status() + HepMC::SIM_STATUS_INCREMENT);
140  gVertex->add_particle_out(gParticle);
142 
143  // Create secondary on the Geant4 side
144  fastStep.SetNumberOfSecondaryTracks(1);
145 
146  const G4ParticleDefinition *aParticleDefinition{};
148  if (pdgcode == MC::GEANTINOPLUS) {
149  aParticleDefinition = G4ChargedGeantino::Definition();
150  }
151  if (pdgcode == MC::GEANTINO0) {
152  aParticleDefinition = G4Geantino::GeantinoDefinition();
153  }
154  if (!aParticleDefinition) {
156  G4ParticleTable *ptable = G4ParticleTable::GetParticleTable();
157  if (ptable) {
158  aParticleDefinition = ptable->FindParticle(pdgcode);
159  }
160  }
161  G4DynamicParticle dp2(aParticleDefinition, energy, postTransportMomentum);
162 
163  // Create UserInformation
164  const ISF::ISFParticle* initialISP = ppi->GetISFParticle();
165  std::unique_ptr<ISF::ISFParticle> postTransportISP{};
166  if (initialISP) {
167  // Create postTransportISP if required.
168  const auto pBarcode = HepMC::barcode(gParticle);
169  const auto particleID = HepMC::uniqueID(gParticle);
170  const int status = gParticle->status();
171  auto tBinding = std::make_unique<ISF::TruthBinding>(gParticle);
172  auto hmpl = std::make_unique<HepMcParticleLink>(pBarcode, gEvent->event_number(), HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE); // FIXME barcode-based
173  const Amg::Vector3D pos(postTransportPosition.x(), postTransportPosition.y(), postTransportPosition.z());
174  const Amg::Vector3D mom(postTransportMomentum.x(), postTransportMomentum.y(), postTransportMomentum.z());
175  postTransportISP = std::make_unique<ISF::ISFParticle>(pos,
176  mom,
177  initialISP->mass(),
178  initialISP->charge(),
179  initialISP->pdgCode(),
180  status,
181  time, // TODO Update??
182  *initialISP,
183  particleID,
184  pBarcode,
185  tBinding.release(),
186  hmpl.release());
187  }
188  std::unique_ptr<PrimaryParticleInformation> ppi2 = std::make_unique<PrimaryParticleInformation>(gParticle,postTransportISP.release());
189  std::unique_ptr<G4PrimaryParticle> pp2 = std::make_unique<G4PrimaryParticle>(
190  aParticleDefinition,
191  postTransportMomentum.x(),
192  postTransportMomentum.y(),
193  postTransportMomentum.z());
194  pp2->SetUserInformation(ppi2.release());
195  dp2.SetPrimaryParticle(pp2.release());
196 
197  G4Track* postTransportTrack =
198  fastStep.CreateSecondaryTrack(
199  dp2,
200  postTransportPosition,
201  time,
202  false); // position in global coordinates
203  if (!postTransportTrack) {
204  G4ExceptionDescription description;
205  description << "ForwardTransportModel::DoIt Failed to create secondary G4Track.";
206  G4Exception("ForwardTransportModel", "ForwardTransportModel04", FatalException, description);
207  abort(); // to keep Coverity happy
208  }
209  fastStep.ProposePrimaryTrackFinalPosition(postTransportPosition, false); // position in global coordinates
210  fastStep.SetPrimaryTrackFinalMomentum(postTransportMomentum, false);
211  fastStep.KillPrimaryTrack();
212 }

◆ getPrimaryParticleInformation()

PrimaryParticleInformation * ForwardTransportModel::getPrimaryParticleInformation ( const G4FastTrack &  fastTrack) const
private

Definition at line 49 of file ForwardTransportModel.cxx.

50 {
51  const G4Track *track = fastTrack.GetPrimaryTrack();
52  const G4DynamicParticle *dp = track->GetDynamicParticle();
53  if (dp) {
54  const G4PrimaryParticle *pp = dp->GetPrimaryParticle();
55  if (pp) {
56  // Extract the PrimaryParticleInformation
57  return dynamic_cast<PrimaryParticleInformation*>
58  ( pp->GetUserInformation() );
59  }
60  }
61  return nullptr;
62 }

◆ IsApplicable()

G4bool ForwardTransportModel::IsApplicable ( const G4ParticleDefinition &  )
inlinefinaloverride

Definition at line 22 of file ForwardTransportModel.h.

22 { return true; } // IDLE: we do selection in DoIt method

◆ KillPrimaryTrack()

void ForwardTransportModel::KillPrimaryTrack ( const G4FastTrack &  fastTrack,
G4FastStep &  fastStep 
)
private

Definition at line 215 of file ForwardTransportModel.cxx.

215  {
218  HepMC::GenEvent* gEvent = (part) ? const_cast<HepMC::GenEvent*>(part->parent_event()) : nullptr;
219  if (!gEvent) {
220  G4ExceptionDescription description;
221  description << "ForwardTransportModel::KillPrimaryTrack Cannot get HepMC::GenEvent pointer";
222  G4Exception("ForwardTransportModel", "ForwardTransportModel02", FatalException, description);
223  abort(); // to keep Coverity happy
224  }
225  const G4ThreeVector& initialPosition = fastTrack.GetPrimaryTrack()->GetPosition();
226  // Add dummy end vertex in Truth
228  HepMC::FourVector(
229  initialPosition.x(),
230  initialPosition.y(),
231  initialPosition.z(),
232  fastTrack.GetPrimaryTrack()->GetGlobalTime()));
233  // Flag the fact that Forward Transport has occurred using the vertex status
234 #ifdef HEPMC3
236 #else
238 #endif
239  gEvent->add_vertex(gVertex);
240  gVertex->add_particle_in(part);
241  // Kill track and deposit all energy in the current volume
242  fastStep.KillPrimaryTrack();
243  fastStep.ProposePrimaryTrackPathLength(0.0);
244  fastStep.ProposeTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->GetTotalEnergy());
245 }

◆ ModelTrigger()

G4bool ForwardTransportModel::ModelTrigger ( const G4FastTrack &  )
inlinefinaloverride

Definition at line 23 of file ForwardTransportModel.h.

23 { return true; } // IDLE: we do selection in DoIt method

Member Data Documentation

◆ m_fwdParticle

ForwardTracker::Particle ForwardTransportModel::m_fwdParticle
private

Definition at line 33 of file ForwardTransportModel.h.

◆ m_fwdSvc

ServiceHandle<IForwardTransportSvc> ForwardTransportModel::m_fwdSvc
private

Definition at line 31 of file ForwardTransportModel.h.

◆ m_fwdTrack

ForwardTrack ForwardTransportModel::m_fwdTrack
private

Definition at line 32 of file ForwardTransportModel.h.

◆ m_verboseLevel

const int ForwardTransportModel::m_verboseLevel {0}
private

Definition at line 34 of file ForwardTransportModel.h.


The documentation for this class was generated from the following files:
HepMC::GenVertexPtr
HepMC::GenVertex * GenVertexPtr
Definition: GenVertex.h:59
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
HepMC::suggest_barcode
bool suggest_barcode(T &p, int i)
Definition: GenEvent.h:670
TileDCSDataPlotter.dp
dp
Definition: TileDCSDataPlotter.py:840
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
ForwardTransportModel::getPrimaryParticleInformation
PrimaryParticleInformation * getPrimaryParticleInformation(const G4FastTrack &fastTrack) const
Definition: ForwardTransportModel.cxx:49
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ForwardTransportModel::m_fwdSvc
ServiceHandle< IForwardTransportSvc > m_fwdSvc
Definition: ForwardTransportModel.h:31
ForwardTracker::Point::y
double y() const
Definition: ForwardTracker/ForwardTracker/Point.h:23
HepMC::SIM_STATUS_INCREMENT
constexpr int SIM_STATUS_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
Definition: MagicNumbers.h:43
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
ISF::ISFParticle
Definition: ISFParticle.h:42
ISF::ISFParticle::pdgCode
int pdgCode() const
PDG value.
ForwardTrack::fPar
const ForwardTracker::Particle & fPar()
Definition: ForwardTrack.h:25
ForwardTracker::Point
Definition: ForwardTracker/ForwardTracker/Point.h:15
xAOD::Particle
Particle_v1 Particle
Define the latest version of the particle class.
Definition: Event/xAOD/xAODParticleEvent/xAODParticleEvent/Particle.h:17
HepMC::FORWARD_TRANSPORT_MODEL_PROCESS
constexpr int FORWARD_TRANSPORT_MODEL_PROCESS
Special Forward transport Geant process for vertices.
Definition: MagicNumbers.h:49
ForwardTracker::Point::z
double z() const
Definition: ForwardTracker/ForwardTracker/Point.h:24
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
HepMC::newGenVertexPtr
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition: GenVertex.h:64
ForwardTransportModel::KillPrimaryTrack
void KillPrimaryTrack(const G4FastTrack &, G4FastStep &)
Definition: ForwardTransportModel.cxx:215
PrimaryParticleInformation::GetISFParticle
const ISF::ISFParticle * GetISFParticle() const
return a pointer to the ISFParticle used to create the G4PrimaryParticle
Definition: PrimaryParticleInformation.h:66
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:116
ForwardTransportModel::m_verboseLevel
const int m_verboseLevel
Definition: ForwardTransportModel.h:34
ForwardTrack::TrackParticle
bool TrackParticle(ForwardTracker::Particle)
Definition: ForwardTrack.cxx:23
ForwardTransportModel::m_fwdTrack
ForwardTrack m_fwdTrack
Definition: ForwardTransportModel.h:32
ForwardTrack::initialize
void initialize(const ForwardTracker::ConfigData &)
Definition: ForwardTrack.cxx:14
HepMC::SIM_REGENERATION_INCREMENT
constexpr int SIM_REGENERATION_INCREMENT
Constant defining the barcode threshold for regenerated particles, i.e. particles surviving an intera...
Definition: MagicNumbers.h:40
ForwardTrack::fMom
const ForwardTracker::Point & fMom()
Definition: ForwardTrack.h:24
HepMC::SIM_STATUS_THRESHOLD
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
Definition: MagicNumbers.h:46
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
charge
double charge(const T &p)
Definition: AtlasPID.h:756
ForwardTracker::Point::x
double x() const
Definition: ForwardTracker/ForwardTracker/Point.h:22
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ISF::ISFParticle::charge
double charge() const
charge of the particle
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
ForwardTracker::Particle
Definition: ForwardDetectors/ForwardTracker/ForwardTracker/Particle.h:17
PrimaryParticleInformation::GetHepMCParticle
HepMC::ConstGenParticlePtr GetHepMCParticle() const
return a pointer to the GenParticle used to create the G4PrimaryParticle
Definition: PrimaryParticleInformation.h:47
PrimaryParticleInformation
This class is attached to G4PrimaryParticle objects as UserInformation. The member variable m_thePart...
Definition: PrimaryParticleInformation.h:39
HepMC::newGenParticlePtr
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
Definition: GenParticle.h:39
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ForwardTrack::fPos
const ForwardTracker::Point & fPos()
Definition: ForwardTrack.h:23
merge.status
status
Definition: merge.py:17
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
ISF::ISFParticle::mass
double mass() const
mass of the particle