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"))),
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 if (
seed.nHits() == 0) {
346 seed.setCtfTrack(trackRef);
349 unsigned int nModels = globalCache()->modelNames().size();
365 bool result =
decision(templatedRef, ecalPreId, hcalPreId,
rho, spot, ecalTools);
373 ecalPreIds.push_back(ecalPreId);
374 hcalPreIds.push_back(hcalPreId);
375 trksToPreIdIndx[trackRef.
index()] = ecalPreIds.size() - 1;
384 template void LowPtGsfElectronSeedProducer::loop<reco::Track>(
const edm::Handle<std::vector<reco::Track> >&,
389 TrackIndxMap& trksToPreIdIndx,
395 template void LowPtGsfElectronSeedProducer::loop<reco::PFRecTrack>(
const edm::Handle<std::vector<reco::PFRecTrack> >&,
400 TrackIndxMap& trksToPreIdIndx,
409 std::vector<int>& matchedEcalClusters,
410 std::vector<int>& matchedHcalClusters,
436 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
438 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
441 if (
point.isValid()) {
443 for (
unsigned int iclu = 0; iclu <
clusters.product()->size(); iclu++) {
450 if (dr2 <
info.dr2min) {
452 info.cluRef = cluRef;
453 info.deta = cluRef->positionREP().eta() -
point.positionREP().eta();
455 reco::deltaPhi(cluRef->positionREP().phi(),
point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
462 if (
info.dr2min < 1.e5) {
463 float ep =
info.cluRef->correctedEnergy() /
std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
471 pfTrackRef->trackRef()->normalizedChi2(),
484 std::vector<int>& matchedEcalClusters,
485 std::vector<int>& matchedHcalClusters,
500 kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(),
energy);
502 kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
506 if (particle.getSuccess() == 0) {
512 particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
515 bool below_ps =
pow(ecal_pos.z(), 2.) >
boundary_ * ecal_pos.perp2();
518 for (
unsigned int iclu = 0; iclu <
ecalClusters.product()->size(); iclu++) {
524 particle.particle().momentum().y(),
525 particle.particle().momentum().z())
533 if (dr2 <
info.dr2min) {
535 info.cluRef = cluRef;
536 info.deta =
std::abs(cluRef->positionREP().eta() - showerPos.eta());
538 info.showerPos = showerPos;
554 kfTrackRef->normalizedChi2(),
555 info.cluRef->correctedEnergy() /
std::sqrt(kfTrackRef->innerMomentum().mag2()));
564 for (
unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
565 hits.push_back(trackRef->recHit(ihit)->cloneSH());
568 GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
569 GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
577 if (!traj1.isValid()) {
586 float chi2Ratio = trackRef->chi2() > 0. ? traj2.
chiSquared() / trackRef->chi2() : -1.;
587 float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
590 float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
605 for (
auto&
name : globalCache()->modelNames()) {
606 result |= globalCache()->eval(
name, ecalPreId, hcalPreId,
rho, spot, ecalTools);
623 template <
typename CollType>
628 std::vector<reco::PreIdRef>
values;
630 unsigned ntracks = tracksHandle->size();
631 for (
unsigned itrack = 0; itrack <
ntracks; ++itrack) {
633 auto preIdRefIt = trksToPreIdIndx.find(trackRef.
index());
634 if (preIdRefIt == trksToPreIdIndx.end()) {
638 values.push_back(preIdRef);
659 desc.add<std::vector<std::string> >(
"ModelNames", {});
660 desc.add<std::vector<std::string> >(
"ModelWeights", {});
661 desc.add<std::vector<double> >(
"ModelThresholds", {});
662 desc.add<
bool>(
"PassThrough",
false);
663 desc.add<
bool>(
"UsePfTracks",
true);
664 desc.add<
double>(
"MinPtThreshold", 1.0);
665 desc.add<
double>(
"MaxPtThreshold", 15.);
666 descriptions.
add(
"lowPtGsfElectronSeeds",
desc);