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)
174 success=
false; NeedEnergyCorrector=
false;
break;
178 for (
unsigned int aTrack=0; aTrack<generatedKineticTracks->size();aTrack++)
180 #ifdef debug_G4ExcitedStringDecay
181 G4cout<<
"Prod part No. "<<aTrack+1<<
" "
182 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
183 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
184 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
187 TrackDefinition = (*generatedKineticTracks)[aTrack]->GetDefinition();
198 (*generatedKineticTracks)[aTrack]->Set4Momentum(Tmp);
200 #ifdef debug_G4ExcitedStringDecay
201 G4cout<<
"Resonance *** "<<aTrack+1<<
" "
202 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
203 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
204 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
209 theResult->push_back(generatedKineticTracks->operator[](aTrack));
210 KTsum1+= (*generatedKineticTracks)[aTrack]->Get4Momentum();
212 KTsecondaries+=KTsum1;
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;
220 if ( KTsum1.
e() > 0 &&
221 std::abs((KTsum1.
e()-theStrings->operator[](astring)->Get4Momentum().e()) / KTsum1.
e()) > perMillion )
223 NeedEnergyCorrector=
true;
226 #ifdef debug_G4ExcitedStringDecay
227 G4cout<<
"NeedEnergyCorrection yes/no "<<NeedEnergyCorrector<<
G4endl;
231 delete generatedKineticTracks;
235 if ( NeedEnergyCorrector ) success=EnergyAndMomentumCorrector(theResult, KTsum);
236 }
while (!success && (attempts < 100));
238 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
240 Ptmp=(*theResult)[aTrack]->Get4Momentum();
242 (*theResult)[aTrack]->Set4Momentum(Ptmp);
245 #ifdef debug_G4ExcitedStringDecay
246 G4cout<<
"End of the strings fragmentation (G4ExcitedStringDecay)"<<
G4endl;
250 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
252 G4cout <<
" corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
253 <<
" " << (*theResult)[aTrack]->Get4Momentum()
254 <<
" " << (*theResult)[aTrack]->Get4Momentum().mag()<<
G4endl;
255 KTsum1+= (*theResult)[aTrack]->Get4Momentum();
258 G4cout <<
"Needcorrector/success " << NeedEnergyCorrector <<
"/" << success
259 <<
", Corrected total 4 momentum " << KTsum1 <<
G4endl;
260 if ( ! success )
G4cout <<
"failed to correct E/p" <<
G4endl;
262 G4cout<<
"End of the Hadronization (G4ExcitedStringDecay)"<<
G4endl;
267 if (theResult->size() != 0)
271 delete theResult; theResult=0;
273 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
276 if ( theStrings->operator[](astring)->IsExcited() )
278 Ptmp=theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
280 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
282 Ptmp=theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
284 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
288 Ptmp=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
290 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
298G4bool G4ExcitedStringDecay::
301 const int nAttemptScale = 500;
302 const double ErrLimit = 1.E-5;
303 if (Output->empty())
return TRUE;
306 G4double TotalCollisionMass = TotalCollisionMom.
m();
308 std::vector<G4double> HadronMass;
G4double HadronM(0.);
310 #ifdef debug_G4ExcitedStringCorr
311 G4cout<<
G4endl<<
"EnergyAndMomentumCorrector. Number of particles: "<<Output->size()<<
G4endl;
314 unsigned int cHadron;
315 for (cHadron = 0; cHadron < Output->size(); cHadron++)
317 SumMom += Output->operator[](cHadron)->Get4Momentum();
318 HadronM=Output->operator[](cHadron)->Get4Momentum().mag(); HadronMass.push_back(HadronM);
319 SumMass += Output->operator[](cHadron)->Get4Momentum().mag();
322 #ifdef debug_G4ExcitedStringCorr
324 <<
"Sum str mom "<<TotalCollisionMom<<
" "<<TotalCollisionMom.
mag()<<
G4endl;
325 G4cout<<
"SumMass TotalCollisionMass "<<SumMass<<
" "<<TotalCollisionMass<<
G4endl;
329 if (Output->size() < 2)
return FALSE;
331 if (SumMass > TotalCollisionMass)
return FALSE;
332 SumMass = SumMom.
m2();
333 if (SumMass < 0)
return FALSE;
334 SumMass = std::sqrt(SumMass);
347 for (cAttempt = 0; cAttempt < nAttemptScale; cAttempt++)
350 for (cHadron = 0; cHadron < Output->size(); cHadron++)
352 HadronM = HadronMass.at(cHadron);
353 G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum();
358 Output->operator[](cHadron)->Set4Momentum(HadronMom);
361 Scale = TotalCollisionMass/Sum;
362 #ifdef debug_G4ExcitedStringCorr
363 G4cout <<
"Scale-1=" << Scale -1
364 <<
", TotalCollisionMass=" << TotalCollisionMass
368 if (std::fabs(Scale - 1) <= ErrLimit)
375 #ifdef debug_G4ExcitedStringCorr
378 G4cout <<
"G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<
G4endl;
379 G4cout <<
" Scale not unity at end of iteration loop: "<<TotalCollisionMass<<
" "<<Sum<<
" "<<Scale<<
G4endl;
380 G4cout <<
" Number of secondaries: " << Output->size() <<
G4endl;
381 G4cout <<
" Wanted total energy: " << TotalCollisionMom.
e() <<
G4endl;
382 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