Skip to content

Commit

Permalink
Merge pull request #26190 from guitargeek/PFProducer_cleanup
Browse files Browse the repository at this point in the history
Some RecoParticleFlow/PFProducer cleanup
  • Loading branch information
cmsbuild committed Mar 26, 2019
2 parents 662b7fa + 2529ef9 commit a99c7c9
Show file tree
Hide file tree
Showing 35 changed files with 91 additions and 504 deletions.
4 changes: 2 additions & 2 deletions EgammaAnalysis/ElectronTools/test/ElectronTestAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
#include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "RecoParticleFlow/PFProducer/interface/Utils.h"
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
Expand All @@ -47,6 +46,7 @@
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "TrackingTools/IPTools/interface/IPTools.h"
#include "FWCore/Utilities/interface/isFinite.h"
#include "DataFormats/Math/interface/normalizedPhi.h"

#include <cmath>
#include <vector>
Expand Down Expand Up @@ -357,7 +357,7 @@ ElectronTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& i
float etareco = theEGamma[j].eta();
float phireco = theEGamma[j].phi();
float deta = etamc - etareco;
float dphi = Utils::mpi_pi(phimc - phireco);
float dphi = normalizedPhi(phimc - phireco);
float dR = sqrt(deta*deta + dphi*dphi);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "DataFormats/Math/interface/Point3D.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "RecoParticleFlow/PFProducer/interface/Utils.h"
#include "DataFormats/JetReco/interface/PFJetCollection.h"
#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
Expand Down
1 change: 0 additions & 1 deletion RecoBTag/SoftLepton/plugins/SoftPFMuonTagInfoProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "DataFormats/Math/interface/Point3D.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "RecoParticleFlow/PFProducer/interface/Utils.h"
#include "DataFormats/JetReco/interface/PFJetCollection.h"
#include "DataFormats/JetReco/interface/Jet.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
Expand Down
32 changes: 8 additions & 24 deletions RecoEgamma/EgammaElectronAlgos/interface/ElectronUtilities.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
#ifndef RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H
#define RecoEgamma_EgammaElectronAlgos_ElectronUtilities_H

#include <DataFormats/GeometryVector/interface/GlobalPoint.h>
#include <DataFormats/GeometryVector/interface/GlobalVector.h>
#include <DataFormats/Math/interface/Point3D.h>
#include <DataFormats/Math/interface/Vector3D.h>
#include <CLHEP/Units/GlobalPhysicalConstants.h>


//===============================================================
// Normalization of angles
//===============================================================

template <typename RealType>
RealType normalized_phi( RealType phi )
{
constexpr RealType pi(M_PI);
constexpr RealType pi2(2*M_PI);
if (phi>pi) { phi -= pi2 ; }
if (phi<-pi) { phi += pi2; }
return phi ;
}
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/Math/interface/normalizedPhi.h"


