121 vector< vector<APWeightEntry*> > temp_vec_all{
122 temp_vec_mu, temp_vec_tau, temp_vec_el, temp_vec_jet,
123 std::move(temp_vec_mumo), std::move(temp_vec_taumo), std::move(temp_vec_elmo), std::move(temp_vec_jetmo),
124 temp_vec_dimu, temp_vec_ditau, temp_vec_diel, temp_vec_dijet
129 for(
unsigned int iAll = 0, IAll = temp_vec_all.size(); iAll < IAll; ++iAll ) {
130 for(
unsigned int i = 0,
I = temp_vec_all[iAll].
size(); i <
I; ++i ) {
131 unsigned int ID = temp_vec_all[iAll][i]->GetID();
134 vector<int> original_dimensions = temp_vec_all[iAll][i]->GetOriginalDimensions();
135 int *
bins =
new int[original_dimensions.size()];
136 double *
xmin =
new double[original_dimensions.size()];
137 double *
xmax =
new double[original_dimensions.size()];
138 for(
unsigned int j = 0, J = original_dimensions.size(); j < J; ++j ) {
139 bins[j] = original_dimensions[j];
150 vector<APWeightEntry*> temp_vec_rel;
156 for (
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; ++i ) {
157 vector<int>
coord = temp_vec_rel[i]->GetCoords();
158 double weight_uncert = sqrt(temp_vec_rel[i]->
GetVariance());
159 for (
unsigned int j = 0; j <
I; ++j ) {
160 if (j == i)
continue;
161 weight_uncert *= (1.0 - temp_vec_rel[j]->GetExpectancy());
170 vector<APWeightEntry*> temp_vec_rel;
176 bool isAsymTrig =
false;
177 vector<unsigned int> temp_vec_IDs;
178 temp_vec_IDs.push_back(temp_vec_rel[0]->GetID() );
179 for(
unsigned int i = 1,
I = temp_vec_rel.size(); i <
I; ++i ) {
180 bool knownID =
false;
181 for(
unsigned int j = 0, J = temp_vec_IDs.size(); j < J; ++j ) {
182 if( temp_vec_rel[i]->GetID() == temp_vec_IDs[j] ) { knownID =
true;
break; }
184 if( !knownID ) temp_vec_IDs.push_back( temp_vec_rel[i]->GetID() );
186 if( temp_vec_IDs.size() != 1 ) isAsymTrig =
true;
190 for (
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; ++i ) {
191 vector<int>
coord = temp_vec_rel[i]->GetCoords();
192 double weight_uncert = sqrt(temp_vec_rel[i]->
GetVariance());
193 double weight_derivative = 0.;
194 for (
unsigned int j = 0; j <
I; ++j ) {
195 if (j == i)
continue;
196 double weight_derivative_temp = temp_vec_rel[j]->GetExpectancy();
197 for (
unsigned int k = 0; k <
I; ++k ) {
198 if( k == j || k == i )
continue;
199 weight_derivative_temp *= (1.0 - temp_vec_rel[k]->GetExpectancy());
201 weight_derivative += weight_derivative_temp;
203 weight_uncert *= weight_derivative;
212 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
213 vector<int>
coord = temp_vec_rel[k]->GetCoords();
214 double variance_k = 0.;
215 double variance_temp = 1.;
216 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
217 if( i == k )
continue;
218 variance_temp *= (1. - temp_vec_rel[i]->GetExpectancy());
220 variance_k += variance_temp;
222 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
223 variance_temp *= (1.0 - temp_vec_rel[i+2]->GetExpectancy());
224 if( i == k )
continue;
225 variance_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy());
227 variance_k += variance_temp;
228 variance_temp = -temp_vec_rel[k+3]->GetExpectancy();
229 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
230 if( i == k )
continue;
231 variance_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy())*(1.0 - temp_vec_rel[i+2]->GetExpectancy());
233 variance_k += variance_temp;
235 for(
unsigned int j = 0, J = temp_vec_rel.size(); j < J; j+= 4 ) {
236 if( j == k )
continue;
237 double variance_ijk_temp = temp_vec_rel[j]->GetExpectancy()*temp_vec_rel[j+3]->GetExpectancy();
238 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
239 if( i == j )
continue;
240 variance_ijk_temp *= (1.0 - temp_vec_rel[i+2]->GetExpectancy());
241 if( i == k )
continue;
242 variance_ijk_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy());
244 variance_temp += variance_ijk_temp;
246 variance_k += variance_temp;
247 variance_k *= variance_k*temp_vec_rel[k]->GetVariance();
253 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
254 vector<int>
coord = temp_vec_rel[k+1]->GetCoords();
255 double variance_temp = 1.;
256 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
257 if( i == k )
continue;
258 variance_temp *= (1. - temp_vec_rel[i+1]->GetExpectancy());
260 variance_temp *= variance_temp*temp_vec_rel[k+1]->GetVariance();
266 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
267 vector<int>
coord = temp_vec_rel[k+2]->GetCoords();
268 double variance_k = 0.;
269 double variance_temp = 1.;
270 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
271 variance_temp *= (1. - temp_vec_rel[i]->GetExpectancy());
272 if( i == k )
continue;
273 variance_temp *= (1. - temp_vec_rel[i+2]->GetExpectancy());
275 variance_k += variance_temp;
277 for(
unsigned int j = 0, J = temp_vec_rel.size(); j < J; j+= 4 ) {
278 double variance_ijk_temp = temp_vec_rel[j]->GetExpectancy()*temp_vec_rel[j+3]->GetExpectancy();
279 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
280 if( j == i )
continue;
281 variance_ijk_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy());
282 if( i == k )
continue;
283 variance_ijk_temp *= (1.0 - temp_vec_rel[i+2]->GetExpectancy());
285 variance_temp += variance_ijk_temp;
287 variance_k += variance_temp;
288 variance_k *= variance_k*temp_vec_rel[k+2]->GetVariance();
294 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
295 vector<int>
coord = temp_vec_rel[k+3]->GetCoords();
296 double variance_k = - temp_vec_rel[k]->GetExpectancy();
297 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
298 if( i == k )
continue;
299 variance_k *= (1.0 - temp_vec_rel[i]->GetExpectancy())*(1.0 - temp_vec_rel[i+3]->GetExpectancy());
301 variance_k *= variance_k*temp_vec_rel[k+3]->GetVariance();
311 for (
unsigned int iAll = 0, IAll = temp_vec_all.size(); iAll < IAll; ++iAll ) {
312 for (
unsigned int i = 0,
I = temp_vec_all[iAll].
size(); i <
I; ++i ) {
313 vector<int>
coord = temp_vec_all[iAll][i]->GetCoords();
314 double weight_uncert = sqrt(temp_vec_all[iAll][i]->
GetVariance());
315 weight_uncert *= (temp_vec_all[iAll][i]->GetExpectancy() <= numeric_limits<double>::epsilon() ) ? 0. : evt_weight->
GetWeight()/temp_vec_all[iAll][i]->GetExpectancy();
330 vector<double> temp_weight_rel(12,1.);
333 for (
unsigned int j = 0; j < 8; ++j) {
334 for (
unsigned int i = 0,
I = temp_vec_all[j].
size(); i <
I; ++i ) temp_weight_rel[j] *= (1.0 - temp_vec_all[j][i]->GetExpectancy());
338 else temp_weight_rel[j] = (temp_vec_all[j].size() > 0) ? (1.0 - temp_weight_rel[j]) : 1.;
343 for (
unsigned int j = 8; j < 12; ++j) {
344 if( temp_vec_all[j].
size() >= 2 ) {
345 for (
unsigned int i = 0,
I = temp_vec_all[j].
size(); i <
I; ++i) temp_weight_rel[j] *= (1.0 - temp_vec_all[j][i]->GetExpectancy());
346 for (
unsigned int i = 0,
I = temp_vec_all[j].
size(); i <
I; ++i) {
347 double temp_weight = temp_vec_all[j][i]->GetExpectancy();
348 for (
unsigned int k = 0; k <
I; ++k ) {
349 if( k == i )
continue;
350 temp_weight *= (1.0 - temp_vec_all[j][k]->GetExpectancy());
352 temp_weight_rel[j] += temp_weight;
359 double temp_weight_MO = 1.;
360 int n_noObject_MO = 0;
361 for (
unsigned int l = 4; l < 8; ++l ) {
362 temp_weight_MO *= temp_weight_rel[l];
363 if( temp_vec_all[l].
size() == 0 ) n_noObject_MO += 1;
365 if( n_noObject_MO >= 2 ) temp_weight_MO = 0.;
369 for (
unsigned int j = 0; j < 8; ++j) {
370 for (
unsigned int i = 0,
I = temp_vec_all[j].
size(); i <
I; ++i ) {
371 vector<int>
coord = temp_vec_all[j][i]->GetCoords();
372 double weight_uncert = sqrt(temp_vec_all[j][i]->
GetVariance());
373 for (
unsigned int k = 0; k <
I; ++k ) {
374 if( k == i )
continue;
375 weight_uncert *= (1.0 - temp_vec_all[j][k]->GetExpectancy());
377 for(
unsigned int l = 0; l < 4; ++l ) {
378 if( l == j )
continue;
381 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
383 for(
unsigned int l = 8; l < 12; ++l ) {
384 if( l == j )
continue;
387 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
390 if( j < 4 || j > 7 ) {
393 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
395 else if( j >= 4 && j <= 7 && temp_weight_rel[j] > numeric_limits<double>::epsilon() ) weight_uncert = weight_uncert*temp_weight_MO/temp_weight_rel[j];
402 for (
unsigned int j = 8; j < 12; ++j) {
403 if( temp_vec_all[j].
size() >= 2 ) {
404 for (
unsigned int i = 0,
I = temp_vec_all[j].
size(); i <
I; ++i ) {
405 vector<int>
coord = temp_vec_all[j][i]->GetCoords();
406 double weight_uncert = sqrt(temp_vec_all[j][i]->
GetVariance());
407 double weight_derivative = 0.;
408 for (
unsigned int k = 0; k <
I; ++k ) {
409 if( k == i )
continue;
410 double weight_derivative_temp = temp_vec_all[j][k]->GetExpectancy();
411 for (
unsigned int l = 0; l <
I; ++l ) {
412 if( l == k || l == i )
continue;
413 weight_derivative_temp *= (1.0 - temp_vec_all[j][l]->GetExpectancy());
415 weight_derivative += weight_derivative_temp;
417 weight_uncert *= weight_derivative;
418 for(
unsigned int l = 0; l < 4; ++l ) {
422 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
424 for(
unsigned int l = 8; l < 12; ++l ) {
425 if( l == j )
continue;
428 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
432 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;