ATLAS Offline Software
CalcWtbPartonHistory.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3  */
4 
7 
8 namespace top {
10 
12  xAOD::PartonHistory* wtbPartonHistory) {
13  wtbPartonHistory->IniVarWtb();
14 
15  TLorentzVector t_before, t_after;
16  TLorentzVector antit_before, antit_after;
17  TLorentzVector WfromTop;
18  TLorentzVector bFromTop;
19  TLorentzVector WfromTopDecay1;
20  TLorentzVector WfromTopDecay2;
21  int WfromTopDecay1_pdgId;
22  int WfromTopDecay2_pdgId;
23 
24  bool event_top = CalcTopPartonHistory::topWb(truthParticles, 6, t_before, t_after, WfromTop, bFromTop,
25  WfromTopDecay1, WfromTopDecay1_pdgId, WfromTopDecay2,
26  WfromTopDecay2_pdgId);
27 
28  TLorentzVector WfromAntiTop;
29  TLorentzVector bFromAntiTop;
30  TLorentzVector WfromAntiTopDecay1;
31  TLorentzVector WfromAntiTopDecay2;
32  int WfromAntiTopDecay1_pdgId;
33  int WfromAntiTopDecay2_pdgId;
34 
35  bool event_antitop = CalcTopPartonHistory::topWb(truthParticles, -6, antit_before, antit_after, WfromAntiTop,
36  bFromAntiTop, WfromAntiTopDecay1, WfromAntiTopDecay1_pdgId,
37  WfromAntiTopDecay2, WfromAntiTopDecay2_pdgId);
38 
39  TLorentzVector WnotFromTop;
40  TLorentzVector WnotFromTopDecay1;
41  TLorentzVector WnotFromTopDecay2;
42  int WnotFromTop_pdgId;
43  int WnotFromTopDecay1_pdgId;
44  int WnotFromTopDecay2_pdgId;
45 
46  bool event_WnotTop = CalcTopPartonHistory::Wt_W(truthParticles, WnotFromTop, WnotFromTop_pdgId, WnotFromTopDecay1,
47  WnotFromTopDecay1_pdgId, WnotFromTopDecay2,
48  WnotFromTopDecay2_pdgId);
49 
50  TLorentzVector bNotFromTop_before;
51  TLorentzVector bNotFromTop_after;
52  int bNotFromTop_pdgId;
53 
54  bool event_b = CalcTopPartonHistory::Wt_b(truthParticles, bNotFromTop_before, bNotFromTop_after, bNotFromTop_pdgId);
55 
56  if (event_top && !event_antitop) {
57  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_pt") = t_before.Pt();
58  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_eta") = t_before.Eta();
59  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_phi") = t_before.Phi();
60  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_m") = t_before.M();
61 
62  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_pt") = t_after.Pt();
63  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_eta") = t_after.Eta();
64  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_phi") = t_after.Phi();
65  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_m") = t_after.M();
66 
67  wtbPartonHistory->auxdecor< float >("MC_b_from_top_pt") = bFromTop.Pt();
68  wtbPartonHistory->auxdecor< float >("MC_b_from_top_eta") = bFromTop.Eta();
69  wtbPartonHistory->auxdecor< float >("MC_b_from_top_phi") = bFromTop.Phi();
70  wtbPartonHistory->auxdecor< float >("MC_b_from_top_m") = bFromTop.M();
71 
72  wtbPartonHistory->auxdecor< float >("MC_W_from_top_pt") = WfromTop.Pt();
73  wtbPartonHistory->auxdecor< float >("MC_W_from_top_eta") = WfromTop.Eta();
74  wtbPartonHistory->auxdecor< float >("MC_W_from_top_phi") = WfromTop.Phi();
75  wtbPartonHistory->auxdecor< float >("MC_W_from_top_m") = WfromTop.M();
76 
77  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_pt") = WfromTopDecay1.Pt();
78  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_eta") = WfromTopDecay1.Eta();
79  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_phi") = WfromTopDecay1.Phi();
80  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_m") = WfromTopDecay1.M();
81  wtbPartonHistory->auxdecor< int >("MC_Wdecay1_from_top_pdgId") = WfromTopDecay1_pdgId;
82 
83  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_pt") = WfromTopDecay2.Pt();
84  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_eta") = WfromTopDecay2.Eta();
85  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_phi") = WfromTopDecay2.Phi();
86  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_m") = WfromTopDecay2.M();
87  wtbPartonHistory->auxdecor< int >("MC_Wdecay2_from_top_pdgId") = WfromTopDecay2_pdgId;
88  } else if (!event_top && event_antitop) {
89  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_pt") = antit_before.Pt();
90  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_eta") = antit_before.Eta();
91  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_phi") = antit_before.Phi();
92  wtbPartonHistory->auxdecor< float >("MC_top_beforeFSR_m") = antit_before.M();
93 
94  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_pt") = antit_after.Pt();
95  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_eta") = antit_after.Eta();
96  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_phi") = antit_after.Phi();
97  wtbPartonHistory->auxdecor< float >("MC_top_afterFSR_m") = antit_after.M();
98 
99  wtbPartonHistory->auxdecor< float >("MC_b_from_top_pt") = bFromAntiTop.Pt();
100  wtbPartonHistory->auxdecor< float >("MC_b_from_top_eta") = bFromAntiTop.Eta();
101  wtbPartonHistory->auxdecor< float >("MC_b_from_top_phi") = bFromAntiTop.Phi();
102  wtbPartonHistory->auxdecor< float >("MC_b_from_top_m") = bFromAntiTop.M();
103 
104  wtbPartonHistory->auxdecor< float >("MC_W_from_top_pt") = WfromAntiTop.Pt();
105  wtbPartonHistory->auxdecor< float >("MC_W_from_top_eta") = WfromAntiTop.Eta();
106  wtbPartonHistory->auxdecor< float >("MC_W_from_top_phi") = WfromAntiTop.Phi();
107  wtbPartonHistory->auxdecor< float >("MC_W_from_top_m") = WfromAntiTop.M();
108 
109  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_pt") = WfromAntiTopDecay1.Pt();
110  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_eta") = WfromAntiTopDecay1.Eta();
111  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_phi") = WfromAntiTopDecay1.Phi();
112  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_from_top_m") = WfromAntiTopDecay1.M();
113  wtbPartonHistory->auxdecor< int >("MC_Wdecay1_from_top_pdgId") = WfromAntiTopDecay1_pdgId;
114 
115  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_pt") = WfromAntiTopDecay2.Pt();
116  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_eta") = WfromAntiTopDecay2.Eta();
117  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_phi") = WfromAntiTopDecay2.Phi();
118  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_from_top_m") = WfromAntiTopDecay2.M();
119  wtbPartonHistory->auxdecor< int >("MC_Wdecay2_from_top_pdgId") = WfromAntiTopDecay2_pdgId;
120  }
121 
122  if (((event_top && !event_antitop) || (!event_top && event_antitop)) && event_WnotTop) {
123  wtbPartonHistory->auxdecor< float >("MC_W_not_from_top_pt") = WnotFromTop.Pt();
124  wtbPartonHistory->auxdecor< float >("MC_W_not_from_top_eta") = WnotFromTop.Eta();
125  wtbPartonHistory->auxdecor< float >("MC_W_not_from_top_phi") = WnotFromTop.Phi();
126  wtbPartonHistory->auxdecor< float >("MC_W_not_from_top_m") = WnotFromTop.M();
127 
128  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_not_from_top_pt") = WnotFromTopDecay1.Pt();
129  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_not_from_top_eta") = WnotFromTopDecay1.Eta();
130  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_not_from_top_phi") = WnotFromTopDecay1.Phi();
131  wtbPartonHistory->auxdecor< float >("MC_Wdecay1_not_from_top_m") = WnotFromTopDecay1.M();
132  wtbPartonHistory->auxdecor< int >("MC_Wdecay1_not_from_top_pdgId") = WnotFromTopDecay1_pdgId;
133 
134  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_not_from_top_pt") = WnotFromTopDecay2.Pt();
135  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_not_from_top_eta") = WnotFromTopDecay2.Eta();
136  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_not_from_top_phi") = WnotFromTopDecay2.Phi();
137  wtbPartonHistory->auxdecor< float >("MC_Wdecay2_not_from_top_m") = WnotFromTopDecay2.M();
138  wtbPartonHistory->auxdecor< int >("MC_Wdecay2_not_from_top_pdgId") = WnotFromTopDecay2_pdgId;
139  }//if
140 
141  if (((event_top && !event_antitop) || (!event_top && event_antitop)) && event_b) {
142  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_beforeFSR_pt") = bNotFromTop_before.Pt();
143  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_beforeFSR_eta") = bNotFromTop_before.Eta();
144  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_beforeFSR_phi") = bNotFromTop_before.Phi();
145  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_beforeFSR_m") = bNotFromTop_before.M();
146  wtbPartonHistory->auxdecor< int >("MC_b_not_from_top_pdgId") = bNotFromTop_pdgId;
147 
148  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_afterFSR_pt") = bNotFromTop_after.Pt();
149  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_afterFSR_eta") = bNotFromTop_after.Eta();
150  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_afterFSR_phi") = bNotFromTop_after.Phi();
151  wtbPartonHistory->auxdecor< float >("MC_b_not_from_top_afterFSR_m") = bNotFromTop_after.M();
152  }
153  }
154 
156  // Get the Truth Particles
157  const xAOD::TruthParticleContainer* truthParticles(nullptr);
158 
159  if(m_config->getDerivationStream() == "PHYS") //in DAOD_PHYS we don't have the truth particles container
160  {
161  // To obtain both tops and the H boson, we need the collections for both
162  std::vector<std::string> collections = {"TruthTop", "TruthBosonsWithDecayParticles", "HardScatterParticles"};
163  ATH_CHECK(buildContainerFromMultipleCollections(collections,"AT_WtbPartonHistory_TruthParticles"));
164  ATH_CHECK(evtStore()->retrieve(truthParticles, "AT_WtbPartonHistory_TruthParticles"));
165 
166  //we need to be able to navigate from the Ws to their decayProducts, see CalcTopPartonHistory.h for details
168  }
169  else //otherwise we retrieve the container as usual
170  {
171  ATH_CHECK(evtStore()->retrieve(truthParticles, m_config->sgKeyMCParticle()));
172  }
173 
174  // Create the partonHistory xAOD object
177  partonCont->setStore(partonAuxCont);
178 
179  xAOD::PartonHistory* wtbPartonHistory = new xAOD::PartonHistory {};
180  partonCont->push_back(wtbPartonHistory);
181 
182  // Recover the parton history for Wt SingleTop events
183  wtbHistorySaver(truthParticles, wtbPartonHistory);
184 
185  // Save to StoreGate / TStore
186  std::string outputSGKey = m_config->sgKeyTopPartonHistory();
187  std::string outputSGKeyAux = outputSGKey + "Aux.";
188 
189  StatusCode save = evtStore()->tds()->record(partonCont, outputSGKey);
190  StatusCode saveAux = evtStore()->tds()->record(partonAuxCont, outputSGKeyAux);
191  if (!save || !saveAux) {
192  return StatusCode::FAILURE;
193  }
194 
195  return StatusCode::SUCCESS;
196  }
197 }
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
top::CalcTopPartonHistory::Wt_b
bool Wt_b(const xAOD::TruthParticleContainer *truthParticles, TLorentzVector &b_beforeFSR, TLorentzVector &b_afterFSR, int &b_pdgId)
Store the four-momentum of b quark that is NOT from top in Wt(b) ST events.
Definition: CalcTopPartonHistory.cxx:403
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::CalcTopPartonHistory::Wt_W
bool Wt_W(const xAOD::TruthParticleContainer *truthParticles, TLorentzVector &W_p4, int &W_pdgId, TLorentzVector &Wdecay1_p4, int &Wdecay1_pdgId, TLorentzVector &Wdecay2_p4, int &Wdecay2_pdgId)
Store the four-momentum of several particles in W decay chain for W that is NOT from top in Wt ST eve...
Definition: CalcTopPartonHistory.cxx:345
CalcWtbPartonHistory.h
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
xAOD::PartonHistory::IniVarWtb
void IniVarWtb()
Definition: PartonHistory.cxx:281
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
top::CalcWtbPartonHistory::wtbHistorySaver
void wtbHistorySaver(const xAOD::TruthParticleContainer *truthParticles, xAOD::PartonHistory *wtSTPartonHistory)
Definition: CalcWtbPartonHistory.cxx:11
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
top::CalcWtbPartonHistory::execute
virtual StatusCode execute() override
Definition: CalcWtbPartonHistory.cxx:155
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::CalcWtbPartonHistory::CalcWtbPartonHistory
CalcWtbPartonHistory(const std::string &name)
Definition: CalcWtbPartonHistory.cxx:9
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