diff --git a/RecoTauTag/RecoTau/BuildFile.xml b/RecoTauTag/RecoTau/BuildFile.xml
index ee15b23a648ed..19e5503d0ab85 100644
--- a/RecoTauTag/RecoTau/BuildFile.xml
+++ b/RecoTauTag/RecoTau/BuildFile.xml
@@ -1,6 +1,7 @@
+
@@ -22,6 +23,8 @@
+
+
diff --git a/RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h b/RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h
index 0b167c2568549..fcd10a3fb9d88 100644
--- a/RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h
+++ b/RecoTauTag/RecoTau/interface/PositionAtECalEntranceComputer.h
@@ -15,6 +15,9 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "DataFormats/Candidate/interface/Candidate.h"
+#include "RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h"
+
+class MagneticField;
class PositionAtECalEntranceComputer {
public:
@@ -24,10 +27,14 @@ class PositionAtECalEntranceComputer {
void beginEvent(const edm::EventSetup&);
//To do: it seems to more practical to put this to the ES
- reco::Candidate::Point operator()(const reco::Candidate* particle, bool& success) const;
+ reco::Candidate::Point operator()(const reco::Candidate* particle, bool& success, bool isPhase2 = false) const;
private:
double bField_z_;
+ MagneticField const* bField_;
+ hgcal::RecHitTools recHitTools_;
+ float hgcalFace_z_;
+ static constexpr float ecalBarrelEndcapEtaBorder_ = 1.479;
};
#endif // RecoTauTag_RecoTau_PositionAtECalEntranceComputer_h
diff --git a/RecoTauTag/RecoTau/src/PositionAtECalEntranceComputer.cc b/RecoTauTag/RecoTau/src/PositionAtECalEntranceComputer.cc
index 391ac598bb414..587736e7a30df 100644
--- a/RecoTauTag/RecoTau/src/PositionAtECalEntranceComputer.cc
+++ b/RecoTauTag/RecoTau/src/PositionAtECalEntranceComputer.cc
@@ -2,37 +2,130 @@
#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
+#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
+#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "CommonTools/BaseParticlePropagator/interface/BaseParticlePropagator.h"
+#include "DataFormats/GeometrySurface/interface/Plane.h"
+#include "TrackPropagation/RungeKutta/interface/defaultRKPropagator.h"
#include
+//HGCal helper classes
+//MB: looks be copy of HGCal utils: L1Trigger/L1THGCalUtilities/plugins/ntuples/HGCalTriggerNtupleGen.cc
+namespace HGCal_helpers {
+ class SimpleTrackPropagator {
+ public:
+ SimpleTrackPropagator(MagneticField const* f) : field_(f), prod_(field_, alongMomentum, 5.e-5), absz_target_(0) {
+ ROOT::Math::SMatrixIdentity id;
+ AlgebraicSymMatrix55 C(id);
+ C *= 0.001;
+ err_ = CurvilinearTrajectoryError(C);
+ }
+ void setPropagationTargetZ(const float& z);
+
+ bool propagate(const double& px,
+ const double& py,
+ const double& pz,
+ const double& x,
+ const double& y,
+ const double& z,
+ const float& charge,
+ reco::Candidate::Point& output) const;
+
+ private:
+ SimpleTrackPropagator() : field_(nullptr), prod_(field_, alongMomentum, 5e-5), absz_target_(0) {}
+ const RKPropagatorInS& RKProp() const { return prod_.propagator; }
+ Plane::PlanePointer targetPlaneForward_, targetPlaneBackward_;
+ MagneticField const* field_;
+ CurvilinearTrajectoryError err_;
+ defaultRKPropagator::Product prod_;
+ float absz_target_;
+ };
+ void SimpleTrackPropagator::setPropagationTargetZ(const float& z) {
+ targetPlaneForward_ = Plane::build(Plane::PositionType(0, 0, std::abs(z)), Plane::RotationType());
+ targetPlaneBackward_ = Plane::build(Plane::PositionType(0, 0, -std::abs(z)), Plane::RotationType());
+ absz_target_ = std::abs(z);
+ }
+ bool SimpleTrackPropagator::propagate(const double& px,
+ const double& py,
+ const double& pz,
+ const double& x,
+ const double& y,
+ const double& z,
+ const float& charge,
+ reco::Candidate::Point& output) const {
+ typedef TrajectoryStateOnSurface TSOS;
+ GlobalPoint startingPosition(x, y, z);
+ GlobalVector startingMomentum(px, py, pz);
+ Plane::PlanePointer startingPlane = Plane::build(Plane::PositionType(x, y, z), Plane::RotationType());
+ TSOS startingStateP(
+ GlobalTrajectoryParameters(startingPosition, startingMomentum, charge, field_), err_, *startingPlane);
+ TSOS trackStateP;
+ if (pz > 0) {
+ trackStateP = RKProp().propagate(startingStateP, *targetPlaneForward_);
+ } else {
+ trackStateP = RKProp().propagate(startingStateP, *targetPlaneBackward_);
+ }
+ if (trackStateP.isValid()) {
+ output.SetXYZ(
+ trackStateP.globalPosition().x(), trackStateP.globalPosition().y(), trackStateP.globalPosition().z());
+ return true;
+ }
+ output.SetXYZ(0, 0, 0);
+ return false;
+ }
+} // namespace HGCal_helpers
+
PositionAtECalEntranceComputer::PositionAtECalEntranceComputer() : bField_z_(-1.) {}
PositionAtECalEntranceComputer::~PositionAtECalEntranceComputer() {}
void PositionAtECalEntranceComputer::beginEvent(const edm::EventSetup& es) {
- edm::ESHandle bField;
- es.get().get(bField);
- bField_z_ = bField->inTesla(GlobalPoint(0., 0., 0.)).z();
+ edm::ESHandle bFieldH;
+ es.get().get(bFieldH);
+ bField_z_ = bFieldH->inTesla(GlobalPoint(0., 0., 0.)).z();
+ bField_ = &(*bFieldH);
+ edm::ESHandle caloGeoH;
+ es.get().get(caloGeoH);
+ recHitTools_.setGeometry(*caloGeoH);
+ hgcalFace_z_ = recHitTools_.getPositionLayer(1).z(); // HGCal 1st layer
}
reco::Candidate::Point PositionAtECalEntranceComputer::operator()(const reco::Candidate* particle,
- bool& success) const {
+ bool& success,
+ bool isPhase2) const {
assert(bField_z_ != -1.);
- BaseParticlePropagator propagator = BaseParticlePropagator(
- RawParticle(particle->p4(),
- math::XYZTLorentzVector(particle->vertex().x(), particle->vertex().y(), particle->vertex().z(), 0.),
- particle->charge()),
- 0.,
- 0.,
- bField_z_);
- propagator.propagateToEcalEntrance(false);
reco::Candidate::Point position;
- if (propagator.getSuccess() != 0) {
- position = propagator.particle().vertex().Vect();
- success = true;
- } else {
+ if (!isPhase2 || std::abs(particle->eta()) < ecalBarrelEndcapEtaBorder_) { // ECal
+ BaseParticlePropagator propagator = BaseParticlePropagator(
+ RawParticle(particle->p4(),
+ math::XYZTLorentzVector(particle->vertex().x(), particle->vertex().y(), particle->vertex().z(), 0.),
+ particle->charge()),
+ 0.,
+ 0.,
+ bField_z_);
+ propagator.propagateToEcalEntrance(false);
+ if (propagator.getSuccess() != 0) {
+ position = propagator.particle().vertex().Vect();
+ success = true;
+ } else {
+ success = false;
+ }
+ } else { // HGCal
success = false;
+ if (std::abs(particle->vertex().z()) >= hgcalFace_z_)
+ return position;
+
+ HGCal_helpers::SimpleTrackPropagator propagator(bField_);
+ propagator.setPropagationTargetZ(hgcalFace_z_);
+ success = propagator.propagate(particle->px(),
+ particle->py(),
+ particle->pz(),
+ particle->vertex().x(),
+ particle->vertex().y(),
+ particle->vertex().z(),
+ particle->charge(),
+ position);
}
return position;
}