//===============================================================
Expand All @@ -46,7 +31,7 @@ class EleRelPoint
EleRelPoint( const math::XYZPoint & p, const GlobalPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {}
EleRelPoint( const GlobalPoint & p, const GlobalPoint & origin ) : relP_(p.x()-origin.x(),p.y()-origin.y(),p.z()-origin.z()) {}
double eta() { return relP_.eta() ; }
double phi() { return normalized_phi(relP_.phi()) ; }
double phi() { return normalizedPhi(relP_.phi()) ; }
double perp() { return std::sqrt(relP_.x()*relP_.x()+relP_.y()*relP_.y()) ; }
private :
math::XYZVector relP_ ;
Expand All @@ -64,7 +49,7 @@ class EleRelPointPair
EleRelPointPair( const GlobalPoint & p1, const math::XYZPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
EleRelPointPair( const GlobalPoint & p1, const GlobalPoint & p2, const GlobalPoint & origin ) : relP1_(p1.x()-origin.x(),p1.y()-origin.y(),p1.z()-origin.z()), relP2_(p2.x()-origin.x(),p2.y()-origin.y(),p2.z()-origin.z()) {}
auto dEta() { return (relP1_.eta()-relP2_.eta()) ; }
auto dPhi() { return normalized_phi(relP1_.barePhi()-relP2_.barePhi()) ; }
auto dPhi() { return normalizedPhi(relP1_.barePhi()-relP2_.barePhi()) ; }
auto dZ() { return (relP1_.z()-relP2_.z()) ; }
auto dPerp() { return (relP1_.perp()-relP2_.perp()) ; }
private :
Expand All @@ -86,8 +71,7 @@ double relative_eta( const PointType & p, const PointType & origin )

template <typename PointType>
double relative_phi( const PointType & p, const PointType & origin )
{ return normalized_phi((p-origin).phi()) ; }
{ return normalizedPhi((p-origin).phi()) ; }


#endif

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
#include "TrackingTools/DetLayers/interface/rangesIntersect.h"
#include "DataFormats/GeometryVector/interface/VectorUtil.h"
#include "DataFormats/Math/interface/normalizedPhi.h"


// zero value indicates incompatible ts - hit pair
Expand Down Expand Up @@ -53,9 +54,7 @@ std::pair<bool,double> BarrelMeasurementEstimator::estimate( const TrajectorySta

float rhPhi = gp.phi();

float phiDiff = tsPhi - rhPhi;
if (phiDiff > pi) phiDiff -= twopi;
if (phiDiff < -pi) phiDiff += twopi;
float phiDiff = normalizedPhi(tsPhi - rhPhi);

if ( phiDiff < thePhiMax && phiDiff > thePhiMin ) {

Expand Down Expand Up @@ -91,7 +90,7 @@ std::pair<bool,double> BarrelMeasurementEstimator::estimate

float rhPhi = gp.barePhi() ;
float tsPhi = ts.barePhi();
float phiDiff = normalized_phi(rhPhi-tsPhi) ;
float phiDiff = normalizedPhi(rhPhi-tsPhi) ;

if ( (phiDiff < thePhiMax) & (phiDiff > thePhiMin) )
{ return std::pair<bool,double>(true,1.) ; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "TrackingTools/DetLayers/interface/rangesIntersect.h"
#include "DataFormats/GeometryVector/interface/VectorUtil.h"
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
#include "DataFormats/Math/interface/normalizedPhi.h"

// zero value indicates incompatible ts - hit pair
std::pair<bool,double> ForwardMeasurementEstimator::estimate( const TrajectoryStateOnSurface& ts,
Expand Down Expand Up @@ -50,9 +51,7 @@ std::pair<bool,double> ForwardMeasurementEstimator::estimate( const TrajectorySt
float myPhimin = thePhiMin;
float myPhimax = thePhiMax;

float phiDiff = tsPhi - rhPhi;
if (phiDiff > pi) phiDiff -= twopi;
if (phiDiff < -pi) phiDiff += twopi;
float phiDiff = normalizedPhi(tsPhi - rhPhi);

if ( (phiDiff < myPhimax) & (phiDiff > myPhimin) ) {
return std::pair<bool,double>(true,1.);
Expand Down Expand Up @@ -88,7 +87,7 @@ std::pair<bool,double> ForwardMeasurementEstimator::estimate
float myPhimin = thePhiMin;
float myPhimax = thePhiMax;

float phiDiff = normalized_phi(rhPhi - tsPhi) ;
float phiDiff = normalizedPhi(rhPhi - tsPhi) ;

if ( phiDiff < myPhimax && phiDiff > myPhimin )
{ return std::pair<bool,double>(true,1.) ; }
Expand Down
2 changes: 1 addition & 1 deletion RecoEgamma/EgammaElectronAlgos/src/GsfElectronAlgo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void GsfElectronAlgo::ElectronData::computeCharge
GlobalVector scvect(scpos-orig) ;
GlobalPoint inntkpos = innTSOS.globalPosition() ;
GlobalVector inntkvect = GlobalVector(inntkpos-orig) ;
float dPhiInnEle=normalized_phi(scvect.barePhi()-inntkvect.barePhi()) ;
float dPhiInnEle=normalizedPhi(scvect.barePhi()-inntkvect.barePhi()) ;
if(dPhiInnEle>0) info.scPixCharge = -1 ;
else info.scPixCharge = 1 ;

Expand Down
10 changes: 5 additions & 5 deletions RecoEgamma/EgammaElectronAlgos/src/PixelHitMatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ PixelHitMatcher::compatibleHits
LogDebug("") <<"[PixelHitMatcher::compatibleHits] nbr of hits compatible with extrapolation to first layer: " << pixelMeasurements.size();
for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++){
if (m->recHit()->isValid()) {
float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ;
float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ;
if(std::abs(localDphi)>2.5)continue;
CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
m->forwardPredictedState().globalPosition().y(),
Expand Down Expand Up @@ -309,7 +309,7 @@ PixelHitMatcher::compatibleHits

for (aMeas m=pixel2Measurements.begin(); m!=pixel2Measurements.end(); m++){
if (m->recHit()->isValid()) {
float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ;
float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ;
if(std::abs(localDphi)>2.5)continue;
CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
m->forwardPredictedState().globalPosition().y(),
Expand Down Expand Up @@ -350,7 +350,7 @@ PixelHitMatcher::compatibleHits

for (aMeas m=pixelMeasurements.begin(); m!=pixelMeasurements.end(); m++){
if (m->recHit()->isValid()) {
float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi());
float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi());
if(std::abs(localDphi)>2.5)continue;
CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
m->forwardPredictedState().globalPosition().y(),
Expand All @@ -371,7 +371,7 @@ PixelHitMatcher::compatibleHits

for (aMeas m=pixel2Measurements.begin(); m!=pixel2Measurements.end(); m++){
if (m->recHit()->isValid()) {
float localDphi = normalized_phi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ;
float localDphi = normalizedPhi(SCl_phi-m->forwardPredictedState().globalPosition().barePhi()) ;
if(std::abs(localDphi)>2.5)continue;
CLHEP::Hep3Vector prediction(m->forwardPredictedState().globalPosition().x(),
m->forwardPredictedState().globalPosition().y(),
Expand Down Expand Up @@ -436,7 +436,7 @@ PixelHitMatcher::compatibleHits
if(!secondHit.measurementsInNextLayers().empty()){
for(unsigned int shit=0; shit<secondHit.measurementsInNextLayers().size(); shit++)
{
float dphi = normalized_phi(pred1Meas[i].phi()-validMeasurements[i].recHit()->globalPosition().barePhi()) ;
float dphi = normalizedPhi(pred1Meas[i].phi()-validMeasurements[i].recHit()->globalPosition().barePhi()) ;
if (std::abs(dphi)<2.5)
{
ConstRecHitPointer pxrh = validMeasurements[i].recHit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtraFwd.h"
#include "RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h"

#include <iostream>
#include <string>
Expand Down Expand Up @@ -76,9 +75,8 @@ void GEDGsfElectronProducer::fillGsfElectronValueMap(edm::Event & event, edm::Va
// First check that the GsfTrack is non null
if( it->gsfTrackRef().isNonnull()) {
// now look for the corresponding GsfElectron
GsfElectronEqual myEqual(it->gsfTrackRef());
const reco::GsfElectronCollection::const_iterator itcheck=
std::find_if(orphanHandle()->begin(),orphanHandle()->end(),myEqual);
const auto itcheck = std::find_if( orphanHandle()->begin(),orphanHandle()->end(),
[it](const auto& ele) {return (ele.gsfTrack() == it->gsfTrackRef());} );
if (itcheck != orphanHandle()->end()) {
// Build the Ref from the handle and the index
myRef = reco::GsfElectronRef(orphanHandle(),itcheck-orphanHandle()->begin());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtra.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateEGammaExtraFwd.h"
#include "RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h"

#include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
#include "FWCore/Utilities/interface/isFinite.h"
Expand Down
1 change: 0 additions & 1 deletion RecoParticleFlow/Configuration/test/BlockAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
#include "RecoParticleFlow/PFProducer/interface/Utils.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
Expand Down
22 changes: 0 additions & 22 deletions RecoParticleFlow/PFProducer/interface/GsfElectronEqual.h

This file was deleted.

26 changes: 12 additions & 14 deletions RecoParticleFlow/PFProducer/interface/KDTreeLinkerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
class KDTreeLinkerBase
{
public:
KDTreeLinkerBase();

virtual ~KDTreeLinkerBase();
virtual ~KDTreeLinkerBase() {}

void setTargetType(const reco::PFBlockElement::Type& tgt) {
_targetType = tgt;
Expand All @@ -31,15 +29,9 @@ class KDTreeLinkerBase

// Get/Set of the maximal size of the cristal (ECAL, HCAL,...) in phi/eta and
// X/Y. By default, thus value are set for the ECAL cristal.
void setCristalPhiEtaMaxSize(float size);
void setCristalXYMaxSize(float size);
float getCristalPhiEtaMaxSize() const;
float getCristalXYMaxSize() const;

// Get/Set phi offset. See bellow in the description of phiOffset_ to understand
// the application.
void setPhiOffset(double phiOffset);
float getPhiOffset() const;

// Debug flag.
void setDebug(bool isDebug);
Expand Down Expand Up @@ -69,23 +61,29 @@ class KDTreeLinkerBase

// This method calls is the good order buildTree(), searchLinks(),
// updatePFBlockEltWithLinks() and clear()
virtual void process();
inline void process()
{
buildTree();
searchLinks();
updatePFBlockEltWithLinks();
clear();
}

protected:
// target and field
reco::PFBlockElement::Type _targetType,_fieldType;
// Cristal maximal size. By default, thus value are set for the ECAL cristal.
float cristalPhiEtaMaxSize_;
float cristalXYMaxSize_;
float cristalPhiEtaMaxSize_ = 0.04;
float cristalXYMaxSize_ = 3.;

// Usually, phi is between -Pi and +Pi. But phi space is circular, that's why an element
// with phi = 3.13 and another with phi = -3.14 are close. To solve this problem, during
// the kdtree building step, we duplicate some elements close enough to +Pi (resp -Pi) by
// substracting (adding) 2Pi. This field define the threshold of this operation.
float phiOffset_;
float phiOffset_ = 0.25;

// Debug boolean. Not used until now.
bool debug_;
bool debug_ = false;
};


Expand Down
22 changes: 0 additions & 22 deletions RecoParticleFlow/PFProducer/interface/PhotonEqual.h

This file was deleted.

35 changes: 0 additions & 35 deletions RecoParticleFlow/PFProducer/interface/Utils.h

This file was deleted.

0 comments on commit a99c7c9

Please sign in to comment.