60 produces<GsfPFRecTrackCollection>();
61 produces<GsfPFRecTrackCollection>(
"Secondary").setBranchAlias(
"secondary");
95 auto gsfPFRecTrackCollection = std::make_unique<GsfPFRecTrackCollection>();
97 auto gsfPFRecTrackCollectionSecondary = std::make_unique<GsfPFRecTrackCollection>();
136 vector<Trajectory> tjvec(0);
140 tjvec = *(TrajectoryCollection.
product());
143 vector<reco::GsfPFRecTrack> selGsfPFRecTracks;
144 vector<reco::GsfPFRecTrack> primaryGsfPFRecTracks;
145 std::map<unsigned int, std::vector<reco::GsfPFRecTrack> > GsfPFMap;
147 for (
unsigned igsf = 0; igsf < gsftracks.size(); igsf++) {
158 for (
unsigned int igsf = 0; igsf < gsftracks.size(); igsf++) {
161 int kf_ind =
FindPfRef(PfRTkColl, gsftracks[igsf],
false);
169 bool isEcalDriven =
true;
170 bool isTrackerDriven =
true;
172 if (trackRef->seedRef().
get() ==
nullptr) {
173 isEcalDriven =
false;
174 isTrackerDriven =
false;
176 auto const& SeedFromRef =
static_cast<ElectronSeed const&
>(*(trackRef->extra()->seedRef()));
177 if (SeedFromRef.caloCluster().isNull())
178 isEcalDriven =
false;
179 if (SeedFromRef.ctfTrack().isNull())
180 isTrackerDriven =
false;
203 bool validgsfbrem =
false;
214 if (validgsfbrem && passSel)
215 selGsfPFRecTracks.push_back(
pftrack_);
218 unsigned int count_primary = 0;
219 if (!selGsfPFRecTracks.empty()) {
220 for (
unsigned int ipfgsf = 0; ipfgsf < selGsfPFRecTracks.size(); ipfgsf++) {
221 vector<unsigned int> secondaries(0);
226 keepGsf =
resolveGsfTracks(selGsfPFRecTracks, ipfgsf, secondaries, theEcalClusters);
230 if (keepGsf ==
true) {
233 thePrimaryVertexColl,
242 selGsfPFRecTracks[ipfgsf])) {
243 const vector<PFRecTrackRef>& convBremPFRecTracks(
convBremFinder_->getConvBremPFRecTracks());
244 for (
unsigned int ii = 0;
ii < convBremPFRecTracks.size();
ii++) {
245 selGsfPFRecTracks[ipfgsf].addConvBremPFRecTrackRef(convBremPFRecTracks[
ii]);
251 primaryGsfPFRecTracks.push_back(selGsfPFRecTracks[ipfgsf]);
256 unsigned int primGsfIndex = selGsfPFRecTracks[ipfgsf].trackId();
257 vector<reco::GsfPFRecTrack> trueGsfPFRecTracks;
258 if (!secondaries.empty()) {
260 for (
unsigned int isecpfgsf = 0; isecpfgsf < secondaries.size(); isecpfgsf++) {
261 PFRecTrackRef refsecKF = selGsfPFRecTracks[(secondaries[isecpfgsf])].kfPFRecTrackRef();
263 unsigned int secGsfIndex = selGsfPFRecTracks[(secondaries[isecpfgsf])].trackId();
264 GsfTrackRef secGsfRef = selGsfPFRecTracks[(secondaries[isecpfgsf])].gsfTrackRef();
277 bool validgsfbrem =
false;
286 gsfPFRecTrackCollectionSecondary->push_back(
secpftrack_);
291 GsfPFMap.insert(pair<
unsigned int, std::vector<reco::GsfPFRecTrack> >(count_primary, trueGsfPFRecTracks));
292 trueGsfPFRecTracks.clear();
299 iEvent.
put(
std::move(gsfPFRecTrackCollectionSecondary),
"Secondary");
304 for (
unsigned int iGSF = 0; iGSF < primaryGsfPFRecTracks.size(); iGSF++) {
305 gsfPFRecTrackCollection->push_back(primaryGsfPFRecTracks[iGSF]);
309 selGsfPFRecTracks.clear();
311 primaryGsfPFRecTracks.clear();
319 std::vector<reco::GsfPFRecTrack>& gsfPFRecTrackPrimary,
320 const std::map<
unsigned int, std::vector<reco::GsfPFRecTrack> >& MapPrimSec) {
321 unsigned int cgsf = 0;
322 unsigned int csecgsf = 0;
323 for (
std::map<
unsigned int, std::vector<reco::GsfPFRecTrack> >::const_iterator igsf = MapPrimSec.begin();
324 igsf != MapPrimSec.end();
326 vector<reco::GsfPFRecTrack> SecGsfPF = igsf->second;
327 for (
unsigned int iSecGsf = 0; iSecGsf < SecGsfPF.size(); iSecGsf++) {
329 gsfPFRecTrackPrimary[cgsf].addConvBremGsfPFRecTrackRef(refgprt);
344 if (ElSeedFromRef.ctfTrack().isNull()) {
345 reco::PFRecTrackCollection::const_iterator pft = PfRTkColl.begin();
346 reco::PFRecTrackCollection::const_iterator pftend = PfRTkColl.end();
347 unsigned int i_pf = 0;
349 unsigned int ish_max = 0;
353 for (; pft != pftend; ++pft) {
354 unsigned int ish = 0;
356 float dph = fabs(pft->trackRef()->phi() - gsftk.
phi());
359 float det = fabs(pft->trackRef()->eta() - gsftk.
eta());
360 float dr =
sqrt(dph * dph + det * det);
362 for (
auto const& hhit : pft->trackRef()->recHits()) {
363 if (!hhit->isValid())
367 for (; hit != hit_end; ++hit) {
368 if (!(hit->isValid()))
377 if ((ish > ish_max) || ((ish == ish_max) && (dr < dr_min))) {
388 if ((ish_max == 0) || (dr_min > 0.05))
390 if (otherColl && (ish_max == 0))
396 reco::PFRecTrackCollection::const_iterator pft = PfRTkColl.begin();
397 reco::PFRecTrackCollection::const_iterator pftend = PfRTkColl.end();
398 unsigned int i_pf = 0;
400 for (; pft != pftend; ++pft) {
402 if (pft->trackRef() == ElSeedFromRef.ctfTrack()) {
417 bool passCut =
false;
418 if (ElSeedFromRef.ctfTrack().isNull()) {
419 if (ElSeedFromRef.caloCluster().isNull())
421 auto const* scRef =
static_cast<SuperCluster const*
>(ElSeedFromRef.caloCluster().get());
424 float caloEne = scRef->energy();
426 float fphi = fabs(scRef->phi() - gsftk.
phiMode());
440 vector<unsigned int>& secondaries,
443 bool n_keepGsf =
true;
447 if (nGsfTrack->seedRef().
get() ==
nullptr)
449 auto const& nElSeedFromRef =
static_cast<ElectronSeed const&
>(*(nGsfTrack->extra()->seedRef()));
462 float neta = nGsfTrack->innerMomentum().eta();
463 float nphi = nGsfTrack->innerMomentum().phi();
466 cout <<
" PFElecTkProducer:: considering track " << nGsfTrack->pt() <<
" eta,phi " << nGsfTrack->eta() <<
", " 467 << nGsfTrack->phi() << endl;
469 for (
unsigned int igsf = 0; igsf < GsfPFVec.size(); igsf++) {
474 cout <<
" PFElecTkProducer:: and comparing with track " << iGsfTrack->pt() <<
" eta,phi " << iGsfTrack->eta()
475 <<
", " << iGsfTrack->phi() << endl;
477 float ieta = iGsfTrack->innerMomentum().eta();
478 float iphi = iGsfTrack->innerMomentum().phi();
479 float feta = fabs(neta - ieta);
480 float fphi = fabs(nphi - iphi);
485 if (feta < 0.5 && fabs(fphi) < 1.0) {
487 cout <<
" Entering angular superloose preselection " << endl;
500 if (iGsfTrack->seedRef().
get() ==
nullptr)
502 auto const& iElSeedFromRef =
static_cast<ElectronSeed const&
>(*(iGsfTrack->extra()->seedRef()));
506 bool areBothGsfEcalDriven =
false;
508 bool isSameSC =
isSameEgSC(nElSeedFromRef, iElSeedFromRef, areBothGsfEcalDriven, SCEnergy);
511 if (areBothGsfEcalDriven) {
513 float nEP = SCEnergy / nPin;
514 float iEP = SCEnergy / iPin;
516 cout <<
" Entering SAME supercluster case " 517 <<
" nEP " << nEP <<
" iEP " << iEP << endl;
523 bool isSameLayer =
false;
527 cout <<
" iGsf is InnerMostWithLostHits " << iGsfInnermostWithLostHits <<
" isSameLayer " << isSameLayer
530 if (iGsfInnermostWithLostHits) {
533 }
else if (isSameLayer) {
534 if (fabs(iEP - 1) < fabs(nEP - 1)) {
538 secondaries.push_back(igsf);
542 secondaries.push_back(igsf);
547 float minBremDphi =
minTangDist(GsfPFVec[ngsf], GsfPFVec[igsf]);
550 bool isBothGsfTrackerDriven =
false;
551 bool nEcalDriven =
false;
552 bool iEcalDriven =
false;
558 isBothGsfTrackerDriven,
565 bool isSameLayer =
false;
572 cout <<
" Sharing ECAL energy passed " 573 <<
" nEtot " << nETot <<
" iEtot " << iETot << endl;
574 if (isBothGsfTrackerDriven)
575 cout <<
" Both Track are trackerDriven " << endl;
579 if (iGsfInnermostWithLostHits) {
582 }
else if (isSameLayer) {
590 if (isBothGsfTrackerDriven ==
false) {
596 secondaries.push_back(igsf);
603 if (nETot != iETot) {
611 float nEP = ETot / nPin;
612 float iEP = ETot / iPin;
615 cout <<
" nETot " << nETot <<
" iETot " << iETot <<
" ETot " << ETot << endl
616 <<
" nPin " << nPin <<
" iPin " << iPin <<
" nEP " << nEP <<
" iEP " << iEP << endl;
618 if (fabs(iEP - 1) < fabs(nEP - 1)) {
622 secondaries.push_back(igsf);
626 secondaries.push_back(igsf);
630 bool secPushedBack =
false;
631 if (nEcalDriven ==
false && nETot == 0.) {
634 }
else if (iEcalDriven ==
false && iETot == 0.) {
635 secondaries.push_back(igsf);
636 secPushedBack =
true;
639 cout <<
" Close Tracks " 640 <<
" feta " << feta <<
" fabs(fphi) " << fabs(fphi) <<
" minBremDphi " << minBremDphi <<
" nETot " 641 << nETot <<
" iETot " << iETot <<
" nLostHits " 642 << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) <<
" iLostHits " 643 << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
647 if (iGsfInnermostWithLostHits) {
650 }
else if (isSameLayer ==
false) {
651 if (secPushedBack ==
false)
652 secondaries.push_back(igsf);
655 }
else if (feta < 0.1 && minBremDphi < 0.2) {
659 cout <<
" Close Tracks and failed all the conditions " 660 <<
" feta " << feta <<
" fabs(fphi) " << fabs(fphi) <<
" minBremDphi " << minBremDphi <<
" nETot " 661 << nETot <<
" iETot " << iETot <<
" nLostHits " 662 << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) <<
" iLostHits " 663 << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
665 if (nEcalDriven ==
false && nETot == 0.) {
681 std::vector<reco::PFBrem> primPFBrem = primGsf.
PFRecBrem();
682 std::vector<reco::PFBrem> secPFBrem = secGsf.
PFRecBrem();
684 unsigned int cbrem = 0;
685 for (
unsigned isbrem = 0; isbrem < secPFBrem.size(); isbrem++) {
686 if (secPFBrem[isbrem].indTrajPoint() == 99)
694 unsigned int sbrem = 0;
695 for (
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
696 if (primPFBrem[ipbrem].indTrajPoint() == 99)
706 float dphi = fabs(primPhi - secPhi);
709 if (fabs(dphi) < minDphi) {
710 minDphi = fabs(dphi);
723 bool& bothGsfEcalDriven,
725 bool isSameSC =
false;
731 if (nscRef && iscRef) {
732 bothGsfEcalDriven =
true;
733 if (nscRef == iscRef) {
736 SCEnergy = nscRef->energy();
747 bool& bothGsfTrackerDriven,
752 bool isSharingEnergy =
false;
755 bool oneEcalDriven =
true;
762 nEnergy = scRef->
energy();
764 gsfPfTrack = iGsfPFRecTrack;
768 iEnergy = scRef->
energy();
770 gsfPfTrack = nGsfPFRecTrack;
772 oneEcalDriven =
false;
778 vector<PFCluster> vecPFClusters;
779 vecPFClusters.clear();
781 for (PFClusterCollection::const_iterator clus = theEClus.begin(); clus != theEClus.end(); clus++) {
792 if (deta < 0.5 && fabs(dphi) < 1.0) {
799 iEnergy += clust.
energy();
801 nEnergy += clust.
energy();
802 vecPFClusters.push_back(clust);
806 vector<PFBrem> primPFBrem = gsfPfTrack.
PFRecBrem();
807 for (
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
808 if (primPFBrem[ipbrem].indTrajPoint() == 99)
816 iEnergy += clust.
energy();
818 nEnergy += clust.
energy();
819 vecPFClusters.push_back(clust);
825 if (!vecPFClusters.empty()) {
826 for (
unsigned int pf = 0;
pf < vecPFClusters.size();
pf++) {
829 isSharingEnergy =
true;
837 bothGsfTrackerDriven =
true;
838 vector<PFCluster> nPFCluster;
839 vector<PFCluster> iPFCluster;
844 for (PFClusterCollection::const_iterator clus = theEClus.begin(); clus != theEClus.end(); clus++) {
854 if (ndeta < 0.5 && fabs(ndphi) < 1.0) {
859 nPFCluster.push_back(clust);
860 nEnergy += clust.
energy();
862 const vector<PFBrem>& primPFBrem = nGsfPFRecTrack.
PFRecBrem();
863 for (
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
864 if (primPFBrem[ipbrem].indTrajPoint() == 99)
871 nPFCluster.push_back(clust);
872 nEnergy += clust.
energy();
885 if (ideta < 0.5 && fabs(idphi) < 1.0) {
890 iPFCluster.push_back(clust);
891 iEnergy += clust.
energy();
893 vector<PFBrem> primPFBrem = iGsfPFRecTrack.
PFRecBrem();
894 for (
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
895 if (primPFBrem[ipbrem].indTrajPoint() == 99)
900 iPFCluster.push_back(clust);
901 iEnergy += clust.
energy();
909 if (!nPFCluster.empty() && !iPFCluster.empty()) {
910 for (
unsigned int npf = 0; npf < nPFCluster.size(); npf++) {
911 for (
unsigned int ipf = 0; ipf < iPFCluster.size(); ipf++) {
914 isSharingEnergy =
true;
924 return isSharingEnergy;
936 int gsfHitCounter1 = 0;
937 for (
auto const&
hit : nGsfTrack->recHits()) {
943 int gsfHitCounter2 = 0;
944 for (
auto const&
hit : iGsfTrack->recHits()) {
950 uint32_t gsfHit1 = gsfHitPattern1.
getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1);
951 uint32_t gsfHit2 = gsfHitPattern2.
getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter2);
955 }
else if (gsfHitPattern1.
getLayer(gsfHit1) != gsfHitPattern2.
getLayer(gsfHit2)) {
956 return (gsfHitPattern2.
getLayer(gsfHit2) < gsfHitPattern1.
getLayer(gsfHit1));
966 unsigned int nLostHits = nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
967 unsigned int iLostHits = iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
969 if (nLostHits != iLostHits) {
970 return (nLostHits > iLostHits);
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
bool trajinev_
Trajectory of GSfTracks in the event?
const edm::RefToBase< TrajectorySeed > & seedRef() const
value_type const * get() const
T getParameter(std::string const &) const
const math::XYZPoint & position() const
cluster centroid position
reconstructed track used as an input to particle flow
edm::EDGetTokenT< reco::PFRecTrackCollection > pfTrackLabel_
static uint32_t getLayer(uint16_t pattern)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
bool isNonnull() const
Checks for non-null.
edm::EDGetTokenT< reco::GsfTrackCollection > gsfTrackLabel_
void createGsfPFRecTrackRef(const edm::OrphanHandle< reco::GsfPFRecTrackCollection > &gsfPfHandle, std::vector< reco::GsfPFRecTrack > &gsfPFRecTrackPrimary, const std::map< unsigned int, std::vector< reco::GsfPFRecTrack > > &MapPrimSec)
const TrackExtraRef & extra() const
reference to "extra" object
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
double mvaConvBremFinderIDEndcapsLowPt_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool useFifthStepForTrackDriven_
const std::vector< reco::PFBrem > & PFRecBrem() const
const CaloClusterRef & caloCluster() const
double phi() const
azimuthal angle of momentum vector
bool applySelection(const reco::GsfTrack &)
bool isNonnull() const
Checks for non-null.
key_type key() const
Accessor for product key.
reco::GsfPFRecTrack secpftrack_
std::unique_ptr< ConvBremPFTrackFinder > convBremFinder_
void swap(Association< C > &lhs, Association< C > &rhs)
~PFElecTkProducer() override
Destructor.
edm::EDGetTokenT< reco::VertexCollection > primVtxLabel_
double mvaConvBremFinderIDBarrelLowPt_
double eta() const
pseudorapidity of momentum vector
void calculatePositionREP()
computes posrep_ once and for all
edm::EDGetTokenT< reco::PFV0Collection > pfV0_
const reco::GsfTrackRef & gsfTrackRef() const
recHitContainer::const_iterator const_iterator
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
double energy() const
cluster energy
edm::EDGetTokenT< reco::PFDisplacedTrackerVertexCollection > pfNuclear_
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
T const * get() const
Returns C++ pointer to the item.
bool isSameEgSC(const reco::ElectronSeed &nSeed, const reco::ElectronSeed &iSeed, bool &bothGsfEcalDriven, float &SCEnergy)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
static uint32_t getSubStructure(uint16_t pattern)
double energy() const
cluster energy
bool isInnerMostWithLostHits(const reco::GsfTrackRef &nGsfTrack, const reco::GsfTrackRef &iGsfTrack, bool &sameLayer)
PFElecTkProducer(const edm::ParameterSet &, const convbremhelpers::HeavyObjectCache *)
Constructor.
void endRun(const edm::Run &, const edm::EventSetup &) override
int FindPfRef(const reco::PFRecTrackCollection &PfRTkColl, const reco::GsfTrack &, bool)
bool resolveGsfTracks(const std::vector< reco::GsfPFRecTrack > &GsfPFVec, unsigned int ngsf, std::vector< unsigned int > &secondaries, const reco::PFClusterCollection &theEClus)
bool isValid() const
is this point valid ?
T const * product() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
double mvaConvBremFinderIDBarrelHighPt_
double mvaConvBremFinderIDEndcapsHighPt_
edm::EDGetTokenT< reco::PFConversionCollection > pfConv_
std::vector< Trajectory > TrajectoryCollection
void beginRun(const edm::Run &, const edm::EventSetup &) override
double etaMode() const
pseudorapidity of momentum vector from mode
bool useFifthStepForEcalDriven_
reco::GsfPFRecTrack pftrack_
void produce(edm::Event &, const edm::EventSetup &) override
Produce the PFRecTrack collection.
double phiMode() const
azimuthal angle of momentum vector from mode
bool useConvBremFinder_
Conv Brem Finder.
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
std::unique_ptr< PFTrackTransformer > pfTransformer_
PFTrackTransformer.
std::vector< double > gsfInnerMomentumCache_
bool momentumFromModeCartesian(TrajectoryStateOnSurface const &tsos, GlobalVector &momentum)
uint16_t getHitPattern(HitCategory category, int position) const
T const * product() const
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
float minTangDist(const reco::GsfPFRecTrack &primGsf, const reco::GsfPFRecTrack &secGsf)
std::vector< PFRecTrack > PFRecTrackCollection
collection of PFRecTrack objects
edm::EDGetTokenT< reco::PFClusterCollection > pfEcalClusters_
bool isSharingEcalEnergyWithEgSC(const reco::GsfPFRecTrack &nGsfPFRecTrack, const reco::GsfPFRecTrack &iGsfPFRecTrack, const reco::ElectronSeed &nSeed, const reco::ElectronSeed &iSeed, const reco::PFClusterCollection &theEClus, bool &bothGsfTrackerDriven, bool &nEcalDriven, bool &iEcalDriven, float &nEnergy, float &iEnergy)
bool applyAngularGsfClean_
MultiTrajectoryStateTransform mtsTransform_
bool isInnerMost(const reco::GsfTrackRef &nGsfTrack, const reco::GsfTrackRef &iGsfTrack, bool &sameLayer)