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_
 
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_
 
RecoTauQualityCutsqcuts_
 
int verbosity_
 
RecoTauVertexAssociator vertexAssociator_
 

Additional Inherited Members

- Public Types inherited from reco::tau::PFRecoTauChargedHadronBuilderPlugin
typedef boost::ptr_vector< PFRecoTauChargedHadronChargedHadronVector
 
typedef std::auto_ptr< ChargedHadronVectorreturn_type
 

Detailed Description

Definition at line 46 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 86 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

References dRmergeNeutralHadronWrtChargedHadron_, dRmergeNeutralHadronWrtElectron_, dRmergeNeutralHadronWrtNeutralHadron_, dRmergeNeutralHadronWrtOther_, dRmergePhotonWrtChargedHadron_, dRmergePhotonWrtElectron_, dRmergePhotonWrtNeutralHadron_, dRmergePhotonWrtOther_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), inputParticleIds_, maxUnmatchedBlockElementsNeutralHadron_, maxUnmatchedBlockElementsPhoton_, minBlockElementMatchesNeutralHadron_, minBlockElementMatchesPhoton_, minMergeChargedHadronPt_, minMergeGammaEt_, minMergeNeutralHadronEt_, qcuts_, and verbosity_.

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

Member Function Documentation

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

Hook called at the beginning of the event.

Reimplemented from reco::tau::PFRecoTauChargedHadronBuilderPlugin.

Definition at line 121 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

References bField_, reco::PFCandidate::elementsInBlocks(), reco::tau::RecoTauEventHolderPlugin::evt(), reco::tau::RecoTauEventHolderPlugin::evtSetup(), edm::EventSetup::get(), MagneticField::inTesla(), trackerHitRTTI::isMatched(), reco::tau::RecoTauVertexAssociator::setEvent(), vertexAssociator_, and PV3DBase< T, PVType, FrameType >::z().

122 {
124 
126  evtSetup()->get<IdealMagneticFieldRecord>().get(pSetup);
127  bField_ = pSetup->inTesla(GlobalPoint(0,0,0)).z();
128 }
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
void setEvent(const edm::Event &evt)
Load the vertices from the event.
T z() const
Definition: PV3DBase.h:64
const edm::EventSetup * evtSetup() const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
T get() const
Definition: EventSetup.h:71
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 163 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

References funct::abs(), reco::CompositeCandidate::addDaughter(), patPFMETCorrections_cff::algo, reco::tau::RecoTauVertexAssociator::associatedVertex(), reco::tau::atECALEntrance(), bField_, muons2muons_cfi::chargedHadron, reco::CompositePtrCandidate::daughterPtrVector(), DEFINE_EDM_PLUGIN, reco::deltaR(), dRmergeNeutralHadronWrtChargedHadron_, dRmergeNeutralHadronWrtElectron_, dRmergeNeutralHadronWrtNeutralHadron_, dRmergeNeutralHadronWrtOther_, dRmergePhotonWrtChargedHadron_, dRmergePhotonWrtElectron_, dRmergePhotonWrtNeutralHadron_, dRmergePhotonWrtOther_, reco::tau::RecoTauQualityCuts::filterCandRefs(), reco::PFCandidate::gsfTrackRef(), inputParticleIds_, edm::Ref< C, T, F >::isNonnull(), reco::PFRecoTauChargedHadron::kChargedPFCandidate, reco::PFRecoTauChargedHadron::kPFNeutralHadron, reco::PFRecoTauChargedHadron::kUndefined, maxUnmatchedBlockElementsNeutralHadron_, maxUnmatchedBlockElementsPhoton_, minBlockElementMatchesNeutralHadron_, minBlockElementMatchesPhoton_, minMergeChargedHadronPt_, minMergeGammaEt_, minMergeNeutralHadronEt_, reco::PFCandidate::muonRef(), reco::tau::RecoTauNamedPlugin::name(), convertSQLitetoXML_cfg::output, common_cff::pdgId, reco::tau::pfCandidates(), qcuts_, edm::refToPtr(), reco::tau::setChargedHadronP4(), reco::tau::RecoTauQualityCuts::setPV(), reco::PFCandidate::trackRef(), verbosity_, and vertexAssociator_.

