40 theStringDecay(aStringDecay)
47 throw G4HadronicException(__FILE__, __LINE__,
"G4ExcitedStringDecay::copy ctor not accessible");
56 throw G4HadronicException(__FILE__, __LINE__,
"G4ExcitedStringDecay::operator= meant to not be accessable");
80 #ifdef debug_G4ExcitedStringDecay
82 G4cout<<
"--------------------------- G4ExcitedStringDecay ----------------------"<<
G4endl;
83 G4cout<<
"Hadronization of Excited Strings: theStrings->size() "<<theStrings->size()<<
G4endl;
86 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
88 if ( theStrings->operator[](astring)->IsExcited() ) {
89 KTsum+= theStrings->operator[](astring)->Get4Momentum();
91 KTsum+=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
99 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
101 if ( theStrings->operator[](astring)->IsExcited() ) {
102 Ptmp=toCms * theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
103 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
105 Ptmp=toCms * theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
106 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
108 KTsum+= theStrings->operator[](astring)->Get4Momentum();
110 Ptmp=toCms * theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
111 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
112 KTsum+= theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
119 G4bool NeedEnergyCorrector=
false;
121 #ifdef debug_G4ExcitedStringDecay
122 G4cout<<
"New try No "<<attempts<<
" to hadronize strings"<<
G4endl;
131 NeedEnergyCorrector=
false;
133 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
135 #ifdef debug_G4ExcitedStringDecay
136 G4cout<<
"String No "<<astring+1<<
" Excited? "<<theStrings->operator[](astring)->IsExcited()<<
G4endl;
138 G4cout<<
"String No "<<astring+1<<
" 4Momentum "<<theStrings->operator[](astring)->Get4Momentum()
139 <<
" "<<theStrings->operator[](astring)->Get4Momentum().mag()<<
G4endl;
143 if ( theStrings->operator[](astring)->IsExcited() )
145 #ifdef debug_G4ExcitedStringDecay
146 G4cout<<
"Fragment String with partons: "
147 <<theStrings->operator[](astring)->GetLeftParton()->GetPDGcode() <<
" "
148 <<theStrings->operator[](astring)->GetRightParton()->GetPDGcode()<<
" "
149 <<
"Direction "<<theStrings->operator[](astring)->GetDirection()<<
G4endl;
151 generatedKineticTracks=FragmentString(*theStrings->operator[](astring));
152 #ifdef debug_G4ExcitedStringDecay
153 G4cout<<
"(G4ExcitedStringDecay) Number of produced hadrons = "<<generatedKineticTracks->size()<<
G4endl;
156 #ifdef debug_G4ExcitedStringDecay
159 G4LorentzVector Mom=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
161 theStrings->operator[](astring)->GetKineticTrack()->GetDefinition(),
162 theStrings->operator[](astring)->GetKineticTrack()->GetFormationTime(),
165 aTrack->
SetPosition(theStrings->operator[](astring)->GetKineticTrack()->GetPosition());
167 #ifdef debug_G4ExcitedStringDecay
172 generatedKineticTracks->push_back(aTrack);
176 if (generatedKineticTracks->size() == 0)
180 success=
false; NeedEnergyCorrector=
false;
break;
184 for (
unsigned int aTrack=0; aTrack<generatedKineticTracks->size();aTrack++)
186 #ifdef debug_G4ExcitedStringDecay
187 G4cout<<
"Prod part No. "<<aTrack+1<<
" "
188 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
189 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()<<
G4endl;
191 theResult->push_back(generatedKineticTracks->operator[](aTrack));
192 KTsum1+= (*generatedKineticTracks)[aTrack]->Get4Momentum();
194 KTsecondaries+=KTsum1;
196 #ifdef debug_G4ExcitedStringDecay
197 G4cout <<
"String secondaries(" <<generatedKineticTracks->size()<<
")"<<G4endl
198 <<
"Init string momentum: "<< theStrings->operator[](astring)->Get4Momentum()<<G4endl
199 <<
"Final hadrons momentum: "<< KTsum1 <<
G4endl;
202 if ( KTsum1.
e() > 0 && std::abs((KTsum1.
e()-theStrings->operator[](astring)->Get4Momentum().e()) / KTsum1.
e()) >
perMillion )
204 NeedEnergyCorrector=
true;
207 #ifdef debug_G4ExcitedStringDecay
208 G4cout<<
"NeedEnergyCorrection yes/no "<<NeedEnergyCorrector<<
G4endl;
212 delete generatedKineticTracks;
218 if ( NeedEnergyCorrector ) success=EnergyAndMomentumCorrector(theResult, KTsum);
219 }
while(!success && (attempts < 100));
221 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
223 Ptmp=(*theResult)[aTrack]->Get4Momentum();
224 Ptmp.transform( toLab);
225 (*theResult)[aTrack]->Set4Momentum(Ptmp);
228 #ifdef debug_G4ExcitedStringDecay
229 G4cout<<
"End of the strings fragmentation (G4ExcitedStringDecay)"<<
G4endl;
233 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
235 G4cout <<
" corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
236 <<
" " << (*theResult)[aTrack]->Get4Momentum()
237 <<
" " << (*theResult)[aTrack]->Get4Momentum().mag()<<
G4endl;
238 KTsum1+= (*theResult)[aTrack]->Get4Momentum();
241 G4cout <<
"Needcorrector/success " << NeedEnergyCorrector <<
"/" << success
242 <<
", Corrected total 4 momentum " << KTsum1 <<
G4endl;
243 if ( ! success )
G4cout <<
"failed to correct E/p" <<
G4endl;
245 G4cout<<
"End of the Hadronization (G4ExcitedStringDecay)"<<
G4endl;
248 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
250 if ( theStrings->operator[](astring)->IsExcited() ) {
251 Ptmp=theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
252 Ptmp.transform( toLab);
253 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
255 Ptmp=theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
256 Ptmp.transform( toLab);
257 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
259 Ptmp=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
260 Ptmp.transform( toLab);
261 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
268 G4bool G4ExcitedStringDecay::EnergyAndMomentumCorrector
271 const int nAttemptScale = 500;
272 const double ErrLimit = 1.E-5;
273 if (Output->empty())
return TRUE;
276 G4double TotalCollisionMass = TotalCollisionMom.
m();
278 #ifdef debug_G4ExcitedStringCorr
279 G4cout<<
G4endl<<
"EnergyAndMomentumCorrector. Number of particles: "<<Output->size()<<
G4endl;
282 unsigned int cHadron;
283 for(cHadron = 0; cHadron < Output->size(); cHadron++)
285 SumMom += Output->operator[](cHadron)->Get4Momentum();
286 SumMass += Output->operator[](cHadron)->GetDefinition()->GetPDGMass();
289 #ifdef debug_G4ExcitedStringCorr
291 <<
"Sum str mom "<<TotalCollisionMom<<
" "<<TotalCollisionMom.
mag()<<
G4endl;
292 G4cout<<
"SumMass TotalCollisionMass "<<SumMass<<
" "<<TotalCollisionMass<<
G4endl;
296 if (Output->size() < 2)
return FALSE;
298 if (SumMass > TotalCollisionMass)
return FALSE;
299 SumMass = SumMom.
m2();
300 if (SumMass < 0)
return FALSE;
301 SumMass = std::sqrt(SumMass);
314 for(cAttempt = 0; cAttempt < nAttemptScale; cAttempt++)
317 for(cHadron = 0; cHadron < Output->size(); cHadron++)
319 G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum();
321 G4double E = std::sqrt(HadronMom.
vect().
mag2() +
sqr(Output->operator[](cHadron)->GetDefinition()->GetPDGMass()));
323 Output->operator[](cHadron)->Set4Momentum(HadronMom);
326 Scale = TotalCollisionMass/Sum;
327 #ifdef debug_G4ExcitedStringCorr
328 G4cout <<
"Scale-1=" << Scale -1
329 <<
", TotalCollisionMass=" << TotalCollisionMass
333 if (std::fabs(Scale - 1) <= ErrLimit)
339 #ifdef debug_G4ExcitedStringCorr
342 G4cout <<
"G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<
G4endl;
343 G4cout <<
" Scale not unity at end of iteration loop: "<<TotalCollisionMass<<
" "<<Sum<<
" "<<Scale<<
G4endl;
344 G4cout <<
" Number of secondaries: " << Output->size() <<
G4endl;
345 G4cout <<
" Wanted total energy: " << TotalCollisionMom.
e() <<
G4endl;
346 G4cout <<
" Increase number of attempts or increase ERRLIMIT"<<
G4endl;
static constexpr double perMillion
Hep3Vector boostVector() const
std::vector< G4ExcitedString * > G4ExcitedStringVector
CLHEP::Hep3Vector G4ThreeVector
virtual G4KineticTrackVector * FragmentString(const G4ExcitedString &theString)=0
virtual G4KineticTrackVector * FragmentStrings(const G4ExcitedStringVector *theStrings)
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
void SetPosition(const G4ThreeVector aPosition)
void Boost(G4ThreeVector &Velocity)
void setVect(const Hep3Vector &)
const G4ParticleDefinition * GetDefinition() const
virtual ~G4ExcitedStringDecay()
CLHEP::HepLorentzVector G4LorentzVector