62 using TrackIndxMap = std::unordered_map<reco::TrackRef::key_type, size_t>;
98 std::vector<int>& matchedEcalClusters,
99 std::vector<int>& matchedHcalClusters,
105 std::vector<int>& matchedClusters,
112 std::vector<int>& matchedEcalClusters,
113 std::vector<int>& matchedHcalClusters,
116 template <
typename CollType>
162 static constexpr
double boundary_ = 2.50746495928 * 2.50746495928;
164 static constexpr
double mass_ = 0.000511 * 0.000511;
178 ebRecHits_{consumes<EcalRecHitCollection>(conf.getParameter<
edm::InputTag>(
"EBRecHits"))},
179 eeRecHits_{consumes<EcalRecHitCollection>(conf.getParameter<
edm::InputTag>(
"EERecHits"))},
180 rho_(consumes<double>(conf.getParameter<
edm::InputTag>(
"rho"))),
181 beamSpot_(consumes<reco::BeamSpot>(conf.getParameter<
edm::InputTag>(
"BeamSpot"))),
183 smoother_(conf.getParameter<
std::string>(
"Smoother")),
184 builder_(conf.getParameter<
std::string>(
"TTRHBuilder")),
185 passThrough_(conf.getParameter<
bool>(
"PassThrough")),
186 usePfTracks_(conf.getParameter<
bool>(
"UsePfTracks")),
187 minPtThreshold_(conf.getParameter<
double>(
"MinPtThreshold")),
188 maxPtThreshold_(conf.getParameter<
double>(
"MaxPtThreshold")) {
190 pfTracks_ = consumes<reco::PFRecTrackCollection>(conf.getParameter<
edm::InputTag>(
"pfTracks"));
191 hcalClusters_ = consumes<reco::PFClusterCollection>(conf.getParameter<
edm::InputTag>(
"hcalClusters"));
193 kfTracks_ = consumes<reco::TrackCollection>(conf.getParameter<
edm::InputTag>(
"tracks"));
195 produces<reco::ElectronSeedCollection>();
196 produces<reco::PreIdCollection>();
197 produces<reco::PreIdCollection>(
"HCAL");
198 produces<edm::ValueMap<reco::PreIdRef> >();
211 auto seeds = std::make_unique<reco::ElectronSeedCollection>();
212 auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
213 auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
232 if (trk.trackRef().isNonnull()) {
233 if (trk.trackRef().id() != kfTracks.
id()) {
235 <<
"kfTracks is not the collection that pfTracks was built from, please fix this";
261 auto ecalPreIdsHandle =
event.put(
std::move(ecalPreIds));
262 event.put(
std::move(hcalPreIds),
"HCAL");
265 auto preIdVMOut = std::make_unique<edm::ValueMap<reco::PreIdRef> >();
286 template <
typename T>
316 TkClonerImpl hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(builder.
product())->cloner();
328 std::vector<int> matchedEcalClusters;
329 std::vector<int> matchedHcalClusters;
333 ecalPreIds.reserve(
handle->size());
334 hcalPreIds.reserve(
handle->size());
337 for (
unsigned int itrk = 0; itrk <
handle.product()->size(); itrk++) {
350 seed.setCtfTrack(trackRef);
353 unsigned int nModels = globalCache()->modelNames().size();
369 bool result =
decision(templatedRef, ecalPreId, hcalPreId, *
rho, *spot, ecalTools);
377 ecalPreIds.push_back(ecalPreId);
378 hcalPreIds.push_back(hcalPreId);
379 trksToPreIdIndx[trackRef.
index()] = ecalPreIds.size() - 1;
388 template void LowPtGsfElectronSeedProducer::loop<reco::Track>(
const edm::Handle<std::vector<reco::Track> >&,
393 TrackIndxMap& trksToPreIdIndx,
399 template void LowPtGsfElectronSeedProducer::loop<reco::PFRecTrack>(
const edm::Handle<std::vector<reco::PFRecTrack> >&,
404 TrackIndxMap& trksToPreIdIndx,
413 std::vector<int>& matchedEcalClusters,
414 std::vector<int>& matchedHcalClusters,
440 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
442 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
445 if (
point.isValid()) {
447 for (
unsigned int iclu = 0; iclu <
clusters.product()->size(); iclu++) {
454 if (dr2 <
info.dr2min) {
456 info.cluRef = cluRef;
457 info.deta = cluRef->positionREP().eta() -
point.positionREP().eta();
459 reco::deltaPhi(cluRef->positionREP().phi(),
point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
466 if (
info.dr2min < 1.e5) {
467 float ep =
info.cluRef->correctedEnergy() /
std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
475 pfTrackRef->trackRef()->normalizedChi2(),
488 std::vector<int>& matchedEcalClusters,
489 std::vector<int>& matchedHcalClusters,
504 kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(),
energy);
506 kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
510 if (particle.getSuccess() == 0) {
516 particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
519 bool below_ps =
pow(ecal_pos.z(), 2.) >
boundary_ * ecal_pos.perp2();
522 for (
unsigned int iclu = 0; iclu <
ecalClusters.product()->size(); iclu++) {
528 particle.particle().momentum().y(),
529 particle.particle().momentum().z())
537 if (dr2 <
info.dr2min) {
539 info.cluRef = cluRef;
540 info.deta =
std::abs(cluRef->positionREP().eta() - showerPos.eta());
542 info.showerPos = showerPos;
558 kfTrackRef->normalizedChi2(),
559 info.cluRef->correctedEnergy() /
std::sqrt(kfTrackRef->innerMomentum().mag2()));
569 for (
unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
570 hits.push_back(trackRef->recHit(ihit)->cloneSH());
573 GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
574 GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
582 if (!traj1.isValid()) {
591 float chi2Ratio = trackRef->chi2() > 0. ? traj2.
chiSquared() / trackRef->chi2() : -1.;
592 float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
595 float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
610 for (
auto&
name : globalCache()->modelNames()) {
611 result |= globalCache()->eval(
name, ecalPreId, hcalPreId,
rho, spot, ecalTools);
628 template <
typename CollType>
633 std::vector<reco::PreIdRef>
values;
635 unsigned ntracks = tracksHandle->size();
636 for (
unsigned itrack = 0; itrack < ntracks; ++itrack) {
638 auto preIdRefIt = trksToPreIdIndx.find(trackRef.
index());
639 if (preIdRefIt == trksToPreIdIndx.end()) {
643 values.push_back(preIdRef);
662 desc.
add<
std::string>(
"Smoother",
"GsfTrajectorySmoother_forPreId");
664 desc.
add<std::vector<std::string> >(
"ModelNames", std::vector<std::string>());
665 desc.
add<std::vector<std::string> >(
"ModelWeights", std::vector<std::string>());
666 desc.
add<std::vector<double> >(
"ModelThresholds", std::vector<double>());
667 desc.
add<
bool>(
"PassThrough",
false);
668 desc.
add<
bool>(
"UsePfTracks",
true);
669 desc.
add<
double>(
"MinPtThreshold", 1.0);
670 desc.
add<
double>(
"MaxPtThreshold", 15.);
671 descriptions.
add(
"lowPtGsfElectronSeeds", desc);