CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
DeepTauIdBase< Producer >::IDOutput Struct Reference

#include <DeepTauIdBase.h>

Public Member Functions

template<typename PredType >
std::unique_ptr< TauDiscriminatorget_value (const edm::Handle< TauCollection > &taus, const PredType &pred, const WPList *working_points, bool is_online) const
 
 IDOutput (const std::vector< size_t > &num, const std::vector< size_t > &den)
 
float read_value (const tensorflow::Tensor &pred, size_t tau_index, size_t elem) const
 
float read_value (const std::vector< std::vector< float >> &pred, size_t tau_index, size_t elem) const
 

Public Attributes

std::vector< size_t > den_
 
std::vector< size_t > num_
 

Detailed Description

template<class Producer>
struct DeepTauIdBase< Producer >::IDOutput

Definition at line 856 of file DeepTauIdBase.h.

Constructor & Destructor Documentation

◆ IDOutput()

template<class Producer>
DeepTauIdBase< Producer >::IDOutput::IDOutput ( const std::vector< size_t > &  num,
const std::vector< size_t > &  den 
)
inline

Definition at line 859 of file DeepTauIdBase.h.

859 : num_(num), den_(den) {}
std::vector< size_t > num_
std::vector< size_t > den_

Member Function Documentation

◆ get_value()

template<class Producer>
template<typename PredType >
std::unique_ptr<TauDiscriminator> DeepTauIdBase< Producer >::IDOutput::get_value ( const edm::Handle< TauCollection > &  taus,
const PredType &  pred,
const WPList working_points,
bool  is_online 
) const
inline

Definition at line 871 of file DeepTauIdBase.h.

References DeepTauIdBase< Producer >::IDOutput::den_, trigObjTnPSource_cfi::filler, HLT_2024v14_cff::is_online, SiStripPI::max, DeepTauIdBase< Producer >::IDOutput::num_, convertSQLitetoXML_cfg::output, DeepTauIdBase< Producer >::IDOutput::read_value(), Tau3MuMonitor_cff::taus, FWLite::working_points, l1tPFClustersFromHGC3DClusters_cfi::wp, and x.

874  {
875  std::vector<reco::SingleTauDiscriminatorContainer> outputbuffer(taus->size());
876 
877  for (size_t tau_index = 0; tau_index < taus->size(); ++tau_index) {
878  float x = 0;
879  for (size_t num_elem : num_)
880  x += read_value(pred, tau_index, num_elem);
881  if (x != 0 && !den_.empty()) {
882  float den_val = 0;
883  for (size_t den_elem : den_)
884  den_val += read_value(pred, tau_index, den_elem);
885  x = den_val != 0 ? x / den_val : std::numeric_limits<float>::max();
886  }
887  outputbuffer[tau_index].rawValues.push_back(x);
888  if (working_points) {
889  for (const auto& wp : *working_points) {
890  const bool pass = x > (*wp)(taus->at(tau_index), is_online);
891  outputbuffer[tau_index].workingPoints.push_back(pass);
892  }
893  }
894  }
895  std::unique_ptr<TauDiscriminator> output = std::make_unique<TauDiscriminator>();
897  filler.insert(taus, outputbuffer.begin(), outputbuffer.end());
898  filler.fill();
899  return output;
900  }
std::vector< size_t > num_
working_points
Definition: FWLite.py:140
std::vector< size_t > den_
float read_value(const tensorflow::Tensor &pred, size_t tau_index, size_t elem) const
Definition: output.py:1

◆ read_value() [1/2]

template<class Producer>
float DeepTauIdBase< Producer >::IDOutput::read_value ( const tensorflow::Tensor &  pred,
size_t  tau_index,
size_t  elem 
) const
inline

Definition at line 862 of file DeepTauIdBase.h.

Referenced by DeepTauIdBase< Producer >::IDOutput::get_value().

862  {
863  return pred.matrix<float>()(tau_index, elem);
864  }

◆ read_value() [2/2]

template<class Producer>
float DeepTauIdBase< Producer >::IDOutput::read_value ( const std::vector< std::vector< float >> &  pred,
size_t  tau_index,
size_t  elem 
) const
inline

Definition at line 866 of file DeepTauIdBase.h.

866  {
867  return pred.at(tau_index).at(elem);
868  }

Member Data Documentation

◆ den_

template<class Producer>
std::vector<size_t> DeepTauIdBase< Producer >::IDOutput::den_

Definition at line 857 of file DeepTauIdBase.h.

Referenced by DeepTauIdBase< Producer >::IDOutput::get_value().

◆ num_

template<class Producer>
std::vector<size_t> DeepTauIdBase< Producer >::IDOutput::num_

Definition at line 857 of file DeepTauIdBase.h.

Referenced by DeepTauIdBase< Producer >::IDOutput::get_value().