CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions
deep_tau::DeepTauBase Class Referenceabstract

#include <DeepTauBase.h>

Inheritance diagram for deep_tau::DeepTauBase:
edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > > DeepTauId DPFIsolation

Classes

struct  Output
 

Public Types

using Cutter = TauWPThreshold
 
using CutterPtr = std::unique_ptr< Cutter >
 
using ElectronCollection = pat::ElectronCollection
 
using LorentzVectorXYZ = ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double >>
 
using MuonCollection = pat::MuonCollection
 
using OutputCollection = std::map< std::string, Output >
 
using TauCollection = std::vector< TauType >
 
using TauDiscriminator = pat::PATTauDiscriminator
 
using TauRef = edm::Ref< TauCollection >
 
using TauRefProd = edm::RefProd< TauCollection >
 
using TauType = pat::Tau
 
using WPMap = std::map< std::string, CutterPtr >
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

 DeepTauBase (const edm::ParameterSet &cfg, const OutputCollection &outputs, const DeepTauCache *cache)
 
void produce (edm::Event &event, const edm::EventSetup &es) override
 
 ~DeepTauBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > >
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void globalEndJob (const DeepTauCache *cache)
 
static std::unique_ptr< DeepTauCacheinitializeGlobalCache (const edm::ParameterSet &cfg)
 

Protected Attributes

const DeepTauCachecache_
 
OutputCollection outputs_
 
edm::EDGetTokenT< TauCollectiontausToken_
 
std::map< std::string, WPMapworkingPoints_
 

Private Member Functions

virtual void createOutputs (edm::Event &event, const tensorflow::Tensor &pred, edm::Handle< TauCollection > taus)
 
virtual tensorflow::Tensor getPredictions (edm::Event &event, const edm::EventSetup &es, edm::Handle< TauCollection > taus)=0
 

Detailed Description

Definition at line 58 of file DeepTauBase.h.

Member Typedef Documentation

Definition at line 68 of file DeepTauBase.h.

using deep_tau::DeepTauBase::CutterPtr = std::unique_ptr<Cutter>

Definition at line 69 of file DeepTauBase.h.

Definition at line 65 of file DeepTauBase.h.

Definition at line 67 of file DeepTauBase.h.

Definition at line 66 of file DeepTauBase.h.

using deep_tau::DeepTauBase::OutputCollection = std::map<std::string, Output>

Definition at line 82 of file DeepTauBase.h.

Definition at line 62 of file DeepTauBase.h.

Definition at line 61 of file DeepTauBase.h.

Definition at line 63 of file DeepTauBase.h.

Definition at line 64 of file DeepTauBase.h.

Definition at line 60 of file DeepTauBase.h.

using deep_tau::DeepTauBase::WPMap = std::map<std::string, CutterPtr>

Definition at line 70 of file DeepTauBase.h.

Constructor & Destructor Documentation

deep_tau::DeepTauBase::DeepTauBase ( const edm::ParameterSet cfg,
const OutputCollection outputs,
const DeepTauCache cache 
)

Definition at line 79 of file DeepTauBase.cc.

References edm::ParameterSet::getParameter(), outputs_, AlCaHLTBitMon_QueryRunRegistry::string, and workingPoints_.

79  :
80  tausToken_(consumes<TauCollection>(cfg.getParameter<edm::InputTag>("taus"))),
81  outputs_(outputCollection),
82  cache_(cache)
83 {
84  for(const auto& output_desc : outputs_) {
85  produces<TauDiscriminator>(output_desc.first);
86  const auto& cut_pset = cfg.getParameter<edm::ParameterSet>(output_desc.first + "WP");
87  for(const std::string& wp_name : cut_pset.getParameterNames()) {
88  const auto& cut_str = cut_pset.getParameter<std::string>(wp_name);
89  workingPoints_[output_desc.first][wp_name] = std::make_unique<Cutter>(cut_str);
90  produces<TauDiscriminator>(output_desc.first + wp_name);
91  }
92  }
93 }
T getParameter(std::string const &) const
edm::EDGetTokenT< TauCollection > tausToken_
Definition: DeepTauBase.h:98
const DeepTauCache * cache_
Definition: DeepTauBase.h:101
OutputCollection outputs_
Definition: DeepTauBase.h:100
def cache(function)
std::map< std::string, WPMap > workingPoints_
Definition: DeepTauBase.h:99
deep_tau::DeepTauBase::~DeepTauBase ( )
inlineoverride

