Skip to content

Commit

Permalink
Merge pull request #5643 from davidlange6/fix_SimG4CoreGenerators
Browse files Browse the repository at this point in the history
Fix sim g4 core generators
  • Loading branch information
davidlange6 committed Oct 1, 2014
2 parents ca8d7eb + 19520d4 commit b831028
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
22 changes: 19 additions & 3 deletions SimG4Core/Generators/src/Generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 2 additions & 4 deletions Validation/EventGenerator/src/HepMCValidationHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "DataFormats/Math/interface/deltaR.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <iostream>
#include <cassert>
#include <limits>
#include "TLorentzVector.h"

Expand Down Expand Up @@ -185,10 +184,9 @@ namespace HepMCValidationHelper {
for (unsigned int i = 0; i < taus.size(); ++i){
std::vector<const HepMC::GenParticle*> 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
Expand Down

0 comments on commit b831028

Please sign in to comment.