ATLAS Offline Software
Loading...
Searching...
No Matches
TruthMuonsToSG.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12
13#include "TruthMuonsToSG.h"
14
19
20
21namespace D3PD {
22
23
24TruthMuonsToSG::TruthMuonsToSG(const std::string& name, ISvcLocator* pSvcLocator)
25 : AthAlgorithm(name, pSvcLocator),
27 m_classifier ("MCTruthClassifier")
28{
29 declareProperty("TruthContainer", m_truthContainerKey = "TruthParticle" );
30 declareProperty("TruthMuonContainer", m_truthMuonContainerKey = "TruthMuons" );
31 declareProperty ("Classifier", m_classifier, "Classifier tool instance.");
32
33}
34
37 CHECK( m_classifier.retrieve() );
38 return StatusCode::SUCCESS;
39}
40
42 return StatusCode::SUCCESS;
43}
44
45
47 const xAOD::TruthParticleContainer *truthCollection = nullptr;
48 StatusCode sc=evtStore()->retrieve( truthCollection, m_resolver.key());
49 if( sc.isFailure() || !truthCollection) {
50 ATH_MSG_ERROR("Failed to retrieve xAOD::TruthParticleContainer " << m_resolver.key());
51 return StatusCode::FAILURE;
52 }
53
54 // output container for muons
57
58 for (const xAOD::TruthParticle* p : *truthCollection) {
59 if( abs(p->pdgId()) == MC::MUON && MC::isStable(p) ) {
60 muonColl->push_back(p);
61 }
62 else if( MC::isPhoton(p) ) {
63 auto Classify = m_classifier->particleTruthClassifier( p );
65 muonColl->push_back(p);
66 }
67 }
68 }
69
70 if( evtStore()->record(muonColl, m_truthMuonContainerKey).isFailure() ) return StatusCode::FAILURE;
71 return StatusCode::SUCCESS;
72}
73
74
75} // namespace D3PD
#define ATH_MSG_ERROR(x)
DataVector adapter that acts like it holds const pointers.
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
ATLAS-specific HepMC functions.
static Double_t sc
Create collection of true muons in StoreGate, based on analogous code in TauD3PDMaker.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ToolHandle< IMCTruthClassifier > m_classifier
TruthMuonsToSG(const std::string &name, ISvcLocator *pSvcLocator)
SGKeyResolver m_resolver
Helper to resolve SG key for input collection.
std::string m_truthMuonContainerKey
std::string m_truthContainerKey
Block filler tool for noisy FEB information.
static const int MUON
bool isPhoton(const T &p)
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
TruthParticle_v1 TruthParticle
Typedef to implementation.
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.