63 #ifdef debug_G4ExcitedStringDecay
65 G4cout<<
"--------------------------- G4ExcitedStringDecay ----------------------"<<
G4endl;
66 G4cout<<
"Hadronization of Excited Strings: theStrings->size() "<<theStrings->size()<<
G4endl;
69 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
73 if ( theStrings->operator[](astring)->IsExcited() )
74 {KTsum+= theStrings->operator[](astring)->Get4Momentum();}
75 else {KTsum+=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();}
83 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
86 if ( theStrings->operator[](astring)->IsExcited() )
88 Ptmp=toCms * theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
89 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
91 Ptmp=toCms * theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
92 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
94 KTsum+= theStrings->operator[](astring)->Get4Momentum();
98 Ptmp=toCms * theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
99 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
100 KTsum+= theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
110 G4bool NeedEnergyCorrector=
false;
112 #ifdef debug_G4ExcitedStringDecay
113 G4cout<<
"New try No "<<attempts<<
" to hadronize strings"<<
G4endl;
122 NeedEnergyCorrector=
false;
124 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
129 #ifdef debug_G4ExcitedStringDecay
130 G4cout<<
"String No "<<astring+1<<
" Excited? "<<theStrings->operator[](astring)->IsExcited()<<
G4endl;
132 G4cout<<
"String No "<<astring+1<<
" 4Momentum "<<theStrings->operator[](astring)->Get4Momentum()
133 <<
" "<<theStrings->operator[](astring)->Get4Momentum().mag()<<
G4endl;
137 if ( theStrings->operator[](astring)->IsExcited() )
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;
145 generatedKineticTracks=FragmentString(*theStrings->operator[](astring));
146 #ifdef debug_G4ExcitedStringDecay
147 G4cout<<
"(G4ExcitedStringDecay) Number of produced hadrons = "
148 <<generatedKineticTracks->size()<<
G4endl;
151 #ifdef debug_G4ExcitedStringDecay
154 G4LorentzVector Mom=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
156 theStrings->operator[](astring)->GetKineticTrack()->GetDefinition(),
157 theStrings->operator[](astring)->GetKineticTrack()->GetFormationTime(),
160 aTrack->
SetPosition(theStrings->operator[](astring)->GetKineticTrack()->GetPosition());
162 #ifdef debug_G4ExcitedStringDecay
167 generatedKineticTracks->push_back(aTrack);
170 if (generatedKineticTracks ==
nullptr || generatedKineticTracks->size() == 0)
177 for (
unsigned int aTrack=0; aTrack<generatedKineticTracks->size();aTrack++)
179 #ifdef debug_G4ExcitedStringDecay
180 G4cout<<
"Prod part No. "<<aTrack+1<<
" "
181 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
182 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
183 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
186 TrackDefinition = (*generatedKineticTracks)[aTrack]->GetDefinition();
197 (*generatedKineticTracks)[aTrack]->Set4Momentum(Tmp);
199 #ifdef debug_G4ExcitedStringDecay
200 G4cout<<
"Resonance *** "<<aTrack+1<<
" "
201 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
202 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
203 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
208 theResult->push_back(generatedKineticTracks->operator[](aTrack));
209 KTsum1+= (*generatedKineticTracks)[aTrack]->Get4Momentum();
211 KTsecondaries+=KTsum1;
213 #ifdef debug_G4ExcitedStringDecay
214 G4cout <<
"String secondaries(" <<generatedKineticTracks->size()<<
")"<<
G4endl
215 <<
"Init string momentum: "<< theStrings->operator[](astring)->Get4Momentum()<<
G4endl
216 <<
"Final hadrons momentum: "<< KTsum1 <<
G4endl;
219 if ( KTsum1.
e() > 0 &&
220 std::abs((KTsum1.
e()-theStrings->operator[](astring)->Get4Momentum().e()) / KTsum1.
e()) > perMillion )
222 NeedEnergyCorrector=
true;
225 #ifdef debug_G4ExcitedStringDecay
226 G4cout<<
"NeedEnergyCorrection yes/no "<<NeedEnergyCorrector<<
G4endl;
230 delete generatedKineticTracks;
234 if ( NeedEnergyCorrector ) success=EnergyAndMomentumCorrector(theResult, KTsum);
235 }
while (!success && (attempts < 100));
237 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
239 Ptmp=(*theResult)[aTrack]->Get4Momentum();
241 (*theResult)[aTrack]->Set4Momentum(Ptmp);
244 #ifdef debug_G4ExcitedStringDecay
245 G4cout<<
"End of the strings fragmentation (G4ExcitedStringDecay)"<<
G4endl;
249 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
251 G4cout <<
" corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
252 <<
" " << (*theResult)[aTrack]->Get4Momentum()
253 <<
" " << (*theResult)[aTrack]->Get4Momentum().mag()<<
G4endl;
254 KTsum1+= (*theResult)[aTrack]->Get4Momentum();
257 G4cout <<
"Needcorrector/success " << NeedEnergyCorrector <<
"/" << success
258 <<
", Corrected total 4 momentum " << KTsum1 <<
G4endl;
259 if ( ! success )
G4cout <<
"failed to correct E/p" <<
G4endl;
261 G4cout<<
"End of the Hadronization (G4ExcitedStringDecay)"<<
G4endl;
266 if (theResult->size() != 0)
270 delete theResult; theResult=0;
272 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
275 if ( theStrings->operator[](astring)->IsExcited() )
277 Ptmp=theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
279 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
281 Ptmp=theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
283 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
287 Ptmp=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
289 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
297G4bool G4ExcitedStringDecay::
300 const int nAttemptScale = 500;
301 const double ErrLimit = 1.E-5;
302 if (Output->empty())
return TRUE;
305 G4double TotalCollisionMass = TotalCollisionMom.
m();
307 std::vector<G4double> HadronMass;
G4double HadronM(0.);
309 #ifdef debug_G4ExcitedStringCorr
310 G4cout<<
G4endl<<
"EnergyAndMomentumCorrector. Number of particles: "<<Output->size()<<
G4endl;
313 unsigned int cHadron;
314 for (cHadron = 0; cHadron < Output->size(); cHadron++)
316 SumMom += Output->operator[](cHadron)->Get4Momentum();
317 HadronM=Output->operator[](cHadron)->Get4Momentum().mag(); HadronMass.push_back(HadronM);
318 SumMass += Output->operator[](cHadron)->Get4Momentum().mag();
321 #ifdef debug_G4ExcitedStringCorr
323 <<
"Sum str mom "<<TotalCollisionMom<<
" "<<TotalCollisionMom.
mag()<<
G4endl;
324 G4cout<<
"SumMass TotalCollisionMass "<<SumMass<<
" "<<TotalCollisionMass<<
G4endl;
328 if (Output->size() < 2)
return FALSE;
330 if (SumMass > TotalCollisionMass)
return FALSE;
331 SumMass = SumMom.
m2();
332 if (SumMass < 0)
return FALSE;
333 SumMass = std::sqrt(SumMass);
346 for (cAttempt = 0; cAttempt < nAttemptScale; cAttempt++)
349 for (cHadron = 0; cHadron < Output->size(); cHadron++)
351 HadronM = HadronMass.at(cHadron);
352 G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum();
357 Output->operator[](cHadron)->Set4Momentum(HadronMom);
360 Scale = TotalCollisionMass/Sum;
361 #ifdef debug_G4ExcitedStringCorr
362 G4cout <<
"Scale-1=" << Scale -1
363 <<
", TotalCollisionMass=" << TotalCollisionMass
367 if (std::fabs(Scale - 1) <= ErrLimit)
374 #ifdef debug_G4ExcitedStringCorr
377 G4cout <<
"G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<
G4endl;
378 G4cout <<
" Scale not unity at end of iteration loop: "<<TotalCollisionMass<<
" "<<Sum<<
" "<<Scale<<
G4endl;
379 G4cout <<
" Number of secondaries: " << Output->size() <<
G4endl;
380 G4cout <<
" Wanted total energy: " << TotalCollisionMom.
e() <<
G4endl;
381 G4cout <<
" Increase number of attempts or increase ERRLIMIT"<<
G4endl;
std::vector< G4ExcitedString * > G4ExcitedStringVector
CLHEP::HepLorentzVector G4LorentzVector
G4GLOB_DLL std::ostream G4cout
HepLorentzRotation inverse() const
Hep3Vector boostVector() const
void setVect(const Hep3Vector &)
HepLorentzVector & transform(const HepRotation &)
virtual G4KineticTrackVector * FragmentStrings(const G4ExcitedStringVector *theStrings)
G4ExcitedStringDecay(G4VLongitudinalStringDecay *aStringDecay=nullptr)
virtual ~G4ExcitedStringDecay()
G4HadronicInteraction * FindModel(const G4String &name)
static G4HadronicInteractionRegistry * Instance()
void SetModelName(const G4String &nam)
const G4String & GetModelName() const
void Boost(G4ThreeVector &Velocity)
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
virtual G4KineticTrackVector * FragmentString(const G4ExcitedString &theString)=0