Geant4_10
G4MultiBodyMomentumDist.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 // $Id: G4MultiBodyMomentumDist.cc 71652 2013-06-19 17:20:45Z mkelsey $
27 // Author: Michael Kelsey (SLAC)
28 // Date: 7 March 2013
29 //
30 // Description: Singleton class to evaluate multi-body momentum distribution
31 // functions based on intial state codes and multiplicity.
32 //
33 // 20130308 Use envvar to enable/disable use of 3-body generators.
34 // 20130619 Change singleton instance to be thread-local, to avoid collisions.
35 
37 #include "G4CascadeParameters.hh"
38 #include "G4NuclNucl3BodyMomDst.hh"
39 #include "G4NuclNucl4BodyMomDst.hh"
40 #include "G4HadNucl3BodyMomDst.hh"
41 #include "G4HadNucl4BodyMomDst.hh"
42 #include "G4InuclParticleNames.hh"
43 using namespace G4InuclParticleNames;
44 
45 
46 // Singleton is created at first invocation
47 
48 G4ThreadLocal G4MultiBodyMomentumDist* G4MultiBodyMomentumDist::theInstance = 0;
49 
51  if (!theInstance) theInstance = new G4MultiBodyMomentumDist;
52  return theInstance;
53 }
54 
55 // Constructor and destructor
56 
57 G4MultiBodyMomentumDist::G4MultiBodyMomentumDist()
58  : nn3BodyDst(new G4NuclNucl3BodyMomDst),
59  nn4BodyDst(new G4NuclNucl4BodyMomDst),
60  hn3BodyDst(new G4HadNucl3BodyMomDst),
61  hn4BodyDst(new G4HadNucl4BodyMomDst) {;}
62 
64  delete nn3BodyDst;
65  delete nn4BodyDst;
66  delete hn3BodyDst;
67  delete hn4BodyDst;
68 }
69 
70 
71 // Set verbosity for all generators (const-cast required)
72 
74  const_cast<G4MultiBodyMomentumDist*>(GetInstance())->passVerbose(verbose);
75 }
76 
77 void G4MultiBodyMomentumDist::passVerbose(G4int verbose) {
78  if (nn3BodyDst) nn3BodyDst->setVerboseLevel(verbose);
79  if (nn4BodyDst) nn4BodyDst->setVerboseLevel(verbose);
80  if (hn3BodyDst) hn3BodyDst->setVerboseLevel(verbose);
81  if (hn4BodyDst) hn4BodyDst->setVerboseLevel(verbose);
82 }
83 
84 
85 // Return appropriate distribution generator for specified interaction
86 
87 const G4VMultiBodyMomDst*
88 G4MultiBodyMomentumDist::ChooseDist(G4int is, G4int mult) const {
89  if (is == pro*pro || is == pro*neu || is == neu*neu) {
90  //***** REMOVED BY VLADIMIR UZHINSKY 18 JULY 2011
91  if (G4CascadeParameters::use3BodyMom() && mult==3) return nn3BodyDst;
92  return nn4BodyDst;
93  }
94 
95  else { // FIXME: All other initial states use pi-N scattering
96  //***** REMOVED BY VLADIMIR UZHINSKY 18 JULY 2011
97  if (G4CascadeParameters::use3BodyMom() && mult==3) return hn3BodyDst;
98  return hn4BodyDst;
99  }
100 
101  // Invalid interaction
102  return 0;
103 }
static void setVerboseLevel(G4int vb=0)
#define G4ThreadLocal
Definition: tls.hh:52
virtual void setVerboseLevel(G4int verbose=0)
int G4int
Definition: G4Types.hh:78
static const G4MultiBodyMomentumDist * GetInstance()
static G4bool use3BodyMom()