2 #include "Math/GenVector/VectorUtil.h" 33 std::vector<CandidatePtr> hadrons = tagInfo->PFChargedHadrCands();
78 pfTau.
setP4(tagInfo->pfjetRef()->p4());
93 for(
unsigned int h=0;
h<hadrons.size();++
h) {
109 std::vector<CandidatePtr> signal;
110 signal.push_back(hadron);
148 if(!hadrons.empty()&&!
strips.empty()){
150 for(std::vector<std::vector<CandidatePtr>>::const_iterator candVector=
strips.begin();candVector!=
strips.end();++candVector)
151 for(std::vector<CandidatePtr>::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) {
155 std::vector<CandidatePtr> emConstituents = *candVector;
166 (*hadron)->p4()+
strip,
167 (*hadron)->vertex());
174 tau.setpfTauTagInfoRef(tagInfo);
177 std::vector<CandidatePtr> signal;
178 std::vector<CandidatePtr> signalH;
179 std::vector<CandidatePtr> signalG;
182 signalH.push_back(*hadron);
183 signal.push_back(*hadron);
188 tauCone=
std::max(fabs(ROOT::Math::VectorUtil::Angle(
tau.p4(),(*hadron)->p4())),
189 fabs(ROOT::Math::VectorUtil::Angle(
tau.p4(),
strip)));
194 if(!emConstituents.empty())
195 for(std::vector<CandidatePtr>::const_iterator j=emConstituents.begin();j!=emConstituents.end();++j) {
196 signal.push_back(*j);
197 signalG.push_back(*j);
201 tau.setsignalChargedHadrCands(signalH);
202 tau.setsignalGammaCands(signalG);
203 tau.setsignalCands(signal);
204 tau.setleadChargedHadrCand(*hadron);
205 tau.setleadNeutralCand(emConstituents[0]);
208 if((*hadron)->pt()>emConstituents[0]->pt())
209 tau.setleadCand(*hadron);
211 tau.setleadCand(emConstituents[0]);
241 if(!hadrons.empty()&&
strips.size()>1){
243 for(
unsigned int Nstrip1=0;Nstrip1<
strips.size()-1;++Nstrip1)
244 for(
unsigned int Nstrip2=Nstrip1+1;Nstrip2<
strips.size();++Nstrip2)
245 for(std::vector<CandidatePtr>::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) {
250 std::vector<CandidatePtr> emConstituents1 =
strips[Nstrip1];
251 std::vector<CandidatePtr> emConstituents2 =
strips[Nstrip2];
268 (*hadron)->p4()+strip1+strip2,
269 (*hadron)->vertex());
277 tau.setpfTauTagInfoRef(tagInfo);
281 std::vector<CandidatePtr> signal;
282 std::vector<CandidatePtr> signalH;
283 std::vector<CandidatePtr> signalG;
286 signalH.push_back(*hadron);
287 signal.push_back(*hadron);
290 double tauCone=1000.0;
293 fabs(ROOT::Math::VectorUtil::Angle(
tau.p4(),strip1))),
294 fabs(ROOT::Math::VectorUtil::Angle(
tau.p4(),strip2)));
303 for(std::vector<CandidatePtr>::const_iterator j=emConstituents1.begin();j!=emConstituents1.end();++j) {
304 signal.push_back(*j);
305 signalG.push_back(*j);
308 for(std::vector<CandidatePtr>::const_iterator j=emConstituents2.begin();j!=emConstituents2.end();++j) {
309 signal.push_back(*j);
310 signalG.push_back(*j);
314 tau.setsignalChargedHadrCands(signalH);
315 tau.setsignalGammaCands(signalG);
316 tau.setsignalCands(signal);
317 tau.setleadChargedHadrCand(*hadron);
320 if((*hadron)->pt()>emConstituents1[0]->pt())
321 tau.setleadCand(*hadron);
323 tau.setleadCand(emConstituents1[0]);
362 for(
unsigned int a=0;
a<hadrons.size()-2;++
a)
363 for(
unsigned int b=
a+1;
b<hadrons.size()-1;++
b)
364 for(
unsigned int c=
b+1;
c<hadrons.size();++
c) {
373 if (h1 ==
nullptr || h2 ==
nullptr || h3 ==
nullptr) {
374 throw cms::Exception(
"Type Mismatch") <<
"The PFTau was not made from PFCandidates, and this outdated algorithm as not updated to cope with PFTaus made from other Candidates.\n";
391 std::vector<CandidatePtr> signal;
392 signal.push_back(c_h1);
393 signal.push_back(c_h2);
394 signal.push_back(c_h3);
396 double tauCone = 10000.0;
405 tauCone =
std::max(fabs(ROOT::Math::VectorUtil::Angle(tau.
p4(),h1->
p4())),
406 std::max(fabs(ROOT::Math::VectorUtil::Angle(tau.
p4(),h2->
p4())),
407 fabs(ROOT::Math::VectorUtil::Angle(tau.
p4(),h3->
p4()))));
446 if(cone<allowedConeSize)
459 using namespace reco;
467 std::vector<CandidatePtr> hadrons;
468 std::vector<CandidatePtr> gammas;
469 std::vector<CandidatePtr> neutral;
474 const std::vector<reco::CandidatePtr>& pfChargedHadrCands = tau.
pfTauTagInfoRef()->PFChargedHadrCands();
475 double tauEta=tau.
eta();
476 double tauPhi=tau.
phi();
477 for ( std::vector<reco::CandidatePtr>::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin();
478 pfChargedHadrCand != pfChargedHadrCands.end(); ++pfChargedHadrCand ) {
479 double dR =
reco::deltaR(tauEta, tauPhi, (*pfChargedHadrCand)->eta(), (*pfChargedHadrCand)->phi());
483 const std::vector<reco::CandidatePtr>& pfGammaCands = tau.
pfTauTagInfoRef()->PFGammaCands();
484 for ( std::vector<reco::CandidatePtr>::const_iterator pfGammaCand = pfGammaCands.begin();
485 pfGammaCand != pfGammaCands.end(); ++pfGammaCand ) {
486 double dR =
reco::deltaR(tauEta, tauPhi, (*pfGammaCand)->eta(), (*pfGammaCand)->phi());
490 const std::vector<reco::CandidatePtr>& pfNeutralHadrCands = tau.
pfTauTagInfoRef()->PFNeutrHadrCands();
491 for ( std::vector<reco::CandidatePtr>::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin();
492 pfNeutralHadrCand != pfNeutralHadrCands.end(); ++pfNeutralHadrCand ) {
493 double dR =
reco::deltaR(tauEta, tauPhi, (*pfNeutralHadrCand)->eta(), (*pfNeutralHadrCand)->phi());
497 double tauEta=tau.
eta();
498 double tauPhi=tau.
phi();
499 const std::vector<reco::CandidatePtr>& pfChargedHadrCands = tau.
pfTauTagInfoRef()->PFChargedHadrCands();
500 for ( std::vector<reco::CandidatePtr>::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin();
501 pfChargedHadrCand != pfChargedHadrCands.end(); ++pfChargedHadrCand ) {
502 double dR =
reco::deltaR(tauEta, tauPhi, (*pfChargedHadrCand)->eta(), (*pfChargedHadrCand)->phi());
506 const std::vector<reco::CandidatePtr>& pfGammaCands = tau.
pfTauTagInfoRef()->PFGammaCands();
507 for ( std::vector<reco::CandidatePtr>::const_iterator pfGammaCand = pfGammaCands.begin();
508 pfGammaCand != pfGammaCands.end(); ++pfGammaCand ) {
509 double dR =
reco::deltaR(tauEta, tauPhi, (*pfGammaCand)->eta(), (*pfGammaCand)->phi());
513 const std::vector<reco::CandidatePtr>& pfNeutralHadrCands = tau.
pfTauTagInfoRef()->PFNeutrHadrCands();
514 for ( std::vector<reco::CandidatePtr>::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin();
515 pfNeutralHadrCand != pfNeutralHadrCands.end(); ++pfNeutralHadrCand ) {
516 double dR =
reco::deltaR(tauEta, tauPhi, (*pfNeutralHadrCand)->eta(), (*pfNeutralHadrCand)->phi());
535 for(
unsigned int i=0;
i<hadrons.size();++
i)
537 sumPT+=hadrons[
i]->pt();
540 for(
unsigned int i=0;
i<gammas.size();++
i)
542 sumET+=gammas[
i]->pt();
552 std::vector<CandidatePtr> isoAll = hadrons;
553 for(
unsigned int i=0;
i<gammas.size();++
i)
554 isoAll.push_back(gammas[
i]);
556 for(
unsigned int i=0;i<neutral.size();++
i)
557 isoAll.push_back(neutral[i]);
578 segComp=(
float)(mu->matches().size());
579 if(mu->caloCompatibility()>caloComp)
580 caloComp = mu->caloCompatibility();
625 bool electronDecision;
627 electronDecision=
true;
629 electronDecision=
false;
672 if(oneProngStripMassWindow_.size()!=2)
673 throw cms::Exception(
"") <<
"OneProngStripMassWindow must be a vector of size 2 [min,max] " << std::endl;
674 if(oneProngTwoStripsMassWindow_.size()!=2)
675 throw cms::Exception(
"") <<
"OneProngTwoStripsMassWindow must be a vector of size 2 [min,max] " << std::endl;
676 if(threeProngMassWindow_.size()!=2)
677 throw cms::Exception(
"") <<
"ThreeProngMassWindow must be a vector of size 2 [min,max] " << std::endl;
678 if(coneMetric_!=
"angle" && coneMetric_ !=
"DR")
679 throw cms::Exception(
"") <<
"Cone Metric should be angle or DR " << std::endl;
692 for(
unsigned int i=0;
i<cands.size();++
i) {
701 std::vector<CandidatePtr> newVec;
703 std::vector<CandidatePtr>::iterator it;
704 it =
std::find(vec.begin(),vec.end(),cand);
712 double factor =
sqrt(vec.energy()*vec.energy()-mass*
mass)/vec.P();
713 vec.SetCoordinates(vec.px()*factor,vec.py()*factor,vec.pz()*factor,vec.energy());
730 std::vector<TransientTrack> transientTracks;
748 const std::vector<reco::TransientTrack>& refittedTracks = myVertex.
refittedTracks();
749 const reco::Track& track1 = refittedTracks.at(0).track();
751 const reco::Track& track2 = refittedTracks.at(1).track();
753 const reco::Track& track3 = refittedTracks.at(2).track();
768 reco::PFTauCollection::iterator it;
771 it = std::min_element(taus.begin(),taus.end(),
sorter);
776 it = std::min_element(taus.begin(),taus.end(),
sorter);
std::string coneSizeFormula_
T getParameter(std::string const &) const
double ecalEnergy() const
return corrected Ecal energy
int pdgId() const final
PDG identifier.
math::XYZTLorentzVector createMergedLorentzVector(const std::vector< reco::CandidatePtr > &)
void setsignalChargedHadrCands(const std::vector< reco::CandidatePtr > &)
void setMuonDecision(const bool &)
void setelectronPreIDOutput(const float &)
bool isNonnull() const
Checks for non-null.
std::vector< PFTau > PFTauCollection
collection of PFTau objects
double eta() const final
momentum pseudorapidity
void removeCandidateFromRefVector(const reco::CandidatePtr &, std::vector< reco::CandidatePtr > &)
void buildOneProng(const reco::PFTauTagInfoRef &, const std::vector< reco::CandidatePtr > &)
void setisolationNeutrHadrCands(const std::vector< reco::CandidatePtr > &)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
virtual std::vector< std::vector< reco::CandidatePtr > > mergeCandidates(const std::vector< reco::CandidatePtr > &)=0
void setelectronPreIDDecision(const bool &)
const TransientTrackBuilder * TransientTrackBuilder_
double gammaIsolationCone_
~HPSPFRecoTauAlgorithm() override
T const * get() const
Returns C++ pointer to the item.
Sin< T >::type sin(const T &t)
bool useIsolationAnnulus_
reco::TransientTrack build(const reco::Track *p) const
double pt() const final
transverse momentum
int charge() const final
electric charge
double leadPionThreshold_
const std::vector< reco::CandidatePtr > & signalGammaCands() const
Gamma candidates in signal region.
std::string overlapCriterion_
bool hasRefittedTracks() const
std::vector< double > threeProngMassWindow_
double px() const
x coordinate of momentum vector
void sethcal3x3OverPLead(const float &)
void setleadCand(const CandidatePtr &)
const Vector & momentum() const
track momentum vector
reco::PFTauCollection pfTaus_
void setisolationPFGammaCandsEtSum(const float &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void setemFraction(const float &)
const math::XYZPointF & positionAtECALEntrance() const
void setisolationChargedHadrCands(const std::vector< reco::CandidatePtr > &)
void setVertex(const Point &vertex) override
set vertex
void buildThreeProngs(const reco::PFTauTagInfoRef &, const std::vector< reco::CandidatePtr > &)
reco::TrackRef trackRef() const
void setleadChargedHadrCand(const CandidatePtr &)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
const Point & vertex() const override
vertex position (overwritten by PF...)
reco::PFTau getBestTauCandidate(reco::PFTauCollection &)
void setisolationCands(const std::vector< reco::CandidatePtr > &)
double et() const final
transverse energy
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
GlobalPoint position() const
void buildOneProngStrip(const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::CandidatePtr >> &, const std::vector< reco::CandidatePtr > &)
void setCaloComp(const float &)
void applyElectronRejection(reco::PFTau &, double)
double energy() const final
energy
Abs< T >::type abs(const T &t)
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
void setisolationPFChargedHadrCandsPtSum(const float &)
void setleadPFChargedHadrCandsignedSipt(const float &)
const LorentzVector & p4() const final
four-momentum Lorentz vector
reco::PFTau buildPFTau(const reco::PFTauTagInfoRef &, const reco::Vertex &) override
bool isNull() const
Checks for null.
void setsignalCands(const std::vector< reco::CandidatePtr > &)
void setbremsRecoveryEOverPLead(const float &)
reco::MuonRef muonRef() const
bool isNonnull() const
Checks for non-null.
double pz() const
z coordinate of momentum vector
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
float mva_e_pi() const
mva for electron-pion discrimination
double chargeIsolationCone_
const PFTauTagInfoRef & pfTauTagInfoRef() const
void sethcalMaxOverPLead(const float &)
std::vector< double > oneProngTwoStripsMassWindow_
virtual double pt() const =0
transverse momentum
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void setSegComp(const float &)
XYZPointD XYZPoint
point in space with cartesian internal representation
const std::vector< reco::CandidatePtr > & signalChargedHadrCands() const
Charged hadrons in signal region.
void setisolationGammaCands(const std::vector< reco::CandidatePtr > &)
bool doOneProngTwoStrips_
virtual int charge() const =0
electric charge
std::vector< double > oneProngStripMassWindow_
Particle reconstructed by the particle flow algorithm.
void setmaximumHCALPFClusterEt(const float &)
void applyMuonRejection(reco::PFTau &)
double hcalEnergy() const
return corrected Hcal energy
void setecalStripSumEOverPLead(const float &)
virtual const Point & vertex() const =0
vertex position
std::vector< double > oneProngTwoStripsPi0MassWindow_
double neutrHadrIsolationCone_
std::vector< reco::TransientTrack > const & refittedTracks() const
void sethcalTotOverPLead(const float &)
void applyMassConstraint(math::XYZTLorentzVector &, double)
const PFCandidatePtr leadPFChargedHadrCand() const
Getters for different PFCandidates for PFTaus made from PFCandidates.
void setelectronPreIDTrack(const reco::TrackRef &)
void configure(const edm::ParameterSet &)
bool refitThreeProng(reco::PFTau &)
PFCandidateMergerBase * candidateMerger_
double phi() const final
momentum azimuthal angle
bool isNarrowTau(const reco::PFTau &, double)
void setP4(const LorentzVector &p4) final
set 4-momentum
void associateIsolationCandidates(reco::PFTau &, double)
double py() const
y coordinate of momentum vector
void buildOneProngTwoStrips(const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::CandidatePtr >> &, const std::vector< reco::CandidatePtr > &)
double mass() const final
mass
void setpfTauTagInfoRef(const PFTauTagInfoRef)