CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DeepTauIdSonicProducer Class Reference
Inheritance diagram for DeepTauIdSonicProducer:
DeepTauIdBase< TritonEDProducer<> > TritonEDProducerT< G, Capabilities > SonicEDProducer< TritonClient, edm::GlobalCache< G >, Capabilities... > SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > > edm::stream::EDProducer< edm::ExternalWork, Capabilities... >

Public Member Functions

void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, Input &iInput) override
 
 DeepTauIdSonicProducer (edm::ParameterSet const &cfg)
 
void produce (edm::Event &iEvent, edm::EventSetup const &iSetup, Output const &iOutput) override
 
- Public Member Functions inherited from DeepTauIdBase< TritonEDProducer<> >
 DeepTauIdBase (const edm::ParameterSet &cfg)
 
const std::map< BasicDiscriminator, size_t > matchDiscriminatorIndices (edm::Event const &event, edm::EDGetTokenT< reco::TauDiscriminatorContainer > discriminatorContainerToken, std::vector< BasicDiscriminator > requiredDiscr)
 
- Public Member Functions inherited from TritonEDProducerT< G, Capabilities >
void endStream () final
 
 TritonEDProducerT (edm::ParameterSet const &cfg)
 
virtual void tritonEndStream ()
 
- Public Member Functions inherited from SonicEDProducer< TritonClient, edm::GlobalCache< G >, Capabilities... >
void produce (edm::Event &iEvent, edm::EventSetup const &iSetup) final
 
virtual void produce (edm::Event &iEvent, edm::EventSetup const &iSetup, Output const &iOutput)=0
 
 SonicEDProducer (edm::ParameterSet const &cfg)
 
 ~SonicEDProducer () override=default
 
- Public Member Functions inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder holder) final
 
virtual void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, Input &iInput)=0
 
void beginStream (edm::StreamID) override
 
 SonicAcquirer (edm::ParameterSet const &cfg)
 
 ~SonicAcquirer () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork, Capabilities... >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from DeepTauIdBase< TritonEDProducer<> >
static void fillDescriptionsHelper (edm::ParameterSetDescription &desc)
 
static const IDOutputCollectionGetIDOutputs ()
 
- Static Public Member Functions inherited from TritonEDProducerT< G, Capabilities >
static void globalEndJob (G *)
 
static std::unique_ptr< G > initializeGlobalCache (edm::ParameterSet const &pset)
 

Private Member Functions

template<typename CandidateCastType , typename TauCastType >
void createConvFeatures (const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const CellGrid &grid, const TauFunc &tau_funcs, bool is_inner, std::vector< float > *p_egammaBlockInputs, std::vector< float > *p_muonBlockInputs, std::vector< float > *p_hadronBlockInputs, std::vector< int64_t > *p_GridposInputs)
 
template<typename CandidateCastType , typename TauCastType >
void prepareInputsV2 (TauCollection::const_reference &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const std::vector< pat::Electron > *electrons, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const reco::Vertex &pv, double rho, const TauFunc &tau_funcs)
 

Private Attributes

std::vector< float > * p_egammaInnerBlockInputs
 
std::vector< float > * p_egammaOuterBlockInputs
 
std::vector< float > * p_hadronInnerBlockInputs
 
std::vector< float > * p_hadronOuterBlockInputs
 
std::vector< int64_t > * p_innerGridposInputs
 
std::vector< float > * p_muonInnerBlockInputs
 
std::vector< float > * p_muonOuterBlockInputs
 
std::vector< int64_t > * p_outerGridposInputs
 
std::vector< float > * p_tauBlockInputs
 
std::vector< size_t > tau_indices_
 

Additional Inherited Members

- Public Types inherited from DeepTauIdBase< TritonEDProducer<> >
using BasicDiscriminator = deep_tau::BasicDiscriminator
 
using CandidateCollection = edm::View< reco::Candidate >
 
using Cutter = tau::TauWPThreshold
 
using CutterPtr = std::unique_ptr< Cutter >
 
using ElectronCollection = pat::ElectronCollection
 
using IDOutputCollection = std::map< std::string, IDOutput >
 
using LorentzVectorXYZ = ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > >
 
using MuonCollection = pat::MuonCollection
 
using TauCollection = edm::View< reco::BaseTau >
 
using TauDiscriminator = reco::TauDiscriminatorContainer
 
