-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29832 from guitargeek/EgammaTools_deps
Move EffectiveAreas and ThreadSafeFunctor classes out of EgammaTools
- Loading branch information
Showing
72 changed files
with
312 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
7 changes: 3 additions & 4 deletions
7
...Egamma/EgammaTools/src/ConversionTools.cc → CommonTools/Egamma/src/ConversionTools.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
RecoEgamma/EgammaTools/src/EffectiveAreas.cc → CommonTools/Egamma/src/EffectiveAreas.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.