LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Py8CharmDecayerPhysics.cc
Go to the documentation of this file.
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 //
33 
35 #include "Py8Decayer.hh"
36 
37 #include "Geant4/G4ParticleDefinition.hh"
38 #include "Geant4/G4ProcessManager.hh"
39 #include "Geant4/G4Decay.hh"
40 #include "Geant4/G4DecayTable.hh"
41 
42 // factory
43 //
44 #include "Geant4/G4PhysicsConstructorFactory.hh"
45 //
46 // register it with contructor factory
47 //
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53  : G4VPhysicsConstructor("Py8CharmDecayerPhysics")
54 {
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61 }
62 
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64 
66 {
67  // Nothing needs to be done here
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74 
75  // Loop over all particles instantiated and add external decayer
76  // to all decay processes where there's no decay table, plus tau's
77 
78  // Create external decayer for G4Decay process
79  // NOTE: The extDecayer will be deleted in G4Decay destructor
80  Py8Decayer* extDecayer = new Py8Decayer();
81 
82  auto particleIterator=GetParticleIterator();
83  particleIterator->reset();
84  while ((*particleIterator)())
85  {
86  G4ParticleDefinition* particle = particleIterator->value();
87  G4ProcessManager* pmanager = particle->GetProcessManager();
88 /*
89  if ( verboseLevel > 1 ) {
90  G4cout << "Setting ext decayer for: "
91  << particleIterator->value()->GetParticleName()
92  << G4endl;
93  }
94 */
95  G4ProcessVector* processVector = pmanager->GetProcessList();
96  for ( size_t i=0; i<processVector->length(); ++i )
97  {
98  G4Decay* decay = dynamic_cast<G4Decay*>((*processVector)[i]);
99  if ( decay )
100  {
101  // remove native/existing decay table for
102  // a) charm hadrons
103  // b) B hadrons
104  // and replace with external decayer
105  // for taus: if ( std::abs(particle->GetPDGEncoding()) == 15 )
106 #ifdef EXPLICIT_CHARM_LIST
107  std::set<int> abspdglist = { 411, 421, 10411, 10421, 413,
108  423, 10413, 10423, 20413, 20423,
109  415, 425, 431, 10431, 433,
110  10433, 20433, 435, 441, 10441,
111  100441, 443, 10443, 20443,100443,
112  30443, 445,
113  };
114  int abspdg = abs(particle->GetPDGEncoding());
115  if ( abspdglist.find(abspdg) != abspdglist.end() )
116 #else
117  int abspdg = abs(particle->GetPDGEncoding());
118  // PDG encoding: +/-n n_r N-L n_q1 n_q2 n_q3 n_J
119  //int n_q3 = (abspdg/10 )%10;
120  int n_q2 = (abspdg/100 )%10;
121  int n_q1 = (abspdg/1000)%10;
122  // charm mesons have n_q2=4, charm baryons n_q1=4
123  // bottom mesons have n_q2=5, bottom baryons n_q1=5
124  if ( n_q2 == 4 || n_q1 == 4 || n_q2 == 5 || n_q1 == 5 )
125 #endif
126  {
127  if ( particle->GetDecayTable() )
128  {
129  delete particle->GetDecayTable();
130  particle->SetDecayTable(nullptr);
131  }
132  decay->SetExtDecayer(extDecayer);
133  }
134  // now set external decayer to all particles
135  // that don't yet have a decay table
136  if ( !particle->GetDecayTable() )
137  {
138  decay->SetExtDecayer(extDecayer);
139  }
140  }
141  }
142  }
143 
144  return;
145 
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
constexpr auto abs(T v)
Returns the absolute value of the argument.
G4_DECLARE_PHYSCONSTR_FACTORY(Py8CharmDecayerPhysics)