using TauRef = edm::Ref< TauCollection >
 
using TauRefProd = edm::RefProd< TauCollection >
 
using WPList = std::vector< CutterPtr >
 
- Public Types inherited from SonicEDProducer< TritonClient, edm::GlobalCache< G >, Capabilities... >
typedef TritonClient ::Output Output
 
- Public Types inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
typedef TritonClient ::Input Input
 
- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork, Capabilities... >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Public Attributes inherited from DeepTauIdBase< TritonEDProducer<> >
uint8_t andPrediscriminants_
 
std::vector< TauDiscInfo< pat::PATTauDiscriminator > > patPrediscriminants_
 
std::vector< TauDiscInfo< reco::PFTauDiscriminator > > recoPrediscriminants_
 
- Static Public Attributes inherited from DeepTauIdBase< TritonEDProducer<> >
static constexpr float default_value
 
- Protected Member Functions inherited from DeepTauIdBase< TritonEDProducer<> >
void createEgammaBlockInputs (unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Electron > *electrons, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner, EgammaBlockType &egammaBlockInputs)
 
void createHadronsBlockInputs (unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner, HadronBlockType &hadronBlockInputs)
 
void createMuonBlockInputs (unsigned idx, const TauCastType &tau, const size_t tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, const std::vector< pat::Muon > *muons, const edm::View< reco::Candidate > &pfCands, const Cell &cell_map, TauFunc tau_funcs, bool is_inner, MuonBlockType &muonBlockInputs)
 
void createOutputs (edm::Event &event, const PredType &pred, edm::Handle< TauCollection > taus)
 
void createTauBlockInputs (const TauCastType &tau, const size_t &tau_index, const edm::RefToBase< reco::BaseTau > tau_ref, const reco::Vertex &pv, double rho, TauFunc tau_funcs, TauBlockType &tauBlockInputs)
 
void fillGrids (const TauCastType &tau, const Collection &objects, CellGrid &inner_grid, CellGrid &outer_grid)
 
void loadPrediscriminants (edm::Event const &event, edm::Handle< TauCollection > const &taus)
 
- Protected Member Functions inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
void makeClient ()
 
- Static Protected Member Functions inherited from DeepTauIdBase< TritonEDProducer<> >
static void calculateElectronClusterVars (const pat::Electron *ele, float &elecEe, float &elecEgamma)
 
static bool calculateElectronClusterVarsV2 (const pat::Electron &ele, float &cc_ele_energy, float &cc_gamma_energy, int &cc_n_gamma)
 
static bool calculateGottfriedJacksonAngleDifference (const TauCastType &tau, const size_t tau_index, double &gj_diff, TauFunc tau_funcs)
 
static float calculateGottfriedJacksonAngleDifference (const TauCastType &tau, const size_t tau_index, TauFunc tau_funcs)
 
static const pat::ElectronfindMatchedElectron (const TauCastType &tau, const std::vector< pat::Electron > *electrons, double deltaR)
 
static double getInnerSignalConeRadius (double pt)
 
static float getValue (T value)
 
static float getValueLinear (T value, float min_value, float max_value, bool positive)
 
static float getValueNorm (T value, float mean, float sigma, float n_sigmas_max=5)
 
static bool isAbove (double value, double min)
 
static bool isInEcalCrack (double eta)
 
static void processIsolationPFComponents (const TauCastType &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4, float &pt, float &d_eta, float &d_phi, float &m, float &n)
 
static void processSignalPFComponents (const TauCastType &tau, const CandidateCollection &candidates, LorentzVectorXYZ &p4_inner, LorentzVectorXYZ &p4_outer, float &pt_inner, float &dEta_inner, float &dPhi_inner, float &m_inner, float &pt_outer, float &dEta_outer, float &dPhi_outer, float &m_outer, float &n_inner, float &n_outer)
 
- Protected Attributes inherited from DeepTauIdBase< TritonEDProducer<> >
std::map< BasicDiscriminator, size_t > basicDiscrdR03IndexMap_
 
std::map< BasicDiscriminator, size_t > basicDiscrIndexMap_
 
edm::EDGetTokenT< reco::TauDiscriminatorContainerbasicTauDiscriminators_inputToken_
 
edm::EDGetTokenT< reco::TauDiscriminatorContainerbasicTauDiscriminatorsdR03_inputToken_
 
