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 #32910 from Sam-Harper/EgTrigSum_1117
New HLT DEBUG object: EgTrigSumObj : CMSSW_11_1_X
- Loading branch information
Showing
8 changed files
with
673 additions
and
0 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
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,64 @@ | ||
#ifndef DataFormats_HLTReco_EgammaObject_h | ||
#define DataFormats_HLTReco_EgammaObject_h | ||
|
||
#include "DataFormats/HLTReco/interface/TriggerObject.h" | ||
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" | ||
#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h" | ||
#include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" | ||
|
||
#include <vector> | ||
#include <string> | ||
|
||
namespace reco { | ||
class RecoEcalCandidate; | ||
} | ||
|
||
namespace trigger { | ||
class EgammaObject : public TriggerObject { | ||
public: | ||
EgammaObject() : hasPixelMatch_(false) {} | ||
|
||
EgammaObject(int id, float pt, float eta, float phi, float mass) | ||
: TriggerObject(id, pt, eta, phi, mass), hasPixelMatch_(false) {} | ||
EgammaObject(const reco::RecoEcalCandidate& ecalCand); | ||
|
||
const reco::SuperClusterRef& superCluster() const { return superCluster_; } | ||
const reco::GsfTrackRefVector& gsfTracks() const { return gsfTracks_; } | ||
const reco::ElectronSeedRefVector& seeds() const { return seeds_; } | ||
|
||
void setSuperCluster(const reco::SuperClusterRef& sc) { superCluster_ = sc; } | ||
void setGsfTracks(reco::GsfTrackRefVector trks) { gsfTracks_ = std::move(trks); } | ||
void setSeeds(reco::ElectronSeedRefVector seeds); | ||
|
||
bool hasVar(const std::string& varName) const; | ||
float var(const std::string& varName, bool raiseExcept = true) const; | ||
const std::vector<std::pair<std::string, float>>& vars() const { return vars_; } | ||
//varNames and varNamesStr are reasonably expensive functions and are more | ||
//intended for debugging than normal use | ||
std::vector<std::string> varNames() const; | ||
std::string varNamesStr() const; | ||
void setVars(std::vector<std::pair<std::string, float>> vars); | ||
void clearVars() { vars_.clear(); } | ||
|
||
private: | ||
struct VarComparer { | ||
bool operator()(const std::string& lhs, const std::pair<std::string, float>& rhs) const { | ||
return lhs < rhs.first; | ||
} | ||
bool operator()(const std::pair<std::string, float>& lhs, const std::string& rhs) const { | ||
return lhs.first < rhs; | ||
} | ||
}; | ||
|
||
bool hasPixelMatch_; | ||
std::vector<std::pair<std::string, float>> vars_; | ||
|
||
reco::SuperClusterRef superCluster_; | ||
reco::GsfTrackRefVector gsfTracks_; | ||
//currently these are pixel seeds but could be tracker seeds... | ||
reco::ElectronSeedRefVector seeds_; | ||
}; | ||
|
||
} // namespace trigger | ||
|
||
#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,19 @@ | ||
#ifndef DataFormats_HLTReco_EgammaObjectFwd_h | ||
#define DataFormats_HLTReco_EgammaObjectFwd_h | ||
|
||
#include <vector> | ||
#include "DataFormats/Common/interface/Ref.h" | ||
#include "DataFormats/Common/interface/RefVector.h" | ||
#include "DataFormats/Common/interface/RefProd.h" | ||
|
||
namespace trigger { | ||
class EgammaObject; | ||
|
||
typedef std::vector<EgammaObject> EgammaObjectCollection; | ||
typedef edm::Ref<EgammaObjectCollection> EgammaObjectRef; | ||
typedef edm::RefProd<EgammaObjectCollection> EgammaObjectRefProd; | ||
typedef edm::RefVector<EgammaObjectCollection> EgammaObjectRefVector; | ||
typedef EgammaObjectRefVector::iterator EgammaObjectIterator; | ||
} // namespace trigger | ||
|
||
#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,62 @@ | ||
#include "DataFormats/HLTReco/interface/EgammaObject.h" | ||
|
||
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h" | ||
#include "DataFormats/EgammaReco/interface/SuperCluster.h" | ||
#include "DataFormats/EgammaReco/interface/ElectronSeed.h" | ||
#include "DataFormats/GsfTrackReco/interface/GsfTrack.h" | ||
|
||
trigger::EgammaObject::EgammaObject(const reco::RecoEcalCandidate& ecalCand) | ||
: TriggerObject(ecalCand), hasPixelMatch_(false), superCluster_(ecalCand.superCluster()) {} | ||
|
||
void trigger::EgammaObject::setSeeds(reco::ElectronSeedRefVector seeds) { | ||
seeds_ = std::move(seeds); | ||
hasPixelMatch_ = false; | ||
for (const auto& seed : seeds_) { | ||
if (!seed->hitInfo().empty()) { | ||
hasPixelMatch_ = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
bool trigger::EgammaObject::hasVar(const std::string& varName) const { | ||
return std::binary_search(vars_.begin(), vars_.end(), varName, VarComparer()); | ||
} | ||
|
||
float trigger::EgammaObject::var(const std::string& varName, const bool raiseExcept) const { | ||
//here we have a guaranteed sorted vector with unique entries | ||
auto varIt = std::equal_range(vars_.begin(), vars_.end(), varName, VarComparer()); | ||
if (varIt.first != varIt.second) | ||
return varIt.first->second; | ||
else if (raiseExcept) { | ||
cms::Exception ex("AttributeError"); | ||
ex << " error variable " << varName << " is not present, variables present are " << varNamesStr(); | ||
throw ex; | ||
} else { | ||
return std::numeric_limits<float>::max(); | ||
} | ||
} | ||
|
||
std::vector<std::string> trigger::EgammaObject::varNames() const { | ||
std::vector<std::string> names; | ||
for (const auto& var : vars_) { | ||
names.push_back(var.first); | ||
} | ||
return names; | ||
} | ||
|
||
std::string trigger::EgammaObject::varNamesStr() const { | ||
std::string retVal; | ||
auto names = varNames(); | ||
for (const auto& name : names) { | ||
if (!retVal.empty()) | ||
retVal += " "; | ||
retVal += name; | ||
} | ||
return retVal; | ||
} | ||
|
||
void trigger::EgammaObject::setVars(std::vector<std::pair<std::string, float>> vars) { | ||
vars_ = std::move(vars); | ||
std::sort(vars_.begin(), vars_.end(), [](auto& lhs, auto& rhs) { return lhs.first < rhs.first; }); | ||
} |
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.