Skip to content

Commit

Permalink
Merge pull request #29832 from guitargeek/EgammaTools_deps
Browse files Browse the repository at this point in the history
Move EffectiveAreas and ThreadSafeFunctor classes out of EgammaTools
  • Loading branch information
cmsbuild authored May 27, 2020
2 parents a5def04 + 9d189b5 commit 3ffd39c
Show file tree
Hide file tree
Showing 72 changed files with 312 additions and 332 deletions.
8 changes: 8 additions & 0 deletions CommonTools/Egamma/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<use name="DataFormats/Common"/>
<use name="DataFormats/EgammaCandidates"/>
<use name="DataFormats/GsfTrackReco"/>
<use name="DataFormats/TrackReco"/>
<use name="FWCore/Utilities"/>
<export>
<lib name="1"/>
</export>
135 changes: 135 additions & 0 deletions CommonTools/Egamma/interface/ConversionTools.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#ifndef CommonTools_Egamma_ConversionTools_h
#define CommonTools_Egamma_ConversionTools_h

//--------------------------------------------------------------------------------------------------
//
// ConversionTools
//
// Utility to match electrons/photons/tracks to conversions and perform various conversion
// selection criteria.
//
// Matching to photons is by geometrical match with the SuperCluster (defined by angle between
// conversion momentum and vector joining conversion vertex to SuperCluster position)
//
// Matching to tracks and electrons is by reference.
//
// Also implemented here is a "conversion-safe electron veto" for photons through the
// matchedPromptElectron and hasMatchedPromptElectron functions
//
//
// Authors: J.Bendavid
//--------------------------------------------------------------------------------------------------

#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"

class ConversionTools {
public:
ConversionTools() {}

static bool isGoodConversion(const reco::Conversion &conv,
const math::XYZPoint &beamspot,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 1);

static bool matchesConversion(const reco::GsfElectron &ele,
const reco::Conversion &conv,
bool allowCkfMatch = true,
bool allowAmbiguousGsfMatch = false);
static bool matchesConversion(const reco::GsfElectronCore &eleCore,
const reco::Conversion &conv,
bool allowCkfMatch = true);
static bool matchesConversion(const reco::SuperCluster &sc,
const reco::Conversion &conv,
float dRMax = 0.1,
float dEtaMax = 999.,
float dPhiMax = 999.);
static bool matchesConversion(const edm::RefToBase<reco::Track> &trk, const reco::Conversion &conv);
static bool matchesConversion(const reco::TrackRef &trk, const reco::Conversion &conv);
static bool matchesConversion(const reco::GsfTrackRef &trk, const reco::Conversion &conv);

static bool hasMatchedConversion(const reco::GsfElectron &ele,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
bool allowCkfMatch = true,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 0);

static bool hasMatchedConversion(const reco::TrackRef &trk,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 1);

static bool hasMatchedConversion(const reco::SuperCluster &sc,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
float dRMax = 0.1,
float dEtaMax = 999.,
float dPhiMax = 999.,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 1);

static reco::Conversion const *matchedConversion(const reco::GsfElectron &ele,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
bool allowCkfMatch = true,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 0);

static reco::Conversion const *matchedConversion(const reco::GsfElectronCore &eleCore,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
bool allowCkfMatch = true,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 0);

static reco::Conversion const *matchedConversion(const reco::TrackRef &trk,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 1);

static reco::Conversion const *matchedConversion(const reco::SuperCluster &sc,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
float dRMax = 0.1,
float dEtaMax = 999.,
float dPhiMax = 999.,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 1);

static bool hasMatchedPromptElectron(const reco::SuperClusterRef &sc,
const reco::GsfElectronCollection &eleCol,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
bool allowCkfMatch = true,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 0);

static reco::GsfElectron const *matchedPromptElectron(const reco::SuperClusterRef &sc,
const reco::GsfElectronCollection &eleCol,
const reco::ConversionCollection &convCol,
const math::XYZPoint &beamspot,
bool allowCkfMatch = true,
float lxyMin = 2.0,
float probMin = 1e-6,
unsigned int nHitsBeforeVtxMax = 0);

static float getVtxFitProb(const reco::Conversion *conv);
};
#endif
27 changes: 27 additions & 0 deletions CommonTools/Egamma/interface/EffectiveAreas.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef CommonTools_Egamma_EffectiveAreas_h
#define CommonTools_Egamma_EffectiveAreas_h

