14#include "CLHEP/Random/RandGauss.h"
16#include "TFitResult.h"
71 std::string inputFileName;
79 inputFileName = std::format(
"{}/neural_net_{}_eta_{}_{}_All.*",
88 }
else if (
m_pid == 2212) {
89 inputFileName = std::format(
"{}/neural_net_{}_eta_{}_{}_High10.*",
99 inputFileName = std::format(
"{}/neural_net_{}_eta_{}_{}_High12.*",
109 inputFileName = std::format(
"{}/neural_net_{}_eta_{}_{}_UltraLow12.*",
122 std::string rootFileName = std::format(
"{}/rootFiles/pid{}_E1048576_eta_{}_{}.root",
128 std::unique_ptr<TFile>
file (TFile::Open(rootFileName.c_str(),
"read"));
130 throw std::runtime_error(std::format(
"Failed to open or initialize ROOT file: {}", rootFileName));
132 for (
int layer :
m_param.GetRelevantLayers()) {
135 TH2D *h2 = &binsInLayers[layer];
137 std::string histoName = std::format(
"r{}w", layer);
138 TH1D *h1 = (TH1D *)
file->Get(histoName.c_str());
139 if (std::isnan(h1->Integral())) {
140 histoName = std::format(
"r{}", layer);
141 h1 = (TH1D *)
file->Get(histoName.c_str());
144 TAxis *
x = (TAxis *)h2->GetXaxis();
145 for (
int ix = 1; ix <= h2->GetNbinsX(); ++ix) {
147 h1->GetXaxis()->SetRangeUser(
x->GetBinLowEdge(ix),
x->GetBinUpEdge(ix));
150 if (h1->Integral() > 0 && h1->GetNbinsX() > 2) {
151 TFitResultPtr
res(0);
153 res = h1->Fit(
"expo",
"SQ");
154 if (
res >= 0 && !std::isnan(
res->Parameter(0))) {
155 result =
res->Parameter(1);
165 std::string rootFileName = std::format(
"{}/rootFiles/pid{}_E65536_eta_{}_{}_validation.root",
171 std::unique_ptr<TFile>
file (TFile::Open(rootFileName.c_str(),
"read"));
173 throw std::runtime_error(std::format(
"Failed to open or initialize ROOT file: {}", rootFileName));
175 for (
int layer :
m_param.GetRelevantLayers()) {
176 TH1D *
h =
new TH1D(
"h",
"h", 100, 0.01, 1);
177 TTree *
tree = (TTree *)
file->Get(
"rootTree");
178 std::string command = std::format(
"extrapWeight_{}>>h", layer);
179 tree->Draw(command.c_str());
190 double randUniformZ = 0.;
193 int maxExp = 0, minExp = 0;
204 }
else if (std::abs(
m_pid) == 211) {
207 }
else if (std::abs(
m_pid) == 2212) {
212 int p_min = std::pow(2, minExp);
213 int p_max = std::pow(2, maxExp);
216 std::sqrt(std::pow(p_min, 2) + std::pow(truth->M(), 2)) - truth->M();
218 std::sqrt(std::pow(p_max, 2) + std::pow(truth->M(), 2)) - truth->M();
219 for (
int i = 0; i <
m_param.GetLatentSpaceSize(); i++) {
220 randUniformZ = CLHEP::RandGauss::shoot(simulstate.
randomEngine(), 0.5, 0.5);
221 inputs[
"Noise"].insert(std::pair<std::string, double>(
222 "variable_" + std::to_string(i), randUniformZ));
234 inputs[
"mycond"].insert(std::pair<std::string, double>(
235 "variable_0", log(truth->
Ekin() / Ekin_min) / log(Ekin_max / Ekin_min)));
237 if (
m_param.GetGANVersion() >= 2) {
241 inputs[
"mycond"].insert(std::pair<std::string, double>(
244 inputs[
"mycond"].insert(std::pair<std::string, double>(
"variable_1", 0));
std::pair< std::vector< unsigned int >, bool > res
Header file for AthHistogramAlgorithm.
VNetworkBase * GetNetAll() const
TFCSGANLWTNNHandler * m_gan_all
TFCSGANLWTNNHandler * m_gan_low
NetworkOutputs GetNetworkOutputs(const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol, TFCSSimulationState &simulstate) const
TFCSGANLWTNNHandler * m_gan_high
std::unique_ptr< VNetworkBase > m_net_high
std::unique_ptr< VNetworkBase > m_net_all
void CalculateMeanPointFromDistributionOfR()
virtual ~TFCSGANEtaSlice()
std::unique_ptr< VNetworkBase > m_net_low
ExtrapolatorWeights m_extrapolatorWeights
bool IsGanCorrectlyLoaded() const
VNetworkBase * GetNetLow() const
std::map< std::string, std::map< std::string, double > > NetworkInputs
VNetworkBase * GetNetHigh() const
void ExtractExtrapolatorMeansFromInputs()
FitResultsPerLayer m_allFitResults
TFCSGANXMLParameters m_param
std::map< int, TH2D > Binning
static std::unique_ptr< VNetworkBase > create(std::string input)
Given a string, make a network.
CLHEP::HepRandomEngine * randomEngine()
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
virtual NetworkOutputs compute(NetworkInputs const &inputs) const =0
Function to pass values to the network.
static std::string representNetworkOutputs(NetworkOutputs const &outputs, int maxValues=3)
String representation of network outputs.
std::map< std::string, double > NetworkOutputs
Format for network outputs.
static std::string representNetworkInputs(NetworkInputs const &inputs, int maxValues=3)
String representation of network inputs.