ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSEnergyAndHitGAN.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ISF_FASTCALOSIMEVENT_TFCSEnergyAndHitGAN_h
6#define ISF_FASTCALOSIMEVENT_TFCSEnergyAndHitGAN_h
7
10#include <string>
11#include "TH2D.h"
12
13// forward declare lwtnn dependencies
14namespace lwt {
15class LightweightGraph;
16}
17
19public:
20 // type of input requested by lwtnn
21 typedef std::map<std::string, std::map<std::string, double>> NetworkInputs;
22 typedef std::map<std::string, double> NetworkOutputs;
23 typedef std::map<int, TH2D> Binning;
24
25 TFCSEnergyAndHitGAN(const char *name = nullptr, const char *title = nullptr);
26 virtual ~TFCSEnergyAndHitGAN();
27
28 virtual bool is_match_Ekin_bin(int /*Ekin_bin*/) const override {
29 return true;
30 };
31 virtual bool is_match_calosample(int calosample) const override;
32 virtual bool is_match_all_Ekin_bin() const override { return true; };
33 virtual bool is_match_all_calosample() const override { return false; };
34
37 kGANfreemem = BIT(17)
39 };
40
41 bool GANfreemem() const { return TestBit(kGANfreemem); };
42 void set_GANfreemem() { SetBit(kGANfreemem); };
43 void reset_GANfreemem() { ResetBit(kGANfreemem); };
44
51
52 bool OnlyScaleEnergy() const { return TestBit(kOnlyScaleEnergy); };
55
57 virtual int get_bin(TFCSSimulationState &simulstate, const TFCSTruthState *,
58 const TFCSExtrapolationState *) const override {
59 return simulstate.getAuxInfo<int>("GANlayer"_FCShash);
60 };
61 virtual const std::string
63 const TFCSExtrapolationState *) const override;
64
65 unsigned int get_nr_of_init(unsigned int bin) const;
66 void set_nr_of_init(unsigned int bin, unsigned int ninit);
67
68 const Binning &get_Binning() const { return m_Binning; };
69 const lwt::LightweightGraph *get_graph() const { return m_graph; };
70 const std::string *get_input() const { return m_input; };
71
72 bool initializeNetwork(int pid, int etaMin,
73 const std::string &FastCaloGANInputFolderName);
74
76 const TFCSTruthState *truth,
77 NetworkInputs &inputs,
78 double &trueEnergy) const;
79 bool fillEnergy(TFCSSimulationState &simulstate, const TFCSTruthState *truth,
80 const TFCSExtrapolationState *extrapol,
81 NetworkInputs inputs) const;
82 virtual FCSReturnCode
83 simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth,
84 const TFCSExtrapolationState *extrapol) const override;
85
86 virtual void Print(Option_t *option = "") const override;
87
88 static void unit_test(TFCSSimulationState *simulstate = nullptr,
89 const TFCSTruthState *truth = nullptr,
90 const TFCSExtrapolationState *extrapol = nullptr);
91
92protected:
93 void GetBinning(int pid, int etaMax,
94 const std::string &FastCaloGANInputFolderName);
95
96private:
97 std::vector<int> m_bin_ninit;
98
99 // Persistify configuration in string m_input. A custom Streamer(...) builds
100 // m_graph on the fly when reading from file. Inside Athena, if GANfreemem()
101 // is true, the content of m_input is deleted after reading in order to free
102 // memory
103 std::string *m_input = nullptr;
104 lwt::LightweightGraph *m_graph = nullptr;
105
107
108 // specific to architecture
109 // preprocessing of input
111
112 ClassDefOverride(TFCSEnergyAndHitGAN, 2) // TFCSEnergyAndHitGAN
113};
114
115#endif
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
unsigned int get_nr_of_init(unsigned int bin) const
lwt::LightweightGraph * m_graph
FCSEnergyInitializationStatusBits
Status bit for energy initialization.
@ kOnlyScaleEnergy
Set this bit in the TObject bit field the simulated energy.
void set_nr_of_init(unsigned int bin, unsigned int ninit)
virtual bool is_match_Ekin_bin(int) const override
virtual void Print(Option_t *option="") const override
const lwt::LightweightGraph * get_graph() const
virtual int get_bin(TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
use the layer to be done as binning of the GAN chain
Binning m_Binning
Do not persistify.
TFCSEnergyAndHitGAN(const char *name=nullptr, const char *title=nullptr)
virtual bool is_match_all_Ekin_bin() const override
bool fillEnergy(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol, NetworkInputs inputs) const
const Binning & get_Binning() const
std::map< std::string, double > NetworkOutputs
const std::string * get_input() const
FCSGANfreemem
Status bit for chain persistency.
@ kGANfreemem
Set this bit in the TObject bit if the memory for m_input should be freed after reading in athena.
virtual const std::string get_variable_text(TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
std::map< std::string, std::map< std::string, double > > NetworkInputs
virtual bool is_match_all_calosample() const override
std::map< int, TH2D > Binning
void GetBinning(int pid, int etaMax, const std::string &FastCaloGANInputFolderName)
virtual bool is_match_calosample(int calosample) const override
bool initializeNetwork(int pid, int etaMin, const std::string &FastCaloGANInputFolderName)
std::vector< int > m_bin_ninit
static void unit_test(TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)
bool fillFastCaloGanNetworkInputs(TFCSSimulationState &simulstate, const TFCSTruthState *truth, NetworkInputs &inputs, double &trueEnergy) const
TFCSParametrizationBinnedChain(const char *name=nullptr, const char *title=nullptr)
const T getAuxInfo(std::uint32_t index) const