1diff --git a/src/fnlo-tk-statunc.cc b/src/fnlo-tk-statunc.cc
2index 62d1eec..ad62cac 100644
3--- a/src/fnlo-tk-statunc.cc
4+++ b/src/fnlo-tk-statunc.cc
5@@ -30,7 +30,16 @@
6 #include "fastnlotk/fastNLOLHAPDF.h"
7 #include "fastnlotk/speaker.h"
8 #ifdef WITH_YODA
9+#if defined __has_include
10+#if !__has_include("YODA/WriterAIDA.h")
11+#define WITH_YODA2
12+#endif
13+#endif
14+#ifdef WITH_YODA2
15+#include "YODA/Scatter.h"
16+#else
17 #include "YODA/Scatter2D.h"
18+#endif
19 #include "YODA/WriterYODA.h"
20 #endif
21
22@@ -493,28 +502,25 @@ int main(int argc, char** argv) {
23
24 //! --- 1D
25 if (NDim == 1) {
26- //! Vectors to fill 2D scatter plot
27- vector < double > x;
28- vector < double > y;
29- vector < double > exminus;
30- vector < double > explus;
31- vector < double > eyminus;
32- vector < double > eyplus;
33+ //! Vector to fill 2D scatter plot
34+ vector<YODA::Point2D> points;
35 //! Loop over bins in outer (1st) dimension
36 for (unsigned int k =0 ; k<NDimBins[0] ; k++) {
37- x.push_back((bins[iobs].second + bins[iobs].first)/2.0);
38- explus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
39- exminus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
40- y.push_back(xs[iobs]);
41- eyplus.push_back(dxsu[iobs]);
42- eyminus.push_back(std::abs(dxsl[iobs]));
43+ points.emplace_back(
44+ (bins[iobs].second + bins[iobs].first)/2.0,
45+ xs[iobs],
46+ (bins[iobs].second - bins[iobs].first)/2.0,
47+ (bins[iobs].second - bins[iobs].first)/2.0,
48+ std::abs(dxsl[iobs]),
49+ dxsu[iobs]
50+ );
51 iobs++;
52 }
53 stringstream plotno; // To make i+1 from int
54 plotno << offset; // to a string for the naming
55 // RivetId.replace( capital_pos +3 - plotno.str().size(), plotno.str().size(), plotno.str()); // Next plot name
56 // Pointer in order not to be deleted after we exit the loop, so we can then save them into the yoda file
57- YODA::Scatter2D * plot = new YODA::Scatter2D(x,y,exminus,explus,eyminus,eyplus,"/" + RivetId,LineName);
58+ YODA::Scatter2D * plot = new YODA::Scatter2D(points, "/" + RivetId, LineName);
59 // Insert the plot pointer into the vector of analysis object pointers
60 aos.push_back(plot);
61 }
62@@ -522,29 +528,26 @@ int main(int argc, char** argv) {
63 else if (NDim == 2) {
64 //! Loop over bins in outer (1st) dimension
65 for (unsigned int j=0; j<NDimBins[0]; j++) {
66- //! Vectors to fill 2D scatter plot
67- vector < double > x;
68- vector < double > y;
69- vector < double > exminus;
70- vector < double > explus;
71- vector < double > eyminus;
72- vector < double > eyplus;
73+ //! Vector to fill 2D scatter plot
74+ vector<YODA::Point2D> points;
75 //! Loop over bins in inner (2nd) dimension
76 NDimBins[1] = fnlo.GetNDim1Bins(j);
77 for (unsigned int k = 0; k<NDimBins[1]; k++) {
78- x.push_back((bins[iobs].second + bins[iobs].first)/2.0);
79- explus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
80- exminus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
81- y.push_back(xs[iobs]);
82- eyplus.push_back(dxsu[iobs]);
83- eyminus.push_back(std::abs(dxsl[iobs]));
84+ points.emplace_back(
85+ (bins[iobs].second + bins[iobs].first)/2.0,
86+ xs[iobs],
87+ (bins[iobs].second - bins[iobs].first)/2.0,
88+ (bins[iobs].second - bins[iobs].first)/2.0,
89+ std::abs(dxsl[iobs]),
90+ dxsu[iobs]
91+ );
92 iobs++;
93 }
94 stringstream plotno; // To make i+1 from int
95 plotno << offset+j; // to a string for the naming
96 RivetId.replace( capital_pos +3 - plotno.str().size(), plotno.str().size(), plotno.str()); // Next plot name
97 // Pointer in order not to be deleted after we exit the loop, so we can then save them into the yoda file
98- YODA::Scatter2D * plot = new YODA::Scatter2D(x,y,exminus,explus,eyminus,eyplus,"/" + RivetId,LineName);
99+ YODA::Scatter2D * plot = new YODA::Scatter2D(points, "/" + RivetId, LineName);
100 // Insert the plot pointer into the vector of analysis object pointers
101 aos.push_back(plot);
102 }
103diff --git a/src/fnlo-tk-yodaout.cc b/src/fnlo-tk-yodaout.cc
104index 9aa8ac3..dabe924 100644
105--- a/src/fnlo-tk-yodaout.cc
106+++ b/src/fnlo-tk-yodaout.cc
107@@ -25,7 +25,16 @@
108 #include "fastnlotk/fastNLOTools.h"
109 #include "fastnlotk/speaker.h"
110 #ifdef WITH_YODA
111+#if defined __has_include
112+#if !__has_include("YODA/WriterAIDA.h")
113+#define WITH_YODA2
114+#endif
115+#endif
116+#ifdef WITH_YODA2
117+#include "YODA/Scatter.h"
118+#else
119 #include "YODA/Scatter2D.h"
120+#endif
121 #include "YODA/WriterYODA.h"
122 #endif
123
124@@ -548,26 +557,23 @@ int main(int argc, char** argv) {
125
126 //! --- 1D
127 if (NDim == 1) {
128- //! Vectors to fill 2D scatter plot
129- vector < double > x;
130- vector < double > y;
131- vector < double > exminus;
132- vector < double > explus;
133- vector < double > eyminus;
134- vector < double > eyplus;
135+ //! Vector to fill 2D scatter plot
136+ vector < YODA::Point2D > points;
137 //! Loop over bins in outer (1st) dimension
138 for (unsigned int k =0 ; k<NDimBins[0] ; k++) {
139- x.push_back((bins[iobs].second + bins[iobs].first)/2.0);
140- explus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
141- exminus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
142- y.push_back(xs[iobs]);
143- eyplus.push_back(dxsu[iobs]);
144- eyminus.push_back(std::abs(dxsl[iobs]));
145+ points.emplace_back(
146+ (bins[iobs].second + bins[iobs].first)/2.0,
147+ xs[iobs],
148+ (bins[iobs].second - bins[iobs].first)/2.0,
149+ (bins[iobs].second - bins[iobs].first)/2.0,
150+ std::abs(dxsl[iobs]),
151+ dxsu[iobs]
152+ );
153 iobs++;
154 }
155 #ifdef WITH_YODA
156 /// Pointer in order not to be deleted after we exit the loop, so we can then save them into the yoda file
157- YODA::Scatter2D * plot = new YODA::Scatter2D(x,y,exminus,explus,eyminus,eyplus,"/" + RivetId,LineName);
158+ YODA::Scatter2D * plot = new YODA::Scatter2D(points, "/" + RivetId, LineName);
159 /// Insert the plot pointer into the vector of analysis object pointers
160 aos.push_back(plot);
161 #endif
162@@ -577,23 +583,20 @@ int main(int argc, char** argv) {
163 //! Loop over bins in outer (1st) dimension
164 int nhist = 0;
165 for (unsigned int j=0; j<NDimBins[0]; j++) {
166- //! Vectors to fill 2D scatter plot
167+ //! Vector to fill 2D scatter plot
168 nhist++;
169- vector < double > x;
170- vector < double > y;
171- vector < double > exminus;
172- vector < double > explus;
173- vector < double > eyminus;
174- vector < double > eyplus;
175+ vector < YODA::Point2D > points;
176 //! Loop over bins in inner (2nd) dimension
177 NDimBins[1] = fnlo->GetNDim1Bins(j);
178 for (unsigned int k = 0; k<NDimBins[1]; k++) {
179- x.push_back((bins[iobs].second + bins[iobs].first)/2.0);
180- explus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
181- exminus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
182- y.push_back(xs[iobs]);
183- eyplus.push_back(dxsu[iobs]);
184- eyminus.push_back(std::abs(dxsl[iobs]));
185+ points.emplace_back(
186+ (bins[iobs].second + bins[iobs].first)/2.0,
187+ xs[iobs],
188+ (bins[iobs].second - bins[iobs].first)/2.0,
189+ (bins[iobs].second - bins[iobs].first)/2.0,
190+ std::abs(dxsl[iobs]),
191+ dxsu[iobs]
192+ );
193 iobs++;
194 }
195 /// Derive histogram counter
196@@ -610,7 +613,7 @@ int main(int argc, char** argv) {
197 RivetId.replace(capital_pos +3 - histno.str().size(), histno.str().size(), histno.str());
198 #ifdef WITH_YODA
199 /// Pointer in order not to be deleted after we exit the loop, so we can then save the plots into the yoda file
200- YODA::Scatter2D * plot = new YODA::Scatter2D(x,y,exminus,explus,eyminus,eyplus,"/" + RivetId,LineName);
201+ YODA::Scatter2D * plot = new YODA::Scatter2D(points, "/" + RivetId, LineName);
202 /// Insert the plot pointer into the vector of analysis object pointers
203 aos.push_back(plot);
204 #endif
205@@ -624,23 +627,20 @@ int main(int argc, char** argv) {
206 //! Loop over bins in middle (2nd) dimension
207 NDimBins[1] = fnlo->GetNDim1Bins(j);
208 for (unsigned int k = 0; k<NDimBins[1]; k++) {
209- //! Vectors to fill 2D scatter plot
210+ //! Vector to fill 2D scatter plot
211 nhist++;
212- vector < double > x;
213- vector < double > y;
214- vector < double > exminus;
215- vector < double > explus;
216- vector < double > eyminus;
217- vector < double > eyplus;
218+ vector < YODA::Point2D > points;
219 //! Loop over bins in inner (3rd) dimension
220 NDimBins[2] = fnlo->GetNDim2Bins(j,k);
221 for (unsigned int l = 0; l<NDimBins[2]; l++) {
222- x.push_back((bins[iobs].second + bins[iobs].first)/2.0);
223- explus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
224- exminus.push_back((bins[iobs].second - bins[iobs].first)/2.0);
225- y.push_back(xs[iobs]);
226- eyplus.push_back(dxsu[iobs]);
227- eyminus.push_back(std::abs(dxsl[iobs]));
228+ points.emplace_back(
229+ (bins[iobs].second + bins[iobs].first)/2.0,
230+ xs[iobs],
231+ (bins[iobs].second - bins[iobs].first)/2.0,
232+ (bins[iobs].second - bins[iobs].first)/2.0,
233+ std::abs(dxsl[iobs]),
234+ dxsu[iobs]
235+ );
236 iobs++;
237 }
238 /// Derive histogram counter
239@@ -657,7 +657,7 @@ int main(int argc, char** argv) {
240 RivetId.replace(capital_pos +3 - histno.str().size(), histno.str().size(), histno.str());
241 #ifdef WITH_YODA
242 /// Pointer in order not to be deleted after we exit the loop, so we can then save the plots into the yoda file
243- YODA::Scatter2D * plot = new YODA::Scatter2D(x,y,exminus,explus,eyminus,eyplus,"/" + RivetId,LineName);
244+ YODA::Scatter2D * plot = new YODA::Scatter2D(points, "/" + RivetId, LineName);
245 /// Insert the plot pointer into the vector of analysis object pointers
246 aos.push_back(plot);
247 #endif