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 | // Historic fragment from M.Komogorov; clean-up still necessary @@@ |
---|
27 | #include "G4ExcitedStringDecay.hh" |
---|
28 | #include "G4KineticTrack.hh" |
---|
29 | |
---|
30 | G4ExcitedStringDecay::G4ExcitedStringDecay() |
---|
31 | { |
---|
32 | theStringDecay=NULL; |
---|
33 | } |
---|
34 | |
---|
35 | G4ExcitedStringDecay::G4ExcitedStringDecay(G4VLongitudinalStringDecay * aStringDecay) |
---|
36 | : theStringDecay(aStringDecay) |
---|
37 | {} |
---|
38 | |
---|
39 | G4ExcitedStringDecay::G4ExcitedStringDecay(const G4ExcitedStringDecay &) : G4VStringFragmentation() |
---|
40 | { |
---|
41 | } |
---|
42 | |
---|
43 | G4ExcitedStringDecay::~G4ExcitedStringDecay() |
---|
44 | { |
---|
45 | } |
---|
46 | |
---|
47 | const G4ExcitedStringDecay & G4ExcitedStringDecay::operator=(const G4ExcitedStringDecay &) |
---|
48 | { |
---|
49 | throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay::operator= meant to not be accessable"); |
---|
50 | return *this; |
---|
51 | } |
---|
52 | |
---|
53 | int G4ExcitedStringDecay::operator==(const G4ExcitedStringDecay &) const |
---|
54 | { |
---|
55 | return 0; |
---|
56 | } |
---|
57 | |
---|
58 | int G4ExcitedStringDecay::operator!=(const G4ExcitedStringDecay &) const |
---|
59 | { |
---|
60 | return 1; |
---|
61 | } |
---|
62 | |
---|
63 | G4bool G4ExcitedStringDecay:: |
---|
64 | EnergyAndMomentumCorrector(G4KineticTrackVector* Output, G4LorentzVector& TotalCollisionMom) |
---|
65 | { |
---|
66 | const int nAttemptScale = 500; |
---|
67 | const double ErrLimit = 1.E-5; |
---|
68 | if (Output->empty()) |
---|
69 | return TRUE; |
---|
70 | G4LorentzVector SumMom; |
---|
71 | G4double SumMass = 0; |
---|
72 | G4double TotalCollisionMass = TotalCollisionMom.m(); |
---|
73 | if( !(TotalCollisionMass<1) && !(TotalCollisionMass>-1) ) |
---|
74 | { |
---|
75 | std::cout << "TotalCollisionMomentum = "<<TotalCollisionMom<<G4endl; |
---|
76 | throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay received nan mass..."); |
---|
77 | } |
---|
78 | // Calculate sum hadron 4-momenta and summing hadron mass |
---|
79 | unsigned int cHadron; |
---|
80 | for(cHadron = 0; cHadron < Output->size(); cHadron++) |
---|
81 | { |
---|
82 | SumMom += Output->operator[](cHadron)->Get4Momentum(); |
---|
83 | if( !(SumMom<1) && !(SumMom>-1) ) |
---|
84 | { |
---|
85 | throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay::EnergyAndMomentumCorrector() received nan momentum..."); |
---|
86 | } |
---|
87 | SumMass += Output->operator[](cHadron)->GetDefinition()->GetPDGMass(); |
---|
88 | if( !(SumMass<1) && !(SumMass>-1) ) |
---|
89 | { |
---|
90 | throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay::EnergyAndMomentumCorrector() received nan mass..."); |
---|
91 | } |
---|
92 | } |
---|
93 | // Cannot correct a single particle |
---|
94 | if (Output->size() < 2) return FALSE; |
---|
95 | |
---|
96 | if (SumMass > TotalCollisionMass) return FALSE; |
---|
97 | SumMass = SumMom.m2(); |
---|
98 | if (SumMass < 0) return FALSE; |
---|
99 | SumMass = std::sqrt(SumMass); |
---|
100 | |
---|
101 | // Compute c.m.s. hadron velocity and boost KTV to hadron c.m.s. |
---|
102 | G4ThreeVector Beta = -SumMom.boostVector(); |
---|
103 | Output->Boost(Beta); |
---|
104 | |
---|
105 | // Scale total c.m.s. hadron energy (hadron system mass). |
---|
106 | // It should be equal interaction mass |
---|
107 | G4double Scale = 1; |
---|
108 | G4int cAttempt = 0; |
---|
109 | G4double Sum = 0; |
---|
110 | G4bool success = false; |
---|
111 | for(cAttempt = 0; cAttempt < nAttemptScale; cAttempt++) |
---|
112 | { |
---|
113 | Sum = 0; |
---|
114 | for(cHadron = 0; cHadron < Output->size(); cHadron++) |
---|
115 | { |
---|
116 | G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum(); |
---|
117 | HadronMom.setVect(Scale*HadronMom.vect()); |
---|
118 | G4double E = std::sqrt(HadronMom.vect().mag2() + sqr(Output->operator[](cHadron)->GetDefinition()->GetPDGMass())); |
---|
119 | HadronMom.setE(E); |
---|
120 | Output->operator[](cHadron)->Set4Momentum(HadronMom); |
---|
121 | Sum += E; |
---|
122 | } |
---|
123 | Scale = TotalCollisionMass/Sum; |
---|
124 | #ifdef debug_G4ExcitedStringDecay |
---|
125 | G4cout << "Scale-1=" << Scale -1 |
---|
126 | << ", TotalCollisionMass=" << TotalCollisionMass |
---|
127 | << ", Sum=" << Sum |
---|
128 | << G4endl; |
---|
129 | #endif |
---|
130 | if (std::fabs(Scale - 1) <= ErrLimit) |
---|
131 | { |
---|
132 | success = true; |
---|
133 | break; |
---|
134 | } |
---|
135 | } |
---|
136 | |
---|
137 | if(!success) |
---|
138 | { |
---|
139 | G4cout << "G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<G4endl; |
---|
140 | G4cout << " Scale not unity at end of iteration loop: "<<TotalCollisionMass<<" "<<Sum<<" "<<Scale<<G4endl; |
---|
141 | G4cout << " Number of secondaries: " << Output->size() << G4endl; |
---|
142 | G4cout << " Wanted total energy: " << TotalCollisionMom.e() << G4endl; |
---|
143 | G4cout << " Increase number of attempts or increase ERRLIMIT"<<G4endl; |
---|
144 | // throw G4HadronicException(__FILE__, __LINE__, "G4ExcitedStringDecay failed to correct..."); |
---|
145 | } |
---|
146 | |
---|
147 | // Compute c.m.s. interaction velocity and KTV back boost |
---|
148 | Beta = TotalCollisionMom.boostVector(); |
---|
149 | Output->Boost(Beta); |
---|
150 | return success; |
---|
151 | } |
---|