47 (
"GsfTrackModuleLabel"));
53 (
"PrimaryVertexLabel"));
72 produces<GsfPFRecTrackCollection>();
73 produces<GsfPFRecTrackCollection>(
"Secondary" ).setBranchAlias(
"secondary" );
116 auto gsfPFRecTrackCollection = std::make_unique<GsfPFRecTrackCollection>();
118 auto gsfPFRecTrackCollectionSecondary = std::make_unique<GsfPFRecTrackCollection>();
160 vector<Trajectory> tjvec(0);
164 tjvec= *(TrajectoryCollection.
product());
168 vector<reco::GsfPFRecTrack> selGsfPFRecTracks;
169 vector<reco::GsfPFRecTrack> primaryGsfPFRecTracks;
170 std::map<unsigned int, std::vector<reco::GsfPFRecTrack> > GsfPFMap;
172 for(
unsigned igsf = 0; igsf < gsftracks.size(); igsf++ ) {
183 for (
unsigned int igsf=0; igsf<gsftracks.size();igsf++) {
187 int kf_ind=
FindPfRef(PfRTkColl,gsftracks[igsf],
false);
199 bool isEcalDriven =
true;
200 bool isTrackerDriven =
true;
202 if (trackRef->seedRef().
get()==
nullptr) {
203 isEcalDriven =
false;
204 isTrackerDriven =
false;
207 auto const& SeedFromRef=
static_cast<ElectronSeed const&
>(*(trackRef->extra()->seedRef()) );
208 if(SeedFromRef.caloCluster().isNull())
209 isEcalDriven =
false;
210 if(SeedFromRef.ctfTrack().isNull())
211 isTrackerDriven =
false;
214 if(isFifthStepTrack &&
216 isTrackerDriven ==
false &&
221 if(isFifthStepTrack &&
223 isEcalDriven ==
false &&
228 if(isFifthStepTrack &&
250 bool validgsfbrem =
false;
266 if(validgsfbrem && passSel)
267 selGsfPFRecTracks.push_back(
pftrack_);
271 unsigned int count_primary = 0;
272 if(!selGsfPFRecTracks.empty()) {
273 for(
unsigned int ipfgsf=0; ipfgsf<selGsfPFRecTracks.size();ipfgsf++) {
275 vector<unsigned int> secondaries(0);
280 keepGsf =
resolveGsfTracks(selGsfPFRecTracks,ipfgsf,secondaries,theEcalClusters);
284 if(keepGsf ==
true) {
287 if(
convBremFinder_->foundConvBremPFRecTrack(thePfRecTrackCollection,thePrimaryVertexColl,
288 pfNuclears,pfConversions,pfV0,
291 theEcalClusters,selGsfPFRecTracks[ipfgsf])) {
292 const vector<PFRecTrackRef>& convBremPFRecTracks(
convBremFinder_->getConvBremPFRecTracks());
293 for(
unsigned int ii = 0;
ii<convBremPFRecTracks.size();
ii++) {
294 selGsfPFRecTracks[ipfgsf].addConvBremPFRecTrackRef(convBremPFRecTracks[
ii]);
300 primaryGsfPFRecTracks.push_back(selGsfPFRecTracks[ipfgsf]);
306 unsigned int primGsfIndex = selGsfPFRecTracks[ipfgsf].trackId();
307 vector<reco::GsfPFRecTrack> trueGsfPFRecTracks;
308 if(!secondaries.empty()) {
310 for(
unsigned int isecpfgsf=0; isecpfgsf<secondaries.size();isecpfgsf++) {
312 PFRecTrackRef refsecKF = selGsfPFRecTracks[(secondaries[isecpfgsf])].kfPFRecTrackRef();
314 unsigned int secGsfIndex = selGsfPFRecTracks[(secondaries[isecpfgsf])].trackId();
315 GsfTrackRef secGsfRef = selGsfPFRecTracks[(secondaries[isecpfgsf])].gsfTrackRef();
321 primGsfIndex, secGsfRef,
329 primGsfIndex, secGsfRef,
333 bool validgsfbrem =
false;
336 gsftracks[secGsfIndex],
341 gsftracks[secGsfIndex],
346 gsfPFRecTrackCollectionSecondary->push_back(
secpftrack_);
351 GsfPFMap.insert(pair<
unsigned int,std::vector<reco::GsfPFRecTrack> >(count_primary,trueGsfPFRecTracks));
352 trueGsfPFRecTracks.clear();
360 iEvent.
put(
std::move(gsfPFRecTrackCollectionSecondary),
"Secondary");
366 for(
unsigned int iGSF = 0; iGSF<primaryGsfPFRecTracks.size();iGSF++){
367 gsfPFRecTrackCollection->push_back(primaryGsfPFRecTracks[iGSF]);
371 selGsfPFRecTracks.clear();
373 primaryGsfPFRecTracks.clear();
381 std::vector<reco::GsfPFRecTrack>& gsfPFRecTrackPrimary,
382 const std::map<
unsigned int, std::vector<reco::GsfPFRecTrack> >& MapPrimSec) {
384 unsigned int csecgsf=0;
385 for (
std::map<
unsigned int, std::vector<reco::GsfPFRecTrack> >::const_iterator igsf = MapPrimSec.begin();
386 igsf != MapPrimSec.end(); igsf++,cgsf++) {
387 vector<reco::GsfPFRecTrack> SecGsfPF = igsf->second;
388 for (
unsigned int iSecGsf=0; iSecGsf < SecGsfPF.size(); iSecGsf++) {
390 gsfPFRecTrackPrimary[cgsf].addConvBremGsfPFRecTrackRef(refgprt);
404 if (gsftk.
seedRef().
get()==
nullptr)
return -1;
405 auto const & ElSeedFromRef=
static_cast<ElectronSeed const&
>( *(gsftk.
extra()->seedRef()) );
407 if (ElSeedFromRef.ctfTrack().isNull()){
408 reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
409 reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
412 unsigned int ish_max=0;
416 for(;pft!=pftend;++pft){
419 float dph= fabs(pft->trackRef()->phi()-gsftk.
phi());
421 float det=fabs(pft->trackRef()->eta()-gsftk.
eta());
422 float dr =
sqrt(dph*dph+det*det);
424 for(
auto const& hhit : pft->trackRef()->recHits()) {
425 if (!hhit->isValid())
continue;
428 for(;hit!=hit_end;++hit) {
429 if (!(hit->isValid()))
continue;
438 ((ish==ish_max)&&(dr<dr_min))){
448 if (ibest<0)
return -1;
450 if((ish_max==0) || (dr_min>0.05))
return -1;
451 if(otherColl && (ish_max==0))
return -1;
457 reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
458 reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
461 for(;pft!=pftend;++pft){
463 if (pft->trackRef()==ElSeedFromRef.ctfTrack()){
475 if (gsftk.
seedRef().
get()==
nullptr)
return false;
476 auto const& ElSeedFromRef=
static_cast<ElectronSeed const&
>( *(gsftk.
extra()->seedRef()) );
478 bool passCut =
false;
479 if (ElSeedFromRef.ctfTrack().isNull()){
480 if(ElSeedFromRef.caloCluster().isNull())
return passCut;
481 auto const* scRef =
static_cast<SuperCluster const*
>(ElSeedFromRef.caloCluster().get());
484 float caloEne = scRef->
energy();
485 float feta = fabs(scRef->eta()-gsftk.
etaMode());
486 float fphi = fabs(scRef->phi()-gsftk.
phiMode());
501 vector<unsigned int> &secondaries,
504 bool n_keepGsf =
true;
508 if (nGsfTrack->seedRef().
get()==
nullptr)
return false;
509 auto const& nElSeedFromRef=
static_cast<ElectronSeed const&
>( *(nGsfTrack->extra()->seedRef()) );
522 float neta = nGsfTrack->innerMomentum().eta();
523 float nphi = nGsfTrack->innerMomentum().phi();
529 cout <<
" PFElecTkProducer:: considering track " << nGsfTrack->pt()
530 <<
" eta,phi " << nGsfTrack->eta() <<
", " << nGsfTrack->phi() << endl;
533 for (
unsigned int igsf=0; igsf< GsfPFVec.size();igsf++) {
538 cout <<
" PFElecTkProducer:: and comparing with track " << iGsfTrack->pt()
539 <<
" eta,phi " << iGsfTrack->eta() <<
", " << iGsfTrack->phi() << endl;
541 float ieta = iGsfTrack->innerMomentum().eta();
542 float iphi = iGsfTrack->innerMomentum().phi();
543 float feta = fabs(neta - ieta);
544 float fphi = fabs(nphi - iphi);
549 if(feta < 0.5 && fabs(fphi) < 1.0) {
551 cout <<
" Entering angular superloose preselection " << endl;
564 if (iGsfTrack->seedRef().
get()==
nullptr)
continue;
565 auto const& iElSeedFromRef=
static_cast<ElectronSeed const&
>( *(iGsfTrack->extra()->seedRef()) );
567 float SCEnergy = -1.;
569 bool areBothGsfEcalDriven =
false;;
570 bool isSameSC =
isSameEgSC(nElSeedFromRef,iElSeedFromRef,areBothGsfEcalDriven,SCEnergy);
573 if(areBothGsfEcalDriven ) {
575 float nEP = SCEnergy/nPin;
576 float iEP = SCEnergy/iPin;
578 cout <<
" Entering SAME supercluster case " 580 <<
" iEP " << iEP << endl;
588 bool isSameLayer =
false;
589 bool iGsfInnermostWithLostHits =
594 cout <<
" iGsf is InnerMostWithLostHits " << iGsfInnermostWithLostHits
595 <<
" isSameLayer " << isSameLayer << endl;
597 if (iGsfInnermostWithLostHits) {
601 else if(isSameLayer){
602 if(fabs(iEP-1) < fabs(nEP-1)) {
607 secondaries.push_back(igsf);
612 secondaries.push_back(igsf);
618 float minBremDphi =
minTangDist(GsfPFVec[ngsf],GsfPFVec[igsf]);
621 bool isBothGsfTrackerDriven =
false;
622 bool nEcalDriven =
false;
623 bool iEcalDriven =
false;
629 isBothGsfTrackerDriven,
636 bool isSameLayer =
false;
637 bool iGsfInnermostWithLostHits =
644 cout <<
" Sharing ECAL energy passed " 645 <<
" nEtot " << nETot
646 <<
" iEtot " << iETot << endl;
647 if(isBothGsfTrackerDriven)
648 cout <<
" Both Track are trackerDriven " << endl;
652 if (iGsfInnermostWithLostHits) {
656 else if(isSameLayer){
665 if(isBothGsfTrackerDriven ==
false) {
672 secondaries.push_back(igsf);
689 float nEP = ETot/nPin;
690 float iEP = ETot/iPin;
694 cout <<
" nETot " << nETot
695 <<
" iETot " << iETot
696 <<
" ETot " << ETot << endl
700 <<
" iEP " << iEP << endl;
703 if(fabs(iEP-1) < fabs(nEP-1)) {
708 secondaries.push_back(igsf);
713 secondaries.push_back(igsf);
718 bool secPushedBack =
false;
719 if(nEcalDriven ==
false && nETot == 0.) {
723 else if(iEcalDriven ==
false && iETot == 0.) {
724 secondaries.push_back(igsf);
725 secPushedBack =
true;
728 cout <<
" Close Tracks " 729 <<
" feta " << feta <<
" fabs(fphi) " << fabs(fphi)
730 <<
" minBremDphi " << minBremDphi
731 <<
" nETot " << nETot
732 <<
" iETot " << iETot
733 <<
" nLostHits " << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS)
734 <<
" iLostHits " << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
738 if (iGsfInnermostWithLostHits) {
742 else if(isSameLayer ==
false) {
743 if(secPushedBack ==
false)
744 secondaries.push_back(igsf);
748 else if(feta < 0.1 && minBremDphi < 0.2){
752 cout <<
" Close Tracks and failed all the conditions " 753 <<
" feta " << feta <<
" fabs(fphi) " << fabs(fphi)
754 <<
" minBremDphi " << minBremDphi
755 <<
" nETot " << nETot
756 <<
" iETot " << iETot
757 <<
" nLostHits " << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS)
758 <<
" iLostHits " << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
760 if(nEcalDriven ==
false && nETot == 0.) {
777 float minDphi = 1000.;
780 std::vector<reco::PFBrem> primPFBrem = primGsf.
PFRecBrem();
781 std::vector<reco::PFBrem> secPFBrem = secGsf.
PFRecBrem();
784 unsigned int cbrem = 0;
785 for (
unsigned isbrem = 0; isbrem < secPFBrem.size(); isbrem++) {
786 if(secPFBrem[isbrem].indTrajPoint() == 99)
continue;
789 if( ! atSecECAL.
isValid() )
continue;
792 unsigned int sbrem = 0;
793 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
794 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
797 if( ! atPrimECAL.
isValid() )
continue;
802 float dphi = fabs(primPhi - secPhi);
804 if(fabs(dphi) < minDphi) {
805 minDphi = fabs(dphi);
820 bool& bothGsfEcalDriven,
823 bool isSameSC =
false;
829 if(nscRef && iscRef) {
830 bothGsfEcalDriven =
true;
831 if(nscRef == iscRef) {
834 SCEnergy = nscRef->
energy();
846 bool& bothGsfTrackerDriven,
852 bool isSharingEnergy =
false;
855 bool oneEcalDriven =
true;
862 nEnergy = scRef->
energy();
864 gsfPfTrack = iGsfPFRecTrack;
869 iEnergy = scRef->
energy();
871 gsfPfTrack = nGsfPFRecTrack;
874 oneEcalDriven =
false;
880 vector<PFCluster> vecPFClusters;
881 vecPFClusters.clear();
883 for (PFClusterCollection::const_iterator clus = theEClus.begin();
884 clus != theEClus.end();
895 if(deta < 0.5 && fabs(dphi) < 1.0) {
901 iEnergy += clust.
energy();
903 nEnergy += clust.
energy();
904 vecPFClusters.push_back(clust);
908 vector<PFBrem> primPFBrem = gsfPfTrack.
PFRecBrem();
909 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
910 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
916 iEnergy += clust.
energy();
918 nEnergy += clust.
energy();
919 vecPFClusters.push_back(clust);
925 if(!vecPFClusters.empty() ) {
926 for(
unsigned int pf = 0;
pf < vecPFClusters.size();
pf++) {
929 isSharingEnergy =
true;
938 bothGsfTrackerDriven =
true;
939 vector<PFCluster> nPFCluster;
940 vector<PFCluster> iPFCluster;
945 for (PFClusterCollection::const_iterator clus = theEClus.begin();
946 clus != theEClus.end();
956 if(ndeta < 0.5 && fabs(ndphi) < 1.0) {
961 nPFCluster.push_back(clust);
962 nEnergy += clust.
energy();
965 const vector<PFBrem>& primPFBrem = nGsfPFRecTrack.
PFRecBrem();
966 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
967 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
972 nPFCluster.push_back(clust);
973 nEnergy += clust.
energy();
985 if(ideta < 0.5 && fabs(idphi) < 1.0) {
989 iPFCluster.push_back(clust);
990 iEnergy += clust.
energy();
993 vector<PFBrem> primPFBrem = iGsfPFRecTrack.
PFRecBrem();
994 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
995 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
999 iPFCluster.push_back(clust);
1000 iEnergy += clust.
energy();
1009 if(!nPFCluster.empty() && !iPFCluster.empty()) {
1010 for(
unsigned int npf = 0; npf < nPFCluster.size(); npf++) {
1011 for(
unsigned int ipf = 0; ipf < iPFCluster.size(); ipf++) {
1014 isSharingEnergy =
true;
1024 return isSharingEnergy;
1037 int gsfHitCounter1 = 0 ;
1038 for(
auto const&
hit : nGsfTrack->recHits()) {
1039 if (
hit->isValid())
break ;
1043 int gsfHitCounter2 = 0 ;
1044 for(
auto const&
hit : iGsfTrack->recHits()) {
1045 if (
hit->isValid())
break ;
1049 uint32_t gsfHit1 = gsfHitPattern1.
getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1) ;
1050 uint32_t gsfHit2 = gsfHitPattern2.
getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter2) ;
1057 else if (gsfHitPattern1.
getLayer(gsfHit1)!=gsfHitPattern2.
getLayer(gsfHit2))
1059 return (gsfHitPattern2.
getLayer(gsfHit2)<gsfHitPattern1.
getLayer(gsfHit1));
1072 unsigned int nLostHits = nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1073 unsigned int iLostHits = iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1075 if (nLostHits!=iLostHits) {
1076 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)