MINT2
DecRateCoeff_Bd.cpp
Go to the documentation of this file.
1 #include "Riostream.h"
2 
3 #include "Mint/DecRateCoeff_Bd.h"
4 
5 #include "RooAbsReal.h"
6 #include "RooAbsCategory.h"
7 #include "RooCategory.h"
8 #include <math.h>
9 #include "TMath.h"
10 #include "RooRealConstant.h"
11 #include "RooConstVar.h"
12 
13 DecRateCoeff_Bd::DecRateCoeff_Bd(const std::string& name,
14  const std::string& title,
15  CoeffType _coeff_type_,
16  RooAbsCategory& _finalstate_,
17  RooAbsReal& _cp_coeff_,
18  RooAbsReal& _cp_coeff_bar_,
19  RooAbsCategory& _tag_os_,
20  RooAbsReal& _eta_os_,
21  RooAbsReal& _p0_os_,
22  RooAbsReal& _p1_os_,
23  RooAbsReal& _delta_p0_os_,
24  RooAbsReal& _delta_p1_os_,
25  RooAbsReal& _avg_eta_os_,
26  RooAbsReal& _tageff_os_,
27  RooAbsReal& _tageff_asym_os_,
28  RooAbsCategory& _tag_ss_,
29  RooAbsReal& _eta_ss_,
30  RooAbsReal& _p0_ss_,
31  RooAbsReal& _p1_ss_,
32  RooAbsReal& _delta_p0_ss_,
33  RooAbsReal& _delta_p1_ss_,
34  RooAbsReal& _avg_eta_ss_,
35  RooAbsReal& _tageff_ss_,
36  RooAbsReal& _tageff_asym_ss_,
37  RooAbsReal& _production_asym_,
38  RooAbsReal& _detection_asym_) :
39 RooAbsReal(name.c_str(),title.c_str()),
40 cp_coeff_("cp_coeff_","cp_coeff_",this,_cp_coeff_),
41 cp_coeff_bar_("cp_coeff_bar_","cp_coeff_bar_",this,_cp_coeff_bar_),
42 coeff_type_(_coeff_type_),
43 finalstate_("finalstate_","finalstate_",this,_finalstate_),
44 tag_os_("tag_os_","tag_os_",this,_tag_os_),
45 eta_os_("eta_os_","eta_os_",this,_eta_os_),
46 avg_eta_os_("avg_eta_os_","avg_eta_os_",this,_avg_eta_os_),
47 p0_os_("p0_os_","p0_os_",this,_p0_os_),
48 p1_os_("p1_os_","p1_os_",this,_p1_os_),
49 delta_p0_os_("delta_p0_os_","delta_p0_os_",this,_delta_p0_os_),
50 delta_p1_os_("delta_p1_os_","delta_p1_os_",this,_delta_p1_os_),
51 tageff_os_("tageff_os_","tageff_os_",this,_tageff_os_),
52 tageff_asym_os_("tageff_asym_os_","tageff_asym_os_",this,_tageff_asym_os_),
53 tag_ss_("tag_ss_","tag_ss_",this,_tag_ss_),
54 eta_ss_("eta_ss_","eta_ss_",this,_eta_ss_),
55 avg_eta_ss_("avg_eta_ss_","avg_eta_ss_",this,_avg_eta_ss_),
56 p0_ss_("p0_ss_","p0_ss_",this,_p0_ss_),
57 p1_ss_("p1_ss_","p1_ss_",this,_p1_ss_),
58 delta_p0_ss_("delta_p0_ss_","delta_p0_ss_",this,_delta_p0_ss_),
59 delta_p1_ss_("delta_p1_ss_","delta_p1_ss_",this,_delta_p1_ss_),
60 tageff_ss_("tageff_ss_","tageff_ss_",this,_tageff_ss_),
61 tageff_asym_ss_("tageff_asym_ss_","tageff_asym_ss_",this,_tageff_asym_ss_),
62 production_asym_("production_asym_","production_asym_",this,_production_asym_),
63 detection_asym_("detection_asym_","detection_asym_",this,_detection_asym_),
64 onetagger_(false)
65 {
66 }
67 
68 DecRateCoeff_Bd::DecRateCoeff_Bd(const std::string& name,
69  const std::string& title,
70  CoeffType _coeff_type_,
71  RooAbsCategory& _finalstate_,
72  RooAbsReal& _cp_coeff_,
73  RooAbsReal& _cp_coeff_bar_,
74  RooAbsCategory& _tag_os_,
75  RooAbsReal& _eta_os_,
76  RooAbsReal& _p0_os_,
77  RooAbsReal& _p1_os_,
78  RooAbsReal& _delta_p0_os_,
79  RooAbsReal& _delta_p1_os_,
80  RooAbsReal& _avg_eta_os_,
81  RooAbsReal& _tageff_os_,
82  RooAbsReal& _tageff_asym_os_,
83  RooAbsReal& _production_asym_,
84  RooAbsReal& _detection_asym_) :
85 RooAbsReal(name.c_str(),title.c_str()),
86 cp_coeff_("cp_coeff_","cp_coeff_",this,_cp_coeff_),
87 cp_coeff_bar_("cp_coeff_bar_","cp_coeff_bar_",this,_cp_coeff_bar_),
88 coeff_type_(_coeff_type_),
89 finalstate_("finalstate_","finalstate_",this,_finalstate_),
90 tag_os_("tag_os_","tag_os_",this,_tag_os_),
91 eta_os_("eta_os_","eta_os_",this,_eta_os_),
92 avg_eta_os_("avg_eta_os_","avg_eta_os_",this,_avg_eta_os_),
93 p0_os_("p0_os_","p0_os_",this,_p0_os_),
94 p1_os_("p1_os_","p1_os_",this,_p1_os_),
95 delta_p0_os_("delta_p0_os_","delta_p0_os_",this,_delta_p0_os_),
96 delta_p1_os_("delta_p1_os_","delta_p1_os_",this,_delta_p1_os_),
97 tageff_os_("tageff_os_","tageff_os_",this,_tageff_os_),
98 tageff_asym_os_("tageff_asym_os_","tageff_asym_os_",this,_tageff_asym_os_),
99 tag_ss_("tag_ss_","tag_ss_",this,_tag_os_),
100 eta_ss_("eta_ss_","eta_ss_",this,_eta_os_),
101 avg_eta_ss_("avg_eta_ss_","avg_eta_ss_",this,_avg_eta_os_),
102 p0_ss_("p0_ss_","p0_ss_",this,_p0_os_),
103 p1_ss_("p1_ss_","p1_ss_",this,_p1_os_),
104 delta_p0_ss_("delta_p0_ss_","delta_p0_ss_",this,_delta_p0_os_),
105 delta_p1_ss_("delta_p1_ss_","delta_p1_ss_",this,_delta_p1_os_),
106 tageff_ss_("tageff_ss_","tageff_ss_",this,_tageff_os_),
107 tageff_asym_ss_("tageff_asym_ss_","tageff_asym_ss_",this,_tageff_asym_os_),
108 production_asym_("production_asym_","production_asym_",this,_production_asym_),
109 detection_asym_("detection_asym_","detection_asym_",this,_detection_asym_),
110 onetagger_(true)
111 {
112 }
113 
114 
115 DecRateCoeff_Bd::DecRateCoeff_Bd(const DecRateCoeff_Bd& other, const char* name) :
116 RooAbsReal(other,name),
117 cp_coeff_("cp_coeff_",this,other.cp_coeff_),
118 cp_coeff_bar_("cp_coeff_bar_",this,other.cp_coeff_bar_),
119 coeff_type_(other.coeff_type_),
120 finalstate_("finalstate_",this,other.finalstate_),
121 tag_os_("tag_os_",this,other.tag_os_),
122 eta_os_("eta_os_",this,other.eta_os_),
123 avg_eta_os_("avg_eta_os_",this,other.avg_eta_os_),
124 p0_os_("p0_os_",this,other.p0_os_),
125 p1_os_("p1_os_",this,other.p1_os_),
126 delta_p0_os_("delta_p0_os_",this,other.delta_p0_os_),
127 delta_p1_os_("delta_p1_os_",this,other.delta_p1_os_),
128 tageff_os_("tageff_os_",this,other.tageff_os_),
129 tageff_asym_os_("tageff_asym_os_",this,other.tageff_asym_os_),
130 tag_ss_("tag_ss_",this,other.tag_ss_),
131 eta_ss_("eta_ss_",this,other.eta_ss_),
132 avg_eta_ss_("avg_eta_ss_",this,other.avg_eta_ss_),
133 p0_ss_("p0_ss_",this,other.p0_ss_),
134 p1_ss_("p1_ss_",this,other.p1_ss_),
135 delta_p0_ss_("delta_p0_ss_",this,other.delta_p0_ss_),
136 delta_p1_ss_("delta_p1_ss_",this,other.delta_p1_ss_),
137 tageff_ss_("tageff_ss_",this,other.tageff_ss_),
138 tageff_asym_ss_("tageff_asym_ss_",this,other.tageff_asym_ss_),
139 production_asym_("production_asym_",this,other.production_asym_),
140 detection_asym_("detection_asym_",this,other.detection_asym_),
141 onetagger_(other.onetagger_)
142 {
143 }
144 
145 
147 {
149 }
150 
151 
152 Int_t DecRateCoeff_Bd::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
153 {
154  // debug
155  // std::printf("CHECK: In %s line %u (%s): #Vars = %d : allVars = ", __func__, __LINE__, __FILE__, allVars.getSize());
156  // allVars.Print();
157 
158  if (matchArgs(allVars, analVars, tag_os_, tag_ss_, finalstate_)) return 2 ;
159  if (matchArgs(allVars, analVars, tag_os_, finalstate_)) return 1 ;
160  if (matchArgs(allVars, analVars, tag_ss_, finalstate_)) return -1 ;
161  return 0 ;
162 }
163 
164 Int_t DecRateCoeff_Bd::getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* /*rangeName*/) const
165 {
166  // debug
167  // std::printf("CHECK: In %s line %u (%s): #Vars = %d : allVars = \n", __func__, __LINE__, __FILE__, allVars.getSize());
168  // allVars.Print();
169  if (normSet) normSet->Print();
170 
171  if (matchArgs(allVars, analVars, tag_os_, tag_ss_)) return 2 ;
172  if (matchArgs(allVars, analVars, tag_os_)) return 1 ;
173  if (matchArgs(allVars, analVars, tag_ss_)) return -1 ;
174  return 0 ;
175 }
176 
177 Double_t DecRateCoeff_Bd::analyticalIntegral(Int_t code, const char* rangeName) const
178 {
179  // debug
180  // std::printf("CHECK: In %s line %u (%s): Range: %s : Code: %d \n", __func__, __LINE__, __FILE__, rangeName, code);
181 
182  // first return analytical integral for defined range
183  if (rangeName){
184  double integral = 0;
185  if (isTagInRange(tag_ss_, +1, rangeName)){
186  if (isTagInRange(tag_os_, +1, rangeName)){
187  if (isFinalstateInRange(finalstate_, +1, rangeName)){
189  }
190  if (isFinalstateInRange(finalstate_, -1, rangeName)){
192  }
193  // debug
194  // std::cout << "Coeff: " << coeff_type_ << " Range: B0B0 : " << integral << std::endl;
195  }
196  if (isTagInRange(tag_os_, -1, rangeName)){
197  if (isFinalstateInRange(finalstate_, +1, rangeName)){
199  }
200  if (isFinalstateInRange(finalstate_, -1, rangeName)){
202  }
203  // debug
204  // std::cout << "Coeff: " << coeff_type_ << " Range: B0barB0 : " << integral << std::endl;
205  }
206  if (isTagInRange(tag_os_, 0, rangeName)){
207  if (isFinalstateInRange(finalstate_, +1, rangeName)){
209  }
210  if (isFinalstateInRange(finalstate_, -1, rangeName)){
212  }
213  // debug
214  // std::cout << "Coeff: " << coeff_type_ << " Range: B0barB0 : " << integral << std::endl;
215  }
216  }
217  if (isTagInRange(tag_ss_, -1, rangeName)){
218  if (isTagInRange(tag_os_, +1, rangeName)){
219  if (isFinalstateInRange(finalstate_, +1, rangeName)){
221  }
222  if (isFinalstateInRange(finalstate_, -1, rangeName)){
224  }
225  // debug
226  // std::cout << "Coeff: " << coeff_type_ << " Range: B0B0bar : " << integral << std::endl;
227  }
228  if (isTagInRange(tag_os_, -1, rangeName)){
229  if (isFinalstateInRange(finalstate_, +1, rangeName)){
231  }
232  if (isFinalstateInRange(finalstate_, -1, rangeName)){
234  }
235  // debug
236  // std::cout << "Coeff: " << coeff_type_ << " Range: B0barB0bar : " << integral << std::endl;
237  }
238  if (isTagInRange(tag_os_, 0, rangeName)){
239  if (isFinalstateInRange(finalstate_, +1, rangeName)){
241  }
242  if (isFinalstateInRange(finalstate_, -1, rangeName)){
244  }
245  // debug
246  // std::cout << "Coeff: " << coeff_type_ << " Range: B0barB0bar : " << integral << std::endl;
247  }
248  }
249  if (isTagInRange(tag_ss_, 0, rangeName)){
250  if (isTagInRange(tag_os_, +1, rangeName)){
251  if (isFinalstateInRange( finalstate_, +1, rangeName)){
253  }
254  if (isFinalstateInRange( finalstate_, -1, rangeName)){
256  }
257  // debug
258  // std::cout << "Coeff: " << coeff_type_ << " Range: B0B0bar : " << integral << std::endl;
259  }
260  if (isTagInRange(tag_os_, -1, rangeName)){
261  if (isFinalstateInRange(finalstate_, +1, rangeName)){
263  }
264  if (isFinalstateInRange(finalstate_, -1, rangeName)){
266  }
267  // debug
268  // std::cout << "Coeff: " << coeff_type_ << " Range: B0barB0bar : " << integral << std::endl;
269  }
270  if (isTagInRange(tag_os_, 0, rangeName)){
271  if (isFinalstateInRange(finalstate_, +1, rangeName)){
273  }
274  if (isFinalstateInRange(finalstate_, -1, rangeName)){
276  }
277  // debug
278  // std::cout << "Coeff: " << coeff_type_ << " Range: B0barB0bar : " << integral << std::endl;
279  }
280  }
281  return integral;
282  }
283  else{
284  if (code == +1){
285  double integral = 0.;
286  if (hasTagState(tag_os_, +1)){
289  }
292  }
293  }
294  if (hasTagState(tag_os_, -1)){
297  }
300  }
301  }
302  if (hasTagState(tag_os_, 0)){
305  }
308  }
309  }
310  // debug
311  // std::cout << "Coeff: " << coeff_type_ << " : OS Integral : " << integral << std::endl;
312  return integral;
313  }
314  if (code == -1){
315  double integral = 0.;
316  if (hasTagState(tag_ss_, +1)){
319  }
322  }
323  }
324  if (hasTagState(tag_ss_, -1)){
327  }
330  }
331  }
332  if (hasTagState(tag_ss_, 0)){
335  }
338  }
339  }
340  // debug
341  // std::cout << "Coeff: " << coeff_type_ << " : SS Integral : " << integral << std::endl;
342  return integral;
343  }
344  if (code == 2){
345  double integral = 0.;
348 
351 
354 
357 
360 
363 
366 
369 
372  // debug
373  // std::cout << "Coeff: " << coeff_type_ << " : OS + SS Integral : " << integral << std::endl;
374  return integral;
375  }
376  }
377  return 0;
378 }
379 
380 
381 std::pair<double, double> DecRateCoeff_Bd::calibrate(double eta, double avg_eta, double p0, double p1, double delta_p0, double delta_p1) const
382 {
383  double eta_cal = 0;
384  double eta_cal_b = 0;
385  double eta_cal_bbar = 0;
386 
387  // calculate calibrated average eta
388  eta_cal = p0 + p1 * ( eta - avg_eta );
389 
390  // if eta is larger or equal 0.5 return 0.5
391  if (eta >= 0.5){
392  eta_cal = 0.5;
393  eta_cal_b = 0.5;
394  eta_cal_bbar = 0.5;
395  }
396  else{
397  // calibrate eta
398  eta_cal_b = p0 + 0.5 * delta_p0 + ( p1 + 0.5 * delta_p1 ) * ( eta - avg_eta );
399  eta_cal_bbar = p0 - 0.5 * delta_p0 + ( p1 - 0.5 * delta_p1 ) * ( eta - avg_eta );
400  }
401  /*
402  // if calibrated average eta is larger or equal 0.5 return 0.5
403  if (eta_cal >= 0.5){
404  eta_cal_b = 0.5;
405  eta_cal_bbar = 0.5;
406  }
407  */
408  // if calibrated eta is smaller than 0 return 0
409  if (eta_cal_b < 0.0) eta_cal_b = 0;
410  if (eta_cal_bbar < 0.0) eta_cal_bbar = 0;
411 
412  // the next few lines set every eta value (avg and high/low from asymmetries) to zero
413  // if only one of them is below zero. This seems to introduce a fit bias on our CP
414  // observables. (CC)
415  // if (eta_cal < 0.0 || eta_cal_b < 0.0 || eta_cal_bbar < 0.0){
416  // eta_cal_b = 0.0;
417  // eta_cal_bbar = 0.0;
418  // }
419  return std::make_pair(eta_cal_b, eta_cal_bbar);
420 }
421 
422 
423 Double_t DecRateCoeff_Bd::evaluate(double cp_coeff,
424  double cp_coeff_bar,
425  CoeffType coeff_type,
426  int finalstate,
427  int tag_os,
428  double eta_os,
429  double avg_eta_os,
430  double p0_os,
431  double p1_os,
432  double delta_p0_os,
433  double delta_p1_os,
434  double tageff_os,
435  double tageff_asym_os,
436  int tag_ss,
437  double eta_ss,
438  double avg_eta_ss,
439  double p0_ss,
440  double p1_ss,
441  double delta_p0_ss,
442  double delta_p1_ss,
443  double tageff_ss,
444  double tageff_asym_ss,
445  double production_asym,
446  double detection_asym) const
447 {
448  // calibrate single tagger
449  std::pair<double, double> calibrated_mistag_os = calibrate(eta_os, avg_eta_os, p0_os, p1_os, delta_p0_os, delta_p1_os);
450  std::pair<double, double> calibrated_mistag_ss = calibrate(eta_ss, avg_eta_ss, p0_ss, p1_ss, delta_p0_ss, delta_p1_ss);
451 
452  double eta_os_b = calibrated_mistag_os.first;
453  double eta_os_bbar = calibrated_mistag_os.second;
454  double eta_ss_b = calibrated_mistag_ss.first;
455  double eta_ss_bbar = calibrated_mistag_ss.second;
456 
457  if(onetagger_) {
458  if(coeff_type == kCos){
459  if(finalstate == 1){
460  if(tag_os == 0) return cp_coeff * (1 + detection_asym) * (tageff_asym_os - 2 * production_asym * (1 - tageff_os));
461  else return 1.0 * cp_coeff * (1 + detection_asym) * (tag_os * tageff_os - 0.5 * tageff_asym_os
462  - production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
463  - tag_os * tageff_os * (eta_os_b - eta_os_bbar)
464  + 0.5 * tag_os * tageff_asym_os * (eta_os_b + eta_os_bbar))
465  - tageff_os * tag_os * (eta_os_b + eta_os_bbar)
466  + 0.5 * tageff_asym_os * tag_os * (eta_os_b - eta_os_bbar) );
467  }
468  else if(finalstate == -1){
469  if(tag_os == 0) return cp_coeff_bar * (1 - detection_asym) * (tageff_asym_os - 2 * production_asym * (1 - tageff_os));
470  else return 1.0 * cp_coeff_bar * (1 - detection_asym) * (tag_os * tageff_os - 0.5 * tageff_asym_os
471  - production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
472  - tag_os * tageff_os * (eta_os_b - eta_os_bbar)
473  + 0.5 * tag_os * tageff_asym_os * (eta_os_b + eta_os_bbar))
474  - tageff_os * tag_os * (eta_os_b + eta_os_bbar)
475  + 0.5 * tageff_asym_os * tag_os * (eta_os_b - eta_os_bbar) );
476  }
477  else{
478  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
479  abort();
480  }
481  }
482  if(coeff_type == kSin){
483  if(finalstate == 1){
484  if(tag_os == 0) return cp_coeff * (1 + detection_asym) * (tageff_asym_os - 2 * production_asym * (1 - tageff_os));
485  else return -1.0 * cp_coeff * (1 + detection_asym) * (tag_os * tageff_os - 0.5 * tageff_asym_os
486  - production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
487  - tag_os * tageff_os * (eta_os_b - eta_os_bbar)
488  + 0.5 * tag_os * tageff_asym_os * (eta_os_b + eta_os_bbar))
489  - tageff_os * tag_os * (eta_os_b + eta_os_bbar)
490  + 0.5 * tageff_asym_os * tag_os * (eta_os_b - eta_os_bbar) );
491  }
492  else if(finalstate == -1){
493  if(tag_os == 0) return cp_coeff_bar * (1 - detection_asym) * (tageff_asym_os - 2 * production_asym * (1 - tageff_os));
494  else return -1.0 * cp_coeff_bar * (1 - detection_asym) * (tag_os * tageff_os - 0.5 * tageff_asym_os
495  - production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
496  - tag_os * tageff_os * (eta_os_b - eta_os_bbar)
497  + 0.5 * tag_os * tageff_asym_os * (eta_os_b + eta_os_bbar))
498  - tageff_os * tag_os * (eta_os_b + eta_os_bbar)
499  + 0.5 * tageff_asym_os * tag_os * (eta_os_b - eta_os_bbar) );
500  }
501  else{
502  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
503  abort();
504  }
505  }
506  if(coeff_type == kSinh){
507  if(finalstate == 1){
508  if(tag_os == 0) return cp_coeff * (1 + detection_asym) * (2 * (1 - tageff_os) - tageff_asym_os * production_asym);
509  else return 1.0 * cp_coeff * (1 + detection_asym) * (tageff_os - 0.5 * tag_os * tageff_asym_os
510  - tag_os * production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
511  - tageff_os * (eta_os_b + eta_os_bbar)
512  + 0.5 * tageff_asym_os * (eta_os_b - eta_os_bbar))
513  - tageff_os * tag_os * (eta_os_b - eta_os_bbar)
514  + 0.5 * tageff_asym_os * tag_os * (eta_os_b + eta_os_bbar) );
515  }
516  else if(finalstate == -1){
517  if(tag_os == 0) return cp_coeff_bar * (1 - detection_asym) * (2 * (1 - tageff_os) - tageff_asym_os * production_asym);
518  else return 1.0 * cp_coeff_bar * (1 - detection_asym) * (tageff_os - 0.5 * tag_os * tageff_asym_os
519  - tag_os * production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
520  - tageff_os * (eta_os_b + eta_os_bbar)
521  + 0.5 * tageff_asym_os * (eta_os_b - eta_os_bbar))
522  - tageff_os * tag_os * (eta_os_b - eta_os_bbar)
523  + 0.5 * tageff_asym_os * tag_os * (eta_os_b + eta_os_bbar) );
524  }
525  else{
526  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
527  abort();
528  }
529  }
530  if(coeff_type == kCosh){
531  if(finalstate == 1){
532  if(tag_os == 0) return cp_coeff * (1 + detection_asym) * (2 * (1 - tageff_os) - tageff_asym_os * production_asym);
533  else return cp_coeff * (1 + detection_asym) * (tageff_os - 0.5 * tag_os * tageff_asym_os
534  - tag_os * production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
535  - tageff_os * (eta_os_b + eta_os_bbar)
536  + 0.5 * tageff_asym_os * (eta_os_b - eta_os_bbar))
537  - tageff_os * tag_os * (eta_os_b - eta_os_bbar)
538  + 0.5 * tageff_asym_os * tag_os * (eta_os_b + eta_os_bbar) );
539  }
540  else if(finalstate == -1){
541  if(tag_os == 0) return cp_coeff_bar * (1 - detection_asym) * (2 * (1 - tageff_os) - tageff_asym_os * production_asym);
542  else return cp_coeff_bar * (1 - detection_asym) * (tageff_os - 0.5 * tag_os * tageff_asym_os
543  - tag_os * production_asym * (tageff_os - 0.5 * tag_os * tageff_asym_os
544  - tageff_os * (eta_os_b + eta_os_bbar)
545  + 0.5 * tageff_asym_os * (eta_os_b - eta_os_bbar))
546  - tageff_os * tag_os * (eta_os_b - eta_os_bbar)
547  + 0.5 * tageff_asym_os * tag_os * (eta_os_b + eta_os_bbar) );
548  }
549  else{
550  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
551  abort();
552  }
553  }
554  else{
555  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
556  abort();
557  }
558  }
559 
560  // combine taggers and calculate intermediate steps
561  double sum = 0;
562  double difference = 0;
563 
564  double tageff_os_b = tageff_os - 0.5 * tageff_asym_os;
565  double tageff_os_bbar = tageff_os + 0.5 * tageff_asym_os;
566 
567  double tageff_ss_b = tageff_ss - 0.5 * tageff_asym_ss;
568  double tageff_ss_bbar = tageff_ss + 0.5 * tageff_asym_ss;
569 
570  if( tag_os == 0 && tag_ss == 0) {
571  sum = (1 - tageff_os_b - tageff_ss_b + tageff_os_b * tageff_ss_b) + (1 - tageff_os_bbar - tageff_ss_bbar + tageff_os_bbar * tageff_ss_bbar);
572  difference = (1 - tageff_os_b - tageff_ss_b + tageff_os_b * tageff_ss_b) - (1 - tageff_os_bbar - tageff_ss_bbar + tageff_os_bbar * tageff_ss_bbar);
573  }
574  else if(tag_os == 0 && tag_ss != 0){
575  sum = 0.5 * tageff_ss_b * (1 - tageff_os_b + tag_ss * (1 - tageff_os_b - 2 * eta_ss_b + 2 * eta_ss_b * tageff_os_b))
576  + 0.5 * tageff_ss_bbar * (1 - tageff_os_bbar - tag_ss * (1 - tageff_os_bbar - 2 * eta_ss_bbar + 2 * eta_ss_bbar * tageff_os_bbar));
577  difference = 0.5 * tageff_ss_b * (1 - tageff_os_b + tag_ss * (1 - tageff_os_b - 2 * eta_ss_b + 2 * eta_ss_b * tageff_os_b))
578  - 0.5 * tageff_ss_bbar * (1 - tageff_os_bbar - tag_ss * (1 - tageff_os_bbar - 2 * eta_ss_bbar + 2 * eta_ss_bbar * tageff_os_bbar));
579  }
580  else if(tag_ss == 0 && tag_os != 0){
581  sum = 0.5 * tageff_os_b * (1 - tageff_ss_b + tag_os * (1 - tageff_ss_b - 2 * eta_os_b + 2 * eta_os_b * tageff_ss_b))
582  + 0.5 * tageff_os_bbar * (1 - tageff_ss_bbar - tag_os * (1 - tageff_ss_bbar - 2 * eta_os_bbar + 2 * eta_os_bbar * tageff_ss_bbar));
583  difference = 0.5 * tageff_os_b * (1 - tageff_ss_b + tag_os * (1 - tageff_ss_b - 2 * eta_os_b + 2 * eta_os_b * tageff_ss_b))
584  - 0.5 * tageff_os_bbar * (1 - tageff_ss_bbar - tag_os * (1 - tageff_ss_bbar - 2 * eta_os_bbar + 2 * eta_os_bbar * tageff_ss_bbar));
585  }
586  else if(tag_ss != 0 && tag_os != 0){
587  sum = 0.25 * tageff_os_b * tageff_ss_b * (1 + tag_ss * (1 - 2 * eta_ss_b) + tag_os * (1 - 2 * eta_os_b)
588  + tag_os * tag_ss * (1 - 2 * eta_os_b - 2 * eta_ss_b + 4 * eta_os_b * eta_ss_b))
589  + 0.25 * tageff_os_bbar * tageff_ss_bbar * (1 - tag_ss * (1 - 2 * eta_ss_bbar) - tag_os * (1 - 2 * eta_os_bbar)
590  + tag_os * tag_ss * (1 - 2 * eta_os_bbar - 2 * eta_ss_bbar + 4 * eta_os_bbar * eta_ss_bbar));
591  difference = 0.25 * tageff_os_b * tageff_ss_b * (1 + tag_ss * (1 - 2 * eta_ss_b) + tag_os * (1 - 2 * eta_os_b)
592  + tag_os * tag_ss * (1 - 2 * eta_os_b - 2 * eta_ss_b + 4 * eta_os_b * eta_ss_b))
593  - 0.25 * tageff_os_bbar * tageff_ss_bbar * (1 - tag_ss * (1 - 2 * eta_ss_bbar) - tag_os * (1 - 2 * eta_os_bbar)
594  + tag_os * tag_ss * (1 - 2 * eta_os_bbar - 2 * eta_ss_bbar + 4 * eta_os_bbar * eta_ss_bbar));
595  }
596  else{
597  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid tag combination!" << std::endl;
598  abort();
599  }
600 
601  // calculate and return coefficients
602  if (coeff_type == kSin){
603  if(finalstate==1){
604  return -1.0 * (1 + detection_asym) * cp_coeff * ( difference - production_asym * sum );
605  }
606  else if(finalstate==-1){
607  return -1.0 * (1 - detection_asym) * cp_coeff_bar * ( difference - production_asym * sum );
608  }
609  else{
610  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
611  abort();
612  }
613  }
614  else if (coeff_type == kCos){
615  if(finalstate==1){
616  return +1.0 * (1 + detection_asym) * cp_coeff * ( difference - production_asym * sum );
617  }
618  else if(finalstate==-1){
619  return +1.0 * (1 - detection_asym) * cp_coeff_bar * ( difference - production_asym * sum );
620  }
621  else{
622  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
623  abort();
624  }
625  }
626  else if (coeff_type == kSinh){
627  if(finalstate==1){
628  return 1.0 * (1 + detection_asym) * cp_coeff * ( sum - production_asym * difference );
629  }
630  else if(finalstate==-1){
631  return 1.0 * (1 - detection_asym) * cp_coeff_bar * ( sum - production_asym * difference );
632  }
633  else{
634  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
635  abort();
636  }
637  }
638  else if (coeff_type == kCosh){
639  if(finalstate==1){
640  return +1.0 * (1 + detection_asym) * cp_coeff * ( sum - production_asym * difference );
641  }
642  else if(finalstate==-1){
643  return +1.0 * (1 - detection_asym) * cp_coeff_bar * ( sum - production_asym * difference );
644  }
645  else{
646  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid finalstate!" << std::endl;
647  abort();
648  }
649  }
650  else{
651  std::cout << "ERROR\t" << "DecRateCoeff_Bd::evaluate(...): No valid coefficient type!" << std::endl;
652  abort();
653  }
654 }
655 
656 
657 bool DecRateCoeff_Bd::isTagInRange(const RooCategoryProxy& tag, int tag_state, const char* rangeName) const
658 {
659  if (tag.arg().lookupType(tag_state) == nullptr){
660  return false;
661  }
662  else{
663  return dynamic_cast<const RooCategory&>(tag.arg()).isStateInRange(rangeName, tag.arg().lookupType(tag_state)->GetName());
664  }
665 }
666 
667 
668 bool DecRateCoeff_Bd::hasTagState(const RooCategoryProxy& tag, int tag_state) const
669 {
670  return dynamic_cast<const RooCategory&>(tag.arg()).isValidIndex(tag_state);
671 }
672 
673 bool DecRateCoeff_Bd::isFinalstateInRange(const RooCategoryProxy& finalstate, int finalstate_state, const char* rangeName) const
674 {
675  if (finalstate.arg().lookupType(finalstate_state) == nullptr){
676  return false;
677  }
678  else{
679  return dynamic_cast<const RooCategory&>(finalstate.arg()).isStateInRange(rangeName, finalstate.arg().lookupType(finalstate_state)->GetName());
680  }
681 }
682 
683 bool DecRateCoeff_Bd::hasFinalstateState(const RooCategoryProxy& finalstate, int finalstate_state) const
684 {
685  return dynamic_cast<const RooCategory&>(finalstate.arg()).isValidIndex(finalstate_state);
686 }
687 
688 int DecRateCoeff_Bd::getIndex(const RooCategoryProxy& tag) const
689 {
690  return dynamic_cast<const RooCategory&>(tag.arg()).getIndex();
691 }
RooRealProxy p1_ss_
RooRealProxy tageff_ss_
int getIndex(const RooCategoryProxy &tag) const
RooRealProxy cp_coeff_bar_
RooRealProxy tageff_asym_os_
Double_t analyticalIntegral(Int_t code, const char *rangeName=0) const
RooRealProxy delta_p0_ss_
Double_t evaluate() const
RooRealProxy p1_os_
RooCategoryProxy tag_ss_
RooRealProxy tageff_os_
DecRateCoeff_Bd()
default constructor for ROOT I/O
RooRealProxy cp_coeff_
bool isFinalstateInRange(const RooCategoryProxy &finalstate, int finalstate_state, const char *rangeName) const
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=0) const
RooCategoryProxy finalstate_
RooRealProxy avg_eta_os_
RooRealProxy delta_p0_os_
RooRealProxy p0_os_
RooRealProxy delta_p1_os_
RooRealProxy delta_p1_ss_
std::pair< double, double > calibrate(double eta, double avg_eta, double p0, double p1, double delta_p0, double delta_p1) const
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
RooRealProxy p0_ss_
RooRealProxy eta_ss_
RooRealProxy avg_eta_ss_
CoeffType coeff_type_
bool hasFinalstateState(const RooCategoryProxy &finalstate, int finalstate_state) const
RooRealProxy production_asym_
cosh/sinh/cos/sin coefficients in decay rate equations
RooCategoryProxy tag_os_
bool hasTagState(const RooCategoryProxy &tag, int tag_state) const
RooRealProxy detection_asym_
bool isTagInRange(const RooCategoryProxy &tag, int tag_state, const char *rangeName) const
RooRealProxy eta_os_
RooRealProxy tageff_asym_ss_