Skip to content
Snippets Groups Projects
Commit f78fe7d2 authored by John Chapman's avatar John Chapman
Browse files

xAODDirectPhotonFilter use ReadHandleKey

parent 87ba5a23
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ public:
private:
SG::ReadHandleKey<xAOD::TruthParticleContainer> m_truthPartContKey{this, "TruthParticleContainerKey", "TruthGen"};
DoubleArrayProperty m_Ptmin{this, "Ptmin", {10000.}};
DoubleArrayProperty m_Ptmax{this, "Ptmax", {std::numeric_limits<double>::max()}};
DoubleProperty m_EtaRange{this, "Etacut", 2.50};
......
......@@ -13,6 +13,7 @@ xAODDirectPhotonFilter::xAODDirectPhotonFilter(const std::string& name, ISvcLoca
StatusCode xAODDirectPhotonFilter::filterInitialize() {
ATH_CHECK(m_truthPartContKey.initialize());
ATH_MSG_INFO("Initialising DirectPhoton filter with OrderPhotons="<<m_OrderPhotons);
......@@ -52,19 +53,16 @@ StatusCode xAODDirectPhotonFilter::filterEvent() {
std::vector<const xAOD::TruthParticle*> promptPhotonsInEta;
int phot = 0;
// Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and
// duplicated barcode ones
const xAOD::TruthParticleContainer* xTruthParticleContainer;
if (evtStore()->retrieve(xTruthParticleContainer, "TruthGen").isFailure()) {
ATH_MSG_ERROR("No TruthParticle collection with name " << "TruthGen" << " found in StoreGate!");
return StatusCode::FAILURE;
// Retrieve TruthGen container from xAOD Gen slimmer, contains all particles witout barcode_zero and
// duplicated barcode ones
SG::ReadHandle<xAOD::TruthParticleContainer> xTruthParticleContainer{m_truthPartContKey};
if (!xTruthParticleContainer.isValid()) {
ATH_MSG_ERROR("No TruthParticle collection with name " << m_truthPartContKey.key() << " found in StoreGate!");
return StatusCode::FAILURE;
}
// Loop over all particles in the event and find photons in given eta range
unsigned int nPart = xTruthParticleContainer->size();
for (unsigned int iPart = 0; iPart < nPart; ++iPart) {
const xAOD::TruthParticle* pitr = (*xTruthParticleContainer)[iPart];
// Loop over all particles in the event and find photons in given eta range
for (const xAOD::TruthParticle* pitr : *xTruthParticleContainer) {
if (MC::isPhoton(pitr) &&
MC::isStable(pitr) &&
std::abs(pitr->eta()) <= m_EtaRange) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment