47 (
"GsfTrackModuleLabel"));
53 (
"PrimaryVertexLabel"));
72 produces<GsfPFRecTrackCollection>();
73 produces<GsfPFRecTrackCollection>(
"Secondary" ).setBranchAlias(
"secondary" );
116 auto_ptr< GsfPFRecTrackCollection >
120 auto_ptr< GsfPFRecTrackCollection >
163 vector<Trajectory> tjvec(0);
167 tjvec= *(TrajectoryCollection.
product());
171 vector<reco::GsfPFRecTrack> selGsfPFRecTracks;
172 vector<reco::GsfPFRecTrack> primaryGsfPFRecTracks;
173 std::map<unsigned int, std::vector<reco::GsfPFRecTrack> > GsfPFMap;
176 for (
unsigned int igsf=0; igsf<gsftracks.size();igsf++) {
180 int kf_ind=
FindPfRef(PfRTkColl,gsftracks[igsf],
false);
192 bool isEcalDriven =
true;
193 bool isTrackerDriven =
true;
195 if (&(*trackRef->seedRef())==0) {
196 isEcalDriven =
false;
197 isTrackerDriven =
false;
200 auto const& SeedFromRef=
dynamic_cast<ElectronSeed const&
>(*(trackRef->extra()->seedRef()) );
201 if(SeedFromRef.caloCluster().isNull())
202 isEcalDriven =
false;
203 if(SeedFromRef.ctfTrack().isNull())
204 isTrackerDriven =
false;
207 if(isFifthStepTrack &&
209 isTrackerDriven ==
false &&
214 if(isFifthStepTrack &&
216 isEcalDriven ==
false &&
221 if(isFifthStepTrack &&
243 bool validgsfbrem =
false;
259 if(validgsfbrem && passSel)
260 selGsfPFRecTracks.push_back(
pftrack_);
264 unsigned int count_primary = 0;
265 if(selGsfPFRecTracks.size() > 0) {
266 for(
unsigned int ipfgsf=0; ipfgsf<selGsfPFRecTracks.size();ipfgsf++) {
268 vector<unsigned int> secondaries(0);
273 keepGsf =
resolveGsfTracks(selGsfPFRecTracks,ipfgsf,secondaries,theEcalClusters);
277 if(keepGsf ==
true) {
280 if(
convBremFinder_->foundConvBremPFRecTrack(thePfRecTrackCollection,thePrimaryVertexColl,
281 pfNuclears,pfConversions,pfV0,
284 theEcalClusters,selGsfPFRecTracks[ipfgsf])) {
285 const vector<PFRecTrackRef>& convBremPFRecTracks(
convBremFinder_->getConvBremPFRecTracks());
286 for(
unsigned int ii = 0;
ii<convBremPFRecTracks.size();
ii++) {
287 selGsfPFRecTracks[ipfgsf].addConvBremPFRecTrackRef(convBremPFRecTracks[
ii]);
293 primaryGsfPFRecTracks.push_back(selGsfPFRecTracks[ipfgsf]);
299 unsigned int primGsfIndex = selGsfPFRecTracks[ipfgsf].trackId();
300 vector<reco::GsfPFRecTrack> trueGsfPFRecTracks;
301 if(secondaries.size() > 0) {
303 for(
unsigned int isecpfgsf=0; isecpfgsf<secondaries.size();isecpfgsf++) {
305 PFRecTrackRef refsecKF = selGsfPFRecTracks[(secondaries[isecpfgsf])].kfPFRecTrackRef();
307 unsigned int secGsfIndex = selGsfPFRecTracks[(secondaries[isecpfgsf])].trackId();
308 GsfTrackRef secGsfRef = selGsfPFRecTracks[(secondaries[isecpfgsf])].gsfTrackRef();
314 primGsfIndex, secGsfRef,
322 primGsfIndex, secGsfRef,
326 bool validgsfbrem =
false;
329 gsftracks[secGsfIndex],
334 gsftracks[secGsfIndex],
339 gsfPFRecTrackCollectionSecondary->push_back(
secpftrack_);
344 GsfPFMap.insert(pair<
unsigned int,std::vector<reco::GsfPFRecTrack> >(count_primary,trueGsfPFRecTracks));
345 trueGsfPFRecTracks.clear();
353 iEvent.
put(gsfPFRecTrackCollectionSecondary,
"Secondary");
359 for(
unsigned int iGSF = 0; iGSF<primaryGsfPFRecTracks.size();iGSF++){
360 gsfPFRecTrackCollection->push_back(primaryGsfPFRecTracks[iGSF]);
362 iEvent.
put(gsfPFRecTrackCollection);
364 selGsfPFRecTracks.clear();
366 primaryGsfPFRecTracks.clear();
372 std::vector<reco::GsfPFRecTrack>& gsfPFRecTrackPrimary,
373 const std::map<
unsigned int, std::vector<reco::GsfPFRecTrack> >& MapPrimSec) {
375 unsigned int csecgsf=0;
376 for (std::map<
unsigned int, std::vector<reco::GsfPFRecTrack> >::const_iterator igsf = MapPrimSec.begin();
377 igsf != MapPrimSec.end(); igsf++,cgsf++) {
378 vector<reco::GsfPFRecTrack> SecGsfPF = igsf->second;
379 for (
unsigned int iSecGsf=0; iSecGsf < SecGsfPF.size(); iSecGsf++) {
381 gsfPFRecTrackPrimary[cgsf].addConvBremGsfPFRecTrackRef(refgprt);
395 if (&(*gsftk.
seedRef())==0)
return -1;
398 if (ElSeedFromRef.ctfTrack().isNull()){
399 reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
400 reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
403 unsigned int ish_max=0;
407 for(;pft!=pftend;++pft){
410 float dph= fabs(pft->trackRef()->phi()-gsftk.
phi());
412 float det=fabs(pft->trackRef()->eta()-gsftk.
eta());
413 float dr =
sqrt(dph*dph+det*det);
416 pft->trackRef()->recHitsBegin();
418 pft->trackRef()->recHitsEnd();
422 for(;hhit!=hhit_end;++hhit){
423 if (!(*hhit)->isValid())
continue;
428 for(;hit!=hit_end;++hit){
429 if (!(hit->isValid()))
continue;
439 ((ish==ish_max)&&(dr<dr_min))){
449 if (ibest<0)
return -1;
451 if((ish_max==0) || (dr_min>0.05))
return -1;
452 if(otherColl && (ish_max==0))
return -1;
458 reco::PFRecTrackCollection::const_iterator pft=PfRTkColl.begin();
459 reco::PFRecTrackCollection::const_iterator pftend=PfRTkColl.end();
462 for(;pft!=pftend;++pft){
464 if (pft->trackRef()==ElSeedFromRef.ctfTrack()){
476 if (&(*gsftk.
seedRef())==0)
return false;
479 bool passCut =
false;
480 if (ElSeedFromRef.ctfTrack().isNull()){
481 if(ElSeedFromRef.caloCluster().isNull())
return passCut;
482 auto const* scRef =
dynamic_cast<SuperCluster const*
>(ElSeedFromRef.caloCluster().get());
485 float caloEne = scRef->energy();
486 float feta = fabs(scRef->eta()-gsftk.
etaMode());
487 float fphi = fabs(scRef->phi()-gsftk.
phiMode());
502 vector<unsigned int> &secondaries,
505 bool n_keepGsf =
true;
509 if (&(*nGsfTrack->seedRef())==0)
return false;
510 auto const& nElSeedFromRef=
dynamic_cast<ElectronSeed const&
>( *(nGsfTrack->extra()->seedRef()) );
515 float nPin = nGsfTrack->pMode();
518 nPin = ninnMom.
mag();
521 float neta = nGsfTrack->innerMomentum().eta();
522 float nphi = nGsfTrack->innerMomentum().phi();
528 cout <<
" PFElecTkProducer:: considering track " << nGsfTrack->pt()
529 <<
" eta,phi " << nGsfTrack->eta() <<
", " << nGsfTrack->phi() << endl;
532 for (
unsigned int igsf=0; igsf< GsfPFVec.size();igsf++) {
537 cout <<
" PFElecTkProducer:: and comparing with track " << iGsfTrack->pt()
538 <<
" eta,phi " << iGsfTrack->eta() <<
", " << iGsfTrack->phi() << endl;
540 float ieta = iGsfTrack->innerMomentum().eta();
541 float iphi = iGsfTrack->innerMomentum().phi();
542 float feta = fabs(neta - ieta);
543 float fphi = fabs(nphi - iphi);
548 if(feta < 0.5 && fabs(fphi) < 1.0) {
550 cout <<
" Entering angular superloose preselection " << endl;
554 float iPin = iGsfTrack->pMode();
557 iPin = i_innMom.
mag();
560 if (&(*iGsfTrack->seedRef())==0)
continue;
561 auto const& iElSeedFromRef=
dynamic_cast<ElectronSeed const&
>( *(iGsfTrack->extra()->seedRef()) );
563 float SCEnergy = -1.;
565 bool areBothGsfEcalDriven =
false;;
566 bool isSameSC =
isSameEgSC(nElSeedFromRef,iElSeedFromRef,areBothGsfEcalDriven,SCEnergy);
569 if(areBothGsfEcalDriven ) {
571 float nEP = SCEnergy/nPin;
572 float iEP = SCEnergy/iPin;
574 cout <<
" Entering SAME supercluster case "
576 <<
" iEP " << iEP << endl;
584 bool isSameLayer =
false;
585 bool iGsfInnermostWithLostHits =
590 cout <<
" iGsf is InnerMostWithLostHits " << iGsfInnermostWithLostHits
591 <<
" isSameLayer " << isSameLayer << endl;
593 if (iGsfInnermostWithLostHits) {
597 else if(isSameLayer){
598 if(fabs(iEP-1) < fabs(nEP-1)) {
603 secondaries.push_back(igsf);
608 secondaries.push_back(igsf);
614 float minBremDphi =
minTangDist(GsfPFVec[ngsf],GsfPFVec[igsf]);
617 bool isBothGsfTrackerDriven =
false;
618 bool nEcalDriven =
false;
619 bool iEcalDriven =
false;
625 isBothGsfTrackerDriven,
632 bool isSameLayer =
false;
633 bool iGsfInnermostWithLostHits =
640 cout <<
" Sharing ECAL energy passed "
641 <<
" nEtot " << nETot
642 <<
" iEtot " << iETot << endl;
643 if(isBothGsfTrackerDriven)
644 cout <<
" Both Track are trackerDriven " << endl;
648 if (iGsfInnermostWithLostHits) {
652 else if(isSameLayer){
661 if(isBothGsfTrackerDriven ==
false) {
668 secondaries.push_back(igsf);
685 float nEP = ETot/nPin;
686 float iEP = ETot/iPin;
690 cout <<
" nETot " << nETot
691 <<
" iETot " << iETot
692 <<
" ETot " << ETot << endl
696 <<
" iEP " << iEP << endl;
699 if(fabs(iEP-1) < fabs(nEP-1)) {
704 secondaries.push_back(igsf);
709 secondaries.push_back(igsf);
714 bool secPushedBack =
false;
715 if(nEcalDriven ==
false && nETot == 0.) {
719 else if(iEcalDriven ==
false && iETot == 0.) {
720 secondaries.push_back(igsf);
721 secPushedBack =
true;
724 cout <<
" Close Tracks "
725 <<
" feta " << feta <<
" fabs(fphi) " << fabs(fphi)
726 <<
" minBremDphi " << minBremDphi
727 <<
" nETot " << nETot
728 <<
" iETot " << iETot
729 <<
" nLostHits " << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS)
730 <<
" iLostHits " << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
734 if (iGsfInnermostWithLostHits) {
738 else if(isSameLayer ==
false) {
739 if(secPushedBack ==
false)
740 secondaries.push_back(igsf);
744 else if(feta < 0.1 && minBremDphi < 0.2){
748 cout <<
" Close Tracks and failed all the conditions "
749 <<
" feta " << feta <<
" fabs(fphi) " << fabs(fphi)
750 <<
" minBremDphi " << minBremDphi
751 <<
" nETot " << nETot
752 <<
" iETot " << iETot
753 <<
" nLostHits " << nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS)
754 <<
" iLostHits " << iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS) << endl;
756 if(nEcalDriven ==
false && nETot == 0.) {
776 std::vector<reco::PFBrem> primPFBrem = primGsf.
PFRecBrem();
777 std::vector<reco::PFBrem> secPFBrem = secGsf.
PFRecBrem();
780 unsigned int cbrem = 0;
781 for (
unsigned isbrem = 0; isbrem < secPFBrem.size(); isbrem++) {
782 if(secPFBrem[isbrem].indTrajPoint() == 99)
continue;
785 if( ! atSecECAL.
isValid() )
continue;
788 unsigned int sbrem = 0;
789 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
790 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
793 if( ! atPrimECAL.
isValid() )
continue;
798 float dphi = fabs(primPhi - secPhi);
800 if(fabs(dphi) < minDphi) {
801 minDphi = fabs(dphi);
816 bool& bothGsfEcalDriven,
819 bool isSameSC =
false;
825 if(nscRef && iscRef) {
826 bothGsfEcalDriven =
true;
827 if(nscRef == iscRef) {
830 SCEnergy = nscRef->energy();
842 bool& bothGsfTrackerDriven,
848 bool isSharingEnergy =
false;
851 bool oneEcalDriven =
true;
858 nEnergy = scRef->
energy();
860 gsfPfTrack = iGsfPFRecTrack;
865 iEnergy = scRef->
energy();
867 gsfPfTrack = nGsfPFRecTrack;
870 oneEcalDriven =
false;
876 vector<PFCluster> vecPFClusters;
877 vecPFClusters.clear();
879 for (PFClusterCollection::const_iterator clus = theEClus.begin();
880 clus != theEClus.end();
891 if(deta < 0.5 && fabs(dphi) < 1.0) {
892 bool foundLink =
false;
898 iEnergy += clust.
energy();
900 nEnergy += clust.
energy();
901 vecPFClusters.push_back(clust);
905 if(foundLink ==
false) {
906 vector<PFBrem> primPFBrem = gsfPfTrack.
PFRecBrem();
907 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
908 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
914 iEnergy += clust.
energy();
916 nEnergy += clust.
energy();
917 vecPFClusters.push_back(clust);
924 if(vecPFClusters.size() > 0 ) {
925 for(
unsigned int pf = 0; pf < vecPFClusters.size(); pf++) {
928 isSharingEnergy =
true;
937 bothGsfTrackerDriven =
true;
938 vector<PFCluster> nPFCluster;
939 vector<PFCluster> iPFCluster;
944 for (PFClusterCollection::const_iterator clus = theEClus.begin();
945 clus != theEClus.end();
955 if(ndeta < 0.5 && fabs(ndphi) < 1.0) {
956 bool foundNLink =
false;
961 nPFCluster.push_back(clust);
962 nEnergy += clust.
energy();
965 if(foundNLink ==
false) {
966 const vector<PFBrem>& primPFBrem = nGsfPFRecTrack.
PFRecBrem();
967 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
968 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
970 if(foundNLink ==
false) {
974 nPFCluster.push_back(clust);
975 nEnergy += clust.
energy();
988 if(ideta < 0.5 && fabs(idphi) < 1.0) {
989 bool foundILink =
false;
993 iPFCluster.push_back(clust);
994 iEnergy += clust.
energy();
997 if(foundILink ==
false) {
998 vector<PFBrem> primPFBrem = iGsfPFRecTrack.
PFRecBrem();
999 for(
unsigned ipbrem = 0; ipbrem < primPFBrem.size(); ipbrem++) {
1000 if(primPFBrem[ipbrem].indTrajPoint() == 99)
continue;
1002 if(foundILink ==
false) {
1005 iPFCluster.push_back(clust);
1006 iEnergy += clust.
energy();
1016 if(nPFCluster.size() > 0 && iPFCluster.size() > 0) {
1017 for(
unsigned int npf = 0; npf < nPFCluster.size(); npf++) {
1018 for(
unsigned int ipf = 0; ipf < iPFCluster.size(); ipf++) {
1021 isSharingEnergy =
true;
1031 return isSharingEnergy;
1044 int gsfHitCounter1 = 0 ;
1047 ( elHitsIt1 = nGsfTrack->recHitsBegin() ;
1048 elHitsIt1 != nGsfTrack->recHitsEnd() ;
1049 elHitsIt1++, gsfHitCounter1++ )
1050 {
if (((**elHitsIt1).isValid())) break ; }
1052 int gsfHitCounter2 = 0 ;
1055 ( elHitsIt2 = iGsfTrack->recHitsBegin() ;
1056 elHitsIt2 != iGsfTrack->recHitsEnd() ;
1057 elHitsIt2++, gsfHitCounter2++ )
1058 {
if (((**elHitsIt2).isValid())) break ; }
1060 uint32_t gsfHit1 = gsfHitPattern1.
getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter1) ;
1061 uint32_t gsfHit2 = gsfHitPattern2.
getHitPattern(HitPattern::TRACK_HITS, gsfHitCounter2) ;
1068 else if (gsfHitPattern1.
getLayer(gsfHit1)!=gsfHitPattern2.
getLayer(gsfHit2))
1070 return (gsfHitPattern2.
getLayer(gsfHit2)<gsfHitPattern1.
getLayer(gsfHit1));
1083 unsigned int nLostHits = nGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1084 unsigned int iLostHits = iGsfTrack->hitPattern().numberOfLostHits(HitPattern::MISSING_INNER_HITS);
1086 if (nLostHits!=iLostHits) {
1087 return (nLostHits > iLostHits);
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
bool trajinev_
Trajectory of GSfTracks in the event?
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)
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
double phi() const
azimuthal angle of momentum vector
bool applySelection(const reco::GsfTrack &)
bool isNonnull() const
Checks for non-null.
~PFElecTkProducer()
Destructor.
bool momentumFromModeCartesian(const TrajectoryStateOnSurface tsos, GlobalVector &momentum) const
reco::GsfPFRecTrack secpftrack_
std::unique_ptr< ConvBremPFTrackFinder > convBremFinder_
edm::EDGetTokenT< reco::VertexCollection > primVtxLabel_
const MultiTrajectoryStateMode * mtsMode_
double mvaConvBremFinderIDBarrelLowPt_
CaloClusterRef caloCluster() const
double eta() const
pseudorapidity of momentum vector
std::vector< GsfPFRecTrack > GsfPFRecTrackCollection
collection of GsfPFRecTrack objects
void calculatePositionREP()
computes posrep_ once and for all
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
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
bool isSameEgSC(const reco::ElectronSeed &nSeed, const reco::ElectronSeed &iSeed, bool &bothGsfEcalDriven, float &SCEnergy)
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.
virtual void endRun(const edm::Run &, const edm::EventSetup &) override
int FindPfRef(const reco::PFRecTrackCollection &PfRTkColl, const reco::GsfTrack &, bool)
edm::RefToBase< TrajectorySeed > seedRef() const
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
T const * product() const
double mvaConvBremFinderIDBarrelHighPt_
double mvaConvBremFinderIDEndcapsHighPt_
edm::EDGetTokenT< reco::PFConversionCollection > pfConv_
std::vector< Trajectory > TrajectoryCollection
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
double etaMode() const
pseudorapidity of momentum vector from mode
bool useFifthStepForEcalDriven_
reco::GsfPFRecTrack pftrack_
virtual 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.
uint16_t getHitPattern(HitCategory category, int position) 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_
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
MultiTrajectoryStateTransform mtsTransform_
bool isInnerMost(const reco::GsfTrackRef &nGsfTrack, const reco::GsfTrackRef &iGsfTrack, bool &sameLayer)