ATLAS Offline Software
Loading...
Searching...
No Matches
TFCSPredictExtrapWeights.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ISF_FASTCALOSIMEVENT_TFCSPREDICTEXTRAPWEIGHTS_h
6#define ISF_FASTCALOSIMEVENT_TFCSPREDICTEXTRAPWEIGHTS_h
7
10#include <string>
11#include "TH2D.h"
12
13// forward declare lwtnn dependencies
14namespace lwt {
15class LightweightNeuralNetwork;
16}
17
19public:
20 TFCSPredictExtrapWeights(const char *name = nullptr,
21 const char *title = nullptr);
23
24 virtual bool operator==(const TFCSParametrizationBase &ref) const override;
25
26 // Used to decorate simulstate with extrapolation weights
27 virtual FCSReturnCode
28 simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth,
29 const TFCSExtrapolationState *extrapol) const override;
30
31 // Used to decorate Hit with extrapolated center positions
32 virtual FCSReturnCode
33 simulate_hit(Hit &hit, TFCSSimulationState &simulstate,
34 const TFCSTruthState *truth,
35 const TFCSExtrapolationState *extrapol) override;
36
37 // Status bit for chain persistency
39 kfreemem = BIT(17)
41 };
42 bool freemem() const { return TestBit(kfreemem); };
43 void set_freemem() { SetBit(kfreemem); };
44
45 // Initialize Neural Network
46 bool initializeNetwork(int pid, const std::string &etaBin,
47 const std::string &FastCaloNNInputFolderName);
48
49 // Get inputs needed to normalize data
50 bool getNormInputs(const std::string &etaBin,
51 const std::string &FastCaloTXTInputFolderName);
52
53 // Test function
54 static void test_path(std::string &net_path, std::string const &norm_path,
55 TFCSSimulationState *simulstate = nullptr,
56 const TFCSTruthState *truth = nullptr,
57 const TFCSExtrapolationState *extrapol = nullptr);
58 static void unit_test(TFCSSimulationState *simulstate = nullptr,
59 const TFCSTruthState *truth = nullptr,
60 const TFCSExtrapolationState *extrapol = nullptr);
61
62 // Prepare inputs to the Neural Network
63 std::map<std::string, double> prepareInputs(TFCSSimulationState &simulstate,
64 const float truthE) const;
65
66 // Print()
67 void Print(Option_t *option = "") const override;
68
69 // Use extrapWeight=0.5 or r and z when constructing a hit?
71 bool UseHardcodedWeight() const { return TestBit(kUseHardcodedWeight); };
74
75private:
76 // Persistify configuration in string m_input. A custom Streamer(...) builds
77 // m_nn on the fly when reading from file.
78 // Inside Athena, if freemem() is true, the content of m_input is deleted
79 // after reading in order to free memory
80 std::string *m_input = nullptr;
81 std::vector<int> *m_relevantLayers = nullptr;
82 lwt::LightweightNeuralNetwork *m_nn = nullptr;
83 std::vector<int> *m_normLayers =
84 nullptr; // vector of index layers (-1 corresponds to truth energy)
85 std::vector<float> *m_normMeans =
86 nullptr; // vector of mean values for normalizing energy fraction per
87 // layer, last index is for total energy
88 std::vector<float> *m_normStdDevs =
89 nullptr; // vector of std dev values for normalizing energy fraction per
90 // layer, last index is for total energy
91
92 ClassDefOverride(TFCSPredictExtrapWeights, 1) // TFCSPredictExtrapWeights
93};
94
95#endif
const boost::regex ref(r_ef)
FCSReturnCode
Base class for all FastCaloSim parametrizations Functionality in derivde classes is provided through ...
TFCSLateralShapeParametrizationHitBase(const char *name=nullptr, const char *title=nullptr)
virtual FCSReturnCode simulate(TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) const override
Method in all derived classes to do some simulation.
bool getNormInputs(const std::string &etaBin, const std::string &FastCaloTXTInputFolderName)
std::vector< float > * m_normMeans
lwt::LightweightNeuralNetwork * m_nn
virtual bool operator==(const TFCSParametrizationBase &ref) const override
The == operator compares the content of instances.
TFCSPredictExtrapWeights(const char *name=nullptr, const char *title=nullptr)
std::vector< float > * m_normStdDevs
std::vector< int > * m_relevantLayers
@ kfreemem
Set this bit in the TObject bit if the memory for m_input should be freed after reading in athena.
void Print(Option_t *option="") const override
std::vector< int > * m_normLayers
Do not persistify.
std::map< std::string, double > prepareInputs(TFCSSimulationState &simulstate, const float truthE) const
virtual FCSReturnCode simulate_hit(Hit &hit, TFCSSimulationState &simulstate, const TFCSTruthState *truth, const TFCSExtrapolationState *extrapol) override
simulated one hit position with some energy.
static void test_path(std::string &net_path, std::string const &norm_path, TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)
static void unit_test(TFCSSimulationState *simulstate=nullptr, const TFCSTruthState *truth=nullptr, const TFCSExtrapolationState *extrapol=nullptr)
bool initializeNetwork(int pid, const std::string &etaBin, const std::string &FastCaloNNInputFolderName)