Skip to content
Snippets Groups Projects
Commit fbfa9a41 authored by Roland Jansky's avatar Roland Jansky
Browse files

starting to add xAOD truth

parent 22185c7b
No related branches found
No related tags found
No related merge requests found
Showing
with 1638 additions and 0 deletions
# $Id: CMakeLists.txt 761796 2016-07-14 08:06:02Z krasznaa $
################################################################################
# Package: xAODTruth
################################################################################
# Declare the package name:
atlas_subdir( xAODTruth )
# Declare the package's dependencies:
atlas_depends_on_subdirs(
PUBLIC
Control/AthContainers
Control/AthLinks
Event/xAOD/xAODBase
Event/xAOD/xAODCore
PRIVATE
Generators/TruthUtils )
# Component(s) in the package:
atlas_add_library( xAODTruth
xAODTruth/*.h xAODTruth/versions/*.h Root/*.h Root/*.cxx
PUBLIC_HEADERS xAODTruth
LINK_LIBRARIES AthContainers AthLinks xAODBase xAODCore
PRIVATE_LINK_LIBRARIES TruthUtils )
atlas_add_dictionary( xAODTruthDict
xAODTruth/xAODTruthDict.h
xAODTruth/selection.xml
LINK_LIBRARIES xAODTruth
EXTRA_FILES Root/dict/*.cxx )
atlas_generate_cliddb( xAODTruth )
# Test(s) in the package:
atlas_add_test( ut_xaodtruth_particle_test
SOURCES test/ut_xaodtruth_particle_test.cxx
LINK_LIBRARIES xAODTruth )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TruthAccessors_v1.cxx 623284 2014-10-22 14:07:48Z krasznaa $
// System include(s):
#include <iostream>
// Local include(s):
#include "TruthAccessors_v1.h"
/// Helper macro for managing cluster moment Accessor objects
#define DEFINE_ACCESSOR( PARENT, TYPE, NAME ) \
case PARENT::NAME: \
{ \
static SG::AuxElement::Accessor< TYPE > a( #NAME ); \
return &a; \
} \
break
namespace xAOD {
SG::AuxElement::Accessor< float >*
polarizationAccessorV1( TruthParticle_v1::PolParam type ) {
switch( type ) {
DEFINE_ACCESSOR( TruthParticle_v1, float, polarizationTheta );
DEFINE_ACCESSOR( TruthParticle_v1, float, polarizationPhi );
default:
std::cerr << "xAOD::polarizationAccessorV1 ERROR Unknown PolParam ("
<< type << ") requested" << std::endl;
return 0;
}
return 0;
}
SG::AuxElement::Accessor< int >*
pdfInfoAccessorV1Int( TruthEvent_v1::PdfParam type ) {
switch( type ) {
DEFINE_ACCESSOR( TruthEvent_v1, int, PDGID1 );
DEFINE_ACCESSOR( TruthEvent_v1, int, PDGID2 );
DEFINE_ACCESSOR( TruthEvent_v1, int, PDFID1 );
DEFINE_ACCESSOR( TruthEvent_v1, int, PDFID2 );
default:
std::cerr << "xAOD::pdfInfoAccessorV1Int ERROR Unknown PdfParam ("
<< type << ") requested" << std::endl;
return 0;
}
return 0;
}
SG::AuxElement::Accessor< float >*
pdfInfoAccessorV1Float( TruthEvent_v1::PdfParam type ) {
switch( type ) {
DEFINE_ACCESSOR( TruthEvent_v1, float, X1 );
DEFINE_ACCESSOR( TruthEvent_v1, float, X2 );
DEFINE_ACCESSOR( TruthEvent_v1, float, Q );
DEFINE_ACCESSOR( TruthEvent_v1, float, XF1 );
DEFINE_ACCESSOR( TruthEvent_v1, float, XF2 );
default:
std::cerr << "xAOD::pdfInfoAccessorV1Float ERROR Unknown ParamDef ("
<< type << ") requested" << std::endl;
return 0;
}
return 0;
}
SG::AuxElement::Accessor< int >*
heavyIonAccessorV1Int( TruthEvent_v1::HIParam type ) {
switch( type ) {
DEFINE_ACCESSOR( TruthEvent_v1, int, NCOLLHARD );
DEFINE_ACCESSOR( TruthEvent_v1, int, NPARTPROJ );
DEFINE_ACCESSOR( TruthEvent_v1, int, NPARTTARG );
DEFINE_ACCESSOR( TruthEvent_v1, int, NCOLL );
DEFINE_ACCESSOR( TruthEvent_v1, int, SPECTATORNEUTRONS );
DEFINE_ACCESSOR( TruthEvent_v1, int, SPECTATORPROTONS );
DEFINE_ACCESSOR( TruthEvent_v1, int, NNWOUNDEDCOLLISIONS );
DEFINE_ACCESSOR( TruthEvent_v1, int, NWOUNDEDNCOLLISIONS );
DEFINE_ACCESSOR( TruthEvent_v1, int, NWOUNDEDNWOUNDEDCOLLISIONS );
default:
std::cerr << "xAOD::heavyIonAccessorV1Int ERROR Unknown HIParam ("
<< type << ") requested" << std::endl;
return 0;
}
return 0;
}
SG::AuxElement::Accessor< float >*
heavyIonAccessorV1Float( TruthEvent_v1::HIParam type ) {
switch( type ) {
DEFINE_ACCESSOR( TruthEvent_v1, float, IMPACTPARAMETER );
DEFINE_ACCESSOR( TruthEvent_v1, float, EVENTPLANEANGLE );
DEFINE_ACCESSOR( TruthEvent_v1, float, ECCENTRICITY );
DEFINE_ACCESSOR( TruthEvent_v1, float, SIGMAINELNN );
DEFINE_ACCESSOR( TruthEvent_v1, float, CENTRALITY );
default:
std::cerr << "xAOD::heavyIonAccessorV1Float ERROR Unknown HIParam ("
<< type << ") requested" << std::endl;
return 0;
}
return 0;
}
} // namespace xAOD
// -*- C++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TruthAccessors_v1.h 623284 2014-10-22 14:07:48Z krasznaa $
#ifndef XAODTRUTH_TRUTHACCESSORS_V1_H
#define XAODTRUTH_TRUTHACCESSORS_V1_H
// EDM include(s):
#include "AthContainers/AuxElement.h"
// Local include(s):
#include "xAODTruth/TruthEvent.h"
#include "xAODTruth/TruthParticle.h"
namespace xAOD {
/// This function holds on to Accessor objects that can be used by each
/// TruthParticle_v1 object at runtime to get/set parameter values on
/// themselves.
SG::AuxElement::Accessor< float >*
polarizationAccessorV1( TruthParticle_v1::PolParam type );
/// Helper function for getting accessors for integer type PDF information
SG::AuxElement::Accessor< int >*
pdfInfoAccessorV1Int( TruthEvent_v1::PdfParam type );
/// Helper function for getting accessors for floating point PDF information
SG::AuxElement::Accessor< float >*
pdfInfoAccessorV1Float( TruthEvent_v1::PdfParam type );
/// Helper function for getting accessors for integer type HI information
SG::AuxElement::Accessor< int >*
heavyIonAccessorV1Int( TruthEvent_v1::HIParam type );
/// Helper function for getting accessors for floating point HI information
SG::AuxElement::Accessor< float >*
heavyIonAccessorV1Float( TruthEvent_v1::HIParam type );
} // namespace xAOD
#endif // XAODTRUTH_TRUTHACCESSORS_V1_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TruthEvent.cxx 761798 2016-07-14 08:15:01Z krasznaa $
// System include(s):
#include <cmath>
// EDM include(s):
#include "xAODCore/AuxStoreAccessorMacros.h"
// Local include(s):
#include "xAODTruth/TruthEvent.h"
#include "TruthAccessors.h"
namespace xAOD {
TruthEvent::TruthEvent()
: SG::AuxElement() {
}
/////////////////////////////////////////////////////////////////////////////
// Implementation of the truth particle accessor functions
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthEvent,
TruthEvent::TruthParticleLinks_t,
truthParticleLinks,
setTruthParticleLinks )
/// Accessor for the truth particles
static SG::AuxElement::Accessor< TruthEvent::TruthParticleLinks_t >
truthParticleLinksAcc( "truthParticleLinks" );
size_t TruthEvent::nTruthParticles() const {
// If the variable is not available, we don't have any truth particles
// associated...
if( ! truthParticleLinksAcc.isAvailable( *this ) ) {
return 0;
}
// Return the size of the vector:
return truthParticleLinksAcc( *this ).size();
}
const TruthEvent::TruthParticleLink_t&
TruthEvent::truthParticleLink( size_t index ) const {
return truthParticleLinksAcc( *this ).at( index );
}
const TruthParticle* TruthEvent::truthParticle( size_t index ) const {
// Check if the variable is available:
if( ! truthParticleLinksAcc.isAvailable( *this ) ) {
return 0;
}
// Check if the link is valid:
const TruthParticleLinks_t& links = truthParticleLinksAcc( *this );
if( ! links[ index ].isValid() ) {
return 0;
}
// Return the de-referenced link:
return *( links[ index ] );
}
void
TruthEvent::addTruthParticleLink( const TruthParticleLink_t& link ) {
truthParticleLinksAcc( *this ).push_back( link );
return;
}
void TruthEvent::clearTruthParticleLinks() {
truthParticleLinksAcc( *this ).clear();
return;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Implementation of the truth vertex accessor functions
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthEvent,
TruthEvent::TruthVertexLinks_t,
truthVertexLinks,
setTruthVertexLinks )
/// Accessor for the truth vertices
static SG::AuxElement::Accessor< TruthEvent::TruthVertexLinks_t >
truthVertexLinksAcc( "truthVertexLinks" );
size_t TruthEvent::nTruthVertices() const {
// If the variable is not available, we don't have any truth particles
// associated...
if( ! truthVertexLinksAcc.isAvailable( *this ) ) {
return 0;
}
// Return the size of the vector:
return truthVertexLinksAcc( *this ).size();
}
const TruthEvent::TruthVertexLink_t&
TruthEvent::truthVertexLink( size_t index ) const {
return truthVertexLinksAcc( *this ).at(index);
}
const TruthVertex* TruthEvent::truthVertex( size_t index ) const {
// Check if the variable is available:
if( ! truthVertexLinksAcc.isAvailable( *this ) ) {
return 0;
}
// Check if the link is valid:
const TruthVertexLinks_t& links = truthVertexLinksAcc( *this );
if( ! links[ index ].isValid() ) {
return 0;
}
// Return the de-referenced link:
return *( links[ index ] );
}
void TruthEvent::addTruthVertexLink( const TruthVertexLink_t& link ) {
truthVertexLinksAcc( *this ).push_back( link );
return;
}
void TruthEvent::clearTruthVertexLinks() {
truthVertexLinksAcc( *this ).clear();
return;
}
/////////////////////////////////////////////////////////////////////////////
// Simple, always-present event properties
/// @todo Need upgrade to allow string-valued map-like access... or access a
/// corresponding vector of names
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthEvent, std::vector< float >,
weights, setWeights )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TruthEvent, float, crossSection,
setCrossSection )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TruthEvent, float,
crossSectionError,
setCrossSectionError )
void TruthEvent::setCrossSection( float value, float error ) {
setCrossSection( value );
setCrossSectionError( error );
return;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Optional PDF info accessors
bool TruthEvent::pdfInfoParameter( int& value,
PdfParam information ) const {
// Look for the accessor object:
auto* acc = pdfInfoAccessorV1Int( information );
if( ! acc ) return false;
// Get the value:
value = ( *acc )( *this );
return true;
}
bool TruthEvent::pdfInfoParameter( float& value,
PdfParam information ) const {
// Look for the accessor object:
auto* acc = pdfInfoAccessorV1Float( information );
if( ! acc ) return false;
// Get the value:
value = ( *acc )( *this );
return true;
}
bool TruthEvent::setPdfInfoParameter( int value,
PdfParam information ) {
// Look for the accessor object:
auto* acc = pdfInfoAccessorV1Int( information );
if( ! acc ) return false;
// Set the value:
( *acc )( *this ) = value;
return true;
}
bool TruthEvent::setPdfInfoParameter( float value,
PdfParam information ) {
// Look for the accessor object:
auto* acc = pdfInfoAccessorV1Float( information );
if( ! acc ) return false;
// Set the value:
( *acc )( *this ) = value;
return true;
}
TruthEvent::PdfInfo::PdfInfo()
: pdgId1( 0 ), pdgId2( 0 ), pdfId1( -1 ), pdfId2( -1 ),
x1( NAN ), x2( NAN ), Q( NAN ), xf1( NAN ), xf2( NAN ) {
}
bool TruthEvent::PdfInfo::valid() const {
return ( ( pdgId1 != 0 ) && ( pdgId2 != 0 ) &&
( pdfId1 >= 0 ) && ( pdfId2 >= 0 ) &&
( ! std::isnan( x1 ) ) && ( ! std::isnan( x2 ) ) &&
( ! std::isnan( Q ) ) &&
( ! std::isnan( xf1 ) ) && ( ! std::isnan( xf2 ) ) );
}
TruthEvent::PdfInfo TruthEvent::pdfInfo() const {
// The result object:
PdfInfo rtn;
// Retrieve all of its elements:
pdfInfoParameter( rtn.pdgId1, PDGID1 );
pdfInfoParameter( rtn.pdgId2, PDGID2 );
pdfInfoParameter( rtn.pdfId1, PDFID1 );
pdfInfoParameter( rtn.pdfId2, PDFID2 );
pdfInfoParameter( rtn.x1, X1 );
pdfInfoParameter( rtn.x2, X2 );
pdfInfoParameter( rtn.Q, Q );
pdfInfoParameter( rtn.xf1, XF1 );
pdfInfoParameter( rtn.xf2, XF2 );
return rtn;
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Implementation for the links to truth particles/vertices
// Accessor for the signal vertex
static SG::AuxElement::Accessor< TruthEvent::TruthVertexLink_t >
signalProcessVertexLinkAcc( "signalProcessVertexLink" );
const TruthVertex* TruthEvent::signalProcessVertex() const {
// Check if the link variable is available:
if( ! signalProcessVertexLinkAcc.isAvailable( *this ) ) {
return 0;
}
// Get the link:
const TruthVertexLink_t& vertLink = signalProcessVertexLinkAcc( *this );
// Check if it's valid:
if( ! vertLink.isValid() ) {
return 0;
}
// Return the de-referenced link:
return *vertLink;
}
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthEvent,
TruthEvent::TruthVertexLink_t,
signalProcessVertexLink,
setSignalProcessVertexLink )
// Accessors for the beam particles
static SG::AuxElement::Accessor< TruthEvent::TruthParticleLink_t >
primaryParticleLinkLinkAcc( "primaryParticleLink" );
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthEvent,
TruthEvent::TruthParticleLink_t,
primaryParticleLink,
setPrimaryParticleLink )
/////////////////////////////////////////////////////////////////////////////
Type::ObjectType TruthEvent::type() const {
return Type::TruthEvent;
}
void TruthEvent::toPersistent() {
if( primaryParticleLinkLinkAcc.isAvailableWritable( *this ) ) {
primaryParticleLinkLinkAcc( *this ).toPersistent();
}
if( signalProcessVertexLinkAcc.isAvailableWritable( *this ) ) {
signalProcessVertexLinkAcc( *this ).toPersistent();
}
// Prepare the truth particle links for writing:
if( truthParticleLinksAcc.isAvailableWritable( *this ) ) {
TruthParticleLinks_t::iterator itr =
truthParticleLinksAcc( *this ).begin();
TruthParticleLinks_t::iterator end =
truthParticleLinksAcc( *this ).end();
for( ; itr != end; ++itr ) {
itr->toPersistent();
}
}
// Prepare the truth vertex links for writing:
if( truthVertexLinksAcc.isAvailableWritable( *this ) ) {
TruthVertexLinks_t::iterator itr =
truthVertexLinksAcc( *this ).begin();
TruthVertexLinks_t::iterator end =
truthVertexLinksAcc( *this ).end();
for( ; itr != end; ++itr ) {
itr->toPersistent();
}
}
return;
}
} // namespace xAOD
// Local include(s):
#include "xAODTruth/TruthEventAuxContainer.h"
namespace xAOD {
TruthEventAuxContainer::TruthEventAuxContainer()
: AuxContainerBase() {
AUX_VARIABLE( signalProcessVertexLink );
AUX_VARIABLE( weights );
AUX_VARIABLE( crossSection );
AUX_VARIABLE( crossSectionError );
AUX_VARIABLE( truthVertexLinks );
AUX_VARIABLE( truthParticleLinks );
}
} // namespace xAOD
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
// Local include(s):
#include "xAODTruth/versions/TruthMetaDataAuxContainer_v1.h"
namespace xAOD {
TruthMetaDataAuxContainer_v1::TruthMetaDataAuxContainer_v1()
: AuxContainerBase() {
AUX_VARIABLE( weightNames );
AUX_VARIABLE( mcChannelNumber );
}
} // namespace xAOD
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
// xAOD include(s):
#include "xAODCore/AuxStoreAccessorMacros.h"
// Local include(s):
#include "xAODTruth/versions/TruthMetaData_v1.h"
namespace xAOD {
TruthMetaData_v1::TruthMetaData_v1(): SG::AuxElement() {}
//Arguments for MACRO are as follows: AUXSTORE_OBJECT/PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
AUXSTORE_OBJECT_SETTER_AND_GETTER(TruthMetaData_v1, std::vector < std::string >, weightNames, setWeightNames )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(TruthMetaData_v1, uint32_t, mcChannelNumber, setMcChannelNumber )
}
//
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TruthParticleAuxContainer_v1.cxx 622193 2014-10-16 16:08:34Z krasznaa $
// Local include(s):
#include "xAODTruth/versions/TruthParticleAuxContainer_v1.h"
namespace xAOD {
TruthParticleAuxContainer_v1::TruthParticleAuxContainer_v1()
: AuxContainerBase() {
AUX_VARIABLE( pdgId );
AUX_VARIABLE( barcode );
AUX_VARIABLE( status );
AUX_VARIABLE( prodVtxLink );
AUX_VARIABLE( decayVtxLink );
AUX_VARIABLE( px );
AUX_VARIABLE( py );
AUX_VARIABLE( pz );
AUX_VARIABLE( e );
AUX_VARIABLE( m );
}
} // namespace xAOD
// -*- C++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TruthParticle_v1.cxx 690336 2015-08-20 10:54:57Z abuckley $
// System include(s):
#include <cmath>
#include <iostream>
#include <stdexcept>
// Utility include(s):
#include "TruthUtils/PIDHelpers.h"
// xAOD include(s):
#include "xAODCore/AuxStoreAccessorMacros.h"
// Local include(s):
#include "xAODTruth/versions/TruthParticle_v1.h"
#include "xAODTruth/TruthVertexContainer.h"
#include "TruthAccessors_v1.h"
namespace xAOD {
TruthParticle_v1::TruthParticle_v1()
: IParticle(), m_p4(), m_p4Cached( false ) {
}
/////////////////////////////////////////////////////////////////////////////
//
// Implementation for functions identifying the particle in the MC record
//
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TruthParticle_v1, int, pdgId,
setPdgId )
int TruthParticle_v1::absPdgId() const {
return std::abs( pdgId() );
}
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TruthParticle_v1, int, barcode,
setBarcode )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TruthParticle_v1, int, status,
setStatus )
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Implementation of the links to the vertices
//
/// Accessor for the production vertex
static SG::AuxElement::Accessor< ElementLink< TruthVertexContainer > >
prodVtxLinkAcc( "prodVtxLink" );
/// Accessor for the decay vertex
static SG::AuxElement::Accessor< ElementLink< TruthVertexContainer > >
decayVtxLinkAcc( "decayVtxLink" );
bool TruthParticle_v1::hasProdVtx() const {
return ( prodVtxLinkAcc.isAvailable( *this ) &&
prodVtxLinkAcc( *this ).isValid() );
}
const TruthVertex* TruthParticle_v1::prodVtx() const {
return hasProdVtx() ? *prodVtxLink() : 0;
}
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthParticle_v1,
ElementLink< TruthVertexContainer >,
prodVtxLink, setProdVtxLink )
bool TruthParticle_v1::hasDecayVtx() const {
return ( decayVtxLinkAcc.isAvailable( *this ) &&
decayVtxLinkAcc( *this ).isValid() );
}
const TruthVertex* TruthParticle_v1::decayVtx() const {
return hasDecayVtx() ? *decayVtxLink() : 0;
}
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthParticle_v1,
ElementLink< TruthVertexContainer >,
decayVtxLink, setDecayVtxLink )
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Direct access to parents and children
//
size_t TruthParticle_v1::nParents() const {
return hasProdVtx() ? prodVtx()->nIncomingParticles() : 0;
}
const TruthParticle_v1* TruthParticle_v1::parent( size_t i ) const {
return hasProdVtx() ? prodVtx()->incomingParticle( i ) : 0;
}
size_t TruthParticle_v1::nChildren() const {
return hasDecayVtx() ? decayVtx()->nOutgoingParticles() : 0;
}
const TruthParticle_v1* TruthParticle_v1::child( size_t i ) const {
return hasDecayVtx() ? decayVtx()->outgoingParticle( i ) : 0;
}
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Implementation of the IParticle interface
//
double TruthParticle_v1::pt() const {
// Do the calculation by hand:
const double localPx = static_cast< double >( px() );
const double localPy = static_cast< double >( py() );
return std::sqrt( localPx * localPx + localPy * localPy );
}
double TruthParticle_v1::eta() const {
// Calculate the pseudo-rapidity using TLorentzVector.
// Could do something more lightweight later on.
return p4().Eta();
}
double TruthParticle_v1::phi() const {
// Calculate the azimuth angle using TLorentzVector.
// Could do something more lightweight later on.
return p4().Phi();
}
AUXSTORE_PRIMITIVE_GETTER_WITH_CAST( TruthParticle_v1, float, double, m )
AUXSTORE_PRIMITIVE_GETTER_WITH_CAST( TruthParticle_v1, float, double, e )
double TruthParticle_v1::rapidity() const {
return p4().Rapidity();
}
const TruthParticle_v1::FourMom_t& TruthParticle_v1::p4() const {
// Cache the 4-momentum if it's not already:
if( ! m_p4Cached ) {
m_p4.SetPxPyPzE( px(), py(), pz(), e() );
m_p4Cached = true;
}
return m_p4;
}
Type::ObjectType TruthParticle_v1::type() const {
return Type::TruthParticle;
}
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Implementation of the truth particle specific 4-momentum functions
//
double TruthParticle_v1::abseta() const {
return std::abs( eta() );
}
double TruthParticle_v1::absrapidity() const {
return std::abs( rapidity() );
}
AUXSTORE_PRIMITIVE_GETTER( TruthParticle_v1, float, px )
void TruthParticle_v1::setPx( float value ) {
static Accessor< float > acc( "px" );
m_p4Cached = false;
acc( *this ) = value;
return;
}
AUXSTORE_PRIMITIVE_GETTER( TruthParticle_v1, float, py )
void TruthParticle_v1::setPy( float value ) {
static Accessor< float > acc( "py" );
m_p4Cached = false;
acc( *this ) = value;
return;
}
AUXSTORE_PRIMITIVE_GETTER( TruthParticle_v1, float, pz )
void TruthParticle_v1::setPz( float value ) {
static Accessor< float > acc( "pz" );
m_p4Cached = false;
acc( *this ) = value;
return;
}
void TruthParticle_v1::setE( float value ) {
static Accessor< float > acc( "e" );
m_p4Cached = false;
acc( *this ) = value;
return;
}
void TruthParticle_v1::setM( float value ) {
static Accessor< float > acc( "m" );
// note: this does not invalidate the cache
acc( *this ) = value;
return;
}
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Implementation of the particle species decoder functions
//
/// Helper macro to implement the functions that rely in functions from MC::PID
#define MC_PID_HELPER( TYPE, FNAME ) \
TYPE TruthParticle_v1::FNAME() const { \
return MC::PID::FNAME( pdgId() ); \
}
MC_PID_HELPER( double, charge )
MC_PID_HELPER( int, threeCharge )
MC_PID_HELPER( bool, isCharged )
MC_PID_HELPER( bool, isNeutral )
MC_PID_HELPER( bool, isPhoton )
MC_PID_HELPER( bool, isLepton )
MC_PID_HELPER( bool, isChLepton )
MC_PID_HELPER( bool, isElectron )
MC_PID_HELPER( bool, isMuon )
MC_PID_HELPER( bool, isTau )
MC_PID_HELPER( bool, isNeutrino )
MC_PID_HELPER( bool, isHadron )
MC_PID_HELPER( bool, isMeson )
MC_PID_HELPER( bool, isBaryon )
MC_PID_HELPER( bool, hasStrange )
MC_PID_HELPER( bool, hasCharm )
MC_PID_HELPER( bool, hasBottom )
MC_PID_HELPER( bool, isLightMeson )
MC_PID_HELPER( bool, isLightBaryon )
MC_PID_HELPER( bool, isLightHadron )
MC_PID_HELPER( bool, isHeavyMeson )
MC_PID_HELPER( bool, isHeavyBaryon )
MC_PID_HELPER( bool, isHeavyHadron )
MC_PID_HELPER( bool, isBottomMeson )
MC_PID_HELPER( bool, isBottomBaryon )
MC_PID_HELPER( bool, isBottomHadron )
MC_PID_HELPER( bool, isCharmMeson )
MC_PID_HELPER( bool, isCharmBaryon )
MC_PID_HELPER( bool, isCharmHadron )
MC_PID_HELPER( bool, isStrangeMeson )
MC_PID_HELPER( bool, isStrangeBaryon )
MC_PID_HELPER( bool, isStrangeHadron )
MC_PID_HELPER( bool, isQuark )
MC_PID_HELPER( bool, isParton )
MC_PID_HELPER( bool, isTop )
MC_PID_HELPER( bool, isW )
MC_PID_HELPER( bool, isZ )
MC_PID_HELPER( bool, isHiggs )
MC_PID_HELPER( bool, isResonance )
MC_PID_HELPER( bool, isGenSpecific )
// Forget about this macro:
#undef MC_PID_HELPER
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Implementation of the optional polarization accessors
//
bool TruthParticle_v1::polarizationParameter( float& value,
PolParam param ) const {
// Get the accessor object:
Accessor< float >* acc = polarizationAccessorV1( param );
if( ! acc ) {
// The user asked for a non-existent parameter type. o.O
std::cerr << "xAOD::TruthParticle_v1::polarizationParameter ERROR "
<< "Request for an unknown (" << param << ") polarization "
<< "parameter type" << std::endl;
return false;
}
// Check if the variable is available:
if( ! acc->isAvailable( *this ) ) {
// No, it is not.
return false;
}
// Read the value:
value = ( *acc )( *this );
return true;
}
bool TruthParticle_v1::setPolarizationParameter( float value,
PolParam param ) {
// Get the accessor object:
Accessor< float >* acc = polarizationAccessorV1( param );
if( ! acc ) {
// The user asked for a non-existent parameter type. o.O
std::cerr << "xAOD::TruthParticle_v1::setPolarizationParameter ERROR "
<< "Request for an unknown (" << param << ") polarization "
<< "parameter type" << std::endl;
return false;
}
// Set the value:
( *acc )( *this ) = value;
return true;
}
float TruthParticle_v1::polarizationPatameter( PolParam param ) const {
// Get the accessor object:
Accessor< float >* acc = polarizationAccessorV1( param );
if( ! acc ) {
// Throw an exception:
throw std::runtime_error( "Unrecognized polarization parameter "
"requested" );
}
// Read the value:
return ( *acc )( *this );
}
TruthParticle_v1::Polarization TruthParticle_v1::polarization() const {
// Construct the object:
Polarization rtn;
polarizationParameter( rtn.phi, polarizationPhi );
polarizationParameter( rtn.theta, polarizationTheta );
return rtn;
}
//
/////////////////////////////////////////////////////////////////////////////
void TruthParticle_v1::toPersistent() {
if( prodVtxLinkAcc.isAvailableWritable( *this ) ) {
prodVtxLinkAcc( *this ).toPersistent();
}
if( decayVtxLinkAcc.isAvailableWritable( *this ) ) {
decayVtxLinkAcc( *this ).toPersistent();
}
return;
}
} // namespace xAOD
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TruthVertexAuxContainer_v1.cxx 624338 2014-10-27 15:08:55Z krasznaa $
// Local include(s):
#include "xAODTruth/versions/TruthVertexAuxContainer_v1.h"
namespace xAOD {
TruthVertexAuxContainer_v1::TruthVertexAuxContainer_v1()
: AuxContainerBase() {
AUX_VARIABLE( id );
AUX_VARIABLE( barcode );
AUX_VARIABLE( incomingParticleLinks );
AUX_VARIABLE( outgoingParticleLinks );
AUX_VARIABLE( x );
AUX_VARIABLE( y );
AUX_VARIABLE( z );
AUX_VARIABLE( t );
}
} // namespace xAOD
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: TruthVertex_v1.cxx 624338 2014-10-27 15:08:55Z krasznaa $
// System include(s):
#include <cmath>
// xAOD include(s):
#include "xAODCore/AuxStoreAccessorMacros.h"
// Local include(s):
#include "xAODTruth/versions/TruthVertex_v1.h"
#include "xAODTruth/TruthParticleContainer.h"
namespace xAOD {
TruthVertex_v1::TruthVertex_v1()
: SG::AuxElement(), m_v4(), m_v4Cached( false ) {
}
/////////////////////////////////////////////////////////////////////////////
//
// Implementation for the "MC specific" functions
//
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TruthVertex_v1, int, id, setId )
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER( TruthVertex_v1, int, barcode,
setBarcode )
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Implementation for the links to the truth particles
//
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthVertex_v1, TruthVertex_v1::TPLinks_t,
incomingParticleLinks,
setIncomingParticleLinks )
/// Accessor for the incoming particles
static SG::AuxElement::Accessor< TruthVertex_v1::TPLinks_t >
incomingParticleLinksAcc( "incomingParticleLinks" );
size_t TruthVertex_v1::nIncomingParticles() const {
// Check if the variable is available:
if( ! incomingParticleLinksAcc.isAvailable( *this ) ) {
// If not, just tell the user that there aren't any incoming particles:
return 0;
}
// Return the size of the vector:
return incomingParticleLinksAcc( *this ).size();
}
const TruthParticle* TruthVertex_v1::incomingParticle( size_t index ) const {
// Check that the variable exists, and that it has enough elements in it:
if( ( ! incomingParticleLinksAcc.isAvailable( *this ) ) ||
( incomingParticleLinksAcc( *this ).size() <= index ) ) {
return 0;
}
// Retrieve the link object and check its validity:
const TPLink_t& ipl = incomingParticleLinksAcc( *this )[ index ];
if( ! ipl.isValid() ) {
return 0;
}
// Finally, de-reference the link:
return *ipl;
}
void TruthVertex_v1::addIncomingParticleLink( const TPLink_t& link ) {
incomingParticleLinksAcc( *this ).push_back( link );
return;
}
void TruthVertex_v1::clearIncomingParticleLinks() {
incomingParticleLinksAcc( *this ).clear();
return;
}
AUXSTORE_OBJECT_SETTER_AND_GETTER( TruthVertex_v1, TruthVertex_v1::TPLinks_t,
outgoingParticleLinks,
setOutgoingParticleLinks )
/// Accessor for the outgoing particles
static SG::AuxElement::Accessor< TruthVertex_v1::TPLinks_t >
outgoingParticleLinksAcc( "outgoingParticleLinks" );
size_t TruthVertex_v1::nOutgoingParticles() const {
// Check if the variable is available:
if( ! outgoingParticleLinksAcc.isAvailable( *this ) ) {
// If not, just tell the user that there aren't any outgoing particles:
return 0;
}
// Return the size of the vector:
return outgoingParticleLinksAcc( *this ).size();
}
const TruthParticle* TruthVertex_v1::outgoingParticle( size_t index ) const {
// Check that the variable exists, and that it has enough elements in it:
if( ( ! outgoingParticleLinksAcc.isAvailable( *this ) ) ||
( outgoingParticleLinksAcc( *this ).size() <= index ) ) {
return 0;
}
// Retrieve the link object and check its validity:
const TPLink_t& opl = outgoingParticleLinksAcc( *this )[ index ];
if( ! opl.isValid() ) {
return 0;
}
// Finally, de-reference the link:
return *opl;
}
void TruthVertex_v1::addOutgoingParticleLink( const TPLink_t& link ) {
outgoingParticleLinksAcc( *this ).push_back( link );
return;
}
void TruthVertex_v1::clearOutgoingParticleLinks() {
outgoingParticleLinksAcc( *this ).clear();
return;
}
//
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//
// Implementation of the functions specifying the vertex's position
//
AUXSTORE_PRIMITIVE_GETTER( TruthVertex_v1, float, x )
void TruthVertex_v1::setX( float x ) {
static SG::AuxElement::Accessor< float > acc( "x" );
m_v4Cached = false;
acc( *this ) = x;
return;
}
AUXSTORE_PRIMITIVE_GETTER( TruthVertex_v1, float, y )
void TruthVertex_v1::setY( float y ) {
static SG::AuxElement::Accessor< float > acc( "y" );
m_v4Cached = false;
acc( *this ) = y;
return;
}
AUXSTORE_PRIMITIVE_GETTER( TruthVertex_v1, float, z )
void TruthVertex_v1::setZ( float z ) {
static SG::AuxElement::Accessor< float > acc( "z" );
m_v4Cached = false;
acc( *this ) = z;
return;
}
float TruthVertex_v1::perp() const {
// Do the calculation by hand. Could make it faster than this even in a
// future iteration...
return std::sqrt( x() * x() + y() * y() );
}
float TruthVertex_v1::eta() const {
// This is not necessarily what Andy was thinking about...
return v4().Eta();
}
float TruthVertex_v1::phi() const {
// This is not necessarily what Andy was thinking about...
return v4().Phi();
}
AUXSTORE_PRIMITIVE_GETTER( TruthVertex_v1, float, t )
void TruthVertex_v1::setT( float t ) {
static SG::AuxElement::Accessor< float > acc( "t" );
m_v4Cached = false;
acc( *this ) = t;
return;
}
const TruthVertex_v1::FourVec_t& TruthVertex_v1::v4() const {
// Cache the 4-vector if it's not already:
if( ! m_v4Cached ) {
m_v4.SetXYZT( x(), y(), z(), t() );
m_v4Cached = true;
}
// Return the cached object:
return m_v4;
}
//
/////////////////////////////////////////////////////////////////////////////
Type::ObjectType TruthVertex_v1::type() const {
return Type::TruthVertex;
}
void TruthVertex_v1::toPersistent() {
// Prepare the incoming particle links for persistification:
if( incomingParticleLinksAcc.isAvailableWritable( *this ) ) {
TPLinks_t::iterator itr = incomingParticleLinksAcc( *this ).begin();
TPLinks_t::iterator end = incomingParticleLinksAcc( *this ).end();
for( ; itr != end; ++itr ) {
itr->toPersistent();
}
}
// Prepare the outgoing particle links for persistification:
if( outgoingParticleLinksAcc.isAvailableWritable( *this ) ) {
TPLinks_t::iterator itr = outgoingParticleLinksAcc( *this ).begin();
TPLinks_t::iterator end = outgoingParticleLinksAcc( *this ).end();
for( ; itr != end; ++itr ) {
itr->toPersistent();
}
}
return;
}
} // namespace xAOD
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: ContainerProxies.cxx 670637 2015-05-28 15:49:43Z tbisanz $
// EDM include(s):
#include "xAODCore/AddDVProxy.h"
// Local include(s):
#include "xAODTruth/versions/TruthParticleContainer_v1.h"
#include "xAODTruth/versions/TruthVertexContainer_v1.h"
#include "xAODTruth/versions/TruthEventContainer_v1.h"
#include "xAODTruth/versions/TruthPileupEventContainer_v1.h"
#include "xAODTruth/versions/TruthMetaDataContainer_v1.h"
// Set up the collection proxies:
ADD_NS_DV_PROXY( xAOD, TruthMetaDataContainer_v1 );
ADD_NS_DV_PROXY( xAOD, TruthParticleContainer_v1 );
ADD_NS_DV_PROXY( xAOD, TruthVertexContainer_v1 );
ADD_NS_DV_PROXY( xAOD, TruthEventContainer_v1 );
ADD_NS_DV_PROXY( xAOD, TruthPileupEventContainer_v1 );
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
//simple includes to force the CLASS_DEF to be encountered during compile
#include "xAODTruth/TruthVertexContainer.h"
#include "xAODTruth/TruthVertexAuxContainer.h"
#include "xAODTruth/TruthEventContainer.h"
#include "xAODTruth/TruthEventAuxContainer.h"
#include "xAODTruth/TruthParticleContainer.h"
#include "xAODTruth/TruthParticleAuxContainer.h"
#include "xAODTruth/TruthPileupEventContainer.h"
#include "xAODTruth/TruthPileupEventAuxContainer.h"
#include "xAODTruth/TruthEventBaseContainer.h"
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: xAODTruthHelpers.cxx 668406 2015-05-19 15:32:15Z krasznaa $
// Core EDM include(s):
#include "AthLinks/ElementLink.h"
#include "AthContainers/AuxElement.h"
// xAOD include(s):
#include "xAODBase/IParticle.h"
// Local include(s):
#include "xAODTruth/xAODTruthHelpers.h"
#include "xAODTruth/TruthParticle.h"
#include "xAODTruth/TruthParticleContainer.h"
namespace xAOD {
namespace TruthHelpers {
/// @param p The particle that we find the associated truth particle for
/// @returns A pointer to the associated truth particle if available,
/// or a null pointer if not
///
const xAOD::TruthParticle* getTruthParticle( const xAOD::IParticle& p ) {
/// A convenience type declaration
typedef ElementLink< xAOD::TruthParticleContainer > Link_t;
/// A static accessor for the information
static SG::AuxElement::ConstAccessor< Link_t > acc( "truthParticleLink" );
// Check if such a link exists on the object:
if( ! acc.isAvailable( p ) ) {
return 0;
}
// Get the link:
const Link_t& link = acc( p );
// Check if the link is valid:
if( ! link.isValid() ) {
return 0;
}
// Everything has passed, let's return the pointer:
return *link;
}
/// @param p The particle that we want to find the truth type of
/// @returns 0 if the truth type is not available, or the truth type
/// determined by MCTruthClassifier, if it is
///
int getParticleTruthType( const xAOD::IParticle& p ) {
/// A static accessor for the information
static SG::AuxElement::ConstAccessor< int > acc( "truthType" );
// Check if such a variable exists on the object:
if( ! acc.isAvailable( p ) ) {
return 0;
}
// Let's return the value:
return acc( p );
}
/// @param p The particle that we want to find the truth origin of
/// @returns 0 if the truth origin is not available, or the truth origin
/// determined by MCTruthClassifier, if it is
///
int getParticleTruthOrigin( const xAOD::IParticle& p ) {
/// A static accessor for the information
static SG::AuxElement::ConstAccessor< int > acc( "truthOrigin" );
// Check if such a variable exists on the object:
if( ! acc.isAvailable( p ) ) {
return 0;
}
// Let's return the value:
return acc( p );
}
} // namespace TruthHelpers
} // namespace xAOD
xAOD truth TODOs
================
* Tidy TruthEvent attrs, add named weight vector
* Handling run-level info like cross-sections?
* Add a vector of separate TruthPileupEvent objects, which store no event-level info
# this makefile also gets parsed by shell scripts
# therefore it does not support full make syntax and features
# edit with care
# for full documentation check:
# https://twiki.cern.ch/twiki/bin/viewauth/Atlas/RootCore#Package_Makefile
PACKAGE = xAODTruth
PACKAGE_PRELOAD =
PACKAGE_CXXFLAGS =
PACKAGE_OBJFLAGS =
PACKAGE_LDFLAGS =
PACKAGE_BINFLAGS =
PACKAGE_LIBFLAGS =
PACKAGE_DEP = AthContainers AthLinks xAODBase xAODCore TruthUtils
PACKAGE_TRYDEP =
PACKAGE_CLEAN =
PACKAGE_NOGRID =
PACKAGE_PEDANTIC = 1
PACKAGE_NOOPT = 0
PACKAGE_NOCC = 0
PACKAGE_REFLEX = 1
include $(ROOTCOREDIR)/Makefile-common
package xAODTruth
# $Id: requirements 761796 2016-07-14 08:06:02Z krasznaa $
author Andy Buckley <andy.buckley@cern.ch>
author James Catmore <james.catmore@cern.ch>
author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
author Jovan Mitrevski <Jovan.Mitrevski@cern.ch>
public
# Central packages:
use AtlasPolicy AtlasPolicy-*
use AthContainers AthContainers-* Control
use AthLinks AthLinks-* Control
# EDM packages:
use xAODBase xAODBase-* Event/xAOD
use xAODCore xAODCore-* Event/xAOD
use AtlasROOT AtlasROOT-* External
# Specify the ROOT components that are necessary for cmake. Transparent to CMT
apply_pattern cmake_add_command command="find_package(ROOT COMPONENTS Physics)"
library xAODTruth ../Root/*.cxx
apply_pattern installed_library
private
use TruthUtils TruthUtils-* Generators
use AtlasReflex AtlasReflex-* External
# Generate a dictionary for the package:
apply_pattern lcgdict dict=xAODTruth selectionfile=selection.xml \
headerfiles="../xAODTruth/xAODTruthDict.h" \
extralibfiles=../Root/dict/*.cxx
apply_pattern do_genCLIDDB library=xAODTruth
# Specify the unit test(s) of the package:
use TestTools TestTools-* AtlasTest
apply_pattern UnitTest_run unit_test=ut_xaodtruth_particle
All tests succeeded
#!/usr/bin/env python
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#
# $Id: ut_xaodtruth_helpers_test.py 761304 2016-07-12 12:03:36Z krasznaa $
#
# This is a simple unit test for checking the health of the truth helper
# functions in the standalone analysis environment.
#
## C/C++ style main function
def main():
# Initialise the environment:
import ROOT
ROOT.gROOT.Macro( "$ROOTCOREDIR/scripts/load_packages.C" )
# Open an input xAOD file:
import os
FNAME = os.getenv( "ROOTCORE_TEST_FILE", "FileNotSpecifiedInEnvironment" )
f = ROOT.TFile.Open( FNAME, "READ" )
if not f:
print( "Couldn't open \"%s\"" % FNAME )
return 1
print( "Opened: %s" % FNAME )
# Make a transient tree from it:
treeMgr = ROOT.xAOD.TTreeMgr( ROOT.xAOD.TEvent.kAthenaAccess )
if not treeMgr.readFrom( f ).isSuccess():
print( "Couldn't make a transient tree from the input file!" )
return 1
import xAODRootAccess.GenerateDVIterators
t = treeMgr.eventTree()
# Loop on the first few events:
for entry in xrange( 10 ):
# Load the event:
if t.GetEntry( entry ) < 0:
print( "Couldn't load entry %i from the input!" % entry )
return 1
# Print some header info:
print( "Processing run #%i event #%i (%i events processed so far)" % \
( t.EventInfo.runNumber(), t.EventInfo.eventNumber(), entry ) )
# Exercise the functions on electrons:
for el in t.Electrons:
print( " - Electron: eta = %g, phi = %g, pt = %g" % \
( el.eta(), el.phi(), el.pt() ) )
print( " truthType = %i, truthOrigin = %i" % \
( ROOT.xAOD.TruthHelpers.getParticleTruthType( el ),
ROOT.xAOD.TruthHelpers.getParticleTruthOrigin( el ) ) )
tp = ROOT.xAOD.TruthHelpers.getTruthParticle( el )
if tp:
print( " - TruthParticle: eta = %g, phi = %g, pt = %g" % \
( tp.eta(), tp.phi(), tp.pt() ) )
pass
pass
pass
return 0;
# Execute the main function:
if __name__ == "__main__":
import sys
sys.exit( main() )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id: ut_xaodtruth_particle_test.cxx 687313 2015-08-04 12:07:38Z krasznaa $
// System include(s):
#include <iostream>
#include <cmath>
// Local include(s):
#include "xAODTruth/TruthParticle.h"
#include "xAODTruth/TruthParticleContainer.h"
#include "xAODTruth/TruthParticleAuxContainer.h"
/// Helper macro to test assertions
#define SIMPLE_ASSERT( EXP ) \
do { \
if( ! ( EXP ) ) { \
std::cout << "Error evaluating: " << #EXP << std::endl; \
return 1; \
} \
} while( 0 )
int main() {
// Create a container to test:
xAOD::TruthParticleContainer c;
xAOD::TruthParticleAuxContainer aux;
c.setStore( &aux );
// Construct a particle that we can test. The values are chosen on purpose
// to not be possible to represent in exactly the same way at single and
// double precision.
static const double PX = std::sqrt( ( double ) 1.2345 );
static const double PY = std::sqrt( ( double ) 2.3456 );
static const double PZ = std::sqrt( ( double ) 3.4567 );
static const double E = std::sqrt( ( double ) 4.5678 );
static const double M = std::sqrt( ( double ) 5.6789 );
xAOD::TruthParticle* p = new xAOD::TruthParticle();
c.push_back( p );
p->setPx( PX );
p->setPy( PY );
p->setPz( PZ );
p->setE( E );
p->setM( M );
// The precisions that we want:
static const double FLOAT_PRECISION = 1e-5;
static const double DOUBLE_PRECISION = 1e-10;
// Start with the most basic checks:
SIMPLE_ASSERT( std::abs( p->px() - PX ) < FLOAT_PRECISION );
SIMPLE_ASSERT( std::abs( p->py() - PY ) < FLOAT_PRECISION );
SIMPLE_ASSERT( std::abs( p->pz() - PZ ) < FLOAT_PRECISION );
SIMPLE_ASSERT( std::abs( p->e() - E ) < FLOAT_PRECISION );
SIMPLE_ASSERT( std::abs( p->m() - M ) < FLOAT_PRECISION );
// Now something more tricky:
SIMPLE_ASSERT( std::abs( p->pt() - p->p4().Pt() ) < DOUBLE_PRECISION );
SIMPLE_ASSERT( std::abs( p->eta() - p->p4().Eta() ) < DOUBLE_PRECISION );
SIMPLE_ASSERT( std::abs( p->phi() - p->p4().Phi() ) < DOUBLE_PRECISION );
SIMPLE_ASSERT( std::abs( p->e() - p->p4().E() ) < DOUBLE_PRECISION );
// And finally something not completely obvious:
SIMPLE_ASSERT( std::abs( p->m() - p->p4().M() ) > 0.1 );
// Let the user know what happened:
std::cout << "All tests succeeded" << std::endl;
// Return gracefully:
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment