 |
ATLAS Offline Software
|
#include <GlobalLargeRDNNCalibration.h>
◆ GlobalLargeRDNNCalibration() [1/3]
| GlobalLargeRDNNCalibration::GlobalLargeRDNNCalibration |
( |
| ) |
|
The constructor.
Constructors.
Note that this doesn't have all the necessary information, so it will not configure things correctly.
Definition at line 186 of file GlobalLargeRDNNCalibration.cxx.
◆ GlobalLargeRDNNCalibration() [2/3]
| GlobalLargeRDNNCalibration::GlobalLargeRDNNCalibration |
( |
const std::string & |
name | ) |
|
The constructor.
Note that this doesn't have all the necessary information, so it will not configure things correctly.
- Parameters
-
| name | The name of the tool being created |
Definition at line 192 of file GlobalLargeRDNNCalibration.cxx.
◆ GlobalLargeRDNNCalibration() [3/3]
| GlobalLargeRDNNCalibration::GlobalLargeRDNNCalibration |
( |
const std::string & |
name, |
|
|
TEnv * |
config, |
|
|
const TString & |
calibArea, |
|
|
bool |
dev |
|
) |
| |
The constructor, which is used by the JetCalibrationTool.
- Parameters
-
| name | The name of the tool being created |
| config | The name of the config file for the calibration |
| jetAlgo | The name of the jet collection |
| calibAreaTag | The tag for this calibration |
| dev | A flag for if the calibration is run in development mode |
Definition at line 198 of file GlobalLargeRDNNCalibration.cxx.
◆ ~GlobalLargeRDNNCalibration()
| GlobalLargeRDNNCalibration::~GlobalLargeRDNNCalibration |
( |
| ) |
|
|
virtual |
◆ calibrate()
Implements JetCalibrationStep.
Definition at line 322 of file GlobalLargeRDNNCalibration.cxx.
327 jetStartP4 =
jet.jetP4();
330 if(
jet.m()<=0 ||
jet.numConstituents()==1){
332 return StatusCode::SUCCESS;
339 for (
long unsigned int i=0;
i<input_tensor_values.size();
i++)
ATH_MSG_DEBUG(
" " << input_tensor_values[
i]);
343 int nNan = std::count_if(input_tensor_values.begin(), input_tensor_values.end(), [](
float f){return std::isnan(f) || std::isinf(f);});
345 ATH_MSG_WARNING(
"Encountered Nan or inf value in input features, will not apply calibration");
347 return StatusCode::SUCCESS;
351 Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeCPU);
352 Ort::Value input_tensor = Ort::Value::CreateTensor<float>( memory_info,
353 input_tensor_values.data(),
354 input_tensor_values.size(),
359 std::vector<float>
vec(input_tensor.GetTensorMutableData<
float>(), input_tensor.GetTensorMutableData<
float>() +
m_input_node_dims[1]);
360 if (
vec!=input_tensor_values) {
361 ATH_MSG_WARNING(
"Input tensor after convertion to Ort tensor is not the same as the input vector, will not apply calibration");
363 return StatusCode::SUCCESS;
368 auto output_tensor = session.Run( Ort::RunOptions{
nullptr},
375 ATH_MSG_WARNING(
"Output tensor does not have the same size as output layer, will not apply calibration");
377 return StatusCode::SUCCESS;
381 float* outputE = output_tensor.at(0).GetTensorMutableData<
float>();
382 float* outputM = output_tensor.at(1).GetTensorMutableData<
float>();
385 float predRespE = outputE[0];
386 float predRespM = outputM[0];
392 if (predRespE==0 || predRespM==0) {
393 ATH_MSG_WARNING(
"Predictions give 0 values, will not apply calibration");
395 return StatusCode::SUCCESS;
399 float calibE = jetStartP4.e() / predRespE;
402 float calibM = jetStartP4.mass();
403 if ( calibM > 40000 ) {
408 float calibpT = std::sqrt( calibE*calibE - calibM*calibM )/std::cosh( jetStartP4.eta() );
411 TLorentzVector TLVjet;
412 TLVjet.SetPtEtaPhiM( calibpT, jetStartP4.eta(), jetStartP4.phi(), calibM );
414 calibP4.SetPxPyPzE( TLVjet.Px(), TLVjet.Py(), TLVjet.Pz(), TLVjet.E() );
418 jet.setJetP4( calibP4 );
420 return StatusCode::SUCCESS;
◆ getJetFeatures()
| std::vector< float > GlobalLargeRDNNCalibration::getJetFeatures |
( |
xAOD::Jet & |
jet_reco, |
|
|
JetEventInfo & |
jetEventInfo |
|
) |
| const |
|
private |
Returns a vector of input features for the NN.
- Parameters
-
| jet_reco | The jet |
| jetEventInfo | A set of information about the event and jet |
Definition at line 426 of file GlobalLargeRDNNCalibration.cxx.
428 std::vector<float> input_tensor_values(
m_NNInputs.size());
431 for(
size_t i=0;
i<input_tensor_values.size();
i++){
437 return input_tensor_values;
◆ getNominalResolutionData()
| StatusCode JetCalibrationStep::getNominalResolutionData |
( |
const xAOD::Jet & |
, |
|
|
double & |
|
|
) |
| const |
|
virtualinherited |
◆ getNominalResolutionMC()
| StatusCode JetCalibrationStep::getNominalResolutionMC |
( |
const xAOD::Jet & |
, |
|
|
double & |
|
|
) |
| const |
|
virtualinherited |
◆ initialize()
| StatusCode GlobalLargeRDNNCalibration::initialize |
( |
| ) |
|
|
overridevirtual |
Returns the charged fraction of a jet.
- Parameters
-
| name | The name of the tool being created |
Implements JetCalibrationStep.
Definition at line 210 of file GlobalLargeRDNNCalibration.cxx.
212 if ( !
m_config ) {
ATH_MSG_FATAL(
"Config file not specified. Aborting.");
return StatusCode::FAILURE; }
230 ATH_MSG_FATAL(
"Misconfiguration of config file : not same number of offset/scale parameters and number of features. Will exit");
231 return StatusCode::FAILURE;
249 std::string modelPath =
"";
260 m_session = CreateORTSession(fullModelPath);
266 std::tuple<std::vector<int64_t>, std::vector<const char*> > inputInfo = GetInputNodeInfo(
m_session);
285 std::tuple<std::vector<int64_t>, std::vector<const char*> > outputInfo = GetOutputNodeInfo(
m_session);
310 ATH_MSG_FATAL(
"DNN input features not the same size as in config, will exit");
311 return StatusCode::FAILURE;
317 return StatusCode::SUCCESS;
◆ initMessaging()
| void AthMessaging::initMessaging |
( |
| ) |
const |
|
privateinherited |
Initialize our message level and MessageSvc.
This method should only be called once.
Definition at line 42 of file AthMessaging.cxx.
◆ msg() [1/2]
| MsgStream & asg::AsgMessaging::msg |
( |
| ) |
const |
|
inherited |
The standard message stream.
- Returns
- A reference to the default message stream of this object.
Definition at line 49 of file AsgMessaging.cxx.
50 #ifndef XAOD_STANDALONE
52 #else // not XAOD_STANDALONE
54 #endif // not XAOD_STANDALONE
◆ msg() [2/2]
| MsgStream & asg::AsgMessaging::msg |
( |
const MSG::Level |
lvl | ) |
const |
|
inherited |
The standard message stream.
- Parameters
-
| lvl | The message level to set the stream to |
- Returns
- A reference to the default message stream, set to level "lvl"
Definition at line 57 of file AsgMessaging.cxx.
58 #ifndef XAOD_STANDALONE
60 #else // not XAOD_STANDALONE
63 #endif // not XAOD_STANDALONE
◆ msgLvl()
| bool asg::AsgMessaging::msgLvl |
( |
const MSG::Level |
lvl | ) |
const |
|
inherited |
Test the output level of the object.
- Parameters
-
| lvl | The message level to test against |
- Returns
- boolean Indicting if messages at given level will be printed
-
true If messages at level "lvl" will be printed
Definition at line 41 of file AsgMessaging.cxx.
42 #ifndef XAOD_STANDALONE
43 return ::AthMessaging::msgLvl( lvl );
44 #else // not XAOD_STANDALONE
45 return m_msg.msgLevel( lvl );
46 #endif // not XAOD_STANDALONE
◆ setLevel()
| void AthMessaging::setLevel |
( |
MSG::Level |
lvl | ) |
|
|
inherited |
◆ setStartP4()
| StatusCode JetCalibrationStep::setStartP4 |
( |
xAOD::Jet & |
jet | ) |
const |
|
protectedvirtualinherited |
Definition at line 21 of file JetCalibrationStep.cxx.
24 return StatusCode::SUCCESS;
27 return StatusCode::SUCCESS;
30 return StatusCode::FAILURE;
◆ setUnitsGeV()
| virtual void JetCalibrationStep::setUnitsGeV |
( |
bool |
useGeV | ) |
|
|
inlinevirtualinherited |
◆ ATLAS_THREAD_SAFE
| std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT |
|
mutableprivateinherited |
◆ m_calibArea
| std::string GlobalLargeRDNNCalibration::m_calibArea |
|
private |
◆ m_config
| TEnv* GlobalLargeRDNNCalibration::m_config {} |
|
private |
◆ m_devMode
| bool GlobalLargeRDNNCalibration::m_devMode {} |
|
private |
◆ m_eScales
| std::vector<double> GlobalLargeRDNNCalibration::m_eScales |
|
private |
◆ m_GeV
| double JetCalibrationStep::m_GeV |
|
protectedinherited |
◆ m_imsg
| std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr } |
|
mutableprivateinherited |
◆ m_input_node_dims
| std::vector<int64_t> GlobalLargeRDNNCalibration::m_input_node_dims |
|
private |
◆ m_input_node_names
| std::vector<const char*> GlobalLargeRDNNCalibration::m_input_node_names |
|
private |
◆ m_jetStartScale
| std::string JetCalibrationStep::m_jetStartScale |
|
protectedinherited |
◆ m_lvl
| std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL } |
|
mutableprivateinherited |
◆ m_modelFileName
| std::string GlobalLargeRDNNCalibration::m_modelFileName |
|
private |
◆ m_msg_tls
| boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls |
|
mutableprivateinherited |
MsgStream instance (a std::cout like with print-out levels)
Definition at line 132 of file AthMessaging.h.
◆ m_name
| std::string JetCalibrationStep::m_name |
|
protectedinherited |
◆ m_nm
| std::string AthMessaging::m_nm |
|
privateinherited |
◆ m_NNInputs
| std::vector<TString> GlobalLargeRDNNCalibration::m_NNInputs |
|
private |
◆ m_NormOffsets
| std::vector<double> GlobalLargeRDNNCalibration::m_NormOffsets |
|
private |
◆ m_NormScales
| std::vector<double> GlobalLargeRDNNCalibration::m_NormScales |
|
private |
◆ m_output_node_dims
| std::vector<int64_t> GlobalLargeRDNNCalibration::m_output_node_dims |
|
private |
◆ m_output_node_names
| std::vector<const char*> GlobalLargeRDNNCalibration::m_output_node_names |
|
private |
◆ m_session
| std::unique_ptr< Ort::Session > GlobalLargeRDNNCalibration::m_session |
|
private |
◆ m_varretrievers
| std::vector<VarRetriever*> GlobalLargeRDNNCalibration::m_varretrievers |
|
private |
The documentation for this class was generated from the following files:
std::atomic< MSG::Level > m_lvl
Current logging level.
std::vector< VarRetriever * > m_varretrievers
std::vector< double > m_eScales
bool msgLvl(const MSG::Level lvl) const
Test the output level of the object.
std::vector< float > getJetFeatures(xAOD::Jet &jet_reco, JetEventInfo &jetEventInfo) const
Returns a vector of input features for the NN.
virtual StatusCode setStartP4(xAOD::Jet &jet) const
std::vector< int64_t > m_output_node_dims
std::vector< double > m_NormScales
std::vector< size_t > vec
std::vector< const char * > m_output_node_names
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
StrV Vectorize(const TString &str, const TString &sep=" ")
IMessageSvc * getMessageSvc(bool quiet=false)
std::atomic_flag m_initialized ATLAS_THREAD_SAFE
Messaging initialized (initMessaging)
std::vector< int64_t > m_input_node_dims
std::vector< double > m_NormOffsets
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
JetCalibrationStep(const char *name="JetCalibrationStep")
std::vector< TString > m_NNInputs
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
std::string m_jetStartScale
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
#define ATH_MSG_WARNING(x)
std::string m_nm
Message source name.
std::unique_ptr< Ort::Session > m_session
std::string m_modelFileName
VecD VectorizeD(const TString &str, const TString &sep=" ")
void initMessaging() const
Initialize our message level and MessageSvc.
std::vector< const char * > m_input_node_names