Commit 355ebd13 authored by Elmar Ritsch's avatar Elmar Ritsch Committed by Graeme Stewart
Browse files

fixing coverity issue CID 13415 (ATLASSIM-1712) (ISF_HepMC_Tools-00-02-16)

	* GenEventStackFiller: fixing coverity issue CID 13415 (ATLASSIM-1712)
	* tag as ISF_HepMC_Tools-00-02-16

2014-11-07  Zach Marshall <ZLMarshall@lbl.gov>
	* GenEventVertexPositioner: Setting up vertex positioning for signal
	vertex (to be passed through xAOD)
	* tag as ISF_HepMC_Tools-00-02-15
parent 2cba9a3a
......@@ -156,13 +156,19 @@ StatusCode ISF::GenEventStackFiller::fillStack(ISF::ISFParticleContainer& partic
m_uniqueBc = 0;
m_largestBc = 0;
StatusCode sc;
if (!m_pMergeSvc.empty()) {
// 1. pileup merge service has been configured.
// retrieve and process merged mceventcollection set
return processMergedColls(particleColl);
sc = processMergedColls(particleColl);
} else {
// 2. try to retrieve and process regular mceventcollection, as usual
return processSingleColl(particleColl);
sc = processSingleColl(particleColl);
}
if (sc.isFailure()) {
ATH_MSG_ERROR("Unable to fill initial particle collection");
return StatusCode::FAILURE;
}
// register the largest barcode appearing in GEN_EVENT
......
......@@ -72,6 +72,9 @@ StatusCode ISF::GenEventVertexPositioner::manipulate(HepMC::GenEvent& ge)
ATH_MSG_VERBOSE("Retrieved Vertex shift of: " << *curShift);
// Get the signal process vertex, just in case...
HepMC::FourVector old_signal_spot = ge.signal_process_vertex()?ge.signal_process_vertex()->position():HepMC::FourVector(0,0,0,0);
// loop over the vertices in the event, they are in respect with another
// (code from Simulation/Fatras/FatrasAlgs/McEventPreProcessing.cxx)
HepMC::GenEvent::vertex_iterator vtxIt = ge.vertices_begin();
......@@ -93,6 +96,31 @@ StatusCode ISF::GenEventVertexPositioner::manipulate(HepMC::GenEvent& ge)
curVtx->set_position( newPos);
}
// Do the same for the signal process vertex
if ( ge.signal_process_vertex() ){
// Signal process vertex is a pointer. There is some risk that the pointer points
// to a vertex somewhere else in the event, rather than a unique / new vertex, in
// which case we will have already modified its position in the loop above. That
// is the reason for hanging on to an old position and seeing if we've moved...
// I would love it if HepMC had a minus operator defined for FourVectors... or
// even a get for the three vector component :(
HepMC::FourVector why_no_minus( ge.signal_process_vertex()->position().x() - old_signal_spot.x() ,
ge.signal_process_vertex()->position().y() - old_signal_spot.y() ,
ge.signal_process_vertex()->position().z() - old_signal_spot.z() ,
ge.signal_process_vertex()->position().t() - old_signal_spot.t() );
if ( why_no_minus.rho() < 0.000001 && why_no_minus.m2() < 0.000001 ){
const HepMC::FourVector &curPos = ge.signal_process_vertex()->position();
CLHEP::HepLorentzVector newPos( curPos.x(), curPos.y(), curPos.z(), curPos.t() );
newPos += (*curShift);
ge.signal_process_vertex()->set_position( newPos);
}
} else { // Have to make a new one
// Don't worry about ID and weights - those should never be used from this thing
HepMC::GenVertex * sig_proc_vert = new HepMC::GenVertex( (*curShift) );
// ge will now take ownership of the signal process vertex
ge.set_signal_process_vertex( sig_proc_vert );
} // Manipulated the signal process vertex
// memory cleanup
delete curShift;
}
......
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