Commit 73d68831 authored by Andrii Verbytskyi's avatar Andrii Verbytskyi
Browse files

Cleanup and a bit of migration to HepMC3

parent 0a56170c
......@@ -897,7 +897,7 @@ void DetailedMuonPatternTruthBuilder::addDetailedTrackTruth(std::vector<Detailed
const HepMC::GenParticle *current = link.cptr();
do {
HepMcParticleLink curlink(current->barcode(), eventIndex);
HepMcParticleLink curlink(HepMC::barcode(current), eventIndex);
// remove the current particle from the list of particles to consider (if it is still there)
seeds.erase(curlink);
......@@ -1145,7 +1145,7 @@ void DetailedMuonPatternTruthBuilder::addDetailedTrackTruthFromSegment(std::vect
const HepMC::GenParticle *current = link.cptr();
do {
HepMcParticleLink curlink(current->barcode(), eventIndex);
HepMcParticleLink curlink(HepMC::barcode(current), eventIndex);
// remove the current particle from the list of particles to consider (if it is still there)
seeds.erase(curlink);
......
......@@ -112,7 +112,7 @@ bool GenObjectsFilterTool::pass( const HepMC::GenEvent* evt,
int gotzero = 1;
for( ; iter != end; ++iter ) {
if( ( ( ( *iter )->event_number() == -1 ) &&
( ( *iter )->signal_process_id() == 0 ) ) ) {
( HepMC::signal_process_id(( *iter )) == 0 ) ) ) {
++gotzero;
}
if( evt == *iter ) break;
......@@ -393,7 +393,7 @@ bool GenObjectsFilterTool::pass( const HepMC::GenParticle* part,
/// remove gluons and quarks of status 2 that pass IsGenStable!!!
if( abs(pdg) < 7 || abs(pdg) == 21 ) return false;
const HepPDT::ParticleData* pd = m_partPropSvc->PDT()->particle( abs( pdg ) );
const HepPDT::ParticleData* pd = m_partPropSvc->PDT()->particle( std::abs( pdg ) );
if( ! pd ) {
ATH_MSG_DEBUG( "Could not get particle data for pdg = " << pdg
<< " status " << part->status() << " barcode " <<HepMC::barcode(part)
......
......@@ -143,7 +143,7 @@ TruthParticleFilterTool::isAccepted (const HepMC::GenParticle* p)
bool ok = false;
int pdg_id = std::abs (p->pdg_id());
int barcode = p->barcode();
int barcode = HepMC::barcode(p);
// Keep first N particles
if (m_particleCountSoFar<m_writeFirstN){
......@@ -151,7 +151,7 @@ TruthParticleFilterTool::isAccepted (const HepMC::GenParticle* p)
ok=true;
}
if (p->barcode() > GEANTMIN && !m_writeGeant && !m_writeEverything && !ok) {
if (HepMC::barcode(p) > GEANTMIN && !m_writeGeant && !m_writeEverything && !ok) {
if (! (pdg_id == PDG::gamma &&
m_geantPhotonPtThresh >= 0 &&
p->momentum().perp() > m_geantPhotonPtThresh) )
......@@ -253,12 +253,12 @@ bool TruthParticleFilterTool::isLeptonFromTau(const HepMC::GenParticle* part) co
int pdg = part->pdg_id();
if(abs(pdg) != 11 &&
abs(pdg) != 12 &&
abs(pdg) != 13 &&
abs(pdg) != 14 &&
abs(pdg) != 15 &&
abs(pdg) != 16) return false; // all leptons including tau.
if(std::abs(pdg) != 11 &&
std::abs(pdg) != 12 &&
std::abs(pdg) != 13 &&
std::abs(pdg) != 14 &&
std::abs(pdg) != 15 &&
std::abs(pdg) != 16) return false; // all leptons including tau.
HepMC::GenVertex* prod = part->production_vertex();
if(!prod) return false; // no parent.
......@@ -293,14 +293,14 @@ bool TruthParticleFilterTool::isFromTau(const HepMC::GenParticle* part) {
int pdg = part->pdg_id();
HepMC::GenVertex* prod = part->production_vertex();
auto prod = part->production_vertex();
if(!prod) return false; // no parent.
// Simple loop catch
if (prod==part->end_vertex()) return false;
// More complex loop catch
if ( find(m_barcode_trace.begin(),m_barcode_trace.end(),prod->barcode()) != m_barcode_trace.end()){
if ( find(m_barcode_trace.begin(),m_barcode_trace.end(),HepMC::barcode(prod)) != m_barcode_trace.end()){
ATH_MSG_DEBUG( "Found a loop (a la Sherpa sample). Backing out." );
return false;
}
......@@ -380,7 +380,7 @@ bool TruthParticleFilterTool::isFsrFromLepton(const HepMC::GenParticle* part) co
if(std::abs(pdg) != 22) return false; // photon
if(HepMC::barcode(part) >= 200000) return false; // Geant photon
HepMC::GenVertex* prod = part->production_vertex();
auto prod = part->production_vertex();
if(!prod) return false; // no parent.
// Loop over the parents of this particle.
......@@ -388,10 +388,10 @@ bool TruthParticleFilterTool::isFsrFromLepton(const HepMC::GenParticle* part) co
HepMC::GenVertex::particle_iterator endParent = prod->particles_end(HepMC::parents);
for(;itrParent!=endParent; ++itrParent){
int parentId = (*itrParent)->pdg_id();
if(abs(parentId) == 11 ||
abs(parentId) == 13 ||
abs(parentId) == 15) {
ATH_MSG_DEBUG("Photon with barcode " << part->barcode() << " matched to particle with pdgId = " << parentId );
if(std::abs(parentId) == 11 ||
std::abs(parentId) == 13 ||
std::abs(parentId) == 15) {
ATH_MSG_DEBUG("Photon with barcode " << HepMC::barcode(part) << " matched to particle with pdgId = " << parentId );
return true; // Has lepton parent
}
......
......@@ -65,7 +65,7 @@ GenEventGenParticleAssociationTool::reset (const HepMC::GenEvent& p)
const HepMC::GenParticle* GenEventGenParticleAssociationTool::next()
{
if (m_it == m_end)
return 0;
return nullptr;
const HepMC::GenParticle* out;
......
......@@ -19,6 +19,7 @@
#include "D3PDMakerUtils/BlockFillerTool.h"
#include "AtlasHepMC/GenVertex.h"
#include "AtlasHepMC/SimpleVector.h"
namespace D3PD {
......
......@@ -358,13 +358,12 @@ bool TruthJetFilterTool::isLeptonFromTau(const HepMC::GenParticle* part) const{
bool
TruthJetFilterTool::acceptParticle (const HepMC::GenParticle* p)
{
bool ok = false;
bool ok = false;
int pdg_id = std::abs (p->pdg_id());
int status = p->status();
int barcode = p->barcode();
int barcode = HepMC::barcode(p);
if (p->barcode() > GEANTMIN && !m_writeGeant)
if (barcode > GEANTMIN && !m_writeGeant)
return false;
if (m_excludeWZdecays) {
......
......@@ -69,9 +69,6 @@ class CompactHardTruth
virtual StatusCode execute();
virtual StatusCode finalize();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
// Parton is quark or gluon
virtual bool isParton( const HepMC::GenParticle* );
......@@ -86,13 +83,6 @@ class CompactHardTruth
virtual HepMC::FourVector vtxInMom(HepMC::GenVertex*);
virtual HepMC::FourVector vtxOutMom(HepMC::GenVertex*);
///////////////////////////////////////////////////////////////////
// Non-const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Private data:
///////////////////////////////////////////////////////////////////
private:
/// Default constructor:
......@@ -120,12 +110,6 @@ class CompactHardTruth
};
// I/O operators
//////////////////////
///////////////////////////////////////////////////////////////////
// Inline methods:
///////////////////////////////////////////////////////////////////
} //> end namespace DerivationFramework
#endif //> !DERIVATIONFRAMEWORK_COMPACTHARDTRUTH_H
......@@ -375,12 +375,6 @@ StatusCode CompactHardTruth::execute() {
bool moreP = true;
typedef std::pair<HepMC::GenVertex*, HepMC::GenParticle*> vpPair;
// std::vector<vpPair> removePV;
// std::vector<vpPair> addinPV;
// std::vector<vpPair> addoutPV;
// std::vector<HepMC::GenVertex*> removeV;
// std::list<HepMC::GenParticle*> deleteP;
// std::list<HepMC::GenVertex*> deleteV;
removePV.clear();
addinPV.clear();
addoutPV.clear();
......
......@@ -114,7 +114,7 @@ EtaPtFilterTool::~EtaPtFilterTool()
StatusCode EtaPtFilterTool::buildMcAod( const McEventCollection* in,McEventCollection* out )
{
if ( 0 == in || 0 == out ) {
if ( !in || !out ) {
ATH_MSG_ERROR("Invalid pointer to McEventCollection !" << endmsg
<< " in: " << in << endmsg
<< " out: " << out);
......@@ -168,7 +168,7 @@ StatusCode EtaPtFilterTool::buildMcAod( const McEventCollection* in,McEventColle
StatusCode EtaPtFilterTool::buildGenEvent( const HepMC::GenEvent* in, HepMC::GenEvent* out )
{
if ( 0 == in || 0 == out ) {
if ( nullptr == in || nullptr == out ) {
ATH_MSG_ERROR("Invalid pointer to GenEvent !!" << endmsg
<< " in: " << in << endmsg
<< " out: " << out);
......@@ -198,7 +198,7 @@ StatusCode EtaPtFilterTool::buildGenEvent( const HepMC::GenEvent* in, HepMC::Gen
bool EtaPtFilterTool::isAccepted( HepMC::ConstGenParticlePtr mc ) const
{
if ( 0 == mc ) {
if ( ! mc ) {
return false;
}
......@@ -246,7 +246,7 @@ bool EtaPtFilterTool::isAccepted( HepMC::ConstGenParticlePtr mc ) const
bool EtaPtFilterTool::isAccepted( const HepMC::GenVertex* vtx ) const
{
if ( 0 == vtx ) {
if ( !vtx ) {
return false;
}
......
......@@ -140,8 +140,5 @@ class TruthIsolationTool : virtual public ITruthIsolationTool,
};
///////////////////////////////////////////////////////////////////
// Inline methods:
///////////////////////////////////////////////////////////////////
#endif
......@@ -65,7 +65,7 @@ VtxBasedFilterTool::~VtxBasedFilterTool()
StatusCode VtxBasedFilterTool::buildMcAod( const McEventCollection* in,
McEventCollection* out )
{
if ( 0 == in || 0 == out ) {
if ( !in || ! out ) {
msg(MSG::ERROR)
<< "Invalid pointer to McEventCollection !" << endmsg
<< " in: " << in << endmsg
......@@ -75,7 +75,7 @@ StatusCode VtxBasedFilterTool::buildMcAod( const McEventCollection* in,
for ( unsigned int iEvt = 0; iEvt != in->size(); ++iEvt ) {
const HepMC::GenEvent * inEvt = (*in)[iEvt];
if ( 0 == inEvt ) {
if ( !inEvt ) {
msg(MSG::WARNING)
<< "Could not launch filtering procedure for GenEvent number ["
<< iEvt << "] from McEventCollection ["
......@@ -118,7 +118,7 @@ StatusCode VtxBasedFilterTool::buildMcAod( const McEventCollection* in,
StatusCode VtxBasedFilterTool::buildGenEvent( const HepMC::GenEvent* in,
HepMC::GenEvent* out )
{
if ( 0 == in || 0 == out ) {
if ( !in || !out ) {
msg(MSG::ERROR)
<< "Invalid pointer to GenEvent !!" << endmsg
<< " in: " << in << endmsg
......@@ -148,7 +148,7 @@ StatusCode VtxBasedFilterTool::buildGenEvent( const HepMC::GenEvent* in,
bool VtxBasedFilterTool::isAccepted( const HepMC::GenVertex* vtx ) const
{
if ( 0 == vtx ) {
if ( !vtx ) {
return false;
}
......@@ -169,7 +169,7 @@ bool VtxBasedFilterTool::isAccepted( const HepMC::GenVertex* vtx ) const
StatusCode VtxBasedFilterTool::addVertex( const HepMC::GenVertex* srcVtx,
HepMC::GenEvent* evt ) const
{
if ( 0 == srcVtx || 0 == evt ) {
if ( !srcVtx || !evt ) {
msg(MSG::ERROR)
<< "In addVertex(vtx,evt) : INVALID pointer given !!" << endmsg
<< " vtx: " << srcVtx << endmsg
......
......@@ -65,9 +65,6 @@ class VtxBasedFilterTool : public TruthParticleFilterBaseTool
/// Destructor:
virtual ~VtxBasedFilterTool();
///////////////////////////////////////////////////////////////////
// Const methods:
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
// Non-const methods:
......@@ -158,11 +155,5 @@ class VtxBasedFilterTool : public TruthParticleFilterBaseTool
};
/// I/O operators
//////////////////////
///////////////////////////////////////////////////////////////////
/// Inline methods:
///////////////////////////////////////////////////////////////////
#endif //> MCPARTICLETOOLS_VTXBASEDFILTERTOOL_H
Supports Markdown
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