65 produces<reco::ElectronSeedCollection>();
66 produces<reco::PreIdCollection>();
67 produces<reco::PreIdCollection>(
"HCAL");
68 produces< edm::ValueMap<reco::PreIdRef> >();
90 auto seeds = std::make_unique<reco::ElectronSeedCollection>();
91 auto ecalPreIds = std::make_unique<reco::PreIdCollection>();
92 auto hcalPreIds = std::make_unique<reco::PreIdCollection>();
112 for(
auto& trk : *pfTracks){
113 if(trk.trackRef().isNonnull()){
114 if(trk.trackRef().id() != kfTracks.
id()){
115 throw cms::Exception(
"ConfigError") <<
"kfTracks is not the collection that pfTracks was built from, please fix this";
143 auto ecalPreIdsHandle =
event.put(
std::move(ecalPreIds));
147 auto preIdVMOut = std::make_unique< edm::ValueMap<reco::PreIdRef> >();
170 template <
typename T>
183 event.getByToken(
rho_,rho);
214 std::vector<int> matchedEcalClusters;
215 std::vector<int> matchedHcalClusters;
218 seeds.reserve(
handle->size());
219 ecalPreIds.reserve(
handle->size());
220 hcalPreIds.reserve(
handle->size());
223 for (
unsigned int itrk = 0; itrk <
handle.product()->size(); itrk++ ) {
236 unsigned int nModels = globalCache()->modelNames().size();
257 bool result =
decision(templatedRef,ecalPreId,hcalPreId,*rho,*spot,ecalTools);
260 if ( !result ) {
continue; }
263 ecalPreIds.push_back(ecalPreId);
264 hcalPreIds.push_back(hcalPreId);
265 trksToPreIdIndx[trackRef.
index()] = ecalPreIds.size()-1;
268 seeds.push_back(seed);
303 std::vector<int>& matchedEcalClusters,
304 std::vector<int>& matchedHcalClusters,
332 if ( ecal ) { point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::ECALShowerMax); }
333 else { point = pfTrackRef->extrapolatedPoint(reco::PFTrajectoryPoint::LayerType::HCALEntrance); }
338 for (
unsigned int iclu = 0; iclu < clusters.
product()->size(); iclu++ ) {
340 if (
std::find( matched.begin(), matched.end(), iclu ) == matched.end() ) {
347 if ( dr2 < info.dr2min ) {
349 info.cluRef = cluRef;
350 info.deta = cluRef->positionREP().eta() - point.
positionREP().eta();
353 pfTrackRef->trackRef()->charge();
361 if ( info.dr2min < 1.e5 ) {
362 float ep = info.cluRef->correctedEnergy() /
std::sqrt( pfTrackRef->trackRef()->innerMomentum().mag2() );
370 pfTrackRef->trackRef()->normalizedChi2(),
383 std::vector<int>& matchedEcalClusters,
384 std::vector<int>& matchedHcalClusters,
399 float energy =
sqrt(
mass_ + kfTrackRef->outerMomentum().Mag2() );
401 kfTrackRef->outerMomentum().y(),
402 kfTrackRef->outerMomentum().z(),
405 kfTrackRef->outerPosition().y(),
406 kfTrackRef->outerPosition().z(),
411 if ( particle.getSuccess() == 0 ) {
return; }
414 GlobalPoint ecal_pos(particle.particle().vertex().x(),
415 particle.particle().vertex().y(),
416 particle.particle().vertex().z());
419 bool below_ps =
pow(ecal_pos.z(),2.) >
boundary_*ecal_pos.perp2();
422 for (
unsigned int iclu = 0; iclu < ecalClusters.
product()->size(); iclu++ ) {
431 particle.particle().momentum().y(),
432 particle.particle().momentum().z()).
unit() * shower_depth;
435 float dr2 =
reco::deltaR2( cluRef->positionREP(), showerPos );
438 if ( dr2 <
info.dr2min ) {
440 info.cluRef = cluRef;
441 info.deta =
std::abs( cluRef->positionREP().eta() - showerPos.eta() );
444 kfTrackRef->charge();
445 info.showerPos = showerPos;
463 kfTrackRef->normalizedChi2(),
464 info.cluRef->correctedEnergy() /
std::sqrt( kfTrackRef->innerMomentum().mag2() ) );
477 for (
unsigned int ihit = 0; ihit < trackRef->recHitsSize(); ++ihit ) {
478 hits.push_back( trackRef->recHit(ihit)->cloneSH() );
482 trackRef->innerMomentum().y(),
483 trackRef->innerMomentum().z() );
485 trackRef->innerPosition().y(),
486 trackRef->innerPosition().z() );
494 trackRef->innerStateCovariance(),
495 *hits[0]->surface() );
499 if ( !traj1.isValid() ) {
return false; }
501 if ( !traj2.
isValid() ) {
return false; }
504 float chi2Ratio = trackRef->chi2() > 0. ? traj2.
chiSquared() / trackRef->chi2() : -1.;
505 float gsfReducedChi2 = chi2Ratio > -1. ? chi2Ratio * trackRef->normalizedChi2() : -1.;
508 float gsfDpt = ( ptIn > 0 ) ? fabs( ptOut - ptIn ) / ptIn : 0.;
525 for (
auto&
name: globalCache()->modelNames() ) {
526 result |= globalCache()->eval(
name,
549 template<
typename CollType>
555 std::vector<reco::PreIdRef>
values;
557 unsigned ntracks=tracksHandle->size();
558 for(
unsigned itrack=0;itrack<ntracks;++itrack){
560 auto preIdRefIt = trksToPreIdIndx.find(trackRef.
index());
561 if(preIdRefIt==trksToPreIdIndx.end()){
565 values.push_back(preIdRef);
568 filler.
insert(tracksHandle,values.begin(),values.end());
585 desc.
add<
std::string>(
"Smoother",
"GsfTrajectorySmoother_forPreId");
587 desc.
add< std::vector<std::string> >(
"ModelNames",std::vector<std::string>());
588 desc.
add< std::vector<std::string> >(
"ModelWeights",std::vector<std::string>());
589 desc.
add< std::vector<double> >(
"ModelThresholds",std::vector<double>());
590 desc.
add<
bool>(
"PassThrough",
false);
591 desc.
add<
bool>(
"UsePfTracks",
true);
592 desc.
add<
double>(
"MinPtThreshold",1.0);
593 desc.
add<
double>(
"MaxPtThreshold",15.);
594 descriptions.
add(
"lowPtGsfElectronSeeds",desc);
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
constexpr double deltaPhi(double phi1, double phi2)
T getParameter(std::string const &) const
edm::ESHandle< MagneticField > field_
const std::string smoother_
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)
double z() const
z of vertex
const math::XYZPoint & position() const
cartesian position (x, y, z)
const edm::EDGetTokenT< reco::PFClusterCollection > ecalClusters_
~LowPtGsfElectronSeedProducer() override
edm::EDGetTokenT< reco::PFClusterCollection > hcalClusters_
void insert(const H &h, I begin, I end)
def setup(process, global_tag, zero_tesla=False)
const edm::EDGetTokenT< reco::BeamSpot > beamSpot_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const std::string builder_
void setCtfTrack(const CtfTrackRef &)
Set additional info.
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 &)
virtual TrajectorySmoother * clone() const =0
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_
virtual std::unique_ptr< TrajectoryFitter > clone() const =0
edm::EDGetTokenT< reco::TrackCollection > kfTracks_
#define DEFINE_FWK_MODULE(type)
edm::Ref< PFClusterCollection > PFClusterRef
persistent reference to PFCluster objects
TrajectoryMeasurement const & lastMeasurement() const
bool lightGsfTracking(reco::PreId &, const reco::TrackRef &, const reco::ElectronSeed &, const edm::EventSetup &)
const edm::EDGetTokenT< EcalRecHitCollection > ebRecHits_
Abs< T >::type abs(const T &t)
edm::Ref< PFRecTrackCollection > PFRecTrackRef
persistent reference to PFRecTrack objects
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
const edm::EDGetTokenT< EcalRecHitCollection > eeRecHits_
const edm::EDGetTokenT< double > rho_
edm::EDGetTokenT< reco::PFRecTrackCollection > pfTracks_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
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())
TrajectoryMeasurement const & firstMeasurement() const
static TrackQuality qualityByName(const std::string &name)
bool isValid() const
is this point valid ?
T const * product() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
const std::string fitter_
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)
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
void setTrackProperties(float newchi2, float chi2ratio, float dpt)
const double maxPtThreshold_
GlobalVector globalMomentum() const
std::unordered_map< reco::TrackRef::key_type, size_t > TrackIndxMap
TrajectoryStateOnSurface const & updatedState() const
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
T const * product() const
reco::TrackRef getBaseRef(edm::Handle< std::vector< reco::Track > > handle, int idx) const
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