16 m_feature_extractors.push_back(getFeatureExtractor(input_var.name));
21 std::vector<xAOD::CaloVertexedTopoCluster> clusters;
24 TLorentzVector clusterP4 = vertexedCluster.p4();
26 clusters.push_back(vertexedCluster);
31 return lhs.
p4().Et() > rhs.p4().Et();
33 std::sort(clusters.begin(), clusters.end(), et_cmp);
36 throw std::runtime_error(
"Unsupported sorting order");
39 if (clusters.size() >
m_config.max_n_constituents) {
40 clusters.resize(
m_config.max_n_constituents, clusters[0]);
47 std::vector<int64_t> features_dim = {
static_cast<int64_t
>(tau_clusters.size()),
static_cast<int64_t
>(
m_feature_extractors.size())};
48 std::vector<float> features;
50 for (
const auto& cluster : tau_clusters) {
52 features.push_back(extractor(cluster, *tau));
55 return Inputs{std::move(features), std::move(features_dim)};
60 std::vector<xAOD::CaloVertexedTopoCluster> sorted_tau_cls =
getTauClusters(tau);
61 return std::make_tuple(
getFeatures(tau, sorted_tau_cls), std::vector<const xAOD::IParticle*>{} );
68 }
catch (
const std::out_of_range &e) {
69 throw std::runtime_error(
"Variable '" + var_name +
"' not defined");
73 bool success = func_as_ref(tau, cls, out);
75 throw std::runtime_error(
"Error in cluster variable calculation");
100 out = std::log10(cluster.
p4().Et());
105 out = std::log10(std::max(tau.
pt(), 1
e-6));
115 out = cluster.
eta() - tau.
eta();
120 out = cluster.
p4().DeltaPhi(tau.
p4());
127 out =
static_cast<float>(double_out);
133 const auto success = cluster.
clust().
retrieveMoment(MomentType::SECOND_LAMBDA, double_out);
134 out =
static_cast<float>(double_out);
140 const auto success = cluster.
clust().
retrieveMoment(MomentType::CENTER_LAMBDA, double_out);
141 out =
static_cast<float>(double_out);
147 float ClustersMeanSecondLambda = acc_ClustersMeanSecondLambda(tau);
148 double secondLambda(0);
149 const auto success = cluster.
clust().
retrieveMoment(MomentType::SECOND_LAMBDA, secondLambda);
150 out = (ClustersMeanSecondLambda != 0.) ? secondLambda/ClustersMeanSecondLambda : 0.;
156 float ClustersMeanCenterLambda = acc_ClustersMeanCenterLambda(tau);
157 double centerLambda(0);
158 const auto success = cluster.
clust().
retrieveMoment(MomentType::CENTER_LAMBDA, centerLambda);
159 if (ClustersMeanCenterLambda == 0.){
162 out = centerLambda/ClustersMeanCenterLambda;
165 out = std::min(out, 250.0f);
175 double clusterFirstEngDens = 0.0;
176 bool status = cluster.
clust().
retrieveMoment(MomentType::FIRST_ENG_DENS, clusterFirstEngDens);
177 if (clusterFirstEngDens < 1
e-6) clusterFirstEngDens = 1
e-6;
180 float clusterTotalEnergy = acc_ClusterTotalEnergy(tau);
181 if (clusterTotalEnergy < 1
e-6) clusterTotalEnergy = 1
e-6;
184 float clustersMeanFirstEngDens = acc_ClustersMeanFirstEngDens(tau);
186 out = std::log10(clusterFirstEngDens/clusterTotalEnergy) - clustersMeanFirstEngDens;
193 out = cluster.
p4().E();
198 out = cluster.
p4().Et();
203 double clusterFirstEngDens = 0.0;
204 bool status = cluster.
clust().
retrieveMoment(MomentType::FIRST_ENG_DENS, clusterFirstEngDens);
205 out = clusterFirstEngDens;
210 double clusterEMprob = 0.0;
217 double clusterCenterMag = 0.0;
219 out = clusterCenterMag;
std::function< float(const xAOD::CaloVertexedTopoCluster &, const xAOD::TauJet &)> FeatureFunc_t
ConstituentLoaderTauCluster(const ConstituentsInputConfig &cfg, double max_cluster_dr, bool doVertexCorrection)
static const std::unordered_map< std::string, FeatureFuncAsReference_t > m_func_map
const FTagDataDependencyNames & getDependencies() const override
Inputs getFeatures(const xAOD::TauJet *tau, const std::vector< xAOD::CaloVertexedTopoCluster > &tau_clusters) const
const std::string & getName() const override
std::tuple< Inputs, std::vector< const xAOD::IParticle * > > getData(const xAOD::IParticle &p) const override
const std::set< std::string > & getUsedRemap() const override
bool m_doVertexCorrection
FeatureFunc_t getFeatureExtractor(const std::string &var_name) const
std::vector< xAOD::CaloVertexedTopoCluster > getTauClusters(const xAOD::TauJet *tau) const
std::function< bool(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &, float &)> FeatureFuncAsReference_t
const ConstituentsType & getType() const override
std::vector< FeatureFunc_t > m_feature_extractors
ConstituentsInputConfig m_config
std::set< std::string > m_used_remap
IConstituentsLoader(const ConstituentsInputConfig &cfg)
FTagDataDependencyNames m_deps
Helper class to provide constant type-safe access to aux data.
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
MomentType
Enums to identify different moments.
virtual FourMom_t p4() const final
The full 4-momentum of the particle.
const CaloCluster & clust() const
Return the cluster being proxied,.
virtual double eta() const final
The pseudorapidity ( ) of the particle.
Evaluate cluster kinematics with a different vertex / signal state.
Class providing the definition of the 4-vector interface.
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
virtual FourMom_t p4() const
The full 4-momentum of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
This file contains "getter" functions used for accessing tagger inputs from the EDM.
std::function< float(const xAOD::CaloVertexedTopoCluster &, const xAOD::TauJet &)> FeatureFunc_t
std::function< bool(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &, float &)> FeatureFuncAsReference_t
std::pair< std::vector< float >, std::vector< int64_t > > Inputs
bool et_log(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool FIRST_ENG_DENS(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool et(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool SECOND_LAMBDAOverClustersMeanSecondLambda(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool CENTER_MAG(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
xAOD::CaloCluster::MomentType MomentType
bool CENTER_LAMBDA(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool EM_PROBABILITY(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool CENTER_LAMBDAOverClustersMeanCenterLambda(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool FirstEngDensOverClustersMeanFirstEngDens(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool SECOND_R(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool SECOND_LAMBDA(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool dEta(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool pt_tau_log(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &, float &out)
bool e(const xAOD::TauJet &, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool pt_jetseed_log(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &, float &out)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
TauJet_v3 TauJet
Definition of the current "tau version".