Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running code-format for reconstruction #27350

Merged
merged 1 commit into from Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 16 additions & 25 deletions RecoEgamma/EgammaTools/interface/AnyMVAEstimatorRun2Base.h
Expand Up @@ -9,40 +9,33 @@
#include "DataFormats/Candidate/interface/Candidate.h"

class AnyMVAEstimatorRun2Base {

public:
public:
// Constructor, destructor
AnyMVAEstimatorRun2Base(const edm::ParameterSet& conf)
: tag_ (conf.getParameter<std::string>("mvaTag"))
, nCategories_ (conf.getParameter<int>("nCategories"))
, debug_ (conf.getUntrackedParameter<bool>("debug", false))
{}

AnyMVAEstimatorRun2Base(const::std::string& mvaName,
const::std::string& mvaTag,
int nCategories,
bool debug)
: name_ (mvaName)
, tag_ (mvaTag)
, nCategories_ (nCategories)
, debug_ (debug)
{}
: tag_(conf.getParameter<std::string>("mvaTag")),
nCategories_(conf.getParameter<int>("nCategories")),
debug_(conf.getUntrackedParameter<bool>("debug", false)) {}

AnyMVAEstimatorRun2Base(const ::std::string& mvaName, const ::std::string& mvaTag, int nCategories, bool debug)
: name_(mvaName), tag_(mvaTag), nCategories_(nCategories), debug_(debug) {}
virtual ~AnyMVAEstimatorRun2Base(){};

// Functions that must be provided in derived classes
// These function should work on electrons or photons
// of the reco or pat type

virtual float mvaValue( const reco::Candidate* candidate, std::vector<float> const& auxVariables, int &iCategory) const = 0;
float mvaValue( const reco::Candidate* candidate, std::vector<float> const& auxVariables) const {
int iCategory;
return mvaValue(candidate, auxVariables, iCategory);
virtual float mvaValue(const reco::Candidate* candidate,
std::vector<float> const& auxVariables,
int& iCategory) const = 0;
float mvaValue(const reco::Candidate* candidate, std::vector<float> const& auxVariables) const {
int iCategory;
return mvaValue(candidate, auxVariables, iCategory);
};

// A specific implementation of MVA is expected to have one or more categories
// defined with respect to eta, pt, etc.
// This function determines the category for a given candidate.
virtual int findCategory( const reco::Candidate* candidate) const = 0;
virtual int findCategory(const reco::Candidate* candidate) const = 0;
int getNCategories() const { return nCategories_; }
const std::string& getName() const { return name_; }
// An extra variable string set during construction that can be used
Expand All @@ -58,8 +51,7 @@ class AnyMVAEstimatorRun2Base {
// Implement these methods only if needed in the derived classes (use "override"
// for certainty).

private:

private:
//
// Data members
//
Expand All @@ -78,7 +70,6 @@ class AnyMVAEstimatorRun2Base {

// define the factory for this base class
#include "FWCore/PluginManager/interface/PluginFactory.h"
typedef edmplugin::PluginFactory< AnyMVAEstimatorRun2Base* (const edm::ParameterSet&) >
AnyMVAEstimatorRun2Factory;
typedef edmplugin::PluginFactory<AnyMVAEstimatorRun2Base*(const edm::ParameterSet&)> AnyMVAEstimatorRun2Factory;

#endif
16 changes: 8 additions & 8 deletions RecoEgamma/EgammaTools/interface/BaselinePFSCRegression.h
Expand Up @@ -4,7 +4,7 @@
#include "RecoEgamma/EgammaTools/interface/SCRegressionCalculator.h"

#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
#include "Geometry/CaloTopology/interface/CaloTopology.h"
#include "Geometry/CaloTopology/interface/CaloTopology.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"

Expand All @@ -27,23 +27,23 @@
#include <vector>

class BaselinePFSCRegression {
public:
BaselinePFSCRegression() : topo_record(nullptr), geom_record(nullptr) {};
public:
BaselinePFSCRegression() : topo_record(nullptr), geom_record(nullptr){};
void update(const edm::EventSetup&);
void set(const reco::SuperCluster&, std::vector<float>&) const;
void setTokens(const edm::ParameterSet&, edm::ConsumesCollector&&);
void setEvent(const edm::Event&);

private:
private:
const CaloTopologyRecord* topo_record;
const CaloGeometryRecord* geom_record;
edm::ESHandle<CaloTopology> calotopo;
edm::ESHandle<CaloGeometry> calogeom;
edm::EDGetTokenT<EcalRecHitCollection> inputTagEBRecHits_;
edm::EDGetTokenT<EcalRecHitCollection> inputTagEERecHits_;
edm::EDGetTokenT<reco::VertexCollection> inputTagVertices_;
edm::EDGetTokenT<EcalRecHitCollection> inputTagEBRecHits_;
edm::EDGetTokenT<EcalRecHitCollection> inputTagEERecHits_;
edm::EDGetTokenT<reco::VertexCollection> inputTagVertices_;
edm::Handle<reco::VertexCollection> vertices;
edm::Handle<EcalRecHitCollection> rechitsEB,rechitsEE;
edm::Handle<EcalRecHitCollection> rechitsEB, rechitsEE;
};

typedef SCRegressionCalculator<BaselinePFSCRegression> PFSCRegressionCalc;
Expand Down
38 changes: 17 additions & 21 deletions RecoEgamma/EgammaTools/interface/ConversionFinder.h
Expand Up @@ -23,8 +23,6 @@
#include "Math/VectorUtil.h"
#include "ConversionInfo.h"



/*
Class Looks for oppositely charged track in the
track collection with the minimum delta cot(theta) between the track
Expand All @@ -39,44 +37,42 @@ namespace egammaTools {
//returns a vector of Conversion Infos.
//you have to decide which is the best
std::vector<ConversionInfo> getConversionInfos(const reco::GsfElectronCore&,
const edm::Handle<reco::TrackCollection>& ctftracks_h,
const edm::Handle<reco::GsfTrackCollection>& gsftracks_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);
const edm::Handle<reco::TrackCollection>& ctftracks_h,
const edm::Handle<reco::GsfTrackCollection>& gsftracks_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);

//retruns the "best" Conversion Info after calling getConversionInfos
ConversionInfo getConversionInfo(const reco::GsfElectronCore&,
const edm::Handle<reco::TrackCollection>& ctftracks_h,
const edm::Handle<reco::GsfTrackCollection>& gsftracks_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);
const edm::Handle<reco::TrackCollection>& ctftracks_h,
const edm::Handle<reco::GsfTrackCollection>& gsftracks_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);

//retruns the "best" Conversion Info after calling getConversionInfos
ConversionInfo getConversionInfo(const reco::GsfElectron& gsfElectron,
const edm::Handle<reco::TrackCollection>& ctftracks_h,
const edm::Handle<reco::GsfTrackCollection>& gsftracks_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);
const edm::Handle<reco::TrackCollection>& ctftracks_h,
const edm::Handle<reco::GsfTrackCollection>& gsftracks_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);

//takes in a vector of candidate conversion partners
//and arbitrates between them returning the one with the
//smallest R=sqrt(dist*dist + dcot*dcot)
ConversionInfo arbitrateConversionPartnersbyR(const std::vector<ConversionInfo>& v_convCandidates);


//places different cuts on dist, dcot, delmissing hits and arbitration based on R = sqrt(dist*dist + dcot*dcot)
ConversionInfo findBestConversionMatch(const std::vector<ConversionInfo>& v_convCandidates);

//for backwards compatibility. Does not use the GSF track collection. This function will be
//deprecated soon
ConversionInfo getConversionInfo(const reco::GsfElectron& gsfElectron,
const edm::Handle<reco::TrackCollection>& track_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);

const edm::Handle<reco::TrackCollection>& track_h,
const double bFieldAtOrigin,
const double minFracSharedHits = 0.45);

// DEPRECATED
bool isFromConversion( const ConversionInfo &, double maxAbsDist = 0.02, double maxAbsDcot = 0.02);
bool isFromConversion(const ConversionInfo&, double maxAbsDist = 0.02, double maxAbsDcot = 0.02);

}
} // namespace egammaTools
#endif
37 changes: 17 additions & 20 deletions RecoEgamma/EgammaTools/interface/ConversionInfo.h
Expand Up @@ -5,27 +5,24 @@
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
#include "DataFormats/Math/interface/Point3D.h"

struct ConversionInfo {
const double dist;
const double dcot;
const double radiusOfConversion;
const math::XYZPoint pointOfConversion;
// if the partner track is found in the GSF track collection,
// this is a ref to the GSF partner track
const reco::TrackRef conversionPartnerCtfTk;
// if the partner track is found in the CTF track collection,
// this is a ref to the CTF partner track
const reco::GsfTrackRef conversionPartnerGsfTk;
const int deltaMissingHits;
const int flag;

struct ConversionInfo
{
const double dist;
const double dcot;
const double radiusOfConversion;
const math::XYZPoint pointOfConversion;
// if the partner track is found in the GSF track collection,
// this is a ref to the GSF partner track
const reco::TrackRef conversionPartnerCtfTk;
// if the partner track is found in the CTF track collection,
// this is a ref to the CTF partner track
const reco::GsfTrackRef conversionPartnerGsfTk;
const int deltaMissingHits;
const int flag;

// flag 0: Partner track found in the CTF collection using the electron's CTF track
// flag 1: Partner track found in the CTF collection using the electron's GSF track
// flag 2: Partner track found in the GSF collection using the electron's CTF track
// flag 3: Partner track found in the GSF collection using the electron's GSF track
// flag 0: Partner track found in the CTF collection using the electron's CTF track
// flag 1: Partner track found in the CTF collection using the electron's GSF track
// flag 2: Partner track found in the GSF collection using the electron's CTF track
// flag 3: Partner track found in the GSF collection using the electron's GSF track
};


#endif
33 changes: 15 additions & 18 deletions RecoEgamma/EgammaTools/interface/ConversionLikelihoodCalculator.h
Expand Up @@ -7,24 +7,21 @@
#include "TMVA/Reader.h"
#include <memory>

class ConversionLikelihoodCalculator
{
public:
ConversionLikelihoodCalculator();
void setWeightsFile(const char * weightsFile);

double calculateLikelihood(reco::ConversionRef conversion);
double calculateLikelihood(reco::Conversion & conversion);

private:
std::unique_ptr<TMVA::Reader> reader_;
float log_e_over_p_;
float log_abs_cot_theta_;
float log_abs_delta_phi_;
float log_chi2_max_pt_;
float log_chi2_min_pt_;

class ConversionLikelihoodCalculator {
public:
ConversionLikelihoodCalculator();
void setWeightsFile(const char* weightsFile);

double calculateLikelihood(reco::ConversionRef conversion);
double calculateLikelihood(reco::Conversion& conversion);

private:
std::unique_ptr<TMVA::Reader> reader_;
float log_e_over_p_;
float log_abs_cot_theta_;
float log_abs_delta_phi_;
float log_chi2_max_pt_;
float log_chi2_min_pt_;
};

#endif