From 4098413b303279d250c88bdd2676f546049edf27 Mon Sep 17 00:00:00 2001 From: Scott Snyder <scott.snyder@cern.ch> Date: Tue, 5 Aug 2014 04:45:52 +0200 Subject: [PATCH] Fix use of ParticleData. (TruthD3PDMaker-00-01-08) --- .../D3PDMaker/TruthD3PDMaker/cmt/requirements | 38 ++ .../python/Atlfast1D3PDMakerFlags.py | 52 ++ .../python/Atlfast1ElectronD3PDObject.py | 87 ++++ .../python/Atlfast1MissingETD3PDObject.py | 26 + .../python/Atlfast1PhotonD3PDObject.py | 85 +++ .../python/GenEventD3PDObject.py | 62 +++ .../python/GenParticleD3PDObject.py | 130 +++++ .../python/GenVertexD3PDObject.py | 88 ++++ .../TruthD3PDMaker/python/HforConfig.py | 171 ++++++ .../TruthD3PDMaker/python/HforD3PDObject.py | 13 + .../python/MCTruthClassifierConfig.py | 38 ++ .../TruthD3PDMaker/python/PartonJetConfig.py | 71 +++ .../python/PileUpInfoD3PDObject.py | 15 + .../python/TruthD3PDMakerFlags.py | 129 +++++ .../python/TruthD3PDMakerKeys.py | 108 ++++ .../python/TruthEventD3PDObject.py | 40 ++ .../python/TruthJetD3PDObject.py | 26 + .../python/TruthJetFilterConfig.py | 64 +++ .../python/TruthLeptonParentAssociation.py | 31 ++ .../python/TruthParticleChildAssociation.py | 38 ++ .../python/TruthParticleD3PDObject.py | 73 +++ .../python/TruthParticleFakerObject.py | 157 ++++++ .../python/TruthParticleParentAssociation.py | 37 ++ .../python/TruthTauDecayAssociation.py | 33 ++ .../TruthD3PDMaker/python/__init__.py | 16 + .../TruthD3PDMaker/python/atlfast1D3PD.py | 80 +++ .../TruthD3PDMaker/python/evgenD3PD.py | 106 ++++ .../share/GenD3PDExample_jobOptions.py | 71 +++ .../share/TruthD3PDfromEVGEN_preInclude.py | 70 +++ .../share/TruthD3PDfromEVGEN_prodOptions.py | 233 +++++++++ .../share/TruthD3PDfromEVGEN_topOptions.py | 47 ++ .../TruthSusyD3PDfromEVGEN_preInclude.py | 33 ++ .../TruthSusyD3PDfromEVGEN_prodOptions.py | 106 ++++ .../TruthSusyD3PDfromEVGEN_topOptions.py | 56 ++ .../share/atlfast1D3PD_topOptions.py | 87 ++++ .../share/evgenD3PD_topOptions.py | 84 +++ .../TruthD3PDMaker/src/GenEventFillerTool.cxx | 83 +++ .../TruthD3PDMaker/src/GenEventFillerTool.h | 109 ++++ .../GenEventGenParticleAssociationTool.cxx | 132 +++++ .../src/GenEventGenParticleAssociationTool.h | 96 ++++ .../src/GenEventGetterFilterTool.cxx | 45 ++ .../src/GenEventGetterFilterTool.h | 64 +++ .../TruthD3PDMaker/src/GenEventGetterTool.cxx | 85 +++ .../TruthD3PDMaker/src/GenEventGetterTool.h | 75 +++ .../src/GenEventPileUpFillerTool.cxx | 109 ++++ .../src/GenEventPileUpFillerTool.h | 81 +++ .../src/GenParticleEventAssociationTool.cxx | 24 + .../src/GenParticleEventAssociationTool.h | 60 +++ .../src/GenParticleFillerTool.cxx | 125 +++++ .../src/GenParticleFillerTool.h | 145 ++++++ .../src/GenParticleGetterTool.cxx | 119 +++++ .../src/GenParticleGetterTool.h | 82 +++ .../GenParticleParticleAssociationTool.cxx | 24 + .../src/GenParticleParticleAssociationTool.h | 63 +++ .../src/GenParticlePerigeeFillerTool.cxx | 83 +++ .../src/GenParticlePerigeeFillerTool.h | 56 ++ ...enParticleTruthParticleAssociationTool.cxx | 132 +++++ .../GenParticleTruthParticleAssociationTool.h | 124 +++++ .../src/GenParticleVertexAssociationTool.cxx | 28 + .../src/GenParticleVertexAssociationTool.h | 67 +++ .../src/GenVertexEventAssociationTool.cxx | 24 + .../src/GenVertexEventAssociationTool.h | 60 +++ .../src/GenVertexFillerTool.cxx | 77 +++ .../TruthD3PDMaker/src/GenVertexFillerTool.h | 87 ++++ .../src/GenVertexGetterTool.cxx | 118 +++++ .../TruthD3PDMaker/src/GenVertexGetterTool.h | 82 +++ .../src/GenVertexParticleAssociationTool.cxx | 45 ++ .../src/GenVertexParticleAssociationTool.h | 80 +++ .../TruthD3PDMaker/src/HforFillerTool.cxx | 122 +++++ .../TruthD3PDMaker/src/HforFillerTool.h | 49 ++ .../TruthD3PDMaker/src/JetFullTruthTag.cxx | 126 +++++ .../TruthD3PDMaker/src/JetFullTruthTag.h | 68 +++ .../src/PileUpInfoAssociatorTool.cxx | 39 ++ .../src/PileUpInfoAssociatorTool.h | 41 ++ .../src/PileUpInfoFillerTool.cxx | 64 +++ .../TruthD3PDMaker/src/PileUpInfoFillerTool.h | 73 +++ .../src/TruthEtIsolationFillerTool.cxx | 82 +++ .../src/TruthEtIsolationFillerTool.h | 66 +++ .../TruthD3PDMaker/src/TruthJetFilterTool.cxx | 490 ++++++++++++++++++ .../TruthD3PDMaker/src/TruthJetFilterTool.h | 157 ++++++ .../src/TruthLeptonNearbyAssociationTool.cxx | 123 +++++ .../src/TruthLeptonNearbyAssociationTool.h | 71 +++ .../src/TruthLeptonParentAssociationTool.cxx | 152 ++++++ .../src/TruthLeptonParentAssociationTool.h | 88 ++++ .../src/TruthParticleBarcodesFillerTool.cxx | 73 +++ .../src/TruthParticleBarcodesFillerTool.h | 63 +++ .../src/TruthParticleBremFillerTool.cxx | 84 +++ .../src/TruthParticleBremFillerTool.h | 68 +++ .../src/TruthParticleChildAssociationTool.cxx | 84 +++ .../src/TruthParticleChildAssociationTool.h | 84 +++ .../TruthParticleClassificationFillerTool.cxx | 84 +++ .../TruthParticleClassificationFillerTool.h | 79 +++ ...ruthParticleEtIsolationAssociationTool.cxx | 85 +++ .../TruthParticleEtIsolationAssociationTool.h | 83 +++ .../src/TruthParticleFakerTool.cxx | 116 +++++ .../src/TruthParticleFakerTool.h | 89 ++++ .../src/TruthParticleFillerTool.cxx | 108 ++++ .../src/TruthParticleFillerTool.h | 99 ++++ ...ruthParticleGenParticleAssociationTool.cxx | 49 ++ .../TruthParticleGenParticleAssociationTool.h | 65 +++ .../TruthParticleParentAssociationTool.cxx | 82 +++ .../src/TruthParticleParentAssociationTool.h | 84 +++ ...TruthParticleProdVertexAssociationTool.cxx | 48 ++ .../TruthParticleProdVertexAssociationTool.h | 63 +++ .../src/TruthTauDecayAssociationTool.cxx | 120 +++++ .../src/TruthTauDecayAssociationTool.h | 82 +++ .../TruthD3PDMaker/src/barcodeOrder.h | 42 ++ .../src/components/TruthD3PDMaker_entries.cxx | 135 +++++ .../src/components/TruthD3PDMaker_load.cxx | 12 + .../TruthD3PDMaker/src/hepMCInheritance.cxx | 24 + 110 files changed, 9001 insertions(+) create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/cmt/requirements create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1D3PDMakerFlags.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1ElectronD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1MissingETD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1PhotonD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenEventD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenParticleD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenVertexD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforConfig.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/MCTruthClassifierConfig.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PartonJetConfig.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PileUpInfoD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerFlags.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerKeys.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthEventD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetFilterConfig.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthLeptonParentAssociation.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleChildAssociation.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleD3PDObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleFakerObject.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleParentAssociation.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthTauDecayAssociation.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/__init__.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/atlfast1D3PD.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/evgenD3PD.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/GenD3PDExample_jobOptions.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_preInclude.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_prodOptions.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_topOptions.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_preInclude.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_prodOptions.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_topOptions.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/atlfast1D3PD_topOptions.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/evgenD3PD_topOptions.py create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/barcodeOrder.h create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_entries.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_load.cxx create mode 100644 PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/hepMCInheritance.cxx diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/cmt/requirements b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/cmt/requirements new file mode 100644 index 00000000000..483072840f0 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/cmt/requirements @@ -0,0 +1,38 @@ +package TruthD3PDMaker + +use AtlasPolicy AtlasPolicy-* + +private +use GaudiInterface GaudiInterface-* External +use AtlasBoost AtlasBoost-* External +use AtlasHepMC AtlasHepMC-* External +use AtlasCLHEP AtlasCLHEP-* External +use AthenaKernel AthenaKernel-* Control +use AthenaBaseComps AthenaBaseComps-* Control +use Navigation Navigation-* Control +use SGTools SGTools-* Control +use EventInfo EventInfo-* Event +use xAODTruth xAODTruth-* Event/xAOD +use HforTool HforTool-* Generators + +use MCTruthClassifier MCTruthClassifier-* PhysicsAnalysis +use D3PDMakerInterfaces D3PDMakerInterfaces-* PhysicsAnalysis/D3PDMaker +use D3PDMakerUtils D3PDMakerUtils-* PhysicsAnalysis/D3PDMaker +use TruthD3PDAnalysis TruthD3PDAnalysis-* PhysicsAnalysis/D3PDMaker + +use GeneratorObjects GeneratorObjects-* Generators +use McParticleKernel McParticleKernel-* PhysicsAnalysis/TruthParticleID +use McParticleEvent McParticleEvent-* PhysicsAnalysis/TruthParticleID + +use TrkToolInterfaces TrkToolInterfaces-* Tracking/TrkTools + +use JetEvent JetEvent-* Reconstruction/Jet +use HepPDT * LCG_Interfaces +end_private + + +library TruthD3PDMaker *.cxx components/*.cxx +apply_pattern component_library + +apply_pattern declare_python_modules files="*.py" +apply_pattern declare_joboptions files="*.py" diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1D3PDMakerFlags.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1D3PDMakerFlags.py new file mode 100644 index 00000000000..d7f097ddd32 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1D3PDMakerFlags.py @@ -0,0 +1,52 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/Atlfast1D3PDMakerFlags.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Feb, 2010 +# @brief Common flags for Atlfast1 D3PD making. +# + + +"""Common flags for Atlfast1 D3PD making. +""" + + +from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer +from AthenaCommon.JobProperties import jobproperties + + +class Atlfast1D3PDMakerFlags (JobPropertyContainer): + """Common flags for Atlfast1 D3PD making. +""" + pass + + +jobproperties.add_Container (Atlfast1D3PDMakerFlags) + + +# Helper to create a SG key property. +def _sgkey_prop (name, val): + prop = type (name, (JobProperty,), {}) + prop.statusOn = True + prop.allowedTypes = ['str'] + prop.StoredValue = val + jobproperties.Atlfast1D3PDMakerFlags.add_JobProperty(prop) + return + +_sgkey_prop ('IsoElectronSGKey', 'AtlfastIsoElectronCollection') +_sgkey_prop ('IsoPhotonSGKey', 'AtlfastIsoPhotonCollection') +_sgkey_prop ('IsoMuonSGKey', 'AtlfastIsoMuonCollection') +_sgkey_prop ('ContainerPrefix', '') + + +class UseAtlfast1Correction (JobProperty): + """If true, use Atlfast1 corrected containers in D3PD.""" + statusOn = True + allowedTypes = ['bool'] + StoredValue = False +jobproperties.Atlfast1D3PDMakerFlags.add_JobProperty(UseAtlfast1Correction) + + +Atlfast1D3PDMakerFlags = jobproperties.Atlfast1D3PDMakerFlags diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1ElectronD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1ElectronD3PDObject.py new file mode 100644 index 00000000000..0a4ae720a3a --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1ElectronD3PDObject.py @@ -0,0 +1,87 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from egammaD3PDMaker.isem_version import isem_version +from EventCommonD3PDMaker.DRAssociation import DRAssociation +from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject +from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from TruthD3PDMaker.Atlfast1D3PDMakerFlags import Atlfast1D3PDMakerFlags +from RecExConfig.RecFlags import rec +import egammaD3PDMaker +import EventCommonD3PDMaker +import D3PDMakerCoreComps + +import PyCintex +PyCintex.loadDictionary('egammaEnumsDict') +from ROOT import egammaParameters +from ROOT import egammaPID + +Atlfast1ElectronD3PDObject = \ + make_SGDataVector_D3PDObject ('ElectronContainer', + D3PDMakerFlags.ElectronSGKey(), + 'el_', 'Atlfast1ElectronD3PDObject') + + +Atlfast1ElectronD3PDObject.defineBlock (0, 'Kinematics', + EventCommonD3PDMaker.FourMomFillerTool, + WriteE = True, + WriteEt = True, + WriteRect = True) +Atlfast1ElectronD3PDObject.defineBlock (0, 'Charge', + EventCommonD3PDMaker.ChargeFillerTool) + +if rec.doTruth(): + import TruthD3PDMaker.MCTruthClassifierConfig + Atlfast1ElectronD3PDObject.defineBlock (1, 'TruthClassification', + egammaD3PDMaker.egammaTruthClassificationFillerTool) + Atlfast1ElectronGenPartAssoc = SimpleAssociation \ + (Atlfast1ElectronD3PDObject, + egammaD3PDMaker.egammaGenParticleAssociationTool, + prefix = 'truth_', + matched = 'matched', + blockname = 'Truth') + Atlfast1ElectronGenPartAssoc.defineBlock (0, 'Truth', + EventCommonD3PDMaker.GenParticleFillerTool, + WriteE = True, + WriteM = False) + Atlfast1ElectronGenPartAssoc.defineBlock (0, 'TruthBrem', + EventCommonD3PDMaker.GenParticleBremFillerTool) + +############################################################################ +# Check isolation via associations +# +Atlfast1EleIsoD3PDAssoc = DRAssociation (Atlfast1ElectronD3PDObject, + 'ElectronContainer', + Atlfast1D3PDMakerFlags.IsoElectronSGKey(), + 0.2, + 'iso_', + level = 0, + blockname = 'Isolated') + +############################################################################ +# Jet associations +# + +Atlfast1EleJetD3PDAssoc = DRAssociation (Atlfast1ElectronD3PDObject, + 'JetCollection', + D3PDMakerFlags.JetSGKey(), + 0.2, + 'jet_', + level = 2, + blockname = 'JetMatch') +Atlfast1EleJetD3PDAssoc.defineBlock (2, 'JetKinematics', + EventCommonD3PDMaker.FourMomFillerTool, + WriteE = True) + + +if rec.doTruth(): + Atlfast1JetTruthJetD3PDAssoc = DRAssociation (Atlfast1EleJetD3PDAssoc, + 'JetCollection', + D3PDMakerFlags.TruthJetSGKey(), + 0.2, + 'truth_', + level = 2, + blockname = 'TrueJetMatch') + Atlfast1JetTruthJetD3PDAssoc.defineBlock (2, 'TrueJetKinematics', + EventCommonD3PDMaker.FourMomFillerTool, + WriteE = True) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1MissingETD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1MissingETD3PDObject.py new file mode 100644 index 00000000000..adbb5738cb1 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1MissingETD3PDObject.py @@ -0,0 +1,26 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +import MissingETD3PDMaker +import D3PDMakerCoreComps +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerCoreComps.D3PDObject import make_SG_D3PDObject +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from MissingETD3PDMaker.MissingETD3PDMakerFlags import * + +Atlfast1MissingETD3PDObject = \ + make_SG_D3PDObject ('MissingET', + D3PDMakerFlags.MissingETSGKey(), + 'MET_RefFinal_', + 'Atlfast1MissingETD3PDObject') +Atlfast1MissingETD3PDObject.defineBlock (0, 'MET_RefFinal_', + MissingETD3PDMaker.MissingETFillerTool) + +TruthMETD3PDObject = \ + make_SG_D3PDObject ('MissingEtTruth', + MissingETD3PDMakerFlags.METTruthSGKey(), + 'MET_Truth_', + 'TruthMETD3PDObject') +TruthMETD3PDObject.defineBlock (1, 'MET_Truth_NonInt_', + MissingETD3PDMaker.MissingETTruthNonIntFillerTool) +TruthMETD3PDObject.defineBlock (3, 'MET_Truth_Int_', + MissingETD3PDMaker.MissingETD3PDMakerConf.D3PD__MissingETTruthIntFillerTool) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1PhotonD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1PhotonD3PDObject.py new file mode 100644 index 00000000000..2e418a1a898 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/Atlfast1PhotonD3PDObject.py @@ -0,0 +1,85 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from egammaD3PDMaker.isem_version import isem_version +from EventCommonD3PDMaker.DRAssociation import DRAssociation +from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject +from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from TruthD3PDMaker.Atlfast1D3PDMakerFlags import Atlfast1D3PDMakerFlags +from RecExConfig.RecFlags import rec +import egammaD3PDMaker +import EventCommonD3PDMaker +import D3PDMakerCoreComps + +import PyCintex +PyCintex.loadDictionary('egammaEnumsDict') +from ROOT import egammaParameters +from ROOT import egammaPID + + +Atlfast1PhotonD3PDObject = \ + make_SGDataVector_D3PDObject ('PhotonContainer', + D3PDMakerFlags.PhotonSGKey(), + 'ph_', 'Atlfast1PhotonD3PDObject') + + +Atlfast1PhotonD3PDObject.defineBlock (0, 'Kinematics', + EventCommonD3PDMaker.FourMomFillerTool, + WriteE = True, + WriteEt = True, + WriteRect = True) + +if rec.doTruth(): + import TruthD3PDMaker.MCTruthClassifierConfig + Atlfast1PhotonD3PDObject.defineBlock (1, 'TruthClassification', + egammaD3PDMaker.egammaTruthClassificationFillerTool) + Atlfast1PhotonGenPartAssoc = SimpleAssociation \ + (Atlfast1PhotonD3PDObject, + egammaD3PDMaker.egammaGenParticleAssociationTool, + prefix = 'truth_', + matched = 'matched', + blockname = 'Truth', + DRVar = 'deltaRRecPhoton') + Atlfast1PhotonGenPartAssoc.defineBlock (0, 'Truth', + EventCommonD3PDMaker.GenParticleFillerTool, + WriteE = True, + WriteM = False) + +############################################################################ +# Check isolation via associations +# +Atlfast1PhoIsoD3PDAssoc = DRAssociation (Atlfast1PhotonD3PDObject, + 'PhotonContainer', + Atlfast1D3PDMakerFlags.IsoPhotonSGKey(), + 0.2, + 'iso_', + level = 0, + blockname = 'Isolated') + +############################################################################ +# Jet associations +# + +Atlfast1PhotonJetD3PDAssoc = DRAssociation (Atlfast1PhotonD3PDObject, + 'JetCollection', + D3PDMakerFlags.JetSGKey(), + 0.2, + 'jet_', + level = 2, + blockname = 'JetMatch') +Atlfast1PhotonJetD3PDAssoc.defineBlock (2, 'JetKinematics', + EventCommonD3PDMaker.FourMomFillerTool, + WriteE = True) + + +if rec.doTruth(): + Atlfast1JetTruthJetD3PDAssoc = DRAssociation (Atlfast1PhotonJetD3PDAssoc, + 'JetCollection', + D3PDMakerFlags.TruthJetSGKey(), + 0.2, + 'truth_', + level = 2, + blockname = 'TrueJetMatch') + Atlfast1JetTruthJetD3PDAssoc.defineBlock (2, 'TrueJetKinematics', + EventCommonD3PDMaker.FourMomFillerTool, + WriteE = True) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenEventD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenEventD3PDObject.py new file mode 100644 index 00000000000..89e6bb49ff9 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenEventD3PDObject.py @@ -0,0 +1,62 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# +## @file TruthD3PDMaker/python/GenParticleD3PDObject.py +## @brief gen event D3PD object; includes pileup info +## @author Georges Aad +## @date Nov, 2010 +## + +from AthenaCommon.AppMgr import ToolSvc + +import TruthD3PDMaker + +import D3PDMakerCoreComps +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + +from TruthD3PDAnalysis.AllTruthFilterTool import AllTruthFilterTool +from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags + +def make_GenEvent_D3PDObject( default_prefix, default_sgkey, + default_object_name = "", + default_filter = AllTruthFilterTool(), + default_label = None, **other_defaults ): + + def make_obj( name, prefix, object_name, + getter = None, sgkey = None, filter = default_filter, + label = default_label, **kw ): + + if sgkey == None: sgkey = default_sgkey + if label == None: label = TruthD3PDKeys.GenEventGetterLabel() + if getter == None: + getter = TruthD3PDMaker.GenEventGetterTool( name + '_Getter', + Label = label, + Selector = filter, + SGKey = sgkey ) + + defs = other_defaults.copy() + defs.update( kw ) + + from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + return D3PDMakerCoreComps.VectorFillerTool( name, + Prefix = prefix, + Getter = getter, + ObjectName = object_name, + SaveMetadata = \ + D3PDMakerFlags.SaveObjectMetadata(), + **defs ) + + return D3PDObject( make_obj, default_prefix, default_object_name ) + +GenEventD3PDObject = make_GenEvent_D3PDObject( TruthD3PDKeys.GenEventPrefix(), + D3PDMakerFlags.TruthSGKey(), + "GenEventD3PDObject" ) + +GenEventD3PDObject.defineBlock( 0, 'mcevt', + TruthD3PDMaker.GenEventFillerTool ) + +GenEventD3PDObject.defineBlock( 1, 'pileup', + TruthD3PDMaker.GenEventPileUpFillerTool, + GetterLabel = TruthD3PDKeys.GenEventGetterLabel()) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenParticleD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenParticleD3PDObject.py new file mode 100644 index 00000000000..d1c4ecb0614 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenParticleD3PDObject.py @@ -0,0 +1,130 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# +## @file TruthD3PDMaker/python/GenParticleD3PDObject.py +## @brief gen particles and truth tracks D3PD object +## @author Georges Aad +## @date Nov, 2010 +## + +import TruthD3PDMaker + +import D3PDMakerCoreComps +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation +from D3PDMakerCoreComps.IndexAssociation import IndexAssociation +from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + +from TruthD3PDAnalysis.AllTruthFilterTool import AllTruthFilterTool +from TruthD3PDAnalysis.StableChargedTruthFilterTool import StableChargedTruthFilterTool +from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags + + +def make_GenParticle_D3PDObject( default_prefix, default_sgkey, + default_object_name = "", + default_filter = AllTruthFilterTool(), + default_label = None, **other_defaults ): + + def make_obj( name, prefix, object_name, + getter = None, sgkey = None, filter = default_filter, + label = default_label, **kw ): + + if sgkey == None: sgkey = default_sgkey + if label == None: label = prefix + if getter == None: + getter = TruthD3PDMaker.GenParticleGetterTool (name + "_Getter", + Label = label, + SGKey = sgkey, + Selector = filter ) + + defs = other_defaults.copy() + defs.update( kw ) + + from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + return D3PDMakerCoreComps.VectorFillerTool( name, + Prefix = prefix, + Getter = getter, + ObjectName = object_name, + SaveMetadata = \ + D3PDMakerFlags.SaveObjectMetadata(), + **defs ) + + return D3PDObject( make_obj, default_prefix, default_object_name ) + +GenParticleD3PDObject = make_GenParticle_D3PDObject( TruthD3PDKeys.GenParticlePrefix(), + D3PDMakerFlags.TruthSGKey(), + "GenParticleD3PDObject", + AllTruthFilterTool(), + TruthD3PDKeys.GenParticleGetterLabel() ) + +GenParticleD3PDObject.defineBlock( 0, 'GenParticle', + TruthD3PDMaker.GenParticleFillerTool ) + +if TruthD3PDFlags.GenEventAssocLabel() != None and TruthD3PDFlags.GenEventAssocLabel() != "": + GenPartEventAssoc = IndexAssociation( GenParticleD3PDObject, + TruthD3PDMaker.GenParticleEventAssociationTool, + TruthD3PDFlags.GenEventAssocLabel(), + blockname = "GenPartEventAssoc", + prefix = 'mcevt_' ) + +if TruthD3PDFlags.GenVertexAssocLabel() != None and TruthD3PDFlags.GenVertexAssocLabel() != "": + GenPartProdVertexAssoc = IndexAssociation( GenParticleD3PDObject, + TruthD3PDMaker.GenParticleVertexAssociationTool, + TruthD3PDFlags.GenVertexAssocLabel(), + blockname = "GenPartProdVertexAssoc", + prefix = 'mcprodvtx_', + DecayVertex = False ) + +if TruthD3PDFlags.GenParticleMother(): + GenPartProdVertexAssocM = SimpleAssociation( GenParticleD3PDObject, + TruthD3PDMaker.GenParticleVertexAssociationTool, + blockname = "GenPartProdVertexAssocM", + prefix = '', + DecayVertex = False) + + GenPartMotherAssoc = IndexMultiAssociation( GenPartProdVertexAssocM, + TruthD3PDMaker.GenVertexParticleAssociationTool, + TruthD3PDKeys.GenParticleGetterLabel(), + blockname = "GenPartMotherAssoc", + prefix = 'mother_', + InParticles = True) + +if TruthD3PDFlags.GenVertexAssocLabel() != None and TruthD3PDFlags.GenVertexAssocLabel() != "": + GenPartDecayVertexAssoc = IndexAssociation( GenParticleD3PDObject, + TruthD3PDMaker.GenParticleVertexAssociationTool, + TruthD3PDFlags.GenVertexAssocLabel(), + blockname = "GenPartDecayVertexAssoc", + prefix = 'mcdecayvtx_', + DecayVertex = True ) + +if TruthD3PDFlags.GenParticleChild(): + GenPartDecayVertexAssocC = SimpleAssociation( GenParticleD3PDObject, + TruthD3PDMaker.GenParticleVertexAssociationTool, + blockname = "GenPartDecayVertexAssocC", + prefix = '', + DecayVertex = True) + + GenPartChildAssoc = IndexMultiAssociation( GenPartDecayVertexAssocC, + TruthD3PDMaker.GenVertexParticleAssociationTool, + TruthD3PDKeys.GenParticleGetterLabel(), + blockname = "GenPartChildAssoc", + prefix = 'child_', + InParticles = False ) + +if TruthD3PDFlags.TruthTrackAssocLabel() != None and TruthD3PDFlags.TruthTrackAssocLabel() != "": + GenPartTruthTrackAssoc = IndexAssociation( GenParticleD3PDObject, + TruthD3PDMaker.GenParticleParticleAssociationTool, + TruthD3PDFlags.TruthTrackAssocLabel(), + blockname = "GenPartTruthTrackAssoc", + prefix = 'truthtracks_' ) + +GenTruthTrackD3PDObject = make_GenParticle_D3PDObject( TruthD3PDKeys.TruthTrackPrefix(), + D3PDMakerFlags.TruthSGKey(), + "GenTruthTrackD3PDObject", + StableChargedTruthFilterTool(), + TruthD3PDKeys.TruthTrackGetterLabel() ) + +GenTruthTrackD3PDObject.defineBlock( 0, 'TruthTracks', + TruthD3PDMaker.GenParticlePerigeeFillerTool ) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenVertexD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenVertexD3PDObject.py new file mode 100644 index 00000000000..7e5462cda3e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/GenVertexD3PDObject.py @@ -0,0 +1,88 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# +## @file TruthD3PDMaker/python/GenParticleD3PDObject.py +## @brief gen vertex D3PD object +## @author Georges Aad +## @date Nov, 2010 +## + +import TruthD3PDMaker +import D3PDMakerCoreComps + +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation +from D3PDMakerCoreComps.IndexAssociation import IndexAssociation + +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from TruthD3PDAnalysis.AllTruthFilterTool import AllTruthFilterTool +from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags + + +def make_GenVertex_D3PDObject( default_prefix, default_sgkey, + default_object_name = "", + default_filter = AllTruthFilterTool(), + default_label = None, **other_defaults ): + + def make_obj( name, prefix, object_name, + getter = None, sgkey = None, filter = default_filter, + label = default_label, **kw ): + + if sgkey == None: sgkey = default_sgkey + if label == None: label = TruthD3PDKeys.GenVertexGetterLabel() + if getter == None: + getter = TruthD3PDMaker.GenVertexGetterTool( name + '_Getter', + Label = label, + Selector = filter, + SGKey = sgkey ) + + defs = other_defaults.copy() + defs.update( kw ) + + from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + return D3PDMakerCoreComps.VectorFillerTool( name, + Prefix = prefix, + Getter = getter, + ObjectName = object_name, + SaveMetadata = \ + D3PDMakerFlags.SaveObjectMetadata(), + **defs ) + + return D3PDObject( make_obj, default_prefix, default_object_name ) + +GenVertexD3PDObject = make_GenVertex_D3PDObject( TruthD3PDKeys.GenVertexPrefix(), + D3PDMakerFlags.TruthSGKey(), + "GenVertexD3PDObject" ) + +GenVertexD3PDObject.defineBlock( 0, + 'GenVertex', + TruthD3PDMaker.GenVertexFillerTool, + WriteID=TruthD3PDFlags.WriteTruthVertexIDs() ) + +if TruthD3PDFlags.GenParticleAssocLabel() != None and TruthD3PDFlags.GenParticleAssocLabel() != "": + if TruthD3PDFlags.GenVertexInPartAssoc(): + GenVertexPartInAssoc = \ + IndexMultiAssociation( GenVertexD3PDObject, + TruthD3PDMaker.GenVertexParticleAssociationTool, + TruthD3PDFlags.GenParticleAssocLabel(), + blockname = "GenVertexPartInAssoc", + prefix = 'inpart_', + InParticles = True ) + + if TruthD3PDFlags.GenVertexOutPartAssoc(): + GenVertexPartOutAssoc = \ + IndexMultiAssociation( GenVertexD3PDObject, + TruthD3PDMaker.GenVertexParticleAssociationTool, + TruthD3PDFlags.GenParticleAssocLabel(), + blockname = "GenVertexPartOutAssoc", + prefix = 'outpart_', + InParticles = False ) + +if TruthD3PDFlags.GenEventAssocLabel() != None and TruthD3PDFlags.GenEventAssocLabel() != "": + GenVertexEventAssoc = IndexAssociation( GenVertexD3PDObject, + TruthD3PDMaker.GenVertexEventAssociationTool, + TruthD3PDFlags.GenEventAssocLabel(), + level = 1, + blockname = "GenVertexEventAssoc", + prefix = 'mcevt_' ) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforConfig.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforConfig.py new file mode 100644 index 00000000000..ac8720e1ec5 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforConfig.py @@ -0,0 +1,171 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +class HforConfig: + """ + Class to work out the DSID and find the corresponding string used to configure the Hfortool in a file on CVMFS + + Config strings are usually of the form isBB, isCC etc. + + """ + def __init__(self): + """ + Sets up logging and class variables needed + + """ + from AthenaCommon.Logging import logging + self.hforLog = logging.getLogger('Hfor') + self.hforLog.debug("****************** STARTING Hfor Configuration *****************") + + self.file = "" + self.curr_DSID = "" + self.config_String = "fail" + from AthenaCommon.AthenaCommonFlags import athenaCommonFlags + self.fList = athenaCommonFlags.FilesInput() + + + + + def getSampleType(self, runArgs, filepath): + """ + function called from outside the class to work out the config string, gives the class access to runArgs variables + + (runArgs are the arguaments given to Reco_trf at the command line) + + """ + self.getConfigFile(runArgs, filepath) + self.getDSID(runArgs) + self.getHforType() + #self.checkConsistency() + return self.config_String + + + + + def getConfigFile(self, runArgs, filepath): + """ + Function to determine the location of the text file that contains the DSIDs and their corresponding configuration strings + + There is a default location that can be overridden + + """ + + #Identify Hfor type + from AthenaCommon.Utils.unixtools import FindFile + import sys, os + + try: + self.file = open(filepath) + except: + currentError = "Exiting. Configuration file should be in "+str(filepath) + self.hforLog.error(currentError) + sys.exit(0) + + + #find and open the file to configure mode based on DSID + currentError = "using file found in "+filepath + self.hforLog.info(currentError) + + + + + def getDSID(self, runArgs): + + """ + Finds the DSID of the dataset being used. + + Note: It must be specified as a command line option for running on the grid + For local running it is possible to configure it from the container name + + """ + #try getting the DSID from the RunNumber variable in the file + import PyUtils.AthFile as af + f = af.fopen( self.fList[0] ) + if len(f.run_numbers) > 0: + self.curr_DSID = f.run_numbers[0] + else: + import re + try: + #try to get the DSID from runArgs + self.curr_DSID = runArgs.RunNumber + except: + #if cannot access runargs parse input file name for DSID + if len(self.fList) != 0: + files = self.fList + firstFile = files[0].split(".") + + for index, x in enumerate(firstFile): + if re.search('mc[1234567890]{2}', x) is not None: + self.curr_DSID = firstFile[index+1] + try: + int(self.curr_DSID) + except: + self.hforLog.error("Could not find DSID from filename. The Hfor tool will not be correctly configured! Have you obeyed the naming convention?") + self.curr_DSID = 0 + + else: + self.hforLog.error("No DSID found. Is the naming convention correct?") + + + + + def getHforType(self): + + """ + Find the configuration string that corresponds to the DSID + + + """ + + proc_dict = {} + for line in self.file: + #Dont want to look at comments so lets remove anything beginning with a # symbol + line = line[:line.find("#")].strip() + line = line.rstrip() + if not line.strip(): + continue + + + + if line: + #split the line into a DSID and a sample config string + proc_list = line.split() + proc_dict[proc_list[0]] = proc_list[1] + if int(proc_list[0]) == int(self.curr_DSID): + self.config_String = proc_list[1] + break + + self.file.close() + + + if self.config_String == "fail": + self.hforLog.warning("failed to find DSID in configuration file. Hfor has not been activated. Does this sample require Hfor? ") + + + + + def checkConsistency(self): + """ + Checks that all the files have the same DSID + Currently not used - remove? + + """ + import re + + + #check that all samples are of the same Hfor type otherwise exit + #What to do in case of runArgs being used? + for newfile in self.fList: + tmp2 = newfile.split(".") + for index, x in enumerate(tmp2): + if re.search('mc[1234567890]{2}', x) is not None: + thisDSID = index + + try: + if proc_dict[tmp2[thisDSID+1]] != self.config_String: + self.hforLog.error("This tool must be used with samples of the same Hfor type. Terminating now") + sys.exit(0) + except: + + self.hforLog.error("failure when checking if all DSIDs are of same type") + + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforD3PDObject.py new file mode 100644 index 00000000000..3b67c108e18 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/HforD3PDObject.py @@ -0,0 +1,13 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + + +from D3PDMakerCoreComps.D3PDObject import make_Void_D3PDObject +import TruthD3PDMaker +#import TopInputsD3PDMaker + +HforD3PDObject = make_Void_D3PDObject( "top_", "HforD3PDObject", + default_name = "HforFiller" ) + +HforD3PDObject.defineBlock( 0, "HforBits", + TruthD3PDMaker.HforFillerTool) + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/MCTruthClassifierConfig.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/MCTruthClassifierConfig.py new file mode 100644 index 00000000000..1793588436e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/MCTruthClassifierConfig.py @@ -0,0 +1,38 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/MCTruthClassifierConfig.py +# @author scott snyder <snyder@bnl.gov> +# @date Jan, 2010 +# @brief Import this to configure the MCTruthClassifier tool for D3PD making. +# + +# Create the classifier tool, and set the MC collection name to match +# what's in D3PDMakerFlags. + +from D3PDMakerCoreComps.resolveSGKey import resolveSGKey +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from AthenaCommon.Constants import ERROR + +mckey = resolveSGKey ('DataVector<xAOD::TruthParticle_v1>', D3PDMakerFlags.TruthSGKey()) + +from MCTruthClassifier.MCTruthClassifierBase import exToCalo + + +from TruthD3PDAnalysis import D3PDMCTruthClassifier +D3PDMCTruthClassifier = D3PDMCTruthClassifier (name = 'D3PDMCTruthClassifier', + ExtrapolateToCaloTool = exToCalo, + xAODTruthParticleContainerName = mckey, + pTNeutralPartCut = 1e-3, + OutputLevel = ERROR, + partExtrConePhi = 0.6, #0.4 + partExtrConeEta = 0.2, #0.2 + ROICone = True) +try: + D3PDMCTruthClassifier.forceNotUseBremRefitTrk = True +except AttributeError: + pass + +from AthenaCommon.AppMgr import ToolSvc +ToolSvc += D3PDMCTruthClassifier diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PartonJetConfig.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PartonJetConfig.py new file mode 100644 index 00000000000..4b61f09f5a4 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PartonJetConfig.py @@ -0,0 +1,71 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/PartonJetConfig.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Apr, 2010 +# @brief Configure algorithms to build parton-level jets +# information on algorithm configuration can be found on +# Reconstruction/Jet/JetSimTools/PartonTruthJets_jobOptions.py +# + + +import EventCommonD3PDMaker +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from AthenaCommon.AlgSequence import AlgSequence +from RecExConfig.ObjKeyStore import cfgKeyStore +from RecExConfig.RecFlags import rec + +from JetRec.JetMomentGetter import make_JetMomentGetter +from JetRec.JetGetters import * + +from AthenaCommon.SystemOfUnits import MeV, GeV +from JetRec.JetRecConf import JetAlgorithm + +from JetSimTools.JetSimToolsConf import JetPartonSelectorTool + +def PartonJetConfig (finder = 'AntiKt', + size = 0.4, + doPythia = False, + doHerwig = False, + minJetPt = 7.*GeV, + absEtaMax = 10., + suffix = '', + inputCollections = None): + + if not rec.doTruth(): + return + + # Is the container already in SG? + import JetRec.JetAlgConfiguration + nameBuilder = JetRec.JetAlgConfiguration.nameBuilder + editParm = JetRec.JetAlgConfiguration.editParm + sgkey = nameBuilder(finder,editParm(size),'','Truth','Parton'+suffix,'',)+'Jets' + if cfgKeyStore.isInInput ('JetCollection', sgkey): + return + + # Configure parton selector tool + from AthenaCommon.AppMgr import ToolSvc + jetPartonSelectorTool = JetPartonSelectorTool("JetPartonSelectorTool") + jetPartonSelectorTool.DoPythia = doPythia + jetPartonSelectorTool.DoHerwig = doHerwig + jetPartonSelectorTool.max_absEta = absEtaMax + #jetPartonSelectorTool.OutputLevel = INFO + ToolSvc += jetPartonSelectorTool + + # Configure jets builder + if inputCollections != None: + partonJetAlg = make_StandardJetGetter(finder,size,'Truth',inputSuff='Parton'+suffix, + inputCollectionNames=inputCollections, + inputTools=[jetPartonSelectorTool]).jetAlgorithmHandle() + partonJetAlg.AlgTools['JetPartonSelectorTool'].InputCollectionKeys = [] + partonJetAlg.AlgTools['JetPartonSelectorTool'].InputCollectionKeys.append(inputCollections[0]) + print 'partonJetAlg',partonJetAlg + else: + partonJetAlg = make_StandardJetGetter(finder,size,'Truth',inputSuff='Parton'+suffix).jetAlgorithmHandle() + partonJetAlg.AlgTools['JetFinalPtCut'].MinimumSignal = minJetPt + #partonJetAlg.AlgTools['InputToJet'].InputSelector = jetPartonSelectorTool + #partonJetAlg.OutputLevel = INFO + + return diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PileUpInfoD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PileUpInfoD3PDObject.py new file mode 100644 index 00000000000..b0b4c96010e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/PileUpInfoD3PDObject.py @@ -0,0 +1,15 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +import TruthD3PDMaker +import D3PDMakerCoreComps +from D3PDMakerCoreComps.D3PDObject import * +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from TruthD3PDMaker.TruthD3PDMakerConf import * +from D3PDMakerCoreComps.ContainedVectorMultiAssociation import ContainedVectorMultiAssociation + + +PileUpInfoD3PDObject=make_SG_D3PDObject("PileUpEventInfo","OverlayEvent","pevt_","PileUpInfoD3PDObject") + +PileUpObject=ContainedVectorMultiAssociation(PileUpInfoD3PDObject,TruthD3PDMaker.PileUpInfoAssociatorTool,"") + +PileUpObject.defineBlock (0,'PileUpInfo',TruthD3PDMaker.PileUpInfoFillerTool) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerFlags.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerFlags.py new file mode 100644 index 00000000000..dd5e2e8242e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerFlags.py @@ -0,0 +1,129 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# +## @file TruthD3PDMaker/python/TruthD3PDMakerFlags.py +## @brief Python module to hold TruthD3PDMaker common flags +## @author Georges Aad +## @date Nov, 2010 +## + + + +""" +This file is used to configure the Gen objects in the TruthD3PDMaker +""" + + + +##----------------------------------------------------------------------------- +## Import +from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer +from AthenaCommon.JobProperties import jobproperties + +from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys + + +class GenParticleAssocLabel(JobProperty): + """ label for the gen particle getter for association + """ + statusOn=True + allowedTypes=['str'] + StoredValue=TruthD3PDKeys.GenParticleGetterLabel() + + +class GenVertexAssocLabel(JobProperty): + """ label for the gen vertex getter for association + """ + statusOn=True + allowedTypes=['str'] + StoredValue=TruthD3PDKeys.GenVertexGetterLabel() + +class GenEventAssocLabel(JobProperty): + """ label for the gen event getter for association + """ + statusOn=True + allowedTypes=['str'] + StoredValue=TruthD3PDKeys.GenEventGetterLabel() + +class TruthTrackAssocLabel(JobProperty): + """ label for the truth track getter for association + """ + statusOn=True + allowedTypes=['str'] + StoredValue=TruthD3PDKeys.TruthTrackGetterLabel() + + +class GenVertexOutPartAssoc(JobProperty): + """ switch to associate gen vertex to out gen particles + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=False + +class GenVertexInPartAssoc(JobProperty): + """ switch to associate gen vertex to in gen particles + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=False + +class GenParticleMother(JobProperty): + """ switch to associate gen particles to there mothers + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=True + +class GenParticleChild(JobProperty): + """ switch to associate gen particles to there children + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=True + +class TruthD3PDOutputFileName(JobProperty): + """ label for the truth track getter for association + """ + statusOn=True + allowedTypes=['str'] + StoredValue="" + +class WriteTruthVertices(JobProperty): + """ Switch to save truth vertices + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=False + +class WriteTruthVertexIDs(JobProperty): + """ Switch to save truth vertices + """ + statusOn=True + allowedTypes=['bool'] + StoredValue=False + +class TruthD3PDMakerFlags(JobPropertyContainer): + """ The Truth D3PD Flags container + """ + +# add the flag container to the top container +jobproperties.add_Container(TruthD3PDMakerFlags) + +# and now add the properties + +jobproperties.TruthD3PDMakerFlags.add_JobProperty(GenParticleAssocLabel) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(GenVertexAssocLabel) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(GenEventAssocLabel) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(TruthTrackAssocLabel) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(GenVertexOutPartAssoc) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(GenVertexInPartAssoc) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(GenParticleMother) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(GenParticleChild) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(TruthD3PDOutputFileName) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(WriteTruthVertices) +jobproperties.TruthD3PDMakerFlags.add_JobProperty(WriteTruthVertexIDs) + +## use this shortcut +#from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags +## +TruthD3PDFlags=jobproperties.TruthD3PDMakerFlags diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerKeys.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerKeys.py new file mode 100644 index 00000000000..2fcb458e974 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthD3PDMakerKeys.py @@ -0,0 +1,108 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# +## @file TruthD3PDMaker/python/TruthD3PDMakerKeys.py +## @brief Python module to hold TruthD3PDMaker common Keys +## @author Georges Aad +## @date Nov, 2010 +## + + + +""" +This file is used to set different conventions for the Gen D3PD objects: +block names and common labels ... +In most cases you do not need to change them. +""" + +from AthenaCommon.JobProperties import JobProperty, JobPropertyContainer +from AthenaCommon.JobProperties import jobproperties + + + + +class GenEventGetterLabel(JobProperty): + """ label for gen event getter + """ + statusOn=True + allowedTypes=['str'] + StoredValue="TruthD3PD_GenEvent" + +class GenEventPrefix(JobProperty): + """ prefix for gen event object + """ + statusOn=True + allowedTypes=['str'] + StoredValue="mcevt_" + + +class GenVertexGetterLabel(JobProperty): + """ label for gen vertex getter + """ + statusOn=True + allowedTypes=['str'] + StoredValue="TruthD3PD_GenVertex" + +class GenVertexPrefix(JobProperty): + """ prefix for gen vertex object + """ + statusOn=True + allowedTypes=['str'] + StoredValue="mcvtx_" + + +class GenParticleGetterLabel(JobProperty): + """ label for gen particle getter + """ + statusOn=True + allowedTypes=['str'] + StoredValue="TruthD3PD_GenParticle" + +class GenParticlePrefix(JobProperty): + """ prefix for gen particle object + """ + statusOn=True + allowedTypes=['str'] + StoredValue="mcpart_" + + +class TruthTrackGetterLabel(JobProperty): + """ label for truth track getter + """ + statusOn=True + allowedTypes=['str'] + StoredValue="TruthD3PD_TruthTrack" + +class TruthTrackPrefix(JobProperty): + """ prefix for truth track object + """ + statusOn=True + allowedTypes=['str'] + StoredValue="truthtrack_" + + +##----------------------------------------------------------------------------- +## Definition of the TruthD3PDMaker flag container + +class TruthD3PDMakerKeys(JobPropertyContainer): + """ The Truth D3PD keys container + """ +# add the key container to the top container +jobproperties.add_Container(TruthD3PDMakerKeys) + +# and now add the properties + +jobproperties.TruthD3PDMakerKeys.add_JobProperty(GenEventGetterLabel) +jobproperties.TruthD3PDMakerKeys.add_JobProperty(GenEventPrefix) +jobproperties.TruthD3PDMakerKeys.add_JobProperty(GenVertexGetterLabel) +jobproperties.TruthD3PDMakerKeys.add_JobProperty(GenVertexPrefix) +jobproperties.TruthD3PDMakerKeys.add_JobProperty(GenParticleGetterLabel) +jobproperties.TruthD3PDMakerKeys.add_JobProperty(GenParticlePrefix) +jobproperties.TruthD3PDMakerKeys.add_JobProperty(TruthTrackGetterLabel) +jobproperties.TruthD3PDMakerKeys.add_JobProperty(TruthTrackPrefix) + + +## use this shortcut +#from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys +## +TruthD3PDKeys=jobproperties.TruthD3PDMakerKeys diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthEventD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthEventD3PDObject.py new file mode 100644 index 00000000000..7575ef99b63 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthEventD3PDObject.py @@ -0,0 +1,40 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# +## @file TruthD3PDMaker/python/TruthD3PDObject.py +## @brief xAOD truth event D3PD object +## @author sss +## @date Jul, 2014 +## + + +from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +import D3PDMakerCoreComps + + +TruthEventD3PDObject = make_SGDataVector_D3PDObject \ + ('DataVector<xAOD::TruthEvent_v1>', + D3PDMakerFlags.TruthEventSGKey(), + 'mcevt_', + 'GenEventD3PDObject') + +TruthEventD3PDObject.defineBlock ( + 0, 'mcevt', + D3PDMakerCoreComps.AuxDataFillerTool, + Vars = [ + #'signal_process_id = signalProcessId', + #'event_number = eventNumber', + 'event_scale = eventScale', + 'alphaQCD', + 'alphaQED', + 'pdf_id1 = id1', + 'pdf_id2 = id2', + 'pdf_x1 = x1', + 'pdf_x2 = x2', + 'pdf_scale = scalePDF', + 'pdf1', + 'pdf2', + 'weight = weights', + ]) + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetD3PDObject.py new file mode 100644 index 00000000000..e3b5b17e614 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetD3PDObject.py @@ -0,0 +1,26 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +import D3PDMakerCoreComps +import EventCommonD3PDMaker +import JetD3PDMaker +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from RecExConfig.RecFlags import rec + +TruthJetD3PDObject = make_SGDataVector_D3PDObject ('JetCollection', + D3PDMakerFlags.JetSGKey(), + 'truthjet_', + 'TruthJetD3PDObject') + +TruthJetD3PDObject.defineBlock(0, 'Kinematics', + EventCommonD3PDMaker.FourMomFillerTool, + WriteE = True) + +TruthJetD3PDObject.defineBlock(2, 'JetShape', + JetD3PDMaker.JetShapeFillerTool) + +if rec.doTruth: + TruthJetD3PDObject.defineBlock(2, 'TrueFlavorComponents', + JetD3PDMaker.JetTrueTagFillerTool) + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetFilterConfig.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetFilterConfig.py new file mode 100644 index 00000000000..dd93bf3c72a --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthJetFilterConfig.py @@ -0,0 +1,64 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/TruthJetFilterConfig.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Apr, 2010 +# @brief Build truth container to be used for parton-jet building +# + +import EventCommonD3PDMaker +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from McParticleAlgs.JobOptCfg import createMcAodBuilder +from RecExConfig.RecFlags import rec +from AthenaCommon.AlgSequence import AlgSequence +from RecExConfig.ObjKeyStore import cfgKeyStore +from AthenaCommon import CfgMgr +from TruthD3PDMaker.TruthD3PDMakerConf import D3PD__TruthJetFilterTool + + +def TruthJetFilterConfig (seq, + sgkey = 'Filtered'+D3PDMakerFlags.TruthParticlesSGKey(), + prefix = '', + excludeWZdecays = True, + photonCone = -1., + doPileup = D3PDMakerFlags.TruthDoPileup(), + writePartons = D3PDMakerFlags.TruthWritePartons(), + writeHadrons = D3PDMakerFlags.TruthWriteHadrons(), + writeGeant = D3PDMakerFlags.TruthWriteGeant(), + excludeLeptonsFromTau = False): + + if not rec.doTruth(): + return + + # Is the container already in SG? + if cfgKeyStore.isInInput ('TruthParticleContainer', sgkey): + return + + algname = prefix + sgkey + 'Builder' + if hasattr (seq, algname): + return + + filtname = prefix + sgkey + 'Filter' + + seq += createMcAodBuilder\ + (algname, + inMcEvtCollection = D3PDMakerFlags.TruthSGKey(), + outMcEvtCollection = sgkey + '_GEN_D3PD', + outTruthParticles = sgkey, + filterTool = D3PD__TruthJetFilterTool + (filtname, + DoPileup = doPileup, + WritePartons = writePartons, + WriteHadrons = writeHadrons, + WriteGeant = writeGeant, + ExcludeWZdecays = excludeWZdecays, + PhotonCone = photonCone, + ExcludeLeptonsFromTau = excludeLeptonsFromTau, + ), + cnvTool = CfgMgr.TruthParticleCnvTool('D3PDTruthJetCnvTool'), + ) + + cfgKeyStore.addTransient ('TruthParticleContainer', sgkey) + return diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthLeptonParentAssociation.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthLeptonParentAssociation.py new file mode 100644 index 00000000000..975f5b841d3 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthLeptonParentAssociation.py @@ -0,0 +1,31 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/TruthLeptonParentAssociation.py +# @author Zach Marshall <zach.marshall@cern.ch> +# @date June 2013 +# @brief Helper for setting up an association to lepton parents (not direct) in the truth record + +import TruthD3PDMaker +from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation + +def TruthLeptonParentAssociation (parent, + prefix = '', + target = '', + level = 0, + blockname = None, + *args, **kw): + """Helper for setting up an association to lepton parents in the truth record""" + + if blockname == None: + blockname = prefix + 'LeptonParentMultiAssoc' + + return IndexMultiAssociation (parent, + TruthD3PDMaker.TruthLeptonParentAssociationTool, + target, + prefix, + level, + blockname, + nrowName = '') + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleChildAssociation.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleChildAssociation.py new file mode 100644 index 00000000000..795b767121e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleChildAssociation.py @@ -0,0 +1,38 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/TruthParticleChildAssociation.py +# @author Ryan Reece <ryan.reece@cern.ch> +# @date Mar, 2010 +# @brief Helper for setting up an association for truth particle +# children by index. +# + + +import D3PDMakerCoreComps +import TruthD3PDMaker +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation + + +def TruthParticleChildAssociation (parent, + prefix = '', + target = '', + level = 0, + blockname = None, + *args, **kw): + """Helper for setting up an association for truth particle +children by index. +""" + if blockname == None: + blockname = prefix + 'TruthParticleChildAssociation' + + return IndexMultiAssociation (parent, + TruthD3PDMaker.TruthParticleChildAssociationTool, + target, + prefix, + level, + blockname, + nrowName = '') + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleD3PDObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleD3PDObject.py new file mode 100644 index 00000000000..78e8345af2d --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleD3PDObject.py @@ -0,0 +1,73 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/TruthParticleD3PDObject.py +# @author scott snyder <snyder@bnl.gov> +# @date Dec, 2009 +# @brief Define D3PD object for a collection of TruthParticle's. +# + + +import TruthD3PDMaker +import EventCommonD3PDMaker +import D3PDMakerCoreComps +from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject +from D3PDMakerCoreComps.SimpleAssociation import SimpleAssociation +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +from TruthD3PDMaker.TruthParticleChildAssociation import TruthParticleChildAssociation +from TruthD3PDMaker.TruthParticleParentAssociation import TruthParticleParentAssociation + + +TruthParticleD3PDObject = make_SGDataVector_D3PDObject \ + ('DataVector<xAOD::TruthParticle_v1>', + D3PDMakerFlags.TruthParticlesSGKey(), + 'mc_', + 'TruthParticleD3PDObject') + +TruthParticleD3PDObject.defineBlock (0, 'TruthKin', + EventCommonD3PDMaker.FourMomFillerTool) + +TruthParticleD3PDObject.defineBlock (0, 'TruthInfo', + TruthD3PDMaker.TruthParticleFillerTool) + +ProdVertexAssoc = SimpleAssociation \ + (TruthParticleD3PDObject, + TruthD3PDMaker.TruthParticleProdVertexAssociationTool, + level = 1, + prefix = 'vx_', + blockname = 'ProdVert') +ProdVertexAssoc.defineBlock ( + 1, 'ProdVertPos', + D3PDMakerCoreComps.AuxDataFillerTool, + Vars = ['x', 'y', 'z', 'barcode']) + + +ChildAssoc = TruthParticleChildAssociation( + parent = TruthParticleD3PDObject, + prefix = 'child_', + # target = '', # filled by hook + level = 0 ) + +def _TruthParticleChildAssocHook (c, prefix, *args, **kw): + assoc = getattr(c, c.name() + '_child_TruthParticleChildAssociation', None) + if assoc: + indexer = getattr(assoc, assoc.name() + 'Index') + indexer.Target = prefix + return +TruthParticleD3PDObject.defineHook(_TruthParticleChildAssocHook) + +ParentAssoc = TruthParticleParentAssociation( + parent = TruthParticleD3PDObject, + prefix = 'parent_', + # target = '', # filled by hook + level = 0 ) + +def _TruthParticleParentAssocHook (c, prefix, *args, **kw): + assoc = getattr(c, c.name() + '_parent_TruthParticleParentAssociation', None) + if assoc: + indexer = getattr(assoc, assoc.name() + 'Index') + indexer.Target = prefix + return +TruthParticleD3PDObject.defineHook(_TruthParticleParentAssocHook) + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleFakerObject.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleFakerObject.py new file mode 100644 index 00000000000..3ad98ababf7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleFakerObject.py @@ -0,0 +1,157 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +## @file TruthD3PDMaker/python/TruthParticleFakerObject.py +## @brief Truth D3PD object for single particles +## @author Zach Marshall <zach.marshall@cern.ch> +## @date Nov, 2010 +## + +import TruthD3PDMaker + +import D3PDMakerCoreComps +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + +from TruthD3PDAnalysis.AllTruthFilterTool import AllTruthFilterTool +from TruthD3PDAnalysis.StableChargedTruthFilterTool import StableChargedTruthFilterTool +from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags + +from AthenaCommon.SystemOfUnits import GeV + +def make_TruthParticleFaker_D3PDObject( default_prefix, default_sgkey, + default_object_name = "", + default_filter = AllTruthFilterTool(), + default_label = None, **other_defaults ): + + def make_obj( name, prefix, object_name, + getter = None, sgkey = None, filter = default_filter, + label = default_label, **kw ): + + if sgkey == None: sgkey = default_sgkey + if label == None: label = prefix + if getter == None: + getter = TruthD3PDMaker.GenParticleGetterTool (name + "_Getter", + Label = label, + SGKey = sgkey, + Selector = filter ) + + defs = other_defaults.copy() + defs.update( kw ) + + from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + return D3PDMakerCoreComps.VectorFillerTool( name, + Prefix = prefix, + Getter = getter, + ObjectName = object_name, + SaveMetadata = \ + D3PDMakerFlags.SaveObjectMetadata(), + **defs ) + + return D3PDObject( make_obj, default_prefix, default_object_name ) + +TruthParticleFakerD3PDObject = make_TruthParticleFaker_D3PDObject( 'tpf_' , + D3PDMakerFlags.TruthParticlesSGKey(), + "TruthParticleFakerD3PDObject", + AllTruthFilterTool(), + 'TruthParticleFaker_' ) + +TruthParticleFakerElD3PDObject = make_TruthParticleFaker_D3PDObject( 'tpfel_' , + D3PDMakerFlags.TruthParticlesSGKey(), + "TruthParticleFakerElD3PDObject", + AllTruthFilterTool(), + 'tpfel_' ) + +TruthParticleFakerElD3PDObject.defineBlock( 0, 'TruthParticleFaker', + TruthD3PDMaker.TruthParticleFakerTool , PDG_ID=11 , + WriteCharge=True , WritePn=True , WriteE=True , WriteEt=True ) + +TruthParticleFakerMuD3PDObject = make_TruthParticleFaker_D3PDObject( 'tpfmu_' , + D3PDMakerFlags.TruthParticlesSGKey(), + "TruthParticleFakerMuD3PDObject", + AllTruthFilterTool(), + 'tpfmu_' ) + +TruthParticleFakerMuD3PDObject.defineBlock( 0, 'TruthParticleFaker', + TruthD3PDMaker.TruthParticleFakerTool , PDG_ID=13 , + WriteCharge=True , WritePn=True , WriteE=True , WriteEt=False ) + +TruthParticleFakerPhD3PDObject = make_TruthParticleFaker_D3PDObject( 'tpfph_' , + D3PDMakerFlags.TruthParticlesSGKey(), + "TruthParticleFakerPhD3PDObject", + AllTruthFilterTool(), + 'tpfph_' ) + +TruthParticleFakerPhD3PDObject.defineBlock( 0, 'TruthParticleFaker', + TruthD3PDMaker.TruthParticleFakerTool , PDG_ID=22 , + WriteCharge=False , WritePn=True , WriteE=True , WriteEt=True ) + +TruthParticleFakerTauD3PDObject = make_TruthParticleFaker_D3PDObject( 'tpftau_' , + D3PDMakerFlags.TruthParticlesSGKey(), + "TruthParticleFakerTauD3PDObject", + AllTruthFilterTool(), + 'tpftau_' ) + +TruthParticleFakerTauD3PDObject.defineBlock( 0, 'TruthParticleFaker', + TruthD3PDMaker.TruthParticleFakerTool , PDG_ID=15 , + WriteCharge=True , WritePn=False , WriteE=False , WriteEt=True ) + +# Create stupid little collections for each of these... +from AthenaCommon.AlgSequence import AlgSequence +from RecExConfig.ObjKeyStore import cfgKeyStore +from McParticleAlgs.JobOptCfg import createMcAodBuilder +import TruthD3PDAnalysis +from AthenaCommon import CfgMgr +def simpleParticleConfig (seq = AlgSequence(D3PDMakerFlags.PreD3PDAlgSeqName()), + sgkey = 'SimpleTruthCollection', + prefix = '', + pdg_id = 11, + min_pt = -1.*GeV): + + # Is the container already in SG? + if cfgKeyStore.isInInput ('TruthParticleContainer', sgkey): return + + # Is the algorithm already registered? + algname = prefix + sgkey + 'Builder' + if hasattr (seq, algname): return + + filtname = prefix + sgkey + 'Filter' + + seq += createMcAodBuilder\ + (algname, + inMcEvtCollection = D3PDMakerFlags.TruthSGKey(), + outMcEvtCollection = sgkey + '_GEN_D3PD', + outTruthParticles = sgkey, + filterTool = TruthD3PDAnalysis.SimpleTruthParticleFilterTool + (filtname, + PDG_ID = pdg_id, + MinPt = min_pt), + cnvTool = CfgMgr.TruthParticleCnvTool('D3PDTruthParticleCnvTool'), + ) + + cfgKeyStore.addTransient ('TruthParticleContainer', sgkey) + return + + +from D3PDMakerCoreComps.D3PDObject import make_SGDataVector_D3PDObject +import EventCommonD3PDMaker +def simpleTruthParticleD3PDObject( sgkey_in , prefix = 'mc_' , skipDressing=False ): + + simpleTPDO = make_SGDataVector_D3PDObject \ + ('TruthParticleContainer', + sgkey_in, + prefix, + 'TruthParticleD3PDObject') + + simpleTPDO.defineBlock (0, 'TruthKin', + EventCommonD3PDMaker.FourMomFillerTool) + + simpleTPDO.defineBlock (0, 'TruthInfo', + TruthD3PDMaker.TruthParticleFillerTool) + + if not skipDressing: + simpleTPDO.defineBlock(0, 'TruthNearby_Info', + TruthD3PDMaker.TruthLeptonNearbyAssociationTool) + + return simpleTPDO + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleParentAssociation.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleParentAssociation.py new file mode 100644 index 00000000000..f0ee62e6ac0 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthParticleParentAssociation.py @@ -0,0 +1,37 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/TruthParticleParentAssociation.py +# @author Ryan Reece <ryan.reece@cern.ch> +# @date Mar, 2010 +# @brief Helper for setting up an association for truth particle +# parents by index. +# + + +import D3PDMakerCoreComps +import TruthD3PDMaker +from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation + + +def TruthParticleParentAssociation (parent, + prefix = '', + target = '', + level = 0, + blockname = None, + *args, **kw): + """Helper for setting up an association for truth particle +parents by index. +""" + if blockname == None: + blockname = prefix + 'TruthParticleParentAssociation' + + return IndexMultiAssociation (parent, + TruthD3PDMaker.TruthParticleParentAssociationTool, + target, + prefix, + level, + blockname, + nrowName = '') diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthTauDecayAssociation.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthTauDecayAssociation.py new file mode 100644 index 00000000000..0f70fffb537 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/TruthTauDecayAssociation.py @@ -0,0 +1,33 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/TruthTauDecayAssociation.py +# @author Zach Marshall <zach.marshall@cern.ch> +# @date June 2013 +# @brief Helper for setting up an association to tau decay products in the truth record + +#import D3PDMakerCoreComps +import TruthD3PDMaker +#from D3PDMakerCoreComps.D3PDObject import D3PDObject +from D3PDMakerCoreComps.IndexMultiAssociation import IndexMultiAssociation + +def TruthTauDecayAssociation (parent, + prefix = '', + target = '', + level = 0, + blockname = None, + *args, **kw): + """Helper for setting up an association to tau decay products in the truth record""" + + if blockname == None: + blockname = prefix + 'TauDecayMultiAssoc' + + return IndexMultiAssociation (parent, + TruthD3PDMaker.TruthTauDecayAssociationTool, + target, + prefix, + level, + blockname, + nrowName = '') + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/__init__.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/__init__.py new file mode 100644 index 00000000000..c36b88ca818 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/__init__.py @@ -0,0 +1,16 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/__init__.py +# @author scott snyder <snyder@bnl.gov> +# @date Mar, 2011 +# @brief Move configurables into the module namespace. +# + +# Install any configurables from this package in the D3PD namespace +# directly in the top-level module, without the namespace prefix. +import TruthD3PDMakerConf +for k, v in TruthD3PDMakerConf.__dict__.items(): + if k.startswith ('D3PD__'): + globals()[k[6:]] = v diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/atlfast1D3PD.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/atlfast1D3PD.py new file mode 100644 index 00000000000..ab85305ad88 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/atlfast1D3PD.py @@ -0,0 +1,80 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/atlfast1D3PD.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Feb, 2010 +# @brief Construct an atlfast1 D3PD. +# + + +import D3PDMakerCoreComps +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + + +from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject +from TruthD3PDMaker.Atlfast1ElectronD3PDObject import Atlfast1ElectronD3PDObject +from TruthD3PDMaker.Atlfast1PhotonD3PDObject import Atlfast1PhotonD3PDObject +from MuonD3PDMaker.MuonD3PDObject import MuonD3PDObject +from TrackD3PDMaker.TrackD3PDObject import TrackParticleD3PDObject +from JetD3PDMaker.JetD3PDObject import JetD3PDObject +from TruthD3PDMaker.TruthJetD3PDObject import TruthJetD3PDObject +#from TauD3PDMaker.TauD3PDObject import TauD3PDObject +from MissingETD3PDMaker.MissingETD3PDMakerFlags import MissingETD3PDMakerFlags +from TruthD3PDMaker.Atlfast1MissingETD3PDObject import Atlfast1MissingETD3PDObject +from TruthD3PDMaker.Atlfast1MissingETD3PDObject import TruthMETD3PDObject +from EventCommonD3PDMaker.LBMetadataConfig import LBMetadataConfig +from HforD3PDObject import HforD3PDObject + + +from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject +from TruthD3PDAnalysis.truthParticleConfig import truthParticleConfig +#from TruthD3PDAnalysis.TruthJetFilterConfig import TruthJetFilterConfig +from TruthD3PDMaker.TruthParticleD3PDObject import TruthParticleD3PDObject +from TruthD3PDMaker.PartonJetConfig import PartonJetConfig +from RecExConfig.RecFlags import rec + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +def atlfast1D3PD (file, + tuplename = 'atlfast1', + seq = topSequence, + D3PDSvc = 'D3PD::RootD3PDSvc'): + + #-------------------------------------------------------------------------- + # Configuration + #-------------------------------------------------------------------------- + if rec.doTruth(): + truthParticleConfig (seq) + #TruthJetFilterConfig (seq, excludeWZdecays = False) + # PartonJetConfig is used to build parton-level jets + # PartonJetConfig requires JetSimTools-00-01-22 or higher + PartonJetConfig (doPythia = True, doHerwig = False) + + #-------------------------------------------------------------------------- + # Make the D3PD + #-------------------------------------------------------------------------- + alg = D3PDMakerCoreComps.MakerAlg(tuplename, seq, + file = file, D3PDSvc = D3PDSvc) + alg += EventInfoD3PDObject (10) + alg += Atlfast1ElectronD3PDObject (10) + alg += Atlfast1PhotonD3PDObject (10) + alg += MuonD3PDObject (0) + alg += JetD3PDObject (0) + alg += Atlfast1MissingETD3PDObject (0) + + #alg += TauD3PDObject (0) + #alg += TrackParticleD3PDObject (0) + + if rec.doTruth(): + alg += GenEventD3PDObject (1) + alg += TruthParticleD3PDObject (1) + alg += TruthMETD3PDObject (level=10) + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt4TruthJets', prefix='AntiKt4TruthJets_') + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt4TruthPartonJets', prefix='AntiKt4TruthPartonJets_') + alg += HforD3PDObject (**_args (0, 'HforInfo', kw)) + + return alg diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/evgenD3PD.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/evgenD3PD.py new file mode 100644 index 00000000000..b2e5fdf1cd5 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/python/evgenD3PD.py @@ -0,0 +1,106 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# $Id$ +# +# @file TruthD3PDMaker/python/evgenD3PD.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Apr, 2010 +# @brief Construct an evgen D3PD. +# + + +import D3PDMakerCoreComps +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags + + +from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject +from JetD3PDMaker.JetD3PDObject import JetD3PDObject +from TruthD3PDMaker.TruthJetD3PDObject import TruthJetD3PDObject +from MissingETD3PDMaker.MissingETD3PDMakerFlags import MissingETD3PDMakerFlags +from TruthD3PDMaker.Atlfast1MissingETD3PDObject import TruthMETD3PDObject + +from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject +from TruthD3PDAnalysis.truthParticleConfig import truthParticleConfig +from TruthD3PDMaker.TruthJetFilterConfig import TruthJetFilterConfig +from TruthD3PDMaker.TruthParticleD3PDObject import TruthParticleD3PDObject +from TruthD3PDMaker.PartonJetConfig import PartonJetConfig +from RecExConfig.RecFlags import rec +from JetRec.JetGetters import * + +from AthenaCommon.AlgSequence import AlgSequence +topSequence = AlgSequence() + + +def evgenD3PD (file, + tuplename = 'evgen', + seq = topSequence, + D3PDSvc = 'D3PD::RootD3PDSvc'): + + #-------------------------------------------------------------------------- + # Configuration + #-------------------------------------------------------------------------- + if rec.doTruth(): + # compatibility with jets + from RecExConfig.RecConfFlags import jobproperties + jobproperties.RecConfFlags.AllowBackNavigation = True + from JetRec.JetRecFlags import jobproperties as jobpropjet + jobpropjet.JetRecFlags.inputFileType = "GEN" + + # Build list of particles stored in D3PD + truthParticleConfig (seq) + + # Build list of particles used to jet building + # Be careful, if doExcludeWZdecays == True, + # then W and Z decays (including electrons, QCD FSRs) are excluded from jet building + doExcludeWZdecays = True + mysuffix = 'WZ' if doExcludeWZdecays else '' + TruthJetFilterConfig (seq, writePartons = True, writeHadrons = True, + excludeWZdecays = doExcludeWZdecays) + + # PartonJetConfig is used to build parton-level jets + # PartonJetConfig requires JetSimTools-00-01-22 or higher + PartonJetConfig (doPythia = True, doHerwig = False, + finder = 'AntiKt', size = 0.4, suffix = mysuffix, + inputCollections = ['FilteredD3PDTruth']) + PartonJetConfig (doPythia = True, doHerwig = False, + finder = 'AntiKt', size = 0.6, suffix = mysuffix, + inputCollections = ['FilteredD3PDTruth']) + + # Build truth particle (hadron-level) jets + # flags for AOD + from ParticleBuilderOptions.AODFlags import AODFlags + AODFlags.MissingEtTruth = True + AODFlags.TruthParticleJet = True + AODFlags.McEventKey="GEN_EVENT" + # The function that makes the truth jets, with appropriate arguments + antikt4truthAlg = make_StandardJetGetter('AntiKt',0.4,'Truth',globalSuff=mysuffix,disable=False,includeMuons=True,useInteractingOnly=False).jetAlgorithmHandle() + antikt4truthAlg.AlgTools['InputToJet'].InputCollectionKeys = ['FilteredD3PDTruth'] + print 'antikt4truthAlg',antikt4truthAlg + antikt6truthAlg = make_StandardJetGetter('AntiKt',0.6,'Truth',globalSuff=mysuffix,disable=False,includeMuons=True,useInteractingOnly=False).jetAlgorithmHandle() + antikt6truthAlg.AlgTools['InputToJet'].InputCollectionKeys = ['FilteredD3PDTruth'] + if doExcludeWZdecays: + # Reconstruct standard ATLAS truth jets + antikt4truthAlgStd = make_StandardJetGetter('AntiKt',0.4,'Truth',disable=False).jetAlgorithmHandle() + antikt6truthAlgStd = make_StandardJetGetter('AntiKt',0.6,'Truth',disable=False).jetAlgorithmHandle() + + + #-------------------------------------------------------------------------- + # Make the D3PD + #-------------------------------------------------------------------------- + alg = D3PDMakerCoreComps.MakerAlg(tuplename, seq, + file = file, D3PDSvc = D3PDSvc) + alg += EventInfoD3PDObject (10) + + if rec.doTruth(): + alg += GenEventD3PDObject (1) + alg += TruthParticleD3PDObject (1) + alg += TruthMETD3PDObject (level=10) + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt4Truth'+mysuffix+'Jets', prefix='jet_antikt4truth'+mysuffix+'jets_') + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt6Truth'+mysuffix+'Jets', prefix='jet_antikt6truth'+mysuffix+'jets_') + if doExcludeWZdecays: + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt4TruthJets', prefix='jet_antikt4truthjets_') + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt6TruthJets', prefix='jet_antikt6truthjets_') + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt4TruthParton'+mysuffix+'Jets', prefix='jet_antikt4truthparton'+mysuffix+'jets_') + alg += TruthJetD3PDObject (level=10, sgkey='AntiKt6TruthParton'+mysuffix+'Jets', prefix='jet_antikt6truthparton'+mysuffix+'jets_') + + return alg diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/GenD3PDExample_jobOptions.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/GenD3PDExample_jobOptions.py new file mode 100644 index 00000000000..d01dcc54d2f --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/GenD3PDExample_jobOptions.py @@ -0,0 +1,71 @@ + +###################################################################3 +# Define the input file here. +# + +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +#athenaCommonFlags.FilesInput = [ "AOD.pool.root" ] +athenaCommonFlags.FilesInput= ["/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000002.pool.root.1"] + + +###################################################################3 +# Define the output file here. +# + +if not globals().get('tupleFileOutput'): + tupleFileOutput = 'gen_objects.root' + + +###################################################################3 +# Define other job options here. +# + +athenaCommonFlags.EvtMax = 100 + +################################################################### +# Configure RecExCommon. +# + +from RecExConfig.RecFlags import rec +rec.AutoConfiguration.set_Value_and_Lock( [ "everything" ] ) +rec.doCBNT.set_Value_and_Lock(False) +rec.doWriteESD.set_Value_and_Lock(False) +rec.doWriteAOD.set_Value_and_Lock(False) +rec.doAOD.set_Value_and_Lock(False) +rec.doESD.set_Value_and_Lock(False) +rec.doDPD.set_Value_and_Lock(False) +rec.doWriteTAG.set_Value_and_Lock(False) +rec.doForwardDet.set_Value_and_Lock(False) +include ("RecExCommon/RecExCommon_topOptions.py") + +###################################################################3 +# Make the D3PD. +# +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +alg = MSMgr.NewRootStream( "StreamNTUP_GEN", tupleFileOutput, "gend3pd" ) + +from TruthD3PDMaker.TruthD3PDMakerKeys import TruthD3PDKeys +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags + +from TruthD3PDAnalysis.GenObjectsFilterTool import * + +from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject +alg += GenEventD3PDObject( 10, filter = AllTrackFilterTool(), + pileup_CollectionGetterRegistry=\ + alg.name()+'_CollectionGetterRegistry') + +from TruthD3PDMaker.GenVertexD3PDObject import GenVertexD3PDObject +alg += GenVertexD3PDObject( 10, filter = AllTrackFilterTool() ) + +from TruthD3PDMaker.GenParticleD3PDObject import GenParticleD3PDObject +alg += GenParticleD3PDObject( 10, filter = AllTrackFilterTool() ) + +### stable charged particle with perigee info +from TruthD3PDMaker.GenParticleD3PDObject import GenTruthTrackD3PDObject +alg += GenTruthTrackD3PDObject( 10, filter = TruthTrackFilterTool() ) + +#from TruthD3PDMaker.HforD3PDObject import HforD3PDObject +#alg += HforD3PDObject(**_args(0,'HforInfo',kw)) + +### you can link to the gen particle (e.g from tracks or btag truth lepton info) +### using the gen particle getter label: TruthD3PDKeys.GenParticleGetterLabel() diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_preInclude.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_preInclude.py new file mode 100644 index 00000000000..937b69d2037 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_preInclude.py @@ -0,0 +1,70 @@ +# Example of changing D3PD maker flags. +# Redefine SG keys for evgen running + +################################################################### +# Configure RecExCommon. +# +# Need to set dummy values for when running on pure EVNT files +# if you are running on normal AODs (full simulation), comment next 4 lines +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.ConditionsTag.set_Value_and_Lock('OFLCOND-MC12b-SIM-00') +globalflags.DetDescrVersion.set_Value_and_Lock("ATLAS-GEO-20-00-01") + +## Turn off geometry construction... +#from AthenaCommon.DetFlags import DetFlags +#DetFlags.all_setOff() + +from RecExConfig.RecFlags import rec +rec.doDPD=True +rec.doTruth=True +rec.readAOD.set_Value_and_Lock(True) +rec.AutoConfiguration.set_Value_and_Lock(['ProjectName','BeamType','RealOrSim','DoTruth','InputType']) +rec.doApplyAODFix.set_Value_and_Lock(False) +rec.doTrigger=False +#rec.LoadGeometry.set_Value_and_Lock(False) +rec.doInDet.set_Value_and_Lock(False) +rec.doCalo.set_Value_and_Lock(False) +rec.doMuon.set_Value_and_Lock(False) +rec.doForwardDet.set_Value_and_Lock(False) +rec.doAOD.set_Value_and_Lock(False) + +# The following flags are mandatory if you build jets +from JetRec.JetRecFlags import jetFlags +jetFlags.noStandardConfig.set_Value_and_Lock(True) +jetFlags.evgenJets.set_Value_and_Lock(True) + +# This is necessary to properly disable JVF tools... +# Unfortunately, the functions only exist in newer releases... +try: + from JetMomentTools import JetMomentsConfigHelpers + JetMomentsConfigHelpers.recommendedAreaAndJVFMoments = lambda *l,**a:None +except: + pass + +#-------------------------------------------------------------------------- +# Configuration +#-------------------------------------------------------------------------- +# Set up the D3PD flags the way we want them +# These can be overriden via a set_and_lock_value() +from AthenaCommon.SystemOfUnits import GeV +from D3PDMakerConfig.D3PDMakerFlags import jobproperties +jobproperties.D3PDMakerFlags.DoTrigger = False +jobproperties.D3PDMakerFlags.TruthSGKey = 'GEN_EVENT,GEN_AOD,TruthEvent' +jobproperties.D3PDMakerFlags.TruthWriteTauHad = True +jobproperties.D3PDMakerFlags.TruthWriteBSM = True +jobproperties.D3PDMakerFlags.TruthWriteBHadrons = False +jobproperties.D3PDMakerFlags.TruthWriteBosons = True +jobproperties.D3PDMakerFlags.TruthWriteHadrons = False +jobproperties.D3PDMakerFlags.TruthWritePartons = False +jobproperties.D3PDMakerFlags.TruthPartonPtThresh = 5.*GeV +jobproperties.D3PDMakerFlags.TruthWriteBosonProducts = True +jobproperties.D3PDMakerFlags.TruthWriteBSMProducts = True +jobproperties.D3PDMakerFlags.TruthWriteTopAndDecays = True +#jobproperties.D3PDMakerFlags.TruthWriteFirstN = 10 + +from JetTagD3PDMaker.JetTagD3PDMakerFlags import JetTagD3PDFlags +JetTagD3PDFlags.JetTrackAssoc=False + +rec.DPDMakerScripts.append("TruthD3PDMaker/TruthD3PDfromEVGEN_prodOptions.py") + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_prodOptions.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_prodOptions.py new file mode 100644 index 00000000000..c2c6f0a24e6 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_prodOptions.py @@ -0,0 +1,233 @@ +# Build truth missing Et +include( "ParticleBuilderOptions/MissingEtTruth_jobOptions.py" ) +METPartTruth.TruthCollectionName = "GEN_EVENT" +topSequence.METAlg += METPartTruth + +################################################################### +# Make the D3PD. +# + +#-------------------------------------------------------------------------- +# Configuration +#-------------------------------------------------------------------------- +from AthenaCommon.SystemOfUnits import GeV +from D3PDMakerConfig.D3PDMakerFlags import jobproperties + +# compatibility with jets +#from RecExConfig.RecConfFlags import jobproperties +#jobproperties.RecConfFlags.AllowBackNavigation = True + +from JetRec.JetRecFlags import jobproperties as jobpropjet +jobpropjet.JetRecFlags.inputFileType = "GEN" + +# Build list of particles stored in D3PD +from TruthD3PDAnalysis.truthParticleConfig import truthParticleConfig +truthParticleConfig (topSequence) + +# Build list of particles used to jet building +from TruthD3PDMaker.TruthJetFilterConfig import TruthJetFilterConfig +TruthJetFilterConfig (topSequence, writePartons = False, writeHadrons = True, + excludeWZdecays = True) +# Build list of particles used for WZ jet building +TruthJetFilterConfig (topSequence, sgkey = 'FilteredWZD3PDTruth', writePartons = False, writeHadrons = True, + excludeWZdecays = True, photonCone=0.1, excludeLeptonsFromTau=True) + +# Build truth particle (hadron-level) jets +# Flags for AOD +from ParticleBuilderOptions.AODFlags import AODFlags +AODFlags.MissingEtTruth = True +AODFlags.TruthParticleJet = True +AODFlags.McEventKey="GEN_EVENT" + +# Reconstruct standard ATLAS truth jets +from JetRec.JetGetters import * +antikt4truthAlgStd = make_StandardJetGetter('AntiKt',0.4,'Truth',disable=False).jetAlgorithmHandle() +antikt6truthAlgStd = make_StandardJetGetter('AntiKt',0.6,'Truth',disable=False).jetAlgorithmHandle() + +# Add truth jet collection that includes all final state particles (including muons and neutrinos) +antikt4truthAlgWZ = make_StandardJetGetter('AntiKt',0.4,'Truth',disable=False, + inputCollectionNames=['FilteredWZD3PDTruth'], + outputCollectionName='AntiKt4TruthJets_WZ', + useInteractingOnly=False, + includeMuons=True + ).jetAlgorithmHandle() +antikt6truthAlgWZ = make_StandardJetGetter('AntiKt',0.6,'Truth',disable=False, + inputCollectionNames=['FilteredWZD3PDTruth'], + outputCollectionName='AntiKt6TruthJets_WZ', + useInteractingOnly=False, + includeMuons=True + ).jetAlgorithmHandle() + +if jobproperties.D3PDMakerFlags.TruthWriteExtraJets(): + antikt6truthAlgStd = make_StandardJetGetter('AntiKt',0.6,'Truth',disable=False).jetAlgorithmHandle() + antikt4truthAlgWZ = make_StandardJetGetter('AntiKt',0.4,'Truth',disable=False, + outputCollectionName='AntiKt4TruthJets_ALL', + useInteractingOnly=False, + includeMuons=True + ).jetAlgorithmHandle() + antikt6truthAlgWZ = make_StandardJetGetter('AntiKt',0.6,'Truth',disable=False, + outputCollectionName='AntiKt6TruthJets_ALL', + useInteractingOnly=False, + includeMuons=True + ).jetAlgorithmHandle() + + # Make trimmed fat jet: + from SUSYD3PDMaker.SUSYJSjets import setupTruthJets + GroomedDictsTrimming = [ { 'Type' : 'Trimming', + 'args' : { 'SmallR' : 0.3, 'PtFrac' : 0.05 , 'SaveSubjets' : True } } ] + jetsToWrite = setupTruthJets('AntiKt', 1.0, GroomedDictsTrimming, topSequence) + + +#-------------------------------------------------------------------------- +# Make the D3PD +#-------------------------------------------------------------------------- +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +alg = MSMgr.NewRootStream( "StreamNTUP_TRUTH", TruthD3PDFlags.TruthD3PDOutputFileName(), "truth" ) + + +#-------------------------------------------------------------------------- +# Configure the heavy flavour overlap removal(Hfor) tool +#-------------------------------------------------------------------------- + +# Is there a preExec variable telling us not to use Hfor? +if "useHfor" not in dir() or useHfor: + + # If steering file is not defined in runArgs then use default file + if "hforSteeringFile" not in dir(): + hforSteeringFile = "/cvmfs/atlas.cern.ch/repo/sw/Generators/MC12JobOptions/latest/hfor/hforconfig.txt" + + # Get the sample type from the steering file (i.e. isBB, isCC etc.) + import TruthD3PDMaker.HforConfig as HFC + hforConfTool = HFC.HforConfig() + hforSampleType = hforConfTool.getSampleType(runArgs, hforSteeringFile) + + # Check that we found a valid configuration type + if hforSampleType != "fail": + # Set up the HFOR D3PD object + from TruthD3PDMaker.HforD3PDObject import HforD3PDObject + alg += HforD3PDObject(0,'HforInfo') + + # Configure the Hfor tool + from AthenaCommon.AppMgr import ToolSvc + from HforTool.HforToolConf import HforTool + ToolSvc += HforTool("HforTool") + ToolSvc.HforTool.RemovalSchema = "jetbased" + ToolSvc.HforTool.SampleType = hforSampleType + + +#-------------------------------------------------------------------------- +# Copy EventInfo into D3PD +#-------------------------------------------------------------------------- +from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject +alg += EventInfoD3PDObject (0,'EventInfo') + + +#-------------------------------------------------------------------------- +# Copy (a subset of) the HepMC truth event into D3PD +#-------------------------------------------------------------------------- +from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject +alg += GenEventD3PDObject (0, 'GenEvent') + +if TruthD3PDFlags.WriteTruthVertices(): + from TruthD3PDMaker.GenVertexD3PDObject import GenVertexD3PDObject + alg += GenVertexD3PDObject(1, 'GenVertex', sgkey=jobproperties.D3PDMakerFlags.TruthSGKey(),prefix='mcVx_',label='mcVx_') + +from JetD3PDMaker.JetD3PDObject import JetD3PDObject as myJetD3PDObject +import TruthD3PDMaker + +# Add parton flavor information to jets +myJetD3PDObject.defineBlock(0, 'JetFullTruthTag_Info',TruthD3PDMaker.JetFullTruthTag,prefix='flavor_',MinPartonPt=5*GeV,MinHadronPt=5*GeV) + +alg += myJetD3PDObject (2, 'Jet_Truth', sgkey='AntiKt4TruthJets', prefix='jet_AntiKt4TruthJets_', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) +alg += myJetD3PDObject (2, 'Jet_Truth_WZ', sgkey='AntiKt4TruthJets_WZ', prefix='jet_AntiKt4TruthJets_WZ_', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) +alg += myJetD3PDObject (2, 'Jet_Truth6_WZ', sgkey='AntiKt6TruthJets_WZ', prefix='jet_AntiKt6TruthJets_WZ_', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) + +if jobproperties.D3PDMakerFlags.TruthWriteExtraJets(): + alg += myJetD3PDObject (2, 'Jet_Truth6', sgkey='AntiKt6TruthJets', prefix='jet_AntiKt6TruthJets_', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) + alg += myJetD3PDObject (2, 'Jet_Truth_ALL', sgkey='AntiKt4TruthJets_ALL', prefix='jet_AntiKt4TruthJets_ALL_', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) + alg += myJetD3PDObject (2, 'Jet_Truth6_ALL', sgkey='AntiKt6TruthJets_ALL', prefix='jet_AntiKt6TruthJets_ALL_', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) + + alg += myJetD3PDObject (2, 'Jet_Truth10', sgkey='AntiKt10TruthJets', prefix='jet_AntiKt10TruthJets_', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) + alg += myJetD3PDObject(2, 'Jet_Truth10Trim', prefix='jet_AntiKt10TruthTrimmedPtFrac5SmallR30_', sgkey='AntiKt10TruthTrimmedPtFrac5SmallR30Jets', include=['TrueFlavorComponents','JetLabel'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo','OriginCorrection','DQMoments','JetSamplingsFrac','JetQual','EMFraction','JES','JESMoments','EMScale','Layer','Samplings','ConstituentScale','JetLArHVMoment','JetClusterMoment']) + +from TruthD3PDMaker.TruthParticleD3PDObject import TruthParticleD3PDObject +alg += TruthParticleD3PDObject (1, 'TruthParticle') +alg.TruthParticle.BlockFillers[1].WriteE=True # Turn on the writing of the Energy branch + +from TruthD3PDMaker.Atlfast1MissingETD3PDObject import TruthMETD3PDObject +alg += TruthMETD3PDObject (level=10) + +# Add the necessary input containers for the objects +from TruthD3PDMaker.TruthParticleFakerObject import simpleParticleConfig +simpleParticleConfig(topSequence,sgkey='SimpleElectronContainer',pdg_id=11,min_pt=1*GeV) +simpleParticleConfig(topSequence,sgkey='SimpleMuonContainer',pdg_id=13,min_pt=1*GeV) +simpleParticleConfig(topSequence,sgkey='SimpleTauContainer',pdg_id=15,min_pt=1*GeV) +simpleParticleConfig(topSequence,sgkey='SimplePhotonContainer',pdg_id=22,min_pt=3*GeV) + +# Set up and add the objects to the alg sequence +from TruthD3PDMaker.TruthParticleFakerObject import simpleTruthParticleD3PDObject +elTruth = simpleTruthParticleD3PDObject( 'SimpleElectronContainer' , 'el_' ) +muTruth = simpleTruthParticleD3PDObject( 'SimpleMuonContainer' , 'mu_' ) +tauTruth = simpleTruthParticleD3PDObject( 'SimpleTauContainer' , 'tau_' , skipDressing=True ) + +# Add lepton parent association to leptons +from TruthD3PDMaker.TruthLeptonParentAssociation import TruthLeptonParentAssociation +for lepTruth in [elTruth,muTruth,tauTruth]: + ChildAssoc = TruthLeptonParentAssociation( + parent = lepTruth, + prefix = 'parent_', + target = 'mc_', + level = 0 ) +def _TruthElParentAssocHook (c, prefix, *args, **kw): + assoc = getattr(c, c.name() + '_child_ElParentDecayAssociation', None) + if assoc: + indexer = getattr(assoc, assoc.name() + 'Index') + indexer.Target = prefix + return +elTruth.defineHook(_TruthElParentAssocHook) + +def _TruthMuParentAssocHook (c, prefix, *args, **kw): + assoc = getattr(c, c.name() + '_child_MuParentDecayAssociation', None) + if assoc: + indexer = getattr(assoc, assoc.name() + 'Index') + indexer.Target = prefix + return +muTruth.defineHook(_TruthMuParentAssocHook) + +def _TruthTauParentAssocHook (c, prefix, *args, **kw): + assoc = getattr(c, c.name() + '_child_TauParentDecayAssociation', None) + if assoc: + indexer = getattr(assoc, assoc.name() + 'Index') + indexer.Target = prefix + return +tauTruth.defineHook(_TruthTauParentAssocHook) + +# Add hadronic daughter association to the taus! +from TruthD3PDMaker.TruthTauDecayAssociation import TruthTauDecayAssociation +ChildAssoc = TruthTauDecayAssociation( + parent = tauTruth, + prefix = 'decay_', + target = 'mc_', + level = 0 ) +def _TruthTauDecayAssocHook (c, prefix, *args, **kw): + assoc = getattr(c, c.name() + '_child_TruthTauDecayAssociation', None) + if assoc: + indexer = getattr(assoc, assoc.name() + 'Index') + indexer.Target = prefix + return +tauTruth.defineHook(_TruthTauDecayAssocHook) + +phTruth = simpleTruthParticleD3PDObject( 'SimplePhotonContainer' , 'ph_' , skipDressing=True ) +alg += elTruth (0,'ElTruthParticle',sgkey='SimpleElectronContainer') +alg += muTruth (0,'MuTruthParticle',sgkey='SimpleMuonContainer') +alg += tauTruth(0,'TauTruthParticle',sgkey='SimpleTauContainer') +alg += phTruth (0,'PhotonTruthParticle',sgkey='SimplePhotonContainer') + +# To explicitly list variables to keep or exclude in final D3PD +from AthenaCommon.AppMgr import ServiceMgr +from D3PDMakerRoot.D3PDMakerRootConf import D3PD__RootD3PDSvc +ServiceMgr += D3PD__RootD3PDSvc( "MyD3PDVetoSvc") +ServiceMgr.MyD3PDVetoSvc.VetoedNames = [ 'timestamp','timestamp_ns','lbn','bcid','detmask0','detmask1','actualIntPerXing','averageIntPerXing', + 'el_pdgId','mu_pdgId','tau_pdgId','ph_pdgId','ph_charge'] # These are just stupid +alg.D3PDSvc = ServiceMgr.MyD3PDVetoSvc diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_topOptions.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_topOptions.py new file mode 100644 index 00000000000..bcc70899c3f --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthD3PDfromEVGEN_topOptions.py @@ -0,0 +1,47 @@ +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Apr, 2010 +# @brief Example for building a D3PD from event generation file. + +################################################################### +# Define the input file here. +# + +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +athenaCommonFlags.FilesInput= ["EVNT.pool.root"] + +################################################################### +# Define the output file here. +# +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags +if not globals().get('tupleFileOutput'): + tupleFileOutput = 'susy.root' +TruthD3PDFlags.TruthD3PDOutputFileName = tupleFileOutput + + +################################################################### +# Define other job options here. +# + +athenaCommonFlags.EvtMax = 10 + +include("TopInputsD3PD.py") +#from TruthD3PDMaker.topInputsD3PD import topInputsD3PD +#alg = topInputsD3PD(tupleFileOutput) + +#from HforTool.HforToolConf import HforTool +#ToolSvc += HforTool("HforTool"); +#ToolSvc.HforTool.RemovalSchema = "angularbased" #"jetbased", "angularbased","mc08" +#ToolSvc.HforTool.SampleType = "isC" #isBB isCC isC isLightFlavor + +from RecExConfig.RecFlags import rec +rec.doHist = False +rec.doMonitoring = False +rec.doCBNT = False +rec.doWriteESD = False +rec.doWriteAOD = False +rec.doWriteTAG = False +rec.doApplyAODFix = False + +include("TruthD3PDMaker/TruthD3PDfromEVGEN_preInclude.py") + +include("RecExCommon/RecExCommon_topOptions.py") diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_preInclude.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_preInclude.py new file mode 100644 index 00000000000..95f9028a0ea --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_preInclude.py @@ -0,0 +1,33 @@ +# Example of changing D3PD maker flags. +# Redefine SG keys for evgen running +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +D3PDMakerFlags.TruthSGKey = 'GEN_EVENT,GEN_AOD,TruthEvent' +D3PDMakerFlags.DoTrigger = False +D3PDMakerFlags.TruthWriteBHadrons = True +D3PDMakerFlags.TruthWriteEverything = True + +################################################################### +# Configure RecExCommon. +# +# Need to set dummy values for when running on pure EVNT files +# if you are running on normal AODs (full simulation), comment next 4 lines +from AthenaCommon.GlobalFlags import globalflags +globalflags.DetGeo.set_Value_and_Lock('atlas') +globalflags.ConditionsTag.set_Value_and_Lock('OFLCOND-SDR-BS7T-04-13') +globalflags.DetDescrVersion.set_Value_and_Lock("ATLAS-GEO-16-00-00") + +from RecExConfig.RecFlags import rec +rec.doDPD=True +rec.readAOD.set_Value_and_Lock(True) +rec.AutoConfiguration.set_Value_and_Lock(['ProjectName','BeamType','RealOrSim','DoTruth','InputType']) + +# The following flags are mandatory if you build jets +from JetRec.JetRecFlags import jetFlags +jetFlags.noStandardConfig.set_Value_and_Lock(True) +jetFlags.evgenJets.set_Value_and_Lock(True) + +rec.DPDMakerScripts.append("TruthD3PDMaker/TruthSusyD3PDfromEVGEN_prodOptions.py") + + + + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_prodOptions.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_prodOptions.py new file mode 100644 index 00000000000..3cd9a17304c --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_prodOptions.py @@ -0,0 +1,106 @@ +# Build truth missing Et +include( "ParticleBuilderOptions/MissingEtTruth_jobOptions.py" ) +METPartTruth.TruthCollectionName="GEN_EVENT" +topSequence.METAlg+=METPartTruth + +################################################################### +# Make the D3PD. +# + +#-------------------------------------------------------------------------- +# Configuration +#-------------------------------------------------------------------------- +# compatibility with jets +from RecExConfig.RecConfFlags import jobproperties +jobproperties.RecConfFlags.AllowBackNavigation = True + +from JetRec.JetRecFlags import jobproperties as jobpropjet +jobpropjet.JetRecFlags.inputFileType = "GEN" + +# Build list of particles stored in D3PD +from TruthD3PDAnalysis.truthParticleConfig import truthParticleConfig +truthParticleConfig (topSequence) + +# Build list of particles used to jet building +from TruthD3PDMaker.TruthJetFilterConfig import TruthJetFilterConfig +TruthJetFilterConfig (topSequence, writePartons = False, writeHadrons = True, + excludeWZdecays = True) +# Build list of particles used for WZ jet building +TruthJetFilterConfig (topSequence, sgkey = 'FilteredWZD3PDTruth', writePartons = False, writeHadrons = True, + excludeWZdecays = True, photonCone=0.1) + +# Build truth particle (hadron-level) jets +# flags for AOD +from ParticleBuilderOptions.AODFlags import AODFlags +AODFlags.MissingEtTruth = True +AODFlags.TruthParticleJet = True +AODFlags.McEventKey="GEN_EVENT" + +# Reconstruct standard ATLAS truth jets +from JetRec.JetGetters import * +antikt4truthAlgStd = make_StandardJetGetter('AntiKt',0.4,'Truth',disable=False).jetAlgorithmHandle() + +# Add truth jet collection that includes all final state particles (including muons and neutrinos) +antikt4truthAlgWZ = make_StandardJetGetter('AntiKt',0.4,'Truth',disable=False, + inputCollectionNames=['FilteredWZD3PDTruth'], + outputCollectionName='AntiKt4TruthJets_WZ', + useInteractingOnly=False, + includeMuons=True + ).jetAlgorithmHandle() +antikt6truthAlgWZ = make_StandardJetGetter('AntiKt',0.6,'Truth',disable=False, + inputCollectionNames=['FilteredWZD3PDTruth'], + outputCollectionName='AntiKt6TruthJets_WZ', + useInteractingOnly=False, + includeMuons=True + ).jetAlgorithmHandle() + +#-------------------------------------------------------------------------- +# Make the D3PD +#-------------------------------------------------------------------------- +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags +from OutputStreamAthenaPool.MultipleStreamManager import MSMgr +alg = MSMgr.NewRootStream( "StreamNTUP_SUSYTRUTH", TruthD3PDFlags.TruthD3PDOutputFileName(), "truth" ) + +from EventCommonD3PDMaker.EventInfoD3PDObject import EventInfoD3PDObject +alg += EventInfoD3PDObject (10,'EventInfo') + +from TruthD3PDMaker.GenEventD3PDObject import GenEventD3PDObject +alg += GenEventD3PDObject (1, 'GenEvent') + +from TrackD3PDMaker.TruthVertexD3PDObject import TruthVertexD3PDObject +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +alg += TruthVertexD3PDObject(1, 'TruthVertex', sgkey=D3PDMakerFlags.TruthSGKey(),prefix='mcVx',label='mcVx_') +alg += TruthVertexD3PDObject(1, 'TruthVertexFake', sgkey=D3PDMakerFlags.TruthSGKey(),prefix='vx',label='vx_') + +from SUSYD3PDMaker.SUSYD3PDFlags import SUSYD3PDFlags +from JetD3PDMaker.JetD3PDObject import JetD3PDObject +alg += JetD3PDObject (2, 'Jet_Truth', sgkey=SUSYD3PDFlags.AntiKt4TruthJetsSGKey(), prefix='jet_AntiKt4TruthJets_', include=['TrueFlavorComponents'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo']) +alg += JetD3PDObject (2, 'Jet_NotTruth', sgkey=SUSYD3PDFlags.AntiKt4TruthJetsSGKey(), prefix='jet_AntiKt4TopoNewEM_', include=['TrueFlavorComponents'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo']) + +alg += JetD3PDObject (2, 'Jet_Truth_WZ', sgkey='AntiKt4TruthJets_WZ', prefix='jet_AntiKt4TruthJets_WZ_', include=['TrueFlavorComponents'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo']) +alg += JetD3PDObject (2, 'Jet_Truth6_WZ', sgkey='AntiKt6TruthJets_WZ', prefix='jet_AntiKt6TruthJets_WZ_', include=['TrueFlavorComponents'],exclude=['L1Kinematics','L2Kinematics','EFKinematics','El02Match','Mu02Match','L1Info','L2Info','EFInfo']) + + +from SUSYD3PDMaker.SUSYTruthParticleD3PDObject import SUSYTruthParticleD3PDObject +alg += SUSYTruthParticleD3PDObject (1, 'SUSYTruthParticle') + +from TruthD3PDMaker.Atlfast1MissingETD3PDObject import TruthMETD3PDObject +alg += TruthMETD3PDObject (level=10) + +#from MissingETD3PDMaker.MissingETD3PDMakerFlags import MissingETD3PDMakerFlags +#MissingETD3PDMakerFlags.doMissingETRegions=False +#from MissingETD3PDMaker.MissingETD3PDObject import RefFinalMETD3PDObject +#alg += RefFinalMETD3PDObject( 10 , name='MET_Simplified20' , lebel=1, sgkey='MET_Truth_NonInt' , prefix='MET_Simplified20_' , label='MET_Simplified20_' , exclude=['MET_Regions'] , include = ['MET','MET_Phi','MET_Et','MET_SumEt'] ) + +from TruthD3PDMaker.TruthParticleFakerObject import * +alg += TruthParticleFakerElD3PDObject (level=10, sgkey='GEN_EVENT', prefix="el_", label='GrumpyEl_') +alg += TruthParticleFakerMuD3PDObject (level=10, sgkey='GEN_EVENT', prefix="mu_muid_", label='mu_m_') +alg += TruthParticleFakerMuD3PDObject (level=10, sgkey='GEN_EVENT', prefix="mu_staco_", label='mu_s_') +alg += TruthParticleFakerTauD3PDObject (level=10, sgkey='GEN_EVENT', prefix="tau_", label='tau_') +alg += TruthParticleFakerPhD3PDObject (level=10, sgkey='GEN_EVENT', prefix="ph_", label='ph_') +alg += TruthParticleFakerElD3PDObject (level=10, sgkey='GEN_EVENT', prefix="el_truth_", label='el_t_') +alg += TruthParticleFakerMuD3PDObject (level=10, sgkey='GEN_EVENT', prefix="mu_muid_truth_", label='mu_m_t_') +alg += TruthParticleFakerMuD3PDObject (level=10, sgkey='GEN_EVENT', prefix="mu_staco_truth_", label='mu_s_t_') +alg += TruthParticleFakerTauD3PDObject (level=10, sgkey='GEN_EVENT', prefix="trueTau_", label='tau_t_') +alg += TruthParticleFakerPhD3PDObject (level=10, sgkey='GEN_EVENT', prefix="ph_truth_", label='ph_t_') + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_topOptions.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_topOptions.py new file mode 100644 index 00000000000..2bb73e8f051 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/TruthSusyD3PDfromEVGEN_topOptions.py @@ -0,0 +1,56 @@ +# @file TruthD3PDMaker/share/evgenD3PD_topOptions.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Apr, 2010 +# @brief Example for building a D3PD from event generation file. + +################################################################### +# Define the input file here. +# + +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +#athenaCommonFlags.FilesInput= ["EVNT.pool.root"] +#athenaCommonFlags.FilesInput= ["EVNT.289844._000396.pool.root.1"] +athenaCommonFlags.FilesInput= ["/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000002.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000001.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000003.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000004.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000005.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000006.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000007.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000008.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._000009.pool.root.1", +"/afs/phas.gla.ac.uk/user/p/pmullen/sw-test/EVNTFiles/mc12_8TeV.107283.AlpgenJimmy_AUET2CTEQ6L1_WbbNp3.evgen.EVNT.e1601_tid01025138_00/EVNT.01025138._0000010.pool.root.1"] + +################################################################### +# Define the output file here. +# +from TruthD3PDMaker.TruthD3PDMakerFlags import TruthD3PDFlags +if not globals().get('tupleFileOutput'): + tupleFileOutput = 'susy.root' +TruthD3PDFlags.TruthD3PDOutputFileName = tupleFileOutput + + +################################################################### +# Define other job options here. +# + +#athenaCommonFlags.EvtMax = 1000 +athenaCommonFlags.EvtMax = -1 + + +from RecExConfig.RecFlags import rec +rec.doHist=False +rec.doMonitoring=False +rec.doCBNT=False +rec.doWriteESD=False +rec.doWriteAOD=False +rec.doWriteTAG=False + +include("TruthD3PDMaker/TruthD3PDfromEVGEN_preInclude.py") + +include("RecExCommon/RecExCommon_topOptions.py") +#from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +#D3PDMakerFlags.TruthSGKey = 'GEN_EVENT,GEN_AOD,TruthEvent' +#D3PDMakerFlags.DoTrigger = False +#D3PDMakerFlags.TruthWriteBHadrons=True +#D3PDMakerFlags.TruthWriteEverything=True diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/atlfast1D3PD_topOptions.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/atlfast1D3PD_topOptions.py new file mode 100644 index 00000000000..1c88080fa11 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/atlfast1D3PD_topOptions.py @@ -0,0 +1,87 @@ +# $Id$ +# +# @file TruthD3PDMaker/share/atlfast1D3PD_topOptions.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Feb, 2010 +# @brief Example for building a D3PD from atlfast1 containers. +# + + +################################################################### +# Define the input file here. +# + +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +athenaCommonFlags.FilesInput= ["AOD.pool.root"] +#athenaCommonFlags.FilesInput= ["/afs/cern.ch/user/b/bruneli/scratch0/temp/user09.RenaudBruneliere.106124.AlpgenJimmyGamNp2_pt20_v1.AOD.atlfast1._01101.pool.root"] +#athenaCommonFlags.FilesInput= ["/afs/cern.ch/user/b/bruneli/scratch0/temp/zee.AOD.pool.root"] + +################################################################### +# Define the output file here. +# + +if not globals().get('tupleFileOutput'): + tupleFileOutput = 'atlfast1.root' + + +################################################################### +# Define other job options here. +# + +athenaCommonFlags.EvtMax = -1 + +# Set following flag to True if you want to use Corrected Atlfast1 containers +from TruthD3PDMaker.Atlfast1D3PDMakerFlags import Atlfast1D3PDMakerFlags +Atlfast1D3PDMakerFlags.UseAtlfast1Correction = False +if Atlfast1D3PDMakerFlags.UseAtlfast1Correction: Atlfast1D3PDMakerFlags.ContainerPrefix = 'Corrected' + +# Example of changing D3PD maker flags. +# Redefine SG keys for atlfast1 running +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +D3PDMakerFlags.TruthSGKey = 'GEN_EVENT,GEN_AOD,TruthEvent' +D3PDMakerFlags.PhotonSGKey = Atlfast1D3PDMakerFlags.ContainerPrefix()+'AtlfastPhotonCollection' +D3PDMakerFlags.ElectronSGKey = Atlfast1D3PDMakerFlags.ContainerPrefix()+'AtlfastElectronCollection' +D3PDMakerFlags.MuonSGKey = Atlfast1D3PDMakerFlags.ContainerPrefix()+'AtlfastMuonCollection' +D3PDMakerFlags.JetSGKey = Atlfast1D3PDMakerFlags.ContainerPrefix()+'AtlfastJetContainer' +D3PDMakerFlags.MissingETSGKey = 'AtlfastMissingEt' +D3PDMakerFlags.TauSGKey = 'AtlfastTauJetContainer' +D3PDMakerFlags.TrackSGKey = 'AtlfastTrackParticles' +D3PDMakerFlags.DoTrigger = False + +# Fix by hand mismatch in collection name for jets +if Atlfast1D3PDMakerFlags.UseAtlfast1Correction: D3PDMakerFlags.JetSGKey = 'CorrectedAtlfastJetCollection' + + +from RecExConfig.AutoConfiguration import ConfigureFromListOfKeys +ConfigureFromListOfKeys (['ProjectName', + 'BeamType', + 'RealOrSim', + 'DoTruth', + 'LumiFlags']) + +################################################################### +# Configure RecExCommon. +# +# Need to set dummy values for atlfast1 when running on pure atlfast1 AODs +# if you are running on normal AODs (full simulation), comment next 4 lines +from AthenaCommon.GlobalFlags import GlobalFlags,globalflags +GlobalFlags.DetGeo.set_atlas() +globalflags.ConditionsTag.set_Value_and_Lock('OFLCOND-CSC-00-00-00') +globalflags.DetDescrVersion.set_Value_and_Lock("ATLAS-CSC-02-00-00") + +from RecExConfig.RecFlags import rec +rec.doCBNT.set_Value_and_Lock(False) +rec.doWriteESD.set_Value_and_Lock(False) +rec.doWriteAOD.set_Value_and_Lock(False) +rec.doAOD.set_Value_and_Lock(False) +rec.doESD.set_Value_and_Lock(False) +rec.doDPD.set_Value_and_Lock(False) +rec.doWriteTAG.set_Value_and_Lock(False) +include ("RecExCommon/RecExCommon_topOptions.py") + + +################################################################### +# Make the D3PD. +# +from TruthD3PDMaker.atlfast1D3PD import atlfast1D3PD +alg = atlfast1D3PD (tupleFileOutput) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/evgenD3PD_topOptions.py b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/evgenD3PD_topOptions.py new file mode 100644 index 00000000000..a972a9c6694 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/share/evgenD3PD_topOptions.py @@ -0,0 +1,84 @@ +# $Id$ +# +# @file TruthD3PDMaker/share/evgenD3PD_topOptions.py +# @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> +# @date Apr, 2010 +# @brief Example for building a D3PD from event generation file. +# + + +################################################################### +# Define the input file here. +# + +from AthenaCommon.AthenaCommonFlags import athenaCommonFlags +#athenaCommonFlags.FilesInput= ["EVNT.pool.root"] +athenaCommonFlags.FilesInput= ["/afs/cern.ch/user/b/bruneli/scratch0/temp/mc10_7TeV.114611.SherpaW5jetstoenu30GeV.evgen.EVNT.e711_tid274882_00/EVNT.274882._000157.pool.root.1"] + +################################################################### +# Define the output file here. +# + +if not globals().get('tupleFileOutput'): + tupleFileOutput = 'evgen.root' + + +################################################################### +# Define other job options here. +# + +athenaCommonFlags.EvtMax = -1 + +# Example of changing D3PD maker flags. +# Redefine SG keys for evgen running +from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags +D3PDMakerFlags.TruthSGKey = 'GEN_EVENT,GEN_AOD,TruthEvent' +D3PDMakerFlags.DoTrigger = False + +from RecExConfig.AutoConfiguration import ConfigureFromListOfKeys +ConfigureFromListOfKeys (['ProjectName', + 'BeamType', + 'RealOrSim', + 'DoTruth', + 'LumiFlags']) + +################################################################### +# Configure RecExCommon. +# +# Need to set dummy values for when running on pure EVNT files +# if you are running on normal AODs (full simulation), comment next 4 lines +from AthenaCommon.GlobalFlags import GlobalFlags,globalflags +GlobalFlags.DetGeo.set_atlas() +globalflags.ConditionsTag.set_Value_and_Lock('OFLCOND-DR-BS7T-ANom-12') +globalflags.DetDescrVersion.set_Value_and_Lock("ATLAS-GEO-10-00-00") + +from RecExConfig.RecFlags import rec +rec.doCBNT.set_Value_and_Lock(False) +rec.doWriteESD.set_Value_and_Lock(False) +rec.doWriteAOD.set_Value_and_Lock(False) +rec.doAOD.set_Value_and_Lock(False) +rec.doESD.set_Value_and_Lock(False) +rec.doDPD.set_Value_and_Lock(False) +rec.doWriteTAG.set_Value_and_Lock(False) +rec.doPerfMon.set_Value_and_Lock(False) +rec.doHist.set_Value_and_Lock(False) +rec.doForwardDet.set_Value_and_Lock(False) +rec.readAOD.set_Value_and_Lock(True) + +# The following flags are mandatory if you build jets +from JetRec.JetRecFlags import jetFlags +jetFlags.noStandardConfig.set_Value_and_Lock(True) +jetFlags.evgenJets.set_Value_and_Lock(True) + +include ("RecExCommon/RecExCommon_topOptions.py") + +# Build truth missing Et +include( "ParticleBuilderOptions/MissingEtTruth_jobOptions.py" ) +METPartTruth.TruthCollectionName="GEN_EVENT" +topSequence.METAlg+=METPartTruth + +################################################################### +# Make the D3PD. +# +from TruthD3PDMaker.evgenD3PD import evgenD3PD +alg = evgenD3PD (tupleFileOutput) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.cxx new file mode 100644 index 00000000000..c9c9e5a0db7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventFillerTool.cxx 504001 2012-06-05 16:30:11Z ssnyder $ +/** + * @file EventCommonD3PDMaker/src/GenEventFillerTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2009 + * @brief Block filler tool for @c GenEvent information. + */ + + +#include "GenEventFillerTool.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +GenEventFillerTool::GenEventFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<HepMC::GenEvent> (type, name, parent) +{ + book().ignore(); // Avoid coverity warnings. +} + + +/** + * @brief Book variables for this block. + */ +StatusCode GenEventFillerTool::book() +{ + CHECK( addVariable ("signal_process_id", m_signal_process_id) ); + CHECK( addVariable ("event_number", m_event_number) ); + CHECK( addVariable ("event_scale", m_event_scale) ); + CHECK( addVariable ("alphaQCD", m_alphaQCD) ); + CHECK( addVariable ("alphaQED", m_alphaQED) ); + CHECK( addVariable ("pdf_id1", m_pdf_id1) ); + CHECK( addVariable ("pdf_id2", m_pdf_id2) ); + CHECK( addVariable ("pdf_x1", m_pdf_x1) ); + CHECK( addVariable ("pdf_x2", m_pdf_x2) ); + CHECK( addVariable ("pdf_scale", m_pdf_scale) ); + CHECK( addVariable ("pdf1", m_pdf1) ); + CHECK( addVariable ("pdf2", m_pdf2) ); + CHECK( addVariable ("weight", m_weight) ); + return StatusCode::SUCCESS; +} + + +StatusCode GenEventFillerTool::fill (const HepMC::GenEvent& p) +{ + *m_signal_process_id = p.signal_process_id(); + *m_event_number = p.event_number(); + *m_event_scale = p.event_scale(); + *m_alphaQCD = p.alphaQCD(); + *m_alphaQED = p.alphaQED(); + for(size_t i=0;i<(size_t)p.weights().size();i++) + m_weight->push_back(p.weights()[i]); + if (p.pdf_info()) { + *m_pdf_id1 = p.pdf_info()->id1(); + *m_pdf_id2 = p.pdf_info()->id2(); + *m_pdf_x1 = p.pdf_info()->x1(); + *m_pdf_x2 = p.pdf_info()->x2(); + *m_pdf_scale = p.pdf_info()->scalePDF(); + *m_pdf1 = p.pdf_info()->pdf1(); + *m_pdf2 = p.pdf_info()->pdf2(); + } else { + *m_pdf_id1 = *m_pdf_id2 = 0; + *m_pdf_x1 = *m_pdf_x2 = *m_pdf_scale = *m_pdf1 = *m_pdf2 = -1.; + } + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.h new file mode 100644 index 00000000000..221cbc95dd6 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventFillerTool.h @@ -0,0 +1,109 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventFillerTool.h 356848 2011-04-06 13:51:55Z marti $ +/** + * @file EventCommonD3PDMaker/src/GenEventFillerTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2009 + * @brief Block filler tool for @c GenEvent information. + */ + + +#ifndef EVENTCOMMOND3PPDMAKER_GENEVENTFILLERTOOL_H +#define EVENTCOMMOND3PDMAKER_GENEVENTFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "HepMC/GenEvent.h" + + +namespace D3PD { + + +/** + * @brief Block filler tool for @c GenEvent information. + */ +class GenEventFillerTool + : public BlockFillerTool<HepMC::GenEvent> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenEventFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const HepMC::GenEvent& p); + + +private: + /// Variable: Signal process ID. + int* m_signal_process_id; + + /// Variable: Event number. + int* m_event_number; + + /// Variable: Event scale. + double* m_event_scale; + + /// Variable: alpha_QCD. + double* m_alphaQCD; + + /// Variable: alpha_QED. + double* m_alphaQED; + + /// Variable: pdf id1 + int* m_pdf_id1; + + /// Variable: pdf id2 + int* m_pdf_id2; + + /// Variable: pdf x1 + double* m_pdf_x1; + + /// Variable: pdf x2 + double* m_pdf_x2; + + /// Variable: pdf scale + double* m_pdf_scale; + + /// Variable: pdf name 1 + double* m_pdf1; + + /// Variable: pdf name 2 + double* m_pdf2; + + /// Variable: MC event weights + std::vector<double>* m_weight; + + // vertex? + // weights? + +}; + + +} // namespace D3PD + + +#endif // not EVENTCOMMOND3PDMAKER_GENEVENTFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.cxx new file mode 100644 index 00000000000..e7836082da7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.cxx @@ -0,0 +1,132 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventGenParticleAssociationTool.cxx 452268 2011-08-04 20:27:55Z ssnyder $ +/** + * @file EventCommonD3PDMaker/src/GenEventGenParticleAssociationTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2009 + * @brief Associate from a @c GenEvent to its contained particles. + */ + + +#include "GenEventGenParticleAssociationTool.h" +#include "HepMC/GenParticle.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +GenEventGenParticleAssociationTool::GenEventGenParticleAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent), + m_haveSeenAHadron(false), + m_firstHadronBarcode(0) +{ + declareProperty ("WritePartons", m_doPartons = false); + declareProperty ("WriteHadrons", m_doHadrons = false); + declareProperty ("WriteGeant", m_doGeant = false); +} + + +/** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ +StatusCode +GenEventGenParticleAssociationTool::reset (const HepMC::GenEvent& p) +{ + m_it = p.particles_begin(); + m_end = p.particles_end(); + + m_haveSeenAHadron = false; + + m_firstHadronBarcode = 0; + + return StatusCode::SUCCESS; +} + + +/** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ +const HepMC::GenParticle* GenEventGenParticleAssociationTool::next() +{ + if (m_it == m_end) + return 0; + + const HepMC::GenParticle* out; + + // loop until we see what we want + bool ok = false; + while( !ok ) { + + int pdg_id = std::abs ((*m_it)->pdg_id()); + int status = (*m_it)->status(); + int barcode = (*m_it)->barcode(); + + // are we at parton/hadron level? + if ( status!=3 && pdg_id > PARTONPDGMAX && + !m_haveSeenAHadron ) { + m_haveSeenAHadron = true; + m_firstHadronBarcode = barcode; + } + + // OK if we select partons and are at beginning of event record + if( m_doPartons && !m_haveSeenAHadron ) + ok = true; + + // OK if we should select hadrons and are in hadron range + if( m_doHadrons && m_haveSeenAHadron && barcode < PHOTOSMIN ) + ok = true; + + // PHOTOS range: check whether photons come from parton range or + // hadron range + int motherBarcode = 999999999; + if( barcode > PHOTOSMIN && barcode < GEANTMIN && + (*m_it)->production_vertex() ) { + const HepMC::GenVertex* vprod = (*m_it)->production_vertex(); + if (vprod->particles_in_size() > 0) { + const HepMC::GenParticle* mother = *vprod->particles_in_const_begin(); + if (mother) + motherBarcode = mother->barcode(); + } + if( m_doPartons && motherBarcode < m_firstHadronBarcode ) + ok = true; + if( m_doHadrons && motherBarcode >= m_firstHadronBarcode ) + ok = true; + } + + // OK if we should select G4 particles and are in G4 range + if( m_doGeant && barcode > GEANTMIN ) + ok = true; + + out = *m_it; + ++m_it; + + if (m_it == m_end) + return 0; + + } + + // exit if we are at geant level and not supposed to write this out + if( out->barcode() > GEANTMIN && !m_doGeant ) + return 0; + + return out; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.h new file mode 100644 index 00000000000..abae2a24a41 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGenParticleAssociationTool.h @@ -0,0 +1,96 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventGenParticleAssociationTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file EventCommonD3PDMaker/src/GenEventGenParticleAssociationTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2009 + * @brief Associate from a @c GenEvent to its contained particles. + */ + + +#ifndef EVENTCOMMOND3PDMAKER_GENEVENTGENPARTICLEASSOCIATIONTOOL_H +#define EVENTCOMMOND3PDMAKER_GENEVENTGENPARTICLEASSOCIATIONTOOL_H + + +#include "D3PDMakerUtils/MultiAssociationTool.h" +#include "HepMC/GenEvent.h" +namespace HepMC +{ + class GenParticle; +} // namespace HepMC + + +namespace D3PD { + + +/** + * @brief Associate from a @c GenEvent to its contained particles. + * + * This is a multiple association tool. + */ +class GenEventGenParticleAssociationTool + : public MultiAssociationTool<HepMC::GenEvent, HepMC::GenParticle> +{ +public: + typedef MultiAssociationTool<HepMC::GenEvent, HepMC::GenParticle> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenEventGenParticleAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ + virtual StatusCode reset (const HepMC::GenEvent& p); + + + /** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ + virtual const HepMC::GenParticle* next(); + + +private: + static const int PARTONPDGMAX = 40; + static const int PHOTOSMIN = 10000; + static const int GEANTMIN = 200000; + + /// Property: Should we fill partons? + bool m_doPartons; + + /// Property: Should we fill partons? + bool m_doHadrons; + + /// Property: Should we fill partons? + bool m_doGeant; + + /// have we already walked by a hadron? + bool m_haveSeenAHadron; + int m_firstHadronBarcode; + + /// GenParticle iterators. + HepMC::GenEvent::particle_const_iterator m_it; + HepMC::GenEvent::particle_const_iterator m_end; +}; + + +} // namespace D3PD + + +#endif // not EVENTCOMMOND3PDMAKER_GENEVENTGENPARTICLEASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx new file mode 100644 index 00000000000..83ff1225136 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.cxx @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventGetterFilterTool.cxx 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file EventCommonD3PDMaker/src/GenEventGetterFilterTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Dec, 2009 + * @brief Collection getter filter to remove empty GenEvent instances. + */ + + +#include "GenEventGetterFilterTool.h" +#include "HepMC/GenEvent.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +GenEventGetterFilterTool::GenEventGetterFilterTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : CollectionGetterFilterTool<HepMC::GenEvent> (type, name, parent) +{ +} + + +/** + * @brief Test to see if this event is non-empty. + */ +bool GenEventGetterFilterTool::filter (const HepMC::GenEvent* p) const +{ + return ! p->particles_empty(); +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.h new file mode 100644 index 00000000000..890163284df --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterFilterTool.h @@ -0,0 +1,64 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventGetterFilterTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file EventCommonD3PDMaker/src/GenEventGetterFilterTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Dec, 2009 + * @brief Collection getter filter to remove empty GenEvent instances. + */ + + +#include "D3PDMakerUtils/CollectionGetterFilterTool.h" +namespace HepMC +{ + class GenEvent; +} + + +#ifndef EVENTCOMMOND3PDMAKER_GENEVENTGETTERFILTERTOOL_H +#define EVENTCOMMOND3PDMAKER_GENEVENTGETTERFILTERTOOL_H + + +namespace D3PD { + + +/** + * @brief Collection getter filter to remove empty GenEvent instances. + * + * In some samples, @c McEventCollection contains thousands + * of empty @c GenEvent instances (why???). + * Use this to filter those out. + */ +class GenEventGetterFilterTool + : public CollectionGetterFilterTool<HepMC::GenEvent> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenEventGetterFilterTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /** + * @brief Apply filtering to one element. + * + * Returns true if the filter passes; false otherwise. + */ + virtual bool filter (const HepMC::GenEvent* p) const; +}; + + +} // namespace D3PD + + +#endif // not EVENTCOMMOND3PDMAKER_GENEVENTGETTERFILTERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.cxx new file mode 100644 index 00000000000..fb521e46643 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.cxx @@ -0,0 +1,85 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventGetterTool.cxx 452268 2011-08-04 20:27:55Z ssnyder $ + +// Gaudi/Athena include(s): +#include "AthenaKernel/errorcheck.h" + +// EDM include(s): +#include "HepMC/GenEvent.h" + +// Local include(s): +#include "GenEventGetterTool.h" + +namespace D3PD { + + GenEventGetterTool::GenEventGetterTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ), + m_mcColl(0), + m_selector( "GenObjectsFilterTool" ) + { + + declareProperty( "Selector", m_selector, + "Handle for the selector tool to be used" ); + } + + StatusCode GenEventGetterTool::initialize() { + + // Initialize the base class: + CHECK( Base::initialize() ); + // Retrieve the selector tool: + CHECK( m_selector.retrieve() ); + + return StatusCode::SUCCESS; + } + + size_t GenEventGetterTool::sizeHint( bool allowMissing ) { + + const McEventCollection* mc = get( allowMissing ); + if( ! mc ) { + return 0; + } + + return mc->size(); + } + + StatusCode GenEventGetterTool::reset( bool allowMissing ) { + + // Retrieve the collection from SG: + m_mcColl = get( allowMissing ); + + // Handle the case when there is no collection in SG: + if( ! m_mcColl ) { + m_evtItr = m_evtEnd; + if( allowMissing )return StatusCode::SUCCESS; + return StatusCode::FAILURE; + } + + // Initialize the iterators: + m_evtItr = m_mcColl->begin(); + m_evtEnd = m_mcColl->end(); + + return StatusCode::SUCCESS; + } + + const void* GenEventGetterTool::nextUntyped() { + + // Check if we've reached the end of the container: + if( m_evtItr == m_evtEnd ) return 0; + + // Remember the current GenEvent, and advance the iterator: + const HepMC::GenEvent* evt = *m_evtItr; + ++m_evtItr; + + // If this is not a "good" GenEvent, then try the next one: + if( ! m_selector->pass( evt, m_mcColl ) ) return nextUntyped(); + + // This is a "good" GenEvent: + return evt; + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.h new file mode 100644 index 00000000000..6ce913b60fd --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventGetterTool.h @@ -0,0 +1,75 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventGetterTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenEventGetterTool.h + * @author Georges Aad + * @date Nov, 2010 + * @brief getter for GenEvent +*/ +#ifndef TRUTHD3PDMAKER_GENEVENTGETTERTOOL_H +#define TRUTHD3PDMAKER_GENEVENTGETTERTOOL_H + +// Gaudi/Athena include(s): +#include "GaudiKernel/ToolHandle.h" + +// EDM include(s): +#include "GeneratorObjects/McEventCollection.h" + +// Helper tool(s): +#include "TruthD3PDAnalysis/IGenObjectsFilterTool.h" + +// D3PDMaker include(s): +#include "D3PDMakerUtils/SGCollectionGetterTool.h" + +namespace D3PD { + + /** + * @short Getter tool iterating over "good" GenEvent objects + * + * This tool can be used to feed a D3PD job with "good" + * GenEvent objects. + * + * @author Georges Aad <aad@cern.ch> + * + * $Revision: 348274 $ + * $Date: 2011-02-28 17:25:06 +0100 (Mon, 28 Feb 2011) $ + */ + class GenEventGetterTool + : public SGCollectionGetterTool< McEventCollection > { + + public: + /// Convenience typedef + typedef SGCollectionGetterTool< McEventCollection > Base; + + /// Default AlgTool constructor + GenEventGetterTool( const std::string& type, const std::string& name, + const IInterface* parent ); + + /// Initialization function + virtual StatusCode initialize(); + virtual size_t sizeHint( bool allowMissing = false ); + virtual StatusCode reset( bool sllowMissing = false ); + virtual const void* nextUntyped(); + + private: + /// Pointer to the current McEventCollection object + const McEventCollection* m_mcColl; + + /// Iterator pointing at the current GenEvent object + McEventCollection::const_iterator m_evtItr; + /// Iterator pointing at the last GenEvent object + McEventCollection::const_iterator m_evtEnd; + + /// Tool used to select "good" GenEvent objects + ToolHandle< IGenObjectsFilterTool > m_selector; + + }; // class GenEventGetterTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENEVENTGETTERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx new file mode 100644 index 00000000000..def7403bfb1 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.cxx @@ -0,0 +1,109 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventPileUpFillerTool.cxx 504001 2012-06-05 16:30:11Z ssnyder $ + +// Gaudi/Athena include(s): +#include "AthenaKernel/errorcheck.h" + +// EDM include(s): +#include "GeneratorObjects/McEventCollection.h" + +// D3PDMaker include(s): +#include "D3PDMakerInterfaces/ICollectionGetterTool.h" + +// Local include(s): +#include "GenEventPileUpFillerTool.h" + +namespace D3PD { + + GenEventPileUpFillerTool::GenEventPileUpFillerTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : BlockFillerTool< HepMC::GenEvent >( type, name, parent ), + m_registry( "dummy" ) { + + declareProperty( "GetterLabel", m_getterLabel = "" ); + declareProperty( "CollectionGetterRegistry", m_registry ); + + book().ignore(); // Avoid coverity warnings. + } + + StatusCode GenEventPileUpFillerTool::configureD3PD( IAddVariable* tree, + const std::type_info& ti ) { + + CHECK ( BlockFillerTool< HepMC::GenEvent >::configureD3PD( tree, ti ) ); + + CHECK( m_registry.retrieve() ); + + CHECK( m_registry->get( m_getterLabel, this, m_getter ) ); + + return StatusCode::SUCCESS; + } + + StatusCode GenEventPileUpFillerTool::book() { + + CHECK( addVariable( "nparticle", m_nparticle, + "Number of particles in the event" ) ); + CHECK( addVariable( "pileUpType", m_pileUpType, + "0 = signal MC Event; 1 = in-time pileup MC Event; " + "2 = out-of-time pileup MC Event in [-2BC, +2BC]; " + "3 = the out-of-time pileup MC Event in [-800ns, -2BC] and [+2BC, +800ns]; " + "4 = cavern background MC Event; 5 = dummy event used to separate types; " + "-1 = not filled" ) ); + + return StatusCode::SUCCESS; + } + + ///// pileup type is defined as described here: + ///// https://twiki.cern.ch/twiki/bin/viewauth/Atlas/PileupPerformance#MC_Truth_Task_Force_Recommendati + /// pileUpType=0: the signal MC Event + /// pileUpType=1: the in-time pileup MC Events + /// pileUpType=2: the out-of-time pileup MC Events in [-2BC, +2BC] + /// pileUpType=3: the out-of-time pileup MC Events in [-800ns, -2BC] and [+2BC, +800ns] + /// pileUpType=4: the cavern background MC Events + /// pileUpType=5: dummy event used to separate types + /// pileUpType=-1: not filled + StatusCode GenEventPileUpFillerTool::fill( const HepMC::GenEvent& p ) { + + *m_nparticle = p.particles_size(); + + *m_pileUpType = -1; + + if( ( p.event_number() == -1 ) && ( p.signal_process_id() == 0 ) ) { + *m_pileUpType = 5; + return StatusCode::SUCCESS; + } + + const McEventCollection* mc = m_getter->get< McEventCollection >( false ); + + if( ! mc ) { + ATH_MSG_WARNING( "could not get mc collection" ); + return StatusCode::SUCCESS; + } + + int gotzero = 1; + McEventCollection::const_iterator iter = mc->begin(); + McEventCollection::const_iterator end = mc->end(); + + if( &p == *iter ) { + *m_pileUpType = 0; + return StatusCode::SUCCESS; + } + + for( ;iter != end; ++iter ) { + + if( ( ( ( *iter )->event_number() == -1 ) && + ( ( *iter )->signal_process_id() == 0 ) ) ) { + ++gotzero; + } + if( &p == *iter ) break; + } + + *m_pileUpType = gotzero; + + return StatusCode::SUCCESS; + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.h new file mode 100644 index 00000000000..ff3805887e0 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenEventPileUpFillerTool.h @@ -0,0 +1,81 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenEventPileUpFillerTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenEventPileUpFillerTool.h + * @author Georges Aad + * @date Nov, 2010 + * @brief Block filler tool for the jet truth info object + */ +#ifndef TRUTHD3PDMAKER_GENEVENTPILEUPFILLERTOOL_H +#define TRUTHD3PDMAKER_GENEVENTPILEUPFILLERTOOL_H + +// Gaudi/Athena include(s): +#include "GaudiKernel/ToolHandle.h" + +// EDM include(s): +#include "HepMC/GenEvent.h" + +// D3PDMaker include(s): +#include "D3PDMakerInterfaces/ICollectionGetterRegistryTool.h" +#include "D3PDMakerUtils/BlockFillerTool.h" + +namespace D3PD { + + // Forward declaration(s): + class ICollectionGetterTool; + + class GenEventPileUpFillerTool + : public BlockFillerTool< HepMC::GenEvent > { + + public: + /// Regular AlgTool constructor + GenEventPileUpFillerTool( const std::string& type, const std::string& name, + const IInterface* parent ); + + /** + * @brief Configure during initialization: type-check. + * @param tree Our parent for tuple making. + * @param ti Gives the type of the object being passed to @c fillUntyped. + * + * @c configureD3PD should check that the type of the object coming as input + * is compatible with what it expects, and raise an error otherwise. + */ + virtual StatusCode configureD3PD( IAddVariable* tree, + const std::type_info& ti ); + + /// Book variables for this block. + virtual StatusCode book(); + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill( const HepMC::GenEvent& p ); + + private: + // Variables to write out: + int *m_nparticle; + short *m_pileUpType; + + /// Prefix of the collection the tool is scheduled for + std::string m_getterLabel; + /// The getter tool for accessing the McEventCollection + ICollectionGetterTool* m_getter; + + /// Tool keeping track of all the getter tools + ToolHandle< ICollectionGetterRegistryTool > m_registry; + + }; // class GenEventPileUpFillerTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENEVENTPILEUPFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.cxx new file mode 100644 index 00000000000..92a4fceed9c --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.cxx @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleEventAssociationTool.cxx 348274 2011-02-28 16:25:06Z krasznaa $ + +// Local include(s): +#include "GenParticleEventAssociationTool.h" + +namespace D3PD { + + GenParticleEventAssociationTool::GenParticleEventAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ) { + + } + + const HepMC::GenEvent* GenParticleEventAssociationTool::get( const HepMC::GenParticle& p ) { + + return p.parent_event(); + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.h new file mode 100644 index 00000000000..88a736490fa --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleEventAssociationTool.h @@ -0,0 +1,60 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleEventAssociationTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenParticleEventAssociationTool.h + * @author Georges Aad + * @date Oct, 2010 + * @brief association from MC particles to MC events + * + */ +#ifndef TRUTHD3PDMAKER_GENPARTICLEEVENTASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_GENPARTICLEEVENTASSOCIATIONTOOL_H + +// D3PDMaker include(s): +#include "D3PDMakerUtils/SingleAssociationTool.h" + +// EDM include(s): +#include "HepMC/GenEvent.h" +#include "HepMC/GenParticle.h" + +namespace D3PD { + + /** + * @brief Associate Gen particles to there corresponding event + * + */ + class GenParticleEventAssociationTool + : public SingleAssociationTool< HepMC::GenParticle, HepMC::GenEvent > { + + public: + /// Convenience typedef + typedef SingleAssociationTool< HepMC::GenParticle, HepMC::GenEvent > Base; + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenParticleEventAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ); + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const HepMC::GenEvent* get( const HepMC::GenParticle& p ); + + }; // class GenParticleEventAssociationTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENPARTICLEEVENTASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.cxx new file mode 100644 index 00000000000..2ceca3d2cc7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.cxx @@ -0,0 +1,125 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleFillerTool.cxx 564177 2013-10-04 12:08:34Z dhayden $ +/** + * @file EventCommonD3PDMaker/src/GenParticleFillerTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Aug, 2009 + * @brief Block filler tool for a HepMC GenParticle. + */ + + +#include "GenParticleFillerTool.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenVertex.h" +#include "HepMC/SimpleVector.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +GenParticleFillerTool::GenParticleFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<HepMC::GenParticle> (type, name, parent) +{ + // Avoid coverity warnings + m_do_E = true; + m_do_p = true; + m_do_pt = true; + m_do_m = true; + m_do_mothertype = true; + m_do_motherbarcode = true; + m_do_px = true; + m_do_py = true; + m_do_pz = true; + book().ignore(); + + declareProperty ("WriteE", m_do_E = false); + declareProperty ("WriteP", m_do_p = false); + declareProperty ("WritePt", m_do_pt = true); + declareProperty ("WriteM", m_do_m = true); + declareProperty ("WriteMotherType", m_do_mothertype = true); + declareProperty ("WriteMotherBarcode", m_do_motherbarcode = true); + declareProperty ("WritePx", m_do_px = false); + declareProperty ("WritePy", m_do_py = false); + declareProperty ("WritePz", m_do_pz = false); +} + + +/** + * @brief Book variables for this block. + */ +StatusCode GenParticleFillerTool::book() +{ + if (m_do_E) CHECK( addVariable ("E", m_E) ); + if (m_do_p) CHECK( addVariable ("p", m_p) ); + if (m_do_pt) CHECK( addVariable ("pt", m_pt) ); + if (m_do_m) CHECK( addVariable ("m", m_m) ); + if (m_do_px) CHECK( addVariable ("px", m_px) ); + if (m_do_py) CHECK( addVariable ("py", m_py) ); + if (m_do_pz) CHECK( addVariable ("pz", m_pz) ); + + CHECK( addVariable ("eta", m_eta) ); + CHECK( addVariable ("phi", m_phi) ); + + CHECK( addVariable ("type", m_type) ); + CHECK( addVariable ("status", m_status) ); + CHECK( addVariable ("barcode", m_barcode) ); + if(m_do_mothertype) CHECK( addVariable ("mothertype", m_mothertype) ); + if(m_do_motherbarcode) CHECK( addVariable ("motherbarcode", m_motherbarcode) ); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode GenParticleFillerTool::fill (const HepMC::GenParticle& p) +{ + HepMC::FourVector v = p.momentum(); + if (m_do_E) *m_E = static_cast<float> (v.e()); + if (m_do_p) *m_p = static_cast<float> (v.rho()); + if (m_do_pt) *m_pt = static_cast<float> (v.perp()); + if (m_do_m) *m_m = static_cast<float> (v.m()); + if (m_do_px) *m_px = static_cast<float> (v.px()); + if (m_do_py) *m_py = static_cast<float> (v.py()); + if (m_do_pz) *m_pz = static_cast<float> (v.pz()); + + *m_eta = static_cast<float> (v.eta()); + *m_phi = static_cast<float> (v.phi()); + + *m_type = p.pdg_id(); + *m_status = p.status(); + *m_barcode = p.barcode(); + + if (const HepMC::GenVertex* vprod = p.production_vertex()) { + if (vprod->particles_in_size() > 0) { + const HepMC::GenParticle* mother = *vprod->particles_in_const_begin(); + if (mother) { + if(m_do_mothertype) *m_mothertype = mother->pdg_id(); + if(m_do_motherbarcode) *m_motherbarcode = mother->barcode(); + } + } + } + + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.h new file mode 100644 index 00000000000..2dbfd8218f7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleFillerTool.h @@ -0,0 +1,145 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleFillerTool.h 564204 2013-10-04 14:17:24Z dhayden $ +/** + * @file EventCommonD3PDMaker/src/GenParticleFillerTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Aug, 2009 + * @brief Block filler tool for a HepMC GenParticle. + */ + +#ifndef EVENTCOMMOND3PDMAKER_GENPARTICLEFILLERTOOL_H +#define EVENTCOMMOND3PDMAKER_GENPARTICLEFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +namespace HepMC { + class GenParticle; +} + + +namespace D3PD { + + +/** + * @brief Block filler tool for a HepMC GenParticle. + * + * This tool has properties to control what gets written: + * + * WriteE - Write energy (e). Default: false. + * WriteP - Write momentum (p). Default: false. + * WritePt - Write transverse momentum (pt). Default: true. + * WriteM - Write mass (m). Default: true. + * + * So the default settings give (pt, eta, phi, m). + */ +class GenParticleFillerTool + : public BlockFillerTool<HepMC::GenParticle> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenParticleFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const HepMC::GenParticle& p); + + +private: + /// Property: Should we fill E? + bool m_do_E; + + /// Property: Should we fill p? + bool m_do_p; + + /// Property: Should we fill pt? + bool m_do_pt; + + /// Property: Should we fill m? + bool m_do_m; + + /// Property: Should we fill px? + bool m_do_px; + + /// Property: Should we fill py? + bool m_do_py; + + /// Property: Should we fill pz? + bool m_do_pz; + + /// Property: Should we fill mother type? + bool m_do_mothertype; + + /// Property: Should we fill mother barcode? + bool m_do_motherbarcode; + + /// Variable: Energy. + float* m_E; + + /// Variable: Momentum. + float* m_p; + + /// Variable: Transverse momentum. + float* m_pt; + + /// Variable: Mass. + float* m_m; + + /// Variable: Momentum in x. + float* m_px; + + /// Variable: Momentum in y. + float* m_py; + + /// Variable: Momentum in z. + float* m_pz; + + /// Variable: Pseudorapidity. + float* m_eta; + + /// Variable: Azimuth. + float* m_phi; + + /// Variable: PDG ID. + int* m_type; + + /// Variable: status. + int* m_status; + + /// Variable: PDG ID of mother (first incoming particle of prod vertex). + int* m_mothertype; + + /// Variable: HepMC barcode. + int* m_barcode; + + /// Variable: HepMC barcode of mother (first incoming particle of prod vertex). + int* m_motherbarcode; +}; + + +} // namespace D3PD + + +#endif // not EVENTCOMMOND3PDMAKER_GENPARTICLEFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.cxx new file mode 100644 index 00000000000..393059d26b9 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.cxx @@ -0,0 +1,119 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleGetterTool.cxx 452268 2011-08-04 20:27:55Z ssnyder $ + +// Gaudi/Athena include(s): +#include "AthenaKernel/errorcheck.h" + +// EDM include(s): +#include "HepMC/GenParticle.h" + +// Local include(s): +#include "GenParticleGetterTool.h" + +namespace D3PD { + + GenParticleGetterTool::GenParticleGetterTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ), + m_mcColl(0), + m_selector( "GenObjectsFilterTool" ) + { + + declareProperty( "Selector", m_selector, + "Handle for the selector tool to be used" ); + } + + StatusCode GenParticleGetterTool::initialize() { + + // Initialize the base class: + CHECK( Base::initialize() ); + // Retrieve the selector tool: + CHECK( m_selector.retrieve() ); + + return StatusCode::SUCCESS; + } + + size_t GenParticleGetterTool::sizeHint( bool allowMissing ) { + + const McEventCollection* mc = get( allowMissing ); + if( ! mc ) { + return 0; + } + + McEventCollection::const_iterator iter = mc->begin(); + if( iter == mc->end() ) return 0; + + return ( *iter )->particles_size(); + } + + StatusCode GenParticleGetterTool::reset( bool allowMissing ) { + + m_mcColl = get( allowMissing ); + + if( ! m_mcColl ) { + m_evtItr = m_evtEnd; + m_partItr = m_partEnd; + if( allowMissing ) return StatusCode::SUCCESS; + return StatusCode::FAILURE; + } + + m_evtItr = m_mcColl->begin(); + m_evtEnd = m_mcColl->end(); + + if( m_evtItr == m_evtEnd ){ + m_partItr = m_partEnd; + return StatusCode::SUCCESS; + } + + m_partItr = ( *m_evtItr )->particles_begin(); + m_partEnd = ( *m_evtItr )->particles_end(); + + return StatusCode::SUCCESS; + } + + const void* GenParticleGetterTool::nextUntyped() { + + if( m_evtItr == m_evtEnd ) return 0; + + // Check if this GenEvent passes our selection cuts: + if( ! m_selector->pass( *m_evtItr, m_mcColl ) ) { + ++m_evtItr; + if( m_evtItr == m_evtEnd ) return 0; + m_partItr = ( *m_evtItr )->particles_begin(); + m_partEnd = ( *m_evtItr )->particles_end(); + return nextUntyped(); + } + + // Check if there are no more particles in this GenEvent: + if( m_partItr == m_partEnd ) { + ++m_evtItr; + if( m_evtItr == m_evtEnd ) return 0; + + m_partItr = ( *m_evtItr )->particles_begin(); + m_partEnd = ( *m_evtItr )->particles_end(); + return nextUntyped(); + } + + // Check if this GenParticle passes our selection: + if( ! m_selector->pass( *m_partItr, m_mcColl ) ) { + ++m_partItr; + return nextUntyped(); + } + + // I just like to write this part our verbosely... + HepMC::GenParticle* part = *m_partItr; + ++m_partItr; + + return part; + } + + const std::type_info& GenParticleGetterTool::elementTypeinfo() const { + + return typeid( HepMC::GenParticle ); + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.h new file mode 100644 index 00000000000..6ab6f87a1e0 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleGetterTool.h @@ -0,0 +1,82 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleGetterTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenParticleGetterTool.h + * @author Georges Aad + * @date Nov, 2010 + * @brief getter for GenParticle +*/ +#ifndef TRUTHD3PDMAKER_GENPARTICLEGETTERTOOL_H +#define TRUTHD3PDMAKER_GENPARTICLEGETTERTOOL_H + +// Gaudi/Athena include(s): +#include "GaudiKernel/ToolHandle.h" + +// EDM include(s): +#include "GeneratorObjects/McEventCollection.h" +#include "HepMC/GenEvent.h" + +// Helper tool(s): +#include "TruthD3PDAnalysis/IGenObjectsFilterTool.h" + +// D3PDMaker include(s): +#include "D3PDMakerUtils/SGCollectionGetterTool.h" + +namespace D3PD { + + /** + * @short Getter tool iterating over "good" GenParticle objects + * + * This tool can be used to feed a D3PD job with "good" + * GenParticle objects. + * + * @author Georges Aad <aad@cern.ch> + * + * $Revision: 348274 $ + * $Date: 2011-02-28 17:25:06 +0100 (Mon, 28 Feb 2011) $ + */ + class GenParticleGetterTool + : public SGCollectionGetterTool< McEventCollection > { + + public: + /// Convenience typedef + typedef SGCollectionGetterTool< McEventCollection > Base; + + /// Default AlgTool constructor + GenParticleGetterTool( const std::string& type, const std::string& name, + const IInterface* parent ); + + /// Initialization function + virtual StatusCode initialize(); + virtual size_t sizeHint( bool allowMissing = false ); + virtual StatusCode reset( bool sllowMissing = false ); + virtual const void* nextUntyped(); + virtual const std::type_info& elementTypeinfo() const; + + private: + /// Pointer to the current McEventCollection object + const McEventCollection* m_mcColl; + + /// Iterator pointing at the current GenEvent object + McEventCollection::const_iterator m_evtItr; + /// Iterator pointing at the last GenEvent object + McEventCollection::const_iterator m_evtEnd; + + /// Iterator pointing at the current GenParticle object + HepMC::GenEvent::particle_const_iterator m_partItr; + /// Iterator pointing at the last GenParticle object + HepMC::GenEvent::particle_const_iterator m_partEnd; + + /// Tool used to select "good" GenParticle objects + ToolHandle< IGenObjectsFilterTool > m_selector; + + }; // class GenParticleGetterTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENPARTICLEGETTERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.cxx new file mode 100644 index 00000000000..9b5708c4e5c --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.cxx @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleParticleAssociationTool.cxx 348274 2011-02-28 16:25:06Z krasznaa $ + +// Local include(s): +#include "GenParticleParticleAssociationTool.h" + +namespace D3PD { + + GenParticleParticleAssociationTool::GenParticleParticleAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ) { + + } + + const HepMC::GenParticle* GenParticleParticleAssociationTool::get( const HepMC::GenParticle& p ) { + + return &p; + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.h new file mode 100644 index 00000000000..ab8bb8e5d94 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleParticleAssociationTool.h @@ -0,0 +1,63 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleParticleAssociationTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenParticleParticleAssociationTool.h + * @author Georges Aad + * @date Oct, 2010 + * @brief association from GenParticle to GenParticle + * + */ +#ifndef TRUTHD3PDMAKER_GENPARTICLEPARTICLEASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_GENPARTICLEPARTICLEASSOCIATIONTOOL_H + +// D3PDMaker include(s): +#include "D3PDMakerUtils/SingleAssociationTool.h" + +// EDM include(s): +#include "HepMC/GenParticle.h" + +namespace D3PD { + + /** + * @brief Associate Gen particles to Gen particles + * used to associate charged particles with truth track info + * that is needed for a subset of particles + * + * $Revision: 348274 $ + * $Date: 2011-02-28 17:25:06 +0100 (Mon, 28 Feb 2011) $ + */ + class GenParticleParticleAssociationTool + : public SingleAssociationTool< HepMC::GenParticle, HepMC::GenParticle > { + + public: + /// Convenience typedef + typedef SingleAssociationTool< HepMC::GenParticle, HepMC::GenParticle > Base; + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenParticleParticleAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ); + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const HepMC::GenParticle* get( const HepMC::GenParticle& p ); + + }; // class GenParticleParticleAssociationTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENPARTICLEPARTICLEASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.cxx new file mode 100644 index 00000000000..7d3bd8eda3a --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "GenParticlePerigeeFillerTool.h" + +#include "AthenaKernel/errorcheck.h" +#include "HepMC/GenParticle.h" +#include "TrkToolInterfaces/ITruthToTrack.h" + +namespace D3PD { + +GenParticlePerigeeFillerTool::GenParticlePerigeeFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent), + m_truthToTrack("Trk::TruthToTrack/TruthToTrack") +{ + declareProperty("TruthToTrackTool", m_truthToTrack, "Tool for truth to track"); + + book().ignore(); // Avoid coverity warnings. +} + +StatusCode GenParticlePerigeeFillerTool::initialize(){ + + CHECK( Base::initialize() ); + + // Get TruthToTrack + StatusCode sc = m_truthToTrack.retrieve(); + if (sc.isFailure()) { + REPORT_MESSAGE (MSG::FATAL) << "Could not retrieve TruthToTrackTool"; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode GenParticlePerigeeFillerTool::book() +{ + // truth track parameters at perigee + CHECK( addVariable ("ok", m_ok) ); + CHECK( addVariable ("d0", m_d0) ); + CHECK( addVariable ("z0", m_z0) ); + CHECK( addVariable ("phi", m_phi) ); + CHECK( addVariable ("theta", m_theta) ); + CHECK( addVariable ("qoverp", m_qoverp) ); + + return StatusCode::SUCCESS; +} + +StatusCode GenParticlePerigeeFillerTool::fill (const HepMC::GenParticle& particle) +{ + + this->clearData(); + + // truth track parameters at perigee + const Trk::TrackParameters *perigee = m_truthToTrack->makePerigeeParameters(&particle); + if(perigee) { + *m_ok = 1; + *m_d0 = perigee->parameters()[Trk::d0]; + *m_z0 = perigee->parameters()[Trk::z0]; + *m_phi = perigee->parameters()[Trk::phi0]; + *m_theta = perigee->parameters()[Trk::theta]; + *m_qoverp = perigee->parameters()[Trk::qOverP]; + } else { + REPORT_MESSAGE (MSG::DEBUG) << "Pointer to perigee is NULL"; + } + delete perigee; + + return StatusCode::SUCCESS; +} + +void GenParticlePerigeeFillerTool::clearData(){ + + *m_ok = 0; + *m_d0 = 0; + *m_z0 = 0; + *m_phi = 0; + *m_theta = 0; + *m_qoverp = 0; +} + +} // namespace MinBiasD3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.h new file mode 100644 index 00000000000..1bf9a2b5e5c --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticlePerigeeFillerTool.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRACKD3PDMAKER_GENPARTICLEPERIGEEFILLERTOOL_H +#define TRACKD3PDMAKER_GENPARTICLEPERIGEEFILLERTOOL_H + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "GaudiKernel/ToolHandle.h" + +namespace HepMC { +class GenParticle; +} + +namespace Trk { +class ITruthToTrack; +} + +namespace D3PD { + +class GenParticlePerigeeFillerTool + : public D3PD::BlockFillerTool<HepMC::GenParticle> +{ +public: + typedef D3PD::BlockFillerTool<HepMC::GenParticle> Base; + + GenParticlePerigeeFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + StatusCode initialize(); + virtual StatusCode book(); + + virtual StatusCode fill (const HepMC::GenParticle& p); + +private: + + void clearData(); + + /* Tool to generate perigee parameters for a generated particle **/ + ToolHandle<Trk::ITruthToTrack> m_truthToTrack; + + /* NTuple variables: **/ + // truth track parameters at perigee + int *m_ok; + float *m_d0; + float *m_z0; + float *m_phi; + float *m_theta; + float *m_qoverp; + +}; // class GenParticlePerigeeFillerTool + +} // namespace D3PD + +#endif // not TRACKD3PDMAKER_GENPARTICLEPERIGEEFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx new file mode 100644 index 00000000000..72e0608906e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.cxx @@ -0,0 +1,132 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleTruthParticleAssociationTool.cxx 353417 2011-03-22 10:16:22Z ssnyder $ +/** + * @file EventCommonD3PDMaker/GenParticleTruthParticleAssociationTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2010 + * @brief Associate from a GenParticle to a corresponding TruthParticle. + */ + + +#include "GenParticleTruthParticleAssociationTool.h" +#include "D3PDMakerInterfaces/IObjGetterTool.h" +#include "D3PDMakerInterfaces/ICollectionGetterTool.h" +#include "D3PDMakerInterfaces/ICollectionGetterRegistryTool.h" +#include "McParticleEvent/TruthParticleContainer.h" +#include "HepMC/GenParticle.h" +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/IIncidentSvc.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +GenParticleTruthParticleAssociationTool::GenParticleTruthParticleAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent), + m_getter ("D3PD::SGObjGetterTool", this), + m_incSvc ("IncidentSvc", name), + m_target (0), + m_container (0) +{ + declareProperty ("Target", m_targetLabel, + "Label of the collection getter defining the collection " + "within which find the TruthParticle instances. " + "If this is blank, then Getter is used instead."); + declareProperty ("Getter", m_getter, + "Getter to find the TruthParticle collection to use. " + "Only used if Target is empty."); + declareProperty ("CollectionGetterRegistry", m_registry, + "The ICollectionGetterRegistryTool instance."); + declareProperty ("IncidentSvc", m_incSvc, + "The incident service."); +} + + +/** + * @brief Configure during initialization: type-check. + * @param tree Our parent for tuple making. + * @param ti Gives the type of the object being passed to @c fillUntyped. + * + * @c configureD3PD should check that the type of the object coming as input + * is compatible with what it expects, and raise an error otherwise. + */ +StatusCode +GenParticleTruthParticleAssociationTool::configureD3PD + (IAddVariable* tree, + const std::type_info& ti) +{ + CHECK ( Base::configureD3PD (tree, ti) ); + + // Is the collection specified via target? + if (!m_targetLabel.empty()) { + // Look up the target. + CHECK (m_registry.retrieve() ); + ICollectionGetterTool* cget = 0; + CHECK (m_registry->get (m_targetLabel, this, cget) ); + m_target = cget; + } + else { + // Target was empty. Use a private getter tool. + CHECK (m_getter.retrieve() ); + m_target = &*m_getter; + } + + // Set up to clear the cached container pointer at the end of the event. + CHECK( m_incSvc.retrieve() ); + m_incSvc->addListener (this, "EndEvent"); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ +const TruthParticle* +GenParticleTruthParticleAssociationTool::get (const HepMC::GenParticle& p) +{ + if (!m_target) + return 0; + + if (!m_container) + m_container = m_target->get<TruthParticleContainer>(); + + if (!m_container) { + REPORT_MESSAGE (MSG::WARNING) << "Couldn't find TruthParticleContainer."; + return 0; + } + + return m_container->truthParticle (p.barcode()); +} + + +/** + * @brief Incident handler. + * @param inc The incident. + */ +void GenParticleTruthParticleAssociationTool::handle (const Incident &inc) +{ + // Clear the cached container pointer at the end of the event. + if (inc.type() == "EndEvent") + { + m_container = 0; + } +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.h new file mode 100644 index 00000000000..253459ccc8d --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleTruthParticleAssociationTool.h @@ -0,0 +1,124 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleTruthParticleAssociationTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file EventCommonD3PDMaker/GenParticleTruthParticleAssociationTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2010 + * @brief Associate from a GenParticle to a corresponding TruthParticle. + */ + + +#ifndef EVENTCOMMOND3PDMAKER_GENPARTICLETRUTHPARTICLEASSOCIATIONTOOL_H +#define EVENTCOMMOND3PDMAKER_GENPARTICLETRUTHPARTICLEASSOCIATIONTOOL_H + + +#include "D3PDMakerUtils/SingleAssociationTool.h" +#include "GaudiKernel/IIncidentListener.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/ServiceHandle.h" +#include <string> +class TruthParticle; +class TruthParticleContainer; +namespace HepMC +{ + class GenParticle; +} // namespace HepMC +class Incident; +class IIncidentSvc; + + +namespace D3PD { + + +class IObjGetterTool; +class ICollectionGetterRegistryTool; + + +/** + * @brief Associate from a GenParticle to a corresponding TruthParticle. + * + * To do this, we need to specify the collection containing the TruthParticles. + * This can be done either by specifying an existing getter via a target + * string, or by configuring a new getter. + */ +class GenParticleTruthParticleAssociationTool + : public SingleAssociationTool<HepMC::GenParticle, TruthParticle>, + public IIncidentListener +{ +public: + typedef SingleAssociationTool<HepMC::GenParticle, TruthParticle> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenParticleTruthParticleAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /** + * @brief Configure during initialization: type-check. + * @param tree Our parent for tuple making. + * @param ti Gives the type of the object being passed to @c fillUntyped. + * + * @c configureD3PD should check that the type of the object coming as input + * is compatible with what it expects, and raise an error otherwise. + */ + StatusCode + virtual configureD3PD (IAddVariable* tree, + const std::type_info& ti); + + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const TruthParticle* get (const HepMC::GenParticle& p); + + +private: + /** + * @brief Incident handler. + * @param inc The incident. + */ + virtual void handle (const Incident &inc); + + + /// Property: The label of the collection getter defining the collection + /// within which to look for TruthParticle instances. + /// If empty, we instead use m_getter. + std::string m_targetLabel; + + /// Property: The getter used to find the TruthParticle collection. + /// Only used of m_targetLabel is empty. + ToolHandle<IObjGetterTool> m_getter; + + /// Property: The ICollectionGetterRegistryTool instance. + ToolHandle<ICollectionGetterRegistryTool> m_registry; + + /// Property: The incident service. + ServiceHandle<IIncidentSvc> m_incSvc; + + /// Pointer to the getter we're using. + IObjGetterTool* m_target; + + /// Cached TruthParticle collection. + const TruthParticleContainer* m_container; +}; + + +} // namespace D3PD + + +#endif // not EVENTCOMMOND3PDMAKER_GENPARTICLETRUTHPARTICLEASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.cxx new file mode 100644 index 00000000000..1ee8ab074cb --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.cxx @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleVertexAssociationTool.cxx 348274 2011-02-28 16:25:06Z krasznaa $ + +// Local include(s): +#include "GenParticleVertexAssociationTool.h" + +namespace D3PD { + + GenParticleVertexAssociationTool::GenParticleVertexAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ) { + + declareProperty( "DecayVertex", m_decay = false, + "When set to True, the tool will return the decay vertex and not the " + "production vertex" ); + } + + const HepMC::GenVertex* GenParticleVertexAssociationTool::get( const HepMC::GenParticle& p ) { + + if( m_decay ) return p.end_vertex(); + return p.production_vertex(); + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.h new file mode 100644 index 00000000000..39a157713fa --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenParticleVertexAssociationTool.h @@ -0,0 +1,67 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleVertexAssociationTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenParticleVertexAssociationTool.h + * @author Georges Aad + * @date Oct, 2010 + * @brief association from MC particles to MC vertices + * + */ +#ifndef TRUTHD3PDMAKER_GENPARTICLEVERTEXASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_GENPARTICLEVERTEXASSOCIATIONTOOL_H + +// D3PDMaker include(s): +#include "D3PDMakerUtils/SingleAssociationTool.h" + +// EDM include(s): +#include "HepMC/GenParticle.h" +#include "HepMC/GenVertex.h" + +namespace D3PD { + + /** + * @brief Associate Gen particles to there corresponding production and decay + * vertices + * + * $Revision: 348274 $ + * $Date: 2011-02-28 17:25:06 +0100 (Mon, 28 Feb 2011) $ + */ + class GenParticleVertexAssociationTool + : public SingleAssociationTool< HepMC::GenParticle, HepMC::GenVertex > { + + public: + /// Convenience typedef + typedef SingleAssociationTool< HepMC::GenParticle, HepMC::GenVertex > Base; + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenParticleVertexAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ); + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const HepMC::GenVertex* get( const HepMC::GenParticle& p ); + + private: + /// When set to true, return the decay vertex of the particle + bool m_decay; + + }; // class GenParticleVertexAssociationTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENPARTICLEVERTEXASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.cxx new file mode 100644 index 00000000000..8e1336e619e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.cxx @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexEventAssociationTool.cxx 348274 2011-02-28 16:25:06Z krasznaa $ + +// Local include(s): +#include "GenVertexEventAssociationTool.h" + +namespace D3PD { + + GenVertexEventAssociationTool::GenVertexEventAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ) { + + } + + const HepMC::GenEvent* GenVertexEventAssociationTool::get( const HepMC::GenVertex& p ) { + + return p.parent_event(); + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.h new file mode 100644 index 00000000000..733ebee4734 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexEventAssociationTool.h @@ -0,0 +1,60 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexEventAssociationTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenVertexEventAssociationTool.h + * @author Georges Aad + * @date Jul, 2010 + * @brief association from MC vertices to MC events + * + */ +#ifndef TRUTHD3PDMAKER_GENVERTEXEVENTASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_GENVERTEXEVENTASSOCIATIONTOOL_H + +// D3PDMaker include(s): +#include "D3PDMakerUtils/SingleAssociationTool.h" + +// EDM include(s): +#include "HepMC/GenEvent.h" +#include "HepMC/GenVertex.h" + +namespace D3PD { + + /** + * @brief Associate Gen particles to there corresponding event + * + */ + class GenVertexEventAssociationTool + : public SingleAssociationTool< HepMC::GenVertex, HepMC::GenEvent > { + + public: + /// Convenience typedef + typedef SingleAssociationTool< HepMC::GenVertex, HepMC::GenEvent > Base; + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenVertexEventAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ); + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const HepMC::GenEvent* get( const HepMC::GenVertex& p ); + + }; // class GenVertexEventAssociationTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENVERTEXEVENTASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.cxx new file mode 100644 index 00000000000..cc5733dbce4 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.cxx @@ -0,0 +1,77 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexFillerTool.cxx 586037 2014-03-03 23:23:18Z zmarshal $ +/** + * @file EventCommonD3PDMaker/src/GenVertexFillerTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Apr, 2010 + * @brief Fill the position of a vertex. + */ + + +#include "GenVertexFillerTool.h" +#include "HepMC/GenVertex.h" +#include "CLHEP/Geometry/Point3D.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +GenVertexFillerTool::GenVertexFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<HepMC::GenVertex> (type, name, parent) +{ + m_do_id = false; + book().ignore(); // Avoid coverity warnings. + declareProperty ("WriteID", m_do_id = false); +} + + +/** + * @brief Book variables for this block. + */ +StatusCode GenVertexFillerTool::book() +{ + CHECK( addVariable ("x", m_x, "Vertex x position") ); + CHECK( addVariable ("y", m_y, "Vertex y position") ); + CHECK( addVariable ("z", m_z, "Vertex z position") ); + CHECK( addVariable ("barcode", m_barcode, "Vertex barcode") ); + if (m_do_id){ + CHECK( addVariable ("id", m_id, "Vertex ID") ); + } + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode GenVertexFillerTool::fill (const HepMC::GenVertex& p) +{ + HepMC::ThreeVector pos = p.point3d(); + *m_x = pos.x(); + *m_y = pos.y(); + *m_z = pos.z(); + *m_barcode = p.barcode(); + if (m_do_id) *m_id = p.id(); + + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.h new file mode 100644 index 00000000000..406f650d80a --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexFillerTool.h @@ -0,0 +1,87 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexFillerTool.h 586037 2014-03-03 23:23:18Z zmarshal $ +/** + * @file EventCommonD3PDMaker/src/GenVertexFillerTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Apr, 2010 + * @brief Fill the position of a vertex. + */ + + +#ifndef EVENTCOMMOND3PDMAKER_GENVERTEXFILLERTOOL_H +#define EVENTCOMMOND3PDMAKER_GENVERTEXFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +namespace HepMC { + class GenVertex; +} + + +namespace D3PD { + + +/** + * @brief Fill the position of a vertex. + */ +class GenVertexFillerTool + : public BlockFillerTool<HepMC::GenVertex> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenVertexFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const HepMC::GenVertex& p); + + +private: + /// Parameter: Write vertex ID + bool m_do_id; + + /// Variable: Vertex x position. + float* m_x; + + /// Variable: Vertex y position. + float* m_y; + + /// Variable: Vertex z position. + float* m_z; + + /// Variable: Vertex barcode. + int *m_barcode; + + /// Variable: Vertex ID + int *m_id; + +}; + + +} // namespace D3PD + + +#endif // not EVENTCOMMOND3PDMAKER_GENVERTEXFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.cxx new file mode 100644 index 00000000000..f3c00f5e53e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.cxx @@ -0,0 +1,118 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexGetterTool.cxx 452268 2011-08-04 20:27:55Z ssnyder $ + +// Gaudi/Athena include(s): +#include "AthenaKernel/errorcheck.h" + +// EDM include(s): +#include "HepMC/GenVertex.h" + +// Local include(s): +#include "GenVertexGetterTool.h" + +namespace D3PD { + + GenVertexGetterTool::GenVertexGetterTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ), + m_mcColl(0), + m_selector( "GenObjectsFilterTool" ) + { + + declareProperty( "Selector", m_selector, + "Handle for the selector tool to be used" ); + } + + StatusCode GenVertexGetterTool::initialize() { + + // Initialize the base class: + CHECK( Base::initialize() ); + // Retrieve the selector tool: + CHECK( m_selector.retrieve() ); + + return StatusCode::SUCCESS; + } + + size_t GenVertexGetterTool::sizeHint( bool allowMissing ) { + + const McEventCollection* mc = get( allowMissing ); + if( ! mc ) { + return 0; + } + + McEventCollection::const_iterator iter = mc->begin(); + if( iter == mc->end() ) return 0; + + return ( *iter )->vertices_size(); + } + + StatusCode GenVertexGetterTool::reset( bool allowMissing ) { + + m_mcColl = get( allowMissing ); + + if( ! m_mcColl ) { + m_evtItr = m_evtEnd; + m_vtxItr = m_vtxEnd; + if( allowMissing ) return StatusCode::SUCCESS; + return StatusCode::FAILURE; + } + + m_evtItr = m_mcColl->begin(); + m_evtEnd = m_mcColl->end(); + + if( m_evtItr == m_evtEnd ){ + m_vtxItr = m_vtxEnd; + return StatusCode::SUCCESS; + } + + m_vtxItr = ( *m_evtItr )->vertices_begin(); + m_vtxEnd = ( *m_evtItr )->vertices_end(); + + return StatusCode::SUCCESS; + } + + const void* GenVertexGetterTool::nextUntyped() { + + if( m_evtItr == m_evtEnd ) return 0; + + // Check if this GenEvent passes our selection cuts: + if( ! m_selector->pass( *m_evtItr, m_mcColl ) ) { + ++m_evtItr; + if( m_evtItr == m_evtEnd ) return 0; + m_vtxItr = ( *m_evtItr )->vertices_begin(); + m_vtxEnd = ( *m_evtItr )->vertices_end(); + return nextUntyped(); + } + + // Check if there are no more vertices in this GenEvent: + if( m_vtxEnd == m_vtxItr ){ + ++m_evtItr; + if( m_evtItr == m_evtEnd ) return 0; + + m_vtxItr = ( *m_evtItr )->vertices_begin(); + m_vtxEnd = ( *m_evtItr )->vertices_end(); + return nextUntyped(); + } + + if( ! m_selector->pass( *m_vtxItr, m_mcColl ) ) { + ++m_vtxItr; + return nextUntyped(); + } + + // I just like to write this part our verbosely... + HepMC::GenVertex* vtx = *m_vtxItr; + ++m_vtxItr; + + return vtx; + } + + const std::type_info& GenVertexGetterTool::elementTypeinfo() const { + + return typeid( HepMC::GenVertex ); + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.h new file mode 100644 index 00000000000..e2106eddb9d --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexGetterTool.h @@ -0,0 +1,82 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexGetterTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenVertexGetterTool.h + * @author Georges Aad + * @date Nov, 2010 + * @brief getter for GenVertex +*/ +#ifndef TRUTHD3PDMAKER_GENVERTEXGETTERTOOL_H +#define TRUTHD3PDMAKER_GENVERTEXGETTERTOOL_H + +// Gaudi/Athena include(s): +#include "GaudiKernel/ToolHandle.h" + +// EDM include(s): +#include "GeneratorObjects/McEventCollection.h" +#include "HepMC/GenEvent.h" + +// Helper tool(s): +#include "TruthD3PDAnalysis/IGenObjectsFilterTool.h" + +// D3PDMaker include(s): +#include "D3PDMakerUtils/SGCollectionGetterTool.h" + +namespace D3PD { + + /** + * @short Getter tool iterating over "good" GenVertex objects + * + * This tool can be used to feed a D3PD job with "good" + * GenVertex objects. + * + * @author Georges Aad <aad@cern.ch> + * + * $Revision: 348274 $ + * $Date: 2011-02-28 17:25:06 +0100 (Mon, 28 Feb 2011) $ + */ + class GenVertexGetterTool + : public SGCollectionGetterTool< McEventCollection > { + + public: + /// Convenience typedef + typedef SGCollectionGetterTool< McEventCollection > Base; + + /// Default AlgTool constructor + GenVertexGetterTool( const std::string& type, const std::string& name, + const IInterface* parent ); + + /// Initialization function + virtual StatusCode initialize(); + virtual size_t sizeHint( bool allowMissing = false ); + virtual StatusCode reset( bool sllowMissing = false ); + virtual const void* nextUntyped(); + virtual const std::type_info& elementTypeinfo() const; + + private: + /// Pointer to the current McEventCollection object + const McEventCollection* m_mcColl; + + /// Iterator pointing at the current GenEvent object + McEventCollection::const_iterator m_evtItr; + /// Iterator pointing at the last GenEvent object + McEventCollection::const_iterator m_evtEnd; + + /// Iterator pointing at the current GenVertex object + HepMC::GenEvent::vertex_const_iterator m_vtxItr; + /// Iterator pointing at the lst GenVertex object + HepMC::GenEvent::vertex_const_iterator m_vtxEnd; + + /// Tool used to select "good" GenVertex objects + ToolHandle< IGenObjectsFilterTool > m_selector; + + }; // class GenVertexGetterTool + +} // class D3PD + +#endif // TRUTHD3PDMAKER_GENVERTEXGETTERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.cxx new file mode 100644 index 00000000000..66084b2c347 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.cxx @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexParticleAssociationTool.cxx 348274 2011-02-28 16:25:06Z krasznaa $ + +// Local include(s): +#include "GenVertexParticleAssociationTool.h" + +namespace D3PD { + + GenVertexParticleAssociationTool::GenVertexParticleAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ) + : Base( type, name, parent ) { + + declareProperty( "InParticles", m_inParticles = false, + "Associate the incoming particles of the vertex" ); + } + + StatusCode GenVertexParticleAssociationTool::reset( const HepMC::GenVertex& p ) { + + if( m_inParticles ) { + m_partItr = p.particles_in_const_begin(); + m_partEnd = p.particles_in_const_end(); + return StatusCode::SUCCESS; + } + + m_partItr = p.particles_out_const_begin(); + m_partEnd = p.particles_out_const_end(); + return StatusCode::SUCCESS; + } + + const HepMC::GenParticle* GenVertexParticleAssociationTool::next() { + + if( m_partItr == m_partEnd ) return 0; + + // I like to be verbose about the following: + const HepMC::GenParticle* part = *m_partItr; + ++m_partItr; + + return part; + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.h new file mode 100644 index 00000000000..944b1a31497 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/GenVertexParticleAssociationTool.h @@ -0,0 +1,80 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenVertexParticleAssociationTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file TruthD3PDMaker/src/GenVertexParticleAssociationTool.h + * @author Georges Aad + * @date Oct, 2010 + * @brief association from MC vertices to MC particles + * + */ +#ifndef TRUTHD3PDMAKER_GENVERTEXPARTICLEASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_GENVERTEXPARTICLEASSOCIATIONTOOL_H + +// STL include(s): +#include <vector> + +// D3PDMaker include(s): +#include "D3PDMakerUtils/MultiAssociationTool.h" + +// EDM include(s): +#include "HepMC/GenVertex.h" +#include "HepMC/GenParticle.h" + +namespace D3PD { + + /** + * @brief Associate Gen vertices to there corresponding in and out particles + * can be used also for particle parent child association if conbined with + * particle-vertex association + * + * $Revision: 348274 $ + * $Date: 2011-02-28 17:25:06 +0100 (Mon, 28 Feb 2011) $ + */ + class GenVertexParticleAssociationTool + : public MultiAssociationTool< HepMC::GenVertex, HepMC::GenParticle > { + + public: + /// Convenience typedef + typedef MultiAssociationTool< HepMC::GenVertex, HepMC::GenParticle > Base; + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + GenVertexParticleAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent ); + + /** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ + virtual StatusCode reset( const HepMC::GenVertex& p ); + + /** + * @brief Return a pointer to the next element in the association. + * Return 0 when the association has been exhausted. + */ + const HepMC::GenParticle* next(); + + private: + /// Iterator pointing at the current particle + std::vector< HepMC::GenParticle* >::const_iterator m_partItr; + /// Iterator pointing at the last particle + std::vector< HepMC::GenParticle* >::const_iterator m_partEnd; + + /// Associate the incoming particles of the vertex + bool m_inParticles; + + }; // class GenVertexParticleAssociationTool + +} // namespace D3PD + +#endif // TRUTHD3PDMAKER_GENVERTEXPARTICLEASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.cxx new file mode 100644 index 00000000000..dcec08c68e7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.cxx @@ -0,0 +1,122 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/// @author George Lewis +/// @date Nov, 2010 +/// @brief Fill in Heavy Flavor type for MC from HforTool +/// Modified for use with TruthD3PDMaker + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "AthenaKernel/errorcheck.h" +#include "HforFillerTool.h" + +namespace D3PD{ + + HforFillerTool::HforFillerTool(const std::string& type, const std::string& name, const IInterface* parent) + : BlockFillerTool<void> (type, name, parent), + m_hfor_tool("HforTool/hforTool") + { + declareProperty("hforTool", m_hfor_tool); + } + + + StatusCode HforFillerTool::initialize() { + CHECK( BlockFillerTool<void>::initialize() ); + CHECK( m_hfor_tool.retrieve() ); + return StatusCode::SUCCESS; + } + + + StatusCode HforFillerTool::book() { + CHECK( addVariable ("hfor_type", m_hfor_type) ); + CHECK( addVariable ("hfor_event_flavour", hfor_event_flavour) ); + CHECK( addVariable ("hfor_Quarks_px", hfor_Quarks_px) ); + CHECK( addVariable ("hfor_Quarks_py", hfor_Quarks_py) ); + CHECK( addVariable ("hfor_Quarks_pz", hfor_Quarks_pz) ); + CHECK( addVariable ("hfor_Quarks_e", hfor_Quarks_e) ); + + return StatusCode::SUCCESS; + } + + + StatusCode HforFillerTool::fill() { + + // Get the result for the method chosen in the config-file + + hfor_Quarks_px->clear(); + hfor_Quarks_py->clear(); + hfor_Quarks_pz->clear(); + hfor_Quarks_e->clear(); + + hfor_event_flavour->clear(); + *m_hfor_type = -1; + + std::string hfor_decision; + int m_event_flavour; + + std::vector<HepMC::FourVector> GS_bQuarks; + std::vector<HepMC::FourVector> ME_bQuarks; + + std::vector<HepMC::FourVector> GS_cQuarks; + std::vector<HepMC::FourVector> ME_cQuarks; + + // execute() throws a StatusCode::FAILURE if heavy flavor overlap is not required + StatusCode sc = m_hfor_tool->execute(); + if (sc != StatusCode::FAILURE) { + hfor_decision = m_hfor_tool->getDecision(); + + GS_bQuarks = m_hfor_tool->get_bQuarks_GS(); + ME_bQuarks = m_hfor_tool->get_bQuarks_ME(); + + ME_cQuarks = m_hfor_tool->get_cQuarks_GS(); + GS_cQuarks = m_hfor_tool->get_cQuarks_ME(); + + if (hfor_decision == "") *m_hfor_type = -1; + else if (hfor_decision == "isBB") *m_hfor_type = 0; + else if (hfor_decision == "isCC") *m_hfor_type = 1; + else if (hfor_decision == "isC") *m_hfor_type = 2; + else if (hfor_decision == "isLightFlavor") *m_hfor_type = 3; + else if (hfor_decision == "kill_bb") *m_hfor_type = 4; + else if (hfor_decision == "kill_cc") *m_hfor_type = 4; + else if (hfor_decision == "kill") *m_hfor_type = 4; + + for (size_t i=0; i<GS_bQuarks.size(); i++){ + hfor_Quarks_px->push_back( static_cast<float> (GS_bQuarks.at(i).px()) ); + hfor_Quarks_py->push_back( static_cast<float> (GS_bQuarks.at(i).py()) ); + hfor_Quarks_pz->push_back( static_cast<float> (GS_bQuarks.at(i).pz()) ); + hfor_Quarks_e->push_back( static_cast<float> (GS_bQuarks.at(i).e()) ); + m_event_flavour = 0; + hfor_event_flavour->push_back(m_event_flavour); + } + for (size_t i=0; i<ME_bQuarks.size(); i++){ + hfor_Quarks_px->push_back( static_cast<float> (ME_bQuarks.at(i).px()) ); + hfor_Quarks_py->push_back( static_cast<float> (ME_bQuarks.at(i).py()) ); + hfor_Quarks_pz->push_back( static_cast<float> (ME_bQuarks.at(i).pz()) ); + hfor_Quarks_e->push_back( static_cast<float> (ME_bQuarks.at(i).e()) ); + m_event_flavour = 1; + hfor_event_flavour->push_back(m_event_flavour); + } + for (size_t i=0; i<GS_cQuarks.size(); i++){ + hfor_Quarks_px->push_back( static_cast<float> (GS_cQuarks.at(i).px()) ); + hfor_Quarks_py->push_back( static_cast<float> (GS_cQuarks.at(i).py()) ); + hfor_Quarks_pz->push_back( static_cast<float> (GS_cQuarks.at(i).pz()) ); + hfor_Quarks_e->push_back( static_cast<float> (GS_cQuarks.at(i).e()) ); + m_event_flavour = 2; + hfor_event_flavour->push_back(m_event_flavour); + } + for (size_t i=0; i<ME_cQuarks.size(); i++){ + hfor_Quarks_px->push_back( static_cast<float> (ME_cQuarks.at(i).px()) ); + hfor_Quarks_py->push_back( static_cast<float> (ME_cQuarks.at(i).py()) ); + hfor_Quarks_pz->push_back( static_cast<float> (ME_cQuarks.at(i).pz()) ); + hfor_Quarks_e->push_back( static_cast<float> (ME_cQuarks.at(i).e()) ); + m_event_flavour = 3; + hfor_event_flavour->push_back(m_event_flavour); + } + + } + + return StatusCode::SUCCESS; + } + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.h new file mode 100644 index 00000000000..61aef611d18 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/HforFillerTool.h @@ -0,0 +1,49 @@ +// -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/// @author George Lewis +/// @date Nov, 2010 +/// @brief Fill in Heavy Flavor type for MC from HforTool + +#ifndef TOPINPUTSD3PDMAKER_HFORFILLERTOOL_H +#define TOPINPUTSD3PDMAKER_HFORFILLERTOOL_H + +#include "GaudiKernel/ToolHandle.h" +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "HforTool/HforTool.h" + +namespace D3PD { + + + class HforFillerTool : public BlockFillerTool<void> { + public: + + HforFillerTool (const std::string& type, const std::string& name, const IInterface* parent); + + StatusCode initialize(); + + virtual StatusCode book(); + + virtual StatusCode fill(); + + + private: + + ToolHandle<IHforTool> m_hfor_tool; + + int* m_hfor_type; + std::vector<float>* hfor_Quarks_px; + std::vector<float>* hfor_Quarks_py; + std::vector<float>* hfor_Quarks_pz; + std::vector<float>* hfor_Quarks_e; + std::vector<int>* hfor_event_flavour; + + }; // class HforFillerTool + +} // namespace D3PD + +#endif diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.cxx new file mode 100644 index 00000000000..ce2a8884f58 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.cxx @@ -0,0 +1,126 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/JetFullTruthTag.cxx + * @author Zach Marshall <zach.marshall@cern.ch> + * @date June, 2013 + * @brief Truth tagging info for truth jets + */ + +#include "JetFullTruthTag.h" +#include "AthenaKernel/errorcheck.h" +#include "JetEvent/Jet.h" +#include "GeneratorObjects/McEventCollection.h" +#include "HepMC/GenParticle.h" +#include "HepPID/ParticleIDMethods.hh" +#include "GaudiKernel/SystemOfUnits.h" + +#include <iostream> +#include <cmath> + +namespace D3PD { + +using Gaudi::Units::GeV; + +JetFullTruthTag::JetFullTruthTag (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<Jet> (type, name, parent) +{ + // Avoid coverity warnings + book().ignore(); + + declareProperty ("HadronMatchDR" , m_hadronMatch_dr = 0.3 ); + declareProperty ("PartonMatchDR" , m_partonMatch_dr = 0.4 ); + declareProperty ("TruthCollectionName" , m_truthCollectionName = "GEN_EVENT" ); + declareProperty ("MinPartonPt" , m_min_parton_pt = 5*GeV ); + declareProperty ("MinHadronPt" , m_min_hadron_pt = 5*GeV ); +} + +StatusCode JetFullTruthTag::book() +{ + CHECK( addVariable ("partonDR", m_partonDR) ); + CHECK( addVariable ("partonFlavor", m_partonFlavor) ); + CHECK( addVariable ("hadronFlavor", m_hadronFlavor) ); + CHECK( addVariable ("hadronPDGID", m_hadronPDGID) ); + return StatusCode::SUCCESS; +} + +StatusCode JetFullTruthTag::fill (const Jet& p) +{ + *m_partonDR = -1.; + *m_partonFlavor = 0; + *m_hadronFlavor = 0; + *m_hadronPDGID = 0; + double Emax = 0.; + int pdgid=0; + double dR2=0.; + + const DataHandle<McEventCollection> mcCollection; + if (evtStore()->retrieve(mcCollection,m_truthCollectionName).isSuccess()) { + // We have an McEventCollection + for (McEventCollection::const_iterator currentGenEventIter = mcCollection->begin(); + currentGenEventIter!=mcCollection->end(); ++currentGenEventIter) { + for (HepMC::GenEvent::particle_const_iterator currentGenParticleIter= (*currentGenEventIter)->particles_begin(); + currentGenParticleIter!= (*currentGenEventIter)->particles_end(); ++currentGenParticleIter) { + + // Grab the PDGID, used both for partons and hadrons + pdgid = (*currentGenParticleIter)->pdg_id(); + + // Parton labeling section... + if((*currentGenParticleIter)->momentum().e()>=Emax && (*currentGenParticleIter)->momentum().perp()>m_min_parton_pt){ + if( abs(pdgid)<=21 && // Should be a parton + abs(pdgid)!=6 && // Should not be a top + (abs(pdgid)==15 || abs(pdgid)<=10 || abs(pdgid)>16) && // Not a lepton + abs(pdgid)!=0){ // not an unrecognized thingy + + dR2 = std::pow( std::acos( std::cos( p.phi() - (*currentGenParticleIter)->momentum().phi() ) ) , 2 ); + dR2 += std::pow( p.eta()-(*currentGenParticleIter)->momentum().eta() , 2 ); + + if(dR2<=m_partonMatch_dr*m_partonMatch_dr){ // We have a winner + Emax=(*currentGenParticleIter)->momentum().e(); + *m_partonFlavor = (*currentGenParticleIter)->pdg_id(); + *m_partonDR = static_cast<float> (dR2); + } // Outside of dR + } // Wrong PDG ID + } // Low energy + + // Hadron labeling section + if ((HepPID::isHadron (pdgid) || abs(pdgid)==15) && ((*currentGenParticleIter)->momentum().perp()>m_min_hadron_pt)){ + + // Check on DR match + dR2 = std::pow( std::acos( std::cos( p.phi() - (*currentGenParticleIter)->momentum().phi() ) ) , 2 ); + dR2 += std::pow( p.eta()-(*currentGenParticleIter)->momentum().eta() , 2 ); + + if( dR2<=m_hadronMatch_dr*m_hadronMatch_dr ){ + // Strict ordering bottom up - 0 -> tau -> c -> b + if( abs(pdgid)==15 && (*m_hadronPDGID)==0 ){ + *m_hadronPDGID = 15; + *m_hadronFlavor = 15; + } + if ( HepPID::hasCharm (pdgid) && ((*m_hadronPDGID)==0 || (*m_hadronPDGID)==15)){ + *m_hadronPDGID = 4; + *m_hadronFlavor = pdgid; + } + if ( HepPID::hasBottom (pdgid) ){ + *m_hadronPDGID = 5; + *m_hadronFlavor = pdgid; + } + } // Passed dR match + } // End of was a hadron or tau + + } // Loop over particles + } // Loop over events + } // Was an McEventCollection + + if ( ((*m_hadronFlavor)==4 || (*m_hadronFlavor)==5) && // hadron label fired + ((*m_partonFlavor)==9 || (*m_partonFlavor)==21 ) ) // parton was a gluon + *m_partonFlavor = *m_hadronFlavor; + + return StatusCode::SUCCESS; +} + +} // namespace D3PD + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.h new file mode 100644 index 00000000000..39aff8dfbbd --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/JetFullTruthTag.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/JetFullTruthTag.h + * @author Zach Marshall <zach.marshall@cern.ch> + * @date June, 2013 + * @brief Provides significant info for truth jets. + Fakes the filling of reco-like branches + */ + +#ifndef TRUTHD3PDMAKER_JETFULLTRUTHTAG_H +#define TRUTHD3PDMAKER_JETFULLTRUTHTAG_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include <vector> + +class Jet; + +namespace D3PD { + +class JetFullTruthTag : public BlockFillerTool<Jet> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + JetFullTruthTag (const std::string& type, + const std::string& name, + const IInterface* parent); + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const Jet& p); + +private: + float m_hadronMatch_dr,m_partonMatch_dr; + float m_min_hadron_pt; + float m_min_parton_pt; + std::string m_truthCollectionName; + + int *m_partonFlavor; + float *m_partonDR; + int *m_hadronFlavor; + int *m_hadronPDGID; + +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_JETFULLTRUTHTAG_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.cxx new file mode 100644 index 00000000000..203ac3d5433 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.cxx @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/PileUpInfoFillerTool.cxx + * @author Jacob Searcy <jsearcy1@uoregon.edu> + * @date Jul, 2010 + * @brief Block Associator tool to aid in looping over PileUpInfo Container for @c PileUpInfo information. +*/ + + + +#include "PileUpInfoAssociatorTool.h" +#include "AthenaKernel/errorcheck.h" + +namespace D3PD { + + +PileUpInfoAssociatorTool::PileUpInfoAssociatorTool(const std::string& type, const std::string& name, const IInterface* parent) + : Base(type,name,parent), + m_pevt_time(0), + m_pevt_index(0) +{} + +StatusCode PileUpInfoAssociatorTool::reset(const PileUpEventInfo &p){ + m_it = p.beginSubEvt(); + m_end = p.endSubEvt(); + return StatusCode::SUCCESS; + } + + const PileUpEventInfo::SubEvent* PileUpInfoAssociatorTool::next() + { + if(m_it == m_end) return 0; + const PileUpEventInfo::SubEvent* out=&(*m_it); + ++m_it; + return out; + } + } diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.h new file mode 100644 index 00000000000..397a62db6f6 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoAssociatorTool.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/PileUpInfoFillerTool.cxx + * @author Jacob Searcy <jsearcy1@uoregon.edu> + * @date Jul, 2010 + * @brief Block Associator tool to aid in looping over PileUpInfo Container for @c PileUpInfo information. + */ + + +#ifndef TRUTHD3P3MAKER_PILEUPINFOASSOCIATORTOOL_H +#define TRUTHD3P3MAKER_PILEUPINFOASSOCIATORTOOL_H + +#include "EventInfo/EventInfo.h" +#include "EventInfo/PileUpEventInfo.h" +#include "D3PDMakerUtils/MultiAssociationTool.h" + +namespace D3PD { + + class PileUpInfoAssociatorTool : public MultiAssociationTool<PileUpEventInfo,PileUpEventInfo::SubEvent> + { + public: + typedef MultiAssociationTool<PileUpEventInfo,PileUpEventInfo::SubEvent> Base; + + PileUpInfoAssociatorTool(const std::string& type, const std::string& name, const IInterface* parent); + + virtual StatusCode reset(const PileUpEventInfo &p); + virtual const PileUpEventInfo::SubEvent* next(); + + + private: + PileUpEventInfo::SubEvent::const_iterator m_it; + PileUpEventInfo::SubEvent::const_iterator m_end; + long int* m_pevt_time; + long unsigned int* m_pevt_index; + }; +} + +#endif diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.cxx new file mode 100644 index 00000000000..af889156c9c --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.cxx @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/PileUpInfoFillerTool.cxx + * @author Jacob Searcy <jsearcy1@uoregon.edu> + * @date Jul, 2010 + * @brief Block filler tool for @c PileUpInfo information. + */ + + +#include "PileUpInfoFillerTool.h" +#include "AthenaKernel/errorcheck.h" +#include "EventInfo/EventID.h" + + +namespace D3PD { +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +PileUpInfoFillerTool::PileUpInfoFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<PileUpEventInfo::SubEvent> (type, name, parent) +{ + declareProperty ("WriteEventNumbers", m_do_EvtNum = true); + book().ignore(); // Avoid coverity warnings. +} + +/** + * @brief Book variables for this block. + */ +StatusCode PileUpInfoFillerTool::book() +{ + CHECK( addVariable ("time", m_time, "Event time") ); + CHECK( addVariable ("index", m_index, "Event index") ); + CHECK( addVariable ("type", m_type, + "Pileup type provenance. See PileUpTimeEventIndex.") ); + if(m_do_EvtNum){ + CHECK( addVariable ("runNumber", m_run_number, "Event Run Number") ); + CHECK( addVariable ("EventNumber", m_event_number, "Event Number") ); + } + return StatusCode::SUCCESS; +} + + StatusCode PileUpInfoFillerTool::fill (const PileUpEventInfo::SubEvent& p) +{ + + const EventInfo* sevt = p.pSubEvt; + *m_run_number = sevt->event_ID()->run_number(); + *m_event_number = sevt->event_ID()->event_number(); + *m_time = p.time(); + *m_index = p.index(); + *m_type = p.type(); + + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.h new file mode 100644 index 00000000000..98ad2ca8590 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/PileUpInfoFillerTool.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/PileUpInfoFillerTool.h + * @author Jacob Searcy <jsearcy1@uoregon.edu> + * @date Jul, 18 + * @brief Block filler tool for @c PileUpInfo information. + */ + +#ifndef TRUTHD3PPDMAKER_PILEUPINFOFILLERTOOL_H +#define TRUTHD3PDMAKER_PILEUPINFOFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "EventInfo/PileUpEventInfo.h" + + +namespace D3PD { + +/** + * @brief Block filler tool for @c PileUpInfo information. + */ +class PileUpInfoFillerTool + : public BlockFillerTool<PileUpEventInfo::SubEvent> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + PileUpInfoFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const PileUpEventInfo::SubEvent& p); + +private: + /// Variable: Event time. + int* m_time; + /// Variable: Event index. + int* m_index; + /// Variable: Pileup type provenance. + int* m_type; + /// Variable: Event number. + int* m_run_number; + /// Variable: Run number. + int* m_event_number; + /// Write out Event Number + bool m_do_EvtNum; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_PILEUPINFOFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.cxx new file mode 100644 index 00000000000..d7b644406d6 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.cxx @@ -0,0 +1,82 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthEtIsolationFillerTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Mar, 2011 + * @brief Block filler tool for truth isolation information. + */ + +#include "TruthEtIsolationFillerTool.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthEtIsolationFillerTool::TruthEtIsolationFillerTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<McAod::EtIsolations> (type, name, parent), + m_coneIndex (0) +{ + declareProperty ("ConeSize", m_coneSize = 0.2, + "Size of the cone to fill."); + + m_etcone = 0; +} + + +/** + * @brief Book variables for this block. + */ +StatusCode TruthEtIsolationFillerTool::book() +{ + // Find the proper cone index. + for (m_coneIndex = 0; + m_coneIndex < TruthParticleParameters::NbrOfCones; + m_coneIndex++) + { + float sz = TruthParticleParameters::coneCut + (static_cast<TruthParticleParameters::ConeSize> (m_coneIndex)); + if (std::abs(sz - m_coneSize) < 0.01) + break; + } + if (m_coneIndex >= TruthParticleParameters::NbrOfCones) { + REPORT_MESSAGE(MSG::ERROR) << "Can't find requested cone size " + << m_coneSize; + return StatusCode::FAILURE; + } + + int isize = static_cast<int> (m_coneSize*100 + 0.5); + std::ostringstream sname; + sname << "Etcone" << isize; + CHECK( addVariable(sname.str(), m_etcone) ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode TruthEtIsolationFillerTool::fill (const McAod::EtIsolations& p) +{ + *m_etcone = p[m_coneIndex]; + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.h new file mode 100644 index 00000000000..37d95bbd78f --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthEtIsolationFillerTool.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthEtIsolationFillerTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Mar, 2011 + * @brief Block filler tool for truth isolation information. + */ + +#ifndef TRUTHD3PDMAKER_TRUTHETISOLATIONFILLERTOOL_H +#define TRUTHD3PDMAKER_TRUTHETISOLATIONFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "McParticleEvent/TruthParticleParamDefs.h" + + +namespace D3PD { + +class TruthEtIsolationFillerTool : public BlockFillerTool<McAod::EtIsolations> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthEtIsolationFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const McAod::EtIsolations& p); + + +private: + /// Parameter: Desired cone size. + float m_coneSize; + + /// Index of the cone to fill. + unsigned int m_coneIndex; + + /// Variable: Isolation transverse energy. + float* m_etcone; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_TRUTHETISOLATIONFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx new file mode 100644 index 00000000000..8c75f043375 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.cxx @@ -0,0 +1,490 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthJetFilterTool.cxx + * @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> + * @date Apr, 2010 + * @brief Filter truth particles for building truth jets. + */ + + +#include "TruthJetFilterTool.h" +#include "GeneratorObjects/McEventCollection.h" +#include "AthenaKernel/errorcheck.h" +#include "HepMC/GenEvent.h" +#include "HepMC/GenVertex.h" +#include "HepMC/GenParticle.h" +#include "CLHEP/Vector/LorentzVector.h" +#include "boost/foreach.hpp" +#include <utility> + + +using CLHEP::HepLorentzVector; + + +namespace { + + +const int PARTONPDGMAX = 43; +const int NPPDGMIN = 1000000; +const int NPPDGMAX = 9999999; +const int PHOTOSMIN = 10000; +const int GEANTMIN = 200000; + + +} // anonymous namespace + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthJetFilterTool::TruthJetFilterTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : AthAlgTool (type, name, parent), + m_resolver (name, evtStore(), m_mcEventsName), + m_haveSeenAHadron(false), + m_firstHadronBarcode(0) +{ + declareProperty( "McEvents", + m_mcEventsName = "GEN_AOD", + "Name of the input McEventCollection we want to filter" ); + + declareProperty( "McEventsOutput", + m_mcEventsOutputName = "GEN_D3PD", + "Name of the output McEventCollection which has been filtered" ); + + declareProperty( "DoPileup", + m_doPileup = false, + "If true, include particles from pileup/cavern."); + + declareProperty ("RemoveEmpty", + m_removeEmpty = true, + "If true, remove empty GenEvent structures."); + + declareProperty ("DoEtIsolations", + m_doEtIsolations = false, + "Unused, but required by configuration script."); + + declareProperty ("ExcludeWZdecays", + m_excludeWZdecays = false, + "Do we exclude particles from W/Z decays ?"); + + declareProperty ("WritePartons", + m_writePartons = true, + "Keep partons?"); + + declareProperty ("WriteHadrons", + m_writeHadrons = true, + "Keep hadrons?"); + + declareProperty ("WriteGeant", + m_writeGeant = false, + "Keep geant particles?"); + + declareProperty ("ExcludeLeptonsFromTau", + m_excludeLeptonsFromTau = false, + "Do we exclude leptons from tau decays?"); + + declareProperty ("PhotonCone", + m_photonCone=-1., + "Exclude FSR photons in cone of X around WZ lepton"); +} + + +/** + * @brief Standard Gaudi @c queryInterface method. + */ +StatusCode +TruthJetFilterTool::queryInterface( const InterfaceID& riid, void** ppvIf ) +{ + if ( riid == ITruthParticleFilterTool::interfaceID() ) { + *ppvIf = static_cast<ITruthParticleFilterTool*> (this); + addRef(); + return StatusCode::SUCCESS; + } + + return AlgTool::queryInterface( riid, ppvIf ); +} + + +/** + * @brief Standard Gaudi initialize method. + */ +StatusCode TruthJetFilterTool::initialize() +{ + CHECK( m_resolver.initialize<McEventCollection>() ); + return AthAlgTool::initialize(); +} + + +/** + * @brief Standard Gaudi finalize method. + */ +StatusCode TruthJetFilterTool::finalize() +{ + return AthAlgTool::finalize(); +} + + +/** + * @brief Standard Gaudi execute method. + */ +StatusCode TruthJetFilterTool::execute() +{ + m_haveSeenAHadron = false; + m_firstHadronBarcode = 0; + m_WZleptons.clear(); + + // Fetch input collection. + const McEventCollection* mc_in; + CHECK( evtStore()->retrieve (mc_in, m_resolver.key()) ); + + // Create output collection. + McEventCollection* mc_out = new McEventCollection; + CHECK( evtStore()->record (mc_out, m_mcEventsOutputName) ); + CHECK( evtStore()->setConst (mc_out) ); + + // Copy and filter. + CHECK( buildMcAod (mc_in, mc_out) ); + return StatusCode::SUCCESS; +} + + +/** + * This method will check the validity of the input McEventCollection + * and build a filtered one from the strategy implemented by the + * concrete tool. + * It is not const to allow derived tools to build statistics during + * the filtering process. + */ +StatusCode +TruthJetFilterTool::buildMcAod (const McEventCollection* mc_in, + McEventCollection* mc_out) +{ + // Loop over GenEvent's. + mc_out->reserve (mc_in->size()); + BOOST_FOREACH (const HepMC::GenEvent* ev_in, *mc_in) { + if (!ev_in) continue; + + // Copy the GenEvent. + HepMC::GenEvent* ev_out = new HepMC::GenEvent (ev_in->signal_process_id(), + ev_in->event_number()); + ev_out->set_event_scale (ev_in->event_scale()); + ev_out->set_alphaQCD (ev_in->alphaQCD()); + ev_out->set_alphaQED (ev_in->alphaQED()); + ev_out->weights() = ev_in->weights(); + ev_out->set_random_states (ev_in->random_states()); + if (ev_in->heavy_ion()) + ev_out->set_heavy_ion (*ev_in->heavy_ion()); + if (ev_in->pdf_info()) + ev_out->set_pdf_info (*ev_in->pdf_info()); + + // Copy and filter the contents. + CHECK( filterEvent (ev_in, ev_out) ); + + // Maybe throw out empty GenEvent's. + if (m_removeEmpty && ev_out->particles_empty()) + delete ev_out; + else + mc_out->push_back (ev_out); + + // If we don't want pileup, only do the first GenEvent. + if (!m_doPileup) + break; + } + return StatusCode::SUCCESS; +} + + +/** + * @brief Filter a single @c GenEvent. + */ +StatusCode +TruthJetFilterTool::filterEvent (const HepMC::GenEvent* ev_in, + HepMC::GenEvent* ev_out) +{ + // Loop over particles. + // (FOREACH doesn't work here because particle_const_iterator + // isn't consistent in the use of const...) + for (HepMC::GenEvent::particle_const_iterator ip = ev_in->particles_begin(); + ip != ev_in->particles_end(); + ++ip) + { + // Copy the particle if we want to keep it. + if (acceptParticle (*ip)) + CHECK( addParticle (*ip, ev_out) ); + } + return StatusCode::SUCCESS; +} + + +/** + * @brief Add a @c GenParticle (and its production vertex) to a @c GenEvent. + */ +StatusCode +TruthJetFilterTool::addParticle (const HepMC::GenParticle* p, + HepMC::GenEvent* ev) +{ + // Add parent vertex if it exists. Otherwise, add decay vertex. + if (p->production_vertex()) + CHECK( addVertex (p->production_vertex(), ev) ); + else if (p->end_vertex()) + CHECK( addVertex (p->end_vertex(), ev) ); + else { + REPORT_MESSAGE (MSG::ERROR) << "Encountered GenParticle with no vertices!"; + return StatusCode::FAILURE; + } + + // Find the particle in the event. + // If it doesn't exist yet, copy it. + HepMC::GenParticle* pnew = ev->barcode_to_particle (p->barcode()); + if (!pnew) + pnew = new HepMC::GenParticle (*p); + + // Add ourself to our vertices. + if (p->production_vertex()) { + HepMC::GenVertex* v = + ev->barcode_to_vertex (p->production_vertex()->barcode()); + if (v) + v->add_particle_out (pnew); + } + + if (p->end_vertex()) { + HepMC::GenVertex* v = + ev->barcode_to_vertex (p->end_vertex()->barcode()); + if (v) + v->add_particle_in (pnew); + } + + return StatusCode::SUCCESS; +} + + +/** + * @brief Add a @c GenVertex to a @c GenEvent. + */ +StatusCode +TruthJetFilterTool::addVertex (const HepMC::GenVertex* v, + HepMC::GenEvent* ev) +{ + // See if this vertex has already been copied. + HepMC::GenVertex* vnew = ev->barcode_to_vertex (v->barcode()); + if (!vnew) { + // No ... make a new one. + vnew = new HepMC::GenVertex; + vnew->set_position (v->position()); + vnew->set_id (v->id()); + vnew->suggest_barcode (v->barcode()); + vnew->weights() = v->weights(); + ev->add_vertex (vnew); + + // Fill in the existing relations of the new vertex. + BOOST_FOREACH(const HepMC::GenParticle* p, + std::make_pair (v->particles_in_const_begin(), + v->particles_in_const_end())) + { + HepMC::GenParticle* pnew = ev->barcode_to_particle (p->barcode()); + if (pnew) + vnew->add_particle_in (pnew); + } + + BOOST_FOREACH(const HepMC::GenParticle* p, + std::make_pair (v->particles_out_const_begin(), + v->particles_out_const_end())) + { + HepMC::GenParticle* pnew = ev->barcode_to_particle (p->barcode()); + if (pnew) + vnew->add_particle_out (pnew); + } + } + + return StatusCode::SUCCESS; +} + + +/** + * @brief Test to find leptons from tau decays. + */ +bool TruthJetFilterTool::isLeptonFromTau(const HepMC::GenParticle* part) const{ + + int pdg = part->pdg_id(); + + if(abs(pdg) != 11 && + abs(pdg) != 12 && + abs(pdg) != 13 && + abs(pdg) != 14 && + abs(pdg) != 15 && + abs(pdg) != 16) return false; // all leptons including tau. + + HepMC::GenVertex* prod = part->production_vertex(); + if(!prod) return false; // no parent. + + // Loop over the parents of this particle. + HepMC::GenVertex::particle_iterator itrParent = prod->particles_begin(HepMC::parents); + HepMC::GenVertex::particle_iterator endParent = prod->particles_end(HepMC::parents); + for(;itrParent!=endParent; ++itrParent){ + int parentId = (*itrParent)->pdg_id(); + if(abs(parentId) == 15) { + ATH_MSG_DEBUG("Particle with pdgId = " << pdg << ", matched to tau"); + return true; // Has tau parent + } + + if(parentId == pdg) { // Same particle just a different MC status + // Go up the generator record until a tau is found or not. + // Note that this requires a connected *lepton* chain, while calling + // isFromTau would allow leptons from hadrons from taus + if(isLeptonFromTau(*itrParent)) { + return true; + } + } + } + + return false; +} + + +/** + * @brief Test to see if we want to keep a particle. + */ +bool +TruthJetFilterTool::acceptParticle (const HepMC::GenParticle* p) +{ + bool ok = false; + + int pdg_id = std::abs (p->pdg_id()); + int status = p->status(); + int barcode = p->barcode(); + + if (p->barcode() > GEANTMIN && !m_writeGeant) + return false; + + if (m_excludeWZdecays) { + if (pdg_id == 23 || pdg_id == 24) return false; + + HepMC::GenVertex* vprod = p->production_vertex(); + HepMC::GenVertex*oldVprod = vprod; + + if (vprod && vprod->particles_in_size() > 0) { + int mom_pdg_id = pdg_id; + //int mom_barcode = barcode; + // Ascend decay chain looking for when actual decay occurs (not jsut evolution of particle) + while (pdg_id == mom_pdg_id) { + const HepMC::GenParticle* mother = *(vprod->particles_in_const_begin()); + if (mother) { + mom_pdg_id = abs(mother->pdg_id()); + //mom_barcode = mother->barcode(); + } else break; + if (pdg_id != mom_pdg_id) break; + + // Protect against strange infinite reference in sherpa samples + if(oldVprod==mother->production_vertex()) break; + oldVprod = vprod; + + vprod = mother->production_vertex(); + if (!vprod || vprod->particles_in_size() == 0) break; + } // End while loop + + // The following vertex-based identification of W/Z's is needed for SHERPA + // samples where the W/Z particle is not explicitly in the particle record. + // At this point if we have a valid vertex, it should be a true decay vertex. + // If it is a W or Z then two of those decay products should be lepton/neutrino + int nDecay=0; + // Prompt W/Z's should come from a vertex with more than one incoming particle + // This suppresses fave Z's from conversions + if (vprod && vprod->particles_in_size() >1) + { + //std::cout << "Looping over vertex daughters: "<< vprod->particles_out_size() << std::endl; + for(HepMC::GenVertex::particles_out_const_iterator daughter = vprod->particles_out_const_begin();daughter!=vprod->particles_out_const_end();++daughter) + { + //std::cout << "Daughter pdgId: " << (*daughter)->pdg_id() << std::endl; + if((abs((*daughter)->pdg_id())>10 && abs((*daughter)->pdg_id())<17) ) nDecay++; + } + } + bool isWZ = (nDecay==2); + if (mom_pdg_id == 23 || mom_pdg_id == 24 || + mom_pdg_id==1000011 || mom_pdg_id==1000013 || mom_pdg_id==1000015 || // LH sleptons + mom_pdg_id==2000011 || mom_pdg_id==2000013 || mom_pdg_id==2000015 || // RH sleptons + mom_pdg_id==1000012 || mom_pdg_id==1000014 || mom_pdg_id==1000016 || // Sneutrinos + mom_pdg_id==1000023 || mom_pdg_id==1000024 || mom_pdg_id==1000025 || mom_pdg_id==1000035 || // Gauginos + isWZ) { // paricle decends from W or Z + // Save lepton reference for comparison to FSR photons (only for muons and electrons) + if(p->status()==1 && (abs(p->pdg_id())==11 || abs(p->pdg_id())==13) ) m_WZleptons.push_back(p); + //if(p->status()==1 && (abs(p->pdg_id())==11 || abs(p->pdg_id())==13) ) std::cout << "WZParticle found pdgId: " << p->pdg_id() << " status: " << status << std::endl; + + // Only exclude photons within deltaR of leptons (if m_photonCone<0, exclude all photons) + if(std::abs (p->pdg_id()) == 22 && m_photonCone>0) + { + //if(p->status()==1 && (abs(p->pdg_id())==22) ) std::cout << "WZParticle found pdgId: " << p->pdg_id() << " status: " << status << std::endl; + std::vector<const HepMC::GenParticle*>::iterator lep=m_WZleptons.begin(); + for(;lep!=m_WZleptons.end();++lep) { + double deltaR = HepLorentzVector(p->momentum().px(),p->momentum().py(),p->momentum().pz(),p->momentum().e()) + .deltaR( + HepLorentzVector((*lep)->momentum().px(),(*lep)->momentum().py(),(*lep)->momentum().pz(),(*lep)->momentum().e())); + // if photon within deltaR of lepton, remove along with lepton + if( deltaR < m_photonCone ) return false; + } + } + else // not a photon so exclude + return false; + } + } + } + + // is this a lepton from a tau decay? + if (m_excludeLeptonsFromTau && isLeptonFromTau(p) ) { + return false; + } + + // are we at parton/hadron level? + if ( status!=3 && pdg_id > PARTONPDGMAX && !m_haveSeenAHadron ) { + m_haveSeenAHadron = true; + m_firstHadronBarcode = barcode; + } + + // OK if we select partons and are at beginning of event record + if( m_writePartons /*&& !m_haveSeenAHadron */ && + (pdg_id <= PARTONPDGMAX || (pdg_id >= NPPDGMIN && pdg_id <= NPPDGMAX) )) + ok = true; + + // OK if we should select hadrons and are in hadron range + if( m_writeHadrons && m_haveSeenAHadron && barcode < PHOTOSMIN ) + ok = true; + + // PHOTOS range: check whether photons come from parton range or + // hadron range + int motherBarcode = 999999999; + if( barcode > PHOTOSMIN && barcode < GEANTMIN && + p->production_vertex() ) { + const HepMC::GenVertex* vprod = p->production_vertex(); + if (vprod->particles_in_size() > 0) { + const HepMC::GenParticle* mother = *vprod->particles_in_const_begin(); + if (mother) + motherBarcode = mother->barcode(); + } + + if( m_writePartons && motherBarcode < m_firstHadronBarcode ) + ok = true; + if( m_writeHadrons && motherBarcode >= m_firstHadronBarcode ) + ok = true; + } + + // OK if we should select G4 particles and are in G4 range + if( m_writeGeant && barcode > GEANTMIN ) + ok = true; + + return ok; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.h new file mode 100644 index 00000000000..44eacdede3d --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthJetFilterTool.h @@ -0,0 +1,157 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthJetFilterTool.h + * @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> + * @date Apr, 2010 + * @brief Filter truth particles for making truth jets at parton or hadron level. + */ + + +#ifndef TRUTHD3PDMAKER_TRUTHJETFILTERTOOL_H +#define TRUTHD3PDMAKER_TRUTHJETFILTERTOOL_H + + +#include "D3PDMakerUtils/SGKeyResolver.h" +#include "McParticleKernel/ITruthParticleFilterTool.h" +#include "AthenaBaseComps/AthAlgTool.h" +#include <string> +class McEventCollection; +namespace HepMC { + class GenEvent; + class GenVertex; + class GenParticle; +} + + +namespace D3PD { + + +/** + * @brief Filter truth particles for making truth jets at parton or hadron level. + * + * This is used as part of @c TruthParticleBuilder. + * + * This tool retrieves a @c McEventCollection, filters it, and + * writes a new one. + * + * The @c TruthParticleBuilder will then turn the filtered + * @c McEventCollection into a @c TruthParticleContainer. + * + * Most of the code here is just copying the @c McEventCollection --- + * that should be factored out somehow. + */ +class TruthJetFilterTool + : public ITruthParticleFilterTool, public AthAlgTool +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthJetFilterTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Standard Gaudi @c queryInterface method. + virtual StatusCode queryInterface( const InterfaceID& riid, + void** ppvIf ); + + /// Standard Gaudi initialize method. + virtual StatusCode initialize(); + + /// Standard Gaudi finalize method. + virtual StatusCode finalize(); + + /// Run the tool. + virtual StatusCode execute(); + + + /** This method will check the validity of the input McEventCollection + * and build a filtered one from the strategy implemented by the + * concrete tool. + * It is not const to allow derived tools to build statistics during + * the filtering process. + */ + virtual StatusCode buildMcAod( const McEventCollection* in, + McEventCollection* filtered ); + + +private: + /// Filter a single @c GenEvent. + StatusCode filterEvent (const HepMC::GenEvent* ev_in, + HepMC::GenEvent* ev_out); + + /// Add a @c GenParticle (and its production vertex) to a @c GenEvent. + StatusCode addParticle (const HepMC::GenParticle* p, + HepMC::GenEvent* ev); + + /// Add a @c GenVertex to a @c GenEvent. + StatusCode addVertex (const HepMC::GenVertex* p, + HepMC::GenEvent* ev); + + /// Test to see if we want to keep a particle. + bool acceptParticle (const HepMC::GenParticle* p); + + /// Test to see if a particle is a lepton from a tau decay + bool isLeptonFromTau(const HepMC::GenParticle* part) const; + + /// Parameter: SG key for input @c McEventCollection. + std::string m_mcEventsName; + + /// Helper to resolve SG key for input collection. + SGKeyResolver m_resolver; + + /// Parameter: SG key for output @c McEventCollection. + std::string m_mcEventsOutputName; + + /// Parameter: Keep pileup @c GenEvent's? + bool m_doPileup; + + /// Parameter: Remove @c GenEvent's with no particles? + bool m_removeEmpty; + + /// Unused parameter (but required by configuration code). + bool m_doEtIsolations; + + /// Parameter: Do we exclude particles from W/Z decays ? + bool m_excludeWZdecays; + + /// Parameter: Keep partons? + bool m_writePartons; + + /// Parameter: Keep hadrons? + bool m_writeHadrons; + + /// Parameter: Keep geant particles? + bool m_writeGeant; + + /// Parameter: Keep leptons from tau decays? + bool m_excludeLeptonsFromTau; + + /// Set when we see the first hadron. + bool m_haveSeenAHadron; + + /// Set when we see the first hadron. + int m_firstHadronBarcode; + + // Stores leptons from W/Z decays (final state) + std::vector<const HepMC::GenParticle*> m_WZleptons; + + // Parameter: photon summation cone (only used if m_excludeWZdecays) + float m_photonCone; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_TRUTHJETFILTERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx new file mode 100644 index 00000000000..e7d6ad30062 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx @@ -0,0 +1,123 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.cxx + * @author Zach Marshall <zach.marshall@cern.ch> + * @date Feb, 2014 + * @brief Isolation and dressing info for leptons + */ + +#include "TruthLeptonNearbyAssociationTool.h" +#include "AthenaKernel/errorcheck.h" +#include "GeneratorObjects/McEventCollection.h" +#include "HepMC/GenParticle.h" +#include "McParticleEvent/TruthParticle.h" + +#include <iostream> +#include <cmath> + +namespace D3PD { + +TruthLeptonNearbyAssociationTool::TruthLeptonNearbyAssociationTool( const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<TruthParticle> (type, name, parent) +{ + // Avoid coverity warnings + book().ignore(); + + declareProperty ("DressingDR" , m_dressing_dr = 0.1 ); + declareProperty ("TruthCollectionName" , m_truthCollectionName = "GEN_EVENT" ); +} + +StatusCode TruthLeptonNearbyAssociationTool::book() +{ + CHECK( addVariable ("dressed_pt", m_dressed_pt) ); + CHECK( addVariable ("dressed_eta", m_dressed_eta) ); + CHECK( addVariable ("dressed_phi", m_dressed_phi) ); + CHECK( addVariable ("dressed_m", m_dressed_m) ); + CHECK( addVariable ("iso02", m_iso02) ); + CHECK( addVariable ("iso03", m_iso03) ); + return StatusCode::SUCCESS; +} + +StatusCode TruthLeptonNearbyAssociationTool::fill (const TruthParticle& p) +{ + *m_dressed_pt = 0.; + *m_dressed_eta = 0.; + *m_dressed_phi = 0.; + *m_dressed_m = 0.; + + *m_iso02 = 0.; + *m_iso03 = 0.; + + double dR2=0.; + int real_parent=0; + + CLHEP::HepLorentzVector dressed_4mom = p.hlv(); + + const DataHandle<McEventCollection> mcCollection; + if (evtStore()->retrieve(mcCollection,m_truthCollectionName).isSuccess()) { + // We have an McEventCollection + for (McEventCollection::const_iterator currentGenEventIter = mcCollection->begin(); + currentGenEventIter!=mcCollection->end(); ++currentGenEventIter) { + for (HepMC::GenEvent::particle_const_iterator currentGenParticleIter= (*currentGenEventIter)->particles_begin(); + currentGenParticleIter!= (*currentGenEventIter)->particles_end(); ++currentGenParticleIter) { + if (!(*currentGenParticleIter)) continue; + if ((*currentGenParticleIter)->status()!=1) continue; + if ((*currentGenParticleIter)->barcode()==p.barcode()) continue; // The same particle twice! + + dR2 = p.phi() - (*currentGenParticleIter)->momentum().phi(); + if (dR2>M_PI) dR2-=2.*M_PI; + else if (dR2<-M_PI) dR2+=2.*M_PI; + + dR2 = std::pow(dR2,2)+std::pow(p.eta()-(*currentGenParticleIter)->momentum().eta(),2); + + if (dR2>=0.09) continue; // Save a little time + + // Isolation section + *m_iso03 = (*m_iso03)+(*currentGenParticleIter)->momentum().perp(); + if (dR2<0.04) *m_iso02 = (*m_iso02)+(*currentGenParticleIter)->momentum().perp(); + + // Dressing section + if ((*currentGenParticleIter)->pdg_id()!=22) continue; // Only photons + if (dR2>=0.01) continue; // Only DR<0.1 + + real_parent = std::fabs(get_real_parent( *currentGenParticleIter )); + if (real_parent>=26 || real_parent==15) continue; // Veto hadron parents + + dressed_4mom += CLHEP::HepLorentzVector((*currentGenParticleIter)->momentum().x(),(*currentGenParticleIter)->momentum().y(), + (*currentGenParticleIter)->momentum().z(),(*currentGenParticleIter)->momentum().t()); + + } // Loop over particles + } // Loop over events + } // Was an McEventCollection + + *m_dressed_pt = dressed_4mom.perp(); + *m_dressed_eta = dressed_4mom.eta(); + *m_dressed_phi = dressed_4mom.phi(); + *m_dressed_m = dressed_4mom.m(); + + return StatusCode::SUCCESS; +} + +int TruthLeptonNearbyAssociationTool::get_real_parent( HepMC::GenParticle * p , int depth ) const +{ + if (depth>10) return 0; + if (!p->production_vertex()) return 0; + + // Work assuming one parent... + HepMC::GenVertex::particle_iterator itrPar = p->production_vertex()->particles_begin(HepMC::parents); + if ( !(*itrPar) ) return 0; // parent didn't exist + + // Not a photon - return the parent + if ((*itrPar)->pdg_id()!=22) return (*itrPar)->pdg_id(); + + // Photon - iterate + return get_real_parent( *itrPar , depth+1 ); +} + +} // namespace D3PD + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h new file mode 100644 index 00000000000..6a423a0271c --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h @@ -0,0 +1,71 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthLeptonNearbyAssociationTool.h + * @author Zach Marshall <zach.marshall@cern.ch> + * @date Feb, 2014 + * @brief Provides significant info for truth leptons + */ + +#ifndef TRUTHD3PDMAKER_TRUTHLEPTONNEARBYASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_TRUTHLEPTONNEARBYASSOCIATIONTOOL_H + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include <vector> + +class TruthParticle; + +namespace HepMC { + class GenParticle; +} + +namespace D3PD { + +class TruthLeptonNearbyAssociationTool : public BlockFillerTool<TruthParticle> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthLeptonNearbyAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const TruthParticle& p); + +private: + float m_dressing_dr; + std::string m_truthCollectionName; + + float *m_dressed_pt; + float *m_dressed_eta; + float *m_dressed_phi; + float *m_dressed_m; + float *m_iso02; + float *m_iso03; + + int get_real_parent( HepMC::GenParticle * , int depth=0 ) const; + +}; + + +} // namespace D3PD + +#endif // not TRUTHD3PDMAKER_TRUTHLEPTONNEARBYASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx new file mode 100644 index 00000000000..c9df3d75bac --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx @@ -0,0 +1,152 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: +/** + * @file TruthD3PDMaker/src/TruthLeptonParentAssociationTool.cxx + * @author Zach Marshall <zach.marshall@cern.ch> + * @date June, 2013 + * @brief Associate from a lepton to its parent (boson, tau, hadron) + */ + +#include "TruthLeptonParentAssociationTool.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenVertex.h" +#include "AthenaKernel/errorcheck.h" +#include "barcodeOrder.h" +#include "McParticleEvent/TruthParticle.h" +#include "McParticleEvent/TruthParticleContainer.h" +#include "GeneratorObjects/McEventCollection.h" +#include "boost/foreach.hpp" +#include "HepPID/ParticleIDMethods.hh" +#include <algorithm> + +namespace D3PD { + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthLeptonParentAssociationTool::TruthLeptonParentAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent) + , m_primary_is_tau(false) + , m_i (0) +{ + m_barcode_trace.reserve(10); +} + +/** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ +StatusCode +TruthLeptonParentAssociationTool::reset (const TruthParticle& p) +{ + m_i = 0; + m_parents.clear(); + m_parent_barcodes.clear(); + m_barcode_trace.clear(); + + m_primary_is_tau = (15==abs(p.pdgId())); + + // Just add the daughters in... but have to find it in the full record first + const DataHandle<McEventCollection> mcec; + if (evtStore()->retrieve<McEventCollection>(mcec,"GEN_EVENT").isSuccess()){ // Always run on EVGEN anyway... + // Loop over GenEvent's. + BOOST_FOREACH (const HepMC::GenEvent* ev_in, *mcec) { + if (!ev_in) continue; + for (HepMC::GenEvent::particle_const_iterator itrPart = ev_in->particles_begin(); + itrPart!=ev_in->particles_end();++itrPart){ + if ( (*itrPart) && (*itrPart)->barcode()==p.barcode() ){ + // Found it! + addLeptonParent( (*itrPart) ); + break; + } + } // Loop over particles + } // Loop over events + } // Successful retrieve + + const DataHandle<TruthParticleContainer> tpc; + if (evtStore()->retrieve<TruthParticleContainer>(tpc,"D3PDTruth").isSuccess()){ + for (unsigned int i=0;i<tpc->size();++i){ + if (! (*tpc)[i] ) continue; + for (unsigned int j=0;j<m_parent_barcodes.size();++j){ + if ( (*tpc)[i]->barcode() == m_parent_barcodes[j] ){ + m_parents.push_back( (*tpc)[i] ); + break; + } // End matching barcode + } // End loop over barcodes + } // End loop over particles + } // End successful retrieve + + return StatusCode::SUCCESS; +} + +void TruthLeptonParentAssociationTool::addLeptonParent(const HepMC::GenParticle* part) { + + HepMC::GenVertex* begvx = part->production_vertex(); + if(!begvx){ // no parents + return; + } + + // Catch for crazy generators + if (begvx==part->end_vertex()) return; + + // More complex loop catch + if ( find(m_barcode_trace.begin(),m_barcode_trace.end(),begvx->barcode()) != m_barcode_trace.end()){ + ATH_MSG_DEBUG( "Found a loop (a la Sherpa sample). Backing out." ); + return; + } + m_barcode_trace.push_back(begvx->barcode()); + + // Loop over the parents of this particle. + HepMC::GenVertex::particle_iterator itrPar = begvx->particles_begin(HepMC::parents); + HepMC::GenVertex::particle_iterator endPar = begvx->particles_end(HepMC::parents); + int n_iter=0; + for(;itrPar!=endPar; ++itrPar){ + if ( !(*itrPar) ) continue; // parent didn't exist + n_iter++; + if (n_iter>2) break; // No point in trying - this vertex does not have a quantum meaning... + + int pdg = abs((*itrPar)->pdg_id()); + + if ( (31<pdg && pdg<38) || // BSM Higgs / W' / Z' / etc + pdg==39 || + pdg==41 || + pdg==42 || + (1000000<pdg && pdg<1000040) || // left-handed SUSY + (2000000<pdg && pdg<2000040) || + pdg == 22 || // Photon + pdg == 23 || // Z + pdg == 24 || // W + pdg == 25 || // Higgs + (pdg == 15 && !m_primary_is_tau) || // Tau + HepPID::isHadron (pdg) // from a hadron! + ){ + m_parent_barcodes.push_back( (*itrPar)->barcode() ); + } else { // Will get to here if we are coming from the same lepton again + addLeptonParent( *itrPar ); + } // End of catch on PDG ID + } // End loop over parents + +} + +/** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ +const TruthParticle* TruthLeptonParentAssociationTool::next() +{ + if (m_i < m_parents.size()) + return m_parents[m_i++]; + return 0; +} + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h new file mode 100644 index 00000000000..2d32f6969ad --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthLeptonParentAssociationTool.h @@ -0,0 +1,88 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: +/** + * @file TruthD3PDMaker/src/TruthTauDecayAssociationTool.h + * @author Zach Marshall <zach.marshall@cern.ch> + * @date June, 2013 + * @brief Associate from a tau to its hadronic decay products. + */ + +#ifndef EVENTCOMMOND3PDMAKER_TRUTHLEPTONPARENTASSOCIATIONTOOL_H +#define EVENTCOMMOND3PDMAKER_TRUTHLEPTONPARENTASSOCIATIONTOOL_H + +#include "D3PDMakerUtils/MultiAssociationTool.h" + +class TruthParticle; +namespace HepMC { + class GenParticle; +} +namespace D3PD { + +/** + * @brief Associate from a true hadronic tau to its decay products + * + * This is a multiple association tool. + */ +class TruthLeptonParentAssociationTool + : public MultiAssociationTool<TruthParticle> +{ +public: + typedef MultiAssociationTool<TruthParticle> Base; + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthLeptonParentAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + /** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ + virtual StatusCode reset (const TruthParticle& p); + + /** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ + virtual const TruthParticle* next(); + +private: + + /// Function for association to a specific lepton + void addLeptonParent(const HepMC::GenParticle*); + + /// TruthParticle iterator + std::vector<const TruthParticle*> m_parents; + + /// Name of the container + std::string m_truth_container_name; + + /// TruthParticle barcodes + std::vector<int> m_parent_barcodes; + + /// for keeping trace of barcodes in order to detect loops + std::vector<int> m_barcode_trace; + + /// Is the primary a tau? + bool m_primary_is_tau; + + /// Current index + unsigned int m_i; + +}; + +} // namespace D3PD + +#endif // not EVENTCOMMOND3PDMAKER_TRUTHLEPTONPARENTASSOCIATIONTOOL_H + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.cxx new file mode 100644 index 00000000000..c60a54838c2 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.cxx @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.cxx + * @author sss + * @date Mar, 2012 + * @brief Block filler tool for TruthParticle barcode lists (parent/child) + */ + +#include "TruthParticleBarcodesFillerTool.h" +#include "McParticleEvent/TruthParticle.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleBarcodesFillerTool::TruthParticleBarcodesFillerTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<TruthParticle> (type, name, parent) +{ + book().ignore(); // Avoid coverity warnings. +} + + +/** + * @brief Book variables for this block. + */ +StatusCode TruthParticleBarcodesFillerTool::book() +{ + CHECK( addVariable("parents", m_parents) ); + CHECK( addVariable("children", m_children) ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode TruthParticleBarcodesFillerTool::fill (const TruthParticle& p) +{ + m_parents->reserve (p.nParents()); + for(unsigned int i=0; i < p.nParents(); i++) + { + m_parents->push_back(p.mother(i)->barcode()); + } + std::sort (m_parents->begin(), m_parents->end()); + m_children->reserve (p.nDecay()); + for(unsigned int i=0; i < p.nDecay(); i++) + { + m_children->push_back(p.child(i)->barcode()); + } + std::sort (m_children->begin(), m_children->end()); + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.h new file mode 100644 index 00000000000..0b2e2e6ab44 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleBarcodesFillerTool.h + * @author sss + * @date Mar, 2012 + * @brief Block filler tool for TruthParticle barcode lists (parent/child) + */ + +#ifndef TRUTHD3PDMAKER_TRUTHPARTICLEBARCODESFILLERTOOL_H +#define TRUTHD3PDMAKER_TRUTHPARTICLEBARCODESFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include <vector> +class TruthParticle; + +namespace D3PD { + +class TruthParticleBarcodesFillerTool : public BlockFillerTool<TruthParticle> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleBarcodesFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const TruthParticle& p); + + +private: + /// Variable: Barcodes of parents. + std::vector<int>* m_parents; + + /// Variable: Barcodes of children. + std::vector<int>* m_children; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_TRUTHPARTICLEBARCODESFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.cxx new file mode 100644 index 00000000000..5f8c161aeb2 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: TruthParticleBremFillerTool.cxx 604362 2014-07-01 05:25:22Z ssnyder $ +/** + * @file EventCommonD3PDMaker/src/TruthParticleBremFillerTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2009 + * @brief Fill the hasHardBrem flag. + */ + + +#include "TruthParticleBremFillerTool.h" +#include "xAODTruth/TruthVertex.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleBremFillerTool::TruthParticleBremFillerTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<xAOD::TruthParticle> (type, name, parent) +{ + book().ignore(); // Avoid coverity warnings. +} + + +/** + * @brief Book variables for this block. + */ +StatusCode TruthParticleBremFillerTool::book() +{ + CHECK( addVariable ("hasHardBrem", m_hasHardBrem) ); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode TruthParticleBremFillerTool::fill (const xAOD::TruthParticle& p) +{ + const xAOD::TruthVertex* vx = p.decayVtx(); + if (vx) { + size_t sz = vx->nOutgoingParticles(); + int n_children = 0; + int pdgid_child1 = 0; + int pdgid_child2 = 0; + + for (size_t i = 0; i < sz; i++) { + const xAOD::TruthParticle* child = vx->outgoingParticle(i); + if(n_children==0) pdgid_child1 = child->pdgId(); + if(n_children==1) pdgid_child2 = child->pdgId(); + n_children++; + } + + if (n_children == 2 && + ((std::abs(pdgid_child1)==11 && pdgid_child2==22) || + (std::abs(pdgid_child2)==11 && pdgid_child1==22))) + { + *m_hasHardBrem = true; + } + } + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.h new file mode 100644 index 00000000000..2f93a5e3029 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleBremFillerTool.h @@ -0,0 +1,68 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: GenParticleBremFillerTool.h 348274 2011-02-28 16:25:06Z krasznaa $ +/** + * @file EventCommonD3PDMaker/src/GenParticleBremFillerTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2009 + * @brief Fill the hasHardBrem flag. + */ + +#ifndef EVENTCOMMOND3PDMAKER_TRUTHPARTICLEBREMFILLERTOOL_H +#define EVENTCOMMOND3PDMAKER_TRUTHPARTICLEBREMFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "xAODTruth/TruthParticle.h" + + +namespace D3PD { + + +/** + * @brief Fill the hasHardBrem flag. + */ +class TruthParticleBremFillerTool + : public BlockFillerTool<xAOD::TruthParticle> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleBremFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const xAOD::TruthParticle& p); + + +private: + /// Variable: Does this particle have a brem? + bool* m_hasHardBrem; +}; + + +} // namespace D3PD + + +#endif // not EVENTCOMMOND3PDMAKER_TRUTHPARTICLEBREMFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.cxx new file mode 100644 index 00000000000..54431876fdc --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthParticleChildAssociationTool.cxx + * @author Ryan Reece <ryan.reece@cern.ch> + * @date Mar 2010 + * @brief Associate all the children of a TruthParticle. + */ + + +#include "TruthParticleChildAssociationTool.h" +#include "xAODTruth/TruthVertex.h" +#include "barcodeOrder.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleChildAssociationTool::TruthParticleChildAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent), + m_i (0) +{} + + +/** + * @brief Standard Gaudi initialize method. + */ +StatusCode TruthParticleChildAssociationTool::initialize() +{ + return Base::initialize(); +} + + +/** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ +StatusCode +TruthParticleChildAssociationTool::reset (const xAOD::TruthParticle& p) +{ + m_i = 0; + + const xAOD::TruthVertex* vx = p.decayVtx(); + if (!vx) { + m_xaod_children.clear(); + return StatusCode::SUCCESS; + } + + size_t sz = vx->nOutgoingParticles(); + m_xaod_children.resize (sz); + for (unsigned int i = 0; i < sz; i++) + m_xaod_children[i] = vx->outgoingParticle (i); + std::sort (m_xaod_children.begin(), m_xaod_children.end(), barcodeOrder()); + return StatusCode::SUCCESS; +} + + +/** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ +const xAOD::TruthParticle* TruthParticleChildAssociationTool::next() +{ + if (m_i < m_xaod_children.size()) + return m_xaod_children[m_i++]; + return 0; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.h new file mode 100644 index 00000000000..3caffb12cf9 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleChildAssociationTool.h @@ -0,0 +1,84 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthParticleChildAssociationTool.h + * @author Ryan Reece <ryan.reece@cern.ch> + * @date Mar, 2010 + * @brief Associate children of TruthParticles. + */ + + +#ifndef TRUTHD3PDMAKER_DRCONEASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_DRCONEASSOCIATIONTOOl_H + + +#include "D3PDMakerUtils/MultiAssociationTool.h" +#include "xAODTruth/TruthParticle.h" +#include <vector> + + +namespace D3PD { + + +/** + * @brief Associate all particles within a DR cut. + * + * This is a multiple association tool. + * Given an @c TruthParticle object return all of its children. + * + */ +class TruthParticleChildAssociationTool + : public MultiAssociationTool<xAOD::TruthParticle> +{ +public: + typedef MultiAssociationTool<xAOD::TruthParticle> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleChildAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Standard Gaudi initialize method. + virtual StatusCode initialize() override; + + + /** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ + virtual StatusCode reset (const xAOD::TruthParticle& p) override; + + + /** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ + virtual const xAOD::TruthParticle* next() override; + + +private: + /// Vector of xAOD pointers. + std::vector<const xAOD::TruthParticle*> m_xaod_children; + + /// Current index. + unsigned int m_i; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_DRCONEASSOCIATIONTOOl_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.cxx new file mode 100644 index 00000000000..43962ea1bdf --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleClassificationFillerTool.cxx + * @author sss + * @date Jul 2014 + * @brief Block filler for truth classification + */ + + +#include "TruthParticleClassificationFillerTool.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleClassificationFillerTool::TruthParticleClassificationFillerTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base(type, name, parent), + m_classifier ("MCTruthClassifier") +{ + declareProperty ("Classifier", m_classifier, "Classifier tool instance."); + + book().ignore(); // Avoid coverity warnings. +} + + +/** + * @brief Standard Gaudi initialize method. + */ +StatusCode TruthParticleClassificationFillerTool::initialize() +{ + CHECK( m_classifier.retrieve() ); + return Base::initialize(); +} + + +/** + * @brief Book variables for this block. + */ +StatusCode TruthParticleClassificationFillerTool::book() +{ + CHECK( addVariable ("type", m_type, "MC particle type, from classifier tool" ) ); + CHECK( addVariable ("origin", m_origin, "MC particle origin, from classifier tool" ) ); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode +TruthParticleClassificationFillerTool::fill (const xAOD::TruthParticle& p) +{ + std::pair<MCTruthPartClassifier::ParticleType, + MCTruthPartClassifier::ParticleOrigin> res; + + res = m_classifier->particleTruthClassifier(&p); + + *m_type = res.first; + *m_origin = res.second; + + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.h new file mode 100644 index 00000000000..218c4fe2876 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleClassificationFillerTool.h @@ -0,0 +1,79 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleClassificationFillerTool.h + * @author sss + * @date Jul 2014 + * @brief Block filler for truth classification + */ + +#ifndef TRUTHD3PDMAKER_TRUTHPARTICLECLASSIFICATIONFILLERTOOL_H +#define TRUTHD3PDMAKER_TRUTHPARTICLECLASSIFICATIONFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "MCTruthClassifier/IMCTruthClassifier.h" +#include "xAODTruth/TruthParticle.h" +#include "GaudiKernel/ToolHandle.h" + + +namespace D3PD { + + +class TruthParticleClassificationFillerTool + : public BlockFillerTool<xAOD::TruthParticle> +{ +public: + typedef BlockFillerTool<xAOD::TruthParticle> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleClassificationFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Standard Gaudi initialize method. + StatusCode initialize() override; + + + /// Book variables for this block. + virtual StatusCode book() override; + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const xAOD::TruthParticle& p) override; + + + private: + /// Property: The classifier tool. + ToolHandle<IMCTruthClassifier> m_classifier; + + /// Variable: type from classifier tool + int* m_type; + + /// Variable: origin from classifier tool + int* m_origin; +}; + + +} // namespace D3PD + + +#endif // TRUTHD3PDMAKER_TRUTHPARTICLECLASSIFICATIONFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.cxx new file mode 100644 index 00000000000..227c2e6f24d --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.cxx @@ -0,0 +1,85 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/TruthParticleEtIsolationAssociationTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Mar, 2011 + * @brief Associate from a TruthParticle to the set of isolation cones. + */ + + +#include "TruthParticleEtIsolationAssociationTool.h" +#include "D3PDMakerInterfaces/ICollectionGetterTool.h" +#include "McParticleEvent/TruthParticle.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleEtIsolationAssociationTool::TruthParticleEtIsolationAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent), + m_getter ("D3PD::SGDataVectorGetterTool", this) +{ + declareProperty ("Getter", m_getter, + "Getter to find the isolations container."); +} + + +/** + * @brief Configure during initialization: type-check. + * @param tree Our parent for tuple making. + * @param ti Gives the type of the object being passed to @c fillUntyped. + * + * @c configureD3PD should check that the type of the object coming as input + * is compatible with what it expects, and raise an error otherwise. + */ +StatusCode +TruthParticleEtIsolationAssociationTool::configureD3PD + (IAddVariable* tree, + const std::type_info& ti) +{ + CHECK ( Base::configureD3PD (tree, ti) ); + + CHECK( m_getter.retrieve() ); + CHECK( m_getter->configureD3PD<TruthEtIsolations>() ); + + return StatusCode::SUCCESS; +} + + +/** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ +const McAod::EtIsolations* +TruthParticleEtIsolationAssociationTool::get (const TruthParticle& p) +{ + if ( !m_getter->reset().isSuccess() ) { + REPORT_MESSAGE (MSG::WARNING) << "Can't find truth isolations."; + return 0; + } + + while (const TruthEtIsolations* isoc = m_getter->next<TruthEtIsolations>()) { + const McAod::EtIsolations* iso = isoc->etIsolations (p.barcode()); + if (iso) return iso; + } + return 0; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.h new file mode 100644 index 00000000000..acaa8563935 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleEtIsolationAssociationTool.h @@ -0,0 +1,83 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/TruthParticleEtIsolationAssociationTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Mar, 2011 + * @brief Associate from a TruthParticle to the set of isolation cones. + */ + + +#ifndef TRUTHD3PDMAKER_TRUTHPARTICLEETISOLATIONASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_TRUTHPARTICLEETISOLATIONASSOCIATIONTOOL_H + + +#include "D3PDMakerUtils/SingleAssociationTool.h" +#include "McParticleEvent/TruthParticleParamDefs.h" +#include "GaudiKernel/ToolHandle.h" +class TruthParticle; + + +namespace D3PD { + + +class ICollectionGetterTool; + + +/** + * @brief Associate from a TruthParticle to the corresponding GenParticle. + */ +class TruthParticleEtIsolationAssociationTool + : public SingleAssociationTool<TruthParticle, McAod::EtIsolations> +{ +public: + typedef SingleAssociationTool<TruthParticle, McAod::EtIsolations> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleEtIsolationAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const McAod::EtIsolations* get (const TruthParticle& p); + + + /** + * @brief Configure during initialization: type-check. + * @param tree Our parent for tuple making. + * @param ti Gives the type of the object being passed to @c fillUntyped. + * + * @c configureD3PD should check that the type of the object coming as input + * is compatible with what it expects, and raise an error otherwise. + */ + virtual StatusCode configureD3PD (IAddVariable* tree, + const std::type_info& ti); + + +private: + // Property: The getter used to find the isolations container. + ToolHandle<ICollectionGetterTool> m_getter; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_TRUTHPARTICLEETISOLATIONASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.cxx new file mode 100644 index 00000000000..9443e919d2e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.cxx @@ -0,0 +1,116 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleFakerTool.cxx + * @author Zach Marshall <zmarshal@caltech.edu> + * @date April, 2011 + * @brief Block filler tool for TruthParticle's. + * Fakes the filling of branches from "real" reco + */ + +#include "TruthParticleFakerTool.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenVertex.h" +#include "AthenaKernel/errorcheck.h" + +#include "GaudiKernel/SystemOfUnits.h" + +namespace D3PD { + +using Gaudi::Units::GeV; + +TruthParticleFakerTool::TruthParticleFakerTool (const std::string& type, + const std::string& name, + const IInterface* parent) + : BlockFillerTool<HepMC::GenParticle> (type, name, parent), + m_n(0) +{ + // Avoid coverity warnings + m_do_E = true; + m_do_p = true; + m_do_pt = true; + m_do_m = true; + m_do_pn = true; + m_do_chg = true; + m_do_Et = true; + book().ignore(); + + declareProperty ("PDG_ID" , m_filterID = 11 ); + declareProperty ("WriteE", m_do_E = false); + declareProperty ("WriteP", m_do_p = false); + declareProperty ("WritePt", m_do_pt = true); + declareProperty ("WriteM", m_do_m = true); + declareProperty ("WritePn", m_do_pn = false); + declareProperty ("WriteCharge", m_do_chg = true); + declareProperty ("WriteEt", m_do_Et = false); + declareProperty ("MinPt", m_minPt = -1*GeV ); +} + +StatusCode TruthParticleFakerTool::book() +{ + if (m_do_E) CHECK( addVariable ("E", m_E) ); + if (m_do_p) CHECK( addVariable ("p", m_p) ); + if (m_do_pt) CHECK( addVariable ("pt", m_pt) ); + if (m_do_m) CHECK( addVariable ("m", m_m) ); + if (m_do_pn){ + CHECK( addVariable ("px", m_px) ); + CHECK( addVariable ("py", m_py) ); + CHECK( addVariable ("pz", m_pz) ); + } + CHECK( addVariable ("eta", m_eta) ); + CHECK( addVariable ("phi", m_phi) ); + CHECK( addVariable ("status", m_status) ); + CHECK( addVariable ("barcode", m_barcode) ); + if (m_do_chg) CHECK( addVariable ("charge", m_charge) ); + + return StatusCode::SUCCESS; +} + +StatusCode TruthParticleFakerTool::fill (const HepMC::GenParticle& p) +{ + if ( abs(p.pdg_id())!=m_filterID || + p.momentum().perp()<m_minPt ) return IBlockFillerTool::EMPTY; + + bool last = abs(p.pdg_id())==15; + if ( abs(p.pdg_id())==15 && p.status()!=1 && p.end_vertex() ){ + // Special handling for taus - take the ones that are last in the tau chain + for (HepMC::GenVertex::particles_out_const_iterator pit=p.end_vertex()->particles_out_const_begin(); pit!=p.end_vertex()->particles_out_const_end();++pit){ + if (!(*pit) || + abs((*pit)->pdg_id())!=15) continue; + last=false; + break; + } + if (!last) return IBlockFillerTool::EMPTY; + } + + if ( !last && + p.status()%1000 != 1 && + !(p.status()%1000 == 2 && p.status()>1000) && + !(p.status()==2 && (!p.end_vertex() || p.end_vertex()->barcode()<-200000) ) ) { + return IBlockFillerTool::EMPTY; + } + + HepMC::FourVector v = p.momentum(); + if (m_do_E) *m_E = static_cast<float> (v.e()); + if (m_do_p) *m_p = static_cast<float> (v.rho()); + if (m_do_pt) *m_pt = static_cast<float> (v.perp()); + if (m_do_m) *m_m = static_cast<float> (v.m()); + if (m_do_pn){ + *m_px = static_cast<float> (v.px()); + *m_py = static_cast<float> (v.py()); + *m_pz = static_cast<float> (v.pz()); + } + *m_eta = static_cast<float> (v.eta()); + *m_phi = static_cast<float> (v.phi()); + + *m_status = p.status(); + *m_barcode = p.barcode(); + if (m_do_chg) *m_charge = p.pdg_id()<0?1:-1; + + return StatusCode::SUCCESS; +} + +} // namespace D3PD + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.h new file mode 100644 index 00000000000..0ded7164826 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFakerTool.h @@ -0,0 +1,89 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleFakerTool.h + * @author Zach Marshall <zmarshal@caltech.edu> + * @date April, 2011 + * @brief Block filler tool for TruthParticle's. + Fakes the filling of reco-like branches + */ + +#ifndef TRUTHD3PDMAKER_TRUTHPARTICLEFAKERTOOL_H +#define TRUTHD3PDMAKER_TRUTHPARTICLEFAKERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include <vector> +namespace HepMC { + class GenParticle; +} + +namespace D3PD { + +class TruthParticleFakerTool : public BlockFillerTool<HepMC::GenParticle> +{ +public: + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleFakerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Book variables for this block. + virtual StatusCode book(); + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const HepMC::GenParticle& p); + + +private: + int m_filterID; /// Property: Particle ID for filter + + bool m_do_E; /// Property: Should we fill E? + bool m_do_p; /// Property: Should we fill p? + bool m_do_pt; /// Property: Should we fill pt? + bool m_do_m; /// Property: Should we fill m? + bool m_do_pn; /// Property: Should we fill px, py, and pz? + bool m_do_chg; /// Property: Should we fill charge? + bool m_do_Et; /// Property: Should we fill transverse energy? + double m_minPt; /// Property: minimum pT for a lepton + + int m_n; /// Variable: Count of number of particles saved + + float* m_E; /// Variable: Energy. + float* m_p; /// Variable: Momentum. + float* m_Et; /// Variable: Transverse energy. + float* m_pt; /// Variable: Transverse momentum. + float* m_px; /// Variable: x-omentum. + float* m_py; /// Variable: y-momentum. + float* m_pz; /// Variable: z-momentum. + float* m_m; /// Variable: Mass. + float* m_eta; /// Variable: Pseudorapidity. + float* m_phi; /// Variable: Azimuth. + + int* m_type; /// Variable: PDG ID. + int* m_status; /// Variable: status. + int* m_barcode; /// Variable: HepMC barcode. + int* m_charge; /// Variable: Particle charge. +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_TRUTHPARTICLEFAKERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.cxx new file mode 100644 index 00000000000..8647f984791 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.cxx @@ -0,0 +1,108 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleFillerTool.cxx + * @author Ryan Reece <ryan.reece@cern.ch> + * @date Dec, 2009 + * @brief Block filler tool for TruthParticle's. + */ + +#include "TruthParticleFillerTool.h" +#include "McParticleEvent/TruthParticle.h" +#include "AthenaKernel/errorcheck.h" +#include "GaudiKernel/IPartPropSvc.h" +#include "HepPDT/ParticleData.hh" +#include "HepPDT/ParticleDataTable.hh" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleFillerTool::TruthParticleFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent), + m_ppsvc ("PartPropSvc", name) +{ + declareProperty ("PDGIDVariable", m_PDGIDVariable = "pdgId"); + declareProperty ("PartPropSvc", m_ppsvc, + "Particle property service."); + + book().ignore(); // Avoid coverity warnings. +} + + +/** + * @brief Standard Gaudi initialize method. + */ +StatusCode TruthParticleFillerTool::initialize() +{ + CHECK( m_ppsvc.retrieve() ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Book variables for this block. + */ +StatusCode TruthParticleFillerTool::book() +{ + CHECK( addVariable("status", m_status) ); + CHECK( addVariable("barcode", m_barcode) ); + CHECK( addVariable(m_PDGIDVariable, m_pdgId) ); + CHECK( addVariable("charge", m_charge) ); + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode TruthParticleFillerTool::fill (const TruthParticle& p) +{ + *m_status = p.status(); + *m_barcode = p.barcode(); + *m_pdgId = p.pdgId(); + *m_charge = p.charge(); + return StatusCode::SUCCESS; +} + + +/** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ +StatusCode TruthParticleFillerTool::fill (const xAOD::TruthParticle& p) +{ + *m_status = p.status(); + *m_barcode = p.barcode(); + *m_pdgId = p.pdgId(); + + const HepPDT::ParticleDataTable* pdt = m_ppsvc->PDT(); + const HepPDT::ParticleData* pd = pdt->particle (std::abs(p.pdgId())); + *m_charge = pd ? pd->charge() : 0; + if (p.pdgId() < 0) + *m_charge = - *m_charge; + + return StatusCode::SUCCESS; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.h new file mode 100644 index 00000000000..e30ea36db2e --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleFillerTool.h @@ -0,0 +1,99 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file TruthD3PDMaker/src/TruthParticleFillerTool.h + * @author Ryan Reece <ryan.reece@cern.ch> + * @date Dec, 2009 + * @brief Block filler tool for TruthParticle's. + */ + +#ifndef TRUTHD3PDMAKER_TRUTHPARTICLEFILLERTOOL_H +#define TRUTHD3PDMAKER_TRUTHPARTICLEFILLERTOOL_H + + +#include "D3PDMakerUtils/BlockFillerTool.h" +#include "xAODTruth/TruthParticle.h" +#include "GaudiKernel/ServiceHandle.h" +class TruthParticle; +class IPartPropSvc; + + +namespace D3PD { + +class TruthParticleFillerTool + : public BlockFillerTool<Types<TruthParticle, xAOD::TruthParticle> > +{ +public: + typedef BlockFillerTool<Types<TruthParticle, xAOD::TruthParticle> > Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleFillerTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Standard Gaudi initialize method. + virtual StatusCode initialize() override; + + + /// Book variables for this block. + virtual StatusCode book() override; + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const TruthParticle& p) override; + + + /** + * @brief Fill one block --- type-safe version. + * @param p The input object. + * + * This is called once per object. The caller + * is responsible for arranging that all the pointers for booked variables + * are set appropriately upon entry. + */ + virtual StatusCode fill (const xAOD::TruthParticle& p) override; + + +private: + /// Property: Name for pdgId variable. + std::string m_PDGIDVariable; + + /// Property: Particle property service. + ServiceHandle<IPartPropSvc> m_ppsvc; + + /// Variable: Status code for the particle. + int* m_status; + + /// Variable: Barcode for the particle. + int* m_barcode; + + /// Variable: Particle ID code. + int* m_pdgId; + + /// Variable: Particle charge. + float* m_charge; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_TRUTHPARTICLEFILLERTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.cxx new file mode 100644 index 00000000000..843e7f949f6 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.cxx @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/TruthParticleGenParticleAssociationTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Dec, 2010 + * @brief Associate from a TruthParticle to a corresponding GenParticle. + */ + + +#include "TruthParticleGenParticleAssociationTool.h" +#include "McParticleEvent/TruthParticle.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleGenParticleAssociationTool::TruthParticleGenParticleAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent) +{ +} + + +/** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ +const HepMC::GenParticle* +TruthParticleGenParticleAssociationTool::get (const TruthParticle& p) +{ + return p.genParticle(); +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.h new file mode 100644 index 00000000000..627082cede8 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleGenParticleAssociationTool.h @@ -0,0 +1,65 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/TruthParticleGenParticleAssociationTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Dec, 2010 + * @brief Associate from a TruthParticle to the corresponding GenParticle. + */ + + +#ifndef TRUTHD3PDMAKER_TRUTHPARTICLEGENPARTICLEASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_TRUTHPARTICLEGENPARTICLEASSOCIATIONTOOL_H + + +#include "D3PDMakerUtils/SingleAssociationTool.h" +class TruthParticle; +namespace HepMC +{ + class GenParticle; +} // namespace HepMC + + +namespace D3PD { + + +/** + * @brief Associate from a TruthParticle to the corresponding GenParticle. + */ +class TruthParticleGenParticleAssociationTool + : public SingleAssociationTool<TruthParticle, HepMC::GenParticle> +{ +public: + typedef SingleAssociationTool<TruthParticle, HepMC::GenParticle> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleGenParticleAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const HepMC::GenParticle* get (const TruthParticle& p); +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_TRUTHPARTICLEGENPARTICLEASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.cxx new file mode 100644 index 00000000000..664abb87bbc --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.cxx @@ -0,0 +1,82 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthParticleParentAssociationTool.cxx + * @author Ryan Reece <ryan.reece@cern.ch> + * @date Mar 2010 + * @brief Associate all the parents of a TruthParticle. + */ + + +#include "TruthParticleParentAssociationTool.h" +#include "barcodeOrder.h" +#include "xAODTruth/TruthVertex.h" +#include "AthenaKernel/errorcheck.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleParentAssociationTool::TruthParticleParentAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent), + m_i (0) +{} + + +/** + * @brief Standard Gaudi initialize method. + */ +StatusCode TruthParticleParentAssociationTool::initialize() +{ + return Base::initialize(); +} + + +/** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ +StatusCode +TruthParticleParentAssociationTool::reset (const xAOD::TruthParticle& p) +{ + const xAOD::TruthVertex* vx = p.prodVtx(); + if (!vx) + m_parents.clear(); + else { + size_t sz = vx->nIncomingParticles(); + m_parents.resize (sz); + for (unsigned int i = 0; i < sz; i++) + m_parents[i] = vx->incomingParticle(i); + std::sort (m_parents.begin(), m_parents.end(), barcodeOrder()); + m_i = 0; + } + return StatusCode::SUCCESS; +} + + +/** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ +const xAOD::TruthParticle* TruthParticleParentAssociationTool::next() +{ + if (m_i < m_parents.size()) + return m_parents[m_i++]; + return 0; +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.h new file mode 100644 index 00000000000..befda51e5c7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleParentAssociationTool.h @@ -0,0 +1,84 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthParticleParentAssociationTool.h + * @author Ryan Reece <ryan.reece@cern.ch> + * @date Mar, 2010 + * @brief Associate parents of TruthParticles. + */ + + +#ifndef TRUTHD3PDMAKER_DRCONEASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_DRCONEASSOCIATIONTOOl_H + + +#include "D3PDMakerUtils/MultiAssociationTool.h" +#include "xAODTruth/TruthParticle.h" +#include <vector> + + +namespace D3PD { + + +/** + * @brief Associate all particles within a DR cut. + * + * This is a multiple association tool. + * Given an @c TruthParticle object return all of its parents. + * + */ +class TruthParticleParentAssociationTool + : public MultiAssociationTool<xAOD::TruthParticle> +{ +public: + typedef MultiAssociationTool<xAOD::TruthParticle> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleParentAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /// Standard Gaudi initialize method. + virtual StatusCode initialize(); + + + /** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ + virtual StatusCode reset (const xAOD::TruthParticle& p); + + + /** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ + virtual const xAOD::TruthParticle* next(); + + +private: + /// Vector of parent pointers. + std::vector<const xAOD::TruthParticle*> m_parents; + + /// Current index. + unsigned int m_i; +}; + + +} // namespace D3PD + + +#endif // not TRUTHD3PDMAKER_DRCONEASSOCIATIONTOOl_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.cxx new file mode 100644 index 00000000000..f4045114eb7 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.cxx @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Apr, 2010 + * @brief Associate from a TruthParticle to its GenVertex production vertex. + */ + + +#include "TruthParticleProdVertexAssociationTool.h" + + +namespace D3PD { + + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthParticleProdVertexAssociationTool::TruthParticleProdVertexAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent) +{ +} + + +/** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ +const xAOD::TruthVertex* +TruthParticleProdVertexAssociationTool::get (const xAOD::TruthParticle& p) +{ + return p.prodVtx(); +} + + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.h new file mode 100644 index 00000000000..ca52b197bb8 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.h @@ -0,0 +1,63 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/TruthParticleProdVertexAssociationTool.h + * @author scott snyder <snyder@bnl.gov> + * @date Apr, 2010 + * @brief Associate from a TruthParticle to its vertex. + */ + + +#ifndef TRUTHD3PDMAKER_TRUTHPARTICLEPRODVERTEXASSOCIATIONTOOL_H +#define TRUTHD3PDMAKER_TRUTHPARTICLEPRODVERTEXASSOCIATIONTOOL_H + + +#include "D3PDMakerUtils/SingleAssociationTool.h" +#include "xAODTruth/TruthParticle.h" +#include "xAODTruth/TruthVertex.h" + + +namespace D3PD { + + +/** + * @brief Associate from a TruthParticle to its GenVertex production vertex. + */ +class TruthParticleProdVertexAssociationTool + : public SingleAssociationTool<xAOD::TruthParticle, xAOD::TruthVertex> +{ +public: + typedef SingleAssociationTool<xAOD::TruthParticle, xAOD::TruthVertex> Base; + + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthParticleProdVertexAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + + /** + * @brief Return the target object. + * @param p The source object for the association. + * + * Return the target of the association, or 0. + */ + virtual const xAOD::TruthVertex* get (const xAOD::TruthParticle& p); +}; + + +} // namespace D3PD + + + +#endif // not TRUTHD3PDMAKER_TRUTHPARTICLEPRODVERTEXASSOCIATIONTOOL_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx new file mode 100644 index 00000000000..f09fc72ba31 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx @@ -0,0 +1,120 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: +/** + * @file TruthD3PDMaker/src/TruthTauDecayAssociationTool.cxx + * @author Zach Marshall <zach.marshall@cern.ch> + * @date June, 2013 + * @brief Associate from a true hadronic tau to its decay products. + */ + +#include "TruthTauDecayAssociationTool.h" +#include "HepMC/GenParticle.h" +#include "HepMC/GenVertex.h" +#include "AthenaKernel/errorcheck.h" +#include "barcodeOrder.h" +#include "McParticleEvent/TruthParticle.h" +#include "McParticleEvent/TruthParticleContainer.h" +#include "GeneratorObjects/McEventCollection.h" +#include "boost/foreach.hpp" + +namespace D3PD { + +/** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ +TruthTauDecayAssociationTool::TruthTauDecayAssociationTool + (const std::string& type, + const std::string& name, + const IInterface* parent) + : Base (type, name, parent) + , m_i (0) +{} + +/** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ +StatusCode +TruthTauDecayAssociationTool::reset (const TruthParticle& p) +{ + m_i = 0; + m_tau_prods.clear(); + m_tau_prod_barcodes.clear(); + + // Only receive the last tau in the chain through the filter + // Just add the daughters in... but have to find it in the full record first + const DataHandle<McEventCollection> mcec; + if (evtStore()->retrieve<McEventCollection>(mcec,"GEN_EVENT").isSuccess()){ + // Loop over GenEvent's. + BOOST_FOREACH (const HepMC::GenEvent* ev_in, *mcec) { + if (!ev_in) continue; + for (HepMC::GenEvent::particle_const_iterator itrPart = ev_in->particles_begin(); + itrPart!=ev_in->particles_end();++itrPart){ + if ( (*itrPart) && (*itrPart)->barcode()==p.barcode() ){ + // Found it! + addStableDaughters( (*itrPart) ); + break; + } + } // Loop over particles + } // Loop over events + } // Successful retrieve + + const DataHandle<TruthParticleContainer> tpc; + if (evtStore()->retrieve<TruthParticleContainer>(tpc,"D3PDTruth").isSuccess()){ + for (unsigned int i=0;i<tpc->size();++i){ + if (! (*tpc)[i] ) continue; + for (unsigned int j=0;j<m_tau_prod_barcodes.size();++j){ + if ( (*tpc)[i]->barcode() == m_tau_prod_barcodes[j] ){ + m_tau_prods.push_back( (*tpc)[i] ); + break; + } // End matching barcode + } // End loop over barcodes + } // End loop over particles + } // End successful retrieve + + return StatusCode::SUCCESS; +} + +void TruthTauDecayAssociationTool::addStableDaughters(const HepMC::GenParticle* part) { + // Sanity check + if (!part) return; + + HepMC::GenVertex* endvx = part->end_vertex(); + if(!endvx){ // no children + if ( part && part->status()==1 ) m_tau_prod_barcodes.push_back( part->barcode() ); + return; + } + + // Loop over the parents of this particle. + HepMC::GenVertex::particle_iterator itrChild = endvx->particles_begin(HepMC::children); + HepMC::GenVertex::particle_iterator endChild = endvx->particles_end(HepMC::children); + for(;itrChild!=endChild; ++itrChild){ + if ( (*itrChild) && (*itrChild)->status()==1 ){ + // Found a stable child! + m_tau_prod_barcodes.push_back( (*itrChild)->barcode() ); + } else if ( (*itrChild) ){ + addStableDaughters( (*itrChild) ); + } + } // End loop over children + +} + +/** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ +const TruthParticle* TruthTauDecayAssociationTool::next() +{ + if (m_i < m_tau_prods.size()) + return m_tau_prods[m_i++]; + return 0; +} + +} // namespace D3PD diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h new file mode 100644 index 00000000000..4974d9db7c2 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/TruthTauDecayAssociationTool.h @@ -0,0 +1,82 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: +/** + * @file TruthD3PDMaker/src/TruthTauDecayAssociationTool.h + * @author Zach Marshall <zach.marshall@cern.ch> + * @date June, 2013 + * @brief Associate from a tau to its hadronic decay products. + */ + +#ifndef EVENTCOMMOND3PDMAKER_TRUTHTAUDECAYASSOCIATIONTOOL_H +#define EVENTCOMMOND3PDMAKER_TRUTHTAUDECAYASSOCIATIONTOOL_H + +#include "D3PDMakerUtils/MultiAssociationTool.h" + +class TruthParticle; +namespace HepMC { + class GenParticle; +} +namespace D3PD { + +/** + * @brief Associate from a true hadronic tau to its decay products + * + * This is a multiple association tool. + */ +class TruthTauDecayAssociationTool + : public MultiAssociationTool<TruthParticle> +{ +public: + typedef MultiAssociationTool<TruthParticle> Base; + + /** + * @brief Standard Gaudi tool constructor. + * @param type The name of the tool type. + * @param name The tool name. + * @param parent The tool's Gaudi parent. + */ + TruthTauDecayAssociationTool (const std::string& type, + const std::string& name, + const IInterface* parent); + + /** + * @brief Start the iteration for a new association. + * @param p The object from which to associate. + */ + virtual StatusCode reset (const TruthParticle& p); + + /** + * @brief Return a pointer to the next element in the association. + * + * Return 0 when the association has been exhausted. + */ + virtual const TruthParticle* next(); + +private: + + /// Function for association to a specific tau + void addStableDaughters(const HepMC::GenParticle*); + + /// TruthParticle iterator + std::vector<const TruthParticle*> m_tau_prods; + + /// Current index + unsigned int m_i; + + /// Name of the container + std::string m_truth_container_name; + + /// TruthParticle barcodes + std::vector<int> m_tau_prod_barcodes; + +}; + +} // namespace D3PD + +#endif // not EVENTCOMMOND3PDMAKER_TRUTHTAUDECAYASSOCIATIONTOOL_H + diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/barcodeOrder.h b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/barcodeOrder.h new file mode 100644 index 00000000000..589913cc548 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/barcodeOrder.h @@ -0,0 +1,42 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/barcodeOrder.h + * @author scott snyder <snyder@bnl.gov> + * @date Apr, 2010 + * @brief Helper to sort TruthParticles by barcode. + */ + + +#ifndef TRUTHD3PDMAKER_BARCODEORDER_H +#define TRUTHD3PDMAKER_BARCODEORDER_H + + +#include "McParticleEvent/TruthParticle.h" +#include "xAODTruth/TruthParticle.h" + + +namespace D3PD { + + +/** + * @brief Helper to sort TruthParticles by barcode. + */ +struct barcodeOrder +{ + bool operator() (const TruthParticle* p1, const TruthParticle* p2) + { return p1->barcode() < p2->barcode(); } + bool operator() (const xAOD::TruthParticle* p1, const xAOD::TruthParticle* p2) + { return p1->barcode() < p2->barcode(); } +}; + + +} + + +#endif // not TRUTHD3PDMAKER_BARCODEORDER_H diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_entries.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_entries.cxx new file mode 100644 index 00000000000..24a7510087c --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_entries.cxx @@ -0,0 +1,135 @@ +// $Id$ +/** + * @file TruthD3PDMaker/src/components/TruthD3PDMaker_entries.cxx + * @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> + * @date Apr, 2010 + * @brief List Gaudi components. + */ + +// Gaudi/Athena include(s): +#include "GaudiKernel/DeclareFactoryEntries.h" + +// +// Local include(s): +// +// Getter tool(s): +#include "../GenEventGetterTool.h" +#include "../GenParticleGetterTool.h" +#include "../GenVertexGetterTool.h" +// Associator tool(s): +#include "../GenEventGenParticleAssociationTool.h" +#include "../GenParticleEventAssociationTool.h" +#include "../GenParticleParticleAssociationTool.h" +#include "../GenParticleTruthParticleAssociationTool.h" +#include "../GenParticleVertexAssociationTool.h" +#include "../GenVertexParticleAssociationTool.h" +#include "../GenVertexEventAssociationTool.h" +#include "../TruthParticleEtIsolationAssociationTool.h" +#include "../TruthParticleChildAssociationTool.h" +#include "../TruthParticleParentAssociationTool.h" +#include "../TruthParticleGenParticleAssociationTool.h" +#include "../TruthParticleProdVertexAssociationTool.h" +#include "../PileUpInfoAssociatorTool.h" +#include "../TruthTauDecayAssociationTool.h" +#include "../TruthLeptonParentAssociationTool.h" +#include "../TruthLeptonNearbyAssociationTool.h" +// Filler tool(s): +#include "../GenEventFillerTool.h" +#include "../GenEventPileUpFillerTool.h" +#include "../TruthParticleBremFillerTool.h" +#include "../GenParticleFillerTool.h" +#include "../GenParticlePerigeeFillerTool.h" +#include "../GenVertexFillerTool.h" +#include "../TruthEtIsolationFillerTool.h" +#include "../TruthParticleFillerTool.h" +#include "../TruthParticleBarcodesFillerTool.h" +#include "../PileUpInfoFillerTool.h" +#include "../TruthParticleFakerTool.h" +#include "../HforFillerTool.h" +#include "../JetFullTruthTag.h" +#include "../TruthParticleClassificationFillerTool.h" +// Filter tool(s): +#include "../GenEventGetterFilterTool.h" +#include "../TruthJetFilterTool.h" + +// Getter tool(s): +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenEventGetterTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenParticleGetterTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenVertexGetterTool) +// Associator tool(s): +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenEventGenParticleAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenParticleEventAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenParticleParticleAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenParticleTruthParticleAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenParticleVertexAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenVertexParticleAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenVertexEventAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleEtIsolationAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleChildAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleParentAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleGenParticleAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleProdVertexAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, PileUpInfoAssociatorTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthTauDecayAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthLeptonParentAssociationTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthLeptonNearbyAssociationTool) +// Filler tool(s): +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenEventFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenEventPileUpFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleBremFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenParticleFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenParticlePerigeeFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenVertexFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthEtIsolationFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleBarcodesFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, PileUpInfoFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleFakerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, JetFullTruthTag) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, HforFillerTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthParticleClassificationFillerTool) +// Filter tool(s): +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, GenEventGetterFilterTool) +DECLARE_NAMESPACE_TOOL_FACTORY (D3PD, TruthJetFilterTool) + +DECLARE_FACTORY_ENTRIES(TruthD3PDMaker) { + // Getter tool(s): + DECLARE_NAMESPACE_TOOL (D3PD, GenEventGetterTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenParticleGetterTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenVertexGetterTool) + // Associator tool(s): + DECLARE_NAMESPACE_TOOL (D3PD, GenEventGenParticleAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenParticleEventAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenParticleParticleAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenParticleTruthParticleAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenParticleVertexAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenVertexParticleAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenVertexEventAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleEtIsolationAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleChildAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleParentAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleGenParticleAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleProdVertexAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, PileUpInfoAssociatorToor) + DECLARE_NAMESPACE_TOOL (D3PD, TruthTauDecayAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthLeptonParentAssociationTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthLeptonNearbyAssociationTool) + // Filler tool(s): + DECLARE_NAMESPACE_TOOL (D3PD, GenEventFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenEventPileUpFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleBremFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenParticleFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenParticlePerigeeFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, GenVertexFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthEtIsolationFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleBarcodesFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, PileUpInfoFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleFakerTool) + DECLARE_NAMESPACE_TOOL (D3PD, JetFullTruthTag) + DECLARE_NAMESPACE_TOOL (D3PD, HforFillerTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthParticleClassificationFillerTool) + // Filter tool(s): + DECLARE_NAMESPACE_TOOL (D3PD, GenEventGetterFilterTool) + DECLARE_NAMESPACE_TOOL (D3PD, TruthJetFilterTool) +} diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_load.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_load.cxx new file mode 100644 index 00000000000..ee5be768da3 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/components/TruthD3PDMaker_load.cxx @@ -0,0 +1,12 @@ +// $Id$ +/** + * @file TruthD3PDMaker/src/components/TruthD3PDMaker_load.cxx + * @author Renaud Bruneliere <Renaud.Bruneliere@cern.ch> + * @date Apr, 2010 + * @brief Gaudi boilerplate. + */ + + +#include "GaudiKernel/LoadFactoryEntries.h" + +LOAD_FACTORY_ENTRIES(TruthD3PDMaker) diff --git a/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/hepMCInheritance.cxx b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/hepMCInheritance.cxx new file mode 100644 index 00000000000..023c6a10269 --- /dev/null +++ b/PhysicsAnalysis/D3PDMaker/TruthD3PDMaker/src/hepMCInheritance.cxx @@ -0,0 +1,24 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id$ +/** + * @file TruthD3PDMaker/src/hepMCInheritance.cxx + * @author scott snyder <snyder@bnl.gov> + * @date Nov, 2009 + * @brief Declare inheritance relationships for HepMC classes. + * + * Eventually, these should be moved to the EDM classes. + */ + +#include "McParticleEvent/TruthEtIsolationsContainer.h" +#include "McParticleEvent/TruthParticle.h" +#include "GeneratorObjects/McEventCollection.h" +#include "Navigation/IAthenaBarCode.h" +#include "HepMC/GenEvent.h" +#include "SGTools/BaseInfo.h" + +SG_ADD_BASE (McEventCollection, DataVector<HepMC::GenEvent>); +SG_ADD_BASE (TruthEtIsolationsContainer, DataVector<TruthEtIsolations>); +SG_ADD_BASE (TruthParticle, SG_VIRTUAL(IAthenaBarCode)); -- GitLab