CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
HPSPFRecoTauAlgorithm Class Reference

#include <HPSPFRecoTauAlgorithm.h>

Inheritance diagram for HPSPFRecoTauAlgorithm:
PFRecoTauAlgorithmBase

Classes

class  HPSTauIsolationSorter
 
class  HPSTauPtSorter
 

Public Member Functions

reco::PFTau buildPFTau (const reco::PFTauTagInfoRef &, const reco::Vertex &) override
 
 HPSPFRecoTauAlgorithm ()
 
 HPSPFRecoTauAlgorithm (const edm::ParameterSet &)
 
 ~HPSPFRecoTauAlgorithm () override
 
- Public Member Functions inherited from PFRecoTauAlgorithmBase
 PFRecoTauAlgorithmBase ()
 
 PFRecoTauAlgorithmBase (const edm::ParameterSet &)
 
void setTransientTrackBuilder (const TransientTrackBuilder *)
 
virtual ~PFRecoTauAlgorithmBase ()
 

Private Member Functions

void applyElectronRejection (reco::PFTau &, double)
 
void applyMassConstraint (math::XYZTLorentzVector &, double)
 
void applyMuonRejection (reco::PFTau &)
 
void associateIsolationCandidates (reco::PFTau &, double)
 
void buildOneProng (const reco::PFTauTagInfoRef &, const std::vector< reco::CandidatePtr > &)
 
void buildOneProngStrip (const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::CandidatePtr >> &, const std::vector< reco::CandidatePtr > &)
 
void buildOneProngTwoStrips (const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::CandidatePtr >> &, const std::vector< reco::CandidatePtr > &)
 
void buildThreeProngs (const reco::PFTauTagInfoRef &, const std::vector< reco::CandidatePtr > &)
 
void configure (const edm::ParameterSet &)
 
math::XYZTLorentzVector createMergedLorentzVector (const std::vector< reco::CandidatePtr > &)
 
reco::PFTau getBestTauCandidate (reco::PFTauCollection &)
 
bool isNarrowTau (const reco::PFTau &, double)
 
bool refitThreeProng (reco::PFTau &)
 
void removeCandidateFromRefVector (const reco::CandidatePtr &, std::vector< reco::CandidatePtr > &)
 

Private Attributes

PFCandidateMergerBasecandidateMerger_
 
double chargeIsolationCone_
 
std::string coneMetric_
 
TFormula coneSizeFormula
 
std::string coneSizeFormula_
 
bool doOneProngs_
 
bool doOneProngStrips_
 
bool doOneProngTwoStrips_
 
bool doThreeProngs_
 
std::string emMerger_
 
double gammaIsolationCone_
 
double leadPionThreshold_
 
double matchingCone_
 
double maxSignalCone_
 
double minSignalCone_
 
double neutrHadrIsolationCone_
 
std::vector< double > oneProngStripMassWindow_
 
std::vector< double > oneProngTwoStripsMassWindow_
 
std::vector< double > oneProngTwoStripsPi0MassWindow_
 
std::string overlapCriterion_
 
reco::PFTauCollection pfTaus_
 
double stripPtThreshold_
 
double tauThreshold_
 
std::vector< double > threeProngMassWindow_
 
bool useIsolationAnnulus_
 

Additional Inherited Members

- Protected Attributes inherited from PFRecoTauAlgorithmBase
const TransientTrackBuilderTransientTrackBuilder_
 

Detailed Description

Definition at line 25 of file HPSPFRecoTauAlgorithm.h.

Constructor & Destructor Documentation

HPSPFRecoTauAlgorithm::HPSPFRecoTauAlgorithm ( )

Definition at line 6 of file HPSPFRecoTauAlgorithm.cc.

HPSPFRecoTauAlgorithm::HPSPFRecoTauAlgorithm ( const edm::ParameterSet config)

Definition at line 11 of file HPSPFRecoTauAlgorithm.cc.

References configure().

11  :
13 {
14  configure(config);
15 }
void configure(const edm::ParameterSet &)
HPSPFRecoTauAlgorithm::~HPSPFRecoTauAlgorithm ( )
override

Definition at line 17 of file HPSPFRecoTauAlgorithm.cc.

References candidateMerger_.

18 {
19  if(candidateMerger_ !=nullptr ) delete candidateMerger_;
20 }
PFCandidateMergerBase * candidateMerger_

Member Function Documentation

void HPSPFRecoTauAlgorithm::applyElectronRejection ( reco::PFTau tau,
double  stripEnergy 
)
private

Definition at line 595 of file HPSPFRecoTauAlgorithm.cc.

References funct::abs(), reco::PFCandidate::ecalEnergy(), reco::PFCandidate::hcalEnergy(), edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), reco::PFTau::leadPFChargedHadrCand(), reco::PFCandidate::mva_e_pi(), reco::LeafCandidate::pdgId(), reco::PFCandidate::positionAtECALEntrance(), reco::PFTau::setbremsRecoveryEOverPLead(), reco::PFTau::setecalStripSumEOverPLead(), reco::PFTau::setelectronPreIDDecision(), reco::PFTau::setelectronPreIDOutput(), reco::PFTau::setelectronPreIDTrack(), reco::PFTau::setemFraction(), reco::PFTau::sethcal3x3OverPLead(), reco::PFTau::sethcalMaxOverPLead(), reco::PFTau::sethcalTotOverPLead(), reco::PFTau::setmaximumHCALPFClusterEt(), funct::sin(), HiIsolationCommonParameters_cff::track, and reco::PFCandidate::trackRef().

Referenced by buildOneProng(), buildOneProngStrip(), buildOneProngTwoStrips(), and buildThreeProngs().

