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

adding truth

parent 486a6ff7
No related branches found
No related tags found
No related merge requests found
Showing
with 1143 additions and 1 deletion
################################################################################
# Package: TruthUtils
################################################################################
# Declare the package name:
atlas_subdir( TruthUtils )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( FastJet )
find_package( HEPUtils )
find_package( HepMC )
find_package( MCUtils )
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
# Component(s) in the package:
atlas_add_library( TruthUtils
Root/*.cxx
PUBLIC_HEADERS TruthUtils
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${HEPUTILS_INCLUDE_DIRS} ${MCUTILS_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${FASTJET_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} ${HEPUTILS_LIBRARIES} ${MCUTILS_LIBRARIES} ${HEPMC_LIBRARIES} ${FASTJET_LIBRARIES} )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#include "TruthUtils/GeneratorName.h"
#include <iostream>
#include <algorithm>
/// @todo This scheme doesn't work anymore...
GeneratorName generator_name (const int& index) {
switch (index) {
//new scheme for first generators
case 110000000 : return PYTHIA;
case 20000000 : return HERWIG;
case 30000000 : return ISAJET;
case 40000000 : return SINGLE;
case 50000000 : return HIJING;
case 60000000 : return PHOJET;
case 70000000 : return Sherpa;
case 80000000 : return CASCADE;
case 90000000 : return JIMMY;
case 100000000 : return HYDJET;
// note 110000000 used for PYTHIA
case 120000000 : return EPOS;
case 100000 : return COMPHEP;
// case 150000 : return CHARYBDIS;
case 200000 : return USER;
case 300000 : return ACERMC;
case 400000 : return ALPGEN;
case 500000 : return MADGRAPH;
case 600000 : return MADCUP;
case 700000 : return TOPREX;
case 800000 : return LHAEXT;
case 900000 : return MCATNLO;
// new second generators in a new scheme
case 1001000000 : return CHARYBDIS;
case 1001100000 : return HORACE;
case 1001200000 : return LHEF;
case 1001300000 : return MATCHIG;
case 1001400000 : return HVGEN;
case 1001500000 : return EXOGRAVITON;
case 1001600000 : return PYTHIABC;
case 1001700000 : return PROTOS;
case 1001800000 : return GRAVADD;
case 1001900000 : return HELAC;
case 1002000000 : return PYTHIASGLUON;
// third generators
case 10000 : return TAUOLA;
case 20000 : return PHOTOS;
case 30000 : return TAUOLA_PHOTOS;
}
return UNKNOWN;
}
GeneratorName first_generator(const int& index) {
int gen1;
if (isNewGenCoding(index)) {
gen1 = 10000000*(index/10000000);
if (gen1 >= 1000000000) gen1=gen1-1000000000;
} else{
// Extract the first generator int representation (/1000000 *1000000)
// and convert to a new scheme (*10)
gen1 = 10000000*(index/1000000);
//special treatment for PYTHIA, as the coding is not standard
if (gen1 == 10000000) gen1=110000000;
}
return generator_name(gen1);
}
GeneratorName second_generator(const int& index) {
int gen1,gen2;
if (isNewGenCoding(index)){
gen1 = first_generator(index);
gen2 = index - gen1;
gen2 = 100000*(gen2/100000);
// if (gen2==100000 && (gen1==2000000 || gen1==9000000)) gen2 += 50000;
} else{
gen1 = 1000000*(index/1000000);
gen2 = index - gen1;
gen2 = 100000*(gen2/100000);
}
return generator_name(gen2);
}
GeneratorName third_generator(const int& index) {
int gen1,gen2,gen3;
if (isNewGenCoding(index)){
gen1 = first_generator(index);
gen2 = second_generator(index);
gen3 = index - gen1 - gen2;
gen3 = 10000*(gen3/10000);
} else{
gen1 = 1000000*(index/1000000);
gen2 = index - gen1;
gen2 = 100000*(gen2/100000);
gen3 = index - gen1 - gen2;
gen3 = 10000*(gen3/10000);
}
return generator_name(gen3);
}
int generator_process(int& index) { return index % 10000; }
void GeneratorName_print(int& id) {
std::cout << first_generator(id) << " "
<< second_generator(id) << " "
<< third_generator(id) << " + "
<< generator_process(id);
}
std::string generator_string(const int& index) {
switch (index) {
case 110000000 : return "PYTHIA";
case 20000000 : return "HERWIG";
case 30000000 : return "ISAJET";
case 40000000 : return "SINGLE";
case 50000000 : return "HIJING";
case 60000000 : return "PHOJET";
case 70000000 : return "Sherpa";
case 80000000 : return "CASCADE";
case 90000000 : return "JIMMY";
case 100000000 : return "HYDJET";
case 120000000 : return "EPOS";
case 100000 : return "COMPHEP";
// case 150000 : return "CHARYBDIS";
case 200000 : return "USER";
case 300000 : return "ACERMC";
case 400000 : return "ALPGEN";
case 500000 : return "MADGRAPH";
case 600000 : return "MADCUP";
case 700000 : return "TOPREX";
case 800000 : return "LHAEXT";
case 900000 : return "MCATNLO";
case 1001000000 : return "CHARYBDIS";
case 1001100000 : return "HORACE";
case 1001200000 : return "LHEF";
case 1001300000 : return "MATCHIG";
case 1001400000 : return "HVGEN";
case 1001500000 : return "EXOGRAVITON";
case 1001600000 : return "PYTHIABC";
case 1001700000 : return "PROTOS";
case 1001800000 : return "GRAVADD";
case 1001900000 : return "HELAC";
case 1002000000 : return "PYTHIASGLUON";
case 10000 : return "TAUOLA";
case 20000 : return "PHOTOS";
case 30000 : return "TAUOLA_PHOTOS";
}
return "";
}
int generator_int (std::string& name) {
/// @note Sherpa cannot be written with capital letters as it interferes with the namespace name from external Sherpa package. EML 11.12.2008
if (name == "sherpa") name = "Sherpa";
else transform(name.begin(), name.end(), name.begin(), toupper);
if ( name == "PYTHIA" ) return 110000000;
if ( name == "HERWIG" ) return 20000000;
if ( name == "ISAJET" ) return 30000000;
if ( name == "SINGLE" ) return 40000000;
if ( name == "HIJING" ) return 50000000;
if ( name == "PHOJET" ) return 60000000;
if ( name == "Sherpa" ) return 70000000;
if ( name == "CASCADE" ) return 80000000;
if ( name == "JIMMY" ) return 90000000;
if ( name == "HYDJET" ) return 100000000;
if ( name == "EPOS" ) return 120000000;
if ( name == "COMPHEP" ) return 100000;
// if ( name == "CHARYBDIS" ) return 150000;
if ( name == "USER" ) return 200000;
if ( name == "ACERMC" ) return 300000;
if ( name == "ALPGEN" ) return 400000;
if ( name == "MADGRAPH" ) return 500000;
if ( name == "MADCUP" ) return 600000;
if ( name == "TOPREX" ) return 700000;
if ( name == "LHAEXT" ) return 800000;
if ( name == "MCATNLO" ) return 900000;
if ( name == "CHARYBDIS" ) return 1001000000;
if (name == "HORACE" ) return 1001100000;
if (name == "LHEF") return 1001200000;
if (name == "MATCHIG") return 1001300000;
if (name == "HVGEN") return 1001400000;
if (name == "EXOGRAVITON") return 1001500000;
if (name == "PYTHIABC") return 1001600000;
if (name == "PROTOS") return 1001700000;
if (name == "GRAVADD") return 1001800000;
if (name == "HELAC") return 1001900000;
if (name == "PYTHIASGLUON") return 1002000000;
if ( name == "TAUOLA" ) return 10000;
if ( name == "PHOTOS" ) return 20000;
if ( name == "TAUOLA_PHOTOS" ) return 30000;
return -999;
}
std::ostream& operator<<(std::ostream& lhs, GeneratorName rhs) {
lhs << generator_string(rhs);
return lhs;
}
bool isNewGenCoding(const int& index) {
if (index < 20000000) return false;
else return true;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRUTHUTILS_GENERATORNAME_H
#define TRUTHUTILS_GENERATORNAME_H
#include <iosfwd>
#include <string>
/// @file GeneratorName.h
/// @brief Enum and tools for decoding generator information from the process code -- yuck!
/// @todo This thing is a mess that completely breaks down with LHE files and new gens. REMOVE!
/// @note Sherpa cannot be used with capital letters as it interferes with the namespace name from external Sherpa package.
/// @note New generators need to be added in genames.inc too EML 12.12.2008
/// @note PYTHIA instead of a special number 1010000000 is now 110000000 (the special number may be used when we run out of other numbers) EML 19.01.2009
enum GeneratorName {
/*
PYTHIA = 1000000,
HERWIG = 2000000,
ISAJET = 3000000,
SINGLE = 4000000,
HIJING = 5000000,
PHOJET = 6000000,
Sherpa = 7000000,
CASCADE = 8000000,
JIMMY = 9000000,
HYDJET = 10000000,
*/
// first generators - new scheme
PYTHIA = 110000000,
HERWIG = 20000000,
ISAJET = 30000000,
SINGLE = 40000000,
HIJING = 50000000,
PHOJET = 60000000,
Sherpa = 70000000,
CASCADE = 80000000,
JIMMY = 90000000,
HYDJET = 100000000,
// note 110000000 used for PYTHIA
EPOS = 120000000,
// second generators
COMPHEP = 100000,
// CHARYBDIS = 150000,
USER = 200000,
ACERMC = 300000,
ALPGEN = 400000,
MADGRAPH = 500000,
MADCUP = 600000,
TOPREX = 700000,
LHAEXT = 800000,
MCATNLO = 900000,
// new second generators - new scheme
CHARYBDIS = 1001000000,
HORACE = 1001100000,
LHEF = 1001200000,
MATCHIG = 1001300000,
HVGEN = 1001400000,
EXOGRAVITON = 1001500000,
PYTHIABC = 1001600000,
PROTOS = 1001700000,
GRAVADD = 1001800000,
HELAC = 1001900000,
PYTHIASGLUON = 1002000000,
// third generators
TAUOLA = 10000,
PHOTOS = 20000,
TAUOLA_PHOTOS = 30000,
UNKNOWN = -999
};
GeneratorName generator_name(const int& index);
GeneratorName first_generator(const int& index);
GeneratorName second_generator(const int& index);
GeneratorName third_generator(const int& index);
int generator_process(int& index);
void GeneratorName_print(int& id);
std::string generator_string(const int& index);
int generator_int(std::string& name);
std::ostream &operator<< (std::ostream& lhs, GeneratorName rhs);
bool isNewGenCoding(const int& index);
#endif // GENERATORMODULES_GENERATORNAME_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#pragma once
/// @file
///
/// Provides the HepMC tools from the external MCUtils header package,
/// ATLAS-specific HepMC functions not suitable for MCUtils.
#include "TruthUtils/PIDHelpers.h"
#include "TruthUtils/TruthParticleHelpers.h"
#include "MCUtils/HepMCUtils.h"
// #include "MCUtils/Clustering.h"
// Common imports from external namespaces
using HepMC::GenEvent;
using HepMC::GenParticle;
using HepMC::GenVertex;
//using fastjet::PseudoJet;
//using fastjet::ClusterSequence;
// Alias BOOST_FOREACH as foreach in this semi-safe way
#include <boost/foreach.hpp>
#ifndef foreach
namespace boost { namespace BOOST_FOREACH = foreach; }
#define foreach BOOST_FOREACH
#endif
namespace MC {
// Use the MCUtils and HEPUtils functions as if they were defined in the ATLAS MC and MC::PID namespaces
using namespace MCUtils;
using namespace HEPUtils;
/// @name Extra ATLAS-specific particle classifier functions
//@{
/// @brief Determine if the particle is stable at the generator (not det-sim) level,
///
/// The receipe for this is barcode < 200k and status = 1. Gen-stable particles decayed by
/// G4 are not set to have status = 2 in ATLAS, but simply have more status = 1 children,
/// with barcodes > 200k.
inline bool isGenStable(const HepMC::GenParticle* p) {
return isGenStable(p->status(), p->barcode());
}
/// @todo There are many kinds of stable: stable from generator, stable at intermediate stage of det sim transport, or stable after all det sim. Need fns for each?
/// @brief Identify if the particle is considered stable at the post-detector-sim stage
inline bool isSimStable(const HepMC::GenParticle* p) {
if (p->status() != 1) return false;
if (isGenStable(p)) return p->end_vertex() == NULL;
return true;
}
/// @brief Identify if the particle is considered stable at the post-detector-sim stage
/// @todo I'm sure this shouldn't be exactly the same as isGenStable, but it is...
/// @deprecated Use isSimulStable: this function _will_ be removed!
inline bool isGenSimulStable(const HepMC::GenParticle* p) {
return isSimStable(p);
}
/// @brief Identify if the particle would not interact with the detector, i.e. not a neutrino or WIMP
inline bool isNonInteracting(const HepMC::GenParticle* p) {
return MC::isNonInteracting(p->pdg_id()); //< From TruthUtils/PIDHelpers.h
}
/// @brief Identify if the particle could interact with the detector during the simulation, e.g. not a neutrino or WIMP
/// @todo This one can't be made to only take a PDG ID argument since it needs to check gen-stability via status & decay links
// inline bool isSimInteracting(int pid) {
// if (! MC::isGenStable(pid)) return false; //skip particles which the simulation would not see
// return !MC::isNonInteracting(pid);
// }
/// @brief Identify if the particle could interact with the detector during the simulation, e.g. not a neutrino or WIMP
inline bool isSimInteracting(const HepMC::GenParticle* p) {
if (! MC::isGenStable(p)) return false; //skip particles which the simulation would not see
return !MC::isNonInteracting(p);
}
/// @brief Oddly-named alias for isSimInteracting
/// @deprecated Use isSimInteracting: this function _will_ be removed!
inline bool isGenInteracting(const HepMC::GenParticle* p) {
return isSimInteracting(p);
}
//@}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#pragma once
/// @file
///
/// PID-only functions with no HepMC dependence, both from MCUtils and ATLAS-specific.
#include "MCUtils/PIDUtils.h"
namespace MC {
// Use the MCUtils and HEPUtils functions as if they were defined in the ATLAS MC and MC::PID namespaces
using namespace MCUtils;
using namespace HEPUtils;
/// @brief Identify if the particle with given PDG ID would not interact with the detector, i.e. not a neutrino or WIMP
inline bool isNonInteracting(int pid) {
return !(PID::isStrongInteracting(pid) || PID::isEMInteracting(pid));
}
/// @brief Identify if the particle with given PDG ID would produce ID tracks but not shower in the detector if stable
inline bool isChargedNonShowering(int pid) {
if (PID::isMuon(pid)) return true;
if (PID::isSUSY(pid)) return true; //(meta)stable charginos, R-hadrons etc
return false;
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#pragma once
/// @file
///
/// Provides the HepMC tools from the external MCUtils header package,
/// ATLAS-specific HepMC functions not suitable for MCUtils.
#include "TruthUtils/PIDHelpers.h"
namespace MC {
// Use the MCUtils and HEPUtils functions as if they were defined in the ATLAS MC and MC::PID namespaces
using namespace MCUtils;
using namespace HEPUtils;
/// @brief Constant defining the barcode threshold distinguishing generator record entries from detector sim ones
/// @todo The sim barcodes start at 1M in MC15, so we should update the 200k threshold,
/// but >= 200k is still a valid test for b = 1M so let's keep it this way until MC12 is long-dead.
const int SIM_BARCODE_THRESHOLD = 200000;
/// @name Extra ATLAS-specific particle classifier functions
//@{
/// @brief Determine if the particle is stable at the generator (not det-sim) level,
///
/// The receipe for this is barcode < 200k and status = 1. Gen-stable particles decayed by
/// G4 are not set to have status = 2 in ATLAS, but simply have more status = 1 children,
/// with barcodes > 200k.
inline bool isGenStable(int status, int barcode) {
if (status != 1) return false;
return barcode < SIM_BARCODE_THRESHOLD;
}
//@}
}
# 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 = TruthUtils
PACKAGE_PRELOAD =
PACKAGE_CXXFLAGS =
PACKAGE_OBJFLAGS =
PACKAGE_LDFLAGS =
PACKAGE_BINFLAGS =
PACKAGE_LIBFLAGS =
PACKAGE_DEP = Asg_Boost
PACKAGE_TRYDEP =
PACKAGE_CLEAN =
PACKAGE_NOGRID =
PACKAGE_PEDANTIC = 0
PACKAGE_NOOPT = 0
PACKAGE_NOCC = 0
PACKAGE_REFLEX = 0
include $(ROOTCOREDIR)/Makefile-common
package TruthUtils
author Andy Buckley
use AtlasPolicy AtlasPolicy-*
use AtlasHepMC AtlasHepMC-* External
use AtlasBoost AtlasBoost-* External
use AtlasFastJet AtlasFastJet-* External
use AtlasROOT AtlasROOT-* External
use MCUtils MCUtils-* External
use HEPUtils HEPUtils-* External
library TruthUtils ../Root/*.cxx
apply_pattern installed_library
...@@ -9,4 +9,4 @@ ...@@ -9,4 +9,4 @@
- Database/.* - Database/.*
- DetectorDescription/.* - DetectorDescription/.*
- Scintillator/.* - Scintillator/.*
- Tracker/TrackerDetDescr/.* - Tracker/.*
\ No newline at end of file \ No newline at end of file
# $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 )
/*
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
// 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;
}
# 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
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
/*
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
*/
xAOD::Type::Track, xAOD::Type::CaloCluster
UNKNOWN
/*
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;
}
// 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
// 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
// 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment