ATLAS Offline Software
CalcTtbarLightPartonHistory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3  */
4 
8 
9 namespace top {
11 
13 
15  xAOD::PartonHistory* ttbarPartonHistory) {
16  ttbarPartonHistory->IniVarTtbarLight();
17 
18  TLorentzVector t_before, t_after, t_after_SC;
19  TLorentzVector Wp;
20  TLorentzVector q;
21  int q_pdgId{};
22  TLorentzVector WpDecay1;
23  TLorentzVector WpDecay2;
24  int WpDecay1_pdgId{};
25  int WpDecay2_pdgId{};
26  bool event_top = CalcTopPartonHistory::topWq(truthParticles, 6, t_before, t_after, Wp, q, q_pdgId, WpDecay1,
27  WpDecay1_pdgId, WpDecay2, WpDecay2_pdgId);
28  bool event_top_SC = CalcTopPartonHistory::topAfterFSR_SC(truthParticles, 6, t_after_SC);
29 
30  TLorentzVector tbar_before, tbar_after, tbar_after_SC;
31  TLorentzVector Wm;
32  TLorentzVector qbar;
33  int qbar_pdgId{};
34  TLorentzVector WmDecay1;
35  TLorentzVector WmDecay2;
36  int WmDecay1_pdgId{};
37  int WmDecay2_pdgId{};
38  bool event_topbar = CalcTopPartonHistory::topWq(truthParticles, -6, tbar_before, tbar_after, Wm, qbar, qbar_pdgId,
39  WmDecay1, WmDecay1_pdgId, WmDecay2, WmDecay2_pdgId);
40  bool event_topbar_SC = CalcTopPartonHistory::topAfterFSR_SC(truthParticles, -6, tbar_after_SC);
41 
42  if (event_top && event_topbar) {
43  TLorentzVector temp = t_before + tbar_before;
44  decorateWithMPtPhi(ttbarPartonHistory, "MC_ttbar_beforeFSR", temp);
45  fillEtaBranch(ttbarPartonHistory, "MC_ttbar_beforeFSR_eta", temp);
46 
47  temp = WmDecay1 + WmDecay2 + q + WpDecay1 + WpDecay2 + qbar;
48  decorateWithMPtPhi(ttbarPartonHistory, "MC_ttbar_afterFSR", temp);
49  fillEtaBranch(ttbarPartonHistory, "MC_ttbar_afterFSR_eta", temp);
50  }//if
51  if (event_top) {
52  decorateWithMPtPhi(ttbarPartonHistory, "MC_t_beforeFSR", t_before);
53  fillEtaBranch(ttbarPartonHistory, "MC_t_beforeFSR_eta", t_before);
54 
55  decorateWithMPtPhi(ttbarPartonHistory, "MC_t_afterFSR", t_after);
56  fillEtaBranch(ttbarPartonHistory, "MC_t_afterFSR_eta", t_after);
57 
58  if (event_top_SC) {
59  decorateWithMPtPhi(ttbarPartonHistory, "MC_t_afterFSR_SC", t_after_SC);
60  fillEtaBranch(ttbarPartonHistory, "MC_t_afterFSR_SC_eta", t_after_SC);
61  }
62 
63  decorateWithMPtPhi(ttbarPartonHistory, "MC_W_from_t", Wp);
64  fillEtaBranch(ttbarPartonHistory, "MC_W_from_t_eta", Wp);
65 
66  decorateWithMPtPhi(ttbarPartonHistory, "MC_q_from_t", q);
67  ttbarPartonHistory->auxdecor< int >("MC_q_from_t_pdgId") = q_pdgId;
68  fillEtaBranch(ttbarPartonHistory, "MC_q_from_t_eta", q);
69 
70  decorateWithMPtPhi(ttbarPartonHistory, "MC_Wdecay1_from_t", WpDecay1);
71  ttbarPartonHistory->auxdecor< int >("MC_Wdecay1_from_t_pdgId") = WpDecay1_pdgId;
72  fillEtaBranch(ttbarPartonHistory, "MC_Wdecay1_from_t_eta", WpDecay1);
73 
74  decorateWithMPtPhi(ttbarPartonHistory, "MC_Wdecay2_from_t", WpDecay2);
75  ttbarPartonHistory->auxdecor< int >("MC_Wdecay2_from_t_pdgId") = WpDecay2_pdgId;
76  fillEtaBranch(ttbarPartonHistory, "MC_Wdecay2_from_t_eta", WpDecay2);
77  }//if
78  if (event_topbar) {
79  decorateWithMPtPhi(ttbarPartonHistory, "MC_tbar_beforeFSR", tbar_before);
80  fillEtaBranch(ttbarPartonHistory, "MC_tbar_beforeFSR_eta", tbar_before);
81 
82  decorateWithMPtPhi(ttbarPartonHistory, "MC_tbar_afterFSR", tbar_after);
83  fillEtaBranch(ttbarPartonHistory, "MC_tbar_afterFSR_eta", tbar_after);
84 
85  if (event_topbar_SC) {
86  decorateWithMPtPhi(ttbarPartonHistory, "MC_tbar_afterFSR_SC", tbar_after_SC);
87  fillEtaBranch(ttbarPartonHistory, "MC_tbar_afterFSR_SC_eta", tbar_after_SC);
88  }
89 
90  decorateWithMPtPhi(ttbarPartonHistory, "MC_W_from_tbar", Wm);
91  fillEtaBranch(ttbarPartonHistory, "MC_W_from_tbar_eta", Wm);
92 
93  decorateWithMPtPhi(ttbarPartonHistory, "MC_q_from_tbar", qbar);
94  ttbarPartonHistory->auxdecor< int >("MC_q_from_tbar_pdgId") = qbar_pdgId;
95  fillEtaBranch(ttbarPartonHistory, "MC_q_from_tbar_eta", qbar);
96 
97  decorateWithMPtPhi(ttbarPartonHistory, "MC_Wdecay1_from_tbar", WmDecay1);
98  ttbarPartonHistory->auxdecor< int >("MC_Wdecay1_from_tbar_pdgId") = WmDecay1_pdgId;
99  fillEtaBranch(ttbarPartonHistory, "MC_Wdecay1_from_tbar_eta", WmDecay1);
100 
101  decorateWithMPtPhi(ttbarPartonHistory, "MC_Wdecay2_from_tbar", WmDecay2);
102  ttbarPartonHistory->auxdecor< int >("MC_Wdecay2_from_tbar_pdgId") = WmDecay2_pdgId;
103  fillEtaBranch(ttbarPartonHistory, "MC_Wdecay2_from_tbar_eta", WmDecay2);
104  }//if
105  }
106 
108  // Get the Truth Particles
109  const xAOD::TruthParticleContainer* truthParticles(nullptr);
110 
111  if(m_config->getDerivationStream() == "PHYS") //in DAOD_PHYS we don't have the truth particles container
112  {
113  // To obtain both tops and the ligt quarks, we need the collections for both
114  std::vector<std::string> collections = {"TruthTop", "HardScatterParticles"};
115  ATH_CHECK(buildContainerFromMultipleCollections(collections,"AT_TtbarLightPartonHistory_TruthParticles"));
116  ATH_CHECK(evtStore()->retrieve(truthParticles, "AT_TtbarLightPartonHistory_TruthParticles"));
117 
118  //we need to be able to navigate from the Ws to their decayProducts, see CalcTopPartonHistory.h for details
120  }
121  else //otherwise we retrieve the container as usual
122  {
123  ATH_CHECK(evtStore()->retrieve(truthParticles, m_config->sgKeyMCParticle()));
124  }
125 
126  // Create the partonHistory xAOD object
127  //cppcheck-suppress uninitvar
129  //cppcheck-suppress uninitvar
131  partonCont->setStore(partonAuxCont);
132  //cppcheck-suppress uninitvar
133  xAOD::PartonHistory* ttbarPartonHistory = new xAOD::PartonHistory {};
134  partonCont->push_back(ttbarPartonHistory);
135 
136  // Recover the parton history for ttbar events
137  ttbarHistorySaver(truthParticles, ttbarPartonHistory);
138 
139  // Save to StoreGate / TStore
140  std::string outputSGKey = m_config->sgKeyTopPartonHistory();
141  std::string outputSGKeyAux = outputSGKey + "Aux.";
142 
143  StatusCode save = evtStore()->tds()->record(partonCont, outputSGKey);
144  StatusCode saveAux = evtStore()->tds()->record(partonAuxCont, outputSGKeyAux);
145  if (!save || !saveAux) {
146  return StatusCode::FAILURE;
147  }
148 
149  return StatusCode::SUCCESS;
150  }
151 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
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
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
xAOD::PartonHistory::IniVarTtbarLight
void IniVarTtbarLight()
Definition: PartonHistory.cxx:116
top::CalcTtbarLightPartonHistory::execute
virtual StatusCode execute()
Definition: CalcTtbarLightPartonHistory.cxx:107
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
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
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PartonHistoryUtils.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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::CalcTopPartonHistory::topWq
bool topWq(const xAOD::TruthParticleContainer *truthParticles, int start, TLorentzVector &t_beforeFSR_p4, TLorentzVector &t_afterFSR_p4, TLorentzVector &W_p4, TLorentzVector &q_p4, int &q_pdgId, TLorentzVector &Wdecay1_p4, int &Wdecay1_pdgId, TLorentzVector &Wdecay2_p4, int &Wdecay2_pdgId)
Definition: CalcTopPartonHistory.cxx:246
top::CalcTtbarLightPartonHistory::ttbarHistorySaver
void ttbarHistorySaver(const xAOD::TruthParticleContainer *truthParticles, xAOD::PartonHistory *ttbarPartonHistory)
Definition: CalcTtbarLightPartonHistory.cxx:14
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
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.
TopConfig.h
top::CalcTopPartonHistory
Definition: CalcTopPartonHistory.h:39
xAOD::PartonHistoryAuxContainer
Aux Container.
Definition: PartonHistory.h:41
extractSporadic.q
list q
Definition: extractSporadic.py:98
top::CalcTtbarLightPartonHistory::CalcTtbarLightPartonHistory
CalcTtbarLightPartonHistory(const std::string &name)
Definition: CalcTtbarLightPartonHistory.cxx:12
top::CalcTopPartonHistory::fillEtaBranch
void fillEtaBranch(xAOD::PartonHistory *partonHistory, std::string branchName, TLorentzVector &tlv)
Definition: CalcTopPartonHistory.cxx:692
CalcTtbarLightPartonHistory.h
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