1 #include <boost/foreach.hpp>
16 double factor =
sqrt(vec.energy()*vec.energy() - mass*mass)/vec.P();
46 typedef std::pair<unsigned int, unsigned int>
IntPair;
68 typedef std::vector<edm::ParameterSet> VPSet;
69 const VPSet& decayModes = pset.
getParameter<VPSet>(
"decayModes");
73 if ( decayMode.
exists(
"nTracksMin") ) {
78 if ( decayMode.
exists(
"nChargedPFCandsMin") ) {
85 if ( decayMode.
exists(
"minPi0Mass") ) {
92 if ( decayMode.
exists(
"assumeStripMass") ) {
117 delete it->second.maxMass_;
125 edm::LogPrint(
"PFTauByHPSSelect") <<
"<PFRecoTauDiscriminationByHPSSelection::discriminate>:" ;
126 edm::LogPrint(
"PFTauByHPSSelect") <<
" nCharged = " << tau->signalTauChargedHadronCandidates().size() ;
127 edm::LogPrint(
"PFTauByHPSSelect") <<
" nPiZeros = " << tau->signalPiZeroCandidates().size() ;
131 if ( tau->pt() <
minPt_ ) {
139 DecayModeCutMap::const_iterator massWindowIter =
140 decayModeCuts_.find(std::make_pair(tau->signalTauChargedHadronCandidates().size(),
141 tau->signalPiZeroCandidates().size()));
145 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails mass-window definition requirement." ;
152 unsigned int nTracks = 0;
153 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons = tau->signalTauChargedHadronCandidates();
154 for ( std::vector<reco::PFRecoTauChargedHadron>::const_iterator chargedHadron = chargedHadrons.begin();
155 chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
165 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails nTracks requirement for mass-window." ;
171 unsigned int nChargedPFCands = 0;
172 const std::vector<reco::PFRecoTauChargedHadron>& chargedHadrons = tau->signalTauChargedHadronCandidates();
173 for ( std::vector<reco::PFRecoTauChargedHadron>::const_iterator chargedHadron = chargedHadrons.begin();
174 chargedHadron != chargedHadrons.end(); ++chargedHadron ) {
184 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails nChargedPFCands requirement for mass-window." ;
192 edm::LogPrint(
"PFTauByHPSSelect") <<
"tau: Pt = " << tauP4.pt() <<
", eta = " << tauP4.eta() <<
", phi = " << tauP4.phi() <<
", mass = " << tauP4.mass() ;
197 tau->signalPiZeroCandidates()){
205 tau->signalPiZeroCandidates()){
211 stripsP4 += correction;
215 edm::LogPrint(
"PFTauByHPSSelect") <<
"strips: Pt = " << stripsP4.pt() <<
", eta = " << stripsP4.eta() <<
", phi = " << stripsP4.phi() <<
", mass = " << stripsP4.mass() ;
219 double maxMass_value = (*massWindow.
maxMass_)(*tau);
220 if ( !((tauP4.M() - tau->bendCorrMass()) < maxMass_value && (tauP4.M() + tau->bendCorrMass()) > massWindow.
minMass_) ) {
222 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails tau mass-window cut." ;
231 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails strip mass-window cut." ;
240 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails matching-cone cut." ;
246 double cone_size = tau->signalConeSize();
248 for (
auto const& cand : tau->signalTauChargedHadronCandidates()) {
252 if (
deltaR(cand.
p4(), tauP4) > cone_size ) {
254 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails signal-cone cut for charged hadron(s)." ;
260 for (
auto const& cand : tau->signalPiZeroCandidates()) {
263 double dR2 = dEta*dEta + dPhi*
dPhi;
265 edm::LogPrint(
"PFTauByHPSSelect") <<
"dR2(tau, signalPiZero) = " << dR2 ;
267 if ( dR2 > cone_size*cone_size ) {
269 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails signal-cone cut for strip(s)." ;
282 else algo_string =
"Undefined";
283 edm::LogPrint(
"PFTauByHPSSelect") <<
"algo(signalPFChargedHadr) = " << algo_string ;
287 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails cut on PFRecoTauChargedHadron algo." ;
295 int numPixelHits = 0;
296 const std::vector<reco::PFCandidatePtr>& chargedHadrCands = tau->signalPFChargedHadrCands();
297 for ( std::vector<reco::PFCandidatePtr>::const_iterator chargedHadrCand = chargedHadrCands.begin();
298 chargedHadrCand != chargedHadrCands.end(); ++chargedHadrCand ) {
300 if ( (*chargedHadrCand)->trackRef().isNonnull() ) track = (*chargedHadrCand)->trackRef().get();
301 else if ( (*chargedHadrCand)->gsfTrackRef().isNonnull() ) track = (*chargedHadrCand)->gsfTrackRef().get();
308 edm::LogPrint(
"PFTauByHPSSelect") <<
" fails cut on sum of pixel hits." ;
~PFRecoTauDiscriminationByHPSSelection()
T getParameter(std::string const &) const
std::map< IntPair, DecayModeCuts > DecayModeCutMap
PFRecoTauChargedHadronAlgorithm algo() const
Algorithm that built this charged hadron.
PFRecoTauDiscriminationByHPSSelection(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
virtual double eta() const
momentum pseudorapidity
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
double dPhi(double phi1, double phi2)
bool requireTauChargedHadronsToBeChargedPFCands_
unsigned nChargedPFCandsMin_
std::pair< unsigned int, unsigned int > IntPair
Abs< T >::type abs(const T &t)
double deltaR(double eta1, double eta2, double phi1, double phi2)
double deltaPhi(double phi1, double phi2)
float bendCorrEta() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
std::pair< double, double > DoublePair
StringObjectFunction< reco::PFTau > TauFunc
math::XYZTLorentzVector LorentzVector
Lorentz vector.
float bendCorrPhi() const
DecayModeCutMap decayModeCuts_
int numberOfValidPixelHits() const
double discriminate(const reco::PFTauRef &) const override
virtual double phi() const
momentum azimuthal angle
virtual const LorentzVector & p4() const
four-momentum Lorentz vector