#include <vector>
#include <string>

class EffectiveAreas {
public:
// Constructor, destructor
EffectiveAreas(const std::string& filename);

// Accessors
const float getEffectiveArea(float eta) const;

// Utility functions
void printEffectiveAreas() const;
void checkConsistency() const;

private:
// Data members
const std::string filename_; // effective areas source file name
std::vector<float> absEtaMin_; // low limit of the eta range
std::vector<float> absEtaMax_; // upper limit of the eta range
std::vector<float> effectiveAreaValues_; // effective area for this eta range
};

#endif
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include <TMath.h>
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"
#include "DataFormats/EgammaCandidates/interface/Conversion.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/Common/interface/RefToPtr.h"
#include "DataFormats/Math/interface/deltaPhi.h"
#include "DataFormats/Math/interface/deltaR.h"

#include <TMath.h>

using namespace edm;
using namespace reco;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "RecoEgamma/EgammaTools/interface/EffectiveAreas.h"
#include "CommonTools/Egamma/interface/EffectiveAreas.h"
#include "FWCore/Utilities/interface/Exception.h"

#include <cmath>
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/RecoUtils/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<use name="MagneticField/Records"/>
<use name="MagneticField/Engine"/>
<use name="HLTrigger/HLTcore"/>
<use name="RecoEgamma/EgammaTools"/>
<use name="CommonTools/Egamma"/>
<use name="RecoVertex/KinematicFit"/>
<use name="RecoVertex/KinematicFitPrimitives"/>
<use name="TrackingTools/TransientTrack"/>
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/RecoUtils/src/PF_PU_AssoMapAlgos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"

#include "TrackingTools/IPTools/interface/IPTools.h"
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"

using namespace edm;
using namespace std;
Expand Down
30 changes: 30 additions & 0 deletions CommonTools/Utils/interface/ThreadSafeFunctor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef CommonTools_Utils_ThreadSafeFunctor_H
#define CommonTools_Utils_ThreadSafeFunctor_H

#include "FWCore/Utilities/interface/thread_safety_macros.h"

#include <mutex>
#include <utility>

// This class is a simple wrapper around some functor class to use its operator() in a thread-safe way.

template <class Functor>
class ThreadSafeFunctor {
public:
template <typename... Params>
ThreadSafeFunctor(Params&&... params) : functor_{std::forward<Params>(params)...} {}

ThreadSafeFunctor(ThreadSafeFunctor&& other) noexcept : functor_(std::move(other.functor_)) {}

template <typename... Params>
typename std::invoke_result_t<Functor, Params...> operator()(Params&&... params) const {
std::lock_guard<std::mutex> guard(mutex_);
return functor_(std::forward<Params>(params)...);
}

private:
const Functor functor_;
CMS_THREAD_SAFE mutable std::mutex mutex_;
};

#endif
2 changes: 1 addition & 1 deletion Configuration/Skimming/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<use name="CommonTools/Egamma"/>
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
Expand All @@ -12,7 +13,6 @@
<use name="RecoJets/JetAlgorithms"/>
<use name="HLTrigger/HLTcore"/>
<use name="CommonTools/UtilAlgos"/>
<use name="RecoEgamma/EgammaTools"/>
<use name="PhysicsTools/UtilAlgos"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/Luminosity"/>
Expand Down
3 changes: 1 addition & 2 deletions Configuration/Skimming/interface/LeptonSkimming.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
#include "DataFormats/EgammaCandidates/interface/Conversion.h"
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "FWCore/Common/interface/TriggerNames.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
Expand All @@ -52,7 +52,6 @@
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateIsolation.h"
#include "DataFormats/Common/interface/AssociationMap.h"
#include "HLTrigger/HLTcore/interface/HLTFilter.h"
//#include "HLTrigger/Egamma/plugins/HLTGenericFilter.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/MuonReco/interface/Muon.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "DataFormats/METReco/interface/CaloMETCollection.h"

// Conversions
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"

