5 #define APEvtWeight_cxx
14 : m_current_evt_weights(vector< vector<
APWeightEntry* > >(12)),
35 cout <<
"ERROR in APEvtWeight::AddWeightToEvt: Trying to add a weight entry to a combined event weight. Ignoring command (not adding weight entry)." << endl;
38 cout <<
"ERROR in APEvtWeight::AddWeightToEvt: Trying to add a non-trigger weight entry to trigger event weight. Ignoring command (not adding weight entry)." << endl;
49 if ( ((a_type >=
APEvtWeight::kMuon && a_type <=
APEvtWeight::kJet) || (b_type >=
APEvtWeight::kMuon && b_type <=
APEvtWeight::kJet)) && (a_type != b_type) ) cout <<
"WARNING in APEvtWeight::operator&&: Trying to logically AND weights for single component triggers in multiobject configuration. You shouldn't do this, but use kXxxMO types instead. Uncertainties will be incorrect." << endl;
51 if ( a_type != b_type ) {
78 if (!
b.m_isComputed)
b.Compute();
79 if (!
a.m_isComputed)
a.Compute();
82 ret.
m_variance =
a.m_variance *
b.m_k_evt_weight *
b.m_k_evt_weight +
b.m_variance *
a.m_k_evt_weight *
a.m_k_evt_weight;
83 ret.
m_variance_sys =
a.m_variance_sys *
b.m_k_evt_weight *
b.m_k_evt_weight +
b.m_variance_sys *
a.m_k_evt_weight *
a.m_k_evt_weight;
91 cout <<
"WARNING in APEvtWeight::operator&&: Trying to combine already combined event weights with overlapping objects. Uncertainties will be incorrect." << endl;
118 if (!
b.m_isComputed)
b.Compute();
119 if (!
a.m_isComputed)
a.Compute();
122 ret.
m_variance =
a.m_variance *
b.m_k_evt_weight *
b.m_k_evt_weight +
b.m_variance *
a.m_k_evt_weight *
a.m_k_evt_weight;
123 ret.
m_variance_sys =
a.m_variance_sys *
b.m_k_evt_weight *
b.m_k_evt_weight +
b.m_variance_sys *
a.m_k_evt_weight *
a.m_k_evt_weight;
161 if (!
b.m_isComputed)
b.Compute();
162 if (!
a.m_isComputed)
a.Compute();
165 ret.
m_k_evt_weight =
a.m_k_evt_weight +
b.m_k_evt_weight * ( 1.0 -
a.m_k_evt_weight );
166 ret.
m_variance =
a.m_variance * ( 1.0 -
b.m_k_evt_weight ) * ( 1.0 -
b.m_k_evt_weight ) +
b.m_variance * ( 1.0 -
a.m_k_evt_weight ) * ( 1.0 -
a.m_k_evt_weight );
167 ret.
m_variance_sys =
a.m_variance_sys * ( 1.0 -
b.m_k_evt_weight ) * ( 1.0 -
b.m_k_evt_weight ) +
b.m_variance_sys * ( 1.0 -
a.m_k_evt_weight ) * ( 1.0 -
a.m_k_evt_weight );
172 cout <<
"WARNING in APEvtWeight::operator||: Trying to combine already combined event weights with overlapping objects. Uncertainties will be incorrect." << endl;
202 if (!
b.m_isComputed)
b.Compute();
203 if (!
a.m_isComputed)
a.Compute();
206 ret.
m_k_evt_weight = 1.0 - (1.0 -
a.m_k_evt_weight) * (1.0 -
b.m_k_evt_weight);
207 ret.
m_variance =
a.m_variance * (1.0 -
b.m_k_evt_weight) * (1.0 -
b.m_k_evt_weight) +
b.m_variance * (1.0 -
a.m_k_evt_weight) * (1.0 -
a.m_k_evt_weight);
208 ret.
m_variance_sys =
a.m_variance_sys * (1.0 -
b.m_k_evt_weight) * (1.0 -
b.m_k_evt_weight) +
b.m_variance_sys * (1.0 -
a.m_k_evt_weight) * (1.0 -
a.m_k_evt_weight);
253 cout <<
"WARNING in APEvtWeight::GetWeightObjects: Trying to get non-defined object type. Returning empty vector." << endl;
254 return vector< APWeightEntry* >();
267 void APEvtWeight::Compute() {
269 cout <<
"ERROR in APEvtWeight::Compute: Trying to compute combined event weight. Ignoring command." << endl;
271 double evt_weight = 1.0;
272 double variance = 0.0;
273 double variance_sys = 0.0;
276 double variance_summand = 1.0;
278 for (
unsigned int k = 0;
k <
I; ++
k) {
289 bool isAsymTrig =
false;
290 vector<unsigned int> temp_vec_IDs;
293 bool knownID =
false;
294 for(
unsigned int j = 0, J = temp_vec_IDs.size(); j < J; ++j ) {
299 if( temp_vec_IDs.size() != 1 ) isAsymTrig =
true;
306 double variance_summand = 0.0;
308 for(
unsigned int k = 0;
k <
I; ++
k ) {
309 double temp_variance_summand = 0.0;
314 for(
unsigned int j = 0; j <
I; ++j ) {
317 variance_summand += temp_variance_summand;
321 evt_weight += temp_weight;
333 if( temp_vec_IDs.size() != 4 ) { std::cout <<
"WARNING! Required exactly 4 different efficiencies, while " << temp_vec_IDs.size() <<
" efficiencies are provided! Please check your implementation! Weight is set to 0! " << std::endl; }
337 double evt_weight_leg1 = 1.;
338 double evt_weight_leg2 = 1.;
339 double evt_weight_leg2_cond = 1.;
340 double evt_weight_singleHit = 0.;
347 double temp_weight = 0.;
350 if(
i == j )
continue;
353 evt_weight_singleHit += temp_weight;
356 evt_weight = evt_weight_leg1 + evt_weight_leg2 - evt_weight_leg2_cond + evt_weight_singleHit;
358 double variance_leg1 = 0.;
359 double variance_leg2 = 0.;
360 double variance_leg2_cond = 0.;
361 double variance_singleHit = 0.;
364 double variance_k = 0.;
365 double variance_temp = 1.;
367 if(
i ==
k )
continue;
370 variance_k += variance_temp;
374 if(
i ==
k )
continue;
377 variance_k += variance_temp;
380 if(
i ==
k )
continue;
383 variance_k += variance_temp;
386 if( j ==
k )
continue;
389 if(
i == j )
continue;
391 if(
i ==
k )
continue;
394 variance_temp += variance_ijk_temp;
396 variance_k += variance_temp;
402 double variance_temp = 1.;
404 if(
i ==
k )
continue;
412 double variance_k = 0.;
413 double variance_temp = 1.;
416 if(
i ==
k )
continue;
419 variance_k += variance_temp;
424 if( j ==
i )
continue;
426 if(
i ==
k )
continue;
429 variance_temp += variance_ijk_temp;
431 variance_k += variance_temp;
439 if(
i ==
k )
continue;
446 variance = variance_leg1 + variance_leg2 + variance_leg2_cond + variance_singleHit;