596 {
597  //Here we apply the common electron rejection variables.
598  //The only not common is the E/P that is applied in the decay mode
599  //construction
600 
601 
602  if(tau.leadPFChargedHadrCand().isNonnull()) {
603  PFCandidatePtr leadCharged = tau.leadPFChargedHadrCand();
604  math::XYZVector caloDir(leadCharged->positionAtECALEntrance().x(),
605  leadCharged->positionAtECALEntrance().y(),
606  leadCharged->positionAtECALEntrance().z());
607 
608  tau.setmaximumHCALPFClusterEt(leadCharged->hcalEnergy()*sin(caloDir.theta()));
609 
610 
611 
612  if(leadCharged->trackRef().isNonnull()) {
613  TrackRef track = leadCharged->trackRef();
614  tau.setemFraction(leadCharged->ecalEnergy()/(leadCharged->ecalEnergy()+leadCharged->hcalEnergy()));
615  //For H/P trust particle Flow ! :Just take HCAL energy of the candidate
616  //end of story
617  tau.sethcalTotOverPLead(leadCharged->hcalEnergy()/track->p());
618  tau.sethcalMaxOverPLead(leadCharged->hcalEnergy()/track->p());
619  tau.sethcal3x3OverPLead(leadCharged->hcalEnergy()/track->p());
620  tau.setelectronPreIDTrack(track);
621  tau.setelectronPreIDOutput(leadCharged->mva_e_pi());
622  //Since PF uses brem recovery we will store the default ecal energy here
623  tau.setbremsRecoveryEOverPLead(leadCharged->ecalEnergy()/track->p());
624  tau.setecalStripSumEOverPLead((leadCharged->ecalEnergy()-stripEnergy)/track->p());
625  bool electronDecision;
626  if(std::abs(leadCharged->pdgId())==11)
627  electronDecision=true;
628  else
629  electronDecision=false;
630  tau.setelectronPreIDDecision(electronDecision);
631  }
632  }
633 }
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:222
int pdgId() const final
PDG identifier.
void setelectronPreIDOutput(const float &)
Definition: PFTau.cc:347
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
void setelectronPreIDDecision(const bool &)
Definition: PFTau.cc:348
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void sethcal3x3OverPLead(const float &)
Definition: PFTau.cc:343
void setemFraction(const float &)
Definition: PFTau.cc:340
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:368
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setbremsRecoveryEOverPLead(const float &)
Definition: PFTau.cc:345
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
float mva_e_pi() const
mva for electron-pion discrimination
Definition: PFCandidate.h:314
void sethcalMaxOverPLead(const float &)
Definition: PFTau.cc:342
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
void setmaximumHCALPFClusterEt(const float &)
Definition: PFTau.cc:327
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:232
void setecalStripSumEOverPLead(const float &)
Definition: PFTau.cc:344
void sethcalTotOverPLead(const float &)
Definition: PFTau.cc:341
const PFCandidatePtr leadPFChargedHadrCand() const
Getters for different PFCandidates for PFTaus made from PFCandidates.
Definition: PFTau.cc:154
void setelectronPreIDTrack(const reco::TrackRef &)
Definition: PFTau.cc:346
void HPSPFRecoTauAlgorithm::applyMassConstraint ( math::XYZTLorentzVector vec,
double  mass 
)
private

Definition at line 710 of file HPSPFRecoTauAlgorithm.cc.

References ResonanceBuilder::mass, and mathSSE::sqrt().

Referenced by buildOneProngStrip(), and buildOneProngTwoStrips().

711 {
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());
714 }
T sqrt(T t)
Definition: SSEVec.h:18
void HPSPFRecoTauAlgorithm::applyMuonRejection ( reco::PFTau tau)
private

Definition at line 563 of file HPSPFRecoTauAlgorithm.cc.

References objects.autophobj::float, edm::Ptr< T >::isNonnull(), edm::Ref< C, T, F >::isNonnull(), reco::PFTau::leadPFChargedHadrCand(), RPCpg::mu, reco::PFCandidate::muonRef(), reco::PFTau::setCaloComp(), reco::PFTau::setMuonDecision(), and reco::PFTau::setSegComp().

Referenced by buildOneProng(), buildOneProngStrip(), buildOneProngTwoStrips(), and buildThreeProngs().

564 {
565 
566  // Require that no signal track has segment matches
567 
568  //Also:
569  //The segment compatibility is the number of matched Muon Segments
570  //the old available does not exist in the muons anymore so i will fill the data format with that
571  bool decision=true;
572  float caloComp=0.0;
573  float segComp=0.0;
574 
575  if(tau.leadPFChargedHadrCand().isNonnull()) {
577  if(mu.isNonnull()){
578  segComp=(float)(mu->matches().size());
579  if(mu->caloCompatibility()>caloComp)
580  caloComp = mu->caloCompatibility();
581 
582  if(segComp<1.0)
583  decision=false;
584 
585  tau.setCaloComp(caloComp);
586  tau.setSegComp(segComp);
587  tau.setMuonDecision(decision);
588  }
589 
590  }
591 }
void setMuonDecision(const bool &)
Definition: PFTau.cc:369
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
void setCaloComp(const float &)
Definition: PFTau.cc:367
const int mu
Definition: Constants.h:22
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:459
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
void setSegComp(const float &)
Definition: PFTau.cc:368
const PFCandidatePtr leadPFChargedHadrCand() const
Getters for different PFCandidates for PFTaus made from PFCandidates.
Definition: PFTau.cc:154
void HPSPFRecoTauAlgorithm::associateIsolationCandidates ( reco::PFTau tau,
double  tauCone 
)
private

Definition at line 454 of file HPSPFRecoTauAlgorithm.cc.

References chargeIsolationCone_, reco::deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::LeafCandidate::eta(), gammaIsolationCone_, mps_fire::i, edm::Ref< C, T, F >::isNull(), neutrHadrIsolationCone_, reco::PFTau::pfTauTagInfoRef(), reco::LeafCandidate::phi(), removeCandidateFromRefVector(), reco::PFTau::setisolationCands(), reco::PFTau::setisolationChargedHadrCands(), reco::PFTau::setisolationGammaCands(), reco::PFTau::setisolationNeutrHadrCands(), reco::PFTau::setisolationPFChargedHadrCandsPtSum(), reco::PFTau::setisolationPFGammaCandsEtSum(), reco::PFTau::signalChargedHadrCands(), reco::PFTau::signalGammaCands(), and useIsolationAnnulus_.

Referenced by buildOneProng(), buildOneProngStrip(), buildOneProngTwoStrips(), and buildThreeProngs().

456 {
457 
458 
459  using namespace reco;
460 
461  //Information to get filled
462  double sumPT=0;
463  double sumET=0;
464 
465  if(tau.pfTauTagInfoRef().isNull()) return;
466 
467  std::vector<CandidatePtr> hadrons;
468  std::vector<CandidatePtr> gammas;
469  std::vector<CandidatePtr> neutral;
470 
471  //Remove candidates outside the cones
473  {
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());
480  if ( dR > tauCone && dR < chargeIsolationCone_ ) hadrons.push_back(*pfChargedHadrCand);
481  }
482 
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());
487  if ( dR > tauCone && dR < gammaIsolationCone_ ) gammas.push_back(*pfGammaCand);
488  }
489 
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());
494  if ( dR > tauCone && dR < neutrHadrIsolationCone_ ) hadrons.push_back(*pfNeutralHadrCand);
495  }
496  } else {
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());
503  if ( dR < chargeIsolationCone_ ) hadrons.push_back(*pfChargedHadrCand);
504  }
505 
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());
510  if ( dR < gammaIsolationCone_ ) gammas.push_back(*pfGammaCand);
511  }
512 
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());
517  if ( dR < neutrHadrIsolationCone_ ) hadrons.push_back(*pfNeutralHadrCand);
518  }
519  }
520 
521  //remove the signal Constituents from the collections
522  for(std::vector<CandidatePtr>::const_iterator i=tau.signalChargedHadrCands().begin();i!=tau.signalChargedHadrCands().end();++i)
523  {
525  }
526 
527  for(std::vector<CandidatePtr>::const_iterator i=tau.signalGammaCands().begin();i!=tau.signalGammaCands().end();++i)
528  {
530  removeCandidateFromRefVector(*i,hadrons);//special case where we included a hadron if the strip!
531  }
532 
533 
534  //calculate isolation deposits
535  for(unsigned int i=0;i<hadrons.size();++i)
536  {
537  sumPT+=hadrons[i]->pt();
538  }
539 
540  for(unsigned int i=0;i<gammas.size();++i)
541  {
542  sumET+=gammas[i]->pt();
543  }
544 
545 
548  tau.setisolationChargedHadrCands(hadrons);
549  tau.setisolationNeutrHadrCands(neutral);
550  tau.setisolationGammaCands(gammas);
551 
552  std::vector<CandidatePtr> isoAll = hadrons;
553  for(unsigned int i=0;i<gammas.size();++i)
554  isoAll.push_back(gammas[i]);
555 
556  for(unsigned int i=0;i<neutral.size();++i)
557  isoAll.push_back(neutral[i]);
558 
559  tau.setisolationCands(isoAll);
560 }
double eta() const final
momentum pseudorapidity
void removeCandidateFromRefVector(const reco::CandidatePtr &, std::vector< reco::CandidatePtr > &)
void setisolationNeutrHadrCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:92
const std::vector< reco::CandidatePtr > & signalGammaCands() const
Gamma candidates in signal region.
Definition: PFTau.cc:84
void setisolationPFGammaCandsEtSum(const float &)
Definition: PFTau.cc:324
void setisolationChargedHadrCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:90
void setisolationCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:88
void setisolationPFChargedHadrCandsPtSum(const float &)
Definition: PFTau.cc:321
bool isNull() const
Checks for null.
Definition: Ref.h:248
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
const PFTauTagInfoRef & pfTauTagInfoRef() const
Definition: PFTau.cc:61
const std::vector< reco::CandidatePtr > & signalChargedHadrCands() const
Charged hadrons in signal region.
Definition: PFTau.cc:80
void setisolationGammaCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:94
fixed size matrix
double phi() const final
momentum azimuthal angle
void HPSPFRecoTauAlgorithm::buildOneProng ( const reco::PFTauTagInfoRef tagInfo,
const std::vector< reco::CandidatePtr > &  hadrons 
)
private

Definition at line 88 of file HPSPFRecoTauAlgorithm.cc.

References applyElectronRejection(), applyMuonRejection(), associateIsolationCandidates(), reco::Candidate::charge(), HiRegitMuonDetachedTripletStep_cff::DeltaR, getBestTauCandidate(), h, leadPionThreshold_, matchingCone_, reco::Candidate::p4(), RecoPFTauTag_cff::PFTau, pfTaus_, reco::Candidate::pt(), reco::PFTau::setleadCand(), reco::PFTau::setleadChargedHadrCand(), reco::PFTau::setpfTauTagInfoRef(), reco::PFTau::setsignalCands(), reco::PFTau::setsignalChargedHadrCands(), metsig::tau, nano_cff::taus, tauThreshold_, and reco::Candidate::vertex().

Referenced by buildPFTau().

89 {
91 
92  if(!hadrons.empty())
93  for(unsigned int h=0;h<hadrons.size();++h) {
94  CandidatePtr hadron = hadrons[h];
95 
96  //In the one prong case the lead Track pt should be above the tau Threshold!
97  //since all the tau is just one track!
98  if(hadron->pt()>tauThreshold_)
99  if(hadron->pt()>leadPionThreshold_)
100  //The track should be within the matching cone
101  if(ROOT::Math::VectorUtil::DeltaR(hadron->p4(),tagInfo->pfjetRef()->p4())<matchingCone_) {
102  //OK Lets create a Particle Flow Tau!
103  PFTau tau = PFTau(hadron->charge(),hadron->p4(),hadron->vertex());
104 
105  //Associate the Tag Info to the tau
106  tau.setpfTauTagInfoRef(tagInfo);
107 
108  //Put the Hadron in the signal Constituents
109  std::vector<CandidatePtr> signal;
110  signal.push_back(hadron);
111 
112  //Set The signal candidates of the PF Tau
113  tau.setsignalChargedHadrCands(signal);
114  tau.setsignalCands(signal);
115  tau.setleadChargedHadrCand(hadron);
116  tau.setleadCand(hadron);
117 
118  //Fill isolation variables
120 
121  //Apply Muon rejection algorithms
122  applyMuonRejection(tau);
123  applyElectronRejection(tau,0.0);
124 
125  //Save this candidate
126  taus.push_back(tau);
127  }
128  }
129  if(!taus.empty()) {
130  pfTaus_.push_back(getBestTauCandidate(taus));
131  }
132 
133 }
void setsignalChargedHadrCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:81
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void setleadCand(const CandidatePtr &)
Definition: PFTau.cc:73
reco::PFTauCollection pfTaus_
void setleadChargedHadrCand(const CandidatePtr &)
Definition: PFTau.cc:71
reco::PFTau getBestTauCandidate(reco::PFTauCollection &)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
void applyElectronRejection(reco::PFTau &, double)
void setsignalCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:79
virtual double pt() const =0
transverse momentum
virtual int charge() const =0
electric charge
void applyMuonRejection(reco::PFTau &)
virtual const Point & vertex() const =0
vertex position
void associateIsolationCandidates(reco::PFTau &, double)
void setpfTauTagInfoRef(const PFTauTagInfoRef)
Definition: PFTau.cc:65
void HPSPFRecoTauAlgorithm::buildOneProngStrip ( const reco::PFTauTagInfoRef ,
const std::vector< std::vector< reco::CandidatePtr >> &  ,
const std::vector< reco::CandidatePtr > &   
)
private

Definition at line 138 of file HPSPFRecoTauAlgorithm.cc.

References applyElectronRejection(), applyMassConstraint(), applyMuonRejection(), associateIsolationCandidates(), coneMetric_, createMergedLorentzVector(), HiRegitMuonDetachedTripletStep_cff::DeltaR, getBestTauCandidate(), isNarrowTau(), matchingCone_, SiStripPI::max, oneProngStripMassWindow_, pfTaus_, removeCandidateFromRefVector(), digitizers_cfi::strip, stripPtThreshold_, RecoTauPiZeroBuilderPlugins_cfi::strips, metsig::tau, nano_cff::taus, and tauThreshold_.

Referenced by buildPFTau().

