From 65e055b361f75fb494455a9b59864e5aba1564a2 Mon Sep 17 00:00:00 2001 From: alessandro Date: Wed, 1 Oct 2014 15:57:22 +0200 Subject: [PATCH 1/2] Fix conflicting checks. The if statement would never be true. With this fix the functionality is preserved with some more information in case of error. --- Validation/EventGenerator/src/HepMCValidationHelper.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Validation/EventGenerator/src/HepMCValidationHelper.cc b/Validation/EventGenerator/src/HepMCValidationHelper.cc index acaff48216bc0..8affc00179e1a 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; + abort(); } const HepMC::FourVector& taumom = taus[i]->momentum(); //remove the daughters from the list of particles to compute isolation From 19520d47cd84a0ca477b7ad96605ba14f8fedea7 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 1 Oct 2014 21:37:03 +0200 Subject: [PATCH 2/2] make Vladimirs change const correct --- SimG4Core/Generators/src/Generator.cc | 22 ++++++++++++++++--- .../src/HepMCValidationHelper.cc | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) 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 8affc00179e1a..df806854a6885 100644 --- a/Validation/EventGenerator/src/HepMCValidationHelper.cc +++ b/Validation/EventGenerator/src/HepMCValidationHelper.cc @@ -186,7 +186,7 @@ namespace HepMCValidationHelper { findDescendents(taus[i], taudaughters); if ( taudaughters.size()<=0 ) { edm::LogError("HepMCValidationHelper") << "Tau with no daughters. This is a bug. Fix it"; - abort(); + //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