11 m_trigdec(
"Trig::TrigDecisionTool/TrigDecisionTool"),
13 m_matchTool(
"Trig::R3MatchingTool/TrigR3MatchingTool")
28 ATH_MSG_INFO(
"TrigEgammaMonitorBaseAlgorithm::initialize()...");
30 ATH_MSG_INFO(
"TrigEgammaMonitorBaseAlgorithm DONE INITIALIZING...");
37 std::vector<std::string> steps = {
"L1Calo",
"L2Calo",
"L2",
"EFCalo",
"EFTrack",
"HLT"};
38 for(
const auto& step:steps)
43 return StatusCode::SUCCESS;
51 if (pidname ==
"tight"){
54 else if (pidname ==
"medium"){
57 else if (pidname ==
"loose"){
60 else if (pidname ==
"lhtight"){
64 else if (pidname ==
"lhmedium"){
68 else if (pidname ==
"lhloose"){
72 else if (pidname ==
"lhvloose"){
75 else if (pidname ==
"dnntight"){
79 else if (pidname ==
"dnnmedium"){
83 else if (pidname ==
"dnnloose"){
98 if (pidname ==
"tight"){
101 else if (pidname ==
"medium"){
104 else if (pidname ==
"loose"){
121 ATH_MSG_DEBUG(
"Electron doesn't provide isolation for ptcone20");
124 if (!(fabs(eg->
pt()) > 0)) {
125 ATH_MSG_DEBUG(
"Electron pt is zero, can't calculate relative isolation");
129 float ptcone20_rel = ptcone20/eg->
pt();
131 if (isolation ==
"loose"){
132 if (ptcone20_rel > 0.1) {
141 ATH_MSG_DEBUG(
"No valid working point defined for " << isolation <<
" continue without isolation");
150 bool efprescale=
false;
151 bool l1prescale=
false;
154 std::string l1item=
"";
156 if(trigger.starts_with(
"L1" ))
158 if(trigger.starts_with(
"HLT")){
160 const unsigned int bit=
tdt()->isPassedBits(trigger);
166 ATH_MSG_DEBUG(
"Checking prescale for " << trigger <<
" " << l1item);
167 const unsigned int l1bit=
tdt()->isPassedBits(l1item);
170 l1prescale=l1_beforepre && !l1_afterpre;
171 prescale=efprescale || l1prescale;
172 ATH_MSG_DEBUG(
"L1 prescale " << l1item <<
" " << l1prescale <<
" before " << l1_beforepre <<
" after " << l1_afterpre);
173 ATH_MSG_DEBUG(
"EF prescale " << trigger <<
" " << efprescale <<
" Prescale " << prescale);
174 if(rerun)
return false;
175 if(prescale)
return true;
189 bool passedL1Calo=
false;
190 bool passedL2Calo=
false;
191 bool passedEFCalo=
false;
193 bool passedEFTrk=
false;
197 auto trigger = info.trigger;
209 if(info.signature ==
"Electron" or info.signature ==
"e"){
210 std::string key =
match()->key(
"FastElectrons");
211 if(info.lrt) key =
match()->key(
"FastElectrons_LRT");
213 }
else if(info.signature ==
"Photon" or info.signature ==
"g"){
220 std::string key =
match()->key(
"PrecisionCalo_Electron");
221 if(info.signature ==
"Photon" or info.signature ==
"g") key =
match()->key(
"PrecisionCalo_Photon");
222 if(info.lrt) key =
match()->key(
"PrecisionCalo_LRT");
223 if(info.ion) key =
match()->key(
"PrecisionCalo_HI");
233 if(info.signature ==
"Electron" or info.signature ==
"e"){
234 if( info.etcut || info.idperf){
237 std::string key =
match()->key(
"Electrons_GSF");
238 if(info.lrt) key =
match()->key(
"Electrons_LRT");
239 if(info.nogsf) key =
match()->key(
"Electrons");
243 }
else if(info.signature ==
"Photon" or info.signature ==
"g"){
257 if(info.signature ==
"Electron" or info.signature ==
"e"){
258 if( info.etcut || info.idperf){
261 std::string key =
match()->key(
"Electrons_GSF");
262 if(info.lrt) key =
match()->key(
"Electrons_LRT");
263 if(info.nogsf) key =
match()->key(
"Electrons");
267 }
else if(info.signature ==
"Photon" or info.signature ==
"g"){
297 float deta = fabs(eta1 - eta2);
298 float dphi = fabs(phi1 - phi2) < TMath::Pi() ? fabs(phi1 - phi2) : 2*TMath:: \
299 Pi() - fabs(phi1 - phi2);
300 return sqrt(deta*deta + dphi*dphi);
309 return fabs(cluster->
etaBE(2));
319 float eta = fabs(trk->
eta());
320 return clus->
e()/cosh(
eta);
329 float eta2 = fabs(cluster->
etaBE(2));
330 return cluster->
e()/cosh(eta2);
342 float den = emax+emax2;
344 if (fabs(den) < 1e-6)
return -99.;
346 float val = (emax-emax2)/(den);
357 uint8_t trtHTHits = 0;
359 if (fabs(trtHits) < 1e-6) {
363 return ( (
double)trtHTHits / (
double)trtHits );
375 float vard0 = t->definingParametersCovMatrix()(0,0);
377 d0sigma=sqrtf(vard0);
391 float vard0 = t->definingParametersCovMatrix()(0,0);
393 d0sigma=sqrtf(vard0);
397 if (fabs(d0sigma) < 1e-6)
return -99.;
398 return t->d0()/d0sigma;
446 return (ebe1+ebe2+ebe3);
459 float eacc = ebe1+ebe2+ebe3;
460 if(eacc==0.)
return 0.;
468#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getShowerShape_##_name_(const xAOD::Egamma* eg) const \
470 eg->showerShapeValue(val,xAOD::EgammaParameters::_name_); \
498#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getIsolation_##_name_(const xAOD::Electron* eg) const\
500 eg->isolationValue(val,xAOD::Iso::_name_); \
511#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getIsolation_##_name_(const xAOD::Egamma* eg) const\
513 eg->isolationValue(val,xAOD::Iso::_name_); \
526#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getCluster_##_name_(const xAOD::Egamma* eg) const\
527{ if(eg && eg->caloCluster()) \
528 return eg->caloCluster()->_name_(); \
537#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrack_##_name_(const xAOD::Electron* eg) const\
538{ if(eg && eg->trackParticle()) \
539 return eg->trackParticle()->_name_(); \
550#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrackSummary_##_name_(const xAOD::Electron* eg) const \
551{ uint8_t val_uint8{0}; \
553 eg->trackParticleSummaryValue(val_uint8,xAOD::_name_); \
554 return val_uint8; } \
556 GETTER(numberOfInnermostPixelLayerHits)
557 GETTER(numberOfInnermostPixelLayerOutliers)
559 GETTER(numberOfPixelOutliers)
561 GETTER(numberOfSCTOutliers)
563 GETTER(numberOfTRTHighThresholdHits)
564 GETTER(numberOfTRTHighThresholdOutliers)
565 GETTER(numberOfTRTOutliers)
566 GETTER(expectInnermostPixelLayerHit)
567 GETTER(numberOfPixelDeadSensors)
568 GETTER(numberOfSCTDeadSensors)
569 GETTER(numberOfTRTXenonHits)
573#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getTrackSummaryFloat_##_name_(const xAOD::Electron* eg) const\
574{ float val_float{0}; \
576 eg->trackParticleSummaryValue(val_float,xAOD::_name_); \
577 return val_float; } \
586#define GETTER(_name_) float TrigEgammaMonitorBaseAlgorithm::getCaloTrackMatch_##_name_(const xAOD::Electron* eg) const\
589 eg->trackCaloMatchValue(val,xAOD::EgammaParameters::_name_);} \
645 std::map<std::string, std::string> pidMap = { {
"vloose" ,
"loose" },
646 {
"loose" ,
"loose" },
647 {
"medium" ,
"medium" },
648 {
"tight" ,
"tight" },
649 {
"loose1" ,
"loose" },
650 {
"medium1" ,
"medium" },
651 {
"tight1" ,
"tight" },
652 {
"lhvloose" ,
"lhvloose" },
653 {
"lhloose" ,
"lhloose" },
654 {
"lhmedium" ,
"lhmedium" },
655 {
"lhtight" ,
"lhtight" },
656 {
"dnnloose" ,
"dnnloose" },
657 {
"dnnmedium",
"dnnmedium"},
658 {
"dnntight" ,
"dnntight" },
659 {
"nopid" ,
"nopid" } };
661 std::vector<std::string> isoNames = {
"ivarloose",
"ivarmedium",
"ivartight",
"icaloloose",
"icalomedium",
"icalotight"};
668 bool isolated =
false;
670 std::string isolation=
"";
673 std::string hltinfo=trigger;
674 std::string signature =
"";
677 if(boost::contains(hltinfo,
"HLT")) hltinfo.erase(0,4);
680 std::vector<std::string> parts;
681 boost::split(parts,hltinfo,boost::is_any_of(
"_"));
685 if(boost::contains(parts.at(0),
"e")) {
686 signature =
"Electron";
688 }
else if(boost::contains(parts.at(0),
"g")) {
689 signature =
"Photon";
696 if(parts.at(1) ==
"idperf"){
700 else if( parts.at(1)==
"etcut"){
706 if (pidMap.count(parts.at(1)) != 1) {
707 ATH_MSG_ERROR(
"Unknown trigger type: " << parts.at(1) <<
" (" << trigger <<
")");
709 pidname = pidMap.at(parts.at(1));
714 nogsf = boost::contains(trigger,
"nogsf");
715 lrt = boost::contains(trigger,
"lrt");
716 ion = boost::contains(trigger,
"ion");
718 for(
auto& iso : isoNames){
719 if(boost::contains(trigger, iso)){
720 isolation=iso; isolated=
true;
break;
725 std::string str_thr = parts.at(0);
726 str_thr.erase( 0, 1);
731 l1legacy = !boost::contains(l1seed,
"eEM");
734 ATH_MSG_DEBUG(
"=================== Chain Parser =======================");
746 ATH_MSG_DEBUG(
"L1Seed : " << l1seed <<
" (Is Legacy? " << (l1legacy?
"Yes":
"No") <<
")");
747 ATH_MSG_DEBUG(
"========================================================");
749 TrigInfo info{l1legacy,l1seed,trigger,signature,
threshold,pidname,idperf,etcut,nogsf,lrt,ion,isolation,isolated};
754std::vector<ChainNameParser::LegInfo>
757 std::vector<ChainNameParser::LegInfo> result;
762 <<
", multiplicity = " << legInfo.multiplicity
763 <<
", signature = " << legInfo.signature
764 <<
", threshold = " << legInfo.threshold
765 <<
", leg parts = "<< legInfo.legParts);
767 result.push_back(legInfo);
803 std::map<std::string, std::string> pidMap = { {
"vloose" ,
"loose" },
804 {
"loose" ,
"loose" },
805 {
"medium" ,
"medium" },
806 {
"tight" ,
"tight" },
807 {
"loose1" ,
"loose" },
808 {
"medium1" ,
"medium" },
809 {
"tight1" ,
"tight" },
810 {
"lhvloose" ,
"lhvloose" },
811 {
"lhloose" ,
"lhloose" },
812 {
"lhmedium" ,
"lhmedium" },
813 {
"lhtight" ,
"lhtight" },
814 {
"dnnloose" ,
"dnnloose" },
815 {
"dnnmedium",
"dnnmedium"},
816 {
"dnntight" ,
"dnntight" },
817 {
"nopid" ,
"nopid" } };
826 std::string signature =
"";
827 std::string etthr =
"";
828 std::string pidname =
"";
834 if(!LegParts.empty())
837 for(
const auto& leg: LegParts)
840 if (leg.signature !=
"g")
continue;
843 signature = leg.signature;
844 if (signature ==
"g"){
845 signature =
"Photon";
849 pidname = leg.legParts[0];
857 l1legacy = !boost::contains(l1seed,
"eEM");
860 std::vector<std::string> isoNames = {
"ivarloose",
"ivarmedium",
"ivartight",
"icaloloose",
"icalomedium",
"icalotight"};
867 bool isolated =
false;
869 std::string isolation=
"";
872 nogsf = boost::contains(trigger,
"nogsf");
873 lrt = boost::contains(trigger,
"lrt");
874 ion = boost::contains(trigger,
"ion");
876 for(
auto& iso : isoNames){
877 if(boost::contains(trigger, iso)){
878 isolation=iso; isolated=
true;
break;
882 std::vector<std::string> parts;
883 boost::split(parts, trigger, boost::is_any_of(
"_"));
885 if(boost::contains(trigger,
"idperf")){
889 else if(boost::contains(trigger,
"etcut")){
904 ATH_MSG_DEBUG(
"=================== R3 Chain Parser R3 =======================");
916 ATH_MSG_DEBUG(
"L1Seed : " << l1seed <<
" (Is Legacy? " << (l1legacy?
"Yes":
"No") <<
")");
917 ATH_MSG_DEBUG(
"========================================================");
919 TrigInfo info{l1legacy,l1seed,trigger,signature,
threshold,pidname,idperf,etcut,nogsf,lrt,ion,isolation,isolated};
936 std::vector<std::string> parts;
937 boost::split(parts,trigger,boost::is_any_of(
"_"));
939 std::string l1seed = parts.back();
945 return m_trigdec->ExperimentalAndExpertMethods().isHLTTruncated();
954#include "Gaudi/Parsers/Factory.h"
961 StatusCode
parse(
VecDict_t& result,
const std::string& input ) {
return parse_( result, input ); }
967#include "GaudiKernel/ToStream.h"
974 for (
const auto& dict : vecDict ) {
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define GETTER(_name_)
Macros for plotting.
struct _triginfo TrigInfo
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Helper class that provides access to information about individual legs.
bool ApplyElectronPid(const EventContext &ctx, const xAOD::Electron *eg, const std::string &) const
Get offline electron decision.
Gaudi::Property< bool > m_doEffwithDNN
float getEnergyBE2(const xAOD::Egamma *eg) const
void setTrigInfoR3(const std::string &)
ToolHandleArray< IAsgElectronLikelihoodTool > m_electronLHTool
Offline LH Selectors.
float getEnergyBE3(const xAOD::Egamma *eg) const
float getSigmaD0(const xAOD::Electron *eg) const
std::map< std::string, TrigInfo > m_trigInfo
creates map of trigger name and TrigInfo struct
float getEtCluster37(const xAOD::Egamma *eg) const
TrigEgammaMonitorBaseAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
const ToolHandle< TrigEgammaMatchingToolMT > & match() const
Get the e/g match tool.
Gaudi::Property< std::string > m_defaultProbePidPhoton
default probe pid for photon trigitems that don't have pid in their name
float dR(const float, const float, const float, const float) const
Get delta R.
float getEnergyBE1(const xAOD::Egamma *eg) const
float getDEmaxs1(const xAOD::Egamma *eg) const
float rTRT(const xAOD::Electron *eg) const
ToolHandle< TrigEgammaMatchingToolMT > m_matchTool
bool isHLTTruncated() const
Gaudi::Property< bool > m_doEffwithLH
const ToolHandle< Trig::TrigDecisionTool > & tdt() const
Get the TDT.
float getE0Eaccordion(const xAOD::Egamma *eg) const
Gaudi::Property< std::string > m_defaultProbePidElectron
default probe pid for electron trigitems that don't have pid in their name
ToolHandleArray< IAsgPhotonIsEMSelector > m_photonIsEMTool
Offline isEM Photon Selectors.
ToolHandle< Trig::TrigDecisionTool > m_trigdec
Trigger decision tool.
float getEt(const xAOD::Electron *eg) const
ToolHandleArray< IAsgElectronIsEMSelector > m_electronIsEMTool
Offline isEM Selectors.
asg::AcceptData setAccept(const TrigCompositeUtils::Decision *, const TrigInfo &, const bool) const
Set the accept object for all trigger levels.
virtual ~TrigEgammaMonitorBaseAlgorithm()
bool isPrescaled(const std::string &) const
Check if the event is prescaled.
std::map< std::string, TrigInfo > m_trigInfoR3
virtual StatusCode initialize() override
initialize
TrigInfo getTrigInfo(const std::string &) const
Get the trigger info parsed from the chain name (only single lepton triggers).
bool isIsolated(const xAOD::Electron *, const std::string &) const
Check if electron fulfils isolation criteria.
void setTrigInfo(const std::string &)
Set the trigger info parsed from the chain name.
float getD0sig(const xAOD::Electron *eg) const
float getEta2(const xAOD::Egamma *eg) const
Features helper.
bool ApplyPhotonPid(const EventContext &ctx, const xAOD::Photon *eg, const std::string &) const
Get offline electron decision.
float getEaccordion(const xAOD::Egamma *eg) const
std::string getL1Item(const std::string &trigger) const
Creates static map to return L1 item from trigger name.
ToolHandle< Trig::TrigEgammaEmulationToolMT > m_emulatorTool
TrigInfo getTrigInfoR3(const std::string &) const
float getEnergyBE0(const xAOD::Egamma *eg) const
std::vector< ChainNameParser::LegInfo > getProbeTriggerLeg(const std::string &triggerName) const
ToolHandleArray< IAsgElectronLikelihoodTool > m_electronDNNTool
Offline DNN Selectors.
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer).
virtual double e() const
The total energy of the particle.
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
bool showerShapeValue(float &value, const EgammaParameters::ShowerShapeType information) const
Accessor for ShowerShape values.
bool isolationValue(float &value, const Iso::IsolationType information) const
old Accessor for Isolation values.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
const xAOD::TrackParticle * trackParticle(size_t index=0) const
Pointer to the xAOD::TrackParticle/s that match the electron candidate.
bool trackParticleSummaryValue(uint8_t &value, const SummaryType information, int index=0) const
Accessor to the matching track(s) float information (index = 0 is the best match) If 'information' is...
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
std::vector< Dict_t > VecDict_t
StatusCode parse(std::tuple< Tup... > &tup, const Gaudi::Parsers::InputData &input)
std::ostream & toStream(const SG::VarHandleKeyArray &v, std::ostream &o)
Gaudi function used to convert a property to a string.
=============================================================================
xAOD::TrigComposite Decision
static const unsigned int L1_isPassedBeforePrescale
static const unsigned int L1_isPassedAfterPrescale
static const unsigned int EF_prescaled
static const unsigned int includeFailedDecisions
Run3 synonym of alsoDeactivateTEs.
static const unsigned int EF_resurrected
ostream & operator<<(ostream &s, const SG::VarHandleKey &m)
@ emaxs1
energy of strip with maximal energy deposit
@ e2tsts1
energy of the cell corresponding to second energy maximum in the first sampling
@ ptcone20
Track isolation.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
TrigElectronContainer_v1 TrigElectronContainer
Declare the latest version of the container.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrigEMClusterContainer_v1 TrigEMClusterContainer
Define the latest version of the trigger EM cluster container.
TrigPhotonContainer_v1 TrigPhotonContainer
Declare the latest version of the container.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Egamma_v1 Egamma
Definition of the current "egamma version".
Photon_v1 Photon
Definition of the current "egamma version".
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
@ numberOfTRTHits
number of TRT hits [unit8_t].
@ numberOfTRTHighThresholdHits
number of TRT hits which pass the high threshold (only xenon counted) [unit8_t].
Electron_v1 Electron
Definition of the current "egamma version".
Struct containing information on each leg of a chain.
Extra patterns decribing particle interation process.