61 ATH_MSG_WARNING(
"You are loading a dummy/untrained METNetSig network! This should only be done when testing the code!\n"
62 " -- If you wish to load a trained network please specify a path to an onnx file using the 'NetworkLocation' argument.\n"
63 " -- A list of supported networks can be found at atlas-groupdata.web.cern.ch/atlas-groupdata/METUtilities/run2_13TeV/METNet/" );
75 return StatusCode::FAILURE;
114 return StatusCode::SUCCESS;
127 if ( (*metCont)[metKey] !=
nullptr ) {
128 ATH_MSG_DEBUG(
"MET term '" << metKey <<
"' already exists in the container — skipping rebuild in METNetSig.");
129 return StatusCode::SUCCESS;
132 return m_metmaker_tight->rebuildMET( metKey, metType, metCont, collection, helper, objScale );
136 const std::string& softClusKey,
137 const std::string& softTrkKey,
147 float avgmu = ei->averageInteractionsPerCrossing();
148 float actmu = ei->actualInteractionsPerCrossing();
153 auto metCont_loose = std::make_unique<xAOD::MissingETContainer>();
154 auto metCont_looseAux = std::make_unique<xAOD::MissingETAuxContainer>();
155 metCont_loose->setStore( metCont_looseAux.get() );
157 auto metCont_tight = std::make_unique<xAOD::MissingETContainer>();
158 auto metCont_tightAux = std::make_unique<xAOD::MissingETAuxContainer>();
159 metCont_tight->setStore( metCont_tightAux.get() );
161 auto metCont_tghtr = std::make_unique<xAOD::MissingETContainer>();
162 auto metCont_tghtrAux = std::make_unique<xAOD::MissingETAuxContainer>();
163 metCont_tghtr->setStore( metCont_tghtrAux.get() );
165 auto metCont_tenac = std::make_unique<xAOD::MissingETContainer>();
166 auto metCont_tenacAux = std::make_unique<xAOD::MissingETAuxContainer>();
167 metCont_tenac->setStore( metCont_tenacAux.get() );
185 ATH_CHECK(
m_metmaker_loose->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_loose.get(), jets, metCoreCont, helper_loose,
true ) );
186 ATH_CHECK(
m_metmaker_tight->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_tight.get(), jets, metCoreCont, helper_tight,
true ) );
187 ATH_CHECK(
m_metmaker_tghtr->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_tghtr.get(), jets, metCoreCont, helper_tghtr,
true ) );
188 ATH_CHECK(
m_metmaker_tenac->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_tenac.get(), jets, metCoreCont, helper_tenac,
true ) );
205 std::vector<std::string> input_names;
206 std::vector<float> input_values;
223 ATH_MSG_ERROR(
"Could not retrieve primary vertex container!");
224 return StatusCode::FAILURE;
231 n_tracks = vx->nTrackParticles();
232 if ( n_tracks>=2 ) NVx_2Tracks++;
233 if ( n_tracks>=4 ) NVx_4Tracks++;
245 if ( (*metCont)[
"NetInputDummy"] != NULL ) {
247 ATH_MSG_DEBUG(
"NetInputDummy already present in container — erasing and recreating.");
248 auto it = metCont->
find(
"NetInputDummy");
249 if ( it != metCont->
end() ) metCont->
erase(it);
254 return StatusCode::SUCCESS;
258 float& met_x,
float& met_y,
float& sigma_x,
float& sigma_y)
const
263 if ( (*metCont)[
"NetInputDummy"] == NULL ) {
264 ATH_MSG_ERROR(
"Could not find the NetInputDummy MET object in the container. Did you run rebuildJetMET?" );
265 return StatusCode::FAILURE;
270 std::vector<float> tmp_inputs =
acc_inputvalues(*(*metCont)[
"NetInputDummy"]);
271 ATH_MSG_VERBOSE(
"Loaded " << tmp_inputs.size() <<
" network inputs" );
275 ATH_MSG_ERROR(
"The MET container provided " << tmp_inputs.size()
276 <<
" elements, but the ONNX network needs exactly " <<
m_metnetsighandler->getReqSize() <<
"!" );
277 return StatusCode::FAILURE;
289 sigma_x = net_met[2];
290 sigma_y = net_met[3];
292 ATH_MSG_DEBUG(
"Writing the Final Network MET: (" << met_x <<
", " << met_y <<
", " << sigma_x <<
", " << sigma_y <<
")" );
294 return StatusCode::SUCCESS;
301 std::vector<std::string>& name_vec,
302 std::vector<float>& val_vec )
const
310 return StatusCode::SUCCESS;
315 std::vector<std::string>& name_vec,
316 std::vector<float>& val_vec )
const
319 std::string tname = WP_name +
"_" +
acc_name(*
met);
326 return StatusCode::SUCCESS;
331 std::vector<std::string>& name_vec,
332 std::vector<float>& val_vec )
const
336 ATH_MSG_VERBOSE(
"Adding variable: " << var_name <<
" = " << value <<
" to the network input vector" );
337 name_vec.push_back( var_name );
338 val_vec.push_back( value );
339 return StatusCode::SUCCESS;
351 for (
const auto& old_met : *old_container ) {
356 *(*new_container)[
name] = *(*old_container)[
name];
362 return StatusCode::SUCCESS;
372 ATH_MSG_ERROR(
"METNetSig has not overloaded this version of rebuildMET from IMETMaker!\n"
373 "Please only use this method:\n"
374 "StatusCode METMaker::rebuildMET("
375 "const std::string& metKey,\n"
376 "xAOD::Type::ObjectType metType,\n"
377 "xAOD::MissingETContainer* metCont,\n"
378 "const xAOD::IParticleContainer* collection,\n"
379 "xAOD::MissingETAssociationHelper& helper,\n"
380 "MissingETBase::UsageHandler::Policy objScale\n"
382 return StatusCode::FAILURE;
393 ATH_MSG_ERROR(
"METNetSig has not overloaded this version of rebuildMET from IMETMaker!\n"
394 "Please only use this method:\n"
395 "StatusCode METMaker::rebuildMET("
396 "const std::string& metKey,\n"
397 "xAOD::Type::ObjectType metType,\n"
398 "xAOD::MissingETContainer* metCont,\n"
399 "const xAOD::IParticleContainer* collection,\n"
400 "xAOD::MissingETAssociationHelper& helper,\n"
401 "MissingETBase::UsageHandler::Policy objScale\n"
403 return StatusCode::FAILURE;
414 return rebuildJetMET(metJetKey,
"SoftClus",
"PVSoftTrk", metCont, jets, metCoreCont, helper, doJetJVT);
426 std::vector<const xAOD::IParticle*>* )
const
428 ATH_MSG_ERROR(
"METNetSig has not overloaded this version of rebuildJetMET from IMETMaker!\n"
429 "Please use the method with the following arguments:\n"
430 "StatusCode METNetSig::rebuildJetMET(\n"
431 "const std::string& metJetKey,\n"
432 "const std::string& softClusKey,\n"
433 "const std::string& softTrkKey,\n"
434 "xAOD::MissingETContainer* metCont,\n"
435 "const xAOD::JetContainer* jets,\n"
436 "const xAOD::MissingETContainer* metCoreCont,\n"
437 "xAOD::MissingETAssociationHelper& helper,\n"
440 return StatusCode::FAILURE;
451 ATH_MSG_ERROR(
"Please dont use the method METNetSig::rebuildTrackMET!\n"
452 "It has no use in METNetSig and is a holdover from it's inheritance from IMETMaker." );
453 return StatusCode::FAILURE;
464 return StatusCode::FAILURE;
472 return StatusCode::FAILURE;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
iterator erase(iterator position)
Remove element at a given position.
ElementLink implementation for ROOT usage.
SG::ConstAccessor< T, ALLOC > ConstAccessor
SG::Decorator< T, ALLOC > Decorator
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode setProperty(const std::string &name, const T &value)
set the given property
Gaudi::Property< std::string > m_netSigLocation
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainerKey
ToolHandle< IMETMaker > m_metmaker_loose
StatusCode addMETTerm(const std::string &WP_name, xAOD::MissingET *met, std::vector< std::string > &name_vec, std::vector< float > &val_vec) const
ToolHandle< IMETMaker > m_metmaker_tenac
SG::ReadHandleKey< xAOD::VertexContainer > m_pvContainerKey
virtual StatusCode initialize() override
Athena algtool's initialize.
StatusCode copyMETContainer(xAOD::MissingETContainer *new_container, const xAOD::MissingETContainer *old_container) const
ToolHandle< IMETMaker > m_metmaker_tight
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
virtual StatusCode rebuildTrackMET(const std::string &metJetKey, const std::string &softTrkKey, xAOD::MissingETContainer *metCont, const xAOD::JetContainer *jets, const xAOD::MissingETContainer *metCoreCont, xAOD::MissingETAssociationHelper &helper, bool doJetJVT) const override
Unsuported method inherited from METMaker. Please do not use.
virtual StatusCode rebuildJetMET(const std::string &metJetKey, const std::string &softTrkKey, xAOD::MissingETContainer *metCont, const xAOD::JetContainer *jets, const xAOD::MissingETContainer *metCoreCont, xAOD::MissingETAssociationHelper &helper, bool doJetJVT=false) const override
Adds multiple jet definitions to seperate MET containers and creates the collection of input features...
virtual StatusCode evaluateNNMETSig(xAOD::MissingETContainer *metCont, float &met_x, float &met_y, float &sigma_x, float &sigma_y) const
Uses ONNX runtime to propagate the input features created in rebuildJetMET through the trained networ...
std::unique_ptr< METNetSigHandler > m_metnetsighandler
virtual ~METNetSig() override
Destructor.
virtual StatusCode markInvisible(const xAOD::IParticleContainer *collection, xAOD::MissingETAssociationHelper &helper, xAOD::MissingETContainer *metCont) const override
Unsuported method inherited from METMaker. Please do not use.
StatusCode addMETFinal(const std::string &WP_name, xAOD::MissingETContainer *met_container, std::vector< std::string > &name_vec, std::vector< float > &val_vec) const
virtual StatusCode rebuildMET(const std::string &metKey, xAOD::Type::ObjectType metType, xAOD::MissingETContainer *metCont, const xAOD::IParticleContainer *collection, xAOD::MissingETAssociationHelper &helper, MissingETBase::UsageHandler::Policy objScale) const override
Adds a collection of objects to the core MET container, must be done for photons, elections and muons...
ToolHandle< IMETMaker > m_metmaker_tghtr
StatusCode addInputValue(const std::string &var_name, float value, std::vector< std::string > &name_vec, std::vector< float > &val_vec) const
const_iterator find(const std::string &name) const
Find non-modifiable MET object by name.
uint64_t bitmask_t
Type for status word bit mask.
Policy
Policies on usage checks.
ElementLink< xAOD::IParticleContainer > iplink_t
static const SG::AuxElement::ConstAccessor< MissingETBase::Types::bitmask_t > acc_source("source")
StatusCode buildMETSum(const std::string &totalName, xAOD::MissingETContainer *metCont)
static const SG::AuxElement::ConstAccessor< std::vector< float > > acc_inputvalues("input_values")
static const SG::AuxElement::ConstAccessor< std::string > acc_name("name")
static const SG::AuxElement::Decorator< std::vector< std::string > > dec_inputnames("input_names")
static const SG::AuxElement::Accessor< std::vector< iplink_t > > dec_constitObjLinks("ConstitObjectLinks")
static const SG::AuxElement::Decorator< std::vector< float > > dec_inputvalues("input_values")
static const SG::AuxElement::ConstAccessor< std::vector< iplink_t > > acc_constitObjLinks("ConstitObjectLinks")
static const SG::AuxElement::ConstAccessor< std::vector< std::string > > acc_inputnames("input_names")
StatusCode fillMET(xAOD::MissingET *&met, xAOD::MissingETContainer *metCont, const std::string &metKey, const MissingETBase::Types::bitmask_t metSource)
ObjectType
Type of objects that have a representation in the xAOD EDM.
MissingET_v1 MissingET
Version control by type defintion.
Vertex_v1 Vertex
Define the latest version of the vertex class.
MissingETContainer_v1 MissingETContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
static Types::bitmask_t muon(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed muons.
static Types::bitmask_t tau(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed tau leptons.
static Types::bitmask_t electron(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed electrons.
static Types::bitmask_t photon(Region reg=Region::FullAcceptance)
Standard MET term from reconstructed photons.
@ LCTopo
Indicator for MET contribution from TopoClusters with LCW calibration applied.
@ Track
Indicator for MET contribution from reconstructed charged particle tracks.