164 {
165  if ( verbosity_ ) {
166  edm::LogPrint("TauChHadronFromPF") << "<PFRecoTauChargedHadronFromPFCandidatePlugin::operator()>:";
167  edm::LogPrint("TauChHadronFromPF") << " pluginName = " << name() ;
168  }
169 
171 
172  // Get the candidates passing our quality cuts
175 
176  for ( CandPtrs::iterator cand = candsVector.begin();
177  cand != candsVector.end(); ++cand ) {
178  if ( verbosity_ ) {
179  edm::LogPrint("TauChHadronFromPF") << "processing PFCandidate: Pt = " << (*cand)->pt() << ", eta = " << (*cand)->eta() << ", phi = " << (*cand)->phi()
180  << " (pdgId = " << (*cand)->pdgId() << ", charge = " << (*cand)->charge() << ")" ;
181  }
182 
184  if ( std::abs((*cand)->charge()) > 0.5 ) algo = PFRecoTauChargedHadron::kChargedPFCandidate;
186  std::auto_ptr<PFRecoTauChargedHadron> chargedHadron(new PFRecoTauChargedHadron(**cand, algo));
187 
188  const reco::PFCandidate* pfCand = dynamic_cast<const reco::PFCandidate*>(&**cand);
189  if (pfCand) {
190  if ( pfCand->trackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->trackRef());
191  else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->innerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->innerTrack());
192  else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->globalTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->globalTrack());
193  else if ( pfCand->muonRef().isNonnull() && pfCand->muonRef()->outerTrack().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->muonRef()->outerTrack());
194  else if ( pfCand->gsfTrackRef().isNonnull() ) chargedHadron->track_ = edm::refToPtr(pfCand->gsfTrackRef());
195  } // TauReco@MiniAOD: Tracks only available dynamically, so no possiblity to save ref here; checked by code downstream
196 
197  chargedHadron->positionAtECALEntrance_ = atECALEntrance(&**cand, bField_);
198  chargedHadron->chargedPFCandidate_ = (*cand);
199  chargedHadron->addDaughter(*cand);
200 
201  int pdgId = std::abs(chargedHadron->chargedPFCandidate_->pdgId());
202 
203  if ( chargedHadron->pt() > minMergeChargedHadronPt_ ) {
204  for (const auto& jetConstituent : jet.daughterPtrVector()) {
205  // CV: take care of not double-counting energy in case "charged" PFCandidate is in fact a PFNeutralHadron
206  if ( jetConstituent == chargedHadron->chargedPFCandidate_ ) continue;
207 
208  int jetConstituentPdgId = std::abs(jetConstituent->pdgId());
209  if ( !(jetConstituentPdgId == 130 || jetConstituentPdgId == 22) ) continue;
210 
211  double dR = deltaR(atECALEntrance(jetConstituent.get(), bField_), atECALEntrance(chargedHadron->chargedPFCandidate_.get(), bField_));
212  double dRmerge = -1.;
213  int minBlockElementMatches = 1000;
214  int maxUnmatchedBlockElements = 0;
215  double minMergeEt = 1.e+6;
216  if ( jetConstituentPdgId == 130 ) {
217  if ( pdgId == 211 ) dRmerge = dRmergeNeutralHadronWrtChargedHadron_;
218  else if ( pdgId == 130 ) dRmerge = dRmergeNeutralHadronWrtNeutralHadron_;
219  else if ( pdgId == 11 ) dRmerge = dRmergeNeutralHadronWrtElectron_;
220  else dRmerge = dRmergeNeutralHadronWrtOther_;
221  minBlockElementMatches = minBlockElementMatchesNeutralHadron_;
222  maxUnmatchedBlockElements = maxUnmatchedBlockElementsNeutralHadron_;
223  minMergeEt = minMergeNeutralHadronEt_;
224  } else if ( jetConstituentPdgId == 22 ) {
225  if ( pdgId == 211 ) dRmerge = dRmergePhotonWrtChargedHadron_;
226  else if ( pdgId == 130 ) dRmerge = dRmergePhotonWrtNeutralHadron_;
227  else if ( pdgId == 11 ) dRmerge = dRmergePhotonWrtElectron_;
228  else dRmerge = dRmergePhotonWrtOther_;
229  minBlockElementMatches = minBlockElementMatchesPhoton_;
230  maxUnmatchedBlockElements = maxUnmatchedBlockElementsPhoton_;
231  minMergeEt = minMergeGammaEt_;
232  }
233 
234  if (jetConstituent->et() > minMergeEt) {
235  if (dR < dRmerge) {
236  chargedHadron->neutralPFCandidates_.push_back(jetConstituent);
237  chargedHadron->addDaughter(jetConstituent);
238  }
239  else {
240  // TauReco@MiniAOD: No access to PF blocks at MiniAOD level, but the code below seems to have very minor impact
241  const reco::PFCandidate* pfJetConstituent = dynamic_cast<const reco::PFCandidate*>(jetConstituent.get());
242  if (pfCand != nullptr && pfJetConstituent != nullptr) {
243  if (isMatchedByBlockElement(*pfJetConstituent, *pfCand, minBlockElementMatches, minBlockElementMatches, maxUnmatchedBlockElements)) {
244  chargedHadron->neutralPFCandidates_.push_back(jetConstituent);
245  chargedHadron->addDaughter(jetConstituent);
246  }
247  }
248  }
249  }
250  }
251  }
252 
254 
255  if ( verbosity_ ) {
256  edm::LogPrint("TauChHadronFromPF") << *chargedHadron;
257  }
258  // Update the vertex
259  if ( chargedHadron->daughterPtr(0).isNonnull() ) chargedHadron->setVertex(chargedHadron->daughterPtr(0)->vertex());
260  output.push_back(chargedHadron);
261  }
262 
263  return output.release();
264 }
std::vector< CandidatePtr > pfCandidates(const Jet &jet, int particleId, bool sort=true)
math::XYZPointF atECALEntrance(const reco::Candidate *part, double bField)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
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
Coll filterCandRefs(const Coll &refcoll, bool invert=false) const
Filter a ref vector of Candidates.
boost::ptr_vector< PFRecoTauChargedHadron > ChargedHadronVector
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
std::vector< reco::CandidatePtr > CandPtrs
void setPV(const reco::VertexRef &vtx) const
Update the primary vertex.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:459
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
reco::VertexRef associatedVertex(const Jet &jet) const
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:480
const std::string & name() const
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)

Member Data Documentation

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

Definition at line 81 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

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

double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtChargedHadron_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtElectron_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtNeutralHadron_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergeNeutralHadronWrtOther_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtChargedHadron_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtElectron_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtNeutralHadron_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::dRmergePhotonWrtOther_
private
std::vector<int> reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::inputParticleIds_
private
int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::maxUnmatchedBlockElementsNeutralHadron_
private
int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::maxUnmatchedBlockElementsPhoton_
private
int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minBlockElementMatchesNeutralHadron_
private
int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minBlockElementMatchesPhoton_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minMergeChargedHadronPt_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minMergeGammaEt_
private
double reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::minMergeNeutralHadronEt_
private
RecoTauQualityCuts* reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::qcuts_
private
int reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::verbosity_
private
RecoTauVertexAssociator reco::tau::PFRecoTauChargedHadronFromPFCandidatePlugin::vertexAssociator_
private

Definition at line 59 of file PFRecoTauChargedHadronFromPFCandidatePlugin.cc.

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