60{
62
63 #ifdef debug_G4ExcitedStringDecay
65 G4cout<<
"--------------------------- G4ExcitedStringDecay ----------------------"<<
G4endl;
66 G4cout<<
"Hadronization of Excited Strings: theStrings->size() "<<theStrings->size()<<
G4endl;
67 #endif
68
69 for ( unsigned int astring=0; astring < theStrings->size(); astring++)
70
71 {
72
73 if ( theStrings->operator[](astring)->IsExcited() )
74 {KTsum+= theStrings->operator[](astring)->Get4Momentum();}
75 else {KTsum+=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();}
76 }
77
82
83 for ( unsigned int astring=0; astring < theStrings->size(); astring++)
84
85 {
86 if ( theStrings->operator[](astring)->IsExcited() )
87 {
88 Ptmp=toCms * theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
89 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
90
91 Ptmp=toCms * theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
92 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
93
94 KTsum+= theStrings->operator[](astring)->Get4Momentum();
95 }
96 else
97 {
98 Ptmp=toCms * theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
99 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
100 KTsum+= theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
101 }
102 }
103
106
110 G4bool NeedEnergyCorrector=
false;
111 do {
112 #ifdef debug_G4ExcitedStringDecay
113 G4cout<<
"New try No "<<attempts<<
" to hadronize strings"<<
G4endl;
114 #endif
115
117 theResult->clear();
118
119 attempts++;
120
122 NeedEnergyCorrector=false;
123
124 for ( unsigned int astring=0; astring < theStrings->size(); astring++)
125
126
127
128 {
129 #ifdef debug_G4ExcitedStringDecay
130 G4cout<<
"String No "<<astring+1<<
" Excited? "<<theStrings->operator[](astring)->IsExcited()<<
G4endl;
131
132 G4cout<<
"String No "<<astring+1<<
" 4Momentum "<<theStrings->operator[](astring)->Get4Momentum()
133 <<
" "<<theStrings->operator[](astring)->Get4Momentum().mag()<<
G4endl;
134 #endif
135
137 if ( theStrings->operator[](astring)->IsExcited() )
138 {
139 #ifdef debug_G4ExcitedStringDecay
140 G4cout<<
"Fragment String with partons: "
141 <<theStrings->operator[](astring)->GetLeftParton()->GetPDGcode() <<" "
142 <<theStrings->operator[](astring)->GetRightParton()->GetPDGcode()<<" "
143 <<
"Direction "<<theStrings->operator[](astring)->GetDirection()<<
G4endl;
144 #endif
145 generatedKineticTracks=FragmentString(*theStrings->operator[](astring));
146 #ifdef debug_G4ExcitedStringDecay
147 G4cout<<
"(G4ExcitedStringDecay) Number of produced hadrons = "
148 <<generatedKineticTracks->size()<<
G4endl;
149 #endif
150 } else {
151 #ifdef debug_G4ExcitedStringDecay
153 #endif
154 G4LorentzVector Mom=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
156 theStrings->operator[](astring)->GetKineticTrack()->GetDefinition(),
157 theStrings->operator[](astring)->GetKineticTrack()->GetFormationTime(),
159
160 aTrack->
SetPosition(theStrings->operator[](astring)->GetKineticTrack()->GetPosition());
161
162 #ifdef debug_G4ExcitedStringDecay
164 #endif
165
167 generatedKineticTracks->push_back(aTrack);
168 }
169
170 if (generatedKineticTracks == nullptr || generatedKineticTracks->size() == 0)
171 {
172
173
174 success=false; NeedEnergyCorrector=false; break;
175 }
176
178 for ( unsigned int aTrack=0; aTrack<generatedKineticTracks->size();aTrack++)
179 {
180 #ifdef debug_G4ExcitedStringDecay
181 G4cout<<
"Prod part No. "<<aTrack+1<<
" "
183 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
184 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
185 #endif
186
187 TrackDefinition = (*generatedKineticTracks)[aTrack]->GetDefinition();
188
190 {
197
198 (*generatedKineticTracks)[aTrack]->Set4Momentum(Tmp);
199
200 #ifdef debug_G4ExcitedStringDecay
201 G4cout<<
"Resonance *** "<<aTrack+1<<
" "
203 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
204 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
205 #endif
206 }
207
208
209 theResult->push_back(generatedKineticTracks->operator[](aTrack));
210 KTsum1+= (*generatedKineticTracks)[aTrack]->Get4Momentum();
211 }
212 KTsecondaries+=KTsum1;
213
214 #ifdef debug_G4ExcitedStringDecay
215 G4cout <<
"String secondaries(" <<generatedKineticTracks->size()<<
")"<<
G4endl
216 <<
"Init string momentum: "<< theStrings->operator[](astring)->Get4Momentum()<<
G4endl
217 <<
"Final hadrons momentum: "<< KTsum1 <<
G4endl;
218 #endif
219
220 if ( KTsum1.e() > 0 &&
221 std::abs((KTsum1.e()-theStrings->operator[](astring)->Get4Momentum().e()) / KTsum1.e()) > perMillion )
222 {
223 NeedEnergyCorrector=true;
224 }
225
226 #ifdef debug_G4ExcitedStringDecay
227 G4cout<<
"NeedEnergyCorrection yes/no "<<NeedEnergyCorrector<<
G4endl;
228 #endif
229
230
231 delete generatedKineticTracks;
232 success=true;
233 }
234
235 if ( NeedEnergyCorrector ) success=EnergyAndMomentumCorrector(theResult, KTsum);
236 } while (!success && (attempts < 100));
237
238 for ( unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
239 {
240 Ptmp=(*theResult)[aTrack]->Get4Momentum();
242 (*theResult)[aTrack]->Set4Momentum(Ptmp);
243 }
244
245 #ifdef debug_G4ExcitedStringDecay
246 G4cout<<
"End of the strings fragmentation (G4ExcitedStringDecay)"<<
G4endl;
247
249
250 for ( unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
251 {
252 G4cout <<
" corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
253 <<" " << (*theResult)[aTrack]->Get4Momentum()
254 <<
" " << (*theResult)[aTrack]->Get4Momentum().mag()<<
G4endl;
255 KTsum1+= (*theResult)[aTrack]->Get4Momentum();
256 }
257
258 G4cout <<
"Needcorrector/success " << NeedEnergyCorrector <<
"/" << success
259 <<
", Corrected total 4 momentum " << KTsum1 <<
G4endl;
260 if ( ! success )
G4cout <<
"failed to correct E/p" <<
G4endl;
261
262 G4cout<<
"End of the Hadronization (G4ExcitedStringDecay)"<<
G4endl;
263 #endif
264
265 if (!success)
266 {
267 if (theResult->size() != 0)
268 {
270 theResult->clear();
271 delete theResult; theResult=0;
272 }
273 for ( unsigned int astring=0; astring < theStrings->size(); astring++)
274
275 {
276 if ( theStrings->operator[](astring)->IsExcited() )
277 {
278 Ptmp=theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
280 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
281
282 Ptmp=theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
284 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
285 }
286 else
287 {
288 Ptmp=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
290 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
291 }
292 }
293 }
294 return theResult;
295}
CLHEP::HepLorentzVector G4LorentzVector
G4GLOB_DLL std::ostream G4cout
HepLorentzVector & transform(const HepRotation &)
void SetPosition(const G4ThreeVector aPosition)
const G4ParticleDefinition * GetDefinition() const
G4bool IsShortLived() const
G4double GetPDGMass() const
G4double GetPDGWidth() const
const G4String & GetParticleName() const
G4double SampleMass(const G4double poleMass, const G4double gamma, const G4double minMass, const G4double maxMass) const
G4double GetMinimumMass(const G4ParticleDefinition *p) const