52 class TauLeadTrackExtractor
57 return tau.leadTrack();
59 double getTrackPtSum(
const T& tau)
const 61 double trackPtSum = 0.;
63 signalTrack != tau.signalTracks().end(); ++signalTrack ) {
64 trackPtSum += (*signalTrack)->pt();
81 double trackPtSum = 0.;
84 trackPtSum += (*signalTrack)->pt();
90 template<
class TauType,
class TauDiscriminator>
99 ~TauDiscriminationAgainstCaloMuon()
override {}
104 double discriminate(
const TauRef&)
const override;
120 TauLeadTrackExtractor<TauType> leadTrackExtractor_;
122 double minLeadTrackPt_;
123 double minLeadTrackPtFraction_;
131 double maxEnToTrackRatio_;
134 template<
class TauType,
class TauDiscriminator>
135 TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::TauDiscriminationAgainstCaloMuon(
const edm::ParameterSet&
cfg)
144 minLeadTrackPt_ = cfg.
getParameter<
double>(
"minLeadTrackPt");
145 minLeadTrackPtFraction_ = cfg.
getParameter<
double>(
"minLeadTrackPtFraction");
153 maxEnToTrackRatio_ = cfg.
getParameter<
double>(
"maxEnToTrackRatio");
156 template<
class TauType,
class TauDiscriminator>
159 evt.
getByLabel(srcEcalRecHitsBarrel_, ebRecHits_);
160 evt.
getByLabel(srcEcalRecHitsEndcap_, eeRecHits_);
161 evt.
getByLabel(srcHcalRecHits_, hbheRecHits_);
165 trackBuilder_ = trackBuilderHandle.
product();
166 if ( !trackBuilder_ ) {
167 edm::LogError (
"TauDiscriminationAgainstCaloMuon::discriminate")
168 <<
" Failed to access TransientTrackBuilder !!";
173 caloGeometry_ = caloGeometryHandle.
product();
174 if ( !caloGeometry_ ) {
175 edm::LogError (
"TauDiscriminationAgainstCaloMuon::discriminate")
176 <<
" Failed to access CaloGeometry !!";
182 if (!vertices->empty()) {
183 const reco::Vertex& thePrimaryEventVertex = (*vertices->begin());
184 eventVertexPosition_ =
GlobalPoint(thePrimaryEventVertex.
x(), thePrimaryEventVertex.
y(), thePrimaryEventVertex.
z());
193 double ecalEnergySum = 0.;
198 if ( !cellGeometry ) {
200 <<
" Failed to access ECAL geometry for detId = " <<
ecalRecHit->detid().rawId()
201 <<
" --> skipping !!";
205 const GlobalPoint& cellPosition = cellGeometry->getPosition();
210 if (
deltaR(cellPositionRelVertex.
eta(), cellPositionRelVertex.
phi(),
211 transientTrack.
track().
eta(), transientTrack.
track().
phi()) > 0.5 )
continue;
217 TVector3 d3(d.
x(), d.
y(), d.
z());
220 double dPerp = d3.Cross(
dir.Unit()).Mag();
221 double dParl = TVector3(cellPosition.
x(), cellPosition.
y(), cellPosition.
z()).Dot(
dir.Unit());
223 if ( dPerp < dR && dParl > 100. ) {
228 return ecalEnergySum;
236 double hcalEnergySum = 0.;
238 hcalRecHit != hcalRecHits.
end(); ++hcalRecHit ) {
245 if (
deltaR(cellPositionRelVertex.
eta(), cellPositionRelVertex.
phi(),
246 transientTrack.
track().
eta(), transientTrack.
track().
phi()) > 0.5 )
continue;
252 TVector3 d3(d.
x(), d.
y(), d.
z());
255 double dPerp = d3.Cross(
dir.Unit()).Mag();
256 double dParl = TVector3(cellPosition.
x(), cellPosition.
y(), cellPosition.
z()).Dot(
dir.Unit());
258 if ( dPerp < dR && dParl > 100. ) {
259 hcalEnergySum += hcalRecHit->energy();
263 return hcalEnergySum;
266 template<
class TauType,
class TauDiscriminator>
267 double TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::discriminate(
const TauRef& tau)
const 269 if ( !(trackBuilder_ && caloGeometry_) )
return 0.;
275 TrackRef leadTrackRef = leadTrackExtractor_.getLeadTrack(*tau);
279 double trackPtSum = leadTrackExtractor_.getTrackPtSum(*tau);
281 double leadTrackPtFraction = ( trackPtSum > 0. ) ? (leadTrackPt/trackPtSum) : -1.;
283 if ( leadTrackPt > minLeadTrackPt_ && leadTrackPtFraction > minLeadTrackPtFraction_ ) {
286 double ebEnergySum = compEcalEnergySum(*ebRecHits_, ebGeometry, transientTrack, drEcal_, eventVertexPosition_);
287 double eeEnergySum = compEcalEnergySum(*eeRecHits_, eeGeometry, transientTrack, drEcal_, eventVertexPosition_);
288 double ecalEnergySum = ebEnergySum + eeEnergySum;
290 double hbheEnergySum = compHcalEnergySum(*hbheRecHits_, hcGeometry, transientTrack, drHcal_, eventVertexPosition_);
292 double caloEnergySum = ecalEnergySum + hbheEnergySum;
294 if ( ecalEnergySum < maxEnEcal_ &&
295 hbheEnergySum < maxEnHcal_ &&
296 caloEnergySum < (maxEnToTrackRatio_*leadTrackPt) )
return 0.;
T getParameter(std::string const &) const
GlobalPoint position() const
bool isNonnull() const
Checks for non-null.
edm::Ref< TauBxCollection > TauRef
const PFCandidatePtr & leadPFChargedHadrCand() const
#define DEFINE_FWK_MODULE(type)
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
double eta() const
pseudorapidity of momentum vector
double z() const
z coordinate
const edm::EventSetup * evtSetup() const
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
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
T const * product() const
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Charged hadrons in signal region.
const_iterator begin() const
double py() const
y coordinate of momentum vector