diff --git a/SimG4Core/Generators/src/Generator.cc b/SimG4Core/Generators/src/Generator.cc index 3093a795273d7..f8a14065db2a2 100644 --- a/SimG4Core/Generators/src/Generator.cc +++ b/SimG4Core/Generators/src/Generator.cc @@ -97,9 +97,11 @@ Generator::~Generator() delete fLumiFilter; } -void Generator::HepMC2G4(const HepMC::GenEvent * evt, G4Event * g4evt) +void Generator::HepMC2G4(const HepMC::GenEvent * evt_orig, G4Event * g4evt) { + HepMC::GenEvent *evt=new HepMC::GenEvent(*evt_orig); + if ( *(evt->vertices_begin()) == 0 ) { throw SimG4Exception("SimG4CoreGenerator: Corrupted Event - GenEvent with no vertex"); } @@ -374,7 +376,22 @@ void Generator::HepMC2G4(const HepMC::GenEvent * evt, G4Event * g4evt) G4PrimaryVertex* g4vtx = new G4PrimaryVertex(0.0, 0.0, 0.0, 0.0); if ( verbose > 1 ) g4vtx->Print(); g4evt->AddPrimaryVertex(g4vtx); + } else { + // restore original particle status + // to avoid problem downstream + for(HepMC::GenEvent::vertex_const_iterator vitr= evt->vertices_begin(); vitr != evt->vertices_end(); ++vitr ) { + HepMC::GenVertex::particle_iterator pitr; + for (pitr= (*vitr)->particles_begin(HepMC::children); + pitr != (*vitr)->particles_end(HepMC::children); ++pitr){ + int status = (*pitr)->status(); + if(status > 1000) { + (*pitr)->set_status(status - 1000); + } + } + } } + + delete evt; } void Generator::particleAssignDaughters( G4PrimaryParticle* g4p, @@ -447,8 +464,7 @@ void Generator::particleAssignDaughters( G4PrimaryParticle* g4p, double dd = std::sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)); particleAssignDaughters(g4daught,*vpdec,dd); } - // this line is the source of the "tau-bug" in 7_2_0_pre5 - //(*vpdec)->set_status(1000+(*vpdec)->status()); + (*vpdec)->set_status(1000+(*vpdec)->status()); g4p->SetDaughter(g4daught); if ( verbose > 1 ) g4daught->Print(); diff --git a/Validation/EventGenerator/src/HepMCValidationHelper.cc b/Validation/EventGenerator/src/HepMCValidationHelper.cc index acaff48216bc0..df806854a6885 100644 --- a/Validation/EventGenerator/src/HepMCValidationHelper.cc +++ b/Validation/EventGenerator/src/HepMCValidationHelper.cc @@ -2,7 +2,6 @@ #include "DataFormats/Math/interface/deltaR.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include -#include #include #include "TLorentzVector.h" @@ -185,10 +184,9 @@ namespace HepMCValidationHelper { for (unsigned int i = 0; i < taus.size(); ++i){ std::vector taudaughters; findDescendents(taus[i], taudaughters); - assert(taudaughters.size()>0); - if ( taudaughters.size()==0 ) { + if ( taudaughters.size()<=0 ) { edm::LogError("HepMCValidationHelper") << "Tau with no daughters. This is a bug. Fix it"; - continue; + //comment out for now to be safe abort(); } const HepMC::FourVector& taumom = taus[i]->momentum(); //remove the daughters from the list of particles to compute isolation