51 class TauLeadTrackExtractor
56 return tau.leadTrack();
58 double getTrackPtSum(
const T& tau)
const
60 double trackPtSum = 0.;
62 signalTrack != tau.signalTracks().end(); ++signalTrack ) {
63 trackPtSum += (*signalTrack)->pt();
80 double trackPtSum = 0.;
83 trackPtSum += (*signalTrack)->pt();
89 template<
class TauType,
class TauDiscriminator>
98 ~TauDiscriminationAgainstCaloMuon() {}
103 double discriminate(
const TauRef&)
const override;
119 TauLeadTrackExtractor<TauType> leadTrackExtractor_;
121 double minLeadTrackPt_;
122 double minLeadTrackPtFraction_;
130 double maxEnToTrackRatio_;
133 template<
class TauType,
class TauDiscriminator>
134 TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::TauDiscriminationAgainstCaloMuon(
const edm::ParameterSet&
cfg)
143 minLeadTrackPt_ = cfg.
getParameter<
double>(
"minLeadTrackPt");
144 minLeadTrackPtFraction_ = cfg.
getParameter<
double>(
"minLeadTrackPtFraction");
152 maxEnToTrackRatio_ = cfg.
getParameter<
double>(
"maxEnToTrackRatio");
155 template<
class TauType,
class TauDiscriminator>
156 void TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::beginEvent(
const edm::Event& evt,
const edm::EventSetup& evtSetup)
158 evt.
getByLabel(srcEcalRecHitsBarrel_, ebRecHits_);
159 evt.
getByLabel(srcEcalRecHitsEndcap_, eeRecHits_);
160 evt.
getByLabel(srcHcalRecHits_, hbheRecHits_);
164 trackBuilder_ = trackBuilderHandle.
product();
165 if ( !trackBuilder_ ) {
166 edm::LogError (
"TauDiscriminationAgainstCaloMuon::discriminate")
167 <<
" Failed to access TransientTrackBuilder !!";
172 caloGeometry_ = caloGeometryHandle.
product();
173 if ( !caloGeometry_ ) {
174 edm::LogError (
"TauDiscriminationAgainstCaloMuon::discriminate")
175 <<
" Failed to access CaloGeometry !!";
181 if ( vertices->size() >= 1 ) {
182 const reco::Vertex& thePrimaryEventVertex = (*vertices->begin());
183 eventVertexPosition_ =
GlobalPoint(thePrimaryEventVertex.
x(), thePrimaryEventVertex.
y(), thePrimaryEventVertex.
z());
192 double ecalEnergySum = 0.;
197 if ( !cellGeometry ) {
199 <<
" Failed to access ECAL geometry for detId = " <<
ecalRecHit->detid().rawId()
200 <<
" --> skipping !!";
209 if (
deltaR(cellPositionRelVertex.
eta(), cellPositionRelVertex.
phi(),
210 transientTrack.
track().
eta(), transientTrack.
track().
phi()) > 0.5 )
continue;
216 TVector3 d3(d.
x(), d.
y(), d.
z());
219 double dPerp = d3.Cross(
dir.Unit()).Mag();
220 double dParl = TVector3(cellPosition.
x(), cellPosition.
y(), cellPosition.
z()).Dot(
dir.Unit());
222 if ( dPerp < dR && dParl > 100. ) {
227 return ecalEnergySum;
235 double hcalEnergySum = 0.;
237 hcalRecHit != hcalRecHits.
end(); ++hcalRecHit ) {
242 if ( hbCellGeometry ) cellPosition = &(hbCellGeometry->
getPosition());
243 if ( heCellGeometry ) cellPosition = &(heCellGeometry->
getPosition());
245 if ( !cellPosition ) {
247 <<
" Failed to access HCAL geometry for detId = " << hcalRecHit->detid().rawId()
248 <<
" --> skipping !!";
255 if (
deltaR(cellPositionRelVertex.
eta(), cellPositionRelVertex.
phi(),
256 transientTrack.
track().
eta(), transientTrack.
track().
phi()) > 0.5 )
continue;
262 TVector3 d3(d.
x(), d.
y(), d.
z());
265 double dPerp = d3.Cross(
dir.Unit()).Mag();
266 double dParl = TVector3(cellPosition->
x(), cellPosition->
y(), cellPosition->
z()).Dot(
dir.Unit());
268 if ( dPerp < dR && dParl > 100. ) {
269 hcalEnergySum += hcalRecHit->energy();
273 return hcalEnergySum;
276 template<
class TauType,
class TauDiscriminator>
277 double TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::discriminate(
const TauRef& tau)
const
279 if ( !(trackBuilder_ && caloGeometry_) )
return 0.;
286 TrackRef leadTrackRef = leadTrackExtractor_.getLeadTrack(*tau);
289 double leadTrackPt = leadTrackRef->pt();
290 double trackPtSum = leadTrackExtractor_.getTrackPtSum(*tau);
292 double leadTrackPtFraction = ( trackPtSum > 0. ) ? (leadTrackPt/trackPtSum) : -1.;
294 if ( leadTrackPt > minLeadTrackPt_ && leadTrackPtFraction > minLeadTrackPtFraction_ ) {
297 double ebEnergySum = compEcalEnergySum(*ebRecHits_, ebGeometry, transientTrack, drEcal_, eventVertexPosition_);
298 double eeEnergySum = compEcalEnergySum(*eeRecHits_, eeGeometry, transientTrack, drEcal_, eventVertexPosition_);
299 double ecalEnergySum = ebEnergySum + eeEnergySum;
301 double hbheEnergySum = compHcalEnergySum(*hbheRecHits_, hbGeometry, heGeometry, transientTrack, drHcal_, eventVertexPosition_);
303 double caloEnergySum = ecalEnergySum + hbheEnergySum;
305 if ( ecalEnergySum < maxEnEcal_ &&
306 hbheEnergySum < maxEnHcal_ &&
307 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
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
TauDiscriminationAgainstCaloMuon< PFTau, PFTauDiscriminator > PFRecoTauDiscriminationAgainstCaloMuon
double eta() const
pseudorapidity of momentum vector
double z() const
y coordinate
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
TauDiscriminationAgainstCaloMuon< CaloTau, CaloTauDiscriminator > CaloRecoTauDiscriminationAgainstCaloMuon
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double pz() const
z coordinate of momentum vector
const_iterator end() const
double x() const
x coordinate
const Track & track() const
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
T const * product() const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
const std::vector< reco::PFCandidatePtr > & signalPFChargedHadrCands() const
Charged hadrons in signal region.
const_iterator begin() const
double py() const
y coordinate of momentum vector