Commit 334c7cfd authored by Frank Krauss's avatar Frank Krauss Committed by Enrico Bothmann

Fix double free exception in DIS events

Passes 1M events for LHC & DIS now
parent 3ee7e828
......@@ -103,10 +103,11 @@ bool Beam_Particles_Shifter::RescueLightClusters() {
if (beam) {
double mass = sqrt(sing->Mass2());
if (p_softclusters->MustPromptDecay(trip,anti,mass)) {
//msg_Out()<<"Gotcha pair ("<<trip<<", "<<anti<<") -> mass = "<<mass<<"!\n";
if (sing->size()>2) {
msg_Out()<<" have to add gluons to trip/anti.\n";
exit(1);
msg_Out()<<"Gotcha pair ("<<trip<<", "<<anti<<") -> mass = "<<mass<<"!\n"
<<" have to add gluons to trip/anti.\n"<<(*sing)<<"n";
sing->StripSingletOfGluons();
//exit(1);
}
Cluster cluster((*sing->begin()),(*sing->rbegin()));
if (p_softclusters->Treat(&cluster,true)) {
......
......@@ -58,6 +58,23 @@ bool Singlet::Combine(Proto_Particle * part1,Proto_Particle * part2) {
return false;
}
void Singlet::StripSingletOfGluons() {
list<Proto_Particle *>::iterator pit=begin();
msg_Out()<<METHOD<<" adds momenta to particle with flavour = "
<<(*pit)->Flavour()<<"\n";
Vec4D mom = Vec4D(0.,0.,0.,0.);
pit++;
do {
msg_Out()<<" add mom = "<<(*pit)->Momentum()<<" from "
<<(*pit)->Flavour()<<", ";
mom += (*pit)->Momentum();
pit = erase(pit);
msg_Out()<<size()<<" particles left in singlet.\n";
} while ((*pit)!=(*rbegin()));
(*begin())->SetMomentum((*begin())->Momentum()+0.5*mom);
(*rbegin())->SetMomentum((*rbegin())->Momentum()+0.5*mom);
}
void Singlet::Erase(Proto_Particle * ref) {
for (list<Proto_Particle *>::iterator pit=begin();
pit!=end();pit++) {
......
......@@ -14,6 +14,7 @@ namespace AHADIC {
~Singlet();
void Reorder(Proto_Particle * first=NULL);
void Erase(Proto_Particle * ref);
void StripSingletOfGluons();
bool Combine(Proto_Particle * part1,Proto_Particle * part2);
double Mass2() const;
ATOOLS::Vec4D Momentum() const;
......
......@@ -208,7 +208,12 @@ double Hadron_Remnant::SelectZ(const Flavour & flav,const bool & isvalence) {
void Hadron_Remnant::Reset(const bool & DIS) {
Remnant_Base::Reset();
while (!m_spectators.empty()) {
if (DIS) delete m_spectators.front();
Particle * part = m_spectators.front();
if (part->ProductionBlob())
part->ProductionBlob()->RemoveOutParticle(part);
if (part->DecayBlob())
part->DecayBlob()->RemoveInParticle(part);
delete part;
m_spectators.pop_front();
}
m_spectators.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment