Commit fb2c800d authored by Andrii Verbytskyi's avatar Andrii Verbytskyi Committed by Walter Lampl
Browse files

Cleanup in the codes that will be migrated to HepMC3

parent 8de73746
......@@ -92,8 +92,12 @@ StatusCode GenObjectsFilterTool::initialize() {
bool GenObjectsFilterTool::pass( const HepMC::GenEvent* evt,
const McEventCollection* coll ) const {
#ifdef HEPMC3
bool isEmpty = ( evt->particles().size() == 0 );
#else
bool isEmpty = ( evt->particles_size() == 0 );
#endif
bool isDummy = ( ( evt->event_number() == -1 ) &&
( HepMC::signal_process_id(evt) == 0 ) );
if( isDummy ) isEmpty = false;
......@@ -139,7 +143,7 @@ bool GenObjectsFilterTool::isBCHadron(const HepMC::GenParticle* part) const{
}
bool GenObjectsFilterTool::isBC(int pdg) const{
if(abs(pdg)==5 || abs(pdg)==4)return true;
if(std::abs(pdg)==5 || std::abs(pdg)==4)return true;
return false;
}
......@@ -155,7 +159,7 @@ bool GenObjectsFilterTool::isLeptonicWZ(const HepMC::GenParticle* part) const{
int pdg = part->pdg_id();
if(abs(pdg)!=24 && abs(pdg)!=23) return false;
if(std::abs(pdg)!=24 && std::abs(pdg)!=23) return false;
/// take into account W/Z->W/Z->lnu/ll
......@@ -165,7 +169,7 @@ bool GenObjectsFilterTool::isLeptonicWZ(const HepMC::GenParticle* part) const{
HepMC::GenVertex::particle_iterator endChild = end->particles_end(HepMC::children);
for(;firstChild!=endChild; ++firstChild){
int cpdg = (*firstChild)->pdg_id();
if(abs(cpdg) == 11 || abs(cpdg) == 13 || abs(cpdg) == 15){
if(std::abs(cpdg) == 11 || std::abs(cpdg) == 13 || std::abs(cpdg) == 15){
return true;
}
if(cpdg == pdg){
......@@ -276,7 +280,7 @@ bool GenObjectsFilterTool::isRequested( const HepMC::GenParticle* part) const{
if(m_keepLeptonicWZBosons){
if(abs(pdg)==24 || abs(pdg)==23){
if(std::abs(pdg)==24 || std::abs(pdg)==23){
if(isLeptonicWZ(part)) return true;
}
}
......@@ -291,7 +295,7 @@ bool GenObjectsFilterTool::isRequested( const HepMC::GenParticle* part) const{
HepMC::GenVertex::particle_iterator endParent = prod->particles_end(HepMC::ancestors);
for(;firstParent!=endParent; ++firstParent){
if( abs((*firstParent)->pdg_id())==24 || abs((*firstParent)->pdg_id())==23){
if( std::abs((*firstParent)->pdg_id())==24 || std::abs((*firstParent)->pdg_id())==23){
if( isLeptonicWZ(*firstParent) ){
isleptonicWZ=true;
break;
......@@ -312,7 +316,7 @@ bool GenObjectsFilterTool::isRequested( const HepMC::GenParticle* part) const{
HepMC::GenVertex::particle_iterator endChild = end->particles_end(HepMC::children);
for(;firstChild!=endChild; ++firstChild){
if( abs((*firstChild)->pdg_id())==24 || abs((*firstChild)->pdg_id())==23){
if( std::abs((*firstChild)->pdg_id())==24 || std::abs((*firstChild)->pdg_id())==23){
if( isLeptonicWZ(*firstChild) ){
isleptonicWZ=true;
break;
......@@ -335,7 +339,7 @@ bool GenObjectsFilterTool::isRequested( const HepMC::GenParticle* part) const{
HepMC::GenVertex::particle_iterator endParent = prod->particles_end(HepMC::ancestors);
for(;firstParent!=endParent; ++firstParent){
if( abs((*firstParent)->pdg_id())==24 || abs((*firstParent)->pdg_id())==23){
if( std::abs((*firstParent)->pdg_id())==24 || std::abs((*firstParent)->pdg_id())==23){
if( isLeptonicWZ(*firstParent) ){
isleptonicWZ=true;
break;
......@@ -365,7 +369,7 @@ bool GenObjectsFilterTool::passParticleCuts( const HepMC::GenParticle* part) con
double eta = p4.eta();
if( pt < m_ptMinCut ) return false;
if( ( fabs( eta ) > m_etaCut ) && ( m_etaCut >= 0. ) ) return false;
if( ( std::abs( eta ) > m_etaCut ) && ( m_etaCut >= 0. ) ) return false;
return true;
......@@ -391,7 +395,7 @@ bool GenObjectsFilterTool::pass( const HepMC::GenParticle* part,
int pdg = part->pdg_id();
/// remove gluons and quarks of status 2 that pass IsGenStable!!!
if( abs(pdg) < 7 || abs(pdg) == 21 ) return false;
if( std::abs(pdg) < 7 || std::abs(pdg) == 21 ) return false;
const HepPDT::ParticleData* pd = m_partPropSvc->PDT()->particle( std::abs( pdg ) );
if( ! pd ) {
......@@ -402,7 +406,7 @@ bool GenObjectsFilterTool::pass( const HepMC::GenParticle* part,
}
float charge = pd->charge();
if( fabs( charge ) < 1E-5 ) return false;
if( std::abs( charge ) < 1E-5 ) return false;
return true;
}
......@@ -410,7 +414,7 @@ bool GenObjectsFilterTool::pass( const HepMC::GenParticle* part,
bool GenObjectsFilterTool::pass( const HepMC::GenVertex* vtx,
const McEventCollection* coll ) const {
HepMC::GenEvent* event = vtx->parent_event();
const HepMC::GenEvent* event = vtx->parent_event();
// Check if the vertex is coming from a "good" GenEvent:
if( ! pass(event , coll ) ) return false;
......@@ -425,10 +429,8 @@ bool GenObjectsFilterTool::pass( const HepMC::GenVertex* vtx,
if(m_addOnlyFirstVertex) return false;
// Check if any of the incoming particles pass our selection cuts:
std::vector< HepMC::GenParticle* >::const_iterator iter =
vtx->particles_in_const_begin();
std::vector< HepMC::GenParticle* >::const_iterator end =
vtx->particles_in_const_end();
std::vector< HepMC::GenParticle* >::const_iterator iter = vtx->particles_in_const_begin();
std::vector< HepMC::GenParticle* >::const_iterator end = vtx->particles_in_const_end();
for( ; iter != end; ++iter ) {
if( pass( *iter ) ) return true;
}
......
......@@ -298,8 +298,7 @@ TruthParticleFilterBase::isolations (TruthEtIsolationsContainer const* &isocont)
return StatusCode::FAILURE;
}
std::string isoname =
m_isolationTool->etIsolationsName (m_mcEventsOutputName);
std::string isoname = m_isolationTool->etIsolationsName (m_mcEventsOutputName);
CHECK( evtStore()->retrieve (isocont, isoname) );
......
......@@ -979,7 +979,7 @@ bool CompactHardTruth::isFinalParton(const HepMC::GenParticle* p) {
// Hadron excludes leptons and BSM particles
// Includes clusters to find, e.g., partons->cluster vertices
bool CompactHardTruth::isHadron(const HepMC::GenParticle* p) {
int ida = abs(p->pdg_id());
int ida = std::abs(p->pdg_id());
if ((ida >= 80 && ida < 1000000) || ida > 9000000) return true;
return false;
}
......
......@@ -14,8 +14,6 @@
// STL includes
#include <set>
// FrameWork includes
// McParticleTools includes
#include "TruthParticleFilterBaseTool.h"
......
......@@ -14,8 +14,6 @@
// STL includes
#include <set>
// FrameWork includes
// McParticleTools includes
#include "TruthParticleFilterBaseTool.h"
......@@ -35,8 +33,6 @@ class PileupFilterTool : public TruthParticleFilterBaseTool
///////////////////////////////////////////////////////////////////
public:
// Copy constructor:
/// Constructor with parameters:
PileupFilterTool( const std::string& type,
const std::string& name,
......
......@@ -25,10 +25,6 @@
// McParticleTools includes
#include "VtxBasedFilterTool.h"
///////////////////////////////////////////////////////////////////
/// Public methods:
///////////////////////////////////////////////////////////////////
using namespace TruthHelper;
/// Constructors
......@@ -127,19 +123,17 @@ StatusCode VtxBasedFilterTool::buildGenEvent( const HepMC::GenEvent* in,
}
// loop over vertices
for ( HepMC::GenEvent::vertex_const_iterator vtx = in->vertices_begin();
vtx != in->vertices_end();
++vtx ) {
if ( !isAccepted(*vtx) ) {
for ( HepMC::GenEvent::vertex_const_iterator vtxit = in->vertices_begin(); vtxit != in->vertices_end(); ++vtxit ) {
auto vtx=*vtxit;
if ( !isAccepted(vtx) ) {
// no in-going nor out-going particles at this vertex matches
// the requirements: ==> Skip it
continue;
}
if ( addVertex( *vtx, out ).isFailure() ) {
if ( addVertex( vtx, out ).isFailure() ) {
msg(MSG::WARNING)
<< "Could not add vertex [" << (*vtx)->barcode() << "]" << endmsg;
<< "Could not add vertex [" << HepMC::barcode(vtx) << "]" << endmsg;
}
} //> end loop over vertices
......
......@@ -55,8 +55,6 @@ class VtxBasedFilterTool : public TruthParticleFilterBaseTool
///////////////////////////////////////////////////////////////////
public:
// Copy constructor:
/// Constructor with parameters:
VtxBasedFilterTool( const std::string& type,
const std::string& name,
......
......@@ -8,9 +8,6 @@
// Author: S.Binet<binet@cern.ch>
///////////////////////////////////////////////////////////////////
// STL includes
// Framework includes
#include "AthenaKernel/getMessageSvc.h"
#include "GaudiKernel/MsgStream.h"
......@@ -142,8 +139,7 @@ bool McVtxFilter::isAccepted( const HepMC::GenVertex * vtx ) const
vtx->particles_out_size() == static_cast<unsigned int>( 1 ) ) {
const HepMC::GenParticle * part = *(vtx->particles_out_const_begin());
const ParticleCandidateList * item = *( m_childList.begin() );
if ( item->hasInList( static_cast<PDG::pidType>(part->pdg_id()),
m_matchSign ) ) {
if ( item->hasInList( static_cast<PDG::pidType>(part->pdg_id()), m_matchSign ) ) {
return true;
} else {
return false;
......@@ -395,8 +391,7 @@ bool McVtxFilter::checkChildBranch( const HepMC::GenVertex * vtx ) const
childIds.push_back( (*itrPart)->pdg_id() );
}
AnalysisUtils::Permutation<std::vector<int> > permute( &childIds,
m_childList.size() );
AnalysisUtils::Permutation<std::vector<int> > permute( &childIds, m_childList.size() );
std::vector<int> children;
bool accepted = false;
......@@ -457,9 +452,7 @@ bool McVtxFilter::checkTwoBodyDecay( const HepMC::GenVertex * vtx ) const
for( ParticleCandidateList::const_iterator itr2 = children2->begin();
itr2 != children2->end();
++itr2 ) {
m_msg << MSG::VERBOSE << "Checking the pair : "
<< (*itr1) << "/" << (*itr2)
<< endmsg;
m_msg << MSG::VERBOSE << "Checking the pair : " << (*itr1) << "/" << (*itr2) << endmsg;
/// If the strict match sign has been required, we check if
/// the PDG ids are matching
......
......@@ -12,16 +12,11 @@
#include "GaudiKernel/PhysicalConstants.h"
using namespace Gaudi::Units;
//#include <boost/functional/hash.hpp>
#include <vector>
using std::vector;
#include <string>
using std::string;
#include <cmath>
using std::sqrt;
using std::abs;
// using std::cout;
// using std::endl;
typedef std::pair<int, int> IndexKey;
namespace {
double charge( const int id ) {
......@@ -48,14 +43,14 @@ namespace {
i != 0: baryon, i j k quarks l = 2*spin+1
Default is 0; */
const int sid = abs(id);
const int sid = std::abs(id);
double q = 0;
if ( sid==11 || sid==13 || sid==15 || sid==17 ) q=1; // charged leptons
else if ( sid==12 || sid==14 || sid==16 || sid==18 || sid==22 ) q=0; // neutral leptons and photon
else if ( sid == 2212 || sid==24 ) q=1; //proton/anti-proton and W
else if ( sid == 2112 || sid==23 ) q=0; //neutron/anti-neutron and Z
else { // quarks, gluons, measons and other baryons
int idmod = abs(id) % 10000;
int idmod = std::abs(id) % 10000;
int q1 = (idmod/10) % 10;
int q2 = (idmod/100) % 10;
int q3 = (idmod/1000) % 10;
......@@ -79,13 +74,9 @@ namespace {
//std::size_t key(0);
//Check for Separtor GenEvents
if(signal_process_id==0 && event_number==-1) {
//boost::hash_combine(key, separator_hack);
return std::make_pair(separator_hack, event_number);
}
return std::make_pair(signal_process_id, event_number);
//else { boost::hash_combine(key, signal_process_id); }
//boost::hash_combine(key, event_number);
//return key;
}
class GenEventSorter {
......@@ -438,8 +429,8 @@ StatusCode MergeMcEventCollTool::processTruthFilteredEvent(const McEventCollecti
HepMC::GenEvent& currentBackgroundEvent(*(m_pOvrlMcEvColl->at(m_startingIndexForBackground+m_nBkgEventsReadSoFar)));
currentBackgroundEvent.set_event_number(currentBkgEventIndex);
puType currentGenEventClassification(RESTOFMB);
if ( fabs(currentEventTime)<51.0 ) {
currentGenEventClassification = ( fabs(currentEventTime)<1.0 ) ? INTIME : OUTOFTIME;
if ( std::abs(currentEventTime)<51.0 ) {
currentGenEventClassification = ( std::abs(currentEventTime)<1.0 ) ? INTIME : OUTOFTIME;
}
updateClassificationMap(HepMC::signal_process_id(currentBackgroundEvent),
currentBackgroundEvent.event_number(),
......@@ -464,7 +455,6 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
HepMC::GenEvent::vertex_const_iterator currentVertexIter(currentBackgroundEvent.vertices_begin());
const HepMC::GenEvent::vertex_const_iterator endOfCurrentListOfVertices(currentBackgroundEvent.vertices_end());
ATH_MSG_VERBOSE( "Starting a vertex loop ... " );
//cout << "Starting a vertex loop ... " <<endl;
for (; currentVertexIter != endOfCurrentListOfVertices; ++currentVertexIter) {
const HepMC::GenVertexPtr pCurrentVertex(*currentVertexIter);
HepMC::GenVertexPtr pCopyOfVertexForClassification[NOPUTYPE];
......@@ -479,7 +469,6 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
//loop over outgoing particles in the current GenVertex keeping those not classified as NOPUTYPE
ATH_MSG_VERBOSE( "Starting an outgoing particle loop ... " );
//cout << "Starting an outgoing particle loop ... " <<endl;
HepMC::GenVertex::particles_out_const_iterator currentVertexParticleIter(pCurrentVertex->particles_out_const_begin());
const HepMC::GenVertex::particles_out_const_iterator endOfListOfParticlesFromCurrentVertex(pCurrentVertex->particles_out_const_end());
for (; currentVertexParticleIter != endOfListOfParticlesFromCurrentVertex; ++currentVertexParticleIter) {
......@@ -492,12 +481,10 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
particleClassification=INTIME;
}
//add particle to appropriate vertex
// cout << "Parttype is " << particleClassification << endl;
if (particleClassification<NOPUTYPE && m_saveType[particleClassification]) {
if (!pCopyOfVertexForClassification[particleClassification]) {
pCopyOfVertexForClassification[particleClassification] = new HepMC::GenVertex(pCurrentVertex->position());
ATH_MSG_VERBOSE( "Added bkg vertex " << pCopyOfVertexForClassification[particleClassification]
// << " at position " << pCurrentVertex->position()
<< " at position " << HepMC::GenVertex(pCurrentVertex->position())
<< " for pu type = " << particleClassification );
}
......@@ -509,7 +496,6 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
} //particle loop
/** add the in-coming particles to the in-time minbias vertex only */
if (m_saveType[INTIME] && pCopyOfVertexForClassification[INTIME]) {
// cout << "saving incoming parts for INTIME vertex " << pCopyOfVertexForClassification[INTIME] << endl;
HepMC::GenVertex::particles_in_const_iterator currentVertexParticleIter(pCurrentVertex->particles_in_const_begin());
const HepMC::GenVertex::particles_in_const_iterator endOfListOfParticlesFromCurrentVertex(pCurrentVertex->particles_in_const_end());
for (; currentVertexParticleIter != endOfListOfParticlesFromCurrentVertex; ++currentVertexParticleIter) {
......@@ -524,8 +510,6 @@ StatusCode MergeMcEventCollTool::processUnfilteredEvent(const McEventCollection
}
}
} //vertex loop
// if(m_doSlimming) ATH_MSG_VERBOSE( "execute: copied skimmed Background GenEvent into Output McEventCollection." );
// else ATH_MSG_VERBOSE( "execute: copied full Background GenEvent into Output McEventCollection." );
return StatusCode::SUCCESS;
}
......@@ -556,21 +540,20 @@ MergeMcEventCollTool::puType MergeMcEventCollTool::classifyVertex(const HepMC::G
//throw away unstable particles and particles outside eta cut
if ( m_keepUnstable || MC::isSimStable(pCurrentVertexParticle) ) {
/** cut to select between minbias and cavern background pileup events */
if ( fabs(pCurrentParticleProductionVertex->position().z()) < m_zRange ) {
if ( std::abs(pCurrentParticleProductionVertex->position().z()) < m_zRange ) {
const float xi((pCurrentParticleProductionVertex->position()).x());
const float yi((pCurrentParticleProductionVertex->position()).y());
if ( !m_doSlimming || ( (xi*xi + yi*yi < m_r2Range) && (pCurrentVertexParticle->momentum().perp() > m_ptMin) ) ) {
const double eta(pCurrentVertexParticle->momentum().pseudoRapidity());
if ( !m_doSlimming || (fabs(eta) <= m_absEtaMax) ) {
if ( !m_doSlimming || (std::abs(eta) <= m_absEtaMax) ) {
const bool currentEventIsInTime((m_lowTimeToKeep<=currentEventTime) && (currentEventTime<=m_highTimeToKeep));
if ( currentEventIsInTime ) {
// cout << "the Time is " << currentEventTime << std::endl;
if ( 0.0==currentEventTime ) {
particleClassification=INTIME;
}
else if (fabs(eta) <= m_absEtaMax_outOfTime) {
else if (std::abs(eta) <= m_absEtaMax_outOfTime) {
particleClassification=OUTOFTIME;
//cout << "out of time MB, -2BC, +2BC and |eta<3|" << endl;
}
else {
particleClassification=RESTOFMB;
......
......@@ -149,7 +149,6 @@ const std::map<HepMC::ConstGenParticlePtr, Trk::PRD_TruthTrajectory >& Trk::PRD_
auto prdTruthTrajIter = m_gpPrdTruthTrajectories.begin();
auto prdTruthTrajIterE = m_gpPrdTruthTrajectories.end();
for ( ; prdTruthTrajIter != prdTruthTrajIterE; ++prdTruthTrajIter ){
//std::cout << "sorting, barcode: " << prdTruthTrajIter->first->barcode() << std::endl;
if ( m_prdTruthTrajectoryManipulators.size() ){
ToolHandleArray<IPRD_TruthTrajectoryManipulator>::const_iterator prdTTMIter = m_prdTruthTrajectoryManipulators.begin();
ToolHandleArray<IPRD_TruthTrajectoryManipulator>::const_iterator prdTTMIterE = m_prdTruthTrajectoryManipulators.end();
......
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