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 = reco::TauDiscriminatorContainer
 
using TauRef = edm::Ref< TauCollection >
 
using TauRefProd = edm::RefProd< TauCollection >
 
using TauType = pat::Tau
 
using WPList = std::vector< 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, WPListworkingPoints_
 

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

◆ Cutter

Definition at line 68 of file DeepTauBase.h.

◆ CutterPtr

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

Definition at line 69 of file DeepTauBase.h.

◆ ElectronCollection

Definition at line 65 of file DeepTauBase.h.

◆ LorentzVectorXYZ

using deep_tau::DeepTauBase::LorentzVectorXYZ = ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> >

Definition at line 67 of file DeepTauBase.h.

◆ MuonCollection

Definition at line 66 of file DeepTauBase.h.

◆ OutputCollection

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

Definition at line 82 of file DeepTauBase.h.

◆ TauCollection

Definition at line 62 of file DeepTauBase.h.

◆ TauDiscriminator

Definition at line 61 of file DeepTauBase.h.

◆ TauRef

Definition at line 63 of file DeepTauBase.h.

◆ TauRefProd

Definition at line 64 of file DeepTauBase.h.

◆ TauType

Definition at line 60 of file DeepTauBase.h.

◆ WPList

Definition at line 70 of file DeepTauBase.h.

Constructor & Destructor Documentation

◆ DeepTauBase()

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

Definition at line 76 of file DeepTauBase.cc.

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_list = cfg.getParameter<std::vector<std::string>>(output_desc.first + "WP");
87  for (const std::string& cut_str : cut_list) {
88  workingPoints_[output_desc.first].push_back(std::make_unique<Cutter>(cut_str));
89  }
90  }
91  }

References looper::cfg, outputs_, AlCaHLTBitMon_QueryRunRegistry::string, and workingPoints_.

◆ ~DeepTauBase()

deep_tau::DeepTauBase::~DeepTauBase ( )
inlineoverride

Definition at line 85 of file DeepTauBase.h.

85 {}

Member Function Documentation

◆ createOutputs()

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

Definition at line 101 of file DeepTauBase.cc.

101  {
102  for (const auto& output_desc : outputs_) {
103  auto result = output_desc.second.get_value(taus, pred, workingPoints_.at(output_desc.first));
104  event.put(std::move(result), output_desc.first);
105  }
106  }

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

Referenced by produce().

◆ getPredictions()

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().

◆ globalEndJob()

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

Definition at line 90 of file DeepTauBase.h.

90 {}

◆ initializeGlobalCache()

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

Definition at line 108 of file DeepTauBase.cc.

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

References looper::cfg, mps_splice::entry, edm::FileInPath::fullPath(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ produce()

void deep_tau::DeepTauBase::produce ( edm::Event event,
const edm::EventSetup es 
)
override

Definition at line 93 of file DeepTauBase.cc.

93  {
95  event.getByToken(tausToken_, taus);
96 
97  const tensorflow::Tensor& pred = getPredictions(event, es, taus);
98  createOutputs(event, pred, taus);
99  }

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

Member Data Documentation

◆ cache_

const DeepTauCache* deep_tau::DeepTauBase::cache_
protected

◆ outputs_

OutputCollection deep_tau::DeepTauBase::outputs_
protected

◆ pfcandToken_

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

Definition at line 100 of file DeepTauBase.h.

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

◆ tausToken_

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

Definition at line 99 of file DeepTauBase.h.

Referenced by produce().

◆ vtxToken_

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

Definition at line 101 of file DeepTauBase.h.

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

◆ workingPoints_

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

Definition at line 102 of file DeepTauBase.h.

Referenced by createOutputs(), and DeepTauBase().

deep_tau::DeepTauBase::cache_
const DeepTauCache * cache_
Definition: DeepTauBase.h:104
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
mps_splice.entry
entry
Definition: mps_splice.py:68
deep_tau::DeepTauBase::pfcandToken_
edm::EDGetTokenT< pat::PackedCandidateCollection > pfcandToken_
Definition: DeepTauBase.h:100
deep_tau::DeepTauBase::vtxToken_
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
Definition: DeepTauBase.h:101
edm::Handle< TauCollection >
edm::FileInPath
Definition: FileInPath.h:64
deep_tau::DeepTauBase::workingPoints_
std::map< std::string, WPList > workingPoints_
Definition: DeepTauBase.h:102
utilities.cache
def cache(function)
Definition: utilities.py:3
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
deep_tau::DeepTauBase::outputs_
OutputCollection outputs_
Definition: DeepTauBase.h:103
looper.cfg
cfg
Definition: looper.py:297
deep_tau::DeepTauBase::getPredictions
virtual tensorflow::Tensor getPredictions(edm::Event &event, const edm::EventSetup &es, edm::Handle< TauCollection > taus)=0
eostools.move
def move(src, dest)
Definition: eostools.py:511
deep_tau::DeepTauBase::createOutputs
virtual void createOutputs(edm::Event &event, const tensorflow::Tensor &pred, edm::Handle< TauCollection > taus)
Definition: DeepTauBase.cc:101
mps_fire.result
result
Definition: mps_fire.py:303
cms::Exception
Definition: Exception.h:70
event
Definition: event.py:1
deep_tau::DeepTauBase::tausToken_
edm::EDGetTokenT< TauCollection > tausToken_
Definition: DeepTauBase.h:99
edm::InputTag
Definition: InputTag.h:15
edm::FileInPath::fullPath
std::string fullPath() const
Definition: FileInPath.cc:163