ATLAS Offline Software
TruthCategoriesDecorator.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Tool to decorate the EventInfo object with truth categories informations
6 // Authors: T. Guillemin, J. Lacey, D. Gillberg
7 
8 #ifndef DerivationFrameworkHiggs_TruthCategoriesDecorator_H
9 #define DerivationFrameworkHiggs_TruthCategoriesDecorator_H
10 
12 #include "GaudiKernel/ToolHandle.h"
15 
16 // EDM: typedefs, so must be included and not forward-referenced
19 
20 // Note: must include TLorentzVector before the next one
21 
25 
26 namespace DerivationFramework {
27 
29  public:
30  TruthCategoriesDecorator(const std::string& n, ISvcLocator* p);
31  virtual ~TruthCategoriesDecorator() = default;
33  StatusCode execute(const EventContext& ctx) const;
34 
35  private:
36  ToolHandle<IxAODtoHepMCTool> m_xAODtoHepMCTool{this, "HepMCTool", "xAODtoHepMCTool"};
37  ToolHandle<IHiggsTruthCategoryTool> m_higgsTruthCatTool{this, "CategoryTool", "HiggsTruthCategoryTool"};
38 
39  // Path to TEnv file containing MC-channel-number <-> HiggsProdMode map
40  Gaudi::Property<std::string> m_configPath{this, "ConfigPath", "DerivationFrameworkHiggs/HiggsMCsamples.cfg"};
41  struct HTXSSample {
46  // DSIDs satisfying this production mode
47  std::set<int> dsids{};
48  };
49 
50  std::vector<HTXSSample> m_htxs_samples{};
51 
52  // Detail level. Steers amount of decoration.
53  // 0: basic information. Categoization ints, Higgs prod mode, Njets, Higgs pT
54  // 1: the above + Higgs boson 4-vec + associated V 4-vec
55  // 2: the above + truth jets built excluding the Higgs boson decay
56  // 3: the above + 4-vector sum of all decay products from Higgs boson and V-boson
57  Gaudi::Property<int> m_detailLevel{this, "DetailLevel", 3};
58 
59  // Methods for decoration of four vectors
60  StatusCode decorateFourVec(const EventContext& ctx, const std::string& prefix, const TLorentzVector& p4) const;
61  StatusCode decorateFourVecs(const EventContext& ctx, const std::string& prefix, const std::vector<TLorentzVector>& p4s) const;
62 
63  SG::ReadHandleKey<xAOD::TruthEventContainer> m_truthEvtKey{this, "TruthEvtKey", "TruthEvents"};
64  SG::ReadHandleKey<xAOD::EventInfo> m_evtInfoKey{this, "EvtKey", "EventInfo"};
65 
67  SG::WriteDecorHandleKeyArray<xAOD::EventInfo> m_STXSDecors{this, "ToolDecorations", {}, "List of all keys decorated by the alg"};
68 
71  FourMomDecoration(const SG::ReadHandleKey<xAOD::EventInfo>& ev_key, const std::string& prefix) :
72  pt{ev_key.key() + "." + prefix + "_pt"},
73  eta{ev_key.key() + "." + prefix + "_eta"},
74  phi{ev_key.key() + "." + prefix + "_phi"},
75  m{ev_key.key() + "." + prefix + "_m"} {}
80  std::vector<EvtInfoDecorKey> vect() const { return {pt, eta, phi, m}; }
82  if (!pt.initialize().isSuccess() || !eta.initialize().isSuccess() || !phi.initialize().isSuccess() || !m.initialize().isSuccess()){
83  return StatusCode::FAILURE;
84  }
85  return StatusCode::SUCCESS;
86  }
87  };
88  using P4DecorMap = std::map<std::string, FourMomDecoration>;
90  };
91 
92 } // namespace DerivationFramework
93 
94 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
DerivationFramework::TruthCategoriesDecorator::m_detailLevel
Gaudi::Property< int > m_detailLevel
Definition: TruthCategoriesDecorator.h:57
python.StoreID.UNKNOWN
int UNKNOWN
Definition: StoreID.py:16
SG::WriteDecorHandleKey< xAOD::EventInfo >
DerivationFramework::TruthCategoriesDecorator::m_STXSDecors
SG::WriteDecorHandleKeyArray< xAOD::EventInfo > m_STXSDecors
Definition: TruthCategoriesDecorator.h:67
DerivationFramework::TruthCategoriesDecorator::m_truthEvtKey
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEvtKey
Definition: TruthCategoriesDecorator.h:63
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration::phi
EvtInfoDecorKey phi
Definition: TruthCategoriesDecorator.h:78
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration::pt
EvtInfoDecorKey pt
Definition: TruthCategoriesDecorator.h:76
IxAODtoHepMCTool.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
HiggsTemplateCrossSectionsDefs.h
DerivationFramework::TruthCategoriesDecorator::P4DecorMap
std::map< std::string, FourMomDecoration > P4DecorMap
Definition: TruthCategoriesDecorator.h:88
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration::m
EvtInfoDecorKey m
Definition: TruthCategoriesDecorator.h:79
DerivationFramework::TruthCategoriesDecorator::HTXSSample::dsids
std::set< int > dsids
Definition: TruthCategoriesDecorator.h:47
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
DerivationFramework::TruthCategoriesDecorator::m_configPath
Gaudi::Property< std::string > m_configPath
Definition: TruthCategoriesDecorator.h:40
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
DerivationFramework::TruthCategoriesDecorator::execute
StatusCode execute(const EventContext &ctx) const
Definition: TruthCategoriesDecorator.cxx:175
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
DerivationFramework::TruthCategoriesDecorator
Definition: TruthCategoriesDecorator.h:28
DerivationFramework::TruthCategoriesDecorator::TruthCategoriesDecorator
TruthCategoriesDecorator(const std::string &n, ISvcLocator *p)
Definition: TruthCategoriesDecorator.cxx:22
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration::vect
std::vector< EvtInfoDecorKey > vect() const
Definition: TruthCategoriesDecorator.h:80
DerivationFramework::TruthCategoriesDecorator::~TruthCategoriesDecorator
virtual ~TruthCategoriesDecorator()=default
DerivationFramework::TruthCategoriesDecorator::m_evtInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
Definition: TruthCategoriesDecorator.h:64
DerivationFramework::TruthCategoriesDecorator::HTXSSample::prod
HTXS::HiggsProdMode prod
Higgs production modes, corresponding to input sample.
Definition: TruthCategoriesDecorator.h:43
DerivationFramework::TruthCategoriesDecorator::m_htxs_samples
std::vector< HTXSSample > m_htxs_samples
Definition: TruthCategoriesDecorator.h:50
beamspotman.n
n
Definition: beamspotman.py:731
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration::FourMomDecoration
FourMomDecoration(const SG::ReadHandleKey< xAOD::EventInfo > &ev_key, const std::string &prefix)
Definition: TruthCategoriesDecorator.h:71
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework::TruthCategoriesDecorator::initialize
StatusCode initialize()
Definition: TruthCategoriesDecorator.cxx:24
DerivationFramework::TruthCategoriesDecorator::m_p4_decors
P4DecorMap m_p4_decors
Definition: TruthCategoriesDecorator.h:89
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
DerivationFramework::TruthCategoriesDecorator::HTXSSample
Definition: TruthCategoriesDecorator.h:41
HTXS::noTH
@ noTH
Definition: HiggsTemplateCrossSectionsDefs.h:34
DerivationFramework
THE reconstruction tool.
Definition: ParticleSortingAlg.h:24
AthReentrantAlgorithm.h
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration::initialize
StatusCode initialize()
Definition: TruthCategoriesDecorator.h:81
HTXS::HiggsProdMode
HiggsProdMode
Higgs production modes, corresponding to input sample.
Definition: HiggsTemplateCrossSectionsDefs.h:27
DerivationFramework::TruthCategoriesDecorator::m_higgsTruthCatTool
ToolHandle< IHiggsTruthCategoryTool > m_higgsTruthCatTool
Definition: TruthCategoriesDecorator.h:37
DerivationFramework::TruthCategoriesDecorator::m_xAODtoHepMCTool
ToolHandle< IxAODtoHepMCTool > m_xAODtoHepMCTool
Definition: TruthCategoriesDecorator.h:36
EventInfo.h
DerivationFramework::TruthCategoriesDecorator::HTXSSample::th_type
HTXS::tH_type th_type
Additional identifier flag for TH production modes.
Definition: TruthCategoriesDecorator.h:45
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration
Set of DecorHandleKeys to write the four momenta needed for the HTXS categorization.
Definition: TruthCategoriesDecorator.h:70
DerivationFramework::TruthCategoriesDecorator::decorateFourVec
StatusCode decorateFourVec(const EventContext &ctx, const std::string &prefix, const TLorentzVector &p4) const
Definition: TruthCategoriesDecorator.cxx:125
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
HTXS::tH_type
tH_type
Additional identifier flag for TH production modes.
Definition: HiggsTemplateCrossSectionsDefs.h:34
WriteDecorHandleKeyArray.h
IHiggsTruthCategoryTool.h
TruthEventContainer.h
DerivationFramework::TruthCategoriesDecorator::FourMomDecoration::eta
EvtInfoDecorKey eta
Definition: TruthCategoriesDecorator.h:77
DerivationFramework::TruthCategoriesDecorator::decorateFourVecs
StatusCode decorateFourVecs(const EventContext &ctx, const std::string &prefix, const std::vector< TLorentzVector > &p4s) const
Definition: TruthCategoriesDecorator.cxx:147