140 {
141  //Create output Collection
143 
144 
145 
146 
147  //make taus like this only if there is at least one hadron+ 1 strip
148  if(!hadrons.empty()&&!strips.empty()){
149  //Combinatorics between strips and clusters
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) {
152 
153  //First Cross cleaning ! If you asked to clusterize the candidates
154  //with tracks too then you should not double count the track
155  std::vector<CandidatePtr> emConstituents = *candVector;
156  removeCandidateFromRefVector(*hadron,emConstituents);
157 
158  //Create a LorentzVector for the strip
160 
161  //TEST: Apply Strip Constraint
162  applyMassConstraint(strip,0.1349);
163 
164  //create the Particle Flow Tau: Hadron plus Strip
165  PFTau tau((*hadron)->charge(),
166  (*hadron)->p4()+strip,
167  (*hadron)->vertex());
168 
169  //Check tau threshold, mass, Matching Cone window
170  if(tau.pt()>tauThreshold_&&strip.pt()>stripPtThreshold_)
171  if(tau.mass()>oneProngStripMassWindow_[0]&&tau.mass()<oneProngStripMassWindow_[1])//Apply mass window
172  if(ROOT::Math::VectorUtil::DeltaR(tau.p4(),tagInfo->pfjetRef()->p4())<matchingCone_) { //Apply matching cone
173  //Set The Tag Infor ref
174  tau.setpfTauTagInfoRef(tagInfo);
175 
176  //Create the signal vectors
177  std::vector<CandidatePtr> signal;
178  std::vector<CandidatePtr> signalH;
179  std::vector<CandidatePtr> signalG;
180 
181  //Store the hadron in the PFTau
182  signalH.push_back(*hadron);
183  signal.push_back(*hadron);
184 
185  //calculate the cone size : For the strip use it as one candidate !
186  double tauCone=0.0;
187  if(coneMetric_ =="angle")
188  tauCone=std::max(fabs(ROOT::Math::VectorUtil::Angle(tau.p4(),(*hadron)->p4())),
189  fabs(ROOT::Math::VectorUtil::Angle(tau.p4(),strip)));
190  else if(coneMetric_ == "DR")
191  tauCone=std::max(ROOT::Math::VectorUtil::DeltaR(tau.p4(),(*hadron)->p4()),
193 
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);
198  }
199 
200  //Set the PFTau
201  tau.setsignalChargedHadrCands(signalH);
202  tau.setsignalGammaCands(signalG);
203  tau.setsignalCands(signal);
204  tau.setleadChargedHadrCand(*hadron);
205  tau.setleadNeutralCand(emConstituents[0]);
206 
207  //Set the lead Candidate->Can be the hadron or the leading PFGamma(When we clear the Dataformat we will put the strip)
208  if((*hadron)->pt()>emConstituents[0]->pt())
209  tau.setleadCand(*hadron);
210  else
211  tau.setleadCand(emConstituents[0]);
212 
213  //Apply the signal cone size formula
214  if(isNarrowTau(tau,tauCone)) {
215  //calculate the isolation Deposits
217  //Set Muon Rejection
219  applyElectronRejection(tau,strip.energy());
220 
221  taus.push_back(tau);
222  }
223  }
224  }
225  }
226 
227  if(!taus.empty()) {
228  pfTaus_.push_back(getBestTauCandidate(taus));
229  }
230 
231 }
math::XYZTLorentzVector createMergedLorentzVector(const std::vector< reco::CandidatePtr > &)
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
void removeCandidateFromRefVector(const reco::CandidatePtr &, std::vector< reco::CandidatePtr > &)
reco::PFTauCollection pfTaus_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
reco::PFTau getBestTauCandidate(reco::PFTauCollection &)
void applyElectronRejection(reco::PFTau &, double)
std::vector< double > oneProngStripMassWindow_
void applyMuonRejection(reco::PFTau &)
void applyMassConstraint(math::XYZTLorentzVector &, double)
bool isNarrowTau(const reco::PFTau &, double)
void associateIsolationCandidates(reco::PFTau &, double)
void HPSPFRecoTauAlgorithm::buildOneProngTwoStrips ( const reco::PFTauTagInfoRef ,
const std::vector< std::vector< reco::CandidatePtr >> &  ,
const std::vector< reco::CandidatePtr > &   
)
private

Definition at line 234 of file HPSPFRecoTauAlgorithm.cc.

References applyElectronRejection(), applyMassConstraint(), applyMuonRejection(), associateIsolationCandidates(), coneMetric_, createMergedLorentzVector(), HiRegitMuonDetachedTripletStep_cff::DeltaR, getBestTauCandidate(), isNarrowTau(), matchingCone_, SiStripPI::max, oneProngTwoStripsMassWindow_, oneProngTwoStripsPi0MassWindow_, pfTaus_, removeCandidateFromRefVector(), stripPtThreshold_, RecoTauPiZeroBuilderPlugins_cfi::strips, metsig::tau, nano_cff::taus, and tauThreshold_.

Referenced by buildPFTau().

