42 theStringDecay(aStringDecay)
49 throw G4HadronicException(__FILE__, __LINE__,
"G4ExcitedStringDecay::copy ctor not accessible");
58 throw G4HadronicException(__FILE__, __LINE__,
"G4ExcitedStringDecay::operator= meant to not be accessable");
82 #ifdef debug_G4ExcitedStringDecay
84 G4cout<<
"--------------------------- G4ExcitedStringDecay ----------------------"<<
G4endl;
85 G4cout<<
"Hadronization of Excited Strings: theStrings->size() "<<theStrings->size()<<
G4endl;
88 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
92 if ( theStrings->operator[](astring)->IsExcited() )
93 {KTsum+= theStrings->operator[](astring)->Get4Momentum();}
94 else {KTsum+=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();}
102 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
105 if ( theStrings->operator[](astring)->IsExcited() )
107 Ptmp=toCms * theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
108 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
110 Ptmp=toCms * theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
111 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
113 KTsum+= theStrings->operator[](astring)->Get4Momentum();
117 Ptmp=toCms * theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
118 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
119 KTsum+= theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
129 G4bool NeedEnergyCorrector=
false;
131 #ifdef debug_G4ExcitedStringDecay
132 G4cout<<
"New try No "<<attempts<<
" to hadronize strings"<<
G4endl;
141 NeedEnergyCorrector=
false;
143 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
146 #ifdef debug_G4ExcitedStringDecay
147 G4cout<<
"String No "<<astring+1<<
" Excited? "<<theStrings->operator[](astring)->IsExcited()<<
G4endl;
149 G4cout<<
"String No "<<astring+1<<
" 4Momentum "<<theStrings->operator[](astring)->Get4Momentum()
150 <<
" "<<theStrings->operator[](astring)->Get4Momentum().mag()<<
G4endl;
154 if ( theStrings->operator[](astring)->IsExcited() )
156 #ifdef debug_G4ExcitedStringDecay
157 G4cout<<
"Fragment String with partons: "
158 <<theStrings->operator[](astring)->GetLeftParton()->GetPDGcode() <<
" "
159 <<theStrings->operator[](astring)->GetRightParton()->GetPDGcode()<<
" "
160 <<
"Direction "<<theStrings->operator[](astring)->GetDirection()<<
G4endl;
162 generatedKineticTracks=
FragmentString(*theStrings->operator[](astring));
163 #ifdef debug_G4ExcitedStringDecay
164 G4cout<<
"(G4ExcitedStringDecay) Number of produced hadrons = "
165 <<generatedKineticTracks->size()<<
G4endl;
168 #ifdef debug_G4ExcitedStringDecay
171 G4LorentzVector Mom=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
173 theStrings->operator[](astring)->GetKineticTrack()->GetDefinition(),
174 theStrings->operator[](astring)->GetKineticTrack()->GetFormationTime(),
177 aTrack->
SetPosition(theStrings->operator[](astring)->GetKineticTrack()->GetPosition());
179 #ifdef debug_G4ExcitedStringDecay
184 generatedKineticTracks->push_back(aTrack);
187 if (generatedKineticTracks->size() == 0)
191 success=
false; NeedEnergyCorrector=
false;
break;
195 for (
unsigned int aTrack=0; aTrack<generatedKineticTracks->size();aTrack++)
197 #ifdef debug_G4ExcitedStringDecay
198 G4cout<<
"Prod part No. "<<aTrack+1<<
" "
199 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
200 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
201 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
204 TrackDefinition = (*generatedKineticTracks)[aTrack]->GetDefinition();
213 (*generatedKineticTracks)[aTrack]->Set4Momentum(Tmp);
215 #ifdef debug_G4ExcitedStringDecay
216 G4cout<<
"Resonance *** "<<aTrack+1<<
" "
217 <<(*generatedKineticTracks)[aTrack]->GetDefinition()->GetParticleName()<<
" "
218 <<(*generatedKineticTracks)[aTrack]->Get4Momentum()
219 <<(*generatedKineticTracks)[aTrack]->Get4Momentum().mag()<<
G4endl;
225 theResult->push_back(generatedKineticTracks->operator[](aTrack));
226 KTsum1+= (*generatedKineticTracks)[aTrack]->Get4Momentum();
228 KTsecondaries+=KTsum1;
230 #ifdef debug_G4ExcitedStringDecay
231 G4cout <<
"String secondaries(" <<generatedKineticTracks->size()<<
")"<<G4endl
232 <<
"Init string momentum: "<< theStrings->operator[](astring)->Get4Momentum()<<G4endl
233 <<
"Final hadrons momentum: "<< KTsum1 <<
G4endl;
236 if ( KTsum1.
e() > 0 && std::abs((KTsum1.
e()-theStrings->operator[](astring)->Get4Momentum().e()) / KTsum1.
e()) >
perMillion )
238 NeedEnergyCorrector=
true;
241 #ifdef debug_G4ExcitedStringDecay
242 G4cout<<
"NeedEnergyCorrection yes/no "<<NeedEnergyCorrector<<
G4endl;
246 delete generatedKineticTracks;
251 }
while(!success && (attempts < 100));
253 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
255 Ptmp=(*theResult)[aTrack]->Get4Momentum();
256 Ptmp.transform( toLab);
257 (*theResult)[aTrack]->Set4Momentum(Ptmp);
260 #ifdef debug_G4ExcitedStringDecay
261 G4cout<<
"End of the strings fragmentation (G4ExcitedStringDecay)"<<
G4endl;
265 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
267 G4cout <<
" corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
268 <<
" " << (*theResult)[aTrack]->Get4Momentum()
269 <<
" " << (*theResult)[aTrack]->Get4Momentum().mag()<<
G4endl;
270 KTsum1+= (*theResult)[aTrack]->Get4Momentum();
273 G4cout <<
"Needcorrector/success " << NeedEnergyCorrector <<
"/" << success
274 <<
", Corrected total 4 momentum " << KTsum1 <<
G4endl;
275 if ( ! success )
G4cout <<
"failed to correct E/p" <<
G4endl;
277 G4cout<<
"End of the Hadronization (G4ExcitedStringDecay)"<<
G4endl;
282 if(theResult->size() != 0)
285 delete theResult; theResult=0;
287 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
290 if ( theStrings->operator[](astring)->IsExcited() )
292 Ptmp=theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
293 Ptmp.transform( toLab);
294 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
296 Ptmp=theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
297 Ptmp.transform( toLab);
298 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
302 Ptmp=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
303 Ptmp.transform( toLab);
304 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
314 const int nAttemptScale = 500;
315 const double ErrLimit = 1.E-5;
316 if (Output->empty())
return TRUE;
319 G4double TotalCollisionMass = TotalCollisionMom.
m();
321 std::vector<G4double> HadronMass;
G4double HadronM(0.);
323 #ifdef debug_G4ExcitedStringCorr
324 G4cout<<
G4endl<<
"EnergyAndMomentumCorrector. Number of particles: "<<Output->size()<<
G4endl;
327 unsigned int cHadron;
328 for(cHadron = 0; cHadron < Output->size(); cHadron++)
330 SumMom += Output->operator[](cHadron)->Get4Momentum();
331 HadronM=Output->operator[](cHadron)->Get4Momentum().mag(); HadronMass.push_back(HadronM);
332 SumMass += Output->operator[](cHadron)->Get4Momentum().mag();
335 #ifdef debug_G4ExcitedStringCorr
337 <<
"Sum str mom "<<TotalCollisionMom<<
" "<<TotalCollisionMom.
mag()<<
G4endl;
338 G4cout<<
"SumMass TotalCollisionMass "<<SumMass<<
" "<<TotalCollisionMass<<
G4endl;
342 if (Output->size() < 2)
return FALSE;
344 if (SumMass > TotalCollisionMass)
return FALSE;
345 SumMass = SumMom.
m2();
346 if (SumMass < 0)
return FALSE;
347 SumMass = std::sqrt(SumMass);
360 for(cAttempt = 0; cAttempt < nAttemptScale; cAttempt++)
363 for(cHadron = 0; cHadron < Output->size(); cHadron++)
365 HadronM = HadronMass.at(cHadron);
366 G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum();
371 Output->operator[](cHadron)->Set4Momentum(HadronMom);
374 Scale = TotalCollisionMass/Sum;
375 #ifdef debug_G4ExcitedStringCorr
376 G4cout <<
"Scale-1=" << Scale -1
377 <<
", TotalCollisionMass=" << TotalCollisionMass
381 if (std::fabs(Scale - 1) <= ErrLimit)
388 #ifdef debug_G4ExcitedStringCorr
391 G4cout <<
"G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<
G4endl;
392 G4cout <<
" Scale not unity at end of iteration loop: "<<TotalCollisionMass<<
" "<<Sum<<
" "<<Scale<<
G4endl;
393 G4cout <<
" Number of secondaries: " << Output->size() <<
G4endl;
394 G4cout <<
" Wanted total energy: " << TotalCollisionMom.
e() <<
G4endl;
395 G4cout <<
" Increase number of attempts or increase ERRLIMIT"<<
G4endl;
const G4ExcitedStringDecay & operator=(const G4ExcitedStringDecay &right)
virtual ~G4ExcitedStringDecay()
G4double GetPDGWidth() const
CLHEP::Hep3Vector G4ThreeVector
std::vector< G4ExcitedString * > G4ExcitedStringVector
void Boost(G4ThreeVector &Velocity)
const G4String & GetParticleName() const
const G4ParticleDefinition * GetDefinition() const
static constexpr double perMillion
void setVect(const Hep3Vector &)
G4double SampleMass(const G4double poleMass, const G4double gamma, const G4double minMass, const G4double maxMass) const
G4double GetPDGMass() const
int operator!=(const G4ExcitedStringDecay &right) const
virtual G4KineticTrackVector * FragmentStrings(const G4ExcitedStringVector *theStrings)
G4KineticTrackVector * FragmentString(const G4ExcitedString &theString)
G4bool EnergyAndMomentumCorrector(G4KineticTrackVector *Output, G4LorentzVector &TotalCollisionMom)
void SetPosition(const G4ThreeVector aPosition)
int operator==(const G4ExcitedStringDecay &right) const
G4VLongitudinalStringDecay * theStringDecay
G4GLOB_DLL std::ostream G4cout
Hep3Vector boostVector() const
G4bool IsShortLived() const
CLHEP::HepLorentzVector G4LorentzVector
virtual G4KineticTrackVector * FragmentString(const G4ExcitedString &theString)=0
simulatedPeak Scale(1/simulationNormalisationFactor)