44 theStringDecay(aStringDecay)
52 throw G4HadronicException(__FILE__, __LINE__,
"G4ExcitedStringDecay::copy ctor not accessible");
63 throw G4HadronicException(__FILE__, __LINE__,
"G4ExcitedStringDecay::operator= meant to not be accessable");
91 #ifdef debug_G4ExcitedStringDecay
93 G4cout<<
"--------------------------- G4ExcitedStringDecay ----------------------"<<
G4endl;
94 G4cout<<
"Hadronization of Excited Strings: theStrings->size() "<<theStrings->size()<<
G4endl;
97 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
101 if ( theStrings->operator[](astring)->IsExcited() )
102 {KTsum+= theStrings->operator[](astring)->Get4Momentum();}
103 else {KTsum+=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();}
111 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
114 if ( theStrings->operator[](astring)->IsExcited() )
116 Ptmp=toCms * theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
117 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
119 Ptmp=toCms * theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
120 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
122 KTsum+= theStrings->operator[](astring)->Get4Momentum();
126 Ptmp=toCms * theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
127 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
128 KTsum+= theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
138 G4bool NeedEnergyCorrector=
false;
140 #ifdef debug_G4ExcitedStringDecay
141 G4cout<<
"New try No "<<attempts<<
" to hadronize strings"<<
G4endl;
150 NeedEnergyCorrector=
false;
152 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
157 #ifdef debug_G4ExcitedStringDecay
158 G4cout<<
"String No "<<astring+1<<
" Excited? "<<theStrings->operator[](astring)->IsExcited()<<
G4endl;
160 G4cout<<
"String No "<<astring+1<<
" 4Momentum "<<theStrings->operator[](astring)->Get4Momentum()
161 <<
" "<<theStrings->operator[](astring)->Get4Momentum().mag()<<
G4endl;
165 if ( theStrings->operator[](astring)->IsExcited() )
167 #ifdef debug_G4ExcitedStringDecay
168 G4cout<<
"Fragment String with partons: "
169 <<theStrings->operator[](astring)->GetLeftParton()->GetPDGcode() <<
" "
170 <<theStrings->operator[](astring)->GetRightParton()->GetPDGcode()<<
" "
171 <<
"Direction "<<theStrings->operator[](astring)->GetDirection()<<
G4endl;
173 generatedKineticTracks=
FragmentString(*theStrings->operator[](astring));
174 #ifdef debug_G4ExcitedStringDecay
175 G4cout<<
"(G4ExcitedStringDecay) Number of produced hadrons = "
176 <<generatedKineticTracks->size()<<
G4endl;
179 #ifdef debug_G4ExcitedStringDecay
182 G4LorentzVector Mom=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
184 theStrings->operator[](astring)->GetKineticTrack()->GetDefinition(),
185 theStrings->operator[](astring)->GetKineticTrack()->GetFormationTime(),
188 aTrack->
SetPosition(theStrings->operator[](astring)->GetKineticTrack()->GetPosition());
190 #ifdef debug_G4ExcitedStringDecay
195 generatedKineticTracks->push_back(aTrack);
198 if (generatedKineticTracks->size() == 0)
202 success=
false; NeedEnergyCorrector=
false;
break;
206 for (
unsigned int aTrack=0; aTrack<generatedKineticTracks->size();aTrack++)
208 #ifdef debug_G4ExcitedStringDecay
209 G4cout<<
"Prod part No. "<<aTrack+1<<
" "
210 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
211 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
212 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
215 TrackDefinition = (*generatedKineticTracks)[aTrack]->GetDefinition();
226 (*generatedKineticTracks)[aTrack]->Set4Momentum(Tmp);
228 #ifdef debug_G4ExcitedStringDecay
229 G4cout<<
"Resonance *** "<<aTrack+1<<
" "
230 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
231 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
232 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
237 theResult->push_back(generatedKineticTracks->operator[](aTrack));
238 KTsum1+= (*generatedKineticTracks)[aTrack]->Get4Momentum();
240 KTsecondaries+=KTsum1;
242 #ifdef debug_G4ExcitedStringDecay
243 G4cout <<
"String secondaries(" <<generatedKineticTracks->size()<<
")"<<G4endl
244 <<
"Init string momentum: "<< theStrings->operator[](astring)->Get4Momentum()<<G4endl
245 <<
"Final hadrons momentum: "<< KTsum1 <<
G4endl;
248 if ( KTsum1.
e() > 0 &&
249 std::abs((KTsum1.
e()-theStrings->operator[](astring)->Get4Momentum().e()) / KTsum1.
e()) >
perMillion )
251 NeedEnergyCorrector=
true;
254 #ifdef debug_G4ExcitedStringDecay
255 G4cout<<
"NeedEnergyCorrection yes/no "<<NeedEnergyCorrector<<
G4endl;
259 delete generatedKineticTracks;
264 }
while (!success && (attempts < 100));
266 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
268 Ptmp=(*theResult)[aTrack]->Get4Momentum();
269 Ptmp.transform( toLab);
270 (*theResult)[aTrack]->Set4Momentum(Ptmp);
273 #ifdef debug_G4ExcitedStringDecay
274 G4cout<<
"End of the strings fragmentation (G4ExcitedStringDecay)"<<
G4endl;
278 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
280 G4cout <<
" corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
281 <<
" " << (*theResult)[aTrack]->Get4Momentum()
282 <<
" " << (*theResult)[aTrack]->Get4Momentum().mag()<<
G4endl;
283 KTsum1+= (*theResult)[aTrack]->Get4Momentum();
286 G4cout <<
"Needcorrector/success " << NeedEnergyCorrector <<
"/" << success
287 <<
", Corrected total 4 momentum " << KTsum1 <<
G4endl;
288 if ( ! success )
G4cout <<
"failed to correct E/p" <<
G4endl;
290 G4cout<<
"End of the Hadronization (G4ExcitedStringDecay)"<<
G4endl;
295 if (theResult->size() != 0)
299 delete theResult; theResult=0;
301 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
304 if ( theStrings->operator[](astring)->IsExcited() )
306 Ptmp=theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
307 Ptmp.transform( toLab);
308 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
310 Ptmp=theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
311 Ptmp.transform( toLab);
312 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
316 Ptmp=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
317 Ptmp.transform( toLab);
318 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
329 const int nAttemptScale = 500;
330 const double ErrLimit = 1.E-5;
331 if (Output->empty())
return TRUE;
334 G4double TotalCollisionMass = TotalCollisionMom.
m();
336 std::vector<G4double> HadronMass;
G4double HadronM(0.);
338 #ifdef debug_G4ExcitedStringCorr
339 G4cout<<
G4endl<<
"EnergyAndMomentumCorrector. Number of particles: "<<Output->size()<<
G4endl;
342 unsigned int cHadron;
343 for (cHadron = 0; cHadron < Output->size(); cHadron++)
345 SumMom += Output->operator[](cHadron)->Get4Momentum();
346 HadronM=Output->operator[](cHadron)->Get4Momentum().mag(); HadronMass.push_back(HadronM);
347 SumMass += Output->operator[](cHadron)->Get4Momentum().mag();
350 #ifdef debug_G4ExcitedStringCorr
352 <<
"Sum str mom "<<TotalCollisionMom<<
" "<<TotalCollisionMom.
mag()<<
G4endl;
353 G4cout<<
"SumMass TotalCollisionMass "<<SumMass<<
" "<<TotalCollisionMass<<
G4endl;
357 if (Output->size() < 2)
return FALSE;
359 if (SumMass > TotalCollisionMass)
return FALSE;
360 SumMass = SumMom.
m2();
361 if (SumMass < 0)
return FALSE;
362 SumMass = std::sqrt(SumMass);
375 for (cAttempt = 0; cAttempt < nAttemptScale; cAttempt++)
378 for (cHadron = 0; cHadron < Output->size(); cHadron++)
380 HadronM = HadronMass.at(cHadron);
381 G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum();
386 Output->operator[](cHadron)->Set4Momentum(HadronMom);
389 Scale = TotalCollisionMass/Sum;
390 #ifdef debug_G4ExcitedStringCorr
391 G4cout <<
"Scale-1=" << Scale -1
392 <<
", TotalCollisionMass=" << TotalCollisionMass
396 if (std::fabs(Scale - 1) <= ErrLimit)
403 #ifdef debug_G4ExcitedStringCorr
406 G4cout <<
"G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<
G4endl;
407 G4cout <<
" Scale not unity at end of iteration loop: "<<TotalCollisionMass<<
" "<<Sum<<
" "<<Scale<<
G4endl;
408 G4cout <<
" Number of secondaries: " << Output->size() <<
G4endl;
409 G4cout <<
" Wanted total energy: " << TotalCollisionMom.
e() <<
G4endl;
410 G4cout <<
" Increase number of attempts or increase ERRLIMIT"<<
G4endl;