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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 83 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 76 of file DeepTauBase.cc.

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

79  : tausToken_(consumes<TauCollection>(cfg.getParameter<edm::InputTag>("taus"))),
80  pfcandToken_(consumes<pat::PackedCandidateCollection>(cfg.getParameter<edm::InputTag>("pfcands"))),
81  vtxToken_(consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertices"))),
82  outputs_(outputCollection),
83  cache_(cache) {
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:100
const DeepTauCache * cache_
Definition: DeepTauBase.h:105
OutputCollection outputs_
Definition: DeepTauBase.h:104
def cache(function)
Definition: utilities.py:3
std::map< std::string, WPMap > workingPoints_
Definition: DeepTauBase.h:103
edm::EDGetTokenT< pat::PackedCandidateCollection > pfcandToken_
Definition: DeepTauBase.h:101
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
Definition: DeepTauBase.h:102
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 103 of file DeepTauBase.cc.

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

Referenced by produce().

103  {
104  for (const auto& output_desc : outputs_) {
105  auto result_map = output_desc.second.get_value(taus, pred, workingPoints_.at(output_desc.first));
106  for (auto& result : result_map)
107  event.put(std::move(result.second), output_desc.first + result.first);
108  }
109  }
OutputCollection outputs_
Definition: DeepTauBase.h:104
std::map< std::string, WPMap > workingPoints_
Definition: DeepTauBase.h:103
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 Tau3MuMonitor_cff::taus.

Referenced by DeepTauId::globalEndJob().

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

Definition at line 111 of file DeepTauBase.cc.

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

Referenced by DeepTauId::initializeGlobalCache().

111  {
112  const auto graph_name_vector = cfg.getParameter<std::vector<std::string>>("graph_file");
113  std::map<std::string, std::string> graph_names;
114  for (const auto& entry : graph_name_vector) {
115  const size_t sep_pos = entry.find(':');
116  std::string entry_name, graph_file;
117  if (sep_pos != std::string::npos) {
118  entry_name = entry.substr(0, sep_pos);
119  graph_file = entry.substr(sep_pos + 1);
120  } else {
121  entry_name = "";
122  graph_file = entry;
123  }
124  graph_file = edm::FileInPath(graph_file).fullPath();
125  if (graph_names.count(entry_name))
126  throw cms::Exception("DeepTauCache") << "Duplicated graph entries";
127  graph_names[entry_name] = graph_file;
128  }
129  bool mem_mapped = cfg.getParameter<bool>("mem_mapped");
130  return std::make_unique<DeepTauCache>(graph_names, mem_mapped);
131  }
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 95 of file DeepTauBase.cc.

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

95  {
97  event.getByToken(tausToken_, taus);
98 
99  const tensorflow::Tensor& pred = getPredictions(event, es, taus);
100  createOutputs(event, pred, taus);
101  }
edm::EDGetTokenT< TauCollection > tausToken_
Definition: DeepTauBase.h:100
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:103

Member Data Documentation

const DeepTauCache* deep_tau::DeepTauBase::cache_
protected

Definition at line 105 of file DeepTauBase.h.

OutputCollection deep_tau::DeepTauBase::outputs_
protected

Definition at line 104 of file DeepTauBase.h.

Referenced by createOutputs(), and DeepTauBase().

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

Definition at line 101 of file DeepTauBase.h.

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

Definition at line 100 of file DeepTauBase.h.

Referenced by produce().

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

Definition at line 102 of file DeepTauBase.h.

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

Definition at line 103 of file DeepTauBase.h.

Referenced by createOutputs(), and DeepTauBase().