235 {
236 
237 
239 
240  //make taus like this only if there is at least one hadron+ 2 strips
241  if(!hadrons.empty()&&strips.size()>1){
242  //Combinatorics between strips and clusters
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) {
246 
247 
248 
249  //Create the strips and the vectors .Again cross clean the track if associated
250  std::vector<CandidatePtr> emConstituents1 = strips[Nstrip1];
251  std::vector<CandidatePtr> emConstituents2 = strips[Nstrip2];
252  removeCandidateFromRefVector(*hadron,emConstituents1);
253  removeCandidateFromRefVector(*hadron,emConstituents2);
254 
255 
256  //Create a LorentzVector for the strip
257  math::XYZTLorentzVector strip1 = createMergedLorentzVector(emConstituents1);
258  math::XYZTLorentzVector strip2 = createMergedLorentzVector(emConstituents2);
259 
260 
261 
262  //Apply Mass Constraints
263  applyMassConstraint(strip1,0.0);
264  applyMassConstraint(strip2,0.0);
265 
266 
267  PFTau tau((*hadron)->charge(),
268  (*hadron)->p4()+strip1+strip2,
269  (*hadron)->vertex());
270 
271 
272  if(tau.pt()>tauThreshold_&&strip1.pt()>stripPtThreshold_&&strip2.pt()>stripPtThreshold_)
273  if((strip1+strip2).M() >oneProngTwoStripsPi0MassWindow_[0] &&(strip1+strip2).M() <oneProngTwoStripsPi0MassWindow_[1] )//pi0 conmstraint for two strips
274  if(tau.mass()>oneProngTwoStripsMassWindow_[0]&&tau.mass()<oneProngTwoStripsMassWindow_[1] )//Apply mass window
275  if(ROOT::Math::VectorUtil::DeltaR(tau.p4(),tagInfo->pfjetRef()->p4())<matchingCone_) { //Apply matching cone
276  //create the PFTau
277  tau.setpfTauTagInfoRef(tagInfo);
278 
279 
280  //Create the signal vectors
281  std::vector<CandidatePtr> signal;
282  std::vector<CandidatePtr> signalH;
283  std::vector<CandidatePtr> signalG;
284 
285  //Store the hadron in the PFTau
286  signalH.push_back(*hadron);
287  signal.push_back(*hadron);
288 
289  //calculate the cone size from the reconstructed Objects
290  double tauCone=1000.0;
291  if(coneMetric_ =="angle") {
292  tauCone=std::max(std::max(fabs(ROOT::Math::VectorUtil::Angle(tau.p4(),(*hadron)->p4())),
293  fabs(ROOT::Math::VectorUtil::Angle(tau.p4(),strip1))),
294  fabs(ROOT::Math::VectorUtil::Angle(tau.p4(),strip2)));
295  }
296  else if(coneMetric_ =="DR") {
297  tauCone=std::max(std::max((ROOT::Math::VectorUtil::DeltaR(tau.p4(),(*hadron)->p4())),
298  (ROOT::Math::VectorUtil::DeltaR(tau.p4(),strip1))),
299  (ROOT::Math::VectorUtil::DeltaR(tau.p4(),strip2)));
300 
301  }
302 
303  for(std::vector<CandidatePtr>::const_iterator j=emConstituents1.begin();j!=emConstituents1.end();++j) {
304  signal.push_back(*j);
305  signalG.push_back(*j);
306  }
307 
308  for(std::vector<CandidatePtr>::const_iterator j=emConstituents2.begin();j!=emConstituents2.end();++j) {
309  signal.push_back(*j);
310  signalG.push_back(*j);
311  }
312 
313  //Set the PFTau
314  tau.setsignalChargedHadrCands(signalH);
315  tau.setsignalGammaCands(signalG);
316  tau.setsignalCands(signal);
317  tau.setleadChargedHadrCand(*hadron);
318 
319  //Set the lead Candidate->Can be the hadron or the leading PFGamma(When we clear the Dataformat we will put the strip)
320  if((*hadron)->pt()>emConstituents1[0]->pt())
321  tau.setleadCand(*hadron);
322  else
323  tau.setleadCand(emConstituents1[0]);
324 
325  //Apply the cone size formula
326  if(isNarrowTau(tau,tauCone)) {
327 
328  //calculate the isolation Deposits
330 
332 
333  //For two strips take the nearest strip to the track
334  if(ROOT::Math::VectorUtil::DeltaR(strip1,(*hadron)->p4())<
335  ROOT::Math::VectorUtil::DeltaR(strip2,(*hadron)->p4()))
336  applyElectronRejection(tau,strip1.energy());
337  else
338  applyElectronRejection(tau,strip2.energy());
339 
340  taus.push_back(tau);
341  }
342  }
343  }
344  }
345 
346  if(!taus.empty()) {
347  pfTaus_.push_back(getBestTauCandidate(taus));
348  }
349 }
math::XYZTLorentzVector createMergedLorentzVector(const std::vector< reco::CandidatePtr > &)
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
void removeCandidateFromRefVector(const reco::CandidatePtr &, std::vector< reco::CandidatePtr > &)
reco::PFTauCollection pfTaus_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
reco::PFTau getBestTauCandidate(reco::PFTauCollection &)
void applyElectronRejection(reco::PFTau &, double)
std::vector< double > oneProngTwoStripsMassWindow_
void applyMuonRejection(reco::PFTau &)
std::vector< double > oneProngTwoStripsPi0MassWindow_
void applyMassConstraint(math::XYZTLorentzVector &, double)
bool isNarrowTau(const reco::PFTau &, double)
void associateIsolationCandidates(reco::PFTau &, double)
PFTau HPSPFRecoTauAlgorithm::buildPFTau ( const reco::PFTauTagInfoRef tagInfo,
const reco::Vertex vertex 
)
overridevirtual

Implements PFRecoTauAlgorithmBase.

Definition at line 23 of file HPSPFRecoTauAlgorithm.cc.

References TransientTrackBuilder::build(), buildOneProng(), buildOneProngStrip(), buildOneProngTwoStrips(), buildThreeProngs(), candidateMerger_, doOneProngs_, doOneProngStrips_, doOneProngTwoStrips_, doThreeProngs_, getBestTauCandidate(), edm::Ref< C, T, F >::isNonnull(), metsig::jet, reco::PFTau::leadPFChargedHadrCand(), TauDiscriminatorTools::leadTrack, PFCandidateMergerBase::mergeCandidates(), pfTaus_, reco::PFTau::pfTauTagInfoRef(), reco::PFTau::setleadPFChargedHadrCandsignedSipt(), reco::LeafCandidate::setP4(), reco::PFTau::setpfTauTagInfoRef(), IPTools::signedTransverseImpactParameter(), TauTagTools::sortRefVectorByPt(), RecoTauPiZeroBuilderPlugins_cfi::strips, reco::PFCandidate::trackRef(), and PFRecoTauAlgorithmBase::TransientTrackBuilder_.

24 {
25  PFTau pfTau;
26 
27  pfTaus_.clear();
28  //make the strips globally.
29  std::vector<std::vector<CandidatePtr> > strips = candidateMerger_->mergeCandidates(tagInfo->PFCands());
30 
31 
32  //Sort the hadrons globally and once!
33  std::vector<CandidatePtr> hadrons = tagInfo->PFChargedHadrCands();
34  if(hadrons.size()>1)
36 
37 
38  //OK For this Tau Tag Info we should create all the possible taus
39 
40  //One Prongs
41  if(doOneProngs_)
42  buildOneProng(tagInfo,hadrons);
43 
44  //One Prong Strips
46  buildOneProngStrip(tagInfo,strips,hadrons);
47 
48  //One Prong TwoStrips
50  buildOneProngTwoStrips(tagInfo,strips,hadrons);
51 
52  //Three Prong
53  if(doThreeProngs_)
54  buildThreeProngs(tagInfo,hadrons);
55 
56 
57  //Lets see if we created any taus
58  if(!pfTaus_.empty()) {
59 
61 
62  //Set the IP for the leading track
65  if(pfTau.pfTauTagInfoRef().isNonnull())
66  if(pfTau.pfTauTagInfoRef()->pfjetRef().isNonnull()) {
67  JetBaseRef jet = pfTau.pfTauTagInfoRef()->pfjetRef();
68  GlobalVector jetDir(jet->px(),jet->py(),jet->pz());
69  if(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).first)
70  pfTau.setleadPFChargedHadrCandsignedSipt(IPTools::signedTransverseImpactParameter(leadTrack,jetDir,vertex).second.significance());
71  }
72  }
73  }
74  else { //null PFTau
75  //Simone asked that in case there is no tau returned make a tau
76  //without refs and the LV of the jet
77  pfTau.setpfTauTagInfoRef(tagInfo);
78  pfTau.setP4(tagInfo->pfjetRef()->p4());
79  }
80 
81  return pfTau;
82 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
void buildOneProng(const reco::PFTauTagInfoRef &, const std::vector< reco::CandidatePtr > &)
virtual std::vector< std::vector< reco::CandidatePtr > > mergeCandidates(const std::vector< reco::CandidatePtr > &)=0
const TransientTrackBuilder * TransientTrackBuilder_
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
reco::TransientTrack build(const reco::Track *p) const
reco::PFTauCollection pfTaus_
void buildThreeProngs(const reco::PFTauTagInfoRef &, const std::vector< reco::CandidatePtr > &)
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
reco::PFTau getBestTauCandidate(reco::PFTauCollection &)
void buildOneProngStrip(const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::CandidatePtr >> &, const std::vector< reco::CandidatePtr > &)
void setleadPFChargedHadrCandsignedSipt(const float &)
Definition: PFTau.cc:76
void sortRefVectorByPt(std::vector< reco::CandidatePtr > &)
Definition: TauTagTools.cc:242
const PFTauTagInfoRef & pfTauTagInfoRef() const
Definition: PFTau.cc:61
const PFCandidatePtr leadPFChargedHadrCand() const
Getters for different PFCandidates for PFTaus made from PFCandidates.
Definition: PFTau.cc:154
PFCandidateMergerBase * candidateMerger_
void setP4(const LorentzVector &p4) final
set 4-momentum
void buildOneProngTwoStrips(const reco::PFTauTagInfoRef &, const std::vector< std::vector< reco::CandidatePtr >> &, const std::vector< reco::CandidatePtr > &)
void setpfTauTagInfoRef(const PFTauTagInfoRef)
Definition: PFTau.cc:65
void HPSPFRecoTauAlgorithm::buildThreeProngs ( const reco::PFTauTagInfoRef tagInfo,
const std::vector< reco::CandidatePtr > &  hadrons 
)
private

