Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
P6DExtDecayerPhysics.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file P6DExtDecayerPhysics.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: P6DExtDecayerPhysics.cc,v 1.3 2015/01/05 23:49:39 mccumber Exp $
27 //
32 
33 #include "P6DExtDecayerPhysics.hh"
34 #include "G4Pythia6Decayer.hh"
35 
36 #include <Geant4/G4Decay.hh>
37 #include <Geant4/G4ParticleDefinition.hh>
38 #include <Geant4/G4ParticleTable.hh> // for G4ParticleTable::G4PTblDi...
39 #include <Geant4/G4ProcessManager.hh>
40 #include <Geant4/G4ProcessVector.hh> // for G4ProcessVector
41 #include <Geant4/G4String.hh> // for G4String
42 #include <Geant4/G4VPhysicsConstructor.hh>
43 #include <Geant4/G4VProcess.hh> // for G4VProcess
44 #include <Geant4/G4Version.hh>
45 
46 #include <cstddef> // for size_t
47 #include <iostream> // for operator<<, endl, basic_o...
48 #include <string> // for operator<<
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 // hack for Geant 10.03.p03
52 // Geant 10.02.p02 has this defined
53 #ifndef aParticleIterator
54 #define aParticleIterator ((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
55 #endif
56 
58  : G4VPhysicsConstructor(name)
59  , _active_force_decay(false)
60  , _force_decay_type(kAll)
61 {
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 {
70 }
71 
72 //
73 // protected methods
74 //
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
79 {
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
89 
90  // Create Geant4 external decayer
91  G4Pythia6Decayer* extDecayer = new G4Pythia6Decayer();
92  extDecayer->SetVerboseLevel(0);
93 
94  aParticleIterator->reset();
95  int decayer_used = 0;
96  while ((*aParticleIterator)())
97  {
98  G4ParticleDefinition* particle = aParticleIterator->value();
99  G4ProcessManager* pmanager = particle->GetProcessManager();
100 
101  if (verboseLevel > 1)
102  {
103  std::cout << "Setting ext decayer for: "
104  << aParticleIterator->value()->GetParticleName()
105  << std::endl;
106  }
107 
108  G4ProcessVector* processVector = pmanager->GetProcessList();
109 #if G4VERSION_NUMBER >= 1060
110  for (size_t i = 0; i < processVector->length(); i++)
111 #else
112  for (G4int i = 0; i < processVector->length(); i++)
113 #endif
114  {
115  G4Decay* decay = dynamic_cast<G4Decay*>((*processVector)[i]);
116  if (decay)
117  {
118  // The extDecayer will be deleted in G4Decay destructor
119  // increment counter in case we want to print out stats
120  // for whatever reason (non null means it is used and
121  // must not be deleted)
122  decay->SetExtDecayer(extDecayer);
123  decayer_used++;
124  }
125  }
126  }
127 
129  {
130  extDecayer->ForceDecayType(_force_decay_type);
131  }
132 
133  // If the extDecayer isn't used for this particle we need to delete it here
134  // as far as I see this never happens but this makes coverity happy
135  if (!decayer_used)
136  {
137  delete extDecayer;
138  }
139  if (verboseLevel > 0)
140  {
141  std::cout << "External decayer physics constructed." << std::endl;
142  }
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......