2 #include "Math/GenVector/VectorUtil.h"
33 std::vector<PFCandidatePtr> hadrons = tagInfo->PFChargedHadrCands();
78 pfTau.
setP4(tagInfo->pfjetRef()->p4());
93 for(
unsigned int h=0;
h<hadrons.size();++
h) {
103 PFTau tau =
PFTau(hadron->charge(),hadron->p4(),hadron->vertex());
109 std::vector<PFCandidatePtr> signal;
110 signal.push_back(hadron);
148 if(hadrons.size()>0&&
strips.size()>0){
150 for(std::vector<std::vector<PFCandidatePtr>>::const_iterator candVector=
strips.begin();candVector!=
strips.end();++candVector)
151 for(std::vector<PFCandidatePtr>::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) {
155 std::vector<PFCandidatePtr> emConstituents = *candVector;
166 (*hadron)->p4()+strip,
167 (*hadron)->vertex());
174 tau.setpfTauTagInfoRef(tagInfo);
177 std::vector<PFCandidatePtr> signal;
178 std::vector<PFCandidatePtr> signalH;
179 std::vector<PFCandidatePtr> 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.size()>0)
195 for(std::vector<PFCandidatePtr>::const_iterator
j=emConstituents.begin();
j!=emConstituents.end();++
j) {
196 signal.push_back(*
j);
197 signalG.push_back(*
j);
201 tau.setsignalPFChargedHadrCands(signalH);
202 tau.setsignalPFGammaCands(signalG);
203 tau.setsignalPFCands(signal);
204 tau.setleadPFChargedHadrCand(*hadron);
205 tau.setleadPFNeutralCand(emConstituents[0]);
208 if((*hadron)->pt()>emConstituents[0]->pt())
209 tau.setleadPFCand(*hadron);
211 tau.setleadPFCand(emConstituents[0]);
241 if(hadrons.size()>0&&
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<PFCandidatePtr>::const_iterator hadron=hadrons.begin();hadron!=hadrons.end();++hadron) {
250 std::vector<PFCandidatePtr> emConstituents1 =
strips[Nstrip1];
251 std::vector<PFCandidatePtr> emConstituents2 =
strips[Nstrip2];
268 (*hadron)->p4()+strip1+strip2,
269 (*hadron)->vertex());
277 tau.setpfTauTagInfoRef(tagInfo);
281 std::vector<PFCandidatePtr> signal;
282 std::vector<PFCandidatePtr> signalH;
283 std::vector<PFCandidatePtr> 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<PFCandidatePtr>::const_iterator
j=emConstituents1.begin();
j!=emConstituents1.end();++
j) {
304 signal.push_back(*
j);
305 signalG.push_back(*
j);
308 for(std::vector<PFCandidatePtr>::const_iterator
j=emConstituents2.begin();
j!=emConstituents2.end();++
j) {
309 signal.push_back(*
j);
310 signalG.push_back(*
j);
314 tau.setsignalPFChargedHadrCands(signalH);
315 tau.setsignalPFGammaCands(signalG);
316 tau.setsignalPFCands(signal);
317 tau.setleadPFChargedHadrCand(*hadron);
320 if((*hadron)->pt()>emConstituents1[0]->pt())
321 tau.setleadPFCand(*hadron);
323 tau.setleadPFCand(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) {
371 int charge=h1->charge()+h2->charge()+h3->charge();
374 if(h1->trackRef()!=h2->trackRef()&&h1->trackRef()!=h3->trackRef()&&h2->trackRef()!=h3->trackRef())
378 PFTau tau =
PFTau(charge,h1->p4()+h2->p4()+h3->p4(),h1->vertex());
384 std::vector<PFCandidatePtr> signal;
385 signal.push_back(h1);
386 signal.push_back(h2);
387 signal.push_back(h3);
389 double tauCone = 10000.0;
398 tauCone =
std::max(fabs(ROOT::Math::VectorUtil::Angle(tau.
p4(),h1->p4())),
399 std::max(fabs(ROOT::Math::VectorUtil::Angle(tau.
p4(),h2->p4())),
400 fabs(ROOT::Math::VectorUtil::Angle(tau.
p4(),h3->p4()))));
439 if(cone<allowedConeSize)
452 using namespace reco;
460 std::vector<PFCandidatePtr> hadrons;
461 std::vector<PFCandidatePtr> gammas;
462 std::vector<PFCandidatePtr> neutral;
467 const std::vector<reco::PFCandidatePtr>& pfChargedHadrCands = tau.
pfTauTagInfoRef()->PFChargedHadrCands();
468 double tauEta=tau.
eta();
469 double tauPhi=tau.
phi();
470 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin();
471 pfChargedHadrCand != pfChargedHadrCands.end(); ++pfChargedHadrCand ) {
472 double dR =
reco::deltaR(tauEta, tauPhi, (*pfChargedHadrCand)->eta(), (*pfChargedHadrCand)->phi());
476 const std::vector<reco::PFCandidatePtr>& pfGammaCands = tau.
pfTauTagInfoRef()->PFGammaCands();
477 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfGammaCand = pfGammaCands.begin();
478 pfGammaCand != pfGammaCands.end(); ++pfGammaCand ) {
479 double dR =
reco::deltaR(tauEta, tauPhi, (*pfGammaCand)->eta(), (*pfGammaCand)->phi());
483 const std::vector<reco::PFCandidatePtr>& pfNeutralHadrCands = tau.
pfTauTagInfoRef()->PFNeutrHadrCands();
484 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin();
485 pfNeutralHadrCand != pfNeutralHadrCands.end(); ++pfNeutralHadrCand ) {
486 double dR =
reco::deltaR(tauEta, tauPhi, (*pfNeutralHadrCand)->eta(), (*pfNeutralHadrCand)->phi());
490 double tauEta=tau.
eta();
491 double tauPhi=tau.
phi();
492 const std::vector<reco::PFCandidatePtr>& pfChargedHadrCands = tau.
pfTauTagInfoRef()->PFChargedHadrCands();
493 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfChargedHadrCand = pfChargedHadrCands.begin();
494 pfChargedHadrCand != pfChargedHadrCands.end(); ++pfChargedHadrCand ) {
495 double dR =
reco::deltaR(tauEta, tauPhi, (*pfChargedHadrCand)->eta(), (*pfChargedHadrCand)->phi());
499 const std::vector<reco::PFCandidatePtr>& pfGammaCands = tau.
pfTauTagInfoRef()->PFGammaCands();
500 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfGammaCand = pfGammaCands.begin();
501 pfGammaCand != pfGammaCands.end(); ++pfGammaCand ) {
502 double dR =
reco::deltaR(tauEta, tauPhi, (*pfGammaCand)->eta(), (*pfGammaCand)->phi());
506 const std::vector<reco::PFCandidatePtr>& pfNeutralHadrCands = tau.
pfTauTagInfoRef()->PFNeutrHadrCands();
507 for ( std::vector<reco::PFCandidatePtr>::const_iterator pfNeutralHadrCand = pfNeutralHadrCands.begin();
508 pfNeutralHadrCand != pfNeutralHadrCands.end(); ++pfNeutralHadrCand ) {
509 double dR =
reco::deltaR(tauEta, tauPhi, (*pfNeutralHadrCand)->eta(), (*pfNeutralHadrCand)->phi());
528 for(
unsigned int i=0;
i<hadrons.size();++
i)
530 sumPT+=hadrons[
i]->pt();
533 for(
unsigned int i=0;
i<gammas.size();++
i)
535 sumET+=gammas[
i]->pt();
545 std::vector<PFCandidatePtr> isoAll = hadrons;
546 for(
unsigned int i=0;
i<gammas.size();++
i)
547 isoAll.push_back(gammas[
i]);
549 for(
unsigned int i=0;i<neutral.size();++
i)
550 isoAll.push_back(neutral[i]);
571 segComp=(float)(mu->matches().size());
572 if(mu->caloCompatibility()>caloComp)
573 caloComp = mu->caloCompatibility();
598 leadCharged->positionAtECALEntrance().y(),
599 leadCharged->positionAtECALEntrance().z());
605 if(leadCharged->trackRef().
isNonnull()) {
606 TrackRef track = leadCharged->trackRef();
607 tau.
setemFraction(leadCharged->ecalEnergy()/(leadCharged->ecalEnergy()+leadCharged->hcalEnergy()));
618 bool electronDecision;
619 if(
std::abs(leadCharged->pdgId())==11)
620 electronDecision=
true;
622 electronDecision=
false;
665 if(oneProngStripMassWindow_.size()!=2)
666 throw cms::Exception(
"") <<
"OneProngStripMassWindow must be a vector of size 2 [min,max] " << std::endl;
667 if(oneProngTwoStripsMassWindow_.size()!=2)
668 throw cms::Exception(
"") <<
"OneProngTwoStripsMassWindow must be a vector of size 2 [min,max] " << std::endl;
669 if(threeProngMassWindow_.size()!=2)
670 throw cms::Exception(
"") <<
"ThreeProngMassWindow must be a vector of size 2 [min,max] " << std::endl;
671 if(coneMetric_!=
"angle" && coneMetric_ !=
"DR")
672 throw cms::Exception(
"") <<
"Cone Metric should be angle or DR " << std::endl;
685 for(
unsigned int i=0;
i<cands.size();++
i) {
694 std::vector<PFCandidatePtr> newVec;
696 std::vector<PFCandidatePtr>::iterator it;
697 it =
std::find(vec.begin(),vec.end(),cand);
705 double factor =
sqrt(vec.energy()*vec.energy()-mass*
mass)/vec.P();
723 std::vector<TransientTrack> transientTracks;
742 const reco::Track& track1 = refittedTracks.at(0).track();
744 const reco::Track& track2 = refittedTracks.at(1).track();
746 const reco::Track& track3 = refittedTracks.at(2).track();
761 reco::PFTauCollection::iterator it;
764 it = std::min_element(taus.begin(),taus.end(),
sorter);
769 it = std::min_element(taus.begin(),taus.end(),
sorter);
std::string coneSizeFormula_
T getParameter(std::string const &) const
void setMuonDecision(const bool &)
void setelectronPreIDOutput(const float &)
bool isNonnull() const
Checks for non-null.
std::vector< PFTau > PFTauCollection
collection of PFTau objects
void setleadPFChargedHadrCand(const PFCandidatePtr &)
const PFCandidatePtr & leadPFChargedHadrCand() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void setelectronPreIDDecision(const bool &)
virtual double energy() const final
energy
math::XYZTLorentzVector createMergedLorentzVector(const std::vector< reco::PFCandidatePtr > &)
void setisolationPFCands(const std::vector< reco::PFCandidatePtr > &)
void buildOneProng(const reco::PFTauTagInfoRef &, const std::vector< reco::PFCandidatePtr > &)
const TransientTrackBuilder * TransientTrackBuilder_
double gammaIsolationCone_
void buildThreeProngs(const reco::PFTauTagInfoRef &, const std::vector< reco::PFCandidatePtr > &)
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const
Sin< T >::type sin(const T &t)
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
Gamma candidates in signal region.
bool useIsolationAnnulus_
reco::PFTau buildPFTau(const reco::PFTauTagInfoRef &, const reco::Vertex &)
reco::TransientTrack build(const reco::Track *p) const
virtual double phi() const final
momentum azimuthal angle
void buildOneProngStrip(const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::PFCandidatePtr >> &, const std::vector< reco::PFCandidatePtr > &)
double leadPionThreshold_
std::string overlapCriterion_
bool hasRefittedTracks() const
std::vector< double > threeProngMassWindow_
double px() const
x coordinate of momentum vector
void sethcal3x3OverPLead(const float &)
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 &)
void setisolationPFNeutrHadrCands(const std::vector< reco::PFCandidatePtr > &)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void setsignalPFChargedHadrCands(const std::vector< reco::PFCandidatePtr > &)
reco::PFTau getBestTauCandidate(reco::PFTauCollection &)
GlobalPoint position() const
void setleadPFCand(const PFCandidatePtr &)
void setCaloComp(const float &)
void applyElectronRejection(reco::PFTau &, double)
Abs< T >::type abs(const T &t)
void setisolationPFChargedHadrCandsPtSum(const float &)
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void setleadPFChargedHadrCandsignedSipt(const float &)
void setsignalPFCands(const std::vector< reco::PFCandidatePtr > &)
virtual std::vector< std::vector< reco::PFCandidatePtr > > mergeCandidates(const std::vector< reco::PFCandidatePtr > &)=0
virtual void setVertex(const Point &vertex)
set vertex
virtual double mass() const final
mass
bool isNull() const
Checks for null.
void setbremsRecoveryEOverPLead(const float &)
bool isNonnull() const
Checks for non-null.
double pz() const
z coordinate of momentum vector
double chargeIsolationCone_
const PFTauTagInfoRef & pfTauTagInfoRef() const
void sethcalMaxOverPLead(const float &)
std::vector< double > oneProngTwoStripsMassWindow_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void setisolationPFGammaCands(const std::vector< reco::PFCandidatePtr > &)
void setSegComp(const float &)
XYZPointD XYZPoint
point in space with cartesian internal representation
void setisolationPFChargedHadrCands(const std::vector< reco::PFCandidatePtr > &)
void buildOneProngTwoStrips(const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::PFCandidatePtr >> &, const std::vector< reco::PFCandidatePtr > &)
virtual void setP4(const LorentzVector &p4) final
set 4-momentum
bool doOneProngTwoStrips_
std::vector< double > oneProngStripMassWindow_
void setmaximumHCALPFClusterEt(const float &)
void removeCandidateFromRefVector(const reco::PFCandidatePtr &, std::vector< reco::PFCandidatePtr > &)
void applyMuonRejection(reco::PFTau &)
void setecalStripSumEOverPLead(const float &)
virtual double et() const final
transverse energy
std::vector< double > oneProngTwoStripsPi0MassWindow_
double neutrHadrIsolationCone_
std::vector< reco::TransientTrack > const & refittedTracks() const
void sethcalTotOverPLead(const float &)
virtual double eta() const final
momentum pseudorapidity
void applyMassConstraint(math::XYZTLorentzVector &, double)
void setelectronPreIDTrack(const reco::TrackRef &)
void configure(const edm::ParameterSet &)
bool refitThreeProng(reco::PFTau &)
PFCandidateMergerBase * candidateMerger_
bool isNarrowTau(const reco::PFTau &, double)
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
void associateIsolationCandidates(reco::PFTau &, double)
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Charged hadrons in signal region.
double py() const
y coordinate of momentum vector
virtual double pt() const final
transverse momentum
void setpfTauTagInfoRef(const PFTauTagInfoRef)