Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4ExtDecayerPhysics.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
14
16#include "TG4ExtDecayer.h"
17#include "TG4Globals.h"
18
19#include <TVirtualMC.h>
20#include <TVirtualMCDecayer.h>
21
22#include <G4Decay.hh>
23#include <G4ParticleDefinition.hh>
24#include <G4ProcessManager.hh>
25
26//_____________________________________________________________________________
29 fMessenger(this),
30 fDecayProcess(0),
31 fSelection(),
32 fSkipNeutrino(false)
33{
35}
36
37//_____________________________________________________________________________
39 G4int theVerboseLevel, const G4String& name)
40 : TG4VPhysicsConstructor(name, theVerboseLevel),
41 fMessenger(this),
42 fDecayProcess(0),
43 fSelection(),
44 fSkipNeutrino(false)
45{
47}
48
49//_____________________________________________________________________________
56
57//
58// protected methods
59//
60
61//_____________________________________________________________________________
66
67//_____________________________________________________________________________
69{
72
73 // Check if VMC decayer is defined
74 TVirtualMCDecayer* mcDecayer = gMC->GetDecayer();
75 if (!mcDecayer) {
76 // TG4Globals::Warning(
77 // "TG4ExtDecayerPhysics", "ConstructProcess",
78 // "No VMC external decayer defined.");
79 return;
80 }
81
82 // Create Geant4 external decayer
83 TG4ExtDecayer* tg4Decayer = new TG4ExtDecayer(mcDecayer);
84 tg4Decayer->VerboseLevel(VerboseLevel());
85 tg4Decayer->SetSkipNeutrino(fSkipNeutrino);
86 // The tg4Decayer is deleted in G4Decay destructor
87 // But we may have a problem if there are more than one
88 // instances of G4Decay process
89
90 auto aParticleIterator = GetParticleIterator();
91 aParticleIterator->reset();
92 while ((*aParticleIterator)()) {
93 G4ParticleDefinition* particle = aParticleIterator->value();
94 G4ProcessManager* pmanager = particle->GetProcessManager();
95
96 // skip particles which do not have process manager
97 if (!pmanager) continue;
98
99 if (fSelection.find(particle->GetParticleName()) != std::string::npos) {
100
101 if (VerboseLevel() > 1) {
102 G4cout << "Switching off Geant4 decay table for: "
103 << particle->GetParticleName() << G4endl;
104 }
105
106 // Unset the decay table for particles in a selection;
107 // for the particles in selection, the external decayer
108 // will have a priority over Geant4 decay table
109 particle->SetDecayTable(0);
110 }
111
112 if (VerboseLevel() > 1) {
113 G4cout << "Setting ext decayer for: "
114 << aParticleIterator->value()->GetParticleName() << G4endl;
115 }
116
117 G4ProcessVector* processVector = pmanager->GetProcessList();
118 for (size_t i = 0; i < processVector->length(); i++) {
119
120 G4Decay* decay = dynamic_cast<G4Decay*>((*processVector)[i]);
121 if (decay) decay->SetExtDecayer(tg4Decayer);
122 }
123 }
124
125 if (VerboseLevel() > 0) {
126 G4cout << "### "
127 << "External decayer physics constructed." << G4endl;
128 }
129}
Definition of the TG4ExtDecayerPhysics class.
Definition of the TG4ExtDecayer class.
Definition of the TG4Globals class and basic container types.
G4bool fSkipNeutrino
option to skip importing neutrinos
TG4ExtDecayerPhysics(const G4String &name="ExtDecayer")
G4Decay * fDecayProcess
decay process
virtual void ConstructParticle()
Construct particles.
G4String fSelection
particles selection
virtual void ConstructProcess()
Construct physics processes.
Implements the G4VExtDecayer abstract class with the TVirtualMCDecayer.
void SetSkipNeutrino(G4bool skipNeutrino)
Abstract base class for physics constructors with verbose.
virtual G4int VerboseLevel() const
virtual void VerboseLevel(G4int level)
Definition TG4Verbose.h:72