Definition at line 86 of file DeepTauBase.h.

References looper::cfg.

86 {}

Member Function Documentation

void deep_tau::DeepTauBase::createOutputs ( edm::Event event,
const tensorflow::Tensor &  pred,
edm::Handle< TauCollection taus 
)
privatevirtual

Definition at line 104 of file DeepTauBase.cc.

References eostools::move(), outputs_, mps_fire::result, and workingPoints_.

Referenced by produce().

105 {
106  for(const auto& output_desc : outputs_) {
107  auto result_map = output_desc.second.get_value(taus, pred, workingPoints_.at(output_desc.first));
108  for(auto& result : result_map)
109  event.put(std::move(result.second), output_desc.first + result.first);
110  }
111 }
OutputCollection outputs_
Definition: DeepTauBase.h:100
std::map< std::string, WPMap > workingPoints_
Definition: DeepTauBase.h:99
def move(src, dest)
Definition: eostools.py:510
virtual tensorflow::Tensor deep_tau::DeepTauBase::getPredictions ( edm::Event event,
const edm::EventSetup es,
edm::Handle< TauCollection taus 
)
privatepure virtual

Implemented in DeepTauId, and DPFIsolation.

Referenced by produce().

static void deep_tau::DeepTauBase::globalEndJob ( const DeepTauCache cache)
inlinestatic

Definition at line 91 of file DeepTauBase.h.

References nano_cff::taus.

91 { }
std::unique_ptr< DeepTauCache > deep_tau::DeepTauBase::initializeGlobalCache ( const edm::ParameterSet cfg)
static

Definition at line 113 of file DeepTauBase.cc.

References edm::FileInPath::fullPath(), edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

114 {
115  std::string graph_name = edm::FileInPath(cfg.getParameter<std::string>("graph_file")).fullPath();
116  bool mem_mapped = cfg.getParameter<bool>("mem_mapped");
117  return std::make_unique<DeepTauCache>(graph_name, mem_mapped);
118 }
T getParameter(std::string const &) const
std::string fullPath() const
Definition: FileInPath.cc:197
void deep_tau::DeepTauBase::produce ( edm::Event event,
const edm::EventSetup es 
)
override

Definition at line 95 of file DeepTauBase.cc.

References createOutputs(), getPredictions(), nano_cff::taus, and tausToken_.

96 {
98  event.getByToken(tausToken_, taus);
99 
100  const tensorflow::Tensor& pred = getPredictions(event, es, taus);
101  createOutputs(event, pred, taus);
102 }
edm::EDGetTokenT< TauCollection > tausToken_
Definition: DeepTauBase.h:98
virtual tensorflow::Tensor getPredictions(edm::Event &event, const edm::EventSetup &es, edm::Handle< TauCollection > taus)=0
virtual void createOutputs(edm::Event &event, const tensorflow::Tensor &pred, edm::Handle< TauCollection > taus)
Definition: DeepTauBase.cc:104

Member Data Documentation

const DeepTauCache* deep_tau::DeepTauBase::cache_
protected

Definition at line 101 of file DeepTauBase.h.

Referenced by DPFIsolation::DPFIsolation(), and DPFIsolation::getPredictions().

OutputCollection deep_tau::DeepTauBase::outputs_
protected
edm::EDGetTokenT<TauCollection> deep_tau::DeepTauBase::tausToken_
protected

Definition at line 98 of file DeepTauBase.h.

Referenced by produce().

std::map<std::string, WPMap> deep_tau::DeepTauBase::workingPoints_
protected

Definition at line 99 of file DeepTauBase.h.

Referenced by createOutputs(), and DeepTauBase().