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>
164 static constexpr
double boundary_ = 2.50746495928 * 2.50746495928;
166 static constexpr
double mass_ = 0.000511 * 0.000511;
180 ebRecHits_{consumes(conf.getParameter<
edm::InputTag>(
"EBRecHits"))},
181 eeRecHits_{consumes(conf.getParameter<
edm::InputTag>(
"EERecHits"))},
183 beamSpot_(consumes(conf.getParameter<
edm::InputTag>(
"BeamSpot"))),
187 magToken_{esConsumes<edm::Transition::BeginLuminosityBlock>()},
188 ecalClusterToolsESGetTokens_{consumesCollector()},
189 passThrough_(conf.getParameter<
bool>(
"PassThrough")),
190 usePfTracks_(conf.getParameter<
bool>(
"UsePfTracks")),
191 minPtThreshold_(conf.getParameter<
double>(
"MinPtThreshold")),
192 maxPtThreshold_(conf.getParameter<
double>(
"MaxPtThreshold")) {
194 pfTracks_ = consumes(conf.getParameter<
edm::InputTag>(
"pfTracks"));
195 hcalClusters_ = consumes(conf.getParameter<
edm::InputTag>(
"hcalClusters"));
197 kfTracks_ = consumes(conf.getParameter<
edm::InputTag>(
"tracks"));
199 produces<reco::ElectronSeedCollection>();
200 produces<reco::PreIdCollection>();
201 produces<reco::PreIdCollection>(
"HCAL");
202 produces<edm::ValueMap<reco::PreIdRef> >();
215 auto seeds = std::make_unique<reco::ElectronSeedCollection>();
216 auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
217 auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
236 if (trk.trackRef().isNonnull()) {
237 if (trk.trackRef().id() != kfTracks.
id()) {
239 <<
"kfTracks is not the collection that pfTracks was built from, please fix this";
265 auto ecalPreIdsHandle =
event.put(
std::move(ecalPreIds));
266 event.put(
std::move(hcalPreIds),
"HCAL");
269 auto preIdVMOut = std::make_unique<edm::ValueMap<reco::PreIdRef> >();
290 template <
typename T>
300 auto const&
rho =
event.get(
rho_);
323 std::vector<int> matchedEcalClusters;
324 std::vector<int> matchedHcalClusters;
328 ecalPreIds.reserve(
handle->size());
329 hcalPreIds.reserve(
handle->size());
332 for (
unsigned int itrk = 0; itrk <
handle.product()->size(); itrk++) {
345 if (
seed.nHits() == 0) {
348 seed.setCtfTrack(trackRef);
351 unsigned int nModels = globalCache()->modelNames().size();
367 bool result =
decision(templatedRef, ecalPreId, hcalPreId,
rho, spot, ecalTools);
375 ecalPreIds.push_back(ecalPreId);
376 hcalPreIds.push_back(hcalPreId);
377 trksToPreIdIndx[trackRef.
index()] = ecalPreIds.size() - 1;
391 TrackIndxMap& trksToPreIdIndx,
402 TrackIndxMap& trksToPreIdIndx,
411 std::vector<int>& matchedEcalClusters,
412 std::vector<int>& matchedHcalClusters,
438 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax);
440 point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance);
443 if (
point.isValid()) {
445 for (
unsigned int iclu = 0; iclu <
clusters.product()->size(); iclu++) {
452 if (dr2 <
info.dr2min) {
454 info.cluRef = cluRef;
455 info.deta = cluRef->positionREP().eta() -
point.positionREP().eta();
457 reco::deltaPhi(cluRef->positionREP().phi(),
point.positionREP().phi()) * pfTrackRef->trackRef()->charge();
464 if (
info.dr2min < 1.e5) {
465 float ep =
info.cluRef->correctedEnergy() /
std::sqrt(pfTrackRef->trackRef()->innerMomentum().mag2());
473 pfTrackRef->trackRef()->normalizedChi2(),
486 std::vector<int>& matchedEcalClusters,
487 std::vector<int>& matchedHcalClusters,
502 kfTrackRef->outerMomentum().x(), kfTrackRef->outerMomentum().y(), kfTrackRef->outerMomentum().z(),
energy);
504 kfTrackRef->outerPosition().x(), kfTrackRef->outerPosition().y(), kfTrackRef->outerPosition().z(), 0.);
508 if (particle.getSuccess() == 0) {
514 particle.particle().vertex().x(), particle.particle().vertex().y(), particle.particle().vertex().z());
517 bool below_ps =
pow(ecal_pos.z(), 2.) >
boundary_ * ecal_pos.perp2();
520 for (
unsigned int iclu = 0; iclu <
ecalClusters.product()->size(); iclu++) {
526 particle.particle().momentum().y(),
527 particle.particle().momentum().z())
535 if (dr2 <
info.dr2min) {
537 info.cluRef = cluRef;
538 info.deta =
std::abs(cluRef->positionREP().eta() - showerPos.eta());
540 info.showerPos = showerPos;
556 kfTrackRef->normalizedChi2(),
557 info.cluRef->correctedEnergy() /
std::sqrt(kfTrackRef->innerMomentum().mag2()));
566 for (
unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit) {
567 hits.push_back(trackRef->recHit(ihit)->cloneSH());
570 GlobalVector gv(trackRef->innerMomentum().x(), trackRef->innerMomentum().y(), trackRef->innerMomentum().z());
571 GlobalPoint gp(trackRef->innerPosition().x(), trackRef->innerPosition().y(), trackRef->innerPosition().z());
579 if (!traj1.isValid()) {
588 float chi2Ratio = trackRef->chi2() > 0. ? traj2.
chiSquared() / trackRef->chi2() : -1.;
589 float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
592 float gsfDpt = (ptIn > 0) ? fabs(ptOut - ptIn) / ptIn : 0.;
607 for (
auto&
name : globalCache()->modelNames()) {
608 result |= globalCache()->eval(
name, ecalPreId, hcalPreId,
rho, spot, ecalTools);
625 template <
typename CollType>
630 std::vector<reco::PreIdRef>
values;
632 unsigned ntracks = tracksHandle->size();
633 for (
unsigned itrack = 0; itrack <
ntracks; ++itrack) {
635 auto preIdRefIt = trksToPreIdIndx.find(trackRef.
index());
636 if (preIdRefIt == trksToPreIdIndx.end()) {
640 values.push_back(preIdRef);
661 desc.add<std::vector<std::string> >(
"ModelNames", {});
662 desc.add<std::vector<std::string> >(
"ModelWeights", {});
663 desc.add<std::vector<double> >(
"ModelThresholds", {});
664 desc.add<
bool>(
"PassThrough",
false);
665 desc.add<
bool>(
"UsePfTracks",
true);
666 desc.add<
double>(
"MinPtThreshold", 1.0);
667 desc.add<
double>(
"MaxPtThreshold", 15.);
668 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
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
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