32 ATH_MSG_INFO(
"Loading all tunings configs from " << configFile );
35 if (configFile.empty()){
36 ATH_MSG_ERROR(
"Could not locate the config file: " << configFile);
37 return StatusCode::FAILURE;
41 TEnv env(configFile.c_str());
47 unsigned size = env.GetValue(
"Model__size" , 0 );
59 auto model_paths =
GetPaths(
"Model__path", env );
62 for (
unsigned idx = 0; idx < size; ++idx )
66 auto model =
Ringer::onnx::Model( modelPath, svc, etmin[idx], etmax[idx], etamin[idx], etamax[idx], PreprocessingMode[idx]) ;
76 unsigned size = env.GetValue(
"Threshold__size" , 0);
90 for (
unsigned idx = 0; idx <size; ++idx ){
103 return StatusCode::SUCCESS;
116 if (
et < cutDef.etMin()*Gaudi::Units::GeV ||
et >= cutDef.etMax()*Gaudi::Units::GeV )
continue;
117 if (
eta < cutDef.etaMin() ||
eta >= cutDef.etaMax() )
continue;
118 return cutDef.accept( discr, avgmu );
134 if(
et<model.etMin()*Gaudi::Units::GeV ||
et >= model.etMax()*Gaudi::Units::GeV )
continue;
135 if(
eta<model.etaMin() ||
eta >= model.etaMax())
continue;
136 auto inputs =
prepare_inputs( model.barcode(), ringsCluster, el );
137 auto output = model.predict( inputs );
138 ATH_MSG_DEBUG(
"The current model predict with output: " << output );
142 ATH_MSG_DEBUG(
"There is no model available for this cluster.");
155 std::vector< std::vector< float > > inputs;
158 if ( PreprocessingMode == 0 ){
159 const std::vector<float> rings = ringsCluster->
rings();
160 std::vector<float> refRings(rings.size());
161 refRings.assign(rings.begin(), rings.end());
163 for(
auto &ring : refRings ) energy+=ring;
166 for(
auto &ring : refRings ) ring/=energy;
169 inputs.push_back( refRings );
172 }
else if ( PreprocessingMode == 1){
174 const std::vector<float> rings = ringsCluster->
rings();
175 std::vector<float> refRings(rings.size());
176 refRings.assign(rings.begin(), rings.end());
178 std::vector<float> halfRings;
180 constexpr int PS = 8;
181 constexpr int EM1 = 64;
182 constexpr int EM2 = 8;
183 constexpr int EM3 = 8;
184 constexpr int HAD1 = 4;
185 constexpr int HAD2 = 4;
186 constexpr int HAD3 = 4;
188 halfRings.insert(halfRings.end(), refRings.begin(), refRings.begin() +
PS/2);
189 halfRings.insert(halfRings.end(), refRings.begin() +
PS, refRings.begin() +
PS + (
EM1/2));
190 halfRings.insert(halfRings.end(), refRings.begin() +
PS +
EM1, refRings.begin() +
PS +
EM1 + (
EM2/2));
191 halfRings.insert(halfRings.end(), refRings.begin() +
PS +
EM1 +
EM2, refRings.begin() +
PS +
EM1 +
EM2 + (
EM3/2));
192 halfRings.insert(halfRings.end(), refRings.begin() +
PS +
EM1 +
EM2 +
EM3, refRings.begin() +
PS +
EM1 +
EM2 +
EM3 + (
HAD1/2));
198 for(
auto &ring : halfRings ) energy+=ring;
201 for(
auto &ring : halfRings ) ring/=energy;
204 inputs.push_back( halfRings );
219 std::string tmp = input;
220 std::string::size_type first(0);
221 std::string::size_type last(0);
222 first = ( input.find(
'#') ) ;
225 if (first == std::string::npos) {
226 std::istringstream buffer (tmp);
232 last = (input.find(
'#',first+1) );
234 if (last == std::string::npos) {
238 diff = last - first ;
239 tmp= tmp.erase(first,
diff+1);
240 std::istringstream buffer (tmp);
249 std::vector<T> CutVector;
250 std::string env_input(env.GetValue(input.c_str(),
""));
251 if (!env_input.empty()) {
252 std::string::size_type end;
254 end = env_input.find(
';');
256 if(
strtof(env_input.substr(0,end),myValue)){
257 CutVector.push_back(myValue);
259 if (end != std::string::npos) {
260 env_input= env_input.substr(end+1);
262 }
while (end != std::string::npos);
271 std::vector<std::string> CutVector;
272 std::string env_input(env.GetValue(input.c_str(),
""));
273 if (!env_input.empty()) {
274 std::string::size_type end;
276 end = env_input.find(
';');
277 CutVector.push_back( env_input.substr(0,end) );
278 if (end != std::string::npos) {
279 env_input= env_input.substr(end+2);
281 }
while (end != std::string::npos);
288 std::string ret = std::filesystem::path(path).parent_path().lexically_normal().string();
289 if (!ret.empty() && ret.front()==
'/') ret.erase(0, 1);
Scalar eta() const
pseudorapidity method
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Service used for managing global objects used by Onnx Runtime.
std::vector< T > GetValues(const std::string &input, TEnv &env)
Get the list of values inside of tenv.
StatusCode read_from(const std::string &, AthOnnx::IOnnxRuntimeSvc *)
read tunings from configuration file
bool accept(const xAOD::TrigRingerRings *, float discr, float mu) const
Accept method.
float predict(const xAOD::TrigRingerRings *, const xAOD::TrigElectron *) const
Calculation of model output.
RingerSelector(const std::string &name)
Standard constructor.
std::vector< std::string > GetPaths(const std::string &input, TEnv &env)
Get the list of paths inside of tenv.
std::vector< Ringer::onnx::Model > m_models
hold all onnx sessions
std::vector< Ringer::onnx::Threshold > m_thresholds
hold all thresholds definitions
bool strtof(const std::string &input, T &f)
parse tenv string into list with type T
std::vector< std::vector< float > > prepare_inputs(unsigned barcode, const xAOD::TrigRingerRings *, const xAOD::TrigElectron *) const
prepare all inputs
std::string GetBasePath(const std::string &path) const
Get basepath from calib path.
AsgMessaging(const std::string &name)
Constructor with a name.
float et() const
get Et (calibrated)
float eta() const
get Eta (calibrated)
const TrigEMCluster * emCluster() const
The associated EM cluster, as a simple pointer.
const std::vector< float > & rings() const
Acessor methods.
Namespace dedicated for Ringer utilities.
TrigRingerRings_v2 TrigRingerRings
Define the latest version of the TrigRingerRings class.
TrigElectron_v1 TrigElectron
Declare the latest version of the class.
Extra patterns decribing particle interation process.