CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
DeepMETSonicProducer Class Reference
Inheritance diagram for DeepMETSonicProducer:
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
 
 DeepMETSonicProducer (const edm::ParameterSet &)
 
void produce (edm::Event &iEvent, edm::EventSetup const &iSetup, Output const &iOutput) override
 
- 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 TritonEDProducerT< G, Capabilities >
static void globalEndJob (G *)
 
static std::unique_ptr< G > initializeGlobalCache (edm::ParameterSet const &pset)
 

Private Attributes

const bool ignore_leptons_
 
const unsigned int max_n_pf_
 
const float norm_
 
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > pf_token_
 
float px_leptons_
 
float py_leptons_
 
const float scale_
 

Additional Inherited Members

- 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
 
- Protected Member Functions inherited from SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >
void makeClient ()
 
- 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_
 

Detailed Description

Definition at line 13 of file DeepMETSonicProducer.cc.

Constructor & Destructor Documentation

◆ DeepMETSonicProducer()

DeepMETSonicProducer::DeepMETSonicProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 30 of file DeepMETSonicProducer.cc.

32  pf_token_(consumes<std::vector<pat::PackedCandidate>>(cfg.getParameter<edm::InputTag>("pf_src"))),
33  norm_(cfg.getParameter<double>("norm_factor")),
34  ignore_leptons_(cfg.getParameter<bool>("ignore_leptons")),
35  max_n_pf_(cfg.getParameter<unsigned int>("max_n_pf")),
36  scale_(1.0 / norm_) {
37  produces<pat::METCollection>();
38 }
const unsigned int max_n_pf_
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > pf_token_

Member Function Documentation

◆ acquire()

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

Definition at line 40 of file DeepMETSonicProducer.cc.

References funct::abs(), deepmet_helper::charge_embedding, SonicAcquirer< TritonClient, edm::stream::EDProducer< edm::ExternalWork, Capabilities... > >::client_, iEvent, ignore_leptons_, input, max_n_pf_, HiggsValidation_cfi::pdg_id, deepmet_helper::pdg_id_embedding, packedPFCandidateRefMixer_cfi::pf, pf_token_, px_leptons_, py_leptons_, scale_, and deepmet_helper::scale_and_rm_outlier().

40  {
41  // one event per batch
42  client_->setBatchSize(1);
43  px_leptons_ = 0.;
44  py_leptons_ = 0.;
45 
46  auto const& pfs = iEvent.get(pf_token_);
47 
48  auto& input = iInput.at("input");
49  auto pfdata = input.allocate<float>();
50  auto& vpfdata = (*pfdata)[0];
51 
52  auto& input_cat0 = iInput.at("input_cat0");
53  auto pfchg = input_cat0.allocate<float>();
54  auto& vpfchg = (*pfchg)[0];
55 
56  auto& input_cat1 = iInput.at("input_cat1");
57  auto pfpdgId = input_cat1.allocate<float>();
58  auto& vpfpdgId = (*pfpdgId)[0];
59 
60  auto& input_cat2 = iInput.at("input_cat2");
61  auto pffromPV = input_cat2.allocate<float>();
62  auto& vpffromPV = (*pffromPV)[0];
63 
64  size_t i_pf = 0;
65  for (const auto& pf : pfs) {
66  if (ignore_leptons_) {
67  int pdg_id = std::abs(pf.pdgId());
68  if (pdg_id == 11 || pdg_id == 13) {
69  px_leptons_ += pf.px();
70  py_leptons_ += pf.py();
71  continue;
72  }
73  }
74 
75  // PF keys [b'PF_dxy', b'PF_dz', b'PF_eta', b'PF_mass', b'PF_pt', b'PF_puppiWeight', b'PF_px', b'PF_py']
76  vpfdata.push_back(pf.dxy());
77  vpfdata.push_back(pf.dz());
78  vpfdata.push_back(pf.eta());
79  vpfdata.push_back(pf.mass());
80  vpfdata.push_back(scale_and_rm_outlier(pf.pt(), scale_));
81  vpfdata.push_back(pf.puppiWeight());
82  vpfdata.push_back(scale_and_rm_outlier(pf.px(), scale_));
83  vpfdata.push_back(scale_and_rm_outlier(pf.py(), scale_));
84 
85  vpfchg.push_back(charge_embedding.at(pf.charge()));
86 
87  vpfpdgId.push_back(pdg_id_embedding.at(pf.pdgId()));
88 
89  vpffromPV.push_back(pf.fromPV());
90 
91  ++i_pf;
92  if (i_pf == max_n_pf_) {
93  edm::LogWarning("acquire")
94  << "<DeepMETSonicProducer::acquire>:" << std::endl
95  << " The number of particles is equal to or exceeds the maximum considerable for DeepMET" << std::endl;
96  break;
97  }
98  }
99 
100  // fill the remaining with zeros
101  // resize the vector to 4500 for zero-padding
102  vpfdata.resize(8 * max_n_pf_);
103  vpfchg.resize(max_n_pf_);
104  vpfpdgId.resize(max_n_pf_);
105  vpffromPV.resize(max_n_pf_);
106 
107  input.toServer(pfdata);
108  input_cat0.toServer(pfchg);
109  input_cat1.toServer(pfpdgId);
110  input_cat2.toServer(pffromPV);
111 }
const unsigned int max_n_pf_
static const std::unordered_map< int, int32_t > charge_embedding
Definition: DeepMETHelp.h:10
static std::string const input
Definition: EdmProvDump.cc:50
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< std::vector< pat::PackedCandidate > > pf_token_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const std::unordered_map< int, int32_t > pdg_id_embedding
Definition: DeepMETHelp.h:11
float scale_and_rm_outlier(float val, float scale)
Definition: DeepMETHelper.cc:4
Log< level::Warning, false > LogWarning

