ATLAS Offline Software
CalcWlvPartonHistory.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* wlvPartonHistory) {
15  wlvPartonHistory->IniVarWlv();
16 
17  TLorentzVector W;
18  TLorentzVector WDecay1;
19  TLorentzVector WDecay2;
20  int WDecay1_pdgId{};
21  int WDecay2_pdgId{};
22  bool goodevent = CalcTopPartonHistory::Wlv(truthParticles, W, WDecay1, WDecay1_pdgId, WDecay2, WDecay2_pdgId);
23 
24 
25  if (goodevent) {
26  decorateWithMPtPhi(wlvPartonHistory, "MC_W",W);
27  fillEtaBranch(wlvPartonHistory, "MC_W_eta", W);
28 
29  decorateWithMPtPhi(wlvPartonHistory, "MC_l",WDecay1);
30  wlvPartonHistory->auxdecor< int >("MC_l_pdgId") = WDecay1_pdgId;
31  fillEtaBranch(wlvPartonHistory, "MC_l_eta", WDecay1);
32 
33  decorateWithMPtPhi(wlvPartonHistory, "MC_v",WDecay2);
34  wlvPartonHistory->auxdecor< int >("MC_v_pdgId") = WDecay2_pdgId;
35  fillEtaBranch(wlvPartonHistory, "MC_v_eta", WDecay2);
36  }//if
37  }
38 
40  // Get the Truth Particles
41  const xAOD::TruthParticleContainer* truthParticles(nullptr);
42 
43  if(m_config->getDerivationStream() == "PHYS") //in DAOD_PHYS we don't have the truth particles container
44  {
45  // To obtain the W, leptons and the neutrino, we need the collections for all
46  std::vector<std::string> collections = {"HardScatterParticles", "TruthBosonsWithDecayParticles", "TruthNeutrinos"};
47  ATH_CHECK(buildContainerFromMultipleCollections(collections,"AT_WlvPartonHistory_TruthParticles"));
48  ATH_CHECK(evtStore()->retrieve(truthParticles, "AT_WlvPartonHistory_TruthParticles"));
49 
50  //we need to be able to navigate from the Ws to their decayProducts, see CalcTopPartonHistory.h for details
52  }
53  else //otherwise we retrieve the container as usual
54  {
55  ATH_CHECK(evtStore()->retrieve(truthParticles, m_config->sgKeyMCParticle()));
56  }
57 
58  // Create the partonHistory xAOD object
59  //cppcheck-suppress uninitvar
61  //cppcheck-suppress uninitvar
63  partonCont->setStore(partonAuxCont);
64  //cppcheck-suppress uninitvar
65  xAOD::PartonHistory* wlvPartonHistory = new xAOD::PartonHistory {};
66  partonCont->push_back(wlvPartonHistory);
67 
68  // Recover the parton history for wlv events
69  WlvHistorySaver(truthParticles, wlvPartonHistory);
70 
71  // Save to StoreGate / TStore
72  std::string outputSGKey = m_config->sgKeyTopPartonHistory();
73  std::string outputSGKeyAux = outputSGKey + "Aux.";
74 
75  StatusCode save = evtStore()->tds()->record(partonCont, outputSGKey);
76  StatusCode saveAux = evtStore()->tds()->record(partonAuxCont, outputSGKeyAux);
77  if (!save || !saveAux) {
78  return StatusCode::FAILURE;
79  }
80 
81  return StatusCode::SUCCESS;
82  }
83 }
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
CalcWlvPartonHistory.h
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
JetTiledMap::W
@ W
Definition: TiledEtaPhiMap.h:44
xAOD::PartonHistory::IniVarWlv
void IniVarWlv()
Definition: PartonHistory.cxx:260
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::CalcWlvPartonHistory::WlvHistorySaver
void WlvHistorySaver(const xAOD::TruthParticleContainer *truthParticles, xAOD::PartonHistory *wlvPartonHistory)
Definition: CalcWlvPartonHistory.cxx:13
top::CalcWlvPartonHistory::CalcWlvPartonHistory
CalcWlvPartonHistory(const std::string &name)
Definition: CalcWlvPartonHistory.cxx:11
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
top::CalcTopPartonHistory::Wlv
bool Wlv(const xAOD::TruthParticleContainer *truthParticles, TLorentzVector &W_p4, TLorentzVector &Wdecay1_p4, int &Wdecay1_pdgId, TLorentzVector &Wdecay2_p4, int &Wdecay2_pdgId)
Store the four-momentum of several particles in the W decay chain.
Definition: CalcTopPartonHistory.cxx:305
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::CalcWlvPartonHistory::execute
virtual StatusCode execute()
Definition: CalcWlvPartonHistory.cxx:39
TopConfig.h
top::CalcTopPartonHistory
Definition: CalcTopPartonHistory.h:39
xAOD::PartonHistoryAuxContainer
Aux Container.
Definition: PartonHistory.h:41
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