ATLAS Offline Software
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
14 namespace lwt {
15 class LightweightGraph;
16 }
17 
19 public:
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)
38  };
40 
41  bool GANfreemem() const { return TestBit(kGANfreemem); };
42  void set_GANfreemem() { SetBit(kGANfreemem); };
43  void reset_GANfreemem() { ResetBit(kGANfreemem); };
44 
48  BIT(18)
49  };
51 
52  bool OnlyScaleEnergy() const { return TestBit(kOnlyScaleEnergy); };
54  void reset_OnlyScaleEnergy() { ResetBit(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,
78  double &trueEnergy) const;
79  bool fillEnergy(TFCSSimulationState &simulstate, const TFCSTruthState *truth,
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 
92 protected:
93  void GetBinning(int pid, int etaMax,
94  const std::string &FastCaloGANInputFolderName);
95 
96 private:
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
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
Definition: TFCSParametrizationBase.h:41
TFCSEnergyAndHitGAN::NetworkInputs
std::map< std::string, std::map< std::string, double > > NetworkInputs
Definition: TFCSEnergyAndHitGAN.h:21
TFCSSimulationState::getAuxInfo
const T getAuxInfo(std::uint32_t index) const
Definition: TFCSSimulationState.h:161
TFCSEnergyAndHitGAN::fillFastCaloGanNetworkInputs
bool fillFastCaloGanNetworkInputs(TFCSSimulationState &simulstate, const TFCSTruthState *truth, NetworkInputs &inputs, double &trueEnergy) const
Definition: TFCSEnergyAndHitGAN.cxx:240
TFCSEnergyAndHitGAN::initializeNetwork
bool initializeNetwork(int pid, int etaMin, const std::string &FastCaloGANInputFolderName)
Definition: TFCSEnergyAndHitGAN.cxx:84
TFCSEnergyAndHitGAN::Binning
std::map< int, TH2D > Binning
Definition: TFCSEnergyAndHitGAN.h:23
TFCSEnergyAndHitGAN::GetBinning
void GetBinning(int pid, int etaMax, const std::string &FastCaloGANInputFolderName)
Definition: TFCSEnergyAndHitGAN.cxx:143
bin
Definition: BinsDiffFromStripMedian.h:43
TFCSEnergyAndHitGAN::get_variable_text
virtual const std::string get_variable_text(TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
Definition: TFCSEnergyAndHitGAN.cxx:233
TFCSEnergyAndHitGAN::NetworkOutputs
std::map< std::string, double > NetworkOutputs
Definition: TFCSEnergyAndHitGAN.h:22
TFCSEnergyAndHitGAN::set_OnlyScaleEnergy
void set_OnlyScaleEnergy()
Definition: TFCSEnergyAndHitGAN.h:53
TFCSEnergyAndHitGAN::kGANfreemem
@ kGANfreemem
Set this bit in the TObject bit if the memory for m_input should be freed after reading in athena.
Definition: TFCSEnergyAndHitGAN.h:37
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
TFCSEnergyAndHitGAN::set_nr_of_init
void set_nr_of_init(unsigned int bin, unsigned int ninit)
Definition: TFCSEnergyAndHitGAN.cxx:75
TFCSEnergyAndHitGAN::FCSEnergyInitializationStatusBits
FCSEnergyInitializationStatusBits
Status bit for energy initialization.
Definition: TFCSEnergyAndHitGAN.h:46
TFCSEnergyAndHitGAN::get_input
const std::string * get_input() const
Definition: TFCSEnergyAndHitGAN.h:70
TFCSEnergyAndHitGAN::FCSGANfreemem
FCSGANfreemem
Status bit for chain persistency.
Definition: TFCSEnergyAndHitGAN.h:36
TFCSExtrapolationState
Definition: TFCSExtrapolationState.h:13
TFCSEnergyAndHitGAN::~TFCSEnergyAndHitGAN
virtual ~TFCSEnergyAndHitGAN()
Definition: TFCSEnergyAndHitGAN.cxx:52
RunActsMaterialValidation.extrapol
extrapol
Definition: RunActsMaterialValidation.py:90
TFCSEnergyAndHitGAN::get_Binning
const Binning & get_Binning() const
Definition: TFCSEnergyAndHitGAN.h:68
TFCSEnergyAndHitGAN
Definition: TFCSEnergyAndHitGAN.h:18
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
TFCSEnergyAndHitGAN::m_GANLatentSize
int m_GANLatentSize
Definition: TFCSEnergyAndHitGAN.h:110
TFCSEnergyAndHitGAN::set_GANfreemem
void set_GANfreemem()
Definition: TFCSEnergyAndHitGAN.h:42
TFCSEnergyAndHitGAN::is_match_Ekin_bin
virtual bool is_match_Ekin_bin(int) const override
Definition: TFCSEnergyAndHitGAN.h:28
TFCSParametrizationBinnedChain
Definition: TFCSParametrizationBinnedChain.h:10
TFCSEnergyAndHitGAN::reset_GANfreemem
void reset_GANfreemem()
Definition: TFCSEnergyAndHitGAN.h:43
TFCSParametrizationBinnedChain.h
TFCSEnergyAndHitGAN::get_nr_of_init
unsigned int get_nr_of_init(unsigned int bin) const
Definition: TFCSEnergyAndHitGAN.cxx:69
TFCSEnergyAndHitGAN::simulate
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
Definition: TFCSEnergyAndHitGAN.cxx:580
TFCSEnergyAndHitGAN::is_match_all_calosample
virtual bool is_match_all_calosample() const override
Definition: TFCSEnergyAndHitGAN.h:33
covarianceTool.title
title
Definition: covarianceTool.py:542
TFCSEnergyAndHitGAN::is_match_all_Ekin_bin
virtual bool is_match_all_Ekin_bin() const override
Definition: TFCSEnergyAndHitGAN.h:32
TFCSEnergyAndHitGAN::get_bin
virtual int get_bin(TFCSSimulationState &simulstate, const TFCSTruthState *, const TFCSExtrapolationState *) const override
use the layer to be done as binning of the GAN chain
Definition: TFCSEnergyAndHitGAN.h:57
lwt
Definition: NnClusterizationFactory.h:52
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
TFCSEnergyAndHitGAN::is_match_calosample
virtual bool is_match_calosample(int calosample) const override
Definition: TFCSEnergyAndHitGAN.cxx:61
TFCSEnergyAndHitGAN::fillEnergy
bool fillEnergy(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol, NetworkInputs inputs) const
Definition: TFCSEnergyAndHitGAN.cxx:262
TFCSEnergyAndHitGAN::m_Binning
Binning m_Binning
Do not persistify.
Definition: TFCSEnergyAndHitGAN.h:106
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TFCSEnergyAndHitGAN::unit_test
static void unit_test(TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)
Definition: TFCSEnergyAndHitGAN.cxx:688
TFCSEnergyAndHitGAN::Print
virtual void Print(Option_t *option="") const override
Definition: TFCSEnergyAndHitGAN.cxx:611
TFCSEnergyAndHitGAN::OnlyScaleEnergy
bool OnlyScaleEnergy() const
Definition: TFCSEnergyAndHitGAN.h:52
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
TFCSEnergyAndHitGAN::m_input
std::string * m_input
Definition: TFCSEnergyAndHitGAN.h:103
TFCSEnergyAndHitGAN::TFCSEnergyAndHitGAN
TFCSEnergyAndHitGAN(const char *name=nullptr, const char *title=nullptr)
Definition: TFCSEnergyAndHitGAN.cxx:47
TFCSEnergyAndHitGAN::reset_OnlyScaleEnergy
void reset_OnlyScaleEnergy()
Definition: TFCSEnergyAndHitGAN.h:54
TFCSEnergyAndHitGAN::GANfreemem
bool GANfreemem() const
Definition: TFCSEnergyAndHitGAN.h:41
TFCSSimulationState.h
TFCSEnergyAndHitGAN::get_graph
const lwt::LightweightGraph * get_graph() const
Definition: TFCSEnergyAndHitGAN.h:69
TFCSEnergyAndHitGAN::m_bin_ninit
std::vector< int > m_bin_ninit
Definition: TFCSEnergyAndHitGAN.h:97
TFCSTruthState
Definition: TFCSTruthState.h:13
TFCSSimulationState
Definition: TFCSSimulationState.h:32
TFCSEnergyAndHitGAN::m_graph
lwt::LightweightGraph * m_graph
Definition: TFCSEnergyAndHitGAN.h:104
TFCSEnergyAndHitGAN::kOnlyScaleEnergy
@ kOnlyScaleEnergy
Set this bit in the TObject bit field the simulated energy should only be scaled by the GAN.
Definition: TFCSEnergyAndHitGAN.h:47