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 > > edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper 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 Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void globalEndJob (const DeepTauCache *cache)
 
static std::unique_ptr< DeepTauCacheinitializeGlobalCache (const edm::ParameterSet &cfg)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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
 

Additional Inherited Members

- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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:184
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.

OutputCollection deep_tau::DeepTauBase::outputs_
protected

Definition at line 100 of file DeepTauBase.h.

Referenced by createOutputs(), and DeepTauBase().

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