ATLAS Offline Software
CalcTbbarPartonHistory.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 
10 namespace top {
12 
14 
16  xAOD::PartonHistory* tbbarPartonHistory) {
17  tbbarPartonHistory->IniVarTbbar();
18 
19  TLorentzVector t_before, t_after;
20  TLorentzVector Wp;
21  TLorentzVector b_from_top;
22  TLorentzVector WpDecay1;
23  TLorentzVector WpDecay2;
24  int WpDecay1_pdgId;
25  int WpDecay2_pdgId;
26  bool event_top = CalcTopPartonHistory::topWb(truthParticles, 6, t_before, t_after, Wp, b_from_top, WpDecay1,
27  WpDecay1_pdgId, WpDecay2, WpDecay2_pdgId);
28  if (!event_top) event_top = CalcTopPartonHistory::topWb(truthParticles, -6, t_before, t_after, Wp, b_from_top,
29  WpDecay1, WpDecay1_pdgId, WpDecay2, WpDecay2_pdgId);
30 
31  TLorentzVector b_beforeFSR;
32  TLorentzVector b_afterFSR;
33  bool event_b = CalcTopPartonHistory::b(truthParticles, b_beforeFSR, b_afterFSR);
34 
35  if (event_top && event_b) {
36  TLorentzVector temp = t_before + b_beforeFSR;
37  decorateWithMPtPhi(tbbarPartonHistory, "MC_tbbar_beforeFSR", temp);
38  fillEtaBranch(tbbarPartonHistory, "MC_tbbar_beforeFSR_eta", temp);
39 
40  temp = WpDecay1 + WpDecay2 + b_from_top + b_afterFSR;
41  decorateWithMPtPhi(tbbarPartonHistory, "MC_tbbar_afterFSR", temp);
42  fillEtaBranch(tbbarPartonHistory, "MC_tbbar_afterFSR_eta", temp);
43  }//if
44  if (event_top) {
45  decorateWithMPtPhi(tbbarPartonHistory, "MC_t_beforeFSR", t_before);
46  fillEtaBranch(tbbarPartonHistory, "MC_t_beforeFSR_eta", t_before);
47 
48  decorateWithMPtPhi(tbbarPartonHistory, "MC_W_from_t", Wp);
49  fillEtaBranch(tbbarPartonHistory, "MC_W_from_t_eta", Wp);
50 
51  decorateWithMPtPhi(tbbarPartonHistory, "MC_b_from_t", b_from_top);
52  fillEtaBranch(tbbarPartonHistory, "MC_b_from_t_eta", b_from_top);
53 
54  decorateWithMPtPhi(tbbarPartonHistory, "MC_Wdecay1_from_t", WpDecay1);
55  tbbarPartonHistory->auxdecor< int >("MC_Wdecay1_from_t_pdgId") = WpDecay1_pdgId;
56  fillEtaBranch(tbbarPartonHistory, "MC_Wdecay1_from_t_eta", WpDecay1);
57 
58  decorateWithMPtPhi(tbbarPartonHistory, "MC_Wdecay2_from_t", WpDecay2);
59  tbbarPartonHistory->auxdecor< int >("MC_Wdecay2_from_t_pdgId") = WpDecay2_pdgId;
60  fillEtaBranch(tbbarPartonHistory, "MC_Wdecay2_from_t_eta", WpDecay2);
61  }//if
62  if (event_b) {
63  decorateWithMPtPhi(tbbarPartonHistory, "MC_b_beforeFSR", b_beforeFSR);
64  fillEtaBranch(tbbarPartonHistory, "MC_b_beforeFSR_eta", b_beforeFSR);
65 
66  decorateWithMPtPhi(tbbarPartonHistory, "MC_b_afterFSR", b_afterFSR);
67  fillEtaBranch(tbbarPartonHistory, "MC_b_afterFSR_eta", b_afterFSR);
68  }//if
69  }
70 
72  // Get the Truth Particles
73  const xAOD::TruthParticleContainer* truthParticles(nullptr);
74 
75  ATH_CHECK(evtStore()->retrieve(truthParticles, m_config->sgKeyMCParticle()));
76 
77  // Create the partonHistory xAOD object
78  //cppcheck-suppress uninitvar
80  //cppcheck-suppress uninitvar
82  partonCont->setStore(partonAuxCont);
83  //cppcheck-suppress uninitvar
84  xAOD::PartonHistory* tbbarPartonHistory = new xAOD::PartonHistory {};
85  partonCont->push_back(tbbarPartonHistory);
86 
87  // Recover the parton history for tbbar events
88  tbbarHistorySaver(truthParticles, tbbarPartonHistory);
89 
90  // Save to StoreGate / TStore
91  std::string outputSGKey = m_config->sgKeyTopPartonHistory();
92  std::string outputSGKeyAux = outputSGKey + "Aux.";
93 
94  StatusCode save = evtStore()->tds()->record(partonCont, outputSGKey);
95  StatusCode saveAux = evtStore()->tds()->record(partonAuxCont, outputSGKeyAux);
96  if (!save || !saveAux) {
97  return StatusCode::FAILURE;
98  }
99 
100  return StatusCode::SUCCESS;
101  }
102 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::PartonHistory
Interface class.
Definition: PartonHistory.h:48
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
top::CalcTbbarPartonHistory::CalcTbbarPartonHistory
CalcTbbarPartonHistory(const std::string &name)
Definition: CalcTbbarPartonHistory.cxx:13
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
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::CalcTbbarPartonHistory::execute
virtual StatusCode execute()
Definition: CalcTbbarPartonHistory.cxx:71
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CalcTbbarPartonHistory.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
TopConfig.h
top::CalcTbbarPartonHistory::tbbarHistorySaver
void tbbarHistorySaver(const xAOD::TruthParticleContainer *truthParticles, xAOD::PartonHistory *tbbarPartonHistory)
Definition: CalcTbbarPartonHistory.cxx:15
top::CalcTopPartonHistory
Definition: CalcTopPartonHistory.h:39
xAOD::PartonHistoryAuxContainer
Aux Container.
Definition: PartonHistory.h:41
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::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
xAOD::PartonHistory::IniVarTbbar
void IniVarTbbar()
Definition: PartonHistory.cxx:208