#include <PunchThroughG4Classifier.h>
|
static std::map< std::string, std::map< std::string, double > > | computeInputs (const G4FastTrack &fastTrack, const double simE, const std::vector< double > &simEfrac) |
| calcalate NN inputs based on G4FastTrack and simulstate More...
|
|
|
std::unique_ptr< lwt::LightweightGraph > | m_graph {} |
| NN graph. More...
|
|
double | m_scalerMin {} |
| input variable MinMaxScaler members More...
|
|
double | m_scalerMax {} |
|
std::map< std::string, double > | m_scalerMinMap |
|
std::map< std::string, double > | m_scalerMaxMap |
|
std::string | m_calibratorConfigFile |
| isotonic regressor calibrator members More...
|
|
double | m_calibrationMin {} |
|
double | m_calibrationMax {} |
|
std::map< double, double > | m_calibrationMap |
|
StringProperty | m_scalerConfigFileName {this, "ScalerConfigFileName", "", ""} |
|
StringProperty | m_networkConfigFileName {this, "NetworkConfigFileName", "", ""} |
|
StringProperty | m_calibratorConfigFileName {this, "CalibratorConfigFileName", "", ""} |
|
Definition at line 22 of file PunchThroughG4Classifier.h.
◆ PunchThroughG4Classifier()
PunchThroughG4Classifier::PunchThroughG4Classifier |
( |
const std::string & |
type, |
|
|
const std::string & |
name, |
|
|
const IInterface * |
parent |
|
) |
| |
◆ ~PunchThroughG4Classifier()
virtual PunchThroughG4Classifier::~PunchThroughG4Classifier |
( |
| ) |
|
|
virtualdefault |
◆ calibrateOutput()
double PunchThroughG4Classifier::calibrateOutput |
( |
double & |
networkOutput | ) |
const |
calibrate NN output using isotonic regressor
Definition at line 234 of file PunchThroughG4Classifier.cxx.
248 auto lower =
upper--;
251 double m = (
upper->second - lower->second)/(
upper->first - lower->first);
252 double c = lower->second -
m * lower->first;
253 double calibrated =
m * networkOutput +
c;
◆ computeInputs()
std::map< std::string, std::map< std::string, double > > PunchThroughG4Classifier::computeInputs |
( |
const G4FastTrack & |
fastTrack, |
|
|
const double |
simE, |
|
|
const std::vector< double > & |
simEfrac |
|
) |
| |
|
static |
calcalate NN inputs based on G4FastTrack and simulstate
Definition at line 193 of file PunchThroughG4Classifier.cxx.
197 std::map<std::string, std::map<std::string, double> > networkInputs;
200 networkInputs[
"node_0"] = {
201 {
"variable_0", fastTrack.GetPrimaryTrack()->GetMomentum().mag() },
202 {
"variable_1", std::abs(fastTrack.GetPrimaryTrack()->GetPosition().eta()) },
203 {
"variable_2", fastTrack.GetPrimaryTrack()->GetPosition().phi() },
204 {
"variable_3", simE},
208 for (
unsigned int i = 0;
i < simEfrac.size();
i++) {
209 networkInputs[
"node_0"].insert({
"variable_" +
std::to_string(
i + 4), simEfrac[
i]});
212 return networkInputs;
◆ computePunchThroughProbability()
double PunchThroughG4Classifier::computePunchThroughProbability |
( |
const G4FastTrack & |
fastTrack, |
|
|
const double |
simE, |
|
|
const std::vector< double > & |
simEfrac |
|
) |
| const |
|
overridevirtual |
interface method to return probability prediction of punch through
Definition at line 180 of file PunchThroughG4Classifier.cxx.
182 std::map<std::string, std::map<std::string, double> > networkInputs =
computeInputs(fastTrack, simE, simEfrac);
186 std::map<std::string, double> networkOutputs =
m_graph->compute(networkInputs);
190 return calibratedOutput;
◆ finalize()
StatusCode PunchThroughG4Classifier::finalize |
( |
| ) |
|
|
overridevirtual |
◆ initialize()
StatusCode PunchThroughG4Classifier::initialize |
( |
| ) |
|
|
overridevirtual |
◆ initializeCalibrator()
StatusCode PunchThroughG4Classifier::initializeCalibrator |
( |
const std::string & |
calibratorConfigFile | ) |
|
isotonic regressor calibrator initialize method
Definition at line 131 of file PunchThroughG4Classifier.cxx.
137 ATH_MSG_DEBUG(
"[ punchthroughclassifier ] Loading calibrator: " << calibratorConfigFile);
139 doc = xmlParseFile( calibratorConfigFile.c_str() );
141 for( xmlNodePtr nodeRoot =
doc->children; nodeRoot !=
nullptr; nodeRoot = nodeRoot->next) {
143 if (xmlStrEqual( nodeRoot->name, BAD_CAST
"Transformations" )) {
144 for( xmlNodePtr nodeTransform = nodeRoot->children; nodeTransform !=
nullptr; nodeTransform = nodeTransform->next ) {
147 if (xmlStrEqual( nodeTransform->name, BAD_CAST
"LimitValues" )) {
148 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"min")) !=
nullptr) {
151 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"max")) !=
nullptr) {
157 if (xmlStrEqual( nodeTransform->name, BAD_CAST
"LinearNorm" )) {
160 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"orig")) !=
nullptr) {
161 orig =
atof(
reinterpret_cast<const char*
>(xmlBuff));
163 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"norm")) !=
nullptr) {
164 norm =
atof(
reinterpret_cast<const char*
>(xmlBuff));
177 return StatusCode::SUCCESS;
◆ initializeNetwork()
StatusCode PunchThroughG4Classifier::initializeNetwork |
( |
const std::string & |
networkConfigFile | ) |
|
neural network initialize method
Definition at line 111 of file PunchThroughG4Classifier.cxx.
113 ATH_MSG_DEBUG(
"[ punchthroughclassifier ] Loading classifier: " << networkConfigFile);
115 std::ifstream
input(networkConfigFile);
117 ATH_MSG_ERROR(
"Could not find json file " << networkConfigFile );
118 return StatusCode::FAILURE;
123 ATH_MSG_ERROR(
"Could not parse graph json file " << networkConfigFile );
124 return StatusCode::FAILURE;
128 return StatusCode::SUCCESS;
◆ initializeScaler()
StatusCode PunchThroughG4Classifier::initializeScaler |
( |
const std::string & |
scalerConfigFile | ) |
|
input variable MinMaxScaler initialize method
Definition at line 57 of file PunchThroughG4Classifier.cxx.
63 doc = xmlParseFile( scalerConfigFile.c_str() );
65 ATH_MSG_DEBUG(
"[ punchthroughclassifier ] Loading scaler: " << scalerConfigFile);
67 for( xmlNodePtr nodeRoot =
doc->children; nodeRoot !=
nullptr; nodeRoot = nodeRoot->next) {
69 if (xmlStrEqual( nodeRoot->name, BAD_CAST
"Transformations" )) {
70 for( xmlNodePtr nodeTransform = nodeRoot->children; nodeTransform !=
nullptr; nodeTransform = nodeTransform->next ) {
73 if (xmlStrEqual( nodeTransform->name, BAD_CAST
"ScalerValues" )) {
74 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"min")) !=
nullptr) {
77 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"max")) !=
nullptr) {
83 if (xmlStrEqual( nodeTransform->name, BAD_CAST
"VarScales" )) {
84 std::string
name =
"";
87 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"name")) !=
nullptr) {
88 name =
reinterpret_cast<const char*
>(xmlBuff);
90 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"min")) !=
nullptr) {
91 min =
atof(
reinterpret_cast<const char*
>(xmlBuff));
93 if ((xmlBuff = xmlGetProp(nodeTransform, BAD_CAST
"max")) !=
nullptr) {
94 max =
atof(
reinterpret_cast<const char*
>(xmlBuff));
108 return StatusCode::SUCCESS;
◆ scaleInputs()
std::map< std::string, std::map< std::string, double > > PunchThroughG4Classifier::scaleInputs |
( |
std::map< std::string, std::map< std::string, double > > & |
inputs | ) |
const |
◆ m_calibrationMap
std::map<double, double> PunchThroughG4Classifier::m_calibrationMap |
|
private |
◆ m_calibrationMax
double PunchThroughG4Classifier::m_calibrationMax {} |
|
private |
◆ m_calibrationMin
double PunchThroughG4Classifier::m_calibrationMin {} |
|
private |
◆ m_calibratorConfigFile
std::string PunchThroughG4Classifier::m_calibratorConfigFile |
|
private |
◆ m_calibratorConfigFileName
StringProperty PunchThroughG4Classifier::m_calibratorConfigFileName {this, "CalibratorConfigFileName", "", ""} |
|
private |
◆ m_graph
std::unique_ptr<lwt::LightweightGraph> PunchThroughG4Classifier::m_graph {} |
|
private |
◆ m_networkConfigFileName
StringProperty PunchThroughG4Classifier::m_networkConfigFileName {this, "NetworkConfigFileName", "", ""} |
|
private |
◆ m_scalerConfigFileName
StringProperty PunchThroughG4Classifier::m_scalerConfigFileName {this, "ScalerConfigFileName", "", ""} |
|
private |
◆ m_scalerMax
double PunchThroughG4Classifier::m_scalerMax {} |
|
private |
◆ m_scalerMaxMap
std::map<std::string, double> PunchThroughG4Classifier::m_scalerMaxMap |
|
private |
◆ m_scalerMin
double PunchThroughG4Classifier::m_scalerMin {} |
|
private |
◆ m_scalerMinMap
std::map<std::string, double> PunchThroughG4Classifier::m_scalerMinMap |
|
private |
The documentation for this class was generated from the following files:
static std::map< std::string, std::map< std::string, double > > computeInputs(const G4FastTrack &fastTrack, const double simE, const std::vector< double > &simEfrac)
calcalate NN inputs based on G4FastTrack and simulstate
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