Definition at line 354 of file HPSPFRecoTauAlgorithm.cc.

References a, funct::abs(), applyElectronRejection(), applyMuonRejection(), associateIsolationCandidates(), b, EnergyCorrector::c, ALCARECOTkAlJpsiMuMu_cff::charge, reco::LeafCandidate::charge(), coneMetric_, HiRegitMuonDetachedTripletStep_cff::DeltaR, Exception, edm::Ptr< T >::get(), getBestTauCandidate(), isNarrowTau(), leadPionThreshold_, reco::LeafCandidate::mass(), matchingCone_, SiStripPI::max, reco::LeafCandidate::p4(), RecoPFTauTag_cff::PFTau, pfTaus_, reco::LeafCandidate::pt(), refitThreeProng(), reco::PFTau::setleadCand(), reco::PFTau::setleadChargedHadrCand(), reco::PFTau::setpfTauTagInfoRef(), reco::PFTau::setsignalCands(), reco::PFTau::setsignalChargedHadrCands(), metsig::tau, nano_cff::taus, tauThreshold_, threeProngMassWindow_, reco::PFCandidate::trackRef(), and reco::PFCandidate::vertex().

Referenced by buildPFTau().

355 {
357  //get Hadrons
358 
359 
360  //Require at least three hadrons
361  if(hadrons.size()>2)
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) {
365 
366  CandidatePtr c_h1 = hadrons[a];
367  CandidatePtr c_h2 = hadrons[b];
368  CandidatePtr c_h3 = hadrons[c];
369 
370  const reco::PFCandidate* h1 = dynamic_cast<const reco::PFCandidate*>(c_h1.get());
371  const reco::PFCandidate* h2 = dynamic_cast<const reco::PFCandidate*>(c_h2.get());
372  const reco::PFCandidate* h3 = dynamic_cast<const reco::PFCandidate*>(c_h3.get());
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";
375  }
376 
377  //check charge Compatibility and lead track
378  int charge=h1->charge()+h2->charge()+h3->charge();
379  if(std::abs(charge)==1 && h1->pt()>leadPionThreshold_)
380  //check the track refs
381  if(h1->trackRef()!=h2->trackRef()&&h1->trackRef()!=h3->trackRef()&&h2->trackRef()!=h3->trackRef())
382  {
383 
384  //create the tau
385  PFTau tau = PFTau(charge,h1->p4()+h2->p4()+h3->p4(),h1->vertex());
386  tau.setpfTauTagInfoRef(tagInfo);
387 
388  if(tau.pt()>tauThreshold_)//Threshold
389  if(ROOT::Math::VectorUtil::DeltaR(tau.p4(),tagInfo->pfjetRef()->p4())<matchingCone_) {//Matching Cone
390 
391  std::vector<CandidatePtr> signal;
392  signal.push_back(c_h1);
393  signal.push_back(c_h2);
394  signal.push_back(c_h3);
395  //calculate the tau cone by getting the maximum distance
396  double tauCone = 10000.0;
397  if(coneMetric_=="DR")
398  {
399  tauCone = std::max(ROOT::Math::VectorUtil::DeltaR(tau.p4(),h1->p4()),
401  ROOT::Math::VectorUtil::DeltaR(tau.p4(),h3->p4())));
402  }
403  else if(coneMetric_=="angle")
404  {
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()))));
408  }
409 
410  //Set The PFTau
411  tau.setsignalChargedHadrCands(signal);
412  tau.setsignalCands(signal);
413  tau.setleadChargedHadrCand(c_h1);
414  tau.setleadCand(c_h1);
415 
416  if(isNarrowTau(tau,tauCone)) {
417  //calculate the isolation Deposits
418  associateIsolationCandidates(tau,tauCone);
419  applyMuonRejection(tau);
420  applyElectronRejection(tau,0.0);
421  taus.push_back(tau);
422 
423  }
424  }
425  }
426  }
427 
428  if(!taus.empty()) {
429  PFTau bestTau = getBestTauCandidate(taus);
430  if(refitThreeProng(bestTau))
431  //Apply mass constraint
432  if ( bestTau.mass() > threeProngMassWindow_[0] && bestTau.mass() < threeProngMassWindow_[1] )//MassWindow
433  pfTaus_.push_back(bestTau);
434  }
435 
436 }
void setsignalChargedHadrCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:81
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
double pt() const final
transverse momentum
int charge() const final
electric charge
Definition: LeafCandidate.h:91
std::vector< double > threeProngMassWindow_
void setleadCand(const CandidatePtr &)
Definition: PFTau.cc:73
reco::PFTauCollection pfTaus_
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
void setleadChargedHadrCand(const CandidatePtr &)
Definition: PFTau.cc:71
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:656
reco::PFTau getBestTauCandidate(reco::PFTauCollection &)
void applyElectronRejection(reco::PFTau &, double)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
void setsignalCands(const std::vector< reco::CandidatePtr > &)
Definition: PFTau.cc:79
double b
Definition: hdecay.h:120
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
double a
Definition: hdecay.h:121
void applyMuonRejection(reco::PFTau &)
bool refitThreeProng(reco::PFTau &)
bool isNarrowTau(const reco::PFTau &, double)
void associateIsolationCandidates(reco::PFTau &, double)
double mass() const final
mass
void setpfTauTagInfoRef(const PFTauTagInfoRef)
Definition: PFTau.cc:65
void HPSPFRecoTauAlgorithm::configure ( const edm::ParameterSet p)
private

Definition at line 639 of file HPSPFRecoTauAlgorithm.cc.

References candidateMerger_, chargeIsolationCone_, TauTagTools::computeConeSizeTFormula(), coneMetric_, coneSizeFormula, coneSizeFormula_, doOneProngs_, doOneProngStrips_, doOneProngTwoStrips_, doThreeProngs_, emMerger_, Exception, gammaIsolationCone_, edm::ParameterSet::getParameter(), leadPionThreshold_, matchingCone_, maxSignalCone_, minSignalCone_, neutrHadrIsolationCone_, oneProngStripMassWindow_, oneProngTwoStripsMassWindow_, oneProngTwoStripsPi0MassWindow_, overlapCriterion_, AlCaHLTBitMon_QueryRunRegistry::string, stripPtThreshold_, tauThreshold_, threeProngMassWindow_, and useIsolationAnnulus_.

