8#include "Math/Vector4D.h"
14using ROOT::Math::PtEtaPhiEVector;
32 std::size_t nParticleOperands = 0;
35 if (kind ==
"PARTICLE") ++nParticleOperands;
36 else if (kind ==
"MET") usesMET =
true;
39 return StatusCode::FAILURE;
45 ANA_MSG_ERROR(
"EXPR: inconsistent operand configuration (particle handles/selections/indices mismatch)");
46 return StatusCode::FAILURE;
49 ANA_MSG_ERROR(
"EXPR: a MET operand was requested but no MET container was configured");
50 return StatusCode::FAILURE;
65 return StatusCode::SUCCESS;
71 struct Kin {
double pt{0.},
eta{0.},
phi{0.},
e{0.};
bool isMET{
false}; };
98 if (term ==
nullptr) {
100 return StatusCode::FAILURE;
113 std::vector<const xAOD::IParticle*> passing;
114 passing.reserve(cont->
size());
117 passing.push_back(p);
119 std::sort(passing.begin(), passing.end(),
121 return a->pt() > b->pt();
125 if (requested < 0 ||
static_cast<std::size_t
>(requested) >= passing.size()) {
126 ANA_MSG_ERROR(
"EXPR: object index " << requested <<
" requested but only "
127 << passing.size() <<
" object(s) pass the selection; this event "
128 "selection cannot run. Add the appropriate multiplicity requirement "
129 "upstream (e.g. JET_N >= ...).");
130 return StatusCode::FAILURE;
145 const double deta = ops[0].eta - ops[1].eta;
146 const double dphi = TVector2::Phi_mpi_pi(ops[0].
phi - ops[1].
phi);
147 value = std::sqrt(deta * deta + dphi * dphi);
148 }
else if (var ==
"dEta") {
149 value = std::abs(ops[0].
eta - ops[1].
eta);
150 }
else if (var ==
"dPhi") {
151 value = std::abs(TVector2::Phi_mpi_pi(ops[0].
phi - ops[1].
phi));
152 }
else if (var ==
"eta") {
154 }
else if (var ==
"phi") {
156 }
else if (var ==
"m" || var ==
"e" || var ==
"pt") {
157 if (ops.size() == 1 && ops[0].isMET) {
162 for (
const Kin &k : ops)
163 sum += PtEtaPhiEVector(k.pt, k.eta, k.phi, k.e);
164 if (var ==
"m") value = sum.M();
165 else if (var ==
"e") value = sum.E();
166 else value = sum.Pt();
170 return StatusCode::FAILURE;
177 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
CP::SysWriteSelectionHandle m_decoration
the output selection decoration
SignEnum::ComparisonOperator m_signEnum
the operator version of the comparison (>, <, etc)
Gaudi::Property< std::string > m_variable
the kinematic variable to compute (dR, dPhi, dEta, m, pt, e, eta, phi)
Gaudi::Property< std::vector< int > > m_indices
per particle-operand pT-ordered index (parallel to the particle handles)
Gaudi::Property< std::string > m_sign
the comparison sign (GT, LT, etc)
virtual StatusCode initialize() override
std::vector< CP::SysReadSelectionHandle > m_selections
the per particle-operand selection handles, built from m_selectionKeys
CP::SysReadSelectionHandle m_preselection
the preselection
CP::SysReadHandle< xAOD::MissingETContainer > m_metHandle
the MET container (used iff any operand is MET)
ObjectKinematicSelectorAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< std::string > m_metTerm
the MET term to use for a MET operand
Gaudi::Property< float > m_refValue
the reference value against which to compare (in MeV / unitless)
CP::SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the event info handle
Gaudi::Property< std::vector< std::string > > m_selectionKeys
the per particle-operand selection keys (parallel to the particle handles)
CP::SysHandleArray< CP::SysReadHandle< xAOD::IParticleContainer > > m_particlesHandles
the particle-operand input containers (one per PARTICLE operand, in order)
CP::SysListHandle m_systematicsList
the systematics list
Gaudi::Property< std::vector< std::string > > m_operandKinds
per-operand kind, in expression order: "PARTICLE" or "MET"
size_type size() const noexcept
Returns the number of elements in the collection.
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual::StatusCode execute()
execute this algorithm
Class providing the definition of the 4-vector interface.
float met() const
Returns .
float phi() const
Returns .
Select isolated Photons, Electrons and Muons.
This module defines the arguments passed from the BATCH driver to the BATCH worker.
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
static const std::map< std::string, ComparisonOperator > stringToOperator
the map between user inputs and comparison operators
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
setRcore setEtHad setFside pt
EventInfo_v1 EventInfo
Definition of the latest event info version.
MissingET_v1 MissingET
Version control by type defintion.
MissingETContainer_v1 MissingETContainer
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.