const int debug_level
 
const bool disable_CellIndex_workaround_
 
const bool disable_dxy_pca_
 
const bool disable_hcalFraction_workaround_
 
bool discrIndicesMapped_
 
edm::EDGetTokenT< std::vector< pat::Electron > > electrons_token_
 
int file_counter_
 
IDOutputCollection idoutputs_
 
std::string input_layer_
 
bool is_first_block_
 
const bool is_online_
 
std::ofstream * json_file_
 
edm::EDGetTokenT< std::vector< pat::Muon > > muons_token_
 
std::string output_layer_
 
edm::EDGetTokenT< CandidateCollectionpfcandToken_
 
edm::EDGetTokenT< edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > > pfTauTransverseImpactParameters_token_
 
const std::vector< BasicDiscriminatorrequiredBasicDiscriminators_
 
const std::vector< BasicDiscriminatorrequiredBasicDiscriminatorsdR03_
 
edm::EDGetTokenT< double > rho_token_
 
const bool save_inputs_
 
const std::map< std::pair< deep_tau::Scaling::FeatureT, bool >, deep_tau::Scaling::ScalingParams > * scalingParamsMap_
 
const std::map< BasicDiscriminator, std::string > stringFromDiscriminator_
 
const unsigned sub_version_
 
std::vector< int > tauInputs_indices_
 
edm::EDGetTokenT< TauCollectiontausToken_
 
const unsigned version_
 
edm::EDGetTokenT< reco::VertexCollectionvtxToken_
 
std::map< std::string, WPListworkingPoints_
 
const unsigned year_
 
- Protected Attributes inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
std::unique_ptr< TritonClientclient_
 
edm::ParameterSet clientPset_
 
std::string debugName_
 
std::chrono::time_point< std::chrono::high_resolution_clock > t_dispatch_
 
bool verbose_
 
- Static Protected Attributes inherited from DeepTauIdBase< TritonEDProducer<> >
static constexpr float pi
 

Detailed Description

Definition at line 11 of file DeepTauIdSONIC.cc.

Constructor & Destructor Documentation

◆ DeepTauIdSonicProducer()

DeepTauIdSonicProducer::DeepTauIdSonicProducer ( edm::ParameterSet const &  cfg)
inlineexplicit

Member Function Documentation

◆ acquire()

void DeepTauIdSonicProducer::acquire ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup,
Input iInput 
)
override

Definition at line 61 of file DeepTauIdSONIC.cc.

References DeepTauIdBase< TritonEDProducer<> >::andPrediscriminants_, DeepTauIdBase< TritonEDProducer<> >::basicDiscrdR03IndexMap_, DeepTauIdBase< TritonEDProducer<> >::basicDiscrIndexMap_, HLT_2024v12_cff::basicTauDiscriminators, DeepTauIdBase< TritonEDProducer<> >::basicTauDiscriminators_inputToken_, HLT_2024v12_cff::basicTauDiscriminatorsdR03, DeepTauIdBase< TritonEDProducer<> >::basicTauDiscriminatorsdR03_inputToken_, SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::client_, DeepTauIdBase< TritonEDProducer<> >::discrIndicesMapped_, DeepTauIdBase< TritonEDProducer<> >::electrons_token_, iEvent, DeepTauIdBase< TritonEDProducer<> >::is_online_, DeepTauIdBase< TritonEDProducer<> >::loadPrediscriminants(), DeepTauIdBase< TritonEDProducer<> >::matchDiscriminatorIndices(), DeepTauIdBase< TritonEDProducer<> >::muons_token_, p_egammaInnerBlockInputs, p_egammaOuterBlockInputs, p_hadronInnerBlockInputs, p_hadronOuterBlockInputs, p_innerGridposInputs, p_muonInnerBlockInputs, p_muonOuterBlockInputs, p_outerGridposInputs, p_tauBlockInputs, DeepTauIdBase< TritonEDProducer<> >::patPrediscriminants_, DeepTauIdBase< TritonEDProducer<> >::pfcandToken_, HLT_2024v12_cff::pfTauTransverseImpactParameters, DeepTauIdBase< TritonEDProducer<> >::pfTauTransverseImpactParameters_token_, DeepTauIdBase< TritonEDProducer<> >::recoPrediscriminants_, DeepTauIdBase< TritonEDProducer<> >::requiredBasicDiscriminators_, DeepTauIdBase< TritonEDProducer<> >::requiredBasicDiscriminatorsdR03_, rho, DeepTauIdBase< TritonEDProducer<> >::rho_token_, tau_indices_, Tau3MuMonitor_cff::taus, DeepTauIdBase< TritonEDProducer<> >::tausToken_, AlignmentTracksFromVertexSelector_cfi::vertices, and DeepTauIdBase< TritonEDProducer<> >::vtxToken_.

