55 class TauLeadTrackExtractor
60 return tau.leadTrack();
62 double getTrackPtSum(
const T& tau)
const 64 double trackPtSum = 0.;
66 signalTrack != tau.signalTracks().end(); ++signalTrack ) {
67 trackPtSum += (*signalTrack)->pt();
84 double trackPtSum = 0.;
87 trackPtSum += (*signalTrack)->pt();
93 template<
class TauType,
class TauDiscriminator>
102 ~TauDiscriminationAgainstCaloMuon()
override {}
107 double discriminate(
const TauRef&)
const override;
125 TauLeadTrackExtractor<TauType> leadTrackExtractor_;
127 double minLeadTrackPt_;
128 double minLeadTrackPtFraction_;
136 double maxEnToTrackRatio_;
139 template<
class TauType,
class TauDiscriminator>
140 TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::TauDiscriminationAgainstCaloMuon(
const edm::ParameterSet&
cfg)
149 minLeadTrackPt_ = cfg.
getParameter<
double>(
"minLeadTrackPt");
150 minLeadTrackPtFraction_ = cfg.
getParameter<
double>(
"minLeadTrackPtFraction");
158 maxEnToTrackRatio_ = cfg.
getParameter<
double>(
"maxEnToTrackRatio");
161 template<
class TauType,
class TauDiscriminator>
164 evt.
getByLabel(srcEcalRecHitsBarrel_, ebRecHits_);
165 evt.
getByLabel(srcEcalRecHitsEndcap_, eeRecHits_);
166 evt.
getByLabel(srcHcalRecHits_, hbheRecHits_);
170 trackBuilder_ = trackBuilderHandle.
product();
171 if ( !trackBuilder_ ) {
172 edm::LogError (
"TauDiscriminationAgainstCaloMuon::discriminate")
173 <<
" Failed to access TransientTrackBuilder !!";
178 caloGeometry_ = caloGeometryHandle.
product();
179 if ( !caloGeometry_ ) {
180 edm::LogError (
"TauDiscriminationAgainstCaloMuon::discriminate")
181 <<
" Failed to access CaloGeometry !!";
187 if (!vertices->empty()) {
188 const reco::Vertex& thePrimaryEventVertex = (*vertices->begin());
189 eventVertexPosition_ =
GlobalPoint(thePrimaryEventVertex.
x(), thePrimaryEventVertex.
y(), thePrimaryEventVertex.
z());
198 double ecalEnergySum = 0.;
203 if ( !cellGeometry ) {
205 <<
" Failed to access ECAL geometry for detId = " <<
ecalRecHit->detid().rawId()
206 <<
" --> skipping !!";
210 const GlobalPoint& cellPosition = cellGeometry->getPosition();
215 if (
deltaR(cellPositionRelVertex.
eta(), cellPositionRelVertex.
phi(),
216 transientTrack.
track().
eta(), transientTrack.
track().
phi()) > 0.5 )
continue;
222 TVector3 d3(d.
x(), d.
y(), d.
z());
225 double dPerp = d3.Cross(
dir.Unit()).Mag();
226 double dParl = TVector3(cellPosition.
x(), cellPosition.
y(), cellPosition.
z()).Dot(
dir.Unit());
228 if ( dPerp < dR && dParl > 100. ) {
233 return ecalEnergySum;
241 double hcalEnergySum = 0.;
243 hcalRecHit != hcalRecHits.
end(); ++hcalRecHit ) {
250 if (
deltaR(cellPositionRelVertex.
eta(), cellPositionRelVertex.
phi(),
251 transientTrack.
track().
eta(), transientTrack.
track().
phi()) > 0.5 )
continue;
257 TVector3 d3(d.
x(), d.
y(), d.
z());
260 double dPerp = d3.Cross(
dir.Unit()).Mag();
261 double dParl = TVector3(cellPosition.
x(), cellPosition.
y(), cellPosition.
z()).Dot(
dir.Unit());
263 if ( dPerp < dR && dParl > 100. ) {
264 hcalEnergySum += hcalRecHit->energy();
268 return hcalEnergySum;
271 template<
class TauType,
class TauDiscriminator>
272 double TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::discriminate(
const TauRef& tau)
const 274 if ( !(trackBuilder_ && caloGeometry_) )
return 0.;
280 TrackRef leadTrackRef = leadTrackExtractor_.getLeadTrack(*tau);
284 double trackPtSum = leadTrackExtractor_.getTrackPtSum(*tau);
286 double leadTrackPtFraction = ( trackPtSum > 0. ) ? (leadTrackPt/trackPtSum) : -1.;
288 if ( leadTrackPt > minLeadTrackPt_ && leadTrackPtFraction > minLeadTrackPtFraction_ ) {
291 double ebEnergySum = compEcalEnergySum(*ebRecHits_, ebGeometry, transientTrack, drEcal_, eventVertexPosition_);
292 double eeEnergySum = compEcalEnergySum(*eeRecHits_, eeGeometry, transientTrack, drEcal_, eventVertexPosition_);
293 double ecalEnergySum = ebEnergySum + eeEnergySum;
295 double hbheEnergySum = compHcalEnergySum(*hbheRecHits_, hcGeometry, transientTrack, drHcal_, eventVertexPosition_);
297 double caloEnergySum = ecalEnergySum + hbheEnergySum;
299 if ( ecalEnergySum < maxEnEcal_ &&
300 hbheEnergySum < maxEnHcal_ &&
301 caloEnergySum < (maxEnToTrackRatio_*leadTrackPt) )
return 0.;
322 desc.
add<
double>(
"minLeadTrackPt", 15.0);
323 desc.
add<
double>(
"maxEnToTrackRatio", 0.25);
327 desc.
add<
double>(
"dRhcal", 25.0);
333 psd1.
add<
double>(
"cut");
339 desc.
add<
double>(
"maxEnHcal", 8.0);
340 desc.
add<
double>(
"dRecal", 15.0);
342 desc.
add<
double>(
"minLeadTrackPtFraction", 0.8);
343 desc.
add<
double>(
"maxEnEcal", 3.0);
344 descriptions.
add(
"pfRecoTauDiscriminationAgainstCaloMuon", desc);
T getParameter(std::string const &) const
GlobalPoint position() const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
edm::Ref< TauBxCollection > TauRef
double y() const
y coordinate
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< Tau > TauCollection
double phi() const
azimuthal angle of momentum vector
double px() const
x coordinate of momentum vector
reco::TrackRef trackRef() const
TauDiscriminationAgainstCaloMuon< PFTau, PFTauDiscriminator > PFRecoTauDiscriminationAgainstCaloMuon
#define DEFINE_FWK_MODULE(type)
double eta() const
pseudorapidity of momentum vector
double z() const
z coordinate
const edm::EventSetup * evtSetup() const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
TauDiscriminationAgainstCaloMuon< CaloTau, CaloTauDiscriminator > CaloRecoTauDiscriminationAgainstCaloMuon
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
GlobalPoint getPosition(const DetId &id) const
double pz() const
z coordinate of momentum vector
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const_iterator end() const
double x() const
x coordinate
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const Track & track() const
const edm::Event * evt() const
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const std::vector< reco::CandidatePtr > & signalChargedHadrCands() const
Charged hadrons in signal region.
const PFCandidatePtr leadPFChargedHadrCand() const
Getters for different PFCandidates for PFTaus made from PFCandidates.
T const * product() const
const_iterator begin() const
double py() const
y coordinate of momentum vector