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();}
90 else {KTsum+=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();}
97 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
99 if ( theStrings->operator[](astring)->IsExcited() )
101 Ptmp=toCms * theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
102 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
104 Ptmp=toCms * theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
105 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
107 KTsum+= theStrings->operator[](astring)->Get4Momentum();
111 Ptmp=toCms * theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
112 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
113 KTsum+= theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
120 G4bool NeedEnergyCorrector=
false;
122 #ifdef debug_G4ExcitedStringDecay
123 G4cout<<
"New try No "<<attempts<<
" to hadronize strings"<<
G4endl;
132 NeedEnergyCorrector=
false;
134 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
137 #ifdef debug_G4ExcitedStringDecay
138 G4cout<<
"String No "<<astring+1<<
" Excited? "<<theStrings->operator[](astring)->IsExcited()<<
G4endl;
140 G4cout<<
"String No "<<astring+1<<
" 4Momentum "<<theStrings->operator[](astring)->Get4Momentum()
141 <<
" "<<theStrings->operator[](astring)->Get4Momentum().mag()<<
G4endl;
145 if ( theStrings->operator[](astring)->IsExcited() )
147 #ifdef debug_G4ExcitedStringDecay
148 G4cout<<
"Fragment String with partons: "
149 <<theStrings->operator[](astring)->GetLeftParton()->GetPDGcode() <<
" "
150 <<theStrings->operator[](astring)->GetRightParton()->GetPDGcode()<<
" "
151 <<
"Direction "<<theStrings->operator[](astring)->GetDirection()<<
G4endl;
153 generatedKineticTracks=
FragmentString(*theStrings->operator[](astring));
154 #ifdef debug_G4ExcitedStringDecay
155 G4cout<<
"(G4ExcitedStringDecay) Number of produced hadrons = "<<generatedKineticTracks->size()<<
G4endl;
158 #ifdef debug_G4ExcitedStringDecay
161 G4LorentzVector Mom=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
163 theStrings->operator[](astring)->GetKineticTrack()->GetDefinition(),
164 theStrings->operator[](astring)->GetKineticTrack()->GetFormationTime(),
167 aTrack->
SetPosition(theStrings->operator[](astring)->GetKineticTrack()->GetPosition());
169 #ifdef debug_G4ExcitedStringDecay
174 generatedKineticTracks->push_back(aTrack);
177 if (generatedKineticTracks == NULL)
179 G4cerr <<
"G4VPartonStringModel:No KineticTracks produced" <<
G4endl;
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 }
while(!success && (attempts < 10));
220 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
222 Ptmp=(*theResult)[aTrack]->Get4Momentum();
223 Ptmp.transform( toLab);
224 (*theResult)[aTrack]->Set4Momentum(Ptmp);
227 #ifdef debug_G4ExcitedStringDecay
228 G4cout<<
"End of the strings fragmentation (G4ExcitedStringDecay)"<<
G4endl;
232 for (
unsigned int aTrack=0; aTrack<theResult->size();aTrack++)
234 G4cout <<
" corrected tracks .. " << (*theResult)[aTrack]->GetDefinition()->GetParticleName()
235 <<
" " << (*theResult)[aTrack]->Get4Momentum()
236 <<
" " << (*theResult)[aTrack]->Get4Momentum().mag()<<
G4endl;
237 KTsum1+= (*theResult)[aTrack]->Get4Momentum();
240 G4cout <<
"Needcorrector/success " << NeedEnergyCorrector <<
"/" << success <<
", Corrected total 4 momentum " << KTsum1 <<
G4endl;
241 if ( ! success )
G4cout <<
"failed to correct E/p" <<
G4endl;
243 G4cout<<
"End of the Hadronization (G4ExcitedStringDecay)"<<
G4endl;
246 for (
unsigned int astring=0; astring < theStrings->size(); astring++)
248 if ( theStrings->operator[](astring)->IsExcited() )
250 Ptmp=theStrings->operator[](astring)->GetLeftParton()->Get4Momentum();
251 Ptmp.transform( toLab);
252 theStrings->operator[](astring)->GetLeftParton()->Set4Momentum(Ptmp);
254 Ptmp=theStrings->operator[](astring)->GetRightParton()->Get4Momentum();
255 Ptmp.transform( toLab);
256 theStrings->operator[](astring)->GetRightParton()->Set4Momentum(Ptmp);
260 Ptmp=theStrings->operator[](astring)->GetKineticTrack()->Get4Momentum();
261 Ptmp.transform( toLab);
262 theStrings->operator[](astring)->GetKineticTrack()->Set4Momentum(Ptmp);
272 const int nAttemptScale = 500;
273 const double ErrLimit = 1.E-5;
274 if (Output->empty())
return TRUE;
277 G4double TotalCollisionMass = TotalCollisionMom.m();
279 #ifdef debug_G4ExcitedStringCorr
280 G4cout<<
G4endl<<
"EnergyAndMomentumCorrector. Number of particles: "<<Output->size()<<
G4endl;
283 unsigned int cHadron;
284 for(cHadron = 0; cHadron < Output->size(); cHadron++)
286 SumMom += Output->operator[](cHadron)->Get4Momentum();
287 SumMass += Output->operator[](cHadron)->GetDefinition()->GetPDGMass();
290 #ifdef debug_G4ExcitedStringCorr
291 G4cout<<
"Sum part mom "<<SumMom<<
" "<<SumMom.mag()<<
G4endl
292 <<
"Sum str mom "<<TotalCollisionMom<<
" "<<TotalCollisionMom.mag()<<
G4endl;
293 G4cout<<
"SumMass TotalCollisionMass "<<SumMass<<
" "<<TotalCollisionMass<<
G4endl;
297 if (Output->size() < 2)
return FALSE;
299 if (SumMass > TotalCollisionMass)
return FALSE;
300 SumMass = SumMom.m2();
301 if (SumMass < 0)
return FALSE;
302 SumMass = std::sqrt(SumMass);
315 for(cAttempt = 0; cAttempt < nAttemptScale; cAttempt++)
318 for(cHadron = 0; cHadron < Output->size(); cHadron++)
320 G4LorentzVector HadronMom = Output->operator[](cHadron)->Get4Momentum();
321 HadronMom.setVect(Scale*HadronMom.vect());
322 G4double E = std::sqrt(HadronMom.vect().mag2() +
sqr(Output->operator[](cHadron)->GetDefinition()->GetPDGMass()));
324 Output->operator[](cHadron)->Set4Momentum(HadronMom);
327 Scale = TotalCollisionMass/Sum;
328 #ifdef debug_G4ExcitedStringCorr
329 G4cout <<
"Scale-1=" << Scale -1
330 <<
", TotalCollisionMass=" << TotalCollisionMass
334 if (std::fabs(Scale - 1) <= ErrLimit)
340 #ifdef debug_G4ExcitedStringCorr
343 G4cout <<
"G4ExcitedStringDecay::EnergyAndMomentumCorrector - Warning"<<
G4endl;
344 G4cout <<
" Scale not unity at end of iteration loop: "<<TotalCollisionMass<<
" "<<Sum<<
" "<<Scale<<
G4endl;
345 G4cout <<
" Number of secondaries: " << Output->size() <<
G4endl;
346 G4cout <<
" Wanted total energy: " << TotalCollisionMom.e() <<
G4endl;
347 G4cout <<
" Increase number of attempts or increase ERRLIMIT"<<
G4endl;
352 Beta = TotalCollisionMom.boostVector();
G4bool EnergyAndMomentumCorrector(G4KineticTrackVector *Output, G4LorentzVector &TotalCollisionMom)
std::vector< G4ExcitedString * > G4ExcitedStringVector
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepLorentzRotation G4LorentzRotation
virtual G4KineticTrackVector * FragmentString(const G4ExcitedString &theString)=0
virtual G4KineticTrackVector * FragmentStrings(const G4ExcitedStringVector *theStrings)
const G4ExcitedStringDecay & operator=(const G4ExcitedStringDecay &right)
G4VLongitudinalStringDecay * theStringDecay
const G4String & GetParticleName() const
G4KineticTrackVector * FragmentString(const G4ExcitedString &theString)
G4GLOB_DLL std::ostream G4cout
void SetPosition(const G4ThreeVector aPosition)
int operator!=(const G4ExcitedStringDecay &right) const
void Boost(G4ThreeVector &Velocity)
static const double perMillion
int operator==(const G4ExcitedStringDecay &right) const
const G4ParticleDefinition * GetDefinition() const
virtual ~G4ExcitedStringDecay()
G4GLOB_DLL std::ostream G4cerr
CLHEP::HepLorentzVector G4LorentzVector