diff --git a/xAOD/xAODTracking/share/xAODTracking_TrackParticle_test.ref b/xAOD/xAODTracking/share/xAODTracking_TrackParticle_test.ref deleted file mode 100644 index fc7c48f3707099ad299e257ac9d5369d556893c8..0000000000000000000000000000000000000000 --- a/xAOD/xAODTracking/share/xAODTracking_TrackParticle_test.ref +++ /dev/null @@ -1,18 +0,0 @@ -d0 = 1, z0 = 2, phi0 = 1.23, theta = 0.5, qOverP = 0.25 -definingParametersCovMatrixVec = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3] -vx = 0, vy = 1, vz = 2 -numberOfParameters = 2 - - x = 0, y = 1, z = 2, px = 3, py = 4, pz = 5 - - x = 6, y = 7, z = 8, px = 9, py = 10, pz = 11 -parameterPosition( 0 ) = 1 -parameterPosition( 1 ) = 3 - Dumping TrackParticleAuxContainer_v3 -d0:1, z0:2, phi:1.23, theta:0.5, qOverP:0.25, definingParametersCovMatrix: [0x7fffa0474140]1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, -d0 = 1, z0 = 2, phi0 = 1.23, theta = 0.5, qOverP = 0.25 -definingParametersCovMatrixVec = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3] -vx = 0, vy = 1, vz = 2 -numberOfParameters = 2 - - x = 0, y = 1, z = 2, px = 3, py = 4, pz = 5 - - x = 6, y = 7, z = 8, px = 9, py = 10, pz = 11 -parameterPosition( 0 ) = 1 -parameterPosition( 1 ) = 3 diff --git a/xAOD/xAODTracking/share/xAODTracking_TrackParticlexAODHelpers_test.ref b/xAOD/xAODTracking/share/xAODTracking_TrackParticlexAODHelpers_test.ref deleted file mode 100644 index f58064adf66a3f0e2ed79ab069f6b7d65ef46891..0000000000000000000000000000000000000000 --- a/xAOD/xAODTracking/share/xAODTracking_TrackParticlexAODHelpers_test.ref +++ /dev/null @@ -1 +0,0 @@ -PASSED. diff --git a/xAOD/xAODTruth/Root/TruthAccessors_v1.cxx b/xAOD/xAODTruth/Root/TruthAccessors_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1117f20d53901f2e30ae23d333cb70c86a3ed71e --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthAccessors_v1.cxx @@ -0,0 +1,124 @@ +/* + 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 diff --git a/xAOD/xAODTruth/Root/TruthAccessors_v1.h b/xAOD/xAODTruth/Root/TruthAccessors_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..04d3a7d30b0bb469111ea04e44ca121db98a1faa --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthAccessors_v1.h @@ -0,0 +1,44 @@ +// -*- 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 diff --git a/xAOD/xAODTruth/Root/TruthMetaDataAuxContainer_v1.cxx b/xAOD/xAODTruth/Root/TruthMetaDataAuxContainer_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..0d1d7a578c1cdbc2ffe0198a42335214d8f9ca6b --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthMetaDataAuxContainer_v1.cxx @@ -0,0 +1,19 @@ +/* + 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 diff --git a/xAOD/xAODTruth/Root/TruthMetaData_v1.cxx b/xAOD/xAODTruth/Root/TruthMetaData_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..3897c03340dc27adc67ae60ac6b05b922bd51a7f --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthMetaData_v1.cxx @@ -0,0 +1,21 @@ +/* + 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 ) +} + // diff --git a/xAOD/xAODTruth/Root/TruthParticleAuxContainer_v1.cxx b/xAOD/xAODTruth/Root/TruthParticleAuxContainer_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..015457c7f6347e8812ccecd6efa3bba023f9706c --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthParticleAuxContainer_v1.cxx @@ -0,0 +1,27 @@ +/* + 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 diff --git a/xAOD/xAODTruth/Root/TruthParticle_v1.cxx b/xAOD/xAODTruth/Root/TruthParticle_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..33ed93820354e2f383da618031041d50e002cef4 --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthParticle_v1.cxx @@ -0,0 +1,391 @@ +// -*- 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 diff --git a/xAOD/xAODTruth/Root/TruthVertexAuxContainer_v1.cxx b/xAOD/xAODTruth/Root/TruthVertexAuxContainer_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..f3843bcd0a67f36be97c698b6ccb21d20cb995a1 --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthVertexAuxContainer_v1.cxx @@ -0,0 +1,25 @@ +/* + 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 diff --git a/xAOD/xAODTruth/Root/TruthVertex_v1.cxx b/xAOD/xAODTruth/Root/TruthVertex_v1.cxx new file mode 100644 index 0000000000000000000000000000000000000000..c35ac3dccba3bed6e6ae5598b06696b358a4699d --- /dev/null +++ b/xAOD/xAODTruth/Root/TruthVertex_v1.cxx @@ -0,0 +1,251 @@ +/* + 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 diff --git a/xAOD/xAODTruth/xAODTruth/TruthEvent.h b/xAOD/xAODTruth/xAODTruth/TruthEvent.h index 939dd937c16c70a64fa3bf5dbee0fb48802b1ddf..b8420dd68f7b2476bb1ebcc889f6683c2adf69c9 100644 --- a/xAOD/xAODTruth/xAODTruth/TruthEvent.h +++ b/xAOD/xAODTruth/xAODTruth/TruthEvent.h @@ -11,6 +11,10 @@ #include "xAODBase/ObjectType.h" // Local include(s): +<<<<<<< HEAD +======= +#include "xAODTruth/TruthEventBase.h" +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a #include "xAODTruth/TruthParticleContainer.h" #include "xAODTruth/TruthVertexContainer.h" @@ -178,9 +182,12 @@ namespace xAOD { /// Pointer to the incoming primary particle const TruthParticle* primaryParticle() const; +<<<<<<< HEAD /// Get the link to the primary particle const TruthParticleLink_t& primaryParticleLink() const; +======= +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a /// Set incoming primary particle void setPrimaryParticleLink( const TruthParticleLink_t& pcl); @@ -188,6 +195,7 @@ namespace xAOD { /// The type of the object as a simple enumeration virtual Type::ObjectType type() const; +<<<<<<< HEAD /// @name Simple truth meta data properties /// @{ @@ -199,6 +207,8 @@ namespace xAOD { void setWeightNames( const std::vector< std::string >& value ); /// @} +======= +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a /// Function making sure that the object is ready for persistification void toPersistent(); @@ -207,4 +217,11 @@ namespace xAOD { } // namespace xAOD +<<<<<<< HEAD +======= +// Declare the base class of TruthEvent to StoreGate: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::TruthEvent, SG::AuxElement ); + +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a #endif // XAODTRUTH_TRUTHEVENT_H diff --git a/xAOD/xAODTruth/xAODTruth/TruthEventBase.h b/xAOD/xAODTruth/xAODTruth/TruthEventBase.h new file mode 100644 index 0000000000000000000000000000000000000000..f84e151a3879d212d0e0acbe8884507db25738b8 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/TruthEventBase.h @@ -0,0 +1,19 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef XAODTRUTH_TRUTHEVENTBASE_H +#define XAODTRUTH_TRUTHEVENTBASE_H + +#include "xAODTruth/versions/TruthEventBase_v1.h" + +namespace xAOD { + + /// Typedef to implementation + typedef TruthEventBase_v1 TruthEventBase; + +} + +#endif diff --git a/xAOD/xAODTruth/xAODTruth/TruthEventBaseContainer.h b/xAOD/xAODTruth/xAODTruth/TruthEventBaseContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..cbdee8b08c1d5152e5d21b8ff72d1098d5b1ea93 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/TruthEventBaseContainer.h @@ -0,0 +1,24 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthEventBaseContainer.h 622193 2014-10-16 16:08:34Z krasznaa $ +#ifndef XAODTRUTH_TRUTHEVENTBASECONTAINER_H +#define XAODTRUTH_TRUTHEVENTBASECONTAINER_H + +// Local include(s): +#include "xAODTruth/TruthEventBase.h" +#include "xAODTruth/versions/TruthEventBaseContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the truth event container + typedef TruthEventBaseContainer_v1 TruthEventBaseContainer; +} + +// Declare a CLID for the class for Athena: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::TruthEventBaseContainer, 1280408222, 1 ) + +#endif // XAODTRUTH_TRUTHEVENTBASECONTAINER_H diff --git a/xAOD/xAODTruth/xAODTruth/TruthMetaData.h b/xAOD/xAODTruth/xAODTruth/TruthMetaData.h new file mode 100644 index 0000000000000000000000000000000000000000..cc53752da50664234d105cc29d101d807ac79e12 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/TruthMetaData.h @@ -0,0 +1,19 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef XAODTRUTH_TRUTHMETADATA_H +#define XAODTRUTH_TRUTHMETADATA_H + +#include "xAODTruth/versions/TruthMetaData_v1.h" + +namespace xAOD { + + /// Typedef to implementation + typedef TruthMetaData_v1 TruthMetaData; + +} + +#endif diff --git a/xAOD/xAODTruth/xAODTruth/TruthMetaDataAuxContainer.h b/xAOD/xAODTruth/xAODTruth/TruthMetaDataAuxContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..8974a7c4ca848331e5d0d95471a4058501e6dbba --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/TruthMetaDataAuxContainer.h @@ -0,0 +1,23 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +#ifndef XAODTRUTH_TRUTHMETADATAAUXCONTAINER_H +#define XAODTRUTH_TRUTHMETADATAAUXCONTAINER_H + +// Local include(s): +#include "xAODTruth/versions/TruthMetaDataAuxContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the truth vertex auxiliary container + typedef TruthMetaDataAuxContainer_v1 TruthMetaDataAuxContainer; +} + +// Declare a CLID for the class +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::TruthMetaDataAuxContainer, 1094306618, 1 ) + +#endif // XAODTRUTH_TRUTHMETADATAAUXCONTAINER_H diff --git a/xAOD/xAODTruth/xAODTruth/TruthMetaDataContainer.h b/xAOD/xAODTruth/xAODTruth/TruthMetaDataContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..248918cd223da5f9a9e1b7bdd6a6e976bbf5a431 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/TruthMetaDataContainer.h @@ -0,0 +1,24 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +#ifndef XAODTRUTH_TRUTHMETADATACONTAINER_H +#define XAODTRUTH_TRUTHMETADATACONTAINER_H + +// Local include(s): +#include "xAODTruth/TruthMetaData.h" +#include "xAODTruth/versions/TruthMetaDataContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the truth vertex container + typedef TruthMetaDataContainer_v1 TruthMetaDataContainer; +} + +// Declare a CLID for the class for Athena: +#include "xAODCore/CLASS_DEF.h" +CLASS_DEF( xAOD::TruthMetaDataContainer, 1188015687, 1 ) + +#endif // XAODTRUTH_TRUTHMETADATACONTAINER_H diff --git a/xAOD/xAODTruth/xAODTruth/TruthParticle.h b/xAOD/xAODTruth/xAODTruth/TruthParticle.h index 3a230b018d4e8ad54afe337312efe6de18b1aa34..ecf3ed4d80b0806b08020cb1232c8a6172993935 100644 --- a/xAOD/xAODTruth/xAODTruth/TruthParticle.h +++ b/xAOD/xAODTruth/xAODTruth/TruthParticle.h @@ -1,3 +1,4 @@ +<<<<<<< HEAD #ifndef XAODTRUTH_TRUTHPARTICLE_H #define XAODTRUTH_TRUTHPARTICLE_H @@ -356,5 +357,24 @@ namespace xAOD { }; // class TruthParticle } // namespace xAOD +======= +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef XAODTRUTH_TRUTHPARTICLE_H +#define XAODTRUTH_TRUTHPARTICLE_H + +#include "xAODTruth/versions/TruthParticle_v1.h" + +namespace xAOD { + + /// Typedef to implementation + typedef TruthParticle_v1 TruthParticle; + +} +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a #endif diff --git a/xAOD/xAODTruth/xAODTruth/TruthParticleAuxContainer.h b/xAOD/xAODTruth/xAODTruth/TruthParticleAuxContainer.h index ca8ec36160eec199005d0f664863ae426d4e74cb..20032bf8cc1cc7fa4b0a868a65847b15082b4c15 100644 --- a/xAOD/xAODTruth/xAODTruth/TruthParticleAuxContainer.h +++ b/xAOD/xAODTruth/xAODTruth/TruthParticleAuxContainer.h @@ -1,3 +1,4 @@ +<<<<<<< HEAD #ifndef XAODTRUTH_TRUTHPARTICLEAUXCONTAINER_H #define XAODTRUTH_TRUTHPARTICLEAUXCONTAINER_H @@ -39,6 +40,25 @@ namespace xAOD { }; // class TruthParticleAuxContainer } // namespace xAOD +======= +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthParticleAuxContainer.h 622193 2014-10-16 16:08:34Z krasznaa $ +#ifndef XAODTRUTH_TRUTHPARTICLEAUXCONTAINER_H +#define XAODTRUTH_TRUTHPARTICLEAUXCONTAINER_H + +// Local include(s): +#include "xAODTruth/versions/TruthParticleAuxContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the truth particle auxiliary container + typedef TruthParticleAuxContainer_v1 TruthParticleAuxContainer; +} +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a // Declare a CLID for the class #include "xAODCore/CLASS_DEF.h" diff --git a/xAOD/xAODTruth/xAODTruth/TruthVertex.h b/xAOD/xAODTruth/xAODTruth/TruthVertex.h index 6f24fbd975800bc3708c9256dccc1f32c931276e..560715f82fbba17ed80f1426d9bbc2c7466e94a6 100644 --- a/xAOD/xAODTruth/xAODTruth/TruthVertex.h +++ b/xAOD/xAODTruth/xAODTruth/TruthVertex.h @@ -1,3 +1,4 @@ +<<<<<<< HEAD #ifndef XAODTRUTH_TRUTHVERTEX_H #define XAODTRUTH_TRUTHVERTEX_H @@ -138,5 +139,24 @@ namespace xAOD { }; // class TruthVertex } // namespace xAOD +======= +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef XAODTRUTH_TRUTHVERTEX_H +#define XAODTRUTH_TRUTHVERTEX_H + +#include "xAODTruth/versions/TruthVertex_v1.h" + +namespace xAOD { + + /// Typedef to implementation + typedef TruthVertex_v1 TruthVertex; + +} +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a #endif diff --git a/xAOD/xAODTruth/xAODTruth/TruthVertexAuxContainer.h b/xAOD/xAODTruth/xAODTruth/TruthVertexAuxContainer.h index b6098f4323eeee6a834f33495c00133a942571ea..40ccb4033c04b5807ba7439e9dfb723e252d477b 100644 --- a/xAOD/xAODTruth/xAODTruth/TruthVertexAuxContainer.h +++ b/xAOD/xAODTruth/xAODTruth/TruthVertexAuxContainer.h @@ -1,3 +1,4 @@ +<<<<<<< HEAD #ifndef XAODTRUTH_TRUTHVERTEXAUXCONTAINER_H #define XAODTRUTH_TRUTHVERTEXAUXCONTAINER_H @@ -42,6 +43,25 @@ namespace xAOD { }; // class TruthVertexAuxContainer } // namespace xAOD +======= +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthVertexAuxContainer.h 622081 2014-10-16 00:55:18Z abuckley $ +#ifndef XAODTRUTH_TRUTHVERTEXAUXCONTAINER_H +#define XAODTRUTH_TRUTHVERTEXAUXCONTAINER_H + +// Local include(s): +#include "xAODTruth/versions/TruthVertexAuxContainer_v1.h" + +namespace xAOD { + /// Declare the latest version of the truth vertex auxiliary container + typedef TruthVertexAuxContainer_v1 TruthVertexAuxContainer; +} +>>>>>>> fbfa9a4181233045f89cb94c800d3ea1cb76088a // Declare a CLID for the class #include "xAODCore/CLASS_DEF.h" diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthEvent.h b/xAOD/xAODTruth/xAODTruth/versions/TruthEvent.h new file mode 100644 index 0000000000000000000000000000000000000000..38f90cbf48026b76e8c3482c389ece970d46b582 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthEvent.h @@ -0,0 +1,200 @@ +#ifndef XAODTRUTH_TRUTHEVENT_H +#define XAODTRUTH_TRUTHEVENT_H + +// System include(s): +#include <utility> +#include <vector> + +// EDM include(s): +#include "AthContainers/AuxElement.h" +#include "AthLinks/ElementLink.h" +#include "xAODBase/ObjectType.h" + +// Local include(s): +#include "xAODTruth/TruthEventBase.h" +#include "xAODTruth/TruthParticleContainer.h" +#include "xAODTruth/TruthVertexContainer.h" + +namespace xAOD { + + /// Class describing a signal truth event in the MC record + /// + class TruthEvent : public SG::AuxElement { + + public: + /// Default constructor + TruthEvent(); + /// Virtual destructor, to make vtable happy + virtual ~TruthEvent() {} + + /// @name Access to all the particles associated with the event + /// @{ + + /// Type of a single truth particle link + typedef ElementLink< TruthParticleContainer > TruthParticleLink_t; + /// Type of the truth particle links vector + typedef std::vector< TruthParticleLink_t > TruthParticleLinks_t; + + /// Get all the truth particles + const TruthParticleLinks_t& truthParticleLinks() const; + /// Set all the truth particles + void setTruthParticleLinks( const TruthParticleLinks_t& plinks ); + /// Get the number of truth particles + size_t nTruthParticles() const; + /// Get the link to one of the truth particles + const TruthParticleLink_t& truthParticleLink( size_t index ) const; + /// Get a pointer to one of the truth particles + const TruthParticle* truthParticle( size_t index ) const; + /// Add one truth particle + void addTruthParticleLink( const TruthParticleLink_t& plink ); + /// Remove all truth particles + void clearTruthParticleLinks(); + + /// @} + + /// @name Access to all the vertices associated with the event + /// @{ + + /// Type of a single truth vertex link + typedef ElementLink< TruthVertexContainer > TruthVertexLink_t; + /// Type of the truth particle links vector + typedef std::vector< TruthVertexLink_t > TruthVertexLinks_t; + + /// Get all the truth vertices + const TruthVertexLinks_t& truthVertexLinks() const; + /// Set all the truth vertices + void setTruthVertexLinks( const TruthVertexLinks_t& links ); + /// Get the number of truth vertices + size_t nTruthVertices() const; + /// Get the link to one of the truth vertices + const TruthVertexLink_t& truthVertexLink( size_t index ) const; + /// Get a pointer to one of the truth vertices + const TruthVertex* truthVertex( size_t index ) const; + /// Add one truth vertex + void addTruthVertexLink( const TruthVertexLink_t& vlink ); + /// Remove all truth vertices + void clearTruthVertexLinks(); + + /// @} + + /// @name Simple event properties + /// @{ + + /// Const access to the weights vector + /// @todo Need to add the map-like interface for the weights: very important! + const std::vector< float >& weights() const; + /// Set the event weights + /// @todo Need to add named weight access: vector<string> + void setWeights( const std::vector< float >& weights ); + + /// Get the cross section + float crossSection() const; + /// Set the cross-section + void setCrossSection( float value ); + + /// Get the cross section error + float crossSectionError() const; + /// Set the cross-section error + void setCrossSectionError( float value ); + + /// Set the cross-section and its error + void setCrossSection( float value, float error ); + + /// @} + + /// @name Parton density info + /// + /// Optional due to particle gun & NLO events where a single PDF info + /// doesn't work. + /// + /// @{ + + /// Accessor enums for PDF info parameter lookup + enum PdfParam { + PDGID1 = 0, ///< [int] + PDGID2 = 1, ///< [int] + PDFID1 = 2, ///< [int] + PDFID2 = 3, ///< [int] + X1 = 4, ///< [float] + X2 = 5, ///< [float] + SCALE = 6, ///< Not implemented!!! + Q = 6, ///< [float] + PDF1 = 7, ///< Not implemented!!! + PDF2 = 8, ///< Not implemented!!! + XF1 = 7, ///< [float] + XF2 = 8 ///< [float] + }; // enum PdfParam + + /// Read an integer PDF info parameter + bool pdfInfoParameter( int& value, PdfParam parameter ) const; + /// Read a floating point PDF info parameter + bool pdfInfoParameter( float& value, PdfParam parameter ) const; + + /// Set an integer PDF info parameter + bool setPdfInfoParameter( int value, PdfParam parameter ); + /// Set a floating point PDF info parameter + bool setPdfInfoParameter( float value, PdfParam parameter ); + + /// Helper struct holding a full set of PDF info values + struct PdfInfo { + + /// Constructor to set (invalid) defaults + PdfInfo(); + + /// Check if all the variables in the object are valid + bool valid() const; + + int pdgId1; + int pdgId2; + int pdfId1; + int pdfId2; + float x1; + float x2; + float Q; + float xf1; + float xf2; + + }; // struct PdfInfo + + /// Retrieve a full PdfInfo with a single call + /// @note May have invalid values -- use valid() to check. + PdfInfo pdfInfo() const; + + /// @} + + /// @name Links to particles and vertices in the event + /// @{ + + /// Pointer to a vertex representing the primary interaction point + /// + /// The naming of the function is a bit misleading. The returned vertex + /// can only be interpreted as an interaction *position*. + /// + const TruthVertex* signalProcessVertex() const; + /// Link to the vertex representing the primary interaction point + const TruthVertexLink_t& signalProcessVertexLink() const; + /// Set pointer to a vertex representing the primary interaction point + void setSignalProcessVertexLink( const TruthVertexLink_t& link ); + + /// Get the link to the first incoming primary particle + const TruthParticleLink_t& primaryParticleLink() const; + /// Set one incoming primary particle + void setPrimaryParticleLink( const TruthParticleLink_t& pcl ); + + /// @} + + /// The type of the object as a simple enumeration + virtual Type::ObjectType type() const; + + /// Function making sure that the object is ready for persistification + void toPersistent(); + + }; // class TruthEvent + +} // namespace xAOD + +// Declare the base class of TruthEvent to StoreGate: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::TruthEvent, SG::AuxElement ); + +#endif // XAODTRUTH_TRUTHEVENT_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthMetaDataAuxContainer_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthMetaDataAuxContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..aec914664b52160c49992d4b0ad2ddc5a3d8dce6 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthMetaDataAuxContainer_v1.h @@ -0,0 +1,51 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +#ifndef XAODTRUTH_VERSIONS_TRUTHMETADATAAUXCONTAINER_V1_H +#define XAODTRUTH_VERSIONS_TRUTHMETADATAAUXCONTAINER_V1_H + +// System include(s): +#include <vector> + +// EDM include(s): +#include "AthLinks/ElementLink.h" +#include "xAODCore/AuxContainerBase.h" + +// Local include(s): +#include "xAODTruth/TruthParticleContainer.h" + +namespace xAOD { + + /// Auxiliary store for the truth meta data + /// + /// @author Tobias Bisanz <tobias.bisanz@cern.ch> + /// + /// $Revision$ + /// $Date$ + /// + class TruthMetaDataAuxContainer_v1 : public AuxContainerBase { + + public: + /// Default constructor + TruthMetaDataAuxContainer_v1(); + + private: + //Two vectors (of vectors) to store association between weight name and weight + //index. No std::map is used for increased read-back speed in ROOT + std::vector < std::vector < std::string > > weightNames; + std::vector < uint32_t > mcChannelNumber; + + }; // class TruthMetaDataAuxContainer_v1 + +} // namespace xAOD + + +// StoreGate registration +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::TruthMetaDataAuxContainer_v1, xAOD::AuxContainerBase ); + +#endif // XAODTRUTH_VERSIONS_TRUTHMETADATAAUXCONTAINER_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthMetaDataContainer_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthMetaDataContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..93a6633a86d2d604cb54b962afdbf842e0c3a677 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthMetaDataContainer_v1.h @@ -0,0 +1,22 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +#ifndef XAODTRUTH_VERSIONS_TRUTHMETADATACONTAINER_V1_H +#define XAODTRUTH_VERSIONS_TRUTHMETADATACONTAINER_V1_H + +// EDM include(s): +#include "AthContainers/DataVector.h" + +// Local include(s): +#include "xAODTruth/versions/TruthMetaData_v1.h" + +namespace xAOD { + // Alias + typedef DataVector< TruthMetaData_v1 > TruthMetaDataContainer_v1; +} + +#endif // XAODTRUTH_VERSIONS_TRUTHMETADATACONTAINER_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthMetaData_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthMetaData_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..cd48d625979ab35333d96b32ac8fa0fc85356db1 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthMetaData_v1.h @@ -0,0 +1,55 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +#ifndef XAODTRUTH_VERSIONS_TRUTHMETADATA_V1_H +#define XAODTRUTH_VERSIONS_TRUTHMETADATA_V1_H + +// EDM include(s): +#include "AthContainers/AuxElement.h" +#include "AthLinks/ElementLink.h" + +// xAOD include(s): +#include "xAODBase/ObjectType.h" + +namespace xAOD { + + /// Class describing meta data for truth records + /// + /// + /// @author Tobias Bisanz <tobias.bisanz@cern.ch> + /// + /// $Revision$ + /// $Date$ + /// + class TruthMetaData_v1 : public SG::AuxElement { + + public: + /// Default constructor + TruthMetaData_v1(); + + /// @name Simple truth meta data properties + /// @{ + + uint32_t mcChannelNumber() const; + void setMcChannelNumber( uint32_t value ); + + const std::vector< std::string >& weightNames() const; + void setWeightNames( const std::vector< std::string >& value ); + + /// @} + + private: + + }; // class TruthMetaData_v1 + +} // namespace xAOD + +// Declare the inheritance of the type to StoreGate: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::TruthMetaData_v1, SG::AuxElement ); + +#endif // XAODTRUTH_VERSIONS_TRUTHMETADATA_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthParticleAuxContainer_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthParticleAuxContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..5670ccc61b869bdc9b4e4e49b7231e259baae908 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthParticleAuxContainer_v1.h @@ -0,0 +1,55 @@ +// -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef XAODTRUTH_VERSIONS_TRUTHPARTICLEAUXCONTAINER_V1_H +#define XAODTRUTH_VERSIONS_TRUTHPARTICLEAUXCONTAINER_V1_H + +#include <vector> + +#include "AthLinks/ElementLink.h" +#include "xAODCore/AuxContainerBase.h" + +#include "xAODTruth/TruthParticleContainer.h" +#include "xAODTruth/TruthVertexContainer.h" + +namespace xAOD { + + + /// Auxiliary store for the truth vertices + /// + /// @author Andy Buckley <Andy.Buckey@cern.ch> + /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> + /// @author Jovan Mitrevski <Jovan.Mitrevski@cern.h> + /// + class TruthParticleAuxContainer_v1 : public AuxContainerBase { + + public: + /// Default constructor + TruthParticleAuxContainer_v1(); + + private: + std::vector< int > pdgId; + std::vector< int > barcode; + std::vector< int > status; + std::vector< ElementLink< TruthVertexContainer > > prodVtxLink; + std::vector< ElementLink< TruthVertexContainer > > decayVtxLink; + std::vector< float > px; + std::vector< float > py; + std::vector< float > pz; + std::vector< float > e; + std::vector< float > m; // needed since not necessarily on shell + + }; // class TruthParticleAuxContainer_v1 + +} // namespace xAOD + + +// StoreGate registration +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::TruthParticleAuxContainer_v1, xAOD::AuxContainerBase ); + + +#endif // XAODTRUTH_VERSIONS_TRUTHPARTICLEAUXCONTAINER_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthParticleContainer_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthParticleContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..4bee9879f63ca4729110c988001e81d539a82e1d --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthParticleContainer_v1.h @@ -0,0 +1,24 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthParticleContainer_v1.h 622193 2014-10-16 16:08:34Z krasznaa $ +#ifndef XAODTRUTH_VERSIONS_TRUTHPARTICLECONTAINER_V1_H +#define XAODTRUTH_VERSIONS_TRUTHPARTICLECONTAINER_V1_H + +// EDM include(s): +#include "AthContainers/DataVector.h" +#include "xAODBase/IParticleContainer.h" + +// Local include(s): +#include "xAODTruth/versions/TruthParticle_v1.h" +#include "xAODTruth/TruthParticleContainerFwd.h" // Only as long as this is the most recent version... + +namespace xAOD { + // Alias + typedef DataVector< TruthParticle_v1 > TruthParticleContainer_v1; +} + +#endif // XAODTRUTH_VERSIONS_TRUTHPARTICLECONTAINER_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthParticle_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthParticle_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..a6f65a248f015e9784c684df8965ae82b1f51299 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthParticle_v1.h @@ -0,0 +1,381 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthParticle_v1.h 624338 2014-10-27 15:08:55Z krasznaa $ +#ifndef XAODTRUTH_VERSIONS_TRUTHPARTICLE_V1_H +#define XAODTRUTH_VERSIONS_TRUTHPARTICLE_V1_H + +// EDM include(s): +#include "AthLinks/ElementLink.h" + +// xAOD include(s): +#include "xAODBase/IParticle.h" +#include "xAODBase/ObjectType.h" + +// Local include(s): +#include "xAODTruth/TruthVertexContainerFwd.h" + +namespace xAOD { + + /// Class describing a truth particle in the MC record + /// + /// The xAOD truth record mimicks the structure of HepMC. Truth particles + /// and truth vertices form a decay tree. Where each truth particle is + /// connected to a single production and decay vertex. And each vertex is + /// connected to one or more incoming, and one or more outgoing particles. + /// + /// @author Andy Buckley <Andy.Buckley@cern.ch> + /// @author Jovan Mitrevski <Jovan.Mitrevski@cern.ch> + /// + /// $Revision: 624338 $ + /// $Date: 2014-10-27 16:08:55 +0100 (Mon, 27 Oct 2014) $ + /// + class TruthParticle_v1 : public IParticle { + + public: + /// Default constructor + TruthParticle_v1(); + + /// @name Functions identifying the particle in the MC record + /// @{ + + /// Set PDG ID code + void setPdgId( int pid ); + /// PDG ID code + int pdgId() const; + /// Absolute PDG ID code (often useful) + int absPdgId() const; + + /// Barcode + /// @note Meaning of barcode may change -- be careful! + int barcode() const; + /// Set barcode + void setBarcode( int value ); + + /// Status code + int status() const; + /// Set status code + void setStatus( int value ); + + /// @} + + /// @name Links to the production and decay vertices + /// @{ + + /// Check for a production vertex on this particle + bool hasProdVtx() const; + /// The production vertex of this particle + const TruthVertex_v1* prodVtx() const; + /// The production vertex link of this particle + const ElementLink< TruthVertexContainer >& prodVtxLink() const; + /// Set the production vertex of the particle + void setProdVtxLink( const ElementLink< TruthVertexContainer >& link ); + + /// Check for a decay vertex on this particle + bool hasDecayVtx() const; + /// The decay vertex of this particle + const TruthVertex_v1* decayVtx() const; + /// The decay vertex link of this particle + const ElementLink< TruthVertexContainer >& decayVtxLink() const; + /// Set the decay vertex of the particle + void setDecayVtxLink( const ElementLink< TruthVertexContainer >& link ); + + /// @} + + /// @name Particle connection / origin / decay information + /// @{ + + /// Number of parents of this particle + size_t nParents() const; + + /// Retrieve the i-th mother (TruthParticle) of this TruthParticle + const TruthParticle_v1* parent( size_t i = 0 ) const; + + /// Number of children of this particle + size_t nChildren() const; + + /// Retrieve the i-th mother (TruthParticle) of this TruthParticle + const TruthParticle_v1* child( size_t i = 0 ) const; + + /// @todo Add mappings of e.g. isPrimary, isDecayed, isPrompt, + /// isFromDecay, hasHadronicDecay, hasLeptonicDecay, + /// isHadronic/LeptonicTau ... + + /// @todo Add isFirstWith, isLastWith + + /// @} + + /// @name Functions implementing the xAOD::IParticle interface + /// @{ + + /// The transverse momentum (\f$p_T\f$) of the particle + virtual double pt() const; + /// The pseudorapidity (\f$\eta\f$) of the particle + virtual double eta() const; + /// The azimuthal angle (\f$\phi\f$) of the particle + virtual double phi() const; + /// The mass of the particle + /// + /// Note, not necessarily = \f$E^2-p^2\f$ if not on mass shell. + /// + virtual double m() const; + /// The total energy of the particle + virtual double e() const; + /// The true rapidity (\f$y\f$) of the particle + virtual double rapidity() const; + + /// Definition of the 4-momentum type + typedef IParticle::FourMom_t FourMom_t; + + /// The full 4-momentum of the particle + /// + /// Note that m may not be right, though, if not on mass shell. In which + /// case <code>p4().M()</code> will be different from <code>m()</code>. + /// + virtual const FourMom_t& p4() const; + + /// The type of the object as a simple enumeration + virtual Type::ObjectType type() const; + + /// @} + + /// @name 4-momentum accessors specific to truth particles + /// @{ + + /// The absolute pseudorapidity (\f$|\eta|\f$) of the particle + /// @todo Remove this when/if supported in xAOD::IParticle + double abseta() const; + /// The true absolute rapidity (\f$|y|\f$) of the particle + /// @todo Remove this when/if supported in xAOD::IParticle + double absrapidity() const; + + /// The x component of the particle's momentum + float px() const; + /// Set the x component of the particle's momentum + void setPx( float value ); + + /// The y component of the particle's momentum + float py() const; + /// Set the y component of the particle's momentum + void setPy( float value ); + + /// The z component of the particle's momentum + float pz() const; + /// Set the z component of the particle's momentum + void setPz( float value ); + + /// Set the energy of the particle + void setE( float value ); + + /// Also store the mass + void setM( float value ); + + /// @} + + /// @name Particle species information + /// + /// Just convenience methods here, since they all just forward to the + /// utility functions operating on the PDG particle ID code. + /// + /// @{ + + /// Physical charge + double charge() const; + /// 3 x the physical charge (so it can be an int for quarks) + int threeCharge() const; + + /// Whether the particle is electrically charged + bool isCharged() const; + /// Whether the particle is electrically neutral + bool isNeutral() const; + + /// Whether the particle is a photon + bool isPhoton() const; + /// Whether the particle is a lepton + bool isLepton() const; + /// Whether the particle is a charged lepton + bool isChLepton() const; + /// Whether the particle is an electron (or positron) + bool isElectron() const; + /// Whether the particle is a muon (or antimuon) + bool isMuon() const; + /// Whether the particle is a tau (or antitau) + bool isTau() const; + /// Whether the particle is a neutrino (or antineutrino) + bool isNeutrino() const; + + /// Whether the particle is a hadron + bool isHadron() const; + /// Whether the particle is a meson + bool isMeson() const; + /// Whether the particle is a baryon + bool isBaryon() const; + + /// Whether the particle contains a strange quark (or antiquark) + bool hasStrange() const; + /// Whether the particle contains a charm quark (or antiquark) + bool hasCharm() const; + /// Whether the particle contains a bottom quark (or antiquark) + bool hasBottom() const; + + /// Determine if the PID is that of a light flavour (not b or c) meson + bool isLightMeson() const; + /// Determine if the PID is that of a light flavour (not b or c) baryon + bool isLightBaryon() const; + /// Determine if the PID is that of a light flavour (not b or c) hadron + bool isLightHadron() const; + + /// Determine if the PID is that of a heavy flavour (b or c) meson + bool isHeavyMeson() const; + /// Determine if the PID is that of a heavy flavour (b or c) baryon + bool isHeavyBaryon() const; + /// Determine if the PID is that of a heavy flavour (b or c) hadron + bool isHeavyHadron() const; + + /// Determine if the PID is that of a b-meson. + bool isBottomMeson() const; + /// Determine if the PID is that of a b-baryon. + bool isBottomBaryon() const; + /// Determine if the PID is that of a b-hadron. + bool isBottomHadron() const; + + /// @brief Determine if the PID is that of a c-meson. + /// + /// Specifically, the _heaviest_ quark is a c: a B_c is a b-meson and NOT + /// a c-meson. Charmonia (closed charm) are counted as c-mesons here. + /// + bool isCharmMeson() const; + /// @brief Determine if the PID is that of a c-baryon. + /// + /// Specifically, the _heaviest_ quark is a c: a baryon containing a b & c + /// is a b-baryon and NOT a c-baryon. To test for the simpler case, just + /// use a combination of hasCharm() and isBaryon(). + /// + bool isCharmBaryon() const; + /// Determine if the PID is that of a c-hadron. + bool isCharmHadron() const; + + /// Determine if the PID is that of a strange meson + bool isStrangeMeson() const; + /// Determine if the PID is that of a strange baryon + bool isStrangeBaryon() const; + /// Determine if the PID is that of a strange hadron + bool isStrangeHadron() const; + + /// Check if this particle is a quark + bool isQuark() const; + /// Check if this particle is a parton + bool isParton() const; + /// Check if this particle is a top quark + bool isTop() const; + /// Check if this particle is a W boson + bool isW() const; + /// Check if this particle is a Z boson + bool isZ() const; + /// Check if this particle is a Higgs boson + bool isHiggs() const; + /// Check if this particle is a resonant state + bool isResonance() const; + /// Check if this is a generator specific (non-physical) particle + bool isGenSpecific() const; + + /// @} + + /// @name Polarization properties (optional) + /// @{ + + /// Polarization parameter types + enum PolParam { + polarizationPhi = 0, ///< Polarization in (\f$\phi\f$) + polarizationTheta = 1 ///< Polarization in (\f$\theta\f$) + }; + + /// Accessor for polarization parameters + /// + /// Generic C++ code should use this function to retrieve the polarization + /// parameters of a truth particle. Since these parameters are optional, + /// the function is designed to tell the user whether the requested + /// parameter could be retrieved or not. + /// + /// @param value The polarization parameter value read from the object + /// @param parameter The polarization parameter that we are interested in + /// @return <code>true</code> if the retrieval was successful, + /// <code>false</code> if it wasn't + /// + bool polarizationParameter( float& value, PolParam parameter ) const; + + /// Set method for polarization parameter values + /// + /// In order to keep the symmetry with the getter function, this setter + /// communicates a possible failure in its operation through a return + /// value. Setting a polariozation parameter is much less likely to fail + /// than retrieving one, but in some situations it may still happen... + /// + /// @param value The polarization parameter value to set on the object + /// @param parameter The polarization parameter type that we want to set + /// @return <code>true</code> if the operation was successful, or + /// <code>false</code> if it wasn't + /// + bool setPolarizationParameter( float value, PolParam parameter ); + + /// Convenience accessor for a polariozation parameter. + /// + /// Throws an exception if the request can't be completed. It should + /// mostly be used in PyROOT, as the other form of this function is very + /// hard to use there. But one needs to know for sure that the requested + /// parameter will exist. + /// + /// @param parameter The polarion parameter that we are interested in + /// @return The value of the polarization parameter requested + /// + float polarizationPatameter( PolParam parameter ) const; + + /// Single container for full polarization information + /// + /// It can be used as a convenient way for accessing the polarization of + /// the particle with a single call. + /// + struct Polarization { + + /// Constructor to set (invalid) defaults + /// @todo Use C++11 inline member init when allowed + Polarization() + : phi( -1.0 ), theta( -1.0 ) {} + + /// Check if the stored values are valid + bool valid() const { + return ( ( phi > 0.0 ) && ( theta > 0.0 ) ); + } + + float phi; ///< Polarization in (\f$\phi\f$) + float theta; ///< Polarization in (\f$\theta\f$) + + }; // struct Polarization + + /// Retrieve a full Polarization with a single call + /// + /// @note May have invalid values -- use valid() to check. + /// + /// @return An object holding the full polarization information + /// + Polarization polarization() const; + + /// @} + + /// Function making sure that the object is ready for persistification + void toPersistent(); + + private: + /// Cached four momentum + mutable FourMom_t m_p4; + /// Flag specifying if the four-momentum is cached + mutable bool m_p4Cached; + + }; // class TruthParticle_v1 + +} // namespace xAOD + +#endif // XAODTRUTH_VERSIONS_TRUTHPARTICLE_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthVertexAuxContainer_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthVertexAuxContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..dc988e1337e4463dddb99d47b900553b3cb89533 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthVertexAuxContainer_v1.h @@ -0,0 +1,58 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthVertexAuxContainer_v1.h 624338 2014-10-27 15:08:55Z krasznaa $ +#ifndef XAODTRUTH_VERSIONS_TRUTHVERTEXAUXCONTAINER_V1_H +#define XAODTRUTH_VERSIONS_TRUTHVERTEXAUXCONTAINER_V1_H + +// System include(s): +#include <vector> + +// EDM include(s): +#include "AthLinks/ElementLink.h" +#include "xAODCore/AuxContainerBase.h" + +// Local include(s): +#include "xAODTruth/TruthParticleContainer.h" + +namespace xAOD { + + /// Auxiliary store for the truth vertices + /// + /// @author Andy Buckley <Andy.Buckey@cern.ch> + /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> + /// + /// $Revision: 624338 $ + /// $Date: 2014-10-27 16:08:55 +0100 (Mon, 27 Oct 2014) $ + /// + class TruthVertexAuxContainer_v1 : public AuxContainerBase { + + public: + /// Default constructor + TruthVertexAuxContainer_v1(); + + private: + std::vector< int > id; + std::vector< int > barcode; + std::vector< std::vector< ElementLink< TruthParticleContainer > > > + incomingParticleLinks; + std::vector< std::vector< ElementLink< TruthParticleContainer > > > + outgoingParticleLinks; + std::vector< float > x; + std::vector< float > y; + std::vector< float > z; + std::vector< float > t; + + }; // class TruthVertexAuxContainer_v1 + +} // namespace xAOD + + +// StoreGate registration +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::TruthVertexAuxContainer_v1, xAOD::AuxContainerBase ); + +#endif // XAODTRUTH_VERSIONS_TRUTHVERTEXAUXCONTAINER_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthVertexContainer_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthVertexContainer_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..3851af60d1d46d2bb901cf17f39ebc76a82903e5 --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthVertexContainer_v1.h @@ -0,0 +1,23 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthVertexContainer_v1.h 622193 2014-10-16 16:08:34Z krasznaa $ +#ifndef XAODTRUTH_VERSIONS_TRUTHVERTEXCONTAINER_V1_H +#define XAODTRUTH_VERSIONS_TRUTHVERTEXCONTAINER_V1_H + +// EDM include(s): +#include "AthContainers/DataVector.h" + +// Local include(s): +#include "xAODTruth/versions/TruthVertex_v1.h" +#include "xAODTruth/TruthVertexContainerFwd.h" // Only as long as this is the most recent version... + +namespace xAOD { + // Alias + typedef DataVector< TruthVertex_v1 > TruthVertexContainer_v1; +} + +#endif // XAODTRUTH_VERSIONS_TRUTHVERTEXCONTAINER_V1_H diff --git a/xAOD/xAODTruth/xAODTruth/versions/TruthVertex_v1.h b/xAOD/xAODTruth/xAODTruth/versions/TruthVertex_v1.h new file mode 100644 index 0000000000000000000000000000000000000000..ce94b368d48d92efebe67e0d4ca10101b626effe --- /dev/null +++ b/xAOD/xAODTruth/xAODTruth/versions/TruthVertex_v1.h @@ -0,0 +1,153 @@ +// -*- C++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthVertex_v1.h 624338 2014-10-27 15:08:55Z krasznaa $ +#ifndef XAODTRUTH_VERSIONS_TRUTHVERTEX_V1_H +#define XAODTRUTH_VERSIONS_TRUTHVERTEX_V1_H + +// ROOT include(s): +#include <TLorentzVector.h> + +// EDM include(s): +#include "AthContainers/AuxElement.h" +#include "AthLinks/ElementLink.h" + +// xAOD include(s): +#include "xAODBase/ObjectType.h" + +// Local include(s): +#include "xAODTruth/TruthParticleContainerFwd.h" + +namespace xAOD { + + /// Class describing a truth vertex in the MC record + /// + /// The xAOD truth record mimicks the structure of HepMC. Truth particles + /// and truth vertices form a decay tree. Where each truth particle is + /// connected to a single production and decay vertex. And each vertex is + /// connected to one or more incoming, and one or more outgoing particles. + /// + /// @author Andy Buckley <Andy.Buckley@cern.ch> + /// + /// $Revision: 624338 $ + /// $Date: 2014-10-27 16:08:55 +0100 (Mon, 27 Oct 2014) $ + /// + class TruthVertex_v1 : public SG::AuxElement { + + public: + /// Default constructor + TruthVertex_v1(); + + /// @name Functions identifying the vertex in the MC record + /// @{ + + /// Set vertex ID code + void setId( int value ); + /// Vertex ID code + int id() const; + + /// Set barcode + void setBarcode( int value ); + /// Barcode + int barcode() const; + + /// @} + + /// @name Links to the particles associated with this vertex + /// @{ + + /// Type of one truth particle link + typedef ElementLink< TruthParticleContainer > TPLink_t; + /// Type used to save the links to incoming and outgoing particles + typedef std::vector< TPLink_t > TPLinks_t; + + /// Get all the incoming particles + const TPLinks_t& incomingParticleLinks() const; + /// Set all the incoming particles + void setIncomingParticleLinks( const TPLinks_t& links ); + /// Get the number of incoming particles + size_t nIncomingParticles() const; + /// Get one of the incoming particles + const TruthParticle_v1* incomingParticle( size_t index ) const; + /// Add one incoming particle + void addIncomingParticleLink( const TPLink_t& link ); + /// Remove all incoming particles + void clearIncomingParticleLinks(); + + /// Get all the outgoing particles + const TPLinks_t& outgoingParticleLinks() const; + /// Set all the outgoing particles + void setOutgoingParticleLinks( const TPLinks_t& links ); + /// Get the number of outgoing particles + size_t nOutgoingParticles() const; + /// Get one of the outgoing particles + const TruthParticle_v1* outgoingParticle( size_t index ) const; + /// Add one outgoing particle + void addOutgoingParticleLink( const TPLink_t& link ); + /// Remove all outgoing particles + void clearOutgoingParticleLinks(); + + /// @} + + /// @name Vertex position functions + /// @{ + + /// Vertex x displacement + float x() const; + /// Set the x displacement of the vertex + void setX( float value ); + + /// Vertex y displacement + float y() const; + /// Set the y displacement of the vertex + void setY( float value ); + + /// Vertex longitudinal distance along the beam line form the origin + float z() const; + /// Set the vertex's longitudinal distance from the origin + void setZ( float value ); + + /// Vertex transverse distance from the beam line + float perp() const; + /// Vertex pseudorapidity + float eta() const; + /// Vertex azimuthal angle + float phi() const; + + /// Vertex time + float t() const; + /// Set the vertex time + void setT( float value ); + + /// The 4-vector type + typedef TLorentzVector FourVec_t; + + /// The full 4-vector of the vertex + const FourVec_t& v4() const; + + /// @} + + /// The type of the object as a simple enumeration + Type::ObjectType type() const; + + /// Function making sure that the object is ready for persistification + void toPersistent(); + + private: + /// Cached four vector + mutable FourVec_t m_v4; + /// Flag showing whether the four-vector is cached + mutable bool m_v4Cached; + + }; // class TruthVertex_v1 + +} // namespace xAOD + +// Declare the inheritance of the type to StoreGate: +#include "xAODCore/BaseInfo.h" +SG_BASE( xAOD::TruthVertex_v1, SG::AuxElement ); + +#endif // XAODTRUTH_VERSIONS_TRUTHVERTEX_V1_H