61  {
63  iEvent.getByToken(tausToken_, taus);
64 
66 
67  const std::vector<pat::Electron> electron_collection_default;
68  const std::vector<pat::Muon> muon_collection_default;
69  const reco::TauDiscriminatorContainer basicTauDiscriminators_default;
70  const reco::TauDiscriminatorContainer basicTauDiscriminatorsdR03_default;
72  pfTauTransverseImpactParameters_default;
73 
74  const std::vector<pat::Electron>* electron_collection;
75  const std::vector<pat::Muon>* muon_collection;
80 
81  if (!is_online_) {
82  electron_collection = &iEvent.get(electrons_token_);
83  muon_collection = &iEvent.get(muons_token_);
84  pfTauTransverseImpactParameters = &pfTauTransverseImpactParameters_default;
85  basicTauDiscriminators = &basicTauDiscriminators_default;
86  basicTauDiscriminatorsdR03 = &basicTauDiscriminatorsdR03_default;
87  } else {
88  electron_collection = &electron_collection_default;
89  muon_collection = &muon_collection_default;
93 
94  // Get indices for discriminators
95  if (!discrIndicesMapped_) {
100  discrIndicesMapped_ = true;
101  }
102  }
103 
104  TauFunc tauIDs = {basicTauDiscriminators,
109 
111  iEvent.getByToken(pfcandToken_, pfCands);
112 
114  iEvent.getByToken(vtxToken_, vertices);
115 
117  iEvent.getByToken(rho_token_, rho);
118 
119  // vector to store the indices for the taus passing the selections
120  tau_indices_.clear();
121 
122  for (size_t tau_index = 0; tau_index < taus->size(); ++tau_index) {
123  const edm::RefToBase<reco::BaseTau> tauRef = taus->refAt(tau_index);
124  bool passesPrediscriminants;
125  if (is_online_) {
126  passesPrediscriminants = tauIDs.passPrediscriminants<std::vector<TauDiscInfo<reco::PFTauDiscriminator>>>(
128  } else {
129  passesPrediscriminants = tauIDs.passPrediscriminants<std::vector<TauDiscInfo<pat::PATTauDiscriminator>>>(
131  }
132  if (!passesPrediscriminants)
133  continue;
134 
135  // tau index that passes the selection
136  tau_indices_.push_back(tau_index);
137  }
138 
139  if (tau_indices_.empty()) {
140  // no tau passing the requirement
141  // no need to run acquire and inference
142  client_->setBatchSize(0);
143  return;
144  }
145 
146  int n_taus = tau_indices_.size();
147  // for the regular non-split deep-tau model, set the
148  // batch size to the number of taus per event
149  client_->setBatchSize(n_taus);
150 
151  auto& input_tauBlock = iInput.at("input_tau");
152  auto& input_innerEgammaBlock = iInput.at("input_inner_egamma");
153  auto& input_outerEgammaBlock = iInput.at("input_outer_egamma");
154  auto& input_innerMuonBlock = iInput.at("input_inner_muon");
155  auto& input_outerMuonBlock = iInput.at("input_outer_muon");
156  auto& input_innerHadronBlock = iInput.at("input_inner_hadrons");
157  auto& input_outerHadronBlock = iInput.at("input_outer_hadrons");
158 
159  p_innerGridposInputs = nullptr;
160  p_outerGridposInputs = nullptr;
161 
162  auto data_tauBlock = input_tauBlock.allocate<float>();
163  auto data_innerEgammaBlock = input_innerEgammaBlock.allocate<float>();
164  auto data_outerEgammaBlock = input_outerEgammaBlock.allocate<float>();
165  auto data_innerMuonBlock = input_innerMuonBlock.allocate<float>();
166  auto data_outerMuonBlock = input_outerMuonBlock.allocate<float>();
167  auto data_innerHadronBlock = input_innerHadronBlock.allocate<float>();
168  auto data_outerHadronBlock = input_outerHadronBlock.allocate<float>();
169 
170  for (unsigned itau_passed = 0; itau_passed < tau_indices_.size(); ++itau_passed) {
171  // batch size is not one, needs to go to corresponding itau
172  p_tauBlockInputs = &((*data_tauBlock)[itau_passed]);
173 
174  p_egammaInnerBlockInputs = &((*data_innerEgammaBlock)[itau_passed]);
175  p_muonInnerBlockInputs = &((*data_innerMuonBlock)[itau_passed]);
176  p_hadronInnerBlockInputs = &((*data_innerHadronBlock)[itau_passed]);
177 
178  p_egammaOuterBlockInputs = &((*data_outerEgammaBlock)[itau_passed]);
179  p_muonOuterBlockInputs = &((*data_outerMuonBlock)[itau_passed]);
180  p_hadronOuterBlockInputs = &((*data_outerHadronBlock)[itau_passed]);
181 
182  int tau_index = tau_indices_[itau_passed];
183  const edm::RefToBase<reco::BaseTau> tauRef = taus->refAt(tau_index);
184  prepareInputsV2<pat::PackedCandidate, pat::Tau>(taus->at(tau_index),
185  tau_index,
186  tauRef,
187  electron_collection,
188  muon_collection,
189  *pfCands,
190  vertices->at(0),
191  *rho,
192  tauIDs);
193  }
194 
195  // set all input data to the server
196  input_tauBlock.toServer(data_tauBlock);
197 
198  input_innerEgammaBlock.toServer(data_innerEgammaBlock);
199  input_innerMuonBlock.toServer(data_innerMuonBlock);
200  input_innerHadronBlock.toServer(data_innerHadronBlock);
201 
202  input_outerEgammaBlock.toServer(data_outerEgammaBlock);
203  input_outerMuonBlock.toServer(data_outerMuonBlock);
204  input_outerHadronBlock.toServer(data_outerHadronBlock);
205 }
edm::EDGetTokenT< std::vector< pat::Electron > > electrons_token_
std::vector< TauDiscInfo< pat::PATTauDiscriminator > > patPrediscriminants_
std::vector< float > * p_egammaInnerBlockInputs
std::vector< float > * p_hadronOuterBlockInputs
edm::EDGetTokenT< double > rho_token_
std::map< BasicDiscriminator, size_t > basicDiscrIndexMap_
std::vector< float > * p_tauBlockInputs
const std::vector< BasicDiscriminator > requiredBasicDiscriminators_
std::vector< float > * p_egammaOuterBlockInputs
std::vector< float > * p_hadronInnerBlockInputs
edm::EDGetTokenT< CandidateCollection > pfcandToken_
edm::EDGetTokenT< std::vector< pat::Muon > > muons_token_
int iEvent
Definition: GenABIO.cc:224
std::vector< float > * p_muonInnerBlockInputs
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminators_inputToken_
edm::EDGetTokenT< TauCollection > tausToken_
std::map< BasicDiscriminator, size_t > basicDiscrdR03IndexMap_
const std::vector< BasicDiscriminator > requiredBasicDiscriminatorsdR03_
edm::EDGetTokenT< reco::TauDiscriminatorContainer > basicTauDiscriminatorsdR03_inputToken_
const std::map< BasicDiscriminator, size_t > matchDiscriminatorIndices(edm::Event const &event, edm::EDGetTokenT< reco::TauDiscriminatorContainer > discriminatorContainerToken, std::vector< BasicDiscriminator > requiredDiscr)
std::vector< float > * p_muonOuterBlockInputs
void loadPrediscriminants(edm::Event const &event, edm::Handle< TauCollection > const &taus)
std::vector< int64_t > * p_outerGridposInputs
edm::EDGetTokenT< reco::VertexCollection > vtxToken_
std::vector< TauDiscInfo< reco::PFTauDiscriminator > > recoPrediscriminants_
std::vector< int64_t > * p_innerGridposInputs
std::vector< size_t > tau_indices_
edm::EDGetTokenT< edm::AssociationVector< reco::PFTauRefProd, std::vector< reco::PFTauTransverseImpactParameterRef > > > pfTauTransverseImpactParameters_token_

◆ createConvFeatures()

template<typename CandidateCastType , typename TauCastType >
void DeepTauIdSonicProducer::createConvFeatures ( const TauCastType &  tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const reco::Vertex pv,
double  rho,
const std::vector< pat::Electron > *  electrons,
const std::vector< pat::Muon > *  muons,
const edm::View< reco::Candidate > &  pfCands,
const CellGrid &  grid,
const TauFunc &  tau_funcs,
bool  is_inner,
std::vector< float > *  p_egammaBlockInputs,
std::vector< float > *  p_muonBlockInputs,
std::vector< float > *  p_hadronBlockInputs,
std::vector< int64_t > *  p_GridposInputs 
)
private

Definition at line 299 of file DeepTauIdSONIC.cc.

References gather_cfg::cout, DeepTauIdBase< TritonEDProducer<> >::debug_level, pwdgSkimBPark_cfi::electrons, PVValHelper::eta, getRunAppsInfo::grid, heavyIonCSV_trainingSettings::idx, DiMuonV_cfg::muons, phi, MetAnalyzer::pv(), rho, and metsig::tau.

313  {
314  // fill in the block inputs with zeros
315  int n_cells = 0;
316  int n_cell_oneside = is_inner ? dnn_inputs_v2::number_of_inner_cell : dnn_inputs_v2::number_of_outer_cell;
317 
318  n_cells = is_inner ? (dnn_inputs_v2::number_of_inner_cell * dnn_inputs_v2::number_of_inner_cell)
319  : (dnn_inputs_v2::number_of_outer_cell * dnn_inputs_v2::number_of_outer_cell);
320 
321  p_egammaBlockInputs->insert(
322  p_egammaBlockInputs->end(), n_cells * dnn_inputs_v2::EgammaBlockInputs::NumberOfInputs, 0.);
323  std::vector<float>::iterator egammaIter = p_egammaBlockInputs->begin();
324 
325  p_muonBlockInputs->insert(p_muonBlockInputs->end(), n_cells * dnn_inputs_v2::MuonBlockInputs::NumberOfInputs, 0.);
326  std::vector<float>::iterator muonIter = p_muonBlockInputs->begin();
327 
328  p_hadronBlockInputs->insert(
329  p_hadronBlockInputs->end(), n_cells * dnn_inputs_v2::HadronBlockInputs::NumberOfInputs, 0.);
330  std::vector<float>::iterator hadronIter = p_hadronBlockInputs->begin();
331 
332  unsigned idx = 0;
333  for (int eta = -grid.maxEtaIndex(); eta <= grid.maxEtaIndex(); ++eta) {
334  for (int phi = -grid.maxPhiIndex(); phi <= grid.maxPhiIndex(); ++phi) {
335  if (debug_level >= 2) {
336  std::cout << "processing ( eta = " << eta << ", phi = " << phi << " )" << std::endl;
337  }
338  const CellIndex cell_index{eta, phi};
339 
340  const auto cell_iter = grid.find(cell_index);
341  if (cell_iter != grid.end()) {
342  if (debug_level >= 2) {
343  std::cout << " creating inputs for ( eta = " << eta << ", phi = " << phi << " ): idx = " << idx << std::endl;
344  }
345  const Cell& cell = cell_iter->second;
346  const int eta_index = grid.getEtaTensorIndex(cell_index);
347  const int phi_index = grid.getPhiTensorIndex(cell_index);
348  std::vector<float>::iterator egammaIterCell =
349  egammaIter + (eta_index * n_cell_oneside + phi_index) * dnn_inputs_v2::EgammaBlockInputs::NumberOfInputs;
350  std::vector<float>::iterator muonIterCell =
351  muonIter + (eta_index * n_cell_oneside + phi_index) * dnn_inputs_v2::MuonBlockInputs::NumberOfInputs;
352  std::vector<float>::iterator hadronIterCell =
353  hadronIter + (eta_index * n_cell_oneside + phi_index) * dnn_inputs_v2::HadronBlockInputs::NumberOfInputs;
354 
355  createEgammaBlockInputs<CandidateCastType>(
356  idx, tau, tau_index, tau_ref, pv, rho, electrons, pfCands, cell, tau_funcs, is_inner, egammaIterCell);
357  createMuonBlockInputs<CandidateCastType>(
358  idx, tau, tau_index, tau_ref, pv, rho, muons, pfCands, cell, tau_funcs, is_inner, muonIterCell);
359  createHadronsBlockInputs<CandidateCastType>(
360  idx, tau, tau_index, tau_ref, pv, rho, pfCands, cell, tau_funcs, is_inner, hadronIterCell);
361 
362  idx += 1;
363  } else {
364  if (debug_level >= 2) {
365  std::cout << " skipping creation of inputs, because ( eta = " << eta << ", phi = " << phi
366  << " ) is not in the grid !!" << std::endl;
367  }
368  // we need to fill in the zeros for the input tensors
369  idx += 1;
370  }
371  }
372  }
373 }
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
def pv(vc)
Definition: MetAnalyzer.py:7

◆ fillDescriptions()

void DeepTauIdSonicProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 375 of file DeepTauIdSONIC.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, DeepTauIdBase< TritonEDProducer<> >::fillDescriptionsHelper(), and TritonClient::fillPSetDescription().

375  {
379  descriptions.add("DeepTauIdSonicProducer", desc);
380 }
static void fillDescriptionsHelper(edm::ParameterSetDescription &desc)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)

◆ prepareInputsV2()

template<typename CandidateCastType , typename TauCastType >
void DeepTauIdSonicProducer::prepareInputsV2 ( TauCollection::const_reference tau,
const size_t  tau_index,
const edm::RefToBase< reco::BaseTau tau_ref,
const std::vector< pat::Electron > *  electrons,
const std::vector< pat::Muon > *  muons,
const edm::View< reco::Candidate > &  pfCands,
const reco::Vertex pv,
double  rho,
const TauFunc &  tau_funcs 
)
private

Definition at line 242 of file DeepTauIdSONIC.cc.

References DeepTauIdBase< TritonEDProducer<> >::disable_CellIndex_workaround_, pwdgSkimBPark_cfi::electrons, DeepTauIdBase< TritonEDProducer<> >::fillGrids(), DiMuonV_cfg::muons, p_egammaInnerBlockInputs, p_egammaOuterBlockInputs, p_hadronInnerBlockInputs, p_hadronOuterBlockInputs, p_innerGridposInputs, p_muonInnerBlockInputs, p_muonOuterBlockInputs, p_outerGridposInputs, p_tauBlockInputs, MetAnalyzer::pv(), rho, and metsig::tau.

250  {
251  using namespace dnn_inputs_v2;
252  CellGrid inner_grid(number_of_inner_cell, number_of_inner_cell, 0.02, 0.02, disable_CellIndex_workaround_);
253  CellGrid outer_grid(number_of_outer_cell, number_of_outer_cell, 0.05, 0.05, disable_CellIndex_workaround_);
254  auto tau_casted = dynamic_cast<const TauCastType&>(tau);
255  // fill in the inner and outer grids for electrons, muons, and pfCands
256  fillGrids(tau_casted, *electrons, inner_grid, outer_grid);
257  fillGrids(tau_casted, *muons, inner_grid, outer_grid);
258  fillGrids(tau_casted, pfCands, inner_grid, outer_grid);
259 
260  p_tauBlockInputs->insert(p_tauBlockInputs->end(), TauBlockInputs::NumberOfInputs, 0.);
261  std::vector<float>::iterator tauIter = p_tauBlockInputs->begin();
262 
263  createTauBlockInputs<CandidateCastType>(tau_casted, tau_index, tau_ref, pv, rho, tau_funcs, tauIter);
264 
265  // egamma, muon, and hadron inner and outer inputs for the grids
266  createConvFeatures<CandidateCastType>(tau_casted,
267  tau_index,
268  tau_ref,
269  pv,
270  rho,
271  electrons,
272  muons,
273  pfCands,
274  inner_grid,
275  tau_funcs,
276  true,
281  createConvFeatures<CandidateCastType>(tau_casted,
282  tau_index,
283  tau_ref,
284  pv,
285  rho,
286  electrons,
287  muons,
288  pfCands,
289  outer_grid,
290  tau_funcs,
291  false,
296 }
std::vector< float > * p_egammaInnerBlockInputs
std::vector< float > * p_hadronOuterBlockInputs
std::vector< float > * p_tauBlockInputs
std::vector< float > * p_egammaOuterBlockInputs
std::vector< float > * p_hadronInnerBlockInputs
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
std::vector< float > * p_muonInnerBlockInputs
def pv(vc)
Definition: MetAnalyzer.py:7
std::vector< float > * p_muonOuterBlockInputs
std::vector< int64_t > * p_outerGridposInputs
void fillGrids(const TauCastType &tau, const Collection &objects, CellGrid &inner_grid, CellGrid &outer_grid)
std::vector< int64_t > * p_innerGridposInputs

◆ produce()

void DeepTauIdSonicProducer::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup,
Output const &  iOutput 
)
override

Definition at line 207 of file DeepTauIdSONIC.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, DeepTauIdBase< TritonEDProducer<> >::createOutputs(), DeepTauIdBase< TritonEDProducer<> >::debug_level, mps_fire::end, f, mps_fire::i, iEvent, dqmdumpme::k, deep_tau::NumberOfOutputs, tau_indices_, Tau3MuMonitor_cff::taus, and DeepTauIdBase< TritonEDProducer<> >::tausToken_.

207  {
209  iEvent.getByToken(tausToken_, taus);
210 
211  if (taus->empty()) {
212  std::vector<std::vector<float>> pred_all(0, std::vector<float>(deep_tau::NumberOfOutputs, 0.));
213  createOutputs(iEvent, pred_all, taus);
214  return;
215  }
216 
217  const auto& output_tauval = iOutput.at("main_output/Softmax");
218  const auto& outputs_tauval = output_tauval.fromServer<float>();
219 
220  // fill the taus passing the selections with the results from produce,
221  // and the taus failing the selections with 2 and -1.0
222  std::vector<std::vector<float>> pred_all(taus->size(), std::vector<float>(deep_tau::NumberOfOutputs, 0.));
223  for (unsigned itau = 0; itau < taus->size(); ++itau) {
224  for (int k = 0; k < deep_tau::NumberOfOutputs; ++k) {
225  pred_all[itau][k] = (k == 2) ? -1.f : 2.f;
226  }
227  }
228  for (unsigned itau_passed = 0; itau_passed < tau_indices_.size(); ++itau_passed) {
229  int tau_index = tau_indices_[itau_passed];
230  std::copy(outputs_tauval[itau_passed].begin(), outputs_tauval[itau_passed].end(), pred_all[tau_index].begin());
231 
232  if (debug_level >= 2) {
233  for (int i = 0; i < 4; ++i) {
234  std::cout << "tau index " << itau_passed << " k " << i << " pred " << pred_all[tau_index][i] << std::endl;
235  }
236  }
237  }
238  createOutputs(iEvent, pred_all, taus);
239 }
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< TauCollection > tausToken_
double f[11][100]
void createOutputs(edm::Event &event, const PredType &pred, edm::Handle< TauCollection > taus)
std::vector< size_t > tau_indices_
constexpr int NumberOfOutputs
Definition: DeepTauIdBase.h:50

Member Data Documentation

◆ p_egammaInnerBlockInputs

std::vector<float>* DeepTauIdSonicProducer::p_egammaInnerBlockInputs
private

Definition at line 23 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_egammaOuterBlockInputs

std::vector<float>* DeepTauIdSonicProducer::p_egammaOuterBlockInputs
private

Definition at line 26 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_hadronInnerBlockInputs

std::vector<float>* DeepTauIdSonicProducer::p_hadronInnerBlockInputs
private

Definition at line 25 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_hadronOuterBlockInputs

std::vector<float>* DeepTauIdSonicProducer::p_hadronOuterBlockInputs
private

Definition at line 28 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_innerGridposInputs

std::vector<int64_t>* DeepTauIdSonicProducer::p_innerGridposInputs
private

Definition at line 29 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_muonInnerBlockInputs

std::vector<float>* DeepTauIdSonicProducer::p_muonInnerBlockInputs
private

Definition at line 24 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_muonOuterBlockInputs

std::vector<float>* DeepTauIdSonicProducer::p_muonOuterBlockInputs
private

Definition at line 27 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_outerGridposInputs

std::vector<int64_t>* DeepTauIdSonicProducer::p_outerGridposInputs
private

Definition at line 30 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ p_tauBlockInputs

std::vector<float>* DeepTauIdSonicProducer::p_tauBlockInputs
private

Definition at line 22 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and prepareInputsV2().

◆ tau_indices_

std::vector<size_t> DeepTauIdSonicProducer::tau_indices_
private

Definition at line 20 of file DeepTauIdSONIC.cc.

Referenced by acquire(), and produce().