ATLAS Offline Software
CalcTtbarPartonHistory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3  */
4 
8 
9 namespace top {
12 
14  xAOD::PartonHistory* ttbarPartonHistory) {
15  ttbarPartonHistory->IniVarTtbar();
16 
17  TLorentzVector t_before, t_after, t_after_SC;
18  TLorentzVector Wp;
19  TLorentzVector b;
20  TLorentzVector WpDecay1;
21  TLorentzVector WpDecay2;
22  int WpDecay1_pdgId{};
23  int WpDecay2_pdgId{};
24 
25  bool event_top = CalcTopPartonHistory::topWb(truthParticles, 6, t_before, t_after, Wp, b, WpDecay1, WpDecay1_pdgId,
26  WpDecay2, WpDecay2_pdgId);
27  bool event_top_SC = CalcTopPartonHistory::topAfterFSR_SC(truthParticles, 6, t_after_SC);
28 
29  TLorentzVector tbar_before, tbar_after, tbar_after_SC;
30  TLorentzVector Wm;
31  TLorentzVector bbar;
32  TLorentzVector WmDecay1;
33  TLorentzVector WmDecay2;
34  int WmDecay1_pdgId{};
35  int WmDecay2_pdgId{};
36 
37  bool event_topbar = CalcTopPartonHistory::topWb(truthParticles, -6, tbar_before, tbar_after, Wm, bbar, WmDecay1,
38  WmDecay1_pdgId, WmDecay2, WmDecay2_pdgId);
39  bool event_topbar_SC = CalcTopPartonHistory::topAfterFSR_SC(truthParticles, -6, tbar_after_SC);
40 
41  if (event_top && event_topbar) {
42  TLorentzVector temp = t_before + tbar_before;
43  decorateWithMPtPhi(ttbarPartonHistory, "MC_ttbar_beforeFSR", temp);
44  fillEtaBranch(ttbarPartonHistory, "MC_ttbar_beforeFSR_eta", temp);
45 
46  temp = t_after + tbar_after;
47  decorateWithMPtPhi(ttbarPartonHistory, "MC_ttbar_afterFSR_beforeDecay", temp);
48  fillEtaBranch(ttbarPartonHistory, "MC_ttbar_afterFSR_beforeDecay_eta", temp);
49 
50  temp = WmDecay1 + WmDecay2 + b + WpDecay1 + WpDecay2 + bbar;
51  decorateWithMPtPhi(ttbarPartonHistory, "MC_ttbar_afterFSR", temp);
52  fillEtaBranch(ttbarPartonHistory, "MC_ttbar_afterFSR_eta", temp);
53  }//if
54  if (event_top) {
55  decorateWithMPtPhi(ttbarPartonHistory, "MC_t_beforeFSR", t_before);
56  fillEtaBranch(ttbarPartonHistory, "MC_t_beforeFSR_eta", t_before);
57 
58  decorateWithMPtPhi(ttbarPartonHistory, "MC_t_afterFSR", t_after);
59  fillEtaBranch(ttbarPartonHistory, "MC_t_afterFSR_eta", t_after);
60 
61  if (event_top_SC) {
62  decorateWithMPtPhi(ttbarPartonHistory, "MC_t_afterFSR_SC", t_after_SC);
63  fillEtaBranch(ttbarPartonHistory, "MC_t_afterFSR_SC_eta", t_after_SC);
64  }
65  decorateWithMPtPhi(ttbarPartonHistory, "MC_W_from_t", Wp);
66  fillEtaBranch(ttbarPartonHistory, "MC_W_from_t_eta", Wp);
67 
68  decorateWithMPtPhi(ttbarPartonHistory, "MC_b_from_t", b);
69  fillEtaBranch(ttbarPartonHistory, "MC_b_from_t_eta", b);
70 
71  decorateWithMPtPhi(ttbarPartonHistory, "MC_Wdecay1_from_t", WpDecay1);
72  ttbarPartonHistory->auxdecor< int >("MC_Wdecay1_from_t_pdgId") = WpDecay1_pdgId;
73  fillEtaBranch(ttbarPartonHistory, "MC_Wdecay1_from_t_eta", WpDecay1);
74 
75  decorateWithMPtPhi(ttbarPartonHistory, "MC_Wdecay2_from_t", WpDecay2);
76  ttbarPartonHistory->auxdecor< int >("MC_Wdecay2_from_t_pdgId") = WpDecay2_pdgId;
77  fillEtaBranch(ttbarPartonHistory, "MC_Wdecay2_from_t_eta", WpDecay2);
78  }//if
79  if (event_topbar) {
80  decorateWithMPtPhi(ttbarPartonHistory, "MC_tbar_beforeFSR", tbar_before);
81  fillEtaBranch(ttbarPartonHistory, "MC_tbar_beforeFSR_eta", tbar_before);
82 
83  decorateWithMPtPhi(ttbarPartonHistory, "MC_tbar_afterFSR", tbar_after);
84  fillEtaBranch(ttbarPartonHistory, "MC_tbar_afterFSR_eta", tbar_after);
85 
86  if (event_topbar_SC) {
87  decorateWithMPtPhi(ttbarPartonHistory, "MC_tbar_afterFSR_SC", tbar_after_SC);
88  fillEtaBranch(ttbarPartonHistory, "MC_tbar_afterFSR_SC_eta", tbar_after_SC);
89  }
90 
91  decorateWithMPtPhi(ttbarPartonHistory, "MC_W_from_tbar", Wm);
92  fillEtaBranch(ttbarPartonHistory, "MC_W_from_tbar_eta", Wm);
93 
94  decorateWithMPtPhi(ttbarPartonHistory, "MC_b_from_tbar", bbar);
95  fillEtaBranch(ttbarPartonHistory, "MC_b_from_tbar_eta", bbar);
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 
110  const xAOD::TruthParticleContainer* truthParticles(nullptr);
111 
112  if(m_config->getDerivationStream() == "PHYS") //in DAOD_PHYS we don't have the truth particles container
113  {
114  //the functions ued in this class always start from the top, so it's enough to do the following
115  std::vector<std::string> collections = {"TruthTop"};
116  ATH_CHECK(buildContainerFromMultipleCollections(collections,"AT_TTbarPartonHistory_TruthParticles"));
117  ATH_CHECK(evtStore()->retrieve(truthParticles, "AT_TTbarPartonHistory_TruthParticles"));
118 
119  //we need to be able to navigate from the Ws to their decayProducts, see CalcTopPartonHistory.h for details
121 
122  }
123  else //otherwise we retrieve the container as usual
124  {
125  ATH_CHECK(evtStore()->retrieve(truthParticles, m_config->sgKeyMCParticle()));
126  }
127 
128  // Create the partonHistory xAOD object
129  //cppcheck-suppress uninitvar
131  //cppcheck-suppress uninitvar
133  partonCont->setStore(partonAuxCont);
134  //cppcheck-suppress uninitvar
135  xAOD::PartonHistory* ttbarPartonHistory = new xAOD::PartonHistory {};
136  partonCont->push_back(ttbarPartonHistory);
137 
138  // Recover the parton history for ttbar events
139  ttbarHistorySaver(truthParticles, ttbarPartonHistory);
140 
141  // Save to StoreGate / TStore
142  std::string outputSGKey = m_config->sgKeyTopPartonHistory();
143  std::string outputSGKeyAux = outputSGKey + "Aux.";
144 
145  StatusCode save = evtStore()->tds()->record(partonCont, outputSGKey);
146  StatusCode saveAux = evtStore()->tds()->record(partonAuxCont, outputSGKeyAux);
147  if (!save || !saveAux) {
148  return StatusCode::FAILURE;
149  }
150 
151  return StatusCode::SUCCESS;
152  }
153 }
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
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::CalcTtbarPartonHistory::execute
virtual StatusCode execute()
Definition: CalcTtbarPartonHistory.cxx:107
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
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::PartonHistory::IniVarTtbar
void IniVarTtbar()
Definition: PartonHistory.cxx:21
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
CalcTtbarPartonHistory.h
xAOD::PartonHistoryAuxContainer
Aux Container.
Definition: PartonHistory.h:41
top::CalcTtbarPartonHistory::ttbarHistorySaver
void ttbarHistorySaver(const xAOD::TruthParticleContainer *truthParticles, xAOD::PartonHistory *ttbarPartonHistory)
Definition: CalcTtbarPartonHistory.cxx:13
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
top::CalcTopPartonHistory::fillEtaBranch
void fillEtaBranch(xAOD::PartonHistory *partonHistory, std::string branchName, TLorentzVector &tlv)
Definition: CalcTopPartonHistory.cxx:692
top::CalcTtbarPartonHistory::CalcTtbarPartonHistory
CalcTtbarPartonHistory(const std::string &name)
Definition: CalcTtbarPartonHistory.cxx:11
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