35 using json = nlohmann::json;
36 using cstr_t =
const std::string&;
37 using strVec_t = std::vector< std::string >;
39 std::vector< SinglePlotDefinition > plotDefVec;
47 const json& plotDef = json::parse( plotDefStr );
50 cstr_t name = plotDef.contains(
"name" ) ?
51 plotDef.at(
"name" ).get_ref< cstr_t >() :
"";
54 cstr_t
type = plotDef.contains(
"type" ) ?
55 plotDef.at(
"type" ).get_ref< cstr_t >() :
"";
58 cstr_t folder = plotDef.contains(
"folder" ) ?
59 plotDef.at(
"folder" ).get_ref< cstr_t >() :
"";
62 cstr_t title = plotDef.contains(
"title" ) ?
63 plotDef.at(
"title" ).get_ref< cstr_t >() :
"";
66 unsigned int nBinsX = plotDef.contains(
"xAxis_nBins" ) ?
67 getInt( plotDef.at(
"xAxis_nBins" ).get_ref< cstr_t >() ) : 0;
70 unsigned int nBinsY = plotDef.contains(
"yAxis_nBins" ) ?
71 getInt( plotDef.at(
"yAxis_nBins" ).get_ref< cstr_t >() ) : 0;
74 unsigned int nBinsZ = plotDef.contains(
"zAxis_nBins" ) ?
75 getInt( plotDef.at(
"zAxis_nBins" ).get_ref< cstr_t >() ) : 0;
78 float xLow = plotDef.contains(
"xAxis_low" ) ?
79 getFloat( plotDef.at(
"xAxis_low" ).get_ref< cstr_t >() ) : 0.;
80 float xHigh = plotDef.contains(
"xAxis_high" ) ?
81 getFloat( plotDef.at(
"xAxis_high" ).get_ref< cstr_t >() ) : 0.;
84 float yLow = plotDef.contains(
"yAxis_low" ) ?
85 getFloat( plotDef.at(
"yAxis_low" ).get_ref< cstr_t >() ) : 0.;
86 float yHigh = plotDef.contains(
"yAxis_high" ) ?
87 getFloat( plotDef.at(
"yAxis_high" ).get_ref< cstr_t >() ) : 0.;
90 float zLow = plotDef.contains(
"zAxis_low" ) ?
91 getFloat( plotDef.at(
"zAxis_low" ).get_ref< cstr_t >() ) : 0.;
92 float zHigh = plotDef.contains(
"zAxis_high" ) ?
93 getFloat( plotDef.at(
"zAxis_high" ).get_ref< cstr_t >() ) : 0.;
96 bool xDoLogLinBins(
false);
97 if( plotDef.contains(
"xAxis_doLogLinBins" ) ) {
98 std::string xDoLogLinBinsStr = plotDef.at(
"xAxis_doLogLinBins" ).get_ref< cstr_t >();
99 if( xDoLogLinBinsStr ==
"true" ) xDoLogLinBins =
true;
100 else if( xDoLogLinBinsStr ==
"false" ) xDoLogLinBins =
false;
105 bool yDoLogLinBins(
false);
106 if( plotDef.contains(
"yAxis_doLogLinBins" ) ) {
107 std::string yDoLogLinBinsStr = plotDef.at(
"yAxis_doLogLinBins" ).get_ref< cstr_t >();
108 if( yDoLogLinBinsStr ==
"true" ) yDoLogLinBins =
true;
109 else if( yDoLogLinBinsStr ==
"false" ) yDoLogLinBins =
false;
114 bool zDoLogLinBins(
false);
115 if( plotDef.contains(
"zAxis_doLogLinBins" ) ) {
116 std::string zDoLogLinBinsStr = plotDef.at(
"zAxis_doLogLinBins" ).get_ref< cstr_t >();
117 if( zDoLogLinBinsStr ==
"true" ) zDoLogLinBins =
true;
118 else if( zDoLogLinBinsStr ==
"false" ) zDoLogLinBins =
false;
123 strVec_t xBinsStrVec;
124 if( plotDef.contains(
"xAxis_bins" ) ) xBinsStrVec = plotDef.at(
"xAxis_bins" ).get< strVec_t >();
125 std::vector< float > xBinsVec;
126 for( cstr_t thisBin : xBinsStrVec ) xBinsVec.push_back(
getFloat( thisBin ) );
127 if( not xBinsVec.empty() ) {
129 xLow = xBinsVec.front(); xHigh = xBinsVec.back(); nBinsX = xBinsVec.size() - 1;
133 strVec_t yBinsStrVec;
134 if( plotDef.contains(
"yAxis_bins" ) ) yBinsStrVec = plotDef.at(
"yAxis_bins" ).get< strVec_t >();
135 std::vector< float > yBinsVec;
136 for( cstr_t thisBin : yBinsStrVec ) yBinsVec.push_back(
getFloat( thisBin ) );
137 if( not yBinsVec.empty() ) {
139 yLow = yBinsVec.front(); yHigh = yBinsVec.back(); nBinsY = yBinsVec.size() - 1;
143 strVec_t zBinsStrVec;
144 if( plotDef.contains(
"zAxis_bins" ) ) zBinsStrVec = plotDef.at(
"zAxis_bins" ).get< strVec_t >();
145 std::vector< float > zBinsVec;
146 for( cstr_t thisBin : zBinsStrVec ) zBinsVec.push_back(
getFloat( thisBin ) );
147 if( not zBinsVec.empty() ) {
149 zLow = zBinsVec.front(); zHigh = zBinsVec.back(); nBinsZ = zBinsVec.size() - 1;
153 cstr_t xTitle = plotDef.contains(
"xAxis_title" ) ?
154 plotDef.at(
"xAxis_title" ).get_ref< cstr_t >() :
"";
157 cstr_t yTitle = plotDef.contains(
"yAxis_title" ) ?
158 plotDef.at(
"yAxis_title" ).get_ref< cstr_t >() :
"";
161 cstr_t zTitle = plotDef.contains(
"zAxis_title" ) ?
162 plotDef.at(
"zAxis_title" ).get_ref< cstr_t >() :
"";
165 strVec_t xBinLabelsVec;
166 if( plotDef.contains(
"xAxis_labels" ) ) xBinLabelsVec = plotDef.at(
"xAxis_labels" ).get< strVec_t >();
167 if( not xBinLabelsVec.empty() ) {
169 nBinsX = xBinLabelsVec.size(); xLow = 0; xHigh = nBinsX;
173 strVec_t yBinLabelsVec;
174 if( plotDef.contains(
"yAxis_labels" ) ) yBinLabelsVec = plotDef.at(
"yAxis_labels" ).get< strVec_t >();
175 if( not yBinLabelsVec.empty() ) {
177 nBinsY = yBinLabelsVec.size(); yLow = 0; yHigh = nBinsY;
181 strVec_t zBinLabelsVec;
182 if( plotDef.contains(
"zAxis_labels" ) ) zBinLabelsVec = plotDef.at(
"zAxis_labels" ).get< strVec_t >();
183 if( not zBinLabelsVec.empty() ) {
185 nBinsZ = zBinLabelsVec.size(); zLow = 0; zHigh = nBinsZ;
189 plotDefVec.emplace_back(
191 xTitle, nBinsX, xLow, xHigh, xDoLogLinBins, xBinsVec, xBinLabelsVec,
192 yTitle, nBinsY, yLow, yHigh, yDoLogLinBins, yBinsVec, yBinLabelsVec,
193 zTitle, nBinsZ, zLow, zHigh, zDoLogLinBins, zBinsVec, zBinLabelsVec,
197 if( not plotDefVec.back().isValid() ) {
199 "\n\t- string: " << plotDefStr <<
200 "\n\t- digest: " << plotDefVec.back().plotDigest() );
201 plotDefVec.pop_back();