33 typedef ElementLink<xAOD::IParticleContainer>
iplink_t;
54 return StatusCode::FAILURE;
57 std::unique_ptr<METNetHandler> metNetHandler = std::make_unique<METNetHandler>( netFilePath );
58 if( metNetHandler->initialize() != 0){
60 return StatusCode::FAILURE;
62 ATH_MSG_INFO(
"Resolved METNet ONNX file at " + netFilePath);
101 return StatusCode::SUCCESS;
110 return m_metmaker_tight->rebuildMET( metKey, metType, metCont, collection, helper, objScale );
114 const std::string& softClusKey,
115 const std::string& softTrkKey,
125 float avgmu = ei->averageInteractionsPerCrossing();
126 float actmu = ei->actualInteractionsPerCrossing();
129 auto metCont_loose = std::make_shared<xAOD::MissingETContainer>();
130 auto metCont_looseAux = std::make_shared<xAOD::MissingETAuxContainer>();
131 metCont_loose->setStore( metCont_looseAux.get() );
133 auto metCont_tight = std::make_shared<xAOD::MissingETContainer>();
134 auto metCont_tightAux = std::make_shared<xAOD::MissingETAuxContainer>();
135 metCont_tight->setStore( metCont_tightAux.get() );
137 auto metCont_tghtr = std::make_shared<xAOD::MissingETContainer>();
138 auto metCont_tghtrAux = std::make_shared<xAOD::MissingETAuxContainer>();
139 metCont_tghtr->setStore( metCont_tghtrAux.get() );
141 auto metCont_tenac = std::make_shared<xAOD::MissingETContainer>();
142 auto metCont_tenacAux = std::make_shared<xAOD::MissingETAuxContainer>();
143 metCont_tenac->setStore( metCont_tenacAux.get() );
161 ATH_CHECK(
m_metmaker_loose->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_loose.get(), jets, metCoreCont, helper_loose,
true ) );
162 ATH_CHECK(
m_metmaker_tight->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_tight.get(), jets, metCoreCont, helper_tight,
true ) );
163 ATH_CHECK(
m_metmaker_tghtr->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_tghtr.get(), jets, metCoreCont, helper_tghtr,
true ) );
164 ATH_CHECK(
m_metmaker_tenac->rebuildJetMET(
"RefJet", softClusKey, softTrkKey, metCont_tenac.get(), jets, metCoreCont, helper_tenac,
true ) );
181 std::vector<std::string> input_names;
182 std::vector<float> input_values;
199 ATH_MSG_ERROR(
"Could not retrieve primary vertex container!");
200 return StatusCode::FAILURE;
207 n_tracks = vx->nTrackParticles();
208 if ( n_tracks>=2 ) NVx_2Tracks++;
209 if ( n_tracks>=4 ) NVx_4Tracks++;
225 return StatusCode::SUCCESS;
233 if ( (*metCont)[
"NetInputDummy"] == NULL ) {
234 ATH_MSG_ERROR(
"Could not find the NetInputDummy MET object in the container. Did you run rebuildJetMET?" );
235 return StatusCode::FAILURE;
239 std::vector<float> tmp_inputs =
acc_inputvalues(*(*metCont)[
"NetInputDummy"]);
240 ATH_MSG_VERBOSE(
"Loaded " << tmp_inputs.size() <<
" network inputs" );
244 ATH_MSG_ERROR(
"The MET container provided " << tmp_inputs.size()
245 <<
" elements, but the ONNX network needs exactly " <<
m_metNetHandler->getReqSize() <<
"!" );
246 return StatusCode::FAILURE;
250 std::vector<float> net_met;
256 metFinal->
setMpx( net_met[0] );
257 metFinal->
setMpy( net_met[1] );
259 ATH_MSG_VERBOSE(
"Writing the Final Network MET: (" << net_met[0] <<
", " << net_met[1] <<
")" );
261 return StatusCode::SUCCESS;
266 std::vector<std::string>& name_vec,
267 std::vector<float>& val_vec )
const {
274 return StatusCode::SUCCESS;
279 std::vector<std::string>& name_vec,
280 std::vector<float>& val_vec )
const {
283 ATH_MSG_ERROR(
"addMETTerm was called with a null pointer for the input MET value!");
284 return StatusCode::FAILURE;
288 std::string tname = WP_name +
"_" +
met->name();
295 return StatusCode::SUCCESS;
300 std::vector<std::string>& name_vec,
301 std::vector<float>& val_vec )
const {
304 ATH_MSG_VERBOSE(
"Adding variable: " << var_name <<
" = " << value <<
" to the network input vector" );
305 name_vec.push_back( var_name );
306 val_vec.push_back( value );
307 return StatusCode::SUCCESS;
316 const std::string&
name = old_met->name();
319 *(*new_container)[
name] = *(*old_container)[
name];
325 return StatusCode::SUCCESS;
332 ATH_MSG_ERROR(
"METNet has not overloaded this version of rebuildMET from IMETMaker!\n"
333 "Please only use this method:\n"
334 "StatusCode METMaker::rebuildMET("
335 "const std::string& metKey,\n"
336 "xAOD::Type::ObjectType metType,\n"
337 "xAOD::MissingETContainer* metCont,\n"
338 "const xAOD::IParticleContainer* collection,\n"
339 "xAOD::MissingETAssociationHelper& helper,\n"
340 "MissingETBase::UsageHandler::Policy objScale\n"
342 return StatusCode::FAILURE;
351 ATH_MSG_ERROR(
"METNet has not overloaded this version of rebuildMET from IMETMaker!\n"
352 "Please only use this method:\n"
353 "StatusCode METMaker::rebuildMET("
354 "const std::string& metKey,\n"
355 "xAOD::Type::ObjectType metType,\n"
356 "xAOD::MissingETContainer* metCont,\n"
357 "const xAOD::IParticleContainer* collection,\n"
358 "xAOD::MissingETAssociationHelper& helper,\n"
359 "MissingETBase::UsageHandler::Policy objScale\n"
361 return StatusCode::FAILURE;
370 bool doJetJVT)
const {
371 return rebuildJetMET(metJetKey,
"SoftClus",
"PVSoftTrk", metCont, jets, metCoreCont, helper, doJetJVT);
383 std::vector<const xAOD::IParticle*>* )
const {
384 ATH_MSG_ERROR(
"METNet has not overloaded this version of rebuildJetMET from IMETMaker!\n"
385 "Please use the method with the following arguments:\n"
386 "StatusCode METNet::rebuildJetMET(\n"
387 "const std::string& metJetKey,\n"
388 "const std::string& softClusKey,\n"
389 "const std::string& softTrkKey,\n"
390 "xAOD::MissingETContainer* metCont,\n"
391 "const xAOD::JetContainer* jets,\n"
392 "const xAOD::MissingETContainer* metCoreCont,\n"
393 "xAOD::MissingETAssociationHelper& helper,\n"
396 return StatusCode::FAILURE;
406 ATH_MSG_ERROR(
"Please don't use the method METNet::rebuildTrackMET!\n"
407 "It has no use in METNet and is a holdover from its inheritance from IMETMaker." );
408 return StatusCode::FAILURE;
418 return StatusCode::FAILURE;
425 return StatusCode::FAILURE;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
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
StatusCode addMETFinal(const std::string &WP_name, xAOD::MissingETContainer *met_container, std::vector< std::string > &name_vec, std::vector< float > &val_vec) const
std::unique_ptr< const METNetHandler > m_metNetHandler
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
ToolHandle< IMETMaker > m_metmaker_tenac
ToolHandle< IMETMaker > m_metmaker_tghtr
StatusCode copyMETContainer(xAOD::MissingETContainer *new_container, const xAOD::MissingETContainer *old_container) const
virtual StatusCode markInvisible(const xAOD::IParticleContainer *collection, xAOD::MissingETAssociationHelper &helper, xAOD::MissingETContainer *metCont) const override
Gaudi::Property< std::string > m_netLocation
ToolHandle< IMETMaker > m_metmaker_loose
METNet(const std::string &name)
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
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
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainerKey
ToolHandle< IMETMaker > m_metmaker_tight
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
StatusCode addMETTerm(const std::string &WP_name, xAOD::MissingET *met, std::vector< std::string > &name_vec, std::vector< float > &val_vec) const
StatusCode addInputValue(const std::string &var_name, float value, std::vector< std::string > &name_vec, std::vector< float > &val_vec) const
virtual StatusCode evaluateNNMET(const std::string &totalName, xAOD::MissingETContainer *metCont) const override
SG::ReadHandleKey< xAOD::VertexContainer > m_pvContainerKey
void setMpy(float value)
Set the component.
void setMpx(float value)
Set the component.
uint64_t bitmask_t
Type for status word bit mask.
Policy
Policies on usage checks.
ElementLink< xAOD::IParticleContainer > iplink_t
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::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 total(Region reg=Region::FullAcceptance)
Standard full reconstructed MET.
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.