Skip to content
Snippets Groups Projects
Commit 82e6bea6 authored by Peter Sherwood's avatar Peter Sherwood
Browse files

Add jet hypo tools compatible with the current hypo scheme including the use of Decision objects.

The template pattern used until now whereby the base class calls methods on derived classes
to obtain details for a given hypo scenario (and where the concrete objects thus obtained are used
through used though interfaces) has been replaced by th use of a single Tool (TrigJetHypoToolMT)
which obtains the scenario dpendent objects through delegation to a ITrigJetHypoToolConfig.

TrigJetHypoToolMT will be configured with the approriate concrete implementation of ITrigJetHypoToolConfig.

For now, only one such implementation exists: TrigJetHypoToolConfig_EtaEt.


Former-commit-id: 93ef5590
parent 30638e3b
8 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!28528Revert 63f845ae,!27054Atr20369 210,!26342Monopole: Handle fractionally charged particles
#ifndef TRIGHLTJETHYPO_ITRIGJETHYPOTOOLCONFIG_H
#define TRIGHLTJETHYPO_ITRIGJETHYPOTOOLCONFIG_H
#include "GaudiKernel/IAlgTool.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJetGrouper.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerBridge.h"
class ITrigJetHypoToolConfig : virtual public ::IAlgTool {
public:
DeclareInterfaceID(ITrigJetHypoToolConfig, 1, 0);
virtual ~ITrigJetHypoToolConfig(){};
virtual StatusCode checkVals() const = 0;
// allow non-standard cleaners to be added to the cleaner factory.
virtual std::vector<std::shared_ptr<ICleaner>> getCleaners() const = 0;
virtual std::unique_ptr<IJetGrouper> getJetGrouper() const = 0;
virtual Conditions getConditions() const = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGHLTJETHYPO_ITRIGJETHYPOTOOLMT_H
#define TRIGHLTJETHYPO_ITRIGJETHYPOTOOLMT_H
#include "GaudiKernel/IAlgTool.h"
#include "xAODJet/JetContainer.h"
#include "DecisionHandling/TrigCompositeUtils.h"
using TrigCompositeUtils::Decision;
using TrigCompositeUtils::DecisionContainer;
class ITrigJetHypoToolMT : virtual public ::IAlgTool {
public:
DeclareInterfaceID(ITrigJetHypoToolMT, 1, 0);
virtual ~ITrigJetHypoToolMT(){};
virtual StatusCode decide(const xAOD::JetContainer*,
std::unique_ptr<DecisionContainer>&,
const DecisionContainer*) const = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ********************************************************************
//
// NAME: TrigJetHypoToolMT_EtaEt.cxx
// PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo
//
//
// ********************************************************************
#include "TrigJetHypoToolConfig_EtaEt.h"
#include "GaudiKernel/StatusCode.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/conditionsFactory2.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsSorter.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/SingleJetGrouper.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJetFactory.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/groupsMatcherFactory.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerFactory.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/TrigHLTJetHypoHelper2.h"
#include "DecisionHandling/TrigCompositeUtils.h"
using TrigCompositeUtils::DecisionID;
using TrigCompositeUtils::Decision;
using TrigCompositeUtils::DecisionContainer;
TrigJetHypoToolConfig_EtaEt::TrigJetHypoToolConfig_EtaEt(const std::string& type,
const std::string& name,
const IInterface* parent) :
base_class(type, name, parent){
}
TrigJetHypoToolConfig_EtaEt::~TrigJetHypoToolConfig_EtaEt(){
}
StatusCode TrigJetHypoToolConfig_EtaEt::initialize() {
CHECK(checkVals());
return StatusCode::SUCCESS;
}
Conditions TrigJetHypoToolConfig_EtaEt::getConditions() const {
auto conditions = conditionsFactoryEtaEt(m_etaMins,
m_etaMaxs,
m_EtThresholds,
m_asymmetricEtas);
std::sort(conditions.begin(), conditions.end(), ConditionsSorter());
return conditions;
}
std::unique_ptr<IJetGrouper> TrigJetHypoToolConfig_EtaEt::getJetGrouper() const {
return std::make_unique<SingleJetGrouper>();
}
StatusCode TrigJetHypoToolConfig_EtaEt::checkVals() const {
if (m_EtThresholds.size() != m_etaMins.size() or
m_EtThresholds.size() != m_etaMaxs.size() or
m_asymmetricEtas.size() != m_etaMaxs.size()){
ATH_MSG_ERROR(name()
<< ": mismatch between number of thresholds "
<< "and eta min, max boundaries or asymmetric eta flags: "
<< m_EtThresholds.size() << " "
<< m_etaMins.size() << " "
<< m_etaMaxs.size() << " "
<< m_asymmetricEtas.size() << " "
);
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS;
}
std::vector<std::shared_ptr<ICleaner>>
TrigJetHypoToolConfig_EtaEt::getCleaners() const {
std::vector<std::shared_ptr<ICleaner>> v;
return v;
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGJETHYPOTOOLConfig_ETAET_H
#define TRIGJETHYPOTOOLConfig_ETAET_H
/********************************************************************
*
* NAME: TrigJetHypoToolConfig_EtaEtTool.h
* PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo
*
*
*********************************************************************/
#include "ITrigJetHypoToolConfig.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h"
#include "DecisionHandling/HLTIdentifier.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "DecisionHandling/TrigCompositeUtils.h"
#include "AthenaMonitoring/GenericMonitoringTool.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ICleaner.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJetGrouper.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerBridge.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h"
class TrigJetHypoToolConfig_EtaEt:
public extends<AthAlgTool, ITrigJetHypoToolConfig> {
public:
TrigJetHypoToolConfig_EtaEt(const std::string& type,
const std::string& name,
const IInterface* parent);
virtual ~TrigJetHypoToolConfig_EtaEt();
virtual StatusCode initialize() override;
virtual std::vector<std::shared_ptr<ICleaner>> getCleaners() const override;
virtual std::unique_ptr<IJetGrouper> getJetGrouper() const override;
virtual Conditions getConditions() const override;
private:
Gaudi::Property<std::vector<double>>
m_EtThresholds{this, "EtThresholds", {}, "Etthresholds by eta region"};
Gaudi::Property<std::vector<double>>
m_etaMins{this, "eta_mins", {}, "Eta min for eta regions"};
Gaudi::Property<std::vector<double>>
m_etaMaxs{this, "eta_maxs", {}, "Eta max for eta regions"};
Gaudi::Property<std::vector<int>>
m_asymmetricEtas{this, "asymmetricEtas", {}, "Apply asym. eta cuts"};
Gaudi::Property<std::string>
m_matchingAlg{this, "matchingAlg", {}, "matcher alg"};
StatusCode checkVals() const;
// Monitored variables...
/*
declareMonitoredVariable("NJet", m_njet);
declareMonitoredVariable("Et", m_et);
declareMonitoredVariable("Eta", m_eta);
declareMonitoredVariable("Phi", m_phi);
*/
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ********************************************************************
//
// NAME: TrigJetHypoToolMT.cxx
// PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo
//
//
// ********************************************************************
#include "TrigJetHypoToolMT.h"
#include "GaudiKernel/StatusCode.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/conditionsFactory2.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsSorter.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/SingleJetGrouper.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/xAODJetAsIJetFactory.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/groupsMatcherFactory.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerFactory.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/TrigHLTJetHypoHelper2.h"
#include "DecisionHandling/HLTIdentifier.h"
#include "DecisionHandling/TrigCompositeUtils.h"
using TrigCompositeUtils::DecisionID;
using TrigCompositeUtils::Decision;
using TrigCompositeUtils::DecisionContainer;
TrigJetHypoToolMT::TrigJetHypoToolMT(const std::string& type,
const std::string& name,
const IInterface* parent) :
base_class(type, name, parent),
m_decisionId(HLT::Identifier::fromToolName(name)) {
}
TrigJetHypoToolMT::~TrigJetHypoToolMT(){
}
StatusCode TrigJetHypoToolMT::initialize(){
m_conditions = m_config->getConditions();
return StatusCode::SUCCESS;
}
StatusCode TrigJetHypoToolMT::finalize(){
return StatusCode::SUCCESS;
}
StatusCode TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
bool& pass) const {
pass = false;
HypoJetVector hypoJets(jets->size());
std::transform(jets -> begin(),
jets -> end(),
hypoJets.begin(),
xAODJetAsIJetFactory());
// make a new CleanerMatcher every event
auto matcher = groupsMatcherFactory(m_conditions);
auto grouper = m_config->getJetGrouper();
auto helper = TrigHLTJetHypoHelper2(m_cleaners,
std::move(grouper),
std::move(matcher));
/* apply cleaning and hypothesis alg */
ATH_MSG_DEBUG("hypo helper start... " << m_chainName
<< " no of jets ... "
<< jets->size()
<< "...");
// steady_clock::time_point t = steady_clock::now();
try{
pass = !jets->empty() && (m_acceptAll || helper.pass(hypoJets));
} catch(std::exception& e){
ATH_MSG_ERROR("Exception raised by the TrigHLTJetHypoHelper2: "
<< e.what());
return StatusCode::FAILURE;
}
// accumulateTime(steady_clock::now() - t);
ATH_MSG_DEBUG("hypo testing done chain " << m_chainName
<< " no of input jets " << jets->size()
<< " pass " << pass );
if(m_dumpJets){writeDebug(pass, helper.passedJets(), helper.failedJets());}
// delete the xAOD::Jet wrappers
for(auto i : hypoJets){delete i;}
return StatusCode::SUCCESS;
}
StatusCode
TrigJetHypoToolMT::decide(const xAOD::JetContainer* jets,
std::unique_ptr<DecisionContainer>& nDecisions,
const DecisionContainer* oDecisions) const{
if(oDecisions->size() != 1) {
ATH_MSG_ERROR ("expected 1 previous decision, found "<< oDecisions->size());
return StatusCode::FAILURE;
}
auto previousDecision = (*oDecisions)[0];
const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{
TrigCompositeUtils::decisionIDs(previousDecision).begin(),
TrigCompositeUtils::decisionIDs( previousDecision ).end()
};
if (TrigCompositeUtils::passed(m_decisionId.numeric(), previousDecisionIDs)){
bool pass;
CHECK(decide(jets, pass));
if (pass) {
auto decision = TrigCompositeUtils::newDecisionIn(nDecisions.get());
TrigCompositeUtils::addDecisionID(m_decisionId, decision);
}
}
return StatusCode::SUCCESS;
}
void TrigJetHypoToolMT::setCleaners() {
// set up a cleaner factory with known jet cleaners
// Allow the configurer to add in new jet cleaners.
if (m_cleaningAlg != "noCleaning"){
CleanerFactory cleanerFactory(//basic cleaning
m_n90Threshold,
m_presamplerThreshold,
m_negativeEThreshold,
//loose cleaning
m_fSampMaxLooseThreshold,
m_etaLooseThreshold,
m_emfLowLooseThreshold,
m_emfHighLooseThreshold,
m_hecfLooseThreshold,
//tight cleaning
m_fSampMaxTightThreshold,
m_etaTightThreshold,
m_emfLowTightThreshold,
m_emfHighTightThreshold,
m_hecfTightThreshold,
//long-lived particle cleaning
m_fSampMaxLlpThreshold,
m_negELlpThreshold,
m_hecfLlpThreshold,
m_hecqLlpThreshold,
m_avLarQFLlpThreshold,
m_cleaningAlg);
m_cleaners.push_back(cleanerFactory.make());
}
auto cleaners = m_config->getCleaners(); // sub class supplied cleaners
m_cleaners.insert(m_cleaners.end(), cleaners.begin(), cleaners.end());
ATH_MSG_INFO("No of Cleaners " << m_cleaners.size());
}
void TrigJetHypoToolMT::writeDebug(bool pass,
const HypoJetVector& passedJets,
const HypoJetVector& failedJets
) const{
ATH_MSG_INFO("Writing debug start" << m_chainName << "...");
if(pass){
std::cout<<m_chainName<< " event passed \n";
} else {
std::cout<<m_chainName<< " event failed \n";
}
for (auto j : passedJets) {
auto p4 = j->p4();
std::cout<<"\nHYPODUMP passed TrigJetHypoToolImp Et: "
<< p4.Et()
<< " eta "
<< j->eta()
<< " px "
<< p4.Px()
<< " py "
<< p4.Py()
<< " pz "
<< p4.Pz()
<< " E "
<< p4.E()
<< '\n';
}
for (auto j : failedJets) {
auto p4 = j->p4();
std::cout<<"\nHYPODUMP failed TrigJetHypoToolImp Et: "
<< p4.Et()
<< " eta "
<< j->eta()
<< " px "
<< p4.Px()
<< " py "
<< p4.Py()
<< " pz "
<< p4.Pz()
<< " E "
<< p4.E()
<< '\n';
}
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGJETHYPOTOOLMT_H
#define TRIGJETHYPOTOOLMT_H
/********************************************************************
*
* NAME: TrigJetHypoToolMT.h
* PACKAGE: Trigger/TrigHypothesis/TrigHLTJetHypo
*
*
*********************************************************************/
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h"
#include "DecisionHandling/HLTIdentifier.h"
#include "AthenaBaseComps/AthAlgTool.h"
#include "DecisionHandling/TrigCompositeUtils.h"
#include "AthenaMonitoring/GenericMonitoringTool.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ICleaner.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/IJetGrouper.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/CleanerBridge.h"
#include "TrigHLTJetHypo/TrigHLTJetHypoUtils/ConditionsDefs.h"
#include "ITrigJetHypoToolMT.h"
#include "ITrigJetHypoToolConfig.h"
class TrigJetHypoToolMT: public extends<AthAlgTool, ITrigJetHypoToolMT> {
public:
TrigJetHypoToolMT(const std::string& type,
const std::string& name,
const IInterface* parent);
virtual ~TrigJetHypoToolMT();
virtual StatusCode initialize() override;
virtual StatusCode finalize() override;
protected:
// ITrigJetHypoToolMT interface
virtual StatusCode decide(const xAOD::JetContainer*,
std::unique_ptr<DecisionContainer>&,
const DecisionContainer*) const override;
private:
HLT::Identifier m_decisionId;
Conditions m_conditions;
bool m_dumpJets{false};
void setCleaners();
void writeDebug(bool,
const HypoJetVector&,
const HypoJetVector&) const;
StatusCode decide(const xAOD::JetContainer*, bool& pass) const;
private:
std::vector<CleanerBridge> m_cleaners;
ToolHandle<ITrigJetHypoToolConfig> m_config {
this, "HypoConfigurer", {}, "Configurer to set up TrigHLTJetHypoHelper2"};
// Cleaning parameters
Gaudi::Property<std::string>
m_cleaningAlg{this, "cleaningAlg", "noCleaning", "Cleaning Alg"};
//basic cleaning
Gaudi::Property<float>
m_n90Threshold{this, "n90CleaningThreshold", 2., "" };
Gaudi::Property<float>
m_presamplerThreshold{this, "presamplerCleaningThreshold", 0.9, ""};
Gaudi::Property<float>
m_negativeEThreshold{this, "negativeECleaningThreshold", -60e3, ""};//60 GeV
Gaudi::Property<float>
m_qmeanThreshold {this, "qmeanCleaningThreshold", 0.8, ""};
Gaudi::Property<float>
m_hecQThreshold {this, "HECQCleaningThreshold", 0.5, ""};
Gaudi::Property<float>
m_hecFThreshold {this, "HECfCleaningThreshold", 0.5, ""};
Gaudi::Property<float>
m_larQThreshol {this, "LArQCleaningThreshold", 0.8, ""};
Gaudi::Property<float>
m_emFThreshold {this, "EMfCleaningThreshold", 0.95, ""};
//loose cleaning
Gaudi::Property<float>
m_fSampMaxLooseThreshold {this, "fracSamplingMaxLooseThreshold", 0.8, ""};
Gaudi::Property<float>
m_etaLooseThreshold{this, "etaLooseThreshold", 2.0, ""};
Gaudi::Property<float>
m_emfLowLooseThreshold{this, "EMfLowLooseThreshold", 0.10, ""};
Gaudi::Property<float>
m_emfHighLooseThreshold{this, "EMfHighLooseThreshold", 0.99, ""};
Gaudi::Property<float>
m_hecfLooseThreshold{this, "HECfLooseThreshold", 0.85, ""};
//tight cleaning
Gaudi::Property<float>
m_fSampMaxTightThreshold{this, "fracSamplingMaxTightThreshold", 0.8, ""};
Gaudi::Property<float>
m_etaTightThreshold {this, "etaTightThreshold", 2.0, ""};
Gaudi::Property<float>
m_emfLowTightThreshold{this, "EMfLowTightThreshold", 0.10, ""};
Gaudi::Property<float>
m_emfHighTightThreshold{this, "EMfHighTightThreshold", 0.99, ""};
Gaudi::Property<float>
m_hecfTightThreshold{this, "HECfTightThreshold", 0.85, ""};
//long-lived particle cleaning
Gaudi::Property<float>
m_fSampMaxLlpThreshold {this, "fracSamplingMaxLlpThreshold", 0.85, ""};
Gaudi::Property<float>
m_negELlpThreshold{this, "negativeELlpThreshold", 10e3, ""}; // 10 GeV
Gaudi::Property<float>
m_hecfLlpThreshold{this, "HECfLlpThreshold", 0.5, ""};
Gaudi::Property<float>
m_hecqLlpThreshold{this, "HECQLlpThreshold", 0.5, ""};
Gaudi::Property<float>
m_avLarQFLlpThreshold{this, "AverageLArQFLlpThreshold", 0.8*65535, ""};
Gaudi::Property<std::string>
m_chainName{this, "chain_name", {}, "chain name (dbg)"};
Gaudi::Property<bool>
m_acceptAll{this, "AcceptAll", false, "flag to turn of hypo"};
// Monitored variables...
/*
declareMonitoredVariable("NJet", m_njet);
declareMonitoredVariable("Et", m_et);
declareMonitoredVariable("Eta", m_eta);
declareMonitoredVariable("Phi", m_phi);
*/
};
#endif
......@@ -11,6 +11,9 @@
#include "../TrigJetHypoAlg.h"
#include "../TrigJetHypoTool_EtaEt.h"
#include "../TrigJetHypoToolConfig_EtaEt.h"
#include "../TrigJetHypoToolMT.h"
DECLARE_COMPONENT( TrigHLTJetHypo2 )
DECLARE_COMPONENT( TrigJetHypoAlg )
......@@ -24,3 +27,6 @@ DECLARE_COMPONENT( TrigHLTJetHypo_TLATool )
DECLARE_COMPONENT( TrigJetHypoTool_EtaEt )
DECLARE_COMPONENT(TrigJetHypoToolMT)
DECLARE_COMPONENT(TrigJetHypoToolConfig_EtaEt)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment