diff --git a/Projects/Calypso/package_filters.txt b/Projects/Calypso/package_filters.txt index 1eaecdb54f06cd6c309f009f84ae1e0bffa5ddb1..5e7804ee05b89fabc0506e40320b750890cb10c7 100644 --- a/Projects/Calypso/package_filters.txt +++ b/Projects/Calypso/package_filters.txt @@ -9,4 +9,4 @@ - Database/.* - DetectorDescription/.* - Scintillator/.* -- Tracker/TrackerDetDescr/.* \ No newline at end of file +- Tracker/.* \ No newline at end of file diff --git a/xAOD/xAODBase/CMakeLists.txt b/xAOD/xAODBase/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..866ebe3bf79054080bdd85fed766f956f862ee4c --- /dev/null +++ b/xAOD/xAODBase/CMakeLists.txt @@ -0,0 +1,42 @@ +# $Id: CMakeLists.txt 744422 2016-05-03 11:34:39Z krasznaa $ +################################################################################ +# Package: xAODBase +################################################################################ + +# Declare the package name: +atlas_subdir( xAODBase ) + +# Extra dependencies based on what environment we are in: +if( NOT XAOD_STANDALONE ) + set( extra_deps Control/SGTools ) + set( extra_libs SGTools ) +endif() + +# Declare the package's dependencies: +atlas_depends_on_subdirs( + PUBLIC + Control/AthContainers + ${extra_deps} + PRIVATE + Control/AthLinks ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Physics ) + +# Component(s) in the package: +atlas_add_library( xAODBase + xAODBase/*.h Root/*.cxx + PUBLIC_HEADERS xAODBase + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} AthContainers ${extra_libs} + PRIVATE_LINK_LIBRARIES AthLinks ) + +atlas_add_dictionary( xAODBaseDict + xAODBase/xAODBaseDict.h + xAODBase/selection.xml + LINK_LIBRARIES xAODBase ) + +# Test(s) in the package: +atlas_add_test( ut_xAODObjectType_test + SOURCES test/ut_xAODObjectType_test.cxx + LINK_LIBRARIES xAODBase ) diff --git a/xAOD/xAODBase/Root/IParticleHelpers.cxx b/xAOD/xAODBase/Root/IParticleHelpers.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1350ca88bb59ed6d4de2d8993edd7ea3ea645aa5 --- /dev/null +++ b/xAOD/xAODBase/Root/IParticleHelpers.cxx @@ -0,0 +1,161 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: IParticleHelpers.cxx 700032 2015-10-12 11:38:33Z krasznaa $ + +// System include(s): +#include <iostream> + +// EDM include(s): +#include "AthLinks/ElementLink.h" + +// Local include(s): +#include "xAODBase/IParticleHelpers.h" + +namespace xAOD { + + /// Object used for setting/getting the dynamic decoration in question + static SG::AuxElement::Accessor< ElementLink< IParticleContainer > > + acc( "originalObjectLink" ); + + /// This function should be used by CP tools when they make a deep copy + /// of an object in their correctedCopy(...) function. So that the deep + /// copy would hold an ElementLink pointing back to its original, which + /// the MET calculations can use later on. + /// + /// @param original Reference to the original object + /// @param copy Reference to the (deep/shallow) copy of the original object + /// @returns <code>true</code> if the link setting was successful, + /// <code>false</code> if it wasn't + /// + bool setOriginalObjectLink( const IParticle& original, + IParticle& copy ) { + + // We mustn't check for the availability of the decoration on the copied + // object here. Since if the copy is already part of a container, the + // decoration may well exist on it already. But it will not be set to + // anything meaningful yet. + + // Check if the original is part of a container. If not, we can't set + // up a link. + const IParticleContainer* container = + dynamic_cast< const IParticleContainer* >( original.container() ); + if( ! container ) { + std::cerr << "xAOD::setOriginalObjectLink ERROR Original object is " + << "not part of a container" << std::endl; + return false; + } + + // Construct the ElementLink that points back to the original. + // We have to be tricky here. The original itself may already be a + // copy. In which case the new object should point back to the same + // original that "our original" is pointing to. + const ElementLink< IParticleContainer > link = + ( acc.isAvailable( original ) ? + acc( original ) : + ElementLink< IParticleContainer >( *container, original.index() ) ); + + // Now set this link on the copy: + acc( copy ) = link; + + // We were successful: + return true; + } + + /// This function should be used by the users when they make deep/shallow + /// copies of an entire container. It sets up links from all the copied + /// object to their originals. So in later stages of the analysis one can + /// navigate back to them. (This is mostly necessary for proper MET + /// handling.) + /// + /// This function assumes that the original container is *not* a view + /// container, to be able to optimise the code a bit. If you want to use + /// a view container, loop over its elements by hand, and use the version + /// of this function operating on individual xAOD::IParticle objects. + /// + /// @param original Reference to the original container + /// @param copy Reference to the (deep/shallow) copy of the original + /// container + /// @returns <code>true</code> if the link setting was successful, + /// <code>false</code> if it wasn't + /// + bool setOriginalObjectLink( const IParticleContainer& original, + IParticleContainer& copy ) { + + // Check that the containers are of the same size: + if( original.size() != copy.size() ) { + std::cerr << "xAOD::setOriginalObjectLink ERROR Size of original " + << "and copy containers differs" << std::endl; + return false; + } + + // Make sure that the original is not a view container. As the function + // doesn't work correctly for those. + if( original.ownPolicy() != SG::OWN_ELEMENTS ) { + std::cerr << "xAOD::setOriginalObjectLink ERROR Received a view " + << "container" << std::endl; + return false; + } + + // If the containers are empty, we're done: + if( ! copy.size() ) { + return true; + } + + // Create an ElementLink to the first element in the original container. + // To be able to re-use the hashed key of this object in the loop. + const ElementLink< IParticleContainer > refLink( original, 0 ); + + // Loop over the copied container: + IParticleContainer::const_iterator orig_itr = original.begin(); + IParticleContainer::const_iterator orig_end = original.end(); + IParticleContainer::iterator copy_itr = copy.begin(); + // To speed up the loop over large containers a bit, make the decision + // about how to create the links, just once: + if( acc.isAvailable( **orig_itr ) ) { + for( ; orig_itr != orig_end; ++orig_itr, ++copy_itr ) { + // Copy the variable from the original object: + acc( **copy_itr ) = acc( **orig_itr ); + } + } else { + for( ; orig_itr != orig_end; ++orig_itr, ++copy_itr ) { + // Construct the link from scratch: + acc( **copy_itr ) = + ElementLink< IParticleContainer >( refLink.key(), + ( *orig_itr )->index() ); + } + } + + // We were successful: + return true; + } + + /// This function can be used to conveniently get a pointer back to the + /// original object from which a copy was created. If there is no such + /// parent, the function silently returns a null pointer. + /// + /// @param copy The object that should have a parent set on it + /// @returns A pointer to the objects parent if it exists and its available, + /// a null pointer otherwise + /// + const IParticle* getOriginalObject( const IParticle& copy ) { + + // Check if the decoration is available on the object: + if( ! acc.isAvailable( copy ) ) { + return 0; + } + + // Get the link: + const ElementLink< IParticleContainer >& link = acc( copy ); + + // Check if the link is valid: + if( ! link.isValid() ) { + return 0; + } + + // Apparently all is fine: + return *link; + } + +} // namespace xAOD diff --git a/xAOD/xAODBase/Root/ObjectType.cxx b/xAOD/xAODBase/Root/ObjectType.cxx new file mode 100644 index 0000000000000000000000000000000000000000..cfb84e6853322278fd337c620b1657aa403df6a4 --- /dev/null +++ b/xAOD/xAODBase/Root/ObjectType.cxx @@ -0,0 +1,53 @@ +// System include(s): +#include <iostream> + +// Local include(s): +#include "xAODBase/ObjectType.h" + +/// Helper macro for printing the object type as a string +#define PRINT_TYPE( TYPE ) \ + case TYPE: \ + out << #TYPE; \ + break + +/// This function can be used in (debug) printouts to easily show the type +/// name returned by an object. +/// +/// @param out The STL stream to print to +/// @param type The type whose name to print in the stream +/// @returns The same stream that it received +/// +std::ostream& operator<< ( std::ostream& out, xAOD::Type::ObjectType type ) { + + switch( type ) { + + PRINT_TYPE( xAOD::Type::Other ); + + PRINT_TYPE( xAOD::Type::CaloCluster ); + PRINT_TYPE( xAOD::Type::Track ); + PRINT_TYPE( xAOD::Type::NeutralParticle ); + PRINT_TYPE( xAOD::Type::Electron ); + PRINT_TYPE( xAOD::Type::Photon ); + PRINT_TYPE( xAOD::Type::Muon ); + + PRINT_TYPE( xAOD::Type::Vertex ); + + PRINT_TYPE( xAOD::Type::TruthParticle ); + PRINT_TYPE( xAOD::Type::TruthVertex ); + PRINT_TYPE( xAOD::Type::TruthEvent ); + PRINT_TYPE( xAOD::Type::TruthPileupEvent ); + + PRINT_TYPE( xAOD::Type::EventInfo ); + PRINT_TYPE( xAOD::Type::EventFormat ); + + PRINT_TYPE( xAOD::Type::Particle ); + PRINT_TYPE( xAOD::Type::CompositeParticle ); + + default: + out << "UNKNOWN"; + break; + } + + // Return the stream object: + return out; +} diff --git a/xAOD/xAODBase/cmt/Makefile.RootCore b/xAOD/xAODBase/cmt/Makefile.RootCore new file mode 100644 index 0000000000000000000000000000000000000000..eb90d13563386d545435fa7d02ac78ecb49f14db --- /dev/null +++ b/xAOD/xAODBase/cmt/Makefile.RootCore @@ -0,0 +1,24 @@ +# 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 = xAODBase +PACKAGE_PRELOAD = Physics +PACKAGE_CXXFLAGS = +PACKAGE_OBJFLAGS = +PACKAGE_LDFLAGS = +PACKAGE_BINFLAGS = +PACKAGE_LIBFLAGS = +PACKAGE_DEP = AthContainers AthLinks +PACKAGE_TRYDEP = +PACKAGE_CLEAN = +PACKAGE_NOGRID = +PACKAGE_PEDANTIC = 1 +PACKAGE_NOOPT = 0 +PACKAGE_NOCC = 0 +PACKAGE_REFLEX = 1 + +include $(ROOTCOREDIR)/Makefile-common diff --git a/xAOD/xAODBase/cmt/requirements b/xAOD/xAODBase/cmt/requirements new file mode 100644 index 0000000000000000000000000000000000000000..8886e2cbdd84e4aa42f6de90907e8bd7041cdbcf --- /dev/null +++ b/xAOD/xAODBase/cmt/requirements @@ -0,0 +1,31 @@ +package xAODBase +# $Id: requirements 744422 2016-05-03 11:34:39Z krasznaa $ +# + +author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> + +# Base package(s): +use AtlasPolicy AtlasPolicy-* +use AtlasROOT AtlasROOT-* External +use SGTools SGTools-* Control + +# EDM package(s): +use AthContainers AthContainers-* Control + +apply_tag ROOTMathLibs + +library xAODBase ../Root/*.cxx +apply_pattern installed_library + +private + +use AtlasReflex AtlasReflex-* External +use AthLinks AthLinks-* Control + +apply_pattern lcgdict dict=xAODBase selectionfile=selection.xml \ + headerfiles="../xAODBase/xAODBaseDict.h" + +# Set up the test(s): +use TestTools TestTools-* AtlasTest + +apply_pattern UnitTest_run unit_test=ut_xAODObjectType diff --git a/xAOD/xAODBase/doc/mainpage.h b/xAOD/xAODBase/doc/mainpage.h new file mode 100644 index 0000000000000000000000000000000000000000..a13fe15701e55beb5a1a9297a4c112b09131119d --- /dev/null +++ b/xAOD/xAODBase/doc/mainpage.h @@ -0,0 +1,31 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + @mainpage xAODBase package + + @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> + + $Revision: 567380 $ + $Date: 2013-10-28 11:48:26 +0100 (Mon, 28 Oct 2013) $ + + @section xAODBaseOverview Overview + + This is the most base-package of the xAOD EDM. It defines general + interfaces that are used in all parts of the xAOD code. + + @section xAODBaseClasses Main Types + + The main enumerations, definitions and classes of the package are + the following: + - xAOD::Type::ObjectType: Enumeration describing all major xAOD + object types. + - xAOD::IParticle: Interface for all particle-like EDM classes + - xAOD::IParticleContainer: Base class for all the particle-like + containers in the xAOD EDM. + + @htmlinclude used_packages.html + + @include requirements +*/ diff --git a/xAOD/xAODBase/share/ut_xAODObjectType_test.ref b/xAOD/xAODBase/share/ut_xAODObjectType_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..4b97169887aa3febeae8301c2d28af06d3419ad0 --- /dev/null +++ b/xAOD/xAODBase/share/ut_xAODObjectType_test.ref @@ -0,0 +1,2 @@ +xAOD::Type::Track, xAOD::Type::CaloCluster +UNKNOWN diff --git a/xAOD/xAODBase/test/ut_xAODObjectType_test.cxx b/xAOD/xAODBase/test/ut_xAODObjectType_test.cxx new file mode 100644 index 0000000000000000000000000000000000000000..14e31e0ab642450876e904246b94510a34cdbde3 --- /dev/null +++ b/xAOD/xAODBase/test/ut_xAODObjectType_test.cxx @@ -0,0 +1,26 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: ut_xAODObjectType_test.cxx 618658 2014-09-26 09:31:10Z krasznaa $ +// +// This is an extremely simple test to check the health of the output operator +// defined in xAODBase/ObjectType.h. +/// + +// System include(s): +#include <iostream> + +// Local include(s): +#include "xAODBase/ObjectType.h" + +int main() { + + // Print some random values: + std::cout << xAOD::Type::Track << ", " << xAOD::Type::CaloCluster + << std::endl; + std::cout << static_cast< xAOD::Type::ObjectType >( 1500 ) << std::endl; + + // Return gracefully: + return 0; +} diff --git a/xAOD/xAODBase/xAODBase/IParticle.h b/xAOD/xAODBase/xAODBase/IParticle.h new file mode 100644 index 0000000000000000000000000000000000000000..97e598ef97a242465ccf80cae6c8674f85eddf59 --- /dev/null +++ b/xAOD/xAODBase/xAODBase/IParticle.h @@ -0,0 +1,169 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: IParticle.h 604340 2014-07-01 04:04:52Z ssnyder $ +#ifndef XAODBASE_IPARTICLE_H +#define XAODBASE_IPARTICLE_H + +// ROOT include(s): +#include <TLorentzVector.h> + +// EDM include(s): +#include "AthContainers/AuxElement.h" + +// Local include(s): +#include "ObjectType.h" + +/// Namespace holding all the xAOD EDM classes +namespace xAOD { + + /// Class providing the definition of the 4-vector interface + /// + /// All particle-like classes in the xAOD EDM inherit from this simple + /// interface class to make it simple to write generic analysis code + /// for the objects. + /// + /// @author Andy Buckley <Andy.Buckley@cern.ch> + /// @author Till Eifert <Till.Eifert@cern.ch> + /// @author Markus Elsing <Markus.Elsing@cern.ch> + /// @author Dag Gillberg <Dag.Gillberg@cern.ch> + /// @author Karsten Koeneke <karstenkoeneke@gmail.com> + /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> + /// @author Edward Moyse <Edward.Moyse@cern.ch> + /// + /// $Revision: 604340 $ + /// $Date: 2014-07-01 06:04:52 +0200 (Tue, 01 Jul 2014) $ + /// + class IParticle : public SG::AuxElement { + + public: + /// Virtual destructor, to make vtable happy... + virtual ~IParticle() {} + + + /// @name Functions describing the 4-momentum of the object + /// @{ + + /// The transverse momentum (\f$p_T\f$) of the particle + virtual double pt() const = 0; + /// The pseudorapidity (\f$\eta\f$) of the particle + virtual double eta() const = 0; + /// The azimuthal angle (\f$\phi\f$) of the particle + virtual double phi() const = 0; + /// The invariant mass of the particle + virtual double m() const = 0; + /// The total energy of the particle + virtual double e() const = 0; + /// The true rapidity (y) of the particle + virtual double rapidity() const = 0; + + /// Definition of the 4-momentum type + typedef TLorentzVector FourMom_t; + + /// The full 4-momentum of the particle + virtual const FourMom_t& p4() const = 0; + + /// @} + + + /// The type of the object as a simple enumeration + virtual Type::ObjectType type() const = 0; + + + /// @name Functions for getting and setting user properties + /// @{ + + /// Fetch an aux data variable, as a non-const reference + /// + /// This function provides an easy way for users to decorate objects + /// with auxiliary data. + /// + /// Take note that this function is slow. Should not be used inside + /// time-critical code. + /// + /// @param name Name of the aux variable + /// @param clsname The name of the associated class. May be blank + /// @returns A modifyable reference to the decoration + /// + template< class T > + T& auxdata( const std::string& name, + const std::string& clsname = "" ) { + + return SG::AuxElement::auxdata< T >( name, clsname ); + } + + /// Fetch an aux data variable, as a const reference + /// + /// This function provides an easy way for users to retrieve auxiliary + /// decorations from an object. + /// + /// Take note that this function is slow. Should not be used inside + /// time-critical code. + /// + /// @param name Name of the aux variable + /// @param clsname The name of the associated class. May be blank + /// @returns A constant reference to the decoration + /// + template< class T > + const T& auxdata( const std::string& name, + const std::string& clsname = "" ) const { + + return SG::AuxElement::auxdata< T >( name, clsname ); + } + + /// Check if a user property is available for reading or not + /// + /// This function should be used to check if a user property which + /// may or may not exist, is set on the object. + /// + /// @param name Name of the auxiliary variable + /// @param clsname The name of the associated class. May be blank + /// @returns Whether the decoration exists or not + /// + template< class T > + bool isAvailable( const std::string& name, + const std::string& clsname = "" ) const { + + return SG::AuxElement::isAvailable< T >( name, clsname ); + } + + /// Check if a user property is available for writing or not + /// + /// This function can be used to check whether it will be possible to + /// set a user property on the object. + /// + /// @param name Name of the auxiliary variable + /// @param clsname The name of the associated class. May be blank + /// @returns Whether the decoration is possible to set + /// + template< class T > + bool isAvailableWritable( const std::string& name, + const std::string& clsname = "" ) const { + + return SG::AuxElement::isAvailableWritable< T >( name, clsname ); + } + + /// @} + + + protected: + // Hide some functions from the regular xAOD users + using SG::AuxElement::getConstStore; + using SG::AuxElement::getStore; + + // Hide the Accessor class from the regular xAOD users + using SG::AuxElement::Accessor; + + }; // class IParticle + +} // namespace xAOD + +#ifndef XAOD_STANDALONE +#include "SGTools/BaseInfo.h" +SG_BASE (xAOD::IParticle, SG::AuxElement); +#endif // not XAOD_STANDALONE + +#endif // XAODBASE_IPARTICLE_H diff --git a/xAOD/xAODBase/xAODBase/IParticleContainer.h b/xAOD/xAODBase/xAODBase/IParticleContainer.h new file mode 100644 index 0000000000000000000000000000000000000000..eef2cac5f653486eac3c943f305b1c9e2ad13667 --- /dev/null +++ b/xAOD/xAODBase/xAODBase/IParticleContainer.h @@ -0,0 +1,42 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: IParticleContainer.h 567380 2013-10-28 10:48:26Z krasznaa $ +#ifndef XAODBASE_IPARTICLECONTAINER_H +#define XAODBASE_IPARTICLECONTAINER_H + +// EDM include(s): +#include "AthContainers/DataVector.h" + +// Local include(s): +#include "xAODBase/IParticle.h" + +namespace xAOD { + + /// Simple convenience declaration of IParticleContainer + /// + /// Note that this structure should be used with care. It should + /// mainly be used in tool interfaces, and nowhere else. For instance + /// it is possible to put view containers of this type into StoreGate, + /// but it is not possible to write out an object of this type into + /// an output file. + /// + /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> + /// + /// $Revision: 567380 $ + /// $Date: 2013-10-28 11:48:26 +0100 (Mon, 28 Oct 2013) $ + /// + typedef DataVector< IParticle > IParticleContainer; + +} // namespace xAOD + +// To make it possible to put IParticleContainers into StoreGate: +#ifndef XAOD_STANDALONE +#include "SGTools/CLASS_DEF.h" +CLASS_DEF( xAOD::IParticleContainer, 1241842700, 1 ) +#endif // not XAOD_STANDALONE + +#endif // XAODBASE_IPARTICLECONTAINER_H diff --git a/xAOD/xAODBase/xAODBase/IParticleHelpers.h b/xAOD/xAODBase/xAODBase/IParticleHelpers.h new file mode 100644 index 0000000000000000000000000000000000000000..707cd033a0f3111bb3eec716a5fa755258194cc2 --- /dev/null +++ b/xAOD/xAODBase/xAODBase/IParticleHelpers.h @@ -0,0 +1,30 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: IParticleHelpers.h 618909 2014-09-29 10:16:52Z krasznaa $ +#ifndef XAODBASE_IPARTICLEHELPERS_H +#define XAODBASE_IPARTICLEHELPERS_H + +// Local include(s): +#include "xAODBase/IParticle.h" +#include "xAODBase/IParticleContainer.h" + +namespace xAOD { + + /// Function setting a link on a deep copy back to its original object + bool setOriginalObjectLink( const IParticle& original, + IParticle& copy ); + + /// Function setting links on a deep/shallow copy container to the originals + bool setOriginalObjectLink( const IParticleContainer& original, + IParticleContainer& copy ); + + /// Function getting a pointer to the original object from a deep/shallow copy + const IParticle* getOriginalObject( const IParticle& copy ); + +} // namespace xAOD + +#endif // XAODBASE_IPARTICLEHELPERS_H diff --git a/xAOD/xAODBase/xAODBase/ObjectType.h b/xAOD/xAODBase/xAODBase/ObjectType.h new file mode 100644 index 0000000000000000000000000000000000000000..657a09ffa4baf4004c5ab2f4df2de71a9ba7bca9 --- /dev/null +++ b/xAOD/xAODBase/xAODBase/ObjectType.h @@ -0,0 +1,91 @@ +// $Id: ObjectType.h 618658 2014-09-26 09:31:10Z krasznaa $ +#ifndef XAODBASE_OBJECTTYPE_H +#define XAODBASE_OBJECTTYPE_H + +// System include(s): +#include <iosfwd> + +namespace xAOD { + + /// Namespace for the xAOD object types + /// + /// The reason for introducing an extra namespace like this is so the users + /// will write things like + /// <code>if( mypart->type() == xAOD::Type::Muon ) {...}</code> + /// instead of using <code>xAOD::MuonType</code> or something similar. + /// + namespace Type { + + /// Type of objects that have a representation in the xAOD EDM + /// + /// xAOD classes identify themselves by all of them providing a function + /// with the signature: + /// + /// <code> + /// xAOD::Type::ObjectType type() const; + /// </code> + /// + /// This can be used to easily identify what sort of object some generic + /// code is dealing with, avoiding doing a lot of + /// <code>dynamic_cast</code>-s instead. + /// + /// Note that Doxygen doesn't allow to group enumeration variables + /// together like it does for members of a class, that's why the grouping + /// comments are not created according to the Doxygen rules. + /// + enum ObjectType { + + Other = 0, ///< An object not falling into any of the other categories + + // Reconstructed particle types + // { + + CaloCluster = 1, ///< The object is a calorimeter cluster + + Track = 2, ///< The object is a charged track particle + NeutralParticle = 3, ///< The object is a neutral particle + + Electron = 4, ///< The object is an electron + Photon = 5, ///< The object is a photon + Muon = 6, ///< The object is a muon + + // } + + // Reconstructed non-particle types + // { + + Vertex = 101, ///< The object is a vertex + + // } + + // Truth types + // { + + TruthParticle = 201, ///< The object is a truth particle + TruthVertex = 202, ///< The object is a truth vertex + TruthEvent = 203, ///< The object is a truth event + TruthPileupEvent = 204, ///< The object is a truth pileup event + + // } + + // Auxiliary types + // { + + EventInfo = 1001, ///< The object is an event information one + EventFormat = 1002, ///< The object is an event format one + + Particle = 1101, ///< Generic particle object, for analysis + CompositeParticle = 1102 ///< Particle composed of other particles + + // } + + }; // enum ObjectType + + } // namespace Type + +} // namespace xAOD + +/// Convenience operator for printing the object type in a (debug) message +std::ostream& operator<< ( std::ostream& out, xAOD::Type::ObjectType type ); + +#endif // XAODBASE_OBJECTTYPE_H diff --git a/xAOD/xAODBase/xAODBase/selection.xml b/xAOD/xAODBase/xAODBase/selection.xml new file mode 100644 index 0000000000000000000000000000000000000000..b85d3b28a25a37140c0015e1c86d728f77871f61 --- /dev/null +++ b/xAOD/xAODBase/xAODBase/selection.xml @@ -0,0 +1,33 @@ +<!-- $Id: selection.xml 618909 2014-09-29 10:16:52Z krasznaa $ --> +<lcgdict> + + <!-- All the dictionaries for xAOD::IParticle: --> + <class name="xAOD::IParticle" /> + <class name="xAOD::IParticleContainer" /> + <class name="std::vector<xAOD::IParticle*>" /> + + <!-- All smart pointer dictionaries for xAOD::IParticle --> + <class name="DataLink<xAOD::IParticleContainer>" /> + <class name="std::vector<DataLink<xAOD::IParticleContainer> >" /> + + <class name="ElementLink<xAOD::IParticleContainer>" /> + <class name="std::vector<ElementLink<xAOD::IParticleContainer> >" /> + <class name="std::vector<std::vector<ElementLink<xAOD::IParticleContainer> > >" /> + + <class name="ElementLinkVector<xAOD::IParticleContainer>" /> + <class name="std::vector<ElementLinkVector<xAOD::IParticleContainer> >" /> + + <!-- An attempt to make the ObjectType enumeration visible in Python... --> + <enum name="xAOD::Type::ObjectType" /> + + <!-- The helper functions: --> + <function pattern="xAOD::*" /> + + <!-- Suppress the unwanted classes found by ROOT 6. --> + <!-- Hopefully we can remove these extra lines at one point... --> + <exclusion> + <class name="SG::IConstAuxStore" /> + <class name="DataLink<SG::IConstAuxStore>" /> + </exclusion> + +</lcgdict> diff --git a/xAOD/xAODBase/xAODBase/xAODBaseDict.h b/xAOD/xAODBase/xAODBase/xAODBaseDict.h new file mode 100644 index 0000000000000000000000000000000000000000..33067c7bfd1b83bcf846eacc86cda9ae55b3a409 --- /dev/null +++ b/xAOD/xAODBase/xAODBase/xAODBaseDict.h @@ -0,0 +1,108 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: xAODBaseDict.h 618909 2014-09-29 10:16:52Z krasznaa $ +#ifndef XAODBASE_XAODBASEDICT_H +#define XAODBASE_XAODBASEDICT_H + +// STL include(s): +#include <vector> + +// EDM include(s): +#include "AthLinks/DataLink.h" +#include "AthLinks/ElementLink.h" +#include "AthLinks/ElementLinkVector.h" + +// Local include(s): +#include "xAODBase/ObjectType.h" +#include "xAODBase/IParticleContainer.h" +#include "xAODBase/IParticleHelpers.h" + +namespace { + struct GCCXML_DUMMY_INSTANTIATION_XAODBASE { + xAOD::IParticleContainer c1; + DataLink< xAOD::IParticleContainer > l1; + ElementLink< xAOD::IParticleContainer > l2; + ElementLinkVector< xAOD::IParticleContainer > l3; + std::vector< DataLink< xAOD::IParticleContainer > > l4; + std::vector< ElementLink< xAOD::IParticleContainer > > l5; + std::vector< ElementLinkVector< xAOD::IParticleContainer > > l6; + std::vector< std::vector< ElementLink< xAOD::IParticleContainer > > > l7; + }; +} + +template +bool& xAOD::IParticle::auxdata< bool >( const std::string& name, + const std::string& clsname = "" ); + +template +float& xAOD::IParticle::auxdata< float >( const std::string& name, + const std::string& clsname = "" ); + +template +int& xAOD::IParticle::auxdata< int >( const std::string& name, + const std::string& clsname = "" ); + +template +unsigned int& +xAOD::IParticle::auxdata< unsigned int >( const std::string& name, + const std::string& clsname = "" ); + +template +uint8_t& xAOD::IParticle::auxdata< uint8_t >( const std::string& name, + const std::string& clsname = "" ); + +template +const bool& +xAOD::IParticle::auxdata< bool >( const std::string& name, + const std::string& clsname = "" ) const; + +template +const float& +xAOD::IParticle::auxdata< float >( const std::string& name, + const std::string& clsname = "" ) const; + +template +const int& +xAOD::IParticle::auxdata< int >( const std::string& name, + const std::string& clsname = "" ) const; + +template +const unsigned int& +xAOD::IParticle::auxdata< unsigned int >( const std::string& name, + const std::string& clsname = "" ) const; + +template +const uint8_t& +xAOD::IParticle::auxdata< uint8_t >( const std::string& name, + const std::string& clsname = "" ) const; + +template +bool +xAOD::IParticle::isAvailable< bool >( const std::string& name, + const std::string& clsname = "" ) const; + +template +bool +xAOD::IParticle::isAvailable< float >( const std::string& name, + const std::string& clsname = "" ) const; + +template +bool +xAOD::IParticle::isAvailable< int >( const std::string& name, + const std::string& clsname = "" ) const; + +template +bool +xAOD::IParticle::isAvailable< unsigned int >( const std::string& name, + const std::string& clsname = "" ) const; + +template +bool +xAOD::IParticle::isAvailable< uint8_t >( const std::string& name, + const std::string& clsname = "" ) const; + +#endif // XAODBASE_XAODBASEDICT_H diff --git a/xAOD/xAODTracking/CMakeLists.txt b/xAOD/xAODTracking/CMakeLists.txt index 0af665fab93b84a0a687755682cc8fcf9e55f71e..a0e7480507737d3bdd5835df695c975f1c5081dc 100755 --- a/xAOD/xAODTracking/CMakeLists.txt +++ b/xAOD/xAODTracking/CMakeLists.txt @@ -7,6 +7,7 @@ atlas_depends_on_subdirs( PUBLIC Control/AthContainers Control/AthLinks + Event/xAOD/xAODBase Event/xAOD/xAODCore ${extra_deps} ) @@ -19,7 +20,7 @@ atlas_add_library( xAODTracking xAODTracking/*.h Root/*.cxx PUBLIC_HEADERS xAODTracking INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} - LINK_LIBRARIES ${EIGEN_LIBRARIES} ${ROOT_LIBRARIES} AthContainers AthLinks xAODCore ${extra_libs} ) + LINK_LIBRARIES ${EIGEN_LIBRARIES} ${ROOT_LIBRARIES} AthContainers AthLinks xAODBase xAODCore ${extra_libs} ) atlas_add_dictionary( xAODTrackingDict xAODTracking/xAODTrackingDict.h @@ -36,7 +37,6 @@ atlas_add_test( xAODTracking_StripRawData_test SOURCES test/xAODTracking_StripRawData_test.cxx LINK_LIBRARIES xAODTracking ) -atlas_add_test( xAODTracking_TrackParticlexAODHelpers_test - SOURCES test/xAODTracking_TrackParticlexAODHelpers_test.cxx - LINK_LIBRARIES xAODTracking - EXTRA_PATTERNS "^DEBUG" ) \ No newline at end of file +atlas_add_test( xAODTracking_Track_test + SOURCES test/xAODTracking_Track_test.cxx + LINK_LIBRARIES xAODTracking ) \ No newline at end of file diff --git a/xAOD/xAODTracking/Root/Track.cxx b/xAOD/xAODTracking/Root/Track.cxx index bd2c2c8d376fb563353246f4941043c7789acf68..2412c7f5b3f3c14d9148ecfe63430d0af6637655 100644 --- a/xAOD/xAODTracking/Root/Track.cxx +++ b/xAOD/xAODTracking/Root/Track.cxx @@ -7,11 +7,7 @@ // Local include(s): #include "xAODTracking/Track.h" -#include "xAODTracking/TrackSummaryAccessors_v1.h" -#include "EventPrimitives/EventPrimitivesHelpers.h" - -// Amg include -//#include "EventPrimitives/EventPrimitives.h" +#include "xAODTracking/TrackSummaryAccessors.h" namespace xAOD { @@ -38,16 +34,27 @@ namespace xAOD { Track::~Track(){ } - double Track::p() const { - return p4().P(); + double Track::pt() const { + return p4().Pt(); } - + + double Track::eta() const { + return p4().Eta(); + } + + double Track::phi() const { + return p4().Phi(); + } + double Track::m() const { - return p4().M(); + return p4().M(); } - + double Track::e() const { - return p4().E(); + return p4().E(); + } + double Track::rapidity() const { + return p4().Rapidity(); } const Track::FourMom_t& Track::p4() const { @@ -71,7 +78,7 @@ namespace xAOD { } Type::ObjectType Track::type() const { - return Type::TrackParticle; + return Type::Track; } float Track::charge() const { @@ -80,28 +87,24 @@ namespace xAOD { AUXSTORE_PRIMITIVE_GETTER(Track, float, x0) AUXSTORE_PRIMITIVE_GETTER(Track, float, y0) + AUXSTORE_PRIMITIVE_GETTER(Track, float, phi0) AUXSTORE_PRIMITIVE_GETTER(Track, float, theta) AUXSTORE_PRIMITIVE_GETTER(Track, float, qOverP) const DefiningParameters_t Track::definingParameters() const{ DefiningParameters_t tmp; - tmp << d0() , z0() , phi0() , theta() , qOverP(); + tmp << x0() , y0() , phi0() , theta() , qOverP(); return tmp; } - void Track::setDefiningParameters(float d0, float z0, float phi0, float theta, float qOverP) { - m_perigeeCached=false; -#if ( ! defined(XAOD_STANDALONE) ) && ( ! defined(XAOD_MANACORE) ) - delete m_perigeeParameters; - m_perigeeParameters=0; -#endif // not XAOD_STANDALONE and not XAOD_MANACORE - static Accessor< float > acc1( "d0" ); - acc1( *this ) = d0; + void Track::setDefiningParameters(float x0, float y0, float phi0, float theta, float qOverP) { + static Accessor< float > acc1( "x0" ); + acc1( *this ) = x0; - static Accessor< float > acc2( "z0" ); - acc2( *this ) = z0; + static Accessor< float > acc2( "y0" ); + acc2( *this ) = y0; - static Accessor< float > acc3( "phi" ); + static Accessor< float > acc3( "phi0" ); acc3( *this ) = phi0; static Accessor< float > acc4( "theta" ); @@ -115,20 +118,15 @@ namespace xAOD { } void Track::setDefiningParametersCovMatrix(const xAOD::ParametersCovMatrix_t& cov){ - m_perigeeCached=false; -#if ( ! defined(XAOD_STANDALONE) ) && ( ! defined(XAOD_MANACORE) ) - delete m_perigeeParameters; - m_perigeeParameters=0; -#endif // not XAOD_STANDALONE and not XAOD_MANACORE static Accessor< std::vector<float> > acc( "definingParametersCovMatrix" ); - Amg::compress(cov,acc(*this)); + FMath::compress(cov,acc(*this)); } const xAOD::ParametersCovMatrix_t Track::definingParametersCovMatrix() const { xAOD::ParametersCovMatrix_t cov; const std::vector<float>& covVec = definingParametersCovMatrixVec(); - if( !covVec.empty() ) Amg::expand( covVec.begin(), covVec.end(),cov ); + if( !covVec.empty() ) FMath::expand( covVec.begin(), covVec.end(),cov ); else cov.setIdentity(); return cov; } @@ -160,43 +158,6 @@ namespace xAOD { acc3( *this ) = z; } -#if ( ! defined(XAOD_STANDALONE) ) && ( ! defined(XAOD_MANACORE) ) - const Trk::Perigee& Track::perigeeParameters() const { - if (m_perigeeCached) - return *m_perigeeParameters; - m_perigeeCached=true; - - static Accessor< float > acc1( "d0" ); - static Accessor< float > acc2( "z0" ); - static Accessor< float > acc3( "phi" ); - static Accessor< float > acc4( "theta" ); - static Accessor< float > acc5( "qOverP" ); - static Accessor< std::vector<float> > acc6( "definingParametersCovMatrix" ); - ParametersCovMatrix_t* cov = new ParametersCovMatrix_t(definingParametersCovMatrix()); - // cov->setZero(); - // auto it= acc6(*this).begin(); - // for (size_t irow = 0; irow<5; ++irow) - // for (size_t icol =0; icol<=irow; ++icol) - // cov->fillSymmetric(irow,icol,*it++) ; - static Accessor< float > acc7( "beamlineTiltX" ); - static Accessor< float > acc8( "beamlineTiltY" ); - - if(!acc7.isAvailable( *this ) || !acc8.isAvailable( *this )){ - m_perigeeParameters = new Trk::Perigee(acc1(*this),acc2(*this),acc3(*this),acc4(*this),acc5(*this),Trk::PerigeeSurface(Amg::Vector3D(vx(),vy(),vz())),cov); - return *m_perigeeParameters; - } - - Amg::Transform3D * amgTransf = new Amg::Transform3D(); - Amg::Translation3D amgtranslation(vx(),vy(),vz()); - *amgTransf = amgtranslation * Amg::RotationMatrix3D::Identity(); - *amgTransf *= Amg::AngleAxis3D(acc8(*this), Amg::Vector3D(0.,1.,0.)); - *amgTransf *= Amg::AngleAxis3D(acc7(*this), Amg::Vector3D(1.,0.,0.)); - m_perigeeParameters = new Trk::Perigee(acc1(*this),acc2(*this),acc3(*this),acc4(*this),acc5(*this),Trk::PerigeeSurface(amgTransf),cov); - - return *m_perigeeParameters; - } -#endif // not XAOD_STANDALONE and not XAOD_MANACORE - AUXSTORE_PRIMITIVE_GETTER(Track, float, chiSquared) AUXSTORE_PRIMITIVE_GETTER(Track, float, numberDoF) @@ -207,18 +168,10 @@ namespace xAOD { acc2( *this ) = numberDoF; } - AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(Track, float, radiusOfFirstHit, setRadiusOfFirstHit) - AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(Track, uint64_t, identifierOfFirstHit, setIdentifierOfFirstHit) - - AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(Track, float, beamlineTiltX, setBeamlineTiltX) - AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(Track, float, beamlineTiltY, setBeamlineTiltY) - + static SG::AuxElement::Accessor< Track::StripClusterLinks_t > clusterAcc( "clusterLinks" ); + AUXSTORE_OBJECT_SETTER_AND_GETTER( Track, Track::StripClusterLinks_t, clusterLinks, setClusterLinks ) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(Track, uint32_t, hitPattern, setHitPattern) - AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(Track, uint8_t,numberOfUsedHitsdEdx ,setNumberOfUsedHitsdEdx ) - - AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(Track, uint8_t,numberOfIBLOverflowsdEdx , setNumberOfIBLOverflowsdEdx) - size_t Track::numberOfParameters() const{ ///@todo - Can we do this in a better way? Not great to force retrieval of one specific parameter - any would do. static Accessor< std::vector<float> > acc( "parameterX" ); @@ -304,7 +257,7 @@ namespace xAOD { // copy the correct values into the temp matrix xAOD::ParametersCovMatrix_t tmp; std::vector<float>::const_iterator it = acc(*this).begin()+offset; - Amg::expand(it,it+15,tmp); + FMath::expand(it,it+15,tmp); return tmp; } @@ -342,69 +295,14 @@ namespace xAOD { acc( *this ).at(index) = static_cast<uint8_t>(pos); } -#if ( ! defined(XAOD_STANDALONE) ) && ( ! defined(XAOD_MANACORE) ) - const Trk::CurvilinearParameters Track::curvilinearParameters(unsigned int index) const { - - static Accessor< std::vector<float> > acc( "trackParameterCovarianceMatrices" ); - unsigned int offset = index*15; - // copy the correct values into the temp matrix - ParametersCovMatrix_t* cov = new ParametersCovMatrix_t(); - auto it = acc(*this).begin()+offset; - Amg::expand(it,it+15,*cov); - // retrieve the parameters to build the curvilinear frame - Amg::Vector3D pos(parameterX(index),parameterY(index),parameterZ(index)); - Amg::Vector3D mom(parameterPX(index),parameterPY(index),parameterPZ(index)); - Trk::CurvilinearParameters param(pos,mom,charge(),cov); - - return param; - } -#endif // not XAOD_STANDALONE and not XAOD_MANACORE - - AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(Track, uint8_t, xAOD::TrackProperties,trackProperties) - AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(Track, uint8_t, xAOD::TrackProperties,trackProperties, setTrackProperties) - AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(Track, uint8_t, xAOD::TrackFitter,trackFitter) AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(Track, uint8_t, xAOD::TrackFitter,trackFitter, setTrackFitter) - std::bitset<xAOD::NumberOfTrackRecoInfo> Track::patternRecoInfo() const { - static Accessor< uint64_t > acc( "patternRecoInfo" ); - std::bitset<xAOD::NumberOfTrackRecoInfo> tmp(acc(*this)); - return tmp; - } - - void Track::setPatternRecognitionInfo(uint64_t patternReco) { - static Accessor< uint64_t > acc( "patternRecoInfo" ); - acc( *this ) = patternReco; - } - - void Track::setPatternRecognitionInfo(const std::bitset<xAOD::NumberOfTrackRecoInfo>& patternReco) { - static Accessor< uint64_t > acc( "patternRecoInfo" ); - #if __cplusplus < 201100 - uint64_t value = 0; - unsigned int i = 0; - unsigned int size=patternReco.size(); - for (;i<32;++i) value |= ((patternReco[i]) << i); - for (i=32;i<size;++i) value |= ((patternReco[i]) << (i-32)); - acc( *this ) = value; - - #else - acc( *this ) = patternReco.to_ullong(); - #endif - } - AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(Track, uint8_t, xAOD::ParticleHypothesis, particleHypothesis, setParticleHypothesis) AUXSTORE_PRIMITIVE_GETTER_WITH_CAST(Track, uint8_t, xAOD::ParticleHypothesis, particleHypothesis) bool Track::summaryValue(uint8_t& value, const SummaryType &information) const { - xAOD::Track::Accessor< uint8_t >* acc = trackSummaryAccessorV1<uint8_t>( information ); - if( ( ! acc ) || ( ! acc->isAvailable( *this ) ) ) return false; - // Retrieve the value: - value = ( *acc )( *this ); - return true; - } - - bool Track::summaryValue(float& value, const SummaryType &information) const { - xAOD::Track::Accessor< float >* acc = trackSummaryAccessorV1<float>( information ); + xAOD::Track::Accessor< uint8_t >* acc = trackSummaryAccessor<uint8_t>( information ); if( ( ! acc ) || ( ! acc->isAvailable( *this ) ) ) return false; // Retrieve the value: value = ( *acc )( *this ); @@ -412,85 +310,9 @@ namespace xAOD { } void Track::setSummaryValue(uint8_t& value, const SummaryType &information){ - xAOD::Track::Accessor< uint8_t >* acc = trackSummaryAccessorV1<uint8_t>( information ); - // Set the value: - ( *acc )( *this ) = value; - } - - void Track::setSummaryValue(float& value, const SummaryType &information){ - xAOD::Track::Accessor< float >* acc = trackSummaryAccessorV1<float>( information ); + xAOD::Track::Accessor< uint8_t >* acc = trackSummaryAccessor<uint8_t>( information ); // Set the value: ( *acc )( *this ) = value; } - - -#if ( ! defined(XAOD_STANDALONE) ) && ( ! defined(XAOD_MANACORE) ) - /// The function will return an invalid ElementLink in case nothing was set - /// for it yet. This is to avoid users having to always check both for - /// the decoration being available, and the link being valid. - /// - /// @returns An element link to the parent Trk::Track of this track particle - /// - const ElementLink< TrackCollection >& Track::trackLink() const { - - // The accessor: - static ConstAccessor< ElementLink< TrackCollection > > acc( "trackLink" ); - - // Check if one of them is available: - if( acc.isAvailable( *this ) ) { - return acc( *this ); - } - - // If no Trk::Track link was not set (yet), return a dummy object: - static const ElementLink< TrackCollection > dummy; - return dummy; - } - - void Track:: - setTrackLink( const ElementLink< TrackCollection >& el ) { - - // The accessor: - static Accessor< ElementLink< TrackCollection > > acc( "trackLink" ); - - // Do the deed: - acc( *this ) = el; - return; - } - - const Trk::Track* Track::track() const{ - - // The accessor: - static ConstAccessor< ElementLink< TrackCollection > > acc( "trackLink" ); - - if( ! acc.isAvailable( *this ) ) { - return 0; - } - if( ! acc( *this ).isValid() ) { - return 0; - } - - return *( acc( *this ) ); - } - -#endif // not XAOD_STANDALONE and not XAOD_MANACORE - - AUXSTORE_OBJECT_SETTER_AND_GETTER( Track, - ElementLink< VertexContainer >, - vertexLink, setVertexLink ) - - const Vertex* Track::vertex() const { - - // The accessor: - static SG::AuxElement::Accessor< ElementLink< VertexContainer > > - acc( "vertexLink" ); - - if( ! acc.isAvailable( *this ) ) { - return 0; - } - if( ! acc( *this ).isValid() ) { - return 0; - } - return *( acc( *this ) ); - } } // namespace xAOD \ No newline at end of file diff --git a/xAOD/xAODTracking/Root/TrackAuxContainer.cxx b/xAOD/xAODTracking/Root/TrackAuxContainer.cxx new file mode 100644 index 0000000000000000000000000000000000000000..93fcb47f62e1f6f116300141a3951fc85dfbcfcc --- /dev/null +++ b/xAOD/xAODTracking/Root/TrackAuxContainer.cxx @@ -0,0 +1,73 @@ +// Local include(s): +#include "xAODTracking/TrackAuxContainer.h" + +namespace xAOD { + + TrackAuxContainer::TrackAuxContainer() + : AuxContainerBase() { + + AUX_VARIABLE( x0 ); + AUX_VARIABLE( y0 ); + AUX_VARIABLE( phi0 ); + AUX_VARIABLE( theta ); + AUX_VARIABLE( qOverP ); + + AUX_VARIABLE( definingParametersCovMatrix ); + + AUX_VARIABLE( vx ); + AUX_VARIABLE( vy ); + AUX_VARIABLE( vz ); + + AUX_VARIABLE( clusterLinks); + AUX_VARIABLE( hitPattern ); + + AUX_VARIABLE( chiSquared ); + AUX_VARIABLE( numberDoF ); + + AUX_VARIABLE( trackFitter ); + AUX_VARIABLE( particleHypothesis ); + + // TrackSummary information +#ifndef XAODTRACK_SUMMARYDYNAMIC + // uint8_ts + AUX_VARIABLE( numberOfContribStripLayers ); + AUX_VARIABLE( numberOfStripHits ); + AUX_VARIABLE( numberOfStripOutliers ); + AUX_VARIABLE( numberOfStripHoles ); + AUX_VARIABLE( numberOfStripDoubleHoles ); + AUX_VARIABLE( numberOfStripSharedHits ); + AUX_VARIABLE( numberOfStripDeadSensors ); + AUX_VARIABLE( numberOfStripSpoiltHits ); + + AUX_VARIABLE( numberOfOutliersOnTrack ); + AUX_VARIABLE( standardDeviationOfChi2OS ); +#endif + + } + + void TrackAuxContainer::dump() const { + std::cout<<" Dumping TrackAuxContainer"<<std::endl; + std::cout<<"x0:"; + std::copy(x0.begin(), x0.end(), + std::ostream_iterator<float>(std::cout, ", ")); + std::cout<<"y0:"; + std::copy(y0.begin(), y0.end(), + std::ostream_iterator<float>(std::cout, ", ")); + std::cout<<"phi0:"; + std::copy(phi0.begin(), phi0.end(), + std::ostream_iterator<float>(std::cout, ", ")); + std::cout<<"theta:"; + std::copy(theta.begin(), theta.end(), + std::ostream_iterator<float>(std::cout, ", ")); + std::cout<<"qOverP:"; + std::copy(qOverP.begin(), qOverP.end(), + std::ostream_iterator<float>(std::cout, ", ")); + std::cout<<"definingParametersCovMatrix: ["<<&definingParametersCovMatrix<<"]"; + for (unsigned int i=0; i<definingParametersCovMatrix.size();++i){ + std::copy(definingParametersCovMatrix[i].begin(), definingParametersCovMatrix[i].end(), + std::ostream_iterator<float>(std::cout, ", ")); + std::cout<<std::endl; + } + } + +} // namespace xAOD diff --git a/xAOD/xAODTracking/Root/TrackSummaryAccessors.cxx b/xAOD/xAODTracking/Root/TrackSummaryAccessors.cxx new file mode 100644 index 0000000000000000000000000000000000000000..d94ee097d53e9416c229634863b16bf80bff4848 --- /dev/null +++ b/xAOD/xAODTracking/Root/TrackSummaryAccessors.cxx @@ -0,0 +1,49 @@ +// System include(s): +extern "C" { +# include <stdint.h> +} +#include <iostream> + +// Local include(s): +#include "xAODTracking/TrackSummaryAccessors.h" + +/// Helper macro for Accessor objects +#define DEFINE_ACCESSOR(TYPE, NAME ) \ + case xAOD::NAME: \ + { \ + static SG::AuxElement::Accessor< TYPE > a( #NAME ); \ + return &a; \ + } \ + break; + +namespace xAOD { + + // Generic case. Maybe return warning? + template<class T> + SG::AuxElement::Accessor< T >* + trackSummaryAccessor( xAOD::SummaryType /*type*/ ) + {} + + template<> + SG::AuxElement::Accessor< uint8_t >* + trackSummaryAccessor<uint8_t>( xAOD::SummaryType type ) { + + switch( type ) { + DEFINE_ACCESSOR( uint8_t, numberOfContribStripLayers ); + DEFINE_ACCESSOR( uint8_t, numberOfStripHits ); + DEFINE_ACCESSOR( uint8_t, numberOfStripOutliers ); + DEFINE_ACCESSOR( uint8_t, numberOfStripHoles ); + DEFINE_ACCESSOR( uint8_t, numberOfStripDoubleHoles ); + DEFINE_ACCESSOR( uint8_t, numberOfStripSharedHits ); + DEFINE_ACCESSOR( uint8_t, numberOfStripDeadSensors ); + DEFINE_ACCESSOR( uint8_t, numberOfStripSpoiltHits ); + + DEFINE_ACCESSOR( uint8_t, numberOfOutliersOnTrack ); + DEFINE_ACCESSOR( uint8_t, standardDeviationOfChi2OS ); + default: + std::cerr << "xAOD::Track ERROR Unknown SummaryType (" + << type << ") requested" << std::endl; + return 0; + } + } +} // namespace xAOD diff --git a/xAOD/xAODTracking/share/xAODTracking_Track_test.ref b/xAOD/xAODTracking/share/xAODTracking_Track_test.ref new file mode 100644 index 0000000000000000000000000000000000000000..8f4fb0652d50f4df057dd14a6d9011da9b0eb8e1 --- /dev/null +++ b/xAOD/xAODTracking/share/xAODTracking_Track_test.ref @@ -0,0 +1,25 @@ +Filling Track +setDefiningParameters +setDefiningParametersCovMatrixVec +setParametersOrigin +setTrackParameters +setParameterPosition +Printing Track +x0 = 1, y0 = 2, phi = 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 TrackAuxContainer +x0:1, y0:2, phi0:1.23, theta:0.5, qOverP:0.25, definingParametersCovMatrix: [0x7ffd160b5370]1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, +x0 = 1, y0 = 2, phi = 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 \ No newline at end of file diff --git a/xAOD/xAODTracking/test/xAODTracking_Track_test.cxx b/xAOD/xAODTracking/test/xAODTracking_Track_test.cxx index 9395da84ef19fa958b7ae896d557545021cd6934..97dc59998d2eaff9bf0e944db3efe00fdd8425da 100644 --- a/xAOD/xAODTracking/test/xAODTracking_Track_test.cxx +++ b/xAOD/xAODTracking/test/xAODTracking_Track_test.cxx @@ -21,10 +21,10 @@ std::ostream& operator<< ( std::ostream& out, } /// Function filling one Track with information -void fill( xAOD::Track& tp ) { - +void fill( xAOD::Track& tp) { + tp.setDefiningParameters( 1.0, 2.0, 1.23, 0.5, 0.25 ); - + std::cout << "setDefiningParameters" << std::endl; static const float covMatrix[ 15 ] = { 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, @@ -33,9 +33,9 @@ void fill( xAOD::Track& tp ) { static const std::vector< float > covMatrixVec( covMatrix, covMatrix + 15 ); tp.setDefiningParametersCovMatrixVec( covMatrixVec ); - + std::cout << "setDefiningParametersCovMatrixVec" << std::endl; tp.setParametersOrigin( 0.0, 1.0, 2.0 ); - + std::cout << "setParametersOrigin" << std::endl; static const float parameters[ 2 ][ 6 ] = { { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }, { 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 } @@ -49,9 +49,11 @@ void fill( xAOD::Track& tp ) { } } tp.setTrackParameters( parametersVec ); + std::cout << "setTrackParameters" << std::endl; tp.setParameterPosition( 0, xAOD::FirstMeasurement ); tp.setParameterPosition( 1, xAOD::CalorimeterEntrance ); + std::cout << "setParameterPosition" << std::endl; return; } @@ -60,7 +62,7 @@ void fill( xAOD::Track& tp ) { void print( const xAOD::Track& tp ) { std::cout << "x0 = " << tp.x0() << ", y0 = " << tp.y0() - << ", phi = " << tp.phi() << ", theta = " << tp.theta() + << ", phi = " << tp.phi0() << ", theta = " << tp.theta() << ", qOverP = " << tp.qOverP() << std::endl; std::cout << "definingParametersCovMatrixVec = " << tp.definingParametersCovMatrixVec() << std::endl; @@ -89,14 +91,14 @@ int main() { xAOD::TrackAuxContainer aux; xAOD::TrackContainer tpc; tpc.setStore( &aux ); - + // Add one track particle to the container: xAOD::Track* p = new xAOD::Track(); tpc.push_back( p ); - + std::cout << "Filling Track" << std::endl; // Fill it with information: fill( *p ); - + std::cout << "Printing Track" << std::endl; // Print the information: print( *p ); diff --git a/xAOD/xAODTracking/xAODTracking/Track.h b/xAOD/xAODTracking/xAODTracking/Track.h index 123257ebc0c2bddc084e680899b88ff3781ef665..f06867b07e5af2fb094bf06612bdc4a3f54e26e9 100644 --- a/xAOD/xAODTracking/xAODTracking/Track.h +++ b/xAOD/xAODTracking/xAODTracking/Track.h @@ -13,6 +13,7 @@ extern "C" { // xAOD include(s): #include "xAODBase/IParticle.h" +#include "xAODTracking/StripClusterContainer.h" #include "xAODTracking/TrackingPrimitives.h" namespace xAOD { @@ -54,7 +55,14 @@ namespace xAOD { /// The type of the object as a simple enumeration virtual Type::ObjectType type() const; /// @} - + + /// @name ElementLinks to StripClusters + /// @{ + typedef std::vector< ElementLink< xAOD::StripClusterContainer > > StripClusterLinks_t; + const StripClusterLinks_t& clusterLinks() const; + void setClusterLinks(const StripClusterLinks_t& clusterLinks); + /// @} + /// @name Defining parameters functions /// The 'defining parameters' are key to the concept of a Track, and give the values for the IParticle interface /// ( pt(), phi(), eta() etc.). @@ -70,8 +78,8 @@ namespace xAOD { float x0() const; /// Returns the \f$y_0\f$ parameter float y0() const; - /// Returns the \f$\phi\f$ parameter, which has range \f$-\pi\f$ to \f$+\pi\f$. - float phi() const; + /// Returns the \f$phi_0\f$ parameter + float phi0() const; /// Returns the \f$\theta\f$ parameter, which has range 0 to \f$\pi\f$. float theta() const; /// Returns the \f$q/p\f$ parameter @@ -85,7 +93,7 @@ namespace xAOD { /// Returns the length 6 vector containing the elements of defining parameters covariance matrix. const std::vector<float>& definingParametersCovMatrixVec() const; /// Set the defining parameters. - void setDefiningParameters(float x0, float y0, float phi, float theta, float qOverP); + void setDefiningParameters(float x0, float y0, float phi0, float theta, float qOverP); /// Set the defining parameters covariance matrix. void setDefiningParametersCovMatrix(const ParametersCovMatrix_t& cov); /// Set the defining parameters covariance matrix using a length 15 vector. @@ -177,7 +185,7 @@ namespace xAOD { /// Method for setting the particle type, using the ParticleHypothesis enum. void setParticleHypothesis(const ParticleHypothesis hypo); /// Returns the particle hypothesis used for Track fitting. - ParticleHypothesis particleHypothesis() const + ParticleHypothesis particleHypothesis() const; /// Returns the fitter. TrackFitter trackFitter() const; /// @} diff --git a/xAOD/xAODTracking/xAODTracking/TrackAuxContainer.h b/xAOD/xAODTracking/xAODTracking/TrackAuxContainer.h index 97f7ffc9785d1ab532602d841dbefbc0bb164b21..867d274768d8f08f14e291bcbca395ae1af3f89a 100644 --- a/xAOD/xAODTracking/xAODTracking/TrackAuxContainer.h +++ b/xAOD/xAODTracking/xAODTracking/TrackAuxContainer.h @@ -12,7 +12,7 @@ extern "C" { #include "AthLinks/ElementLink.h" // Local include(s): -#include "xAODTracking/TrackAuxContainer.h" +#include "xAODTracking/Track.h" namespace xAOD { class TrackAuxContainer : public AuxContainerBase { @@ -29,7 +29,7 @@ namespace xAOD { /// @{ std::vector< float > x0; std::vector< float > y0; - std::vector< float > phi; + std::vector< float > phi0; std::vector< float > theta; std::vector< float > qOverP; @@ -54,6 +54,7 @@ namespace xAOD { std::vector< std::vector<float> > trackParameterCovarianceMatrices; std::vector< std::vector<uint8_t> > parameterPosition; + std::vector< xAOD::Track::StripClusterLinks_t > clusterLinks; std::vector< uint32_t > hitPattern; /// @name Fit quality functions diff --git a/xAOD/xAODTracking/xAODTracking/TrackSummaryAccessors.h b/xAOD/xAODTracking/xAODTracking/TrackSummaryAccessors.h new file mode 100644 index 0000000000000000000000000000000000000000..7e15800eace01216d6352b1aa90d7286950efe55 --- /dev/null +++ b/xAOD/xAODTracking/xAODTracking/TrackSummaryAccessors.h @@ -0,0 +1,30 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TrackSummaryAccessors_v1.h 574227 2013-12-06 14:20:39Z emoyse $ +#ifndef XAOD_TRACKSUMMARYACCESSORS_H +#define XAOD_TRACKSUMMARYACCESSORS_H + +// EDM include(s): +#include "AthContainers/AuxElement.h" + +// Local include(s): +#include "xAODTracking/TrackingPrimitives.h" + +namespace xAOD { + + /// Helper function for managing TrackSummary Accessor objects + /// + /// This function holds on to Accessor objects that can be used by each + /// TrackParticle_v1 object at runtime to get/set summary values on themselves. + /// + template <class T> + SG::AuxElement::Accessor< T >* + trackSummaryAccessor( xAOD::SummaryType type ); + +} // namespace xAOD + +#endif // XAODCALOEVENT_CALOCLUSTERACCESSORS_H diff --git a/xAOD/xAODTracking/xAODTracking/TrackingPrimitives.h b/xAOD/xAODTracking/xAODTracking/TrackingPrimitives.h index d75bce1058668d57fc7e242e654827efdf4aaed5..da9d408d7e0545bbff1627042d4b239d0b70194c 100644 --- a/xAOD/xAODTracking/xAODTracking/TrackingPrimitives.h +++ b/xAOD/xAODTracking/xAODTracking/TrackingPrimitives.h @@ -5,10 +5,41 @@ #include <Eigen/Core> #include <Eigen/Dense> +namespace FMath{ + template <int N> + inline void compress(const Eigen::Matrix<double, N,N,0,N,N>& covMatrix, std::vector<float>& vec) { + int rows = covMatrix.rows(); + for (int i = 0; i < rows; ++i) { + for (int j = 0; j <= i; ++j) { + vec.push_back(covMatrix(i, j)); + } + } + } + + template <int N> + inline void expand(std::vector<float>::const_iterator it, + std::vector<float>::const_iterator it_end, Eigen::Matrix<double, N,N,0,N,N>& covMatrix) { + unsigned int dist = std::distance(it, it_end); + unsigned int n; + for (n = 1; dist > n; ++n) { + dist = dist - n; + } + covMatrix = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>(n, n); + for (unsigned int i = 0; i < n; ++i) { + for (unsigned int j = 0; j <= i; ++j) { + covMatrix(i,j) = *it; + ++it; + } + } + } +} + namespace xAOD { - using DefiningParameters_t Eigen::Matrix<double, 5, 1>; - using ParametersCovMatrix_t Eigen::Matrix<double, 5, 5>; + using DefiningParameters_t = Eigen::Matrix<double, 5, 1>; + using ParametersCovMatrix_t = Eigen::Matrix<double, 5, 5>; + using CurvilinearParameters_t = Eigen::Matrix<double, 6, 1>; + /// Enums to identify who created this track and which properties does it have. enum TrackFitter { @@ -51,7 +82,7 @@ namespace xAOD { /// When adding a new transient information type, please make sure to increase numberOfTrackSummaryTypes.*/ enum SummaryType { // --- Inner Detector - numberOfContribSCTLayers = 1, //!< number of contributing layers of the pixel detector [unit8_t]. + numberOfContribStripLayers = 1, //!< number of contributing layers of the pixel detector [unit8_t]. numberOfStripHits = 2, //!< number of hits in Strip [unit8_t]. numberOfStripOutliers = 3, //!< number of Strip outliers [unit8_t]. numberOfStripHoles = 4, //!< number of Strip holes [unit8_t]. diff --git a/xAOD/xAODTracking/xAODTracking/xAODTrackingDict.h b/xAOD/xAODTracking/xAODTracking/xAODTrackingDict.h index cb4bb673e608ac61b110e1a4c66dbbc5f5e3d7bf..f4cfd8d135a18e0b47d2b78fa8a989b47f80688b 100644 --- a/xAOD/xAODTracking/xAODTracking/xAODTrackingDict.h +++ b/xAOD/xAODTracking/xAODTracking/xAODTrackingDict.h @@ -17,11 +17,10 @@ // EDM include(s): #include "AthLinks/DataLink.h" -#include "AthLinks/ElementLink.h" +#include "AthLinks/ElementLinkVector.h" // Local include(s): #include "xAODTracking/TrackContainer.h" -#include "xAODTracking/TrackContainer.h" #include "xAODTracking/TrackAuxContainer.h" #include "xAODTracking/StripClusterContainer.h"