53 const std::string& thisJson)
const {
58 std::istringstream input_cfg( thisJson );
59 config = lwt::parse_json_graph(input_cfg);
60 }
catch (boost::property_tree::ptree_error& err) {
62 return StatusCode::FAILURE;
73 thisNN = std::make_unique<lwt::atlas::FastGraph>(
config, order,
"merge_1");
74 }
catch (lwt::NNConfigurationException& exc) {
76 return StatusCode::FAILURE;
79 return StatusCode::SUCCESS;
88 return StatusCode::SUCCESS;
94 return StatusCode::FAILURE;
97 assert( atrcol !=
nullptr);
101 const coral::AttributeList& attrList=atrcol->
attributeList(0);
104 if ((attrList[
"NNConfigurations"]).isNull()) {
106 return StatusCode::FAILURE;
111 const std::string megajson = attrList[
"NNConfigurations"].data<cool::String16M>();
114 std::istringstream initializerStream(megajson);
115 namespace pt = boost::property_tree;
116 pt::ptree parentTree;
117 pt::read_json(initializerStream, parentTree);
118 std::ostringstream configStream;
121 EventIDRange cdo_iov;
122 if(!readHandle.
range(cdo_iov)) {
123 ATH_MSG_ERROR(
"Failed to get valid validity range from " << readHandle.
key());
124 return StatusCode::FAILURE;
129 std::unique_ptr<LWTNNCollection> writeCdo{std::make_unique<LWTNNCollection>()};
132 pt::ptree subtreeNumberNetwork = parentTree.get_child(
"NumberNetwork");
133 writeCdo->insert(std::make_pair(0,std::unique_ptr<lwt::atlas::FastGraph>(
nullptr)));
135 if(subtreeNumberNetwork.empty()) {
136 ATH_MSG_ERROR(
"You are trying to use lwtnn for the number network but have an empty configuration file; this should never happen!");
137 return StatusCode::FAILURE;
142 pt::write_json(configStream, subtreeNumberNetwork);
143 std::string numberNetworkConfig = configStream.str();
144 if ((
configureLwtnn(writeCdo->at(0), numberNetworkConfig)).isFailure())
145 return StatusCode::FAILURE;
151 for (
int i=1; i<4; i++) {
152 const std::string key =
"PositionNetwork_N"+std::to_string(i);
153 configStream.str(
"");
154 pt::ptree subtreePosNetwork = parentTree.get_child(key);
155 pt::write_json(configStream, subtreePosNetwork);
156 std::string posNetworkConfig = configStream.str();
159 writeCdo->insert(std::make_pair(i,std::unique_ptr<lwt::atlas::FastGraph>(
nullptr)));
162 if(subtreePosNetwork.empty()) {
163 ATH_MSG_ERROR(
"You are trying to use lwtnn for the position networks but have an empty configuration file; this should never happen!");
164 return StatusCode::FAILURE;
167 ATH_MSG_DEBUG(
"Setting up lwtnn for n = " << i <<
" position network...");
168 if ((
configureLwtnn(writeCdo->at(i), posNetworkConfig)).isFailure())
169 return StatusCode::FAILURE;
176 if(NnWriteHandle.
record(cdo_iov,std::move(writeCdo)).isFailure()) {
177 ATH_MSG_ERROR(
"Failed to record Trained network collection to "
178 << NnWriteHandle.
key()
179 <<
" with IOV " << cdo_iov );
180 return StatusCode::FAILURE;
183 return StatusCode::SUCCESS;