#include <PunchThroughClassifier.h>
|
| | PunchThroughClassifier (const std::string &, const std::string &, const IInterface *) |
| | Constructor.
|
| virtual | ~PunchThroughClassifier ()=default |
| | Destructor.
|
| virtual StatusCode | initialize () override final |
| | AlgTool initialize method.
|
| StatusCode | initializeScaler (const std::string &scalerConfigFile) |
| | input variable MinMaxScaler initialize method
|
| StatusCode | initializeNetwork (const std::string &networkConfigFile) |
| | neural network initialize method
|
| StatusCode | initializeCalibrator (const std::string &calibratorConfigFile) |
| | isotonic regressor calibrator initialize method
|
| virtual double | computePunchThroughProbability (const ISF::ISFParticle &isfp, const TFCSSimulationState &simulstate) const override |
| | interface method to return probability prediction of punch through
|
| std::map< std::string, std::map< std::string, double > > | scaleInputs (std::map< std::string, std::map< std::string, double > > &inputs) const |
| | scale NN inputs using MinMaxScaler
|
| double | calibrateOutput (double &networkOutput) const |
| | calibrate NN output using isotonic regressor
|
Definition at line 26 of file PunchThroughClassifier.h.
◆ PunchThroughClassifier()
| ISF::PunchThroughClassifier::PunchThroughClassifier |
( |
const std::string & | type, |
|
|
const std::string & | name, |
|
|
const IInterface * | parent ) |
Constructor.
Definition at line 28 of file PunchThroughClassifier.cxx.
29 : base_class(type, name, parent) {
30
34}
std::string m_calibratorConfigFileName
std::string m_scalerConfigFileName
std::string m_networkConfigFileName
◆ ~PunchThroughClassifier()
| virtual ISF::PunchThroughClassifier::~PunchThroughClassifier |
( |
| ) |
|
|
virtualdefault |
◆ calibrateOutput()
| double ISF::PunchThroughClassifier::calibrateOutput |
( |
double & | networkOutput | ) |
const |
calibrate NN output using isotonic regressor
Definition at line 202 of file PunchThroughClassifier.cxx.
202 {
203
204
205
206
209 }
212 }
213
214
216 auto lower =
upper--;
217
218
219 double m = (
upper->second - lower->second)/(
upper->first - lower->first);
220 double c = lower->second -
m * lower->first;
221 double calibrated =
m * networkOutput +
c;
222
223 return calibrated;
224}
std::map< double, double > m_calibrationMap
◆ computeInputs()
calcalate NN inputs based on isfp and simulstate
Definition at line 161 of file PunchThroughClassifier.cxx.
161 {
162
163
164
165 std::map<std::string, std::map<std::string, double> > networkInputs;
166
167
168 networkInputs["node_0"] = {
169 {
"variable_0", isfp.
momentum().mag() },
170 {
"variable_1", std::abs(isfp.
position().eta()) },
171 {
"variable_2", isfp.
position().phi() },
172 {
"variable_3", simulstate.
E()},
173 };
174
175
176 for (
unsigned int i = 0;
i < 24;
i++){
177 networkInputs[
"node_0"].insert({
"variable_" + std::to_string(i + 4), simulstate.
Efrac(i)});
178 }
179
180 return networkInputs;
181}
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
const Amg::Vector3D & position() const
The current position of the ISFParticle.
double Efrac(int sample) const
◆ computePunchThroughProbability()
interface method to return probability prediction of punch through
Definition at line 36 of file PunchThroughClassifier.cxx.
36 {
37
38 std::map<std::string, std::map<std::string, double> > networkInputs =
computeInputs(isfp, simulstate);
39
41
42 std::map<std::string, double> networkOutputs =
m_graph->compute(networkInputs);
43
45
46 return calibratedOutput;
47}
std::map< std::string, std::map< std::string, double > > scaleInputs(std::map< std::string, std::map< std::string, double > > &inputs) const
scale NN inputs using MinMaxScaler
double calibrateOutput(double &networkOutput) const
calibrate NN output using isotonic regressor
static std::map< std::string, std::map< std::string, double > > computeInputs(const ISF::ISFParticle &isfp, const TFCSSimulationState &simulstate)
calcalate NN inputs based on isfp and simulstate
std::unique_ptr< lwt::LightweightGraph > m_graph
NN graph.
◆ initialize()
| StatusCode ISF::PunchThroughClassifier::initialize |
( |
| ) |
|
|
finaloverridevirtual |
AlgTool initialize method.
Definition at line 50 of file PunchThroughClassifier.cxx.
50 {
51
53
56 {
57 ATH_MSG_ERROR(
"[ punchthroughclassifier ] unable to load punchthroughclassifier input scaler");
58 }
59
62 {
63 ATH_MSG_ERROR(
"[ punchthroughclassifier ] unable to load punchthroughclassifier network");
64 }
65
68 {
69 ATH_MSG_ERROR(
"[ punchthroughclassifier ] unable to load punchthroughclassifier calibrator");
70 }
71
72 return StatusCode::SUCCESS;
73}
#define ATH_MSG_VERBOSE(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
StatusCode initializeScaler(const std::string &scalerConfigFile)
input variable MinMaxScaler initialize method
StatusCode initializeNetwork(const std::string &networkConfigFile)
neural network initialize method
StatusCode initializeCalibrator(const std::string &calibratorConfigFile)
isotonic regressor calibrator initialize method
◆ initializeCalibrator()
| StatusCode ISF::PunchThroughClassifier::initializeCalibrator |
( |
const std::string & | calibratorConfigFile | ) |
|
isotonic regressor calibrator initialize method
Definition at line 130 of file PunchThroughClassifier.cxx.
130 {
131
132
133 ATH_MSG_INFO(
"[ punchthroughclassifier ] Loading calibrator: " << calibratorConfigFile);
134
135 xmlDocPtr
doc = xmlParseFile( calibratorConfigFile.c_str() );
136
137 for( xmlNodePtr nodeRoot =
doc->children; nodeRoot !=
nullptr; nodeRoot = nodeRoot->next) {
138
139 if (xmlStrEqual( nodeRoot->name, BAD_CAST "Transformations" )) {
140 for( xmlNodePtr nodeTransform = nodeRoot->children; nodeTransform != nullptr; nodeTransform = nodeTransform->next ) {
141
142
143 if (xmlStrEqual( nodeTransform->name, BAD_CAST "LimitValues" )) {
146 }
147
148
149 if (xmlStrEqual( nodeTransform->name, BAD_CAST "LinearNorm" )) {
153 }
154 }
155 }
156 }
157
158 return StatusCode::SUCCESS;
159}
T GetXmlAttr(xmlNodePtr node, const char *attrName, const T &defaultValue=T{}) noexcept(std::is_arithmetic_v< T >)
◆ initializeNetwork()
| StatusCode ISF::PunchThroughClassifier::initializeNetwork |
( |
const std::string & | networkConfigFile | ) |
|
neural network initialize method
Definition at line 109 of file PunchThroughClassifier.cxx.
109 {
110
111 ATH_MSG_INFO(
"[ punchthroughclassifier ] Loading classifier: " << networkConfigFile);
112
113 std::ifstream
input(networkConfigFile);
114 if(!input){
115 ATH_MSG_ERROR(
"Could not find json file " << networkConfigFile );
116 return StatusCode::FAILURE;
117 }
118
119 m_graph = std::make_unique<lwt::LightweightGraph>(lwt::parse_json_graph(input));
121 ATH_MSG_ERROR(
"Could not parse graph json file " << networkConfigFile );
122 return StatusCode::FAILURE;
123 }
124
125
126 return StatusCode::SUCCESS;
127}
◆ initializeScaler()
| StatusCode ISF::PunchThroughClassifier::initializeScaler |
( |
const std::string & | scalerConfigFile | ) |
|
input variable MinMaxScaler initialize method
Definition at line 75 of file PunchThroughClassifier.cxx.
75 {
76
77
78
79 xmlDocPtr
doc = xmlParseFile( scalerConfigFile.c_str() );
80
81 ATH_MSG_INFO(
"[ punchthroughclassifier ] Loading scaler: " << scalerConfigFile);
82
83 for( xmlNodePtr nodeRoot =
doc->children; nodeRoot !=
nullptr; nodeRoot = nodeRoot->next) {
84
85 if (xmlStrEqual( nodeRoot->name, BAD_CAST "Transformations" )) {
86 for( xmlNodePtr nodeTransform = nodeRoot->children; nodeTransform != nullptr; nodeTransform = nodeTransform->next ) {
87
88
89 if (xmlStrEqual( nodeTransform->name, BAD_CAST "ScalerValues" )) {
92 }
93
94
95 if (xmlStrEqual( nodeTransform->name, BAD_CAST "VarScales" )) {
101 }
102 }
103 }
104 }
105
106 return StatusCode::SUCCESS;
107}
std::map< std::string, double > m_scalerMinMap
double m_scalerMin
input variable MinMaxScaler members
std::map< std::string, double > m_scalerMaxMap
◆ scaleInputs()
| std::map< std::string, std::map< std::string, double > > ISF::PunchThroughClassifier::scaleInputs |
( |
std::map< std::string, std::map< std::string, double > > & | inputs | ) |
const |
scale NN inputs using MinMaxScaler
Definition at line 183 of file PunchThroughClassifier.cxx.
183 {
184
185
186
187 for (auto& var : inputs["node_0"]) {
188
189 double x_std;
192 }
193 else{
195 }
197 }
198
200}
◆ m_calibrationMap
| std::map<double, double> ISF::PunchThroughClassifier::m_calibrationMap |
|
private |
◆ m_calibrationMax
| double ISF::PunchThroughClassifier::m_calibrationMax {} |
|
private |
◆ m_calibrationMin
| double ISF::PunchThroughClassifier::m_calibrationMin {} |
|
private |
◆ m_calibratorConfigFile
| std::string ISF::PunchThroughClassifier::m_calibratorConfigFile |
|
private |
◆ m_calibratorConfigFileName
| std::string ISF::PunchThroughClassifier::m_calibratorConfigFileName |
|
private |
◆ m_graph
| std::unique_ptr<lwt::LightweightGraph> ISF::PunchThroughClassifier::m_graph {} |
|
private |
◆ m_networkConfigFileName
| std::string ISF::PunchThroughClassifier::m_networkConfigFileName |
|
private |
◆ m_scalerConfigFileName
| std::string ISF::PunchThroughClassifier::m_scalerConfigFileName |
|
private |
◆ m_scalerMax
| double ISF::PunchThroughClassifier::m_scalerMax {} |
|
private |
◆ m_scalerMaxMap
| std::map<std::string, double> ISF::PunchThroughClassifier::m_scalerMaxMap |
|
private |
◆ m_scalerMin
| double ISF::PunchThroughClassifier::m_scalerMin {} |
|
private |
◆ m_scalerMinMap
| std::map<std::string, double> ISF::PunchThroughClassifier::m_scalerMinMap |
|
private |
The documentation for this class was generated from the following files: