CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin Class Reference
Inheritance diagram for reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin:
reco::tau::PFRecoTauChargedHadronBuilderPlugin reco::tau::RecoTauEventHolderPlugin reco::tau::RecoTauNamedPlugin

Public Member Functions

void beginEvent () override
 Hook called at the beginning of the event. More...
 
return_type operator() (const reco::Jet &) const override
 Build a collection of chargedHadrons from objects in the input jet. More...
 
 PFRecoTauChargedHadronFromPFCandidatePlugin (const edm::ParameterSet &, edm::ConsumesCollector &&iC)
 
 ~PFRecoTauChargedHadronFromPFCandidatePlugin () override
 
- Public Member Functions inherited from reco::tau::PFRecoTauChargedHadronBuilderPlugin
 PFRecoTauChargedHadronBuilderPlugin (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
 ~PFRecoTauChargedHadronBuilderPlugin () override
 
- Public Member Functions inherited from reco::tau::RecoTauEventHolderPlugin
const edm::Eventevt () const
 
edm::Eventevt ()
 
const edm::EventSetupevtSetup () const
 
 RecoTauEventHolderPlugin (const edm::ParameterSet &pset)
 
void setup (edm::Event &, const edm::EventSetup &)
 
 ~RecoTauEventHolderPlugin () override
 
- Public Member Functions inherited from reco::tau::RecoTauNamedPlugin
const std::string & name () const
 
 RecoTauNamedPlugin (const edm::ParameterSet &pset)
 
virtual ~RecoTauNamedPlugin ()
 

Private Types

typedef std::vector< reco::CandidatePtrCandPtrs
 

Private Attributes

double bField_
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordbFieldToken_
 
double dRmergeNeutralHadronWrtChargedHadron_
 
double dRmergeNeutralHadronWrtElectron_
 
double dRmergeNeutralHadronWrtNeutralHadron_
 
double dRmergeNeutralHadronWrtOther_
 
double dRmergePhotonWrtChargedHadron_
 
double dRmergePhotonWrtElectron_
 
double dRmergePhotonWrtNeutralHadron_
 
double dRmergePhotonWrtOther_
 
std::vector< int > inputParticleIds_
 
int maxUnmatchedBlockElementsNeutralHadron_
 
int maxUnmatchedBlockElementsPhoton_
 
int minBlockElementMatchesNeutralHadron_
 
int minBlockElementMatchesPhoton_
 
double minMergeChargedHadronPt_
 
double minMergeGammaEt_
 
double minMergeNeutralHadronEt_
 
std::unique_ptr< RecoTauQualityCutsqcuts_
 
int verbosity_
 
RecoTauVertexAssociator vertexAssociator_
 

Additional Inherited Members

- Public Types inherited from reco::tau::PFRecoTauChargedHadronBuilderPlugin
typedef std::vector< std::unique_ptr< PFRecoTauChargedHadron > > ChargedHadronVector
 
typedef ChargedHadronVector return_type
 

Detailed Description

Definition at line 43 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

Member Typedef Documentation

◆ CandPtrs

Constructor & Destructor Documentation

◆ PFRecoTauChargedHadronFromPFCandidatePlugin()

reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::PFRecoTauChargedHadronFromPFCandidatePlugin ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
explicit

Definition at line 83 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

References dRmergeNeutralHadronWrtChargedHadron_, dRmergeNeutralHadronWrtElectron_, dRmergeNeutralHadronWrtNeutralHadron_, dRmergeNeutralHadronWrtOther_, dRmergePhotonWrtChargedHadron_, dRmergePhotonWrtElectron_, dRmergePhotonWrtNeutralHadron_, dRmergePhotonWrtOther_, inputParticleIds_, maxUnmatchedBlockElementsNeutralHadron_, maxUnmatchedBlockElementsPhoton_, minBlockElementMatchesNeutralHadron_, minBlockElementMatchesPhoton_, minMergeChargedHadronPt_, minMergeGammaEt_, minMergeNeutralHadronEt_, muonDTDigis_cfi::pset, qcuts_, and verbosity_.

86  vertexAssociator_(pset.getParameter<edm::ParameterSet>("qualityCuts"), std::move(iC)),
87  qcuts_(nullptr),
88  bFieldToken_(iC.esConsumes()) {
89  edm::ParameterSet qcuts_pset = pset.getParameterSet("qualityCuts").getParameterSet("signalQualityCuts");
90  qcuts_ = std::make_unique<RecoTauQualityCuts>(qcuts_pset);
91 
92  inputParticleIds_ = pset.getParameter<std::vector<int> >("chargedHadronCandidatesParticleIds");
93 
94  dRmergeNeutralHadronWrtChargedHadron_ = pset.getParameter<double>("dRmergeNeutralHadronWrtChargedHadron");
95  dRmergeNeutralHadronWrtNeutralHadron_ = pset.getParameter<double>("dRmergeNeutralHadronWrtNeutralHadron");
96  dRmergeNeutralHadronWrtElectron_ = pset.getParameter<double>("dRmergeNeutralHadronWrtElectron");
97  dRmergeNeutralHadronWrtOther_ = pset.getParameter<double>("dRmergeNeutralHadronWrtOther");
98  minBlockElementMatchesNeutralHadron_ = pset.getParameter<int>("minBlockElementMatchesNeutralHadron");
99  maxUnmatchedBlockElementsNeutralHadron_ = pset.getParameter<int>("maxUnmatchedBlockElementsNeutralHadron");
100  dRmergePhotonWrtChargedHadron_ = pset.getParameter<double>("dRmergePhotonWrtChargedHadron");
101  dRmergePhotonWrtNeutralHadron_ = pset.getParameter<double>("dRmergePhotonWrtNeutralHadron");
102  dRmergePhotonWrtElectron_ = pset.getParameter<double>("dRmergePhotonWrtElectron");
103  dRmergePhotonWrtOther_ = pset.getParameter<double>("dRmergePhotonWrtOther");
104  minBlockElementMatchesPhoton_ = pset.getParameter<int>("minBlockElementMatchesPhoton");
105  maxUnmatchedBlockElementsPhoton_ = pset.getParameter<int>("maxUnmatchedBlockElementsPhoton");
106  minMergeNeutralHadronEt_ = pset.getParameter<double>("minMergeNeutralHadronEt");
107  minMergeGammaEt_ = pset.getParameter<double>("minMergeGammaEt");
108  minMergeChargedHadronPt_ = pset.getParameter<double>("minMergeChargedHadronPt");
109 
110  verbosity_ = pset.getParameter<int>("verbosity");
111  }
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken_
def move(src, dest)
Definition: eostools.py:511
PFRecoTauChargedHadronBuilderPlugin(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)

◆ ~PFRecoTauChargedHadronFromPFCandidatePlugin()

reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::~PFRecoTauChargedHadronFromPFCandidatePlugin ( )
inlineoverride

Definition at line 46 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

46 {};

Member Function Documentation

◆ beginEvent()

void reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::beginEvent ( )
overridevirtual

Hook called at the beginning of the event.

Reimplemented from reco::tau::PFRecoTauChargedHadronBuilderPlugin.

Definition at line 114 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

References bField_, bFieldToken_, reco::tau::RecoTauEventHolderPlugin::evt(), reco::tau::RecoTauEventHolderPlugin::evtSetup(), edm::EventSetup::getData(), reco::tau::RecoTauVertexAssociator::setEvent(), and vertexAssociator_.

114  {
116 
117  bField_ = evtSetup()->getData(bFieldToken_).inTesla(GlobalPoint(0, 0, 0)).z();
118  }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::EventSetup * evtSetup() const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
void setEvent(const edm::Event &evt)
Load the vertices from the event.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken_

◆ operator()()

PFRecoTauChargedHadronFromPFCandidatePlugin::return_type reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::operator() ( const reco::Jet ) const
overridevirtual

Build a collection of chargedHadrons from objects in the input jet.

Implements reco::tau::PFRecoTauChargedHadronBuilderPlugin.

Definition at line 158 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

References funct::abs(), reco::tau::RecoTauVertexAssociator::associatedVertex(), reco::tau::atECALEntrance(), bField_, HPSPFTauProducerPuppi_cfi::chargedHadron, reco::deltaR(), HGC3DClusterGenMatchSelector_cfi::dR, dRmergeNeutralHadronWrtChargedHadron_, dRmergeNeutralHadronWrtElectron_, dRmergeNeutralHadronWrtNeutralHadron_, dRmergeNeutralHadronWrtOther_, dRmergePhotonWrtChargedHadron_, dRmergePhotonWrtElectron_, dRmergePhotonWrtNeutralHadron_, dRmergePhotonWrtOther_, inputParticleIds_, metsig::jet, reco::PFRecoTauChargedHadron::kChargedPFCandidate, reco::PFRecoTauChargedHadron::kPFNeutralHadron, reco::PFRecoTauChargedHadron::kUndefined, maxUnmatchedBlockElementsNeutralHadron_, maxUnmatchedBlockElementsPhoton_, minBlockElementMatchesNeutralHadron_, minBlockElementMatchesPhoton_, minMergeChargedHadronPt_, minMergeGammaEt_, minMergeNeutralHadronEt_, eostools::move(), reco::tau::RecoTauNamedPlugin::name(), convertSQLitetoXML_cfg::output, EgammaValidation_cff::pdgId, reco::tau::pfCandidates(), qcuts_, edm::refToPtr(), reco::tau::setChargedHadronP4(), verbosity_, and vertexAssociator_.

159  {
160  if (verbosity_) {
161  edm::LogPrint("TauChHadronFromPF") << "<PFRecoTauChargedHadronFromPFCandidatePlugin::operator()>:";
162  edm::LogPrint("TauChHadronFromPF") << " pluginName = " << name();
163  }
164 
166 
167  // Get the candidates passing our quality cuts
169  CandPtrs candsVector = qcuts_->filterCandRefs(pfCandidates(jet, inputParticleIds_));
170 
171  for (CandPtrs::iterator cand = candsVector.begin(); cand != candsVector.end(); ++cand) {
172  if (verbosity_) {
173  edm::LogPrint("TauChHadronFromPF")
174  << "processing PFCandidate: Pt = " << (*cand)->pt() << ", eta = " << (*cand)->eta()
175  << ", phi = " << (*cand)->phi() << " (pdgId = " << (*cand)->pdgId() << ", charge = " << (*cand)->charge()
176  << ")";
177  }
178 
180  if (std::abs((*cand)->charge()) > 0.5)
182  else
184  auto chargedHadron = std::make_unique<PFRecoTauChargedHadron>(**cand, algo);
185 
186  const reco::PFCandidate* pfCand = dynamic_cast<const reco::PFCandidate*>(&**cand);
187  if (pfCand) {
188  if (pfCand->trackRef().isNonnull())
189  chargedHadron->track_ = edm::refToPtr(pfCand->trackRef());
190  else if (pfCand->muonRef().isNonnull() && pfCand->muonRef()->innerTrack().isNonnull())
191  chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->innerTrack());
192  else if (pfCand->muonRef().isNonnull() && pfCand->muonRef()->globalTrack().isNonnull())
193  chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->globalTrack());
194  else if (pfCand->muonRef().isNonnull() && pfCand->muonRef()->outerTrack().isNonnull())
195  chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->outerTrack());
196  else if (pfCand->gsfTrackRef().isNonnull())
197  chargedHadron->track_ = edm::refToPtr(pfCand->gsfTrackRef());
198  } // TauReco@MiniAOD: Tracks only available dynamically, so no possiblity to save ref here; checked by code downstream
199 
200  chargedHadron->positionAtECALEntrance_ = atECALEntrance(&**cand, bField_);
201  chargedHadron->chargedPFCandidate_ = (*cand);
202  chargedHadron->addDaughter(*cand);
203 
204  int pdgId = std::abs(chargedHadron->chargedPFCandidate_->pdgId());
205 
207  for (const auto& jetConstituent : jet.daughterPtrVector()) {
208  // CV: take care of not double-counting energy in case "charged" PFCandidate is in fact a PFNeutralHadron
209  if (jetConstituent == chargedHadron->chargedPFCandidate_)
210  continue;
211 
212  int jetConstituentPdgId = std::abs(jetConstituent->pdgId());
213  if (!(jetConstituentPdgId == 130 || jetConstituentPdgId == 22))
214  continue;
215 
216  double dR = deltaR(atECALEntrance(jetConstituent.get(), bField_),
217  atECALEntrance(chargedHadron->chargedPFCandidate_.get(), bField_));
218  double dRmerge = -1.;
219  int minBlockElementMatches = 1000;
220  int maxUnmatchedBlockElements = 0;
221  double minMergeEt = 1.e+6;
222  if (jetConstituentPdgId == 130) {
223  if (pdgId == 211)
225  else if (pdgId == 130)
227  else if (pdgId == 11)
229  else
231  minBlockElementMatches = minBlockElementMatchesNeutralHadron_;
232  maxUnmatchedBlockElements = maxUnmatchedBlockElementsNeutralHadron_;
233  minMergeEt = minMergeNeutralHadronEt_;
234  } else if (jetConstituentPdgId == 22) {
235  if (pdgId == 211)
237  else if (pdgId == 130)
239  else if (pdgId == 11)
240  dRmerge = dRmergePhotonWrtElectron_;
241  else
242  dRmerge = dRmergePhotonWrtOther_;
243  minBlockElementMatches = minBlockElementMatchesPhoton_;
244  maxUnmatchedBlockElements = maxUnmatchedBlockElementsPhoton_;
245  minMergeEt = minMergeGammaEt_;
246  }
247 
248  if (jetConstituent->et() > minMergeEt) {
249  if (dR < dRmerge) {
250  chargedHadron->neutralPFCandidates_.push_back(jetConstituent);
251  chargedHadron->addDaughter(jetConstituent);
252  } else {
253  // TauReco@MiniAOD: No access to PF blocks at MiniAOD level, but the code below seems to have very minor impact
254  const reco::PFCandidate* pfJetConstituent =
255  dynamic_cast<const reco::PFCandidate*>(jetConstituent.get());
256  if (pfCand != nullptr && pfJetConstituent != nullptr) {
257  if (isMatchedByBlockElement(*pfJetConstituent,
258  *pfCand,
259  minBlockElementMatches,
260  minBlockElementMatches,
261  maxUnmatchedBlockElements)) {
262  chargedHadron->neutralPFCandidates_.push_back(jetConstituent);
263  chargedHadron->addDaughter(jetConstituent);
264  }
265  }
266  }
267  }
268  }
269  }
270 
272 
273  if (verbosity_) {
274  edm::LogPrint("TauChHadronFromPF") << *chargedHadron;
275  }
276  // Update the vertex
277  if (chargedHadron->daughterPtr(0).isNonnull())
278  chargedHadron->setVertex(chargedHadron->daughterPtr(0)->vertex());
279  output.push_back(std::move(chargedHadron));
280  }
281 
282  return output;
283  }
std::vector< CandidatePtr > pfCandidates(const Jet &jet, int particleId, bool sort=true)
std::vector< std::unique_ptr< PFRecoTauChargedHadron > > ChargedHadronVector
math::XYZPointF atECALEntrance(const reco::Candidate *part, double bField)
Ptr< typename C::value_type > refToPtr(Ref< C, typename C::value_type, refhelper::FindUsingAdvance< C, typename C::value_type > > const &ref)
Definition: RefToPtr.h:18
reco::VertexRef associatedVertex(const Jet &jet) const
std::vector< reco::CandidatePtr > CandPtrs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Warning, true > LogPrint
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
const std::string & name() const
Definition: output.py:1
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ bField_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::bField_
private