Referenced by HPSPFRecoTauAlgorithm().

640 {
641  emMerger_ = p.getParameter<std::string>("emMergingAlgorithm");
642  overlapCriterion_ = p.getParameter<std::string>("candOverlapCriterion");
643  doOneProngs_ = p.getParameter<bool>("doOneProng");
644  doOneProngStrips_ = p.getParameter<bool>("doOneProngStrip");
645  doOneProngTwoStrips_ = p.getParameter<bool>("doOneProngTwoStrips");
646  doThreeProngs_ = p.getParameter<bool>("doThreeProng");
647  tauThreshold_ = p.getParameter<double>("tauPtThreshold");
648  leadPionThreshold_ = p.getParameter<double>("leadPionThreshold");
649  stripPtThreshold_ = p.getParameter<double>("stripPtThreshold");
650  chargeIsolationCone_ = p.getParameter<double>("chargeHadrIsolationConeSize");
651  gammaIsolationCone_ = p.getParameter<double>("gammaIsolationConeSize");
652  neutrHadrIsolationCone_ = p.getParameter<double>("neutrHadrIsolationConeSize");
653  useIsolationAnnulus_ = p.getParameter<bool>("useIsolationAnnulus");
654  oneProngStripMassWindow_ = p.getParameter<std::vector<double> >("oneProngStripMassWindow");
655  oneProngTwoStripsMassWindow_ = p.getParameter<std::vector<double> >("oneProngTwoStripsMassWindow");
656  oneProngTwoStripsPi0MassWindow_= p.getParameter<std::vector<double> >("oneProngTwoStripsPi0MassWindow");
657  threeProngMassWindow_ = p.getParameter<std::vector<double> >("threeProngMassWindow");
658  matchingCone_ = p.getParameter<double>("matchingCone");
659  coneMetric_ = p.getParameter<std::string>("coneMetric");
660  coneSizeFormula_ = p.getParameter<std::string>("coneSizeFormula");
661  minSignalCone_ = p.getParameter<double>("minimumSignalCone");
662  maxSignalCone_ = p.getParameter<double>("maximumSignalCone");
663 
664 
665 
666  //Initialize The Merging Algorithm!
667  if(emMerger_ =="StripBased")
669  //Add the Pi0 Merger from Evan here
670 
671 
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;
680 
681  coneSizeFormula = TauTagTools::computeConeSizeTFormula(coneSizeFormula_,"Signal cone size Formula");
682 
683 
684 }
T getParameter(std::string const &) const
std::vector< double > threeProngMassWindow_
TFormula computeConeSizeTFormula(const std::string &ConeSizeFormula, const char *errorMessage)
std::vector< double > oneProngTwoStripsMassWindow_
std::vector< double > oneProngStripMassWindow_
std::vector< double > oneProngTwoStripsPi0MassWindow_
PFCandidateMergerBase * candidateMerger_
math::XYZTLorentzVector HPSPFRecoTauAlgorithm::createMergedLorentzVector ( const std::vector< reco::CandidatePtr > &  cands)
private

Definition at line 689 of file HPSPFRecoTauAlgorithm.cc.

References mps_fire::i.

Referenced by buildOneProngStrip(), and buildOneProngTwoStrips().

690 {
692  for(unsigned int i=0;i<cands.size();++i) {
693  sum+=cands[i]->p4();
694  }
695  return sum;
696 }
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
reco::PFTau HPSPFRecoTauAlgorithm::getBestTauCandidate ( reco::PFTauCollection taus)
private

Definition at line 766 of file HPSPFRecoTauAlgorithm.cc.

References overlapCriterion_, and MCScenario_CRAFT1_22X::sorter().

Referenced by buildOneProng(), buildOneProngStrip(), buildOneProngTwoStrips(), buildPFTau(), and buildThreeProngs().

767 {
768  reco::PFTauCollection::iterator it;
769  if(overlapCriterion_ =="Isolation"){
770  HPSTauIsolationSorter sorter;
771  it = std::min_element(taus.begin(),taus.end(),sorter);
772 
773  }
774  else if(overlapCriterion_ =="Pt"){
775  HPSTauPtSorter sorter;
776  it = std::min_element(taus.begin(),taus.end(),sorter);
777  }
778 
779  return *it;
780 }
bool HPSPFRecoTauAlgorithm::isNarrowTau ( const reco::PFTau tau,
double  cone 
)
private

Definition at line 440 of file HPSPFRecoTauAlgorithm.cc.

References coneSizeFormula, reco::LeafCandidate::energy(), reco::LeafCandidate::et(), maxSignalCone_, and minSignalCone_.

Referenced by buildOneProngStrip(), buildOneProngTwoStrips(), and buildThreeProngs().

441 {
442  double allowedConeSize=coneSizeFormula.Eval(tau.energy(),tau.et());
443  if (allowedConeSize<minSignalCone_) allowedConeSize=minSignalCone_;
444  if (allowedConeSize>maxSignalCone_) allowedConeSize=maxSignalCone_;
445 
446  if(cone<allowedConeSize)
447  return true;
448  else
449  return false;
450 }
double et() const final
transverse energy
double energy() const final
energy
bool HPSPFRecoTauAlgorithm::refitThreeProng ( reco::PFTau tau)
private

Definition at line 720 of file HPSPFRecoTauAlgorithm.cc.

References TransientTrackBuilder::build(), TransientVertex::hasRefittedTracks(), TransientVertex::isValid(), reco::TrackBase::momentum(), p1, p2, p3, TransientVertex::position(), reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), TransientVertex::refittedTracks(), reco::LeafCandidate::setP4(), reco::LeafCandidate::setVertex(), reco::PFTau::signalPFChargedHadrCands(), mathSSE::sqrt(), reco::PFCandidate::trackRef(), PFRecoTauAlgorithmBase::TransientTrackBuilder_, KalmanVertexFitter::vertex(), badGlobalMuonTaggersAOD_cff::vtx, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by buildThreeProngs().

