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< pat::PackedCandidateCollectionpfcandToken_
 
edm::EDGetTokenT< TauCollectiontausToken_
 
edm::EDGetTokenT< reco::VertexCollectionvtxToken_
 
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_.

80  :
81  tausToken_(consumes<TauCollection>(cfg.getParameter<edm::InputTag>("taus"))),
82  pfcandToken_(consumes<pat::PackedCandidateCollection>(cfg.getParameter<edm::InputTag>("pfcands"))),
83  vtxToken_(consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertices"))),
84  outputs_(outputCollection),
85  cache_(cache)
86 {
87  for(const auto& output_desc : outputs_) {
88  produces<TauDiscriminator>(output_desc.first);
89  const auto& cut_pset = cfg.getParameter<edm::ParameterSet>(output_desc.first + "WP");
90  for(const std::string& wp_name : cut_pset.getParameterNames()) {
91  const auto& cut_str = cut_pset.getParameter<std::string>(wp_name);
92  workingPoints_[output_desc.first][wp_name] = std::make_unique<Cutter>(cut_str);
93  produces<TauDiscriminator>(output_desc.first + wp_name);
94  }
95  }
96 }
T getParameter(std::string const &) const
edm::EDGetTokenT< TauCollection > tausToken_
Definition: DeepTauBase.h:98
const DeepTauCache * cache_
Definition: DeepTauBase.h:103
OutputCollection outputs_
Definition: DeepTauBase.h:102
def cache(function)
Definition: utilities.py:3
std::map< std::string, WPMap > workingPoints_
Definition: DeepTauBase.h:101
edm::EDGetTokenT< pat::PackedCandidateCollection > pfcandToken_
Definition: DeepTauBase.h:99
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
Definition: DeepTauBase.h:100
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 107 of file DeepTauBase.cc.

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

Referenced by produce().

108 {
109  for(const auto& output_desc : outputs_) {
110  auto result_map = output_desc.second.get_value(taus, pred, workingPoints_.at(output_desc.first));
111  for(auto& result : result_map)
112  event.put(std::move(result.second), output_desc.first + result.first);
113  }
114 }
OutputCollection outputs_
Definition: DeepTauBase.h:102
std::map< std::string, WPMap > workingPoints_
Definition: DeepTauBase.h:101
def move(src, dest)
Definition: eostools.py:511
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.

Referenced by DeepTauId::globalEndJob().

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

Definition at line 116 of file DeepTauBase.cc.

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

Referenced by DeepTauId::initializeGlobalCache().

117 {
118  const auto graph_name_vector = cfg.getParameter<std::vector<std::string>>("graph_file");
119  std::map<std::string, std::string> graph_names;
120  for(const auto& entry : graph_name_vector) {
121  const size_t sep_pos = entry.find(':');
122  std::string entry_name, graph_file;
123  if(sep_pos != std::string::npos) {
124  entry_name = entry.substr(0, sep_pos);
125  graph_file = entry.substr(sep_pos + 1);
126  } else {
127  entry_name = "";
128  graph_file = entry;
129  }
130  graph_file = edm::FileInPath(graph_file).fullPath();
131  if(graph_names.count(entry_name))
132  throw cms::Exception("DeepTauCache") << "Duplicated graph entries";
133  graph_names[entry_name] = graph_file;
134  }
135  bool mem_mapped = cfg.getParameter<bool>("mem_mapped");
136  return std::make_unique<DeepTauCache>(graph_names, mem_mapped);
137 }
T getParameter(std::string const &) const
std::string fullPath() const
Definition: FileInPath.cc:163
void deep_tau::DeepTauBase::produce ( edm::Event event,
const edm::EventSetup es 
)
override

Definition at line 98 of file DeepTauBase.cc.

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

99 {
101  event.getByToken(tausToken_, taus);
102 
103  const tensorflow::Tensor& pred = getPredictions(event, es, taus);
104  createOutputs(event, pred, taus);
105 }
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:107

Member Data Documentation

const DeepTauCache* deep_tau::DeepTauBase::cache_
protected

Definition at line 103 of file DeepTauBase.h.

OutputCollection deep_tau::DeepTauBase::outputs_
protected

Definition at line 102 of file DeepTauBase.h.

Referenced by createOutputs(), and DeepTauBase().

edm::EDGetTokenT<pat::PackedCandidateCollection> deep_tau::DeepTauBase::pfcandToken_
protected

Definition at line 99 of file DeepTauBase.h.

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

Definition at line 98 of file DeepTauBase.h.

Referenced by produce().

edm::EDGetTokenT<reco::VertexCollection> deep_tau::DeepTauBase::vtxToken_
protected

Definition at line 100 of file DeepTauBase.h.

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

Definition at line 101 of file DeepTauBase.h.

Referenced by createOutputs(), and DeepTauBase().