ATLAS Offline Software
CalcThqPartonHistory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3  */
4 
9 
10 namespace top {
13 
15 
16  for (const xAOD::TruthParticle* particle : *truthParticles) {
17  if (particle->pdgId() != 25 || particle->nChildren() != 2) {
18  continue;
19  }
20  tH.Higgs_p4 = particle->p4();
21 
23 
24  tH.decay1_p4 = higgs.decay1_vector;
25  tH.decay2_p4 = higgs.decay2_vector;
42 
43  return true;
44  }
45  return false;
46  }
47 
49  xAOD::PartonHistory* ThqPartonHistory) {
50  ThqPartonHistory->IniVarThq();
51  TLorentzVector t_before, t_after, t_after_SC;
52  TLorentzVector Wp;
53  TLorentzVector b;
54  TLorentzVector WpDecay1;
55  TLorentzVector WpDecay2;
56  int WpDecay1_pdgId{};
57  int WpDecay2_pdgId{};
58 
59  const bool event_top = CalcTopPartonHistory::topWb(truthParticles, 6, t_before, t_after,
60  Wp, b, WpDecay1, WpDecay1_pdgId,
61  WpDecay2, WpDecay2_pdgId);
62  const bool event_top_SC = CalcTopPartonHistory::topAfterFSR_SC(truthParticles, 6, t_after_SC);
63  const bool event_topbar = CalcTopPartonHistory::topWb(truthParticles, -6, t_before, t_after,
64  Wp, b, WpDecay1,
65  WpDecay1_pdgId, WpDecay2, WpDecay2_pdgId);
66  const bool event_topbar_SC = CalcTopPartonHistory::topAfterFSR_SC(truthParticles, -6, t_after_SC);
67  const bool event_Higgs = CalcThqPartonHistory::HiggsAndDecay(truthParticles);
68 
69  if (event_Higgs) {
70  if (event_top || event_topbar) {
71 
72  decorateWithMPtPhi(ThqPartonHistory,"MC_t_beforeFSR", t_before);
73  fillEtaBranch(ThqPartonHistory, "MC_t_beforeFSR_eta", t_before);
74 
75  decorateWithMPtPhi(ThqPartonHistory,"MC_t_afterFSR", t_after);
76  fillEtaBranch(ThqPartonHistory, "MC_t_afterFSR_eta", t_after);
77 
78  if (event_top_SC || event_topbar_SC) {
79  decorateWithMPtPhi(ThqPartonHistory,"MC_t_afterFSR_SC", t_after_SC);
80  fillEtaBranch(ThqPartonHistory, "MC_t_afterFSR_SC_eta", t_after_SC);
81  }
82 
83  decorateWithMPtPhi(ThqPartonHistory,"MC_W_from_t", Wp);
84  fillEtaBranch(ThqPartonHistory, "MC_W_from_t_eta", Wp);
85 
86  decorateWithMPtPhi(ThqPartonHistory,"MC_b_from_t", b);
87  fillEtaBranch(ThqPartonHistory, "MC_b_from_t_eta", b);
88 
89  decorateWithMPtPhi(ThqPartonHistory,"MC_Wdecay1_from_t", WpDecay1);
90  ThqPartonHistory->auxdecor< int >("MC_Wdecay1_from_t_pdgId") = WpDecay1_pdgId;
91  fillEtaBranch(ThqPartonHistory, "MC_Wdecay1_from_t_eta", WpDecay1);
92 
93  decorateWithMPtPhi(ThqPartonHistory,"MC_Wdecay2_from_t", WpDecay2);
94  ThqPartonHistory->auxdecor< int >("MC_Wdecay2_from_t_pdgId") = WpDecay2_pdgId;
95  fillEtaBranch(ThqPartonHistory, "MC_Wdecay2_from_t_eta", WpDecay2);
96 
97  //Higgs-Variables
98  decorateWithMPtPhi(ThqPartonHistory,"MC_Higgs", tH.Higgs_p4);
99  fillEtaBranch(ThqPartonHistory, "MC_Higgs_eta", tH.Higgs_p4);
100 
101  //Higgs-decay1-Variables
102  decorateWithMPtPhi(ThqPartonHistory,"MC_Higgs_decay1", tH.decay1_p4);
103  ThqPartonHistory->auxdecor< int >("MC_Higgs_decay1_pdgId") = tH.decay1_pdgId;
104  ThqPartonHistory->auxdecor< int >("MC_Higgs_tau_decay1_isHadronic") = tH.tau_decay1_isHadronic;
105  fillEtaBranch(ThqPartonHistory, "MC_Higgs_decay1_eta", tH.decay1_p4);
106 
107  //Higgs-decay2-Variables
108  decorateWithMPtPhi(ThqPartonHistory,"MC_Higgs_decay2", tH.decay2_p4);
109  ThqPartonHistory->auxdecor< int >("MC_Higgs_decay2_pdgId") = tH.decay2_pdgId;
110  ThqPartonHistory->auxdecor< int >("MC_Higgs_tau_decay2_isHadronic") = tH.tau_decay2_isHadronic;
111  fillEtaBranch(ThqPartonHistory, "MC_Higgs_decay2_eta", tH.decay2_p4);
112 
113  //Higgs-decay1- from decay1-Variables
114  decorateWithMPtPhi(ThqPartonHistory,"MC_Higgs_decay1_from_decay1", tH.decay1_from_decay1_p4);
115  ThqPartonHistory->auxdecor< int >("MC_Higgs_decay1_from_decay1_pdgId") = tH.decay1_from_decay1_pdgId;
116  ThqPartonHistory->auxdecor< int >("MC_Higgs_tau_decay1_from_decay1_isHadronic") = tH.tau_decay1_from_decay1_isHadronic;
117  fillEtaBranch(ThqPartonHistory, "MC_Higgs_decay1_from_decay1_eta", tH.decay1_from_decay1_p4);
118 
119  //Higgs-decay2- from decay1-Variables
120  decorateWithMPtPhi(ThqPartonHistory,"MC_Higgs_decay2_from_decay1", tH.decay2_from_decay1_p4);
121  ThqPartonHistory->auxdecor< int >("MC_Higgs_decay2_from_decay1_pdgId") = tH.decay2_from_decay1_pdgId;
122  ThqPartonHistory->auxdecor< int >("MC_Higgs_tau_decay2_from_decay1_isHadronic") = tH.tau_decay2_from_decay1_isHadronic;
123  fillEtaBranch(ThqPartonHistory, "MC_Higgs_decay2_from_decay1_eta", tH.decay2_from_decay1_p4);
124 
125  //Higgs-decay1- from decay2-Variables
126  decorateWithMPtPhi(ThqPartonHistory,"MC_Higgs_decay1_from_decay2", tH.decay1_from_decay2_p4);
127  ThqPartonHistory->auxdecor< int >("MC_Higgs_decay1_from_decay2_pdgId") = tH.decay1_from_decay2_pdgId;
128  ThqPartonHistory->auxdecor< int >("MC_Higgs_tau_decay1_from_decay2_isHadronic") = tH.tau_decay1_from_decay2_isHadronic;
129  fillEtaBranch(ThqPartonHistory, "MC_Higgs_decay1_from_decay2_eta", tH.decay1_from_decay2_p4);
130 
131  //Higgs-decay2- from decay2-Variables
132  decorateWithMPtPhi(ThqPartonHistory,"MC_Higgs_decay2_from_decay2", tH.decay2_from_decay2_p4);
133  ThqPartonHistory->auxdecor< int >("MC_Higgs_decay2_from_decay2_pdgId") = tH.decay2_from_decay2_pdgId;
134  ThqPartonHistory->auxdecor< int >("MC_Higgs_tau_decay2_from_decay2_isHadronic") = tH.tau_decay2_from_decay2_isHadronic;
135  fillEtaBranch(ThqPartonHistory, "MC_Higgs_decay2_from_decay2_eta", tH.decay2_from_decay2_p4);
136 
137  }
138  }
139  }
140 
142  //Get the Truth Particles
143  const xAOD::TruthParticleContainer* truthParticles(nullptr);
144 
145  if(m_config->getDerivationStream() == "PHYS") //in DAOD_PHYS we don't have the truth particles container
146  {
147  // To obtain both tops and the H boson, we need the collections for both
148  std::vector<std::string> collections = {"TruthTop", "TruthBosonsWithDecayParticles", "HardScatterParticles"};
149  ATH_CHECK(buildContainerFromMultipleCollections(collections,"AT_THQPartonHistory_TruthParticles"));
150  ATH_CHECK(evtStore()->retrieve(truthParticles, "AT_THQPartonHistory_TruthParticles"));
151 
152  //we need to be able to navigate from the Ws to their decayProducts, see CalcTopPartonHistory.h for details
154  }
155  else //otherwise we retrieve the container as usual
156  {
157  ATH_CHECK(evtStore()->retrieve(truthParticles, m_config->sgKeyMCParticle()));
158  }
159 
160  // Create the partonHistory xAOD object
161  //cppcheck-suppress uninitvar
163  //cppcheck-suppress uninitvar
165  partonCont->setStore(partonAuxCont);
166  //cppcheck-suppress uninitvar
167  xAOD::PartonHistory* ThqPartonHistory = new xAOD::PartonHistory {};
168  partonCont->push_back(ThqPartonHistory);
169 
170  // Recover the parton history for TH events
171  THHistorySaver(truthParticles, ThqPartonHistory);
172 
173  // Save to StoreGate / TStore
174  std::string outputSGKey = m_config->sgKeyTopPartonHistory();
175  std::string outputSGKeyAux = outputSGKey + "Aux.";
176 
177  StatusCode save = evtStore()->tds()->record(partonCont, outputSGKey);
178  StatusCode saveAux = evtStore()->tds()->record(partonAuxCont, outputSGKeyAux);
179  if (!save || !saveAux) {
180  return StatusCode::FAILURE;
181  }
182 
183  return StatusCode::SUCCESS;
184  }
185 }
top::CalcThqPartonHistory::tH_values::decay2_from_decay1_pdgId
int decay2_from_decay1_pdgId
Definition: CalcThqPartonHistory.h:37
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
top::PartonHistoryUtils::HiggsDecay::tau_decay2_isHadronic
int tau_decay2_isHadronic
Definition: PartonHistoryUtils.h:27
top::PartonHistoryUtils::HiggsDecay::tau_decay1_isHadronic
int tau_decay1_isHadronic
Definition: PartonHistoryUtils.h:26
top::CalcThqPartonHistory::tH_values::decay2_from_decay2_pdgId
int decay2_from_decay2_pdgId
Definition: CalcThqPartonHistory.h:41
xAOD::PartonHistory
Interface class.
Definition: PartonHistory.h:48
top::CalcTopPartonHistory::buildContainerFromMultipleCollections
StatusCode buildContainerFromMultipleCollections(const std::vector< std::string > &collections, const std::string &out_contName)
used to build container from multiple collections in DAOD_PHYS we don't have the TruthParticles colle...
Definition: CalcTopPartonHistory.cxx:21
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
top::CalcTopPartonHistory::linkBosonCollections
StatusCode linkBosonCollections()
currently in DAOD_PHYS TruthTop have links to Ws from the TruthBoson collection, which have no link t...
Definition: CalcTopPartonHistory.cxx:39
top::CalcThqPartonHistory::tH
struct top::CalcThqPartonHistory::tH_values tH
top::PartonHistoryUtils::HiggsDecay::decay2_from_decay1_pdgId
int decay2_from_decay1_pdgId
Definition: PartonHistoryUtils.h:33
top::CalcThqPartonHistory::tH_values::tau_decay1_isHadronic
int tau_decay1_isHadronic
Definition: CalcThqPartonHistory.h:32
top::PartonHistoryUtils::HiggsDecay::decay1_from_decay1_vector
TLorentzVector decay1_from_decay1_vector
subsequent decays of W/Z
Definition: PartonHistoryUtils.h:30
top::CalcThqPartonHistory::tH_values::tau_decay2_isHadronic
int tau_decay2_isHadronic
Definition: CalcThqPartonHistory.h:33
top::CalcThqPartonHistory::tH_values::decay1_p4
TLorentzVector decay1_p4
Definition: CalcThqPartonHistory.h:28
top::PartonHistoryUtils::HiggsDecay::decay1_from_decay2_vector
TLorentzVector decay1_from_decay2_vector
Definition: PartonHistoryUtils.h:34
top::CalcThqPartonHistory::tH_values::decay1_from_decay2_p4
TLorentzVector decay1_from_decay2_p4
Definition: CalcThqPartonHistory.h:38
top::PartonHistoryUtils::HiggsDecay::decay2_from_decay2_pdgId
int decay2_from_decay2_pdgId
Definition: PartonHistoryUtils.h:37
top::CalcThqPartonHistory::tH_values::decay2_from_decay2_p4
TLorentzVector decay2_from_decay2_p4
Definition: CalcThqPartonHistory.h:39
top::PartonHistoryUtils::HiggsDecay::decay1_pdgId
int decay1_pdgId
Definition: PartonHistoryUtils.h:23
top::CalcThqPartonHistory::tH_values::tau_decay1_from_decay2_isHadronic
int tau_decay1_from_decay2_isHadronic
Definition: CalcThqPartonHistory.h:44
top::CalcThqPartonHistory::tH_values::decay2_pdgId
int decay2_pdgId
Definition: CalcThqPartonHistory.h:31
SG::AuxElement::auxdecor
Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name) const
Fetch an aux decoration, as a non-const reference.
top::CalcTopPartonHistory::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: CalcTopPartonHistory.h:87
top::CalcThqPartonHistory::HiggsAndDecay
bool HiggsAndDecay(const xAOD::TruthParticleContainer *truthParticles)
Store the four-momentum of several particles in the Higgs decay chain.
Definition: CalcThqPartonHistory.cxx:14
top::CalcThqPartonHistory::execute
virtual StatusCode execute()
Definition: CalcThqPartonHistory.cxx:141
xAOD::PartonHistory::IniVarThq
void IniVarThq()
Definition: PartonHistory.cxx:470
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
checkTP.save
def save(self, fileName="./columbo.out")
Definition: checkTP.py:178
top::CalcTopPartonHistory::b
bool b(const xAOD::TruthParticleContainer *truthParticles, TLorentzVector &b_beforeFSR, TLorentzVector &b_afterFSR)
Store the four-momentum of b (not from tops_ before and after FSR.
Definition: CalcTopPartonHistory.cxx:156
top::PartonHistoryUtils::HiggsDecay::decay2_from_decay2_vector
TLorentzVector decay2_from_decay2_vector
Definition: PartonHistoryUtils.h:36
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
top::CalcThqPartonHistory::tH_values::tau_decay1_from_decay1_isHadronic
int tau_decay1_from_decay1_isHadronic
Definition: CalcThqPartonHistory.h:42
PartonHistoryUtils.h
top::PartonHistoryUtils::HiggsDecay::tau_decay1_from_decay1_isHadronic
int tau_decay1_from_decay1_isHadronic
Definition: PartonHistoryUtils.h:38
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CalcThqPartonHistory.h
top::CalcTopPartonHistory::topAfterFSR_SC
bool topAfterFSR_SC(const xAOD::TruthParticleContainer *truthParticles, int start, TLorentzVector &top_afterFSR_SC_p4)
Store the four-momentum of the post-FSR top or anti-top found using statusCodes This would only work ...
Definition: CalcTopPartonHistory.cxx:83
top::PartonHistoryUtils::HiggsDecay::decay2_from_decay1_vector
TLorentzVector decay2_from_decay1_vector
Definition: PartonHistoryUtils.h:32
top::PartonHistoryUtils::HiggsDecay::decay1_from_decay1_pdgId
int decay1_from_decay1_pdgId
Definition: PartonHistoryUtils.h:31
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
top::PartonHistoryUtils::AnalyzeHiggsDecay
HiggsDecay AnalyzeHiggsDecay(const xAOD::TruthParticle *higgs)
Store higgs decay information.
Definition: PartonHistoryUtils.cxx:41
top::PartonHistoryUtils::HiggsDecay::tau_decay1_from_decay2_isHadronic
int tau_decay1_from_decay2_isHadronic
Definition: PartonHistoryUtils.h:40
top::CalcThqPartonHistory::tH_values::decay1_from_decay1_pdgId
int decay1_from_decay1_pdgId
Definition: CalcThqPartonHistory.h:36
top::PartonHistoryUtils::HiggsDecay::tau_decay2_from_decay2_isHadronic
int tau_decay2_from_decay2_isHadronic
Definition: PartonHistoryUtils.h:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
top::CalcThqPartonHistory::CalcThqPartonHistory
CalcThqPartonHistory(const std::string &name)
Definition: CalcThqPartonHistory.cxx:12
top::CalcThqPartonHistory::THHistorySaver
void THHistorySaver(const xAOD::TruthParticleContainer *truthParticles, xAOD::PartonHistory *ThqPartonHistory)
Definition: CalcThqPartonHistory.cxx:48
TopConfig.h
top::CalcThqPartonHistory::tH_values::tau_decay2_from_decay2_isHadronic
int tau_decay2_from_decay2_isHadronic
Definition: CalcThqPartonHistory.h:45
top::PartonHistoryUtils::HiggsDecay::decay2_vector
TLorentzVector decay2_vector
Definition: PartonHistoryUtils.h:24
top::PartonHistoryUtils::HiggsDecay
Definition: PartonHistoryUtils.h:20
top::CalcTopPartonHistory
Definition: CalcTopPartonHistory.h:39
top::PartonHistoryUtils::HiggsDecay::decay1_from_decay2_pdgId
int decay1_from_decay2_pdgId
Definition: PartonHistoryUtils.h:35
xAOD::PartonHistoryAuxContainer
Aux Container.
Definition: PartonHistory.h:41
top::CalcThqPartonHistory::tH_values::decay2_from_decay1_p4
TLorentzVector decay2_from_decay1_p4
Definition: CalcThqPartonHistory.h:35
top::CalcThqPartonHistory::tH_values::decay1_pdgId
int decay1_pdgId
Definition: CalcThqPartonHistory.h:30
top::CalcThqPartonHistory::tH_values::Higgs_p4
TLorentzVector Higgs_p4
Definition: CalcThqPartonHistory.h:27
top::CalcTopPartonHistory::topWb
bool topWb(const xAOD::TruthParticleContainer *truthParticles, int start, TLorentzVector &t_beforeFSR_p4, TLorentzVector &t_afterFSR_p4, TLorentzVector &W_p4, TLorentzVector &b_p4, TLorentzVector &Wdecay1_p4, int &Wdecay1_pdgId, TLorentzVector &Wdecay2_p4, int &Wdecay2_pdgId)
Store the four-momentum of several particles in the top decay chain.
Definition: CalcTopPartonHistory.cxx:182
CalcTopPartonHistory.h
top::PartonHistoryUtils::HiggsDecay::tau_decay2_from_decay1_isHadronic
int tau_decay2_from_decay1_isHadronic
Definition: PartonHistoryUtils.h:39
top::CalcTopPartonHistory::fillEtaBranch
void fillEtaBranch(xAOD::PartonHistory *partonHistory, std::string branchName, TLorentzVector &tlv)
Definition: CalcTopPartonHistory.cxx:692
top::CalcThqPartonHistory::tH_values::decay1_from_decay2_pdgId
int decay1_from_decay2_pdgId
Definition: CalcThqPartonHistory.h:40
top::PartonHistoryUtils::HiggsDecay::decay2_pdgId
int decay2_pdgId
Definition: PartonHistoryUtils.h:25
top::CalcThqPartonHistory::tH_values::decay2_p4
TLorentzVector decay2_p4
Definition: CalcThqPartonHistory.h:29
top::CalcThqPartonHistory::tH_values::tau_decay2_from_decay1_isHadronic
int tau_decay2_from_decay1_isHadronic
Definition: CalcThqPartonHistory.h:43
top::PartonHistoryUtils::HiggsDecay::decay1_vector
TLorentzVector decay1_vector
direct higgs decay
Definition: PartonHistoryUtils.h:22
top::CalcThqPartonHistory::tH_values::decay1_from_decay1_p4
TLorentzVector decay1_from_decay1_p4
Definition: CalcThqPartonHistory.h:34
top::PartonHistoryUtils::decorateWithMPtPhi
void decorateWithMPtPhi(xAOD::PartonHistory *pHistory, const std::string &prefix, const TLorentzVector &vec)
Perform decoration M, Pt, Phi of the history from a TLorentzVector.
Definition: PartonHistoryUtils.cxx:187