721 {
722  bool response=false;
723  //Get Hadrons
724  std::vector<reco::PFCandidatePtr> hadrons = tau.signalPFChargedHadrCands();
725  PFCandidatePtr h1 = hadrons[0];
726  PFCandidatePtr h2 = hadrons[1];
727  PFCandidatePtr h3 = hadrons[2];
728 
729  //Make transient tracks
730  std::vector<TransientTrack> transientTracks;
731  transientTracks.push_back(TransientTrackBuilder_->build(h1->trackRef()));
732  transientTracks.push_back(TransientTrackBuilder_->build(h2->trackRef()));
733  transientTracks.push_back(TransientTrackBuilder_->build(h3->trackRef()));
734 
735  //Apply the Vertex Fit
736  KalmanVertexFitter fitter(true);
737  TransientVertex myVertex = fitter.vertex(transientTracks);
738 
739  //Just require a valid vertex+ 3 refitted tracks
740  if(myVertex.isValid()&&
741  myVertex.hasRefittedTracks()&&
742  myVertex.refittedTracks().size()==3) {
743 
744  response=true;
745  math::XYZPoint vtx(myVertex.position().x(),myVertex.position().y(),myVertex.position().z());
746 
747  //Create a LV for each refitted track
748  const std::vector<reco::TransientTrack>& refittedTracks = myVertex.refittedTracks();
749  const reco::Track& track1 = refittedTracks.at(0).track();
750  math::XYZTLorentzVector p1(track1.px(), track1.py(), track1.pz(), sqrt(track1.momentum().mag2() + 0.139*0.139));
751  const reco::Track& track2 = refittedTracks.at(1).track();
752  math::XYZTLorentzVector p2(track2.px(), track2.py(), track2.pz(), sqrt(track2.momentum().mag2() + 0.139*0.139));
753  const reco::Track& track3 = refittedTracks.at(2).track();
754  math::XYZTLorentzVector p3(track3.px(), track3.py(), track3.pz(), sqrt(track3.momentum().mag2() + 0.139*0.139));
755 
756  //Update the tau p4
757  tau.setP4(p1+p2+p3);
758  //Update the vertex
759  tau.setVertex(vtx);
760  }
761  return response;
762 
763 }
const TransientTrackBuilder * TransientTrackBuilder_
reco::TransientTrack build(const reco::Track *p) const
T y() const
Definition: PV3DBase.h:63
bool hasRefittedTracks() const
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:660
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:708
void setVertex(const Point &vertex) override
set vertex
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:442
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T sqrt(T t)
Definition: SSEVec.h:18
GlobalPoint position() const
T z() const
Definition: PV3DBase.h:64
double p2[4]
Definition: TauolaWrapper.h:90
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:672
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Definition: PFTau.cc:179
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double p1[4]
Definition: TauolaWrapper.h:89
std::vector< reco::TransientTrack > const & refittedTracks() const
T x() const
Definition: PV3DBase.h:62
bool isValid() const
void setP4(const LorentzVector &p4) final
set 4-momentum
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:666
double p3[4]
Definition: TauolaWrapper.h:91
void HPSPFRecoTauAlgorithm::removeCandidateFromRefVector ( const reco::CandidatePtr cand,
std::vector< reco::CandidatePtr > &  vec 
)
private

Definition at line 699 of file HPSPFRecoTauAlgorithm.cc.

References spr::find().

Referenced by associateIsolationCandidates(), buildOneProngStrip(), and buildOneProngTwoStrips().

700 {
701  std::vector<CandidatePtr> newVec;
702 
703  std::vector<CandidatePtr>::iterator it;
704  it = std::find(vec.begin(),vec.end(),cand);
705  if(it!=vec.end())
706  vec.erase(it);
707 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20

Member Data Documentation

PFCandidateMergerBase* HPSPFRecoTauAlgorithm::candidateMerger_
private

Definition at line 39 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildPFTau(), configure(), and ~HPSPFRecoTauAlgorithm().

double HPSPFRecoTauAlgorithm::chargeIsolationCone_
private

Definition at line 98 of file HPSPFRecoTauAlgorithm.h.

Referenced by associateIsolationCandidates(), and configure().

std::string HPSPFRecoTauAlgorithm::coneMetric_
private
TFormula HPSPFRecoTauAlgorithm::coneSizeFormula
private

Definition at line 123 of file HPSPFRecoTauAlgorithm.h.

Referenced by configure(), and isNarrowTau().

std::string HPSPFRecoTauAlgorithm::coneSizeFormula_
private

Definition at line 117 of file HPSPFRecoTauAlgorithm.h.

Referenced by configure().

bool HPSPFRecoTauAlgorithm::doOneProngs_
private

Definition at line 84 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildPFTau(), and configure().

bool HPSPFRecoTauAlgorithm::doOneProngStrips_
private

Definition at line 85 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildPFTau(), and configure().

bool HPSPFRecoTauAlgorithm::doOneProngTwoStrips_
private

Definition at line 86 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildPFTau(), and configure().

bool HPSPFRecoTauAlgorithm::doThreeProngs_
private

Definition at line 87 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildPFTau(), and configure().

std::string HPSPFRecoTauAlgorithm::emMerger_
private

Definition at line 78 of file HPSPFRecoTauAlgorithm.h.

Referenced by configure().

double HPSPFRecoTauAlgorithm::gammaIsolationCone_
private

Definition at line 99 of file HPSPFRecoTauAlgorithm.h.

Referenced by associateIsolationCandidates(), and configure().

double HPSPFRecoTauAlgorithm::leadPionThreshold_
private

Definition at line 93 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildOneProng(), buildThreeProngs(), and configure().

double HPSPFRecoTauAlgorithm::matchingCone_
private
double HPSPFRecoTauAlgorithm::maxSignalCone_
private

Definition at line 120 of file HPSPFRecoTauAlgorithm.h.

Referenced by configure(), and isNarrowTau().

double HPSPFRecoTauAlgorithm::minSignalCone_
private

Definition at line 119 of file HPSPFRecoTauAlgorithm.h.

Referenced by configure(), and isNarrowTau().

double HPSPFRecoTauAlgorithm::neutrHadrIsolationCone_
private

Definition at line 100 of file HPSPFRecoTauAlgorithm.h.

Referenced by associateIsolationCandidates(), and configure().

std::vector<double> HPSPFRecoTauAlgorithm::oneProngStripMassWindow_
private

Definition at line 106 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildOneProngStrip(), and configure().

std::vector<double> HPSPFRecoTauAlgorithm::oneProngTwoStripsMassWindow_
private

Definition at line 107 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildOneProngTwoStrips(), and configure().

std::vector<double> HPSPFRecoTauAlgorithm::oneProngTwoStripsPi0MassWindow_
private

Definition at line 108 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildOneProngTwoStrips(), and configure().

std::string HPSPFRecoTauAlgorithm::overlapCriterion_
private

Definition at line 81 of file HPSPFRecoTauAlgorithm.h.

Referenced by configure(), and getBestTauCandidate().

reco::PFTauCollection HPSPFRecoTauAlgorithm::pfTaus_
private
double HPSPFRecoTauAlgorithm::stripPtThreshold_
private

Definition at line 96 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildOneProngStrip(), buildOneProngTwoStrips(), and configure().

double HPSPFRecoTauAlgorithm::tauThreshold_
private
std::vector<double> HPSPFRecoTauAlgorithm::threeProngMassWindow_
private

Definition at line 109 of file HPSPFRecoTauAlgorithm.h.

Referenced by buildThreeProngs(), and configure().

bool HPSPFRecoTauAlgorithm::useIsolationAnnulus_
private

Definition at line 103 of file HPSPFRecoTauAlgorithm.h.

Referenced by associateIsolationCandidates(), and configure().