60 using TrackIndxMap = std::unordered_map<reco::TrackRef::key_type, size_t>;
94 std::vector<int>& matchedEcalClusters,
95 std::vector<int>& matchedHcalClusters,
101 std::vector<int>& matchedClusters,
108 std::vector<int>& matchedEcalClusters,
109 std::vector<int>& matchedHcalClusters,
112 template <
typename CollType>
178 ebRecHits_{consumes(conf.getParameter<
edm::InputTag>(
"EBRecHits"))},
179 eeRecHits_{consumes(conf.getParameter<
edm::InputTag>(
"EERecHits"))},
181 beamSpot_(consumes(conf.getParameter<
edm::InputTag>(
"BeamSpot"))),
186 ecalClusterToolsESGetTokens_{consumesCollector()},
187 passThrough_(conf.getParameter<
bool>(
"PassThrough")),
188 usePfTracks_(conf.getParameter<
bool>(
"UsePfTracks")),
189 minPtThreshold_(conf.getParameter<
double>(
"MinPtThreshold")),
190 maxPtThreshold_(conf.getParameter<
double>(
"MaxPtThreshold")) {
192 pfTracks_ = consumes(conf.getParameter<
edm::InputTag>(
"pfTracks"));
193 hcalClusters_ = consumes(conf.getParameter<
edm::InputTag>(
"hcalClusters"));
195 kfTracks_ = consumes(conf.getParameter<
edm::InputTag>(
"tracks"));
197 produces<reco::ElectronSeedCollection>();
198 produces<reco::PreIdCollection>();
199 produces<reco::PreIdCollection>(
"HCAL");
200 produces<edm::ValueMap<reco::PreIdRef> >();
208 auto seeds = std::make_unique<reco::ElectronSeedCollection>();
209 auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
210 auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
229 if (trk.trackRef().isNonnull()) {
230 if (trk.trackRef().id() != kfTracks.
id()) {
232 <<
"kfTracks is not the collection that pfTracks was built from, please fix this";
258 auto ecalPreIdsHandle =
event.put(
std::move(ecalPreIds));
259 event.put(
std::move(hcalPreIds),
"HCAL");
262 auto preIdVMOut = std::make_unique<edm::ValueMap<reco::PreIdRef> >();
283 template <
typename T>
293 auto const&
rho =
event.get(
rho_);
316 std::vector<int> matchedEcalClusters;
317 std::vector<int> matchedHcalClusters;
321 ecalPreIds.reserve(
handle->size());
322 hcalPreIds.reserve(
handle->size());
325 for (
unsigned int itrk = 0; itrk <
handle.product()->size(); itrk++) {
338 if (
seed.nHits() == 0) {
341 seed.setCtfTrack(trackRef);
344 unsigned int nModels = globalCache()->modelNames().size();
360 bool result =
decision(templatedRef, ecalPreId, hcalPreId,
rho, spot, ecalTools);
368 ecalPreIds.push_back(ecalPreId);
369 hcalPreIds.push_back(hcalPreId);
370 trksToPreIdIndx[trackRef.
index()] = ecalPreIds.size() - 1;
384 TrackIndxMap& trksToPreIdIndx,
395 TrackIndxMap& trksToPreIdIndx,
404 std::vector<int>& matchedEcalClusters,
405 std::vector<int>& matchedHcalClusters,
431 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
433 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
436 if (
point.isValid()) {
438 for (
unsigned int iclu = 0; iclu <
clusters.product()->size(); iclu++) {
445 if (dr2 <
info.dr2min) {
447 info.cluRef = cluRef;
448 info.deta = cluRef->positionREP().eta() -
point.positionREP().eta();
450 reco::deltaPhi(cluRef->positionREP().phi(),
point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
457 if (
info.dr2min < 1.e5) {
458 float ep =
info.cluRef->correctedEnergy() /
std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
466 pfTrackRef->trackRef()->normalizedChi2(),
479 std::vector<int>& matchedEcalClusters,
480 std::vector<int>& matchedHcalClusters,
495 kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(),
energy);
497 kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
501 if (particle.getSuccess() == 0) {
507 particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
510 bool below_ps =
pow(ecal_pos.z(), 2.) >
boundary_ * ecal_pos.perp2();
513 for (
unsigned int iclu = 0; iclu <
ecalClusters.product()->size(); iclu++) {
519 particle.particle().momentum().y(),
520 particle.particle().momentum().z())
528 if (dr2 <
info.dr2min) {
530 info.cluRef = cluRef;
531 info.deta =
std::abs(cluRef->positionREP().eta() - showerPos.eta());
533 info.showerPos = showerPos;
549 kfTrackRef->normalizedChi2(),
550 info.cluRef->correctedEnergy() /
std::sqrt(kfTrackRef->innerMomentum().mag2()));
559 for (
unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
560 hits.push_back(trackRef->recHit(ihit)->cloneSH());
563 GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
564 GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
572 if (!traj1.isValid()) {
581 float chi2Ratio = trackRef->chi2() > 0. ? traj2.
chiSquared() / trackRef->chi2() : -1.;
582 float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
585 float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
600 for (
auto&
name : globalCache()->modelNames()) {
601 result |= globalCache()->eval(
name, ecalPreId, hcalPreId,
rho, spot, ecalTools);
618 template <
typename CollType>
623 std::vector<reco::PreIdRef>
values;
625 unsigned ntracks = tracksHandle->size();
626 for (
unsigned itrack = 0; itrack <
ntracks; ++itrack) {
628 auto preIdRefIt = trksToPreIdIndx.find(trackRef.
index());
629 if (preIdRefIt == trksToPreIdIndx.end()) {
633 values.push_back(preIdRef);
654 desc.add<std::vector<std::string> >(
"ModelNames", {});
655 desc.add<std::vector<std::string> >(
"ModelWeights", {});
656 desc.add<std::vector<double> >(
"ModelThresholds", {});
657 desc.add<
bool>(
"PassThrough",
false);
658 desc.add<
bool>(
"UsePfTracks",
true);
659 desc.add<
double>(
"MinPtThreshold", 1.0);
660 desc.add<
double>(
"MaxPtThreshold", 15.);
661 descriptions.
add(
"lowPtGsfElectronSeeds",
desc);
constexpr double deltaPhi(double phi1, double phi2)
edm::ESHandle< MagneticField > field_
T getParameter(std::string const &) const
std::unique_ptr< TrajectorySmoother > smootherPtr_
LowPtGsfElectronSeedProducer(const edm::ParameterSet &, const lowptgsfeleseed::HeavyObjectCache *)
void setECALMatchingProperties(PFClusterRef clusterRef, const math::XYZPoint &ecalpos, const math::XYZPoint &meanShower, float deta, float dphi, float chieta, float chiphi, float chi2, float eop)
std::vector< reco::PreId > PreIdCollection
void propagateTrackToCalo(const reco::PFRecTrackRef &pfTrackRef, const edm::Handle< reco::PFClusterCollection > &ecalClusters, const edm::Handle< reco::PFClusterCollection > &hcalClusters, std::vector< int > &matchedEcalClusters, std::vector< int > &matchedHcalClusters, reco::PreId &ecalPreId, reco::PreId &hcalPreId)
bool decision(const reco::PFRecTrackRef &pfTrackRef, reco::PreId &ecal, reco::PreId &hcal, double rho, const reco::BeamSpot &spot, noZS::EcalClusterLazyTools &ecalTools)
bool lightGsfTracking(reco::PreId &, const reco::TrackRef &, const reco::ElectronSeed &)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
static void globalEndJob(lowptgsfeleseed::HeavyObjectCache const *)
edm::EDGetTokenT< reco::PFClusterCollection > hcalClusters_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magToken_
std::unordered_map< reco::TrackRef::key_type, size_t > TrackIndxMap
const edm::ESGetToken< TrajectorySmoother, TrajectoryFitter::Record > trajectorySmootherToken_
const edm::EDGetTokenT< reco::BeamSpot > beamSpot_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::Record > trajectoryFitterToken_
TrajectoryMeasurement const & lastMeasurement() const
const noZS::EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_
void loop(const edm::Handle< std::vector< T > > &handle, edm::Handle< reco::PFClusterCollection > &hcalClusters, reco::ElectronSeedCollection &seeds, reco::PreIdCollection &ecalPreIds, reco::PreIdCollection &hcalPreIds, TrackIndxMap &trksToPreIdIndx, edm::Event &, const edm::EventSetup &)
void setTrack(reco::TrackRef trackref)
void fillPreIdRefValueMap(edm::Handle< CollType > tracksHandle, const TrackIndxMap &trksToPreIdIndx, const edm::OrphanHandle< reco::PreIdCollection > &preIdHandle, edm::ValueMap< reco::PreIdRef >::Filler &filler)
const double minPtThreshold_
static constexpr double mass_
edm::EDGetTokenT< reco::TrackCollection > kfTracks_
edm::Ref< PFClusterCollection > PFClusterRef
persistent reference to PFCluster objects
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
Abs< T >::type abs(const T &t)
double z() const
z of vertex
edm::Ref< PFRecTrackCollection > PFRecTrackRef
persistent reference to PFRecTrack objects
#define DEFINE_FWK_MODULE(type)
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
const edm::EDGetTokenT< double > rho_
edm::EDGetTokenT< reco::PFRecTrackCollection > pfTracks_
Basic3DVector unit() const
bool propagateToEcalEntrance(bool first=true)
static void fillDescriptions(edm::ConfigurationDescriptions &)
void produce(edm::Event &, const edm::EventSetup &) override
static double getDepthCorrection(double energy, bool isBelowPS=false, bool isHadron=false)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static TrackQuality qualityByName(const std::string &name)
static constexpr double boundary_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
void add(std::string const &label, ParameterSetDescription const &psetDescription)
GlobalVector globalMomentum() const
TrajectoryStateOnSurface const & updatedState() const
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
static std::unique_ptr< lowptgsfeleseed::HeavyObjectCache > initializeGlobalCache(const edm::ParameterSet &conf)
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
TrajectoryMeasurement const & firstMeasurement() const
const double maxPtThreshold_
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > builderToken_
reco::TrackRef getBaseRef(edm::Handle< std::vector< reco::Track > > handle, int idx) const
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
Power< A, B >::type pow(const A &a, const B &b)
std::unique_ptr< TrajectoryFitter > fitterPtr_
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Global3DVector GlobalVector
math::XYZTLorentzVector XYZTLorentzVector