EIC 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/G4Types.hh> // for G4int
42 #include <Geant4/G4VPhysicsConstructor.hh>
43 #include <Geant4/G4VProcess.hh> // for G4VProcess
44 #include <Geant4/G4Version.hh>
45 
46 #include <ostream> // for operator<<, basic_ostream
47 #include <string> // for operator<<
48 
49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
50 // hack for Geant 10.03.p03
51 // Geant 10.02.p02 has this defined
52 #ifndef aParticleIterator
53 #define aParticleIterator ((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
54 #endif
55 
57  : G4VPhysicsConstructor(name)
58  , _active_force_decay(false)
59  , _force_decay_type(kAll)
60 {
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 {
69 }
70 
71 //
72 // protected methods
73 //
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
88 
89  // Create Geant4 external decayer
90  G4Pythia6Decayer* extDecayer = new G4Pythia6Decayer();
91  extDecayer->SetVerboseLevel(0);
92 
93  aParticleIterator->reset();
94  int decayer_used = 0;
95  while ((*aParticleIterator)())
96  {
97  G4ParticleDefinition* particle = aParticleIterator->value();
98  G4ProcessManager* pmanager = particle->GetProcessManager();
99 
100  if (verboseLevel > 1)
101  {
102  std::cout << "Setting ext decayer for: "
103  << aParticleIterator->value()->GetParticleName()
104  << std::endl;
105  }
106 
107  G4ProcessVector* processVector = pmanager->GetProcessList();
108 #if G4VERSION_NUMBER >= 1060
109  for (size_t i = 0; i < processVector->length(); i++)
110 #else
111  for (G4int i = 0; i < processVector->length(); i++)
112 #endif
113  {
114  G4Decay* decay = dynamic_cast<G4Decay*>((*processVector)[i]);
115  if (decay)
116  {
117  // The extDecayer will be deleted in G4Decay destructor
118  // increment counter in case we want to print out stats
119  // for whatever reason (non null means it is used and
120  // must not be deleted)
121  decay->SetExtDecayer(extDecayer);
122  decayer_used++;
123  }
124  }
125  }
126 
128  {
129  extDecayer->ForceDecayType(_force_decay_type);
130  }
131 
132  // If the extDecayer isn't used for this particle we need to delete it here
133  // as far as I see this never happens but this makes coverity happy
134  if (!decayer_used)
135  {
136  delete extDecayer;
137  }
138  if (verboseLevel > 0)
139  {
140  std::cout << "External decayer physics constructed." << std::endl;
141  }
142 }
143 
144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......