Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
JSONInterface.cxx
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * Carsten D. Burgard, DESY/ATLAS, Dec 2021
5 *
6 * Copyright (c) 2022, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
14
15namespace {
16template <class Nd>
17class ChildItImpl final : public RooFit::Experimental::JSONNode::child_iterator_t<Nd>::Impl {
18public:
20 ChildItImpl(Nd &n, size_t p) : node(n), pos(p) {}
21 ChildItImpl(const ChildItImpl &other) : node(other.node), pos(other.pos) {}
22 virtual std::unique_ptr<typename child_iterator::Impl> clone() const override
23 {
24 return std::make_unique<ChildItImpl>(node, pos);
25 }
26 virtual void forward() override { ++pos; }
27 virtual void backward() override { --pos; }
28 virtual Nd &current() override { return node.child(pos); }
29 virtual bool equal(const typename child_iterator::Impl &other) const override
30 {
31 auto it = dynamic_cast<const ChildItImpl<Nd> *>(&other);
32 return it && &(it->node) == &(this->node) && (it->pos) == this->pos;
33 }
34
35private:
36 Nd &node;
37 size_t pos;
38};
39} // namespace
40
41namespace RooFit {
42namespace Experimental {
43
44template class JSONNode::child_iterator_t<JSONNode>;
45template class JSONNode::child_iterator_t<const JSONNode>;
46
48{
49 return {child_iterator(std::make_unique<::ChildItImpl<JSONNode>>(*this, 0)),
50 child_iterator(std::make_unique<::ChildItImpl<JSONNode>>(*this, this->num_children()))};
51}
53{
54 return {const_child_iterator(std::make_unique<::ChildItImpl<const JSONNode>>(*this, 0)),
55 const_child_iterator(std::make_unique<::ChildItImpl<const JSONNode>>(*this, this->num_children()))};
56}
57
58std::ostream &operator<<(std::ostream &os, JSONNode const &s)
59{
60 s.writeJSON(os);
61 return os;
62}
63
64template <>
65int JSONNode::val_t<int>() const
66{
67 return val_int();
68}
69template <>
70float JSONNode::val_t<float>() const
71{
72 return val_float();
73}
74template <>
75double JSONNode::val_t<double>() const
76{
77 return val_float();
78}
79template <>
80bool JSONNode::val_t<bool>() const
81{
82 return val_bool();
83}
84template <>
85std::string JSONNode::val_t<std::string>() const
86{
87 return val();
88}
89
90} // namespace Experimental
91} // namespace RooFit
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:399
child_iterator_t< const JSONNode > const_child_iterator
child_iterator_t< JSONNode > child_iterator
virtual size_t num_children() const =0
virtual float val_float() const
virtual bool val_bool() const
virtual void writeJSON(std::ostream &os) const =0
virtual children_view children()
const Int_t n
Definition legend1.C:16
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition Common.h:18
void forward(const LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
apply the weights (and functions) in forward direction of the DNN
void backward(LAYERDATA &prevLayerData, LAYERDATA &currLayerData)
backward application of the weights (back-propagation of the error)