119 vector< vector<APWeightEntry*> > temp_vec_all{
120 temp_vec_mu, temp_vec_tau, temp_vec_el, temp_vec_jet,
121 std::move(temp_vec_mumo), std::move(temp_vec_taumo), std::move(temp_vec_elmo), std::move(temp_vec_jetmo),
122 temp_vec_dimu, temp_vec_ditau, temp_vec_diel, temp_vec_dijet
127 for(
unsigned int iAll = 0, IAll = temp_vec_all.size(); iAll < IAll; ++iAll ) {
128 for(
unsigned int i = 0,
I = temp_vec_all[iAll].size(); i <
I; ++i ) {
129 unsigned int ID = temp_vec_all[iAll][i]->GetID();
132 vector<int> original_dimensions = temp_vec_all[iAll][i]->GetOriginalDimensions();
133 int *
bins =
new int[original_dimensions.size()];
134 double *
xmin =
new double[original_dimensions.size()];
135 double *
xmax =
new double[original_dimensions.size()];
136 for(
unsigned int j = 0, J = original_dimensions.size(); j < J; ++j ) {
137 bins[j] = original_dimensions[j];
148 vector<APWeightEntry*> temp_vec_rel;
154 for (
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; ++i ) {
155 vector<int>
coord = temp_vec_rel[i]->GetCoords();
156 double weight_uncert = sqrt(temp_vec_rel[i]->
GetVariance());
157 for (
unsigned int j = 0; j <
I; ++j ) {
158 if (j == i)
continue;
159 weight_uncert *= (1.0 - temp_vec_rel[j]->GetExpectancy());
168 vector<APWeightEntry*> temp_vec_rel;
174 bool isAsymTrig =
false;
175 vector<unsigned int> temp_vec_IDs;
176 temp_vec_IDs.push_back(temp_vec_rel[0]->GetID() );
177 for(
unsigned int i = 1,
I = temp_vec_rel.size(); i <
I; ++i ) {
178 bool knownID =
false;
179 for(
unsigned int j = 0, J = temp_vec_IDs.size(); j < J; ++j ) {
180 if( temp_vec_rel[i]->GetID() == temp_vec_IDs[j] ) { knownID =
true;
break; }
182 if( !knownID ) temp_vec_IDs.push_back( temp_vec_rel[i]->GetID() );
184 if( temp_vec_IDs.size() != 1 ) isAsymTrig =
true;
188 for (
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; ++i ) {
189 vector<int>
coord = temp_vec_rel[i]->GetCoords();
190 double weight_uncert = sqrt(temp_vec_rel[i]->
GetVariance());
191 double weight_derivative = 0.;
192 for (
unsigned int j = 0; j <
I; ++j ) {
193 if (j == i)
continue;
194 double weight_derivative_temp = temp_vec_rel[j]->GetExpectancy();
195 for (
unsigned int k = 0; k <
I; ++k ) {
196 if( k == j || k == i )
continue;
197 weight_derivative_temp *= (1.0 - temp_vec_rel[k]->GetExpectancy());
199 weight_derivative += weight_derivative_temp;
201 weight_uncert *= weight_derivative;
210 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
211 vector<int>
coord = temp_vec_rel[k]->GetCoords();
212 double variance_k = 0.;
213 double variance_temp = 1.;
214 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
215 if( i == k )
continue;
216 variance_temp *= (1. - temp_vec_rel[i]->GetExpectancy());
218 variance_k += variance_temp;
220 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
221 variance_temp *= (1.0 - temp_vec_rel[i+2]->GetExpectancy());
222 if( i == k )
continue;
223 variance_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy());
225 variance_k += variance_temp;
226 variance_temp = -temp_vec_rel[k+3]->GetExpectancy();
227 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
228 if( i == k )
continue;
229 variance_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy())*(1.0 - temp_vec_rel[i+2]->GetExpectancy());
231 variance_k += variance_temp;
233 for(
unsigned int j = 0, J = temp_vec_rel.size(); j < J; j+= 4 ) {
234 if( j == k )
continue;
235 double variance_ijk_temp = temp_vec_rel[j]->GetExpectancy()*temp_vec_rel[j+3]->GetExpectancy();
236 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
237 if( i == j )
continue;
238 variance_ijk_temp *= (1.0 - temp_vec_rel[i+2]->GetExpectancy());
239 if( i == k )
continue;
240 variance_ijk_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy());
242 variance_temp += variance_ijk_temp;
244 variance_k += variance_temp;
245 variance_k *= variance_k*temp_vec_rel[k]->GetVariance();
251 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
252 vector<int>
coord = temp_vec_rel[k+1]->GetCoords();
253 double variance_temp = 1.;
254 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
255 if( i == k )
continue;
256 variance_temp *= (1. - temp_vec_rel[i+1]->GetExpectancy());
258 variance_temp *= variance_temp*temp_vec_rel[k+1]->GetVariance();
264 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
265 vector<int>
coord = temp_vec_rel[k+2]->GetCoords();
266 double variance_k = 0.;
267 double variance_temp = 1.;
268 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
269 variance_temp *= (1. - temp_vec_rel[i]->GetExpectancy());
270 if( i == k )
continue;
271 variance_temp *= (1. - temp_vec_rel[i+2]->GetExpectancy());
273 variance_k += variance_temp;
275 for(
unsigned int j = 0, J = temp_vec_rel.size(); j < J; j+= 4 ) {
276 double variance_ijk_temp = temp_vec_rel[j]->GetExpectancy()*temp_vec_rel[j+3]->GetExpectancy();
277 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
278 if( j == i )
continue;
279 variance_ijk_temp *= (1.0 - temp_vec_rel[i]->GetExpectancy());
280 if( i == k )
continue;
281 variance_ijk_temp *= (1.0 - temp_vec_rel[i+2]->GetExpectancy());
283 variance_temp += variance_ijk_temp;
285 variance_k += variance_temp;
286 variance_k *= variance_k*temp_vec_rel[k+2]->GetVariance();
292 for(
unsigned int k = 0, K = temp_vec_rel.size(); k < K; k += 4 ) {
293 vector<int>
coord = temp_vec_rel[k+3]->GetCoords();
294 double variance_k = - temp_vec_rel[k]->GetExpectancy();
295 for(
unsigned int i = 0,
I = temp_vec_rel.size(); i <
I; i += 4 ) {
296 if( i == k )
continue;
297 variance_k *= (1.0 - temp_vec_rel[i]->GetExpectancy())*(1.0 - temp_vec_rel[i+3]->GetExpectancy());
299 variance_k *= variance_k*temp_vec_rel[k+3]->GetVariance();
309 for (
unsigned int iAll = 0, IAll = temp_vec_all.size(); iAll < IAll; ++iAll ) {
310 for (
unsigned int i = 0,
I = temp_vec_all[iAll].size(); i <
I; ++i ) {
311 vector<int>
coord = temp_vec_all[iAll][i]->GetCoords();
312 double weight_uncert = sqrt(temp_vec_all[iAll][i]->
GetVariance());
313 weight_uncert *= (temp_vec_all[iAll][i]->GetExpectancy() <= numeric_limits<double>::epsilon() ) ? 0. : evt_weight->
GetWeight()/temp_vec_all[iAll][i]->GetExpectancy();
328 vector<double> temp_weight_rel(12,1.);
331 for (
unsigned int j = 0; j < 8; ++j) {
332 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());
336 else temp_weight_rel[j] = (temp_vec_all[j].size() > 0) ? (1.0 - temp_weight_rel[j]) : 1.;
341 for (
unsigned int j = 8; j < 12; ++j) {
342 if( temp_vec_all[j].size() >= 2 ) {
343 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());
344 for (
unsigned int i = 0,
I = temp_vec_all[j].size(); i <
I; ++i) {
345 double temp_weight = temp_vec_all[j][i]->GetExpectancy();
346 for (
unsigned int k = 0; k <
I; ++k ) {
347 if( k == i )
continue;
348 temp_weight *= (1.0 - temp_vec_all[j][k]->GetExpectancy());
350 temp_weight_rel[j] += temp_weight;
357 double temp_weight_MO = 1.;
358 int n_noObject_MO = 0;
359 for (
unsigned int l = 4; l < 8; ++l ) {
360 temp_weight_MO *= temp_weight_rel[l];
361 if( temp_vec_all[l].size() == 0 ) n_noObject_MO += 1;
363 if( n_noObject_MO >= 2 ) temp_weight_MO = 0.;
367 for (
unsigned int j = 0; j < 8; ++j) {
368 for (
unsigned int i = 0,
I = temp_vec_all[j].size(); i <
I; ++i ) {
369 vector<int>
coord = temp_vec_all[j][i]->GetCoords();
370 double weight_uncert = sqrt(temp_vec_all[j][i]->
GetVariance());
371 for (
unsigned int k = 0; k <
I; ++k ) {
372 if( k == i )
continue;
373 weight_uncert *= (1.0 - temp_vec_all[j][k]->GetExpectancy());
375 for(
unsigned int l = 0; l < 4; ++l ) {
376 if( l == j )
continue;
379 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
381 for(
unsigned int l = 8; l < 12; ++l ) {
382 if( l == j )
continue;
385 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
388 if( j < 4 || j > 7 ) {
391 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
393 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];
400 for (
unsigned int j = 8; j < 12; ++j) {
401 if( temp_vec_all[j].size() >= 2 ) {
402 for (
unsigned int i = 0,
I = temp_vec_all[j].size(); i <
I; ++i ) {
403 vector<int>
coord = temp_vec_all[j][i]->GetCoords();
404 double weight_uncert = sqrt(temp_vec_all[j][i]->
GetVariance());
405 double weight_derivative = 0.;
406 for (
unsigned int k = 0; k <
I; ++k ) {
407 if( k == i )
continue;
408 double weight_derivative_temp = temp_vec_all[j][k]->GetExpectancy();
409 for (
unsigned int l = 0; l <
I; ++l ) {
410 if( l == k || l == i )
continue;
411 weight_derivative_temp *= (1.0 - temp_vec_all[j][l]->GetExpectancy());
413 weight_derivative += weight_derivative_temp;
415 weight_uncert *= weight_derivative;
416 for(
unsigned int l = 0; l < 4; ++l ) {
417 if( l == j )
continue;
420 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
422 for(
unsigned int l = 8; l < 12; ++l ) {
423 if( l == j )
continue;
426 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
430 else cout <<
"WARNING: handling for this weight type is unknown! uncertainties will be incorrect" << endl;
432 if( j >= 4 && j <= 7 && temp_weight_rel[j] > numeric_limits<double>::epsilon() ) weight_uncert /= temp_weight_rel[j];