55 class TauLeadTrackExtractor {
58 double getTrackPtSum(
const T&
tau)
const {
59 double trackPtSum = 0.;
61 signalTrack !=
tau.signalTracks().end();
63 trackPtSum += (*signalTrack)->pt();
71 class TauLeadTrackExtractor<
reco::
PFTau> {
75 double trackPtSum = 0.;
76 for (std::vector<CandidatePtr>::const_iterator signalTrack =
tau.signalChargedHadrCands().begin();
77 signalTrack !=
tau.signalChargedHadrCands().end();
79 trackPtSum += (*signalTrack)->pt();
85 template <
class TauType,
class TauDiscriminator>
93 ~TauDiscriminationAgainstCaloMuon()
override {}
98 double discriminate(
const TauRef&)
const override;
118 TauLeadTrackExtractor<TauType> leadTrackExtractor_;
120 double minLeadTrackPt_;
121 double minLeadTrackPtFraction_;
129 double maxEnToTrackRatio_;
132 template <
class TauType,
class TauDiscriminator>
133 TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::TauDiscriminationAgainstCaloMuon(
138 srcEcalRecHitsBarrel_ =
cfg.getParameter<
edm::InputTag>(
"srcEcalRecHitsBarrel");
139 srcEcalRecHitsEndcap_ =
cfg.getParameter<
edm::InputTag>(
"srcEcalRecHitsEndcap");
144 minLeadTrackPt_ =
cfg.getParameter<
double>(
"minLeadTrackPt");
145 minLeadTrackPtFraction_ =
cfg.getParameter<
double>(
"minLeadTrackPtFraction");
147 drEcal_ =
cfg.getParameter<
double>(
"dRecal");
148 drHcal_ =
cfg.getParameter<
double>(
"dRhcal");
150 maxEnEcal_ =
cfg.getParameter<
double>(
"maxEnEcal");
151 maxEnHcal_ =
cfg.getParameter<
double>(
"maxEnHcal");
153 maxEnToTrackRatio_ =
cfg.getParameter<
double>(
"maxEnToTrackRatio");
156 template <
class TauType,
class TauDiscriminator>
157 void TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::beginEvent(
const edm::Event& evt,
159 evt.
getByLabel(srcEcalRecHitsBarrel_, ebRecHits_);
160 evt.
getByLabel(srcEcalRecHitsEndcap_, eeRecHits_);
161 evt.
getByLabel(srcHcalRecHits_, hbheRecHits_);
163 trackBuilder_ = &evtSetup.
getData(trackBuilderToken_);
164 if (!trackBuilder_) {
165 edm::LogError(
"TauDiscriminationAgainstCaloMuon::discriminate") <<
" Failed to access TransientTrackBuilder !!";
168 caloGeometry_ = &evtSetup.
getData(caloGeometryToken_);
169 if (!caloGeometry_) {
170 edm::LogError(
"TauDiscriminationAgainstCaloMuon::discriminate") <<
" Failed to access CaloGeometry !!";
178 eventVertexPosition_ =
179 GlobalPoint(thePrimaryEventVertex.
x(), thePrimaryEventVertex.
y(), thePrimaryEventVertex.
z());
188 double ecalEnergySum = 0.;
195 <<
" Failed to access ECAL geometry for detId = " <<
ecalRecHit->detid().rawId() <<
" --> skipping !!";
199 const GlobalPoint& cellPosition = cellGeometry->getPosition();
205 cellPositionRelVertex.
phi(),
207 transientTrack.
track().
phi()) > 0.5)
214 TVector3 d3(
d.x(),
d.y(),
d.z());
217 double dPerp = d3.Cross(
dir.Unit()).Mag();
218 double dParl = TVector3(cellPosition.
x(), cellPosition.
y(), cellPosition.
z()).Dot(
dir.Unit());
220 if (dPerp < dR && dParl > 100.) {
225 return ecalEnergySum;
233 double hcalEnergySum = 0.;
242 cellPositionRelVertex.
phi(),
244 transientTrack.
track().
phi()) > 0.5)
251 TVector3 d3(
d.x(),
d.y(),
d.z());
254 double dPerp = d3.Cross(
dir.Unit()).Mag();
255 double dParl = TVector3(cellPosition.
x(), cellPosition.
y(), cellPosition.
z()).Dot(
dir.Unit());
257 if (dPerp < dR && dParl > 100.) {
262 return hcalEnergySum;
265 template <
class TauType,
class TauDiscriminator>
266 double TauDiscriminationAgainstCaloMuon<TauType, TauDiscriminator>::discriminate(
const TauRef&
tau)
const {
267 if (!(trackBuilder_ && caloGeometry_))
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 =
291 compHcalEnergySum(*hbheRecHits_, hcGeometry, transientTrack, drHcal_, eventVertexPosition_);
293 double caloEnergySum = ecalEnergySum + hbheEnergySum;
295 if (ecalEnergySum < maxEnEcal_ && hbheEnergySum < maxEnHcal_ &&
296 caloEnergySum < (maxEnToTrackRatio_ *
leadTrackPt))
317 desc.add<
double>(
"minLeadTrackPt", 15.0);
318 desc.add<
double>(
"maxEnToTrackRatio", 0.25);
322 desc.add<
double>(
"dRhcal", 25.0);
328 psd1.
add<
double>(
"cut");
334 desc.add<
double>(
"maxEnHcal", 8.0);
335 desc.add<
double>(
"dRecal", 15.0);
337 desc.add<
double>(
"minLeadTrackPtFraction", 0.8);
338 desc.add<
double>(
"maxEnEcal", 3.0);
339 descriptions.
add(
"pfRecoTauDiscriminationAgainstCaloMuon",
desc);
const Track & track() const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
double z() const
z coordinate
#define DEFINE_FWK_MODULE(type)
double px() const
x coordinate of momentum vector
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
std::vector< EcalRecHit >::const_iterator const_iterator
double py() const
y coordinate of momentum vector
bool isNonnull() const
Checks for non-null.
std::vector< Tau > TauCollection
Log< level::Error, false > LogError
bool isTransient() const
Checks if this ref is transient (i.e. not persistable).
TrajectoryStateClosestToPoint trajectoryStateClosestToPoint(const GlobalPoint &point) const
TauDiscriminationAgainstCaloMuon< PFTau, PFTauDiscriminator > PFRecoTauDiscriminationAgainstCaloMuon
GlobalPoint position() const
edm::Ref< TauBxCollection > TauRef
double phi() const
azimuthal angle of momentum vector
bool getData(T &iHolder) const
const_iterator begin() const
double x() const
x coordinate
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double y() const
y coordinate
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.
const_iterator end() const
double eta() const
pseudorapidity of momentum vector
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double pz() const
z coordinate of momentum vector
void add(std::string const &label, ParameterSetDescription const &psetDescription)
GlobalPoint getPosition(const DetId &id) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const