ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4PreCompoundDeexcitation.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4PreCompoundDeexcitation.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 //
27 // Takes an arbitrary excited or unphysical nuclear state and produces
28 // a final state with evaporated particles and (possibly) a stable nucleus.
29 //
30 // 20100922 M. Kelsey -- Remove convertFragment() function, pass buffer
31 // instead of copying, clean up code somewhat
32 // 20100925 M. Kelsey -- Use new G4InuclNuclei->G4Fragment conversion, and
33 // G4ReactionProducts -> G4CollisionOutput convertor. Move Z==0
34 // explosion condition to base-class function.
35 // 20100926 M. Kelsey -- Move to new G4VCascadeDeexcitation base class,
36 // replace getDeexcitationFragments() with deExcite().
37 // 20110214 M. Kelsey -- Follow G4InuclParticle::Model enumerator migration
38 // 20110803 M. Kelsey -- Add post-deexcitation diagnostic messages
39 // 20120120 V. Ivanchenko -- Pre-compound model and its handler should not be deleted here
40 // 20130621 Replace collide() interface with deExcite() using G4Fragment ref
41 // 20130622 Inherit from G4CascadeDeexciteBase, add verbosity interface
42 // to pass to PreCompound
43 // 20140508 Per V. Ivanchenko, attempt to use common instance of PreCompound.
44 
46 #include "G4HadronicInteraction.hh"
49 #include "G4InuclNuclei.hh"
50 #include "G4InuclParticle.hh"
51 #include "G4InuclParticleNames.hh"
52 #include "G4PreCompoundModel.hh"
54 
55 using namespace G4InuclParticleNames;
56 
57 
58 // Constructor and destructor
59 
61  : G4CascadeDeexciteBase("G4PreCompoundDeexcitation"),
62  theExcitationHandler(0), theDeExcitation(0) {
63  // Access common instance of PreCompound instead of creating new one
66 
67  // If not found, or cast fails, create a local instance
68  theDeExcitation = static_cast<G4PreCompoundModel*>(p);
69  if (!theDeExcitation) {
72  }
73 }
74 
76  // Per V.I. -- do not delete locally; handled in hadronic registry
77  //delete theExcitationHandler;
78  //delete theDeExcitation;
79 }
80 
84  // NOTE: G4ExcitationHandler doesn't have verbosity
85 }
86 
87 
88 // Main processing
89 
91  G4CollisionOutput& globalOutput) {
92  if (verboseLevel)
93  G4cout << " >>> G4PreCompoundDeexcitation::deExcite" << G4endl;
94 
95  if (verboseLevel > 1)
96  G4cout << fragment << G4endl;
97 
98  G4ReactionProductVector* precompoundProducts = 0;
99 
100  if (explosion(fragment) && theExcitationHandler) {
101  // FIXME: in principle, the explosion(...) stuff should also
102  // handle properly the case of Z=0 (neutron blob)
103  if (verboseLevel) G4cout << " calling BreakItUp" << G4endl;
104  precompoundProducts = theExcitationHandler->BreakItUp(fragment);
105 
106  } else {
107  if (verboseLevel) G4cout << " calling DeExcite" << G4endl;
108  // NOTE: DeExcite() interface takes a *non-const* reference
109  // Make a non-const copy of original G4Fragment; otherwise it may be
110  // changed by DeExcite()
111  G4Fragment originalFragment(fragment);
112  precompoundProducts =
113  theDeExcitation->DeExcite(originalFragment);
114  }
115 
116  // Transfer output of de-excitation back into Bertini objects
117  if (precompoundProducts) {
118  if (verboseLevel>1) {
119  G4cout << " Got " << precompoundProducts->size()
120  << " secondaries back from PreCompound:" << G4endl;
121  }
122 
123  globalOutput.setVerboseLevel(verboseLevel); // For debugging
124  globalOutput.addOutgoingParticles(precompoundProducts);
125  globalOutput.setVerboseLevel(0);
126 
127  for ( size_t i = 0; i < precompoundProducts->size(); i++ ) {
128  if ( (*precompoundProducts)[ i ] ) {
129  delete (*precompoundProducts)[ i ];
130  (*precompoundProducts)[ i ] = 0;
131  }
132  }
133  precompoundProducts->clear();
134  delete precompoundProducts;
135  }
136 }