Definition at line 78 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

Referenced by beginEvent(), and operator()().

◆ bFieldToken_

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::bFieldToken_
private

Definition at line 77 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

Referenced by beginEvent().

◆ dRmergeNeutralHadronWrtChargedHadron_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtChargedHadron_
private

◆ dRmergeNeutralHadronWrtElectron_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtElectron_
private

◆ dRmergeNeutralHadronWrtNeutralHadron_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtNeutralHadron_
private

◆ dRmergeNeutralHadronWrtOther_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtOther_
private

◆ dRmergePhotonWrtChargedHadron_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtChargedHadron_
private

◆ dRmergePhotonWrtElectron_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtElectron_
private

◆ dRmergePhotonWrtNeutralHadron_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtNeutralHadron_
private

◆ dRmergePhotonWrtOther_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtOther_
private

◆ inputParticleIds_

std::vector<int> reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::inputParticleIds_
private

◆ maxUnmatchedBlockElementsNeutralHadron_

int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::maxUnmatchedBlockElementsNeutralHadron_
private

◆ maxUnmatchedBlockElementsPhoton_

int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::maxUnmatchedBlockElementsPhoton_
private

◆ minBlockElementMatchesNeutralHadron_

int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minBlockElementMatchesNeutralHadron_
private

◆ minBlockElementMatchesPhoton_

int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minBlockElementMatchesPhoton_
private

◆ minMergeChargedHadronPt_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minMergeChargedHadronPt_
private

◆ minMergeGammaEt_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minMergeGammaEt_
private

◆ minMergeNeutralHadronEt_

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minMergeNeutralHadronEt_
private

◆ qcuts_

std::unique_ptr<RecoTauQualityCuts> reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::qcuts_
private

◆ verbosity_

int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::verbosity_
private

◆ vertexAssociator_

RecoTauVertexAssociator reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::vertexAssociator_
private

Definition at line 55 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

Referenced by beginEvent(), and operator()().