// Trigger
#include "DataFormats/Common/interface/TriggerResults.h"
Expand Down
2 changes: 1 addition & 1 deletion DQMOffline/Lumi/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<use name="DataFormats/EgammaReco"/>
<use name="DataFormats/EgammaCandidates"/>
<use name="DataFormats/HLTReco"/>
<use name="RecoEgamma/EgammaTools"/>
<use name="CommonTools/Egamma"/>
<use name="rootcore"/>
<export>
<lib name="1"/>
Expand Down
5 changes: 3 additions & 2 deletions DQMOffline/Lumi/interface/ElectronIdentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

#include "PhysicsTools/SelectorUtils/interface/CutApplicatorBase.h"

#include "RecoEgamma/EgammaTools/interface/EffectiveAreas.h"
#include <DataFormats/BeamSpot/interface/BeamSpot.h>
#include "CommonTools/Egamma/interface/EffectiveAreas.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"

enum EleIDCutNames {
SIGMAIETA,
DETAINSEED,
Expand Down
2 changes: 1 addition & 1 deletion DQMOffline/Lumi/src/ElectronIdentifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"

#include "DQMOffline/Lumi/interface/TTrigger.h"
#include "DQMOffline/Lumi/interface/TriggerTools.h"
Expand Down
2 changes: 1 addition & 1 deletion DQMOffline/Trigger/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<use name="DataFormats/TauReco"/>
<use name="DataFormats/METReco"/>
<use name="DataFormats/JetReco"/>
<use name="RecoEgamma/EgammaTools"/>
<use name="CommonTools/Egamma"/>
<use name="RecoVertex/KalmanVertexFit"/>
<use name="HLTrigger/HLTcore"/>
<use name="DQMServices/Core"/>
Expand Down
3 changes: 1 addition & 2 deletions DQMOffline/Trigger/plugins/LepHTMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
#include "DataFormats/EgammaCandidates/interface/Conversion.h"
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"

#include <limits>
#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion DQMServices/Examples/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<use name="CommonTools/Egamma"/>
<use name="DQMServices/Core"/>
<use name="FWCore/Framework"/>
<use name="DataFormats/EgammaCandidates"/>
<use name="DataFormats/JetReco"/>
<use name="DataFormats/METReco"/>
<use name="DataFormats/VertexReco"/>
<use name="RecoEgamma/EgammaTools"/>
<export>
<lib name="1"/>
</export>
2 changes: 1 addition & 1 deletion DQMServices/Examples/interface/DQMExample_Step1.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "DataFormats/JetReco/interface/CaloJet.h"

// Conversions
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"

// Trigger
#include "DataFormats/Common/interface/TriggerResults.h"
Expand Down
3 changes: 2 additions & 1 deletion EgammaAnalysis/ElectronTools/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<use name="CommonTools/Egamma"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/Utilities"/>
Expand All @@ -7,7 +8,6 @@
<use name="CondCore/DBOutputService"/>
<use name="CondFormats/EgammaObjects"/>
<use name="CondFormats/PhysicsToolsObjects"/>
<use name="RecoEgamma/EgammaTools"/>
<use name="RecoEcal/EgammaCoreTools"/>
<use name="DataFormats/Candidate"/>
<use name="DataFormats/Common"/>
Expand All @@ -18,6 +18,7 @@
<use name="TrackingTools/IPTools"/>
<use name="PhysicsTools/UtilAlgos"/>
<use name="PhysicsTools/SelectorUtils"/>
<use name="RecoEgamma/EgammaTools"/>
<use name="clhep"/>
<use name="root"/>
<use name="rootcore"/>
Expand Down
3 changes: 2 additions & 1 deletion EgammaAnalysis/ElectronTools/src/EGammaCutBasedEleId.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "EgammaAnalysis/ElectronTools/interface/EGammaCutBasedEleId.h"
#include "EgammaAnalysis/ElectronTools/interface/ElectronEffectiveArea.h"
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h"

#include <algorithm>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
#include "DataFormats/EgammaCandidates/interface/Conversion.h"
#include "RecoEgamma/EgammaTools/interface/ConversionTools.h"
#include "CommonTools/Egamma/interface/ConversionTools.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
Expand Down
Loading

0 comments on commit 3ffd39c

Please sign in to comment.