ATLAS Offline Software
Loading...
Searching...
No Matches
EgammaHelpers.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8#ifndef COLUMNAR_EGAMMA_EGAMMA_HELPERS_H
9#define COLUMNAR_EGAMMA_EGAMMA_HELPERS_H
10
15
16namespace columnar
17{
18 namespace EgammaHelpers
19 {
26
27
28
29 // not sure if this should live here, since it draws in a dependency
30 // on ColumnarTracking/xAODTracking, but let's keep it here for now
31 template<ContainerIdConcept CI = ContainerId::egamma,typename CM=ColumnarModeDefault>
33 {
40
41 public:
43 : m_etaAcc (columnarTool, "eta"),
44 m_vertexLinksAcc (columnarTool, "vertexLinks"),
45 m_trackParticleLinksAcc (columnarTool, "trackParticleLinks", {.isOptional = true}),
46 m_numberOfPixelHitsAcc (columnarTool, "numberOfPixelHits"),
47 m_numberOfSCTHitsAcc (columnarTool, "numberOfSCTHits")
48 {
49 if constexpr (!CM::isXAOD)
50 resetAccessor (m_objectTypeAcc, columnarTool, "objectType", {.isOptional = true});
51 }
52
60 std::pair<bool,unsigned> operator () (ObjectId<CI,CM> photon, bool excludeTRT) const
61 {
62 // While the accessor is generally meant to be used with
63 // photons, sometimes electrons are passed as photons for
64 // performance studies, etc. In xAOD mode we can just check
65 // `IParticle::type()`, while in columnar mode we need the user
66 // to pass that in as an extra column. Having an extra column
67 // for that feels like a bit of an overkill, but it is optional
68 // here, and we can revisit it later if it becomes an issue.
70 if constexpr (CM::isXAOD)
71 {
72 type = photon.getXAODObjectNoexcept().type();
73 } else
74 {
75 if (m_objectTypeAcc.isAvailable(photon))
76 type = m_objectTypeAcc(photon);
77 }
79 return std::make_pair (false, 0x0);
80
81 const auto vertices = m_vertexLinksAcc(photon);
82 if (vertices.size() == 0) return std::make_pair (false, 0x0);
83 if (!vertices[0].has_value())
84 return std::make_pair (false, 0x1);
85
86 unsigned missingLinks = 0x0;
87
88 auto vertex = vertices[0].value();
89 bool hasTrk1 = false;
90 bool hasTrk2 = false;
91 std::uint8_t nSiHits1 = 0;
92 std::uint8_t nSiHits2 = 0;
93 if (m_trackParticleLinksAcc.isAvailable(vertex)) {
94 const auto tracks = m_trackParticleLinksAcc(vertex);
95 if (tracks.size() > 0) {
96 if (tracks[0].has_value()) {
97 hasTrk1 = true;
98 nSiHits1 += m_numberOfPixelHitsAcc(tracks[0].value());
99 nSiHits1 += m_numberOfSCTHitsAcc(tracks[0].value());
100 } else missingLinks |= 0x2;
101 }
102 if (tracks.size() > 1) {
103 if (tracks[1].has_value()) {
104 hasTrk2 = true;
105 nSiHits2 += m_numberOfPixelHitsAcc(tracks[1].value());
106 nSiHits2 += m_numberOfSCTHitsAcc(tracks[1].value());
107 } else missingLinks |= 0x4;
108 }
109 }
110
111 auto conversionType = xAOD::EgammaDetails::conversionType(hasTrk1, hasTrk2, nSiHits1, nSiHits2);
112 return std::make_pair (xAOD::EgammaDetails::isConvertedPhoton (excludeTRT, photon(m_etaAcc), vertices.size(), conversionType), missingLinks);
113 }
114 };
115 }
116}
117
118#endif
Helper functions for EgammaDetails accessors.
the base class for all columnar components
TrackAccessor< std::uint8_t, CM > m_numberOfSCTHitsAcc
ColumnAccessor< CI, std::vector< OptObjectId< ContainerId::vertex, CM > >, CM > m_vertexLinksAcc
IsConvertedPhotonAccessor(ColumnarTool< CM > &columnarTool)
ColumnAccessor< CI, RetypeColumn< xAOD::Type::ObjectType, std::uint16_t >, CM > m_objectTypeAcc
VertexAccessor< std::vector< OptObjectId< ContainerId::track, CM > >, CM > m_trackParticleLinksAcc
std::pair< bool, unsigned > operator()(ObjectId< CI, CM > photon, bool excludeTRT) const
return whether the photon is converted, and a bitmask of missing links
TrackAccessor< std::uint8_t, CM > m_numberOfPixelHitsAcc
a class representing a single object (electron, muons, etc.)
AccessorTemplate< CI, CT, ColumnAccessMode::input, CM > ColumnAccessor
AccessorTemplate< ContainerId::track, CT, ColumnAccessMode::input, CM > TrackAccessor
Definition TrackDef.h:48
void resetAccessor(AccessorTemplate< CI, CT, CAM, CM > &accessor, ColumnarTool< CM > &columnBase, const std::string &name, ColumnInfo &&info={})
reset a column accessor to point to a new column
AccessorTemplate< ContainerId::vertex, CT, ColumnAccessMode::input, CM > VertexAccessor
Definition TrackDef.h:69
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ Photon
The object is a photon.
Definition ObjectType.h:47
ConversionType conversionType(const bool hasTrk1, const bool hasTrk2, const std::uint8_t nSiHits1, const std::uint8_t nSiHits2)
return the photon conversion type (see EgammaEnums)
bool isConvertedPhoton(const bool excludeTRT, const float eta, const std::size_t nVertices, const ConversionType conversionType)
is the object a converted photon