14#include "CLHEP/Random/RandGauss.h"
16#include "TFitResult.h"
72 std::string inputFileName;
80 inputFileName =
m_param.GetInputFolder() +
"/neural_net_" +
82 "_" + std::to_string(
m_etaMax) +
"_All.*";
87 }
else if (
m_pid == 2212) {
88 inputFileName =
m_param.GetInputFolder() +
"/neural_net_" +
90 "_" + std::to_string(
m_etaMax) +
"_High10.*";
96 inputFileName =
m_param.GetInputFolder() +
"/neural_net_" +
98 "_" + std::to_string(
m_etaMax) +
"_High12.*";
104 inputFileName =
m_param.GetInputFolder() +
"/neural_net_" +
106 "_" + std::to_string(
m_etaMax) +
"_UltraLow12.*";
115 std::string rootFileName =
m_param.GetInputFolder() +
"/rootFiles/pid" +
116 std::to_string(
m_pid) +
"_E1048576_eta_" +
118 std::to_string(
m_etaMin + 5) +
".root";
120 TFile *
file = TFile::Open(rootFileName.c_str(),
"read");
121 for (
int layer :
m_param.GetRelevantLayers()) {
124 TH2D *h2 = &binsInLayers[layer];
126 std::string histoName =
"r" + std::to_string(layer) +
"w";
127 TH1D *h1 = (TH1D *)
file->Get(histoName.c_str());
128 if (std::isnan(h1->Integral())) {
129 histoName =
"r" + std::to_string(layer);
130 h1 = (TH1D *)
file->Get(histoName.c_str());
133 TAxis *
x = (TAxis *)h2->GetXaxis();
134 for (
int ix = 1; ix <= h2->GetNbinsX(); ++ix) {
136 h1->GetXaxis()->SetRangeUser(
x->GetBinLowEdge(ix),
x->GetBinUpEdge(ix));
139 if (h1->Integral() > 0 && h1->GetNbinsX() > 2) {
140 TFitResultPtr
res(0);
142 res = h1->Fit(
"expo",
"SQ");
143 if (
res >= 0 && !std::isnan(
res->Parameter(0))) {
154 std::string rootFileName =
m_param.GetInputFolder() +
"/rootFiles/pid" +
155 std::to_string(
m_pid) +
"_E65536_eta_" +
157 std::to_string(
m_etaMin + 5) +
"_validation.root";
159 TFile *
file = TFile::Open(rootFileName.c_str(),
"read");
160 for (
int layer :
m_param.GetRelevantLayers()) {
161 std::string branchName =
"extrapWeight_" + std::to_string(layer);
162 TH1D *
h =
new TH1D(
"h",
"h", 100, 0.01, 1);
163 TTree *
tree = (TTree *)
file->Get(
"rootTree");
164 std::string command = branchName +
">>h";
165 tree->Draw(command.c_str());
176 double randUniformZ = 0.;
179 int maxExp = 0, minExp = 0;
190 }
else if (std::abs(
m_pid) == 211) {
193 }
else if (std::abs(
m_pid) == 2212) {
198 int p_min = std::pow(2, minExp);
199 int p_max = std::pow(2, maxExp);
202 std::sqrt(std::pow(p_min, 2) + std::pow(truth->M(), 2)) - truth->M();
204 std::sqrt(std::pow(p_max, 2) + std::pow(truth->M(), 2)) - truth->M();
206 for (
int i = 0; i <
m_param.GetLatentSpaceSize(); i++) {
207 randUniformZ = CLHEP::RandGauss::shoot(simulstate.
randomEngine(), 0.5, 0.5);
208 inputs[
"Noise"].insert(std::pair<std::string, double>(
209 "variable_" + std::to_string(i), randUniformZ));
221 inputs[
"mycond"].insert(std::pair<std::string, double>(
222 "variable_0", log(truth->
Ekin() / Ekin_min) / log(Ekin_max / Ekin_min)));
224 if (
m_param.GetGANVersion() >= 2) {
228 inputs[
"mycond"].insert(std::pair<std::string, double>(
229 "variable_1", std::abs(extrapol->IDCaloBoundary_eta())));
231 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
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
NetworkOutputs GetNetworkOutputs(const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol, TFCSSimulationState simulstate) const
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.