60 using TrackIndxMap = std::unordered_map<reco::TrackRef::key_type, size_t>;
96 std::vector<int>& matchedEcalClusters,
97 std::vector<int>& matchedHcalClusters,
103 std::vector<int>& matchedClusters,
110 std::vector<int>& matchedEcalClusters,
111 std::vector<int>& matchedHcalClusters,
114 template <
typename CollType>
163 static constexpr
double boundary_ = 2.50746495928 * 2.50746495928;
165 static constexpr
double mass_ = 0.000511 * 0.000511;
179 ebRecHits_{consumes(conf.getParameter<
edm::InputTag>(
"EBRecHits"))},
180 eeRecHits_{consumes(conf.getParameter<
edm::InputTag>(
"EERecHits"))},
182 beamSpot_(consumes(conf.getParameter<
edm::InputTag>(
"BeamSpot"))),
183 trajectoryFitterToken_{esConsumes(conf.getParameter<
edm::ESInputTag>(
"Fitter"))},
184 trajectorySmootherToken_{esConsumes(conf.getParameter<
edm::ESInputTag>(
"Smoother"))},
185 builderToken_{esConsumes(conf.getParameter<
edm::ESInputTag>(
"TTRHBuilder"))},
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> >();
213 auto seeds = std::make_unique<reco::ElectronSeedCollection>();
214 auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
215 auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
234 if (trk.trackRef().isNonnull()) {
235 if (trk.trackRef().id() != kfTracks.
id()) {
237 <<
"kfTracks is not the collection that pfTracks was built from, please fix this";
263 auto ecalPreIdsHandle =
event.put(
std::move(ecalPreIds));
264 event.put(
std::move(hcalPreIds),
"HCAL");
267 auto preIdVMOut = std::make_unique<edm::ValueMap<reco::PreIdRef> >();
288 template <
typename T>
298 auto const&
rho =
event.get(
rho_);
321 std::vector<int> matchedEcalClusters;
322 std::vector<int> matchedHcalClusters;
326 ecalPreIds.reserve(
handle->size());
327 hcalPreIds.reserve(
handle->size());
330 for (
unsigned int itrk = 0; itrk <
handle.product()->size(); itrk++) {
343 seed.setCtfTrack(trackRef);
346 unsigned int nModels = globalCache()->modelNames().size();
362 bool result =
decision(templatedRef, ecalPreId, hcalPreId,
rho, spot, ecalTools);
370 ecalPreIds.push_back(ecalPreId);
371 hcalPreIds.push_back(hcalPreId);
372 trksToPreIdIndx[trackRef.
index()] = ecalPreIds.size() - 1;
381 template void LowPtGsfElectronSeedProducer::loop<reco::Track>(
const edm::Handle<std::vector<reco::Track> >&,
386 TrackIndxMap& trksToPreIdIndx,
392 template void LowPtGsfElectronSeedProducer::loop<reco::PFRecTrack>(
const edm::Handle<std::vector<reco::PFRecTrack> >&,
397 TrackIndxMap& trksToPreIdIndx,
406 std::vector<int>& matchedEcalClusters,
407 std::vector<int>& matchedHcalClusters,
433 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
435 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
438 if (
point.isValid()) {
440 for (
unsigned int iclu = 0; iclu <
clusters.product()->size(); iclu++) {
447 if (dr2 <
info.dr2min) {
449 info.cluRef = cluRef;
450 info.deta = cluRef->positionREP().eta() -
point.positionREP().eta();
452 reco::deltaPhi(cluRef->positionREP().phi(),
point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
459 if (
info.dr2min < 1.e5) {
460 float ep =
info.cluRef->correctedEnergy() /
std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
468 pfTrackRef->trackRef()->normalizedChi2(),
481 std::vector<int>& matchedEcalClusters,
482 std::vector<int>& matchedHcalClusters,
497 kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(),
energy);
499 kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
503 if (particle.getSuccess() == 0) {
509 particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
512 bool below_ps =
pow(ecal_pos.z(), 2.) >
boundary_ * ecal_pos.perp2();
515 for (
unsigned int iclu = 0; iclu <
ecalClusters.product()->size(); iclu++) {
521 particle.particle().momentum().y(),
522 particle.particle().momentum().z())
530 if (dr2 <
info.dr2min) {
532 info.cluRef = cluRef;
533 info.deta =
std::abs(cluRef->positionREP().eta() - showerPos.eta());
535 info.showerPos = showerPos;
551 kfTrackRef->normalizedChi2(),
552 info.cluRef->correctedEnergy() /
std::sqrt(kfTrackRef->innerMomentum().mag2()));
561 for (
unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
562 hits.push_back(trackRef->recHit(ihit)->cloneSH());
565 GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
566 GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
574 if (!traj1.isValid()) {
583 float chi2Ratio = trackRef->chi2() > 0. ? traj2.
chiSquared() / trackRef->chi2() : -1.;
584 float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
587 float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
602 for (
auto&
name : globalCache()->modelNames()) {
603 result |= globalCache()->eval(
name, ecalPreId, hcalPreId,
rho, spot, ecalTools);
620 template <
typename CollType>
625 std::vector<reco::PreIdRef>
values;
627 unsigned ntracks = tracksHandle->size();
628 for (
unsigned itrack = 0; itrack <
ntracks; ++itrack) {
630 auto preIdRefIt = trksToPreIdIndx.find(trackRef.
index());
631 if (preIdRefIt == trksToPreIdIndx.end()) {
635 values.push_back(preIdRef);
656 desc.add<std::vector<std::string> >(
"ModelNames", {});
657 desc.add<std::vector<std::string> >(
"ModelWeights", {});
658 desc.add<std::vector<double> >(
"ModelThresholds", {});
659 desc.add<
bool>(
"PassThrough",
false);
660 desc.add<
bool>(
"UsePfTracks",
true);
661 desc.add<
double>(
"MinPtThreshold", 1.0);
662 desc.add<
double>(
"MaxPtThreshold", 15.);
663 descriptions.
add(
"lowPtGsfElectronSeeds",
desc);