8#ifndef COLUMNAR_MET_MET_HELPERS_H
9#define COLUMNAR_MET_MET_HELPERS_H
37 template<ContainerIdConcept CI = ContainerId::met,
typename CM=ColumnarModeDefault>
40 template<ContainerIdConcept CI>
50 return metMap.getXAODObject()[metKey];
55 auto result = metMap.getXAODObject()[metKey];
57 throw std::runtime_error (
"MET object does not have the requested term: " + metKey);
63 if (
met::fillMET(metPtr, &metMap.getXAODObject(), metKey, metSource).isFailure())
64 throw std::runtime_error (
"failed to fill MET term \"" + metKey +
"\"");
69 auto iter = metMap.getXAODObject().find (metKey);
70 if (iter != metMap.getXAODObject().end() && *iter !=
nullptr)
71 return StatusCode::SUCCESS;
73 if (
met::fillMET(metPtr, &metMap.getXAODObject(), metKey, metSource).isFailure())
74 return StatusCode::FAILURE;
75 return StatusCode::SUCCESS;
79 template<ContainerIdConcept CI>
105 auto hash = std::hash<std::string>()(metKey);
106 for (
auto metObj : metMap)
121 auto result = operator() (metMap, metKey);
123 throw std::runtime_error (
"MET object does not have the requested term: " + metKey);
128 auto hash = std::hash<std::string>()(metKey);
129 for (
auto metObj : metMap)
134 throw std::runtime_error (
"MET object already has the requested term: " + metKey);
139 throw std::runtime_error (
"MET object does not have the requested term pre-placed: " + metKey);
144 auto hash = std::hash<std::string>()(metKey);
145 for (
auto metObj : metMap)
151 return StatusCode::SUCCESS;
154 throw std::runtime_error (
"MET object does not have the requested term pre-placed: " + metKey);
166 template<ContainerIdConcept CI = ContainerId::met,
typename CM=ColumnarModeDefault>
174 :
mpx (columnarBase,
"mpx"),
175 mpy (columnarBase,
"mpy"),
176 sumet (columnarBase,
"sumet")
184 return std::hypot(
mpx(
object),
mpy(
object));}
186 return std::atan2(
mpy(
object),
mpx(
object));}
191 auto p4 = particle.p4();
193 template<ContainerIdConcept CI2,
typename MomAcc>
195 this->
addParticle(
met, momAcc.px(
object), momAcc.py(
object), momAcc.pt(
object));}
196 template<ContainerIdConcept CI2>
198 mpx(
met) += momAcc.mpx(metSource);
mpy(
met) += momAcc.mpy(metSource);
sumet(
met) += momAcc.sumet(metSource);}
the raw column accessor template class
StatusCode tryCreateIfMissing(ObjectRange< CI, CM > metMap, const std::string &metKey, const MissingETBase::Types::bitmask_t metSource) const
ColumnAccessor< CI, std::size_t, CM > m_nameHashAcc
AccessorTemplate< CI, MissingETBase::Types::bitmask_t, CI::isMutable?ColumnAccessMode::output:ColumnAccessMode::input, CM > m_sourceAcc
ObjectId< CI > fillMET(ObjectRange< CI, CM > metMap, const std::string &metKey, const MissingETBase::Types::bitmask_t metSource) const
MapLookupAccessor(ColumnarTool< CM > &columnBase)
static constexpr MissingETBase::Types::bitmask_t m_nullSource
ObjectId< CI, CM > getRequired(ObjectRange< CI, CM > metMap, const std::string &metKey) const
ObjectId< CI > fillMET(ObjectRange< CI, CM > metMap, const std::string &metKey, const MissingETBase::Types::bitmask_t metSource) const
ObjectId< CI, CM > getRequired(ObjectRange< CI, CM > metMap, const std::string &metKey) const
MapLookupAccessor(ColumnarTool< CM > &)
StatusCode tryCreateIfMissing(ObjectRange< CI, CM > metMap, const std::string &metKey, const MissingETBase::Types::bitmask_t metSource) const
a special "accessor" that allows to do the MET term lookup by name
a class representing a single object (electron, muons, etc.)
a class representing a continuous sequence of objects (a.k.a. a container)
a class representing a single optional object (electron, muons, etc.)
Class providing the definition of the 4-vector interface.
uint64_t bitmask_t
Type for status word bit mask.
AccessorTemplate< CI, CT, ColumnAccessMode::input, CM > ColumnAccessor
ColumnAccessMode
an enum for the different access modes for a column
StatusCode fillMET(xAOD::MissingET *&met, xAOD::MissingETContainer *metCont, const std::string &metKey, const MissingETBase::Types::bitmask_t metSource)
MissingET_v1 MissingET
Version control by type defintion.
double met(ObjectId< CI, CM > object) const
void addParticle(ObjectId< CI, CM > met, const xAOD::IParticle &particle) const
void addMet(ObjectId< CI, CM > met, const MetMomentumAccessors< CI2, CM > &momAcc, ObjectId< CI2, CM > metSource) const
void addParticle(ObjectId< CI, CM > met, const MomAcc &momAcc, const ObjectId< CI2, CM > &object) const
AccessorTemplate< CI, float, CAM, CM > sumet
MetMomentumAccessors(ColumnarTool< CM > &columnarBase)
AccessorTemplate< CI, float, CAM, CM > mpy
static constexpr ColumnAccessMode CAM
double phi(ObjectId< CI, CM > object) const
AccessorTemplate< CI, float, CAM, CM > mpx
static constexpr bool isMutable
void addParticle(ObjectId< CI, CM > met, float px, float py, float pt) const
std::map< std::string, HypoJetVector >::const_iterator CI