◆ fillDescriptions()

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

Definition at line 134 of file DeepMETSonicProducer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, TritonClient::fillPSetDescription(), and HLT_2022v15_cff::InputTag.

134  {
137  desc.add<edm::InputTag>("pf_src", edm::InputTag("packedPFCandidates"));
138  desc.add<bool>("ignore_leptons", false);
139  desc.add<double>("norm_factor", 50.);
140  desc.add<unsigned int>("max_n_pf", 4500);
141  descriptions.add("deepMETSonicProducer", desc);
142 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillPSetDescription(edm::ParameterSetDescription &iDesc)

◆ produce()

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

Definition at line 113 of file DeepMETSonicProducer.cc.

References iEvent, LogDebug, eostools::move(), norm_, skim900GeV_StreamA_MinBiasPD_cfg::output1, PatBasicFWLiteJetAnalyzer_Selector_cfg::outputs, multPhiCorr_741_25nsDY_cfi::px, px_leptons_, multPhiCorr_741_25nsDY_cfi::py, and py_leptons_.

113  {
114  const auto& output1 = iOutput.begin()->second;
115  const auto& outputs = output1.fromServer<float>();
116 
117  // outputs are px and py
118  float px = outputs[0][0] * norm_;
119  float py = outputs[0][1] * norm_;
120 
121  // subtract the lepton pt contribution
122  px -= px_leptons_;
123  py -= py_leptons_;
124 
125  LogDebug("produce") << "<DeepMETSonicProducer::produce>:" << std::endl
126  << " MET from DeepMET Sonic Producer is MET_x " << px << " and MET_y " << py << std::endl;
127 
128  auto pf_mets = std::make_unique<pat::METCollection>();
129  const reco::Candidate::LorentzVector p4(px, py, 0., std::hypot(px, py));
130  pf_mets->emplace_back(reco::MET(p4, {}));
131  iEvent.put(std::move(pf_mets));
132 }
int iEvent
Definition: GenABIO.cc:224
Definition: MET.h:41
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ ignore_leptons_

const bool DeepMETSonicProducer::ignore_leptons_
private

Definition at line 23 of file DeepMETSonicProducer.cc.

Referenced by acquire().

◆ max_n_pf_

const unsigned int DeepMETSonicProducer::max_n_pf_
private

Definition at line 24 of file DeepMETSonicProducer.cc.

Referenced by acquire().

◆ norm_

const float DeepMETSonicProducer::norm_
private

Definition at line 22 of file DeepMETSonicProducer.cc.

Referenced by produce().

◆ pf_token_

const edm::EDGetTokenT<std::vector<pat::PackedCandidate> > DeepMETSonicProducer::pf_token_
private

Definition at line 21 of file DeepMETSonicProducer.cc.

Referenced by acquire().

◆ px_leptons_

float DeepMETSonicProducer::px_leptons_
private

Definition at line 26 of file DeepMETSonicProducer.cc.

Referenced by acquire(), and produce().

◆ py_leptons_

float DeepMETSonicProducer::py_leptons_
private

Definition at line 27 of file DeepMETSonicProducer.cc.

Referenced by acquire(), and produce().

◆ scale_

const float DeepMETSonicProducer::scale_
private

Definition at line 25 of file DeepMETSonicProducer.cc.

Referenced by acquire().