MINT2
FullTimePdf.h
Go to the documentation of this file.
1 #ifndef FULLTIMEPDF_HH
2 #define FULLTIMEPDF_HH
3 // author: Philippe d'Argent
4 #include "Mint/FitParameter.h"
5 #include "Mint/NamedParameter.h"
6 #include "Mint/DalitzEventList.h"
10 #include "Mint/PdfBase.h"
11 #include "Mint/IDalitzEvent.h"
12 #include "Mint/DalitzEvent.h"
14 #include "Mint/IEventGenerator.h"
15 #include "Mint/TimePdfMaster.h"
18 
19 #include "RooRealConstant.h"
20 #include "RooAbsReal.h"
21 #include "RooRealVar.h"
22 #include "RooDataSet.h"
23 #include "RooGlobalFunc.h"
24 #include "RooRealVar.h"
25 #include "RooDecay.h"
26 #include "RooBDecay.h"
27 #include "RooPlot.h"
28 #include "RooEffProd.h"
29 #include "RooGenericPdf.h"
30 #include "RooGaussModel.h"
31 #include "RooProdPdf.h"
32 #include "RooConstVar.h"
33 #include "RooCategory.h"
34 #include "RooDataHist.h"
35 #include "RooHistPdf.h"
36 #include "RooAddPdf.h"
37 #include "RooUniform.h"
38 #include "RooExponential.h"
39 #include "RooRandom.h"
40 #include "RooGaussian.h"
41 #include "RooMultiVarGaussian.h"
42 #include "RooTruthModel.h"
43 #ifndef __CINT__
44 #include "RooGlobalFunc.h"
45 #endif
46 #include "Mint/RooCubicSplineFun.h"
49 #include "Mint/DecRateCoeff_Bd.h"
50 #include "TCanvas.h"
51 #include "TTree.h"
52 #include "TFile.h"
53 #include <TStyle.h>
54 #include <TROOT.h>
55 #include "TRandom3.h"
56 
57 #include <ctime>
58 #include <iostream>
59 #include <fstream>
60 #include <algorithm>
61 #include <TChain.h>
62 #include <TTree.h>
63 #include <TH1D.h>
64 #include <TH2D.h>
65 #include <TF1.h>
66 #include <TFile.h>
67 #include <TCanvas.h>
68 #include <TLorentzVector.h>
69 #include <TLatex.h>
70 #include <TROOT.h>
71 #include <TStyle.h>
72 
73 using namespace std;
74 using namespace RooFit ;
75 using namespace MINT;
76 
77 
78 // Full DsK like time PDF with additional coherence factor
79 class FullTimePdf : public MINT::PdfBase<IDalitzEvent>
80 {
81 protected:
83  const FitParameter& _C;
84  const FitParameter& _D;
86  const FitParameter& _S;
88  const FitParameter& _k;
89 
93 
98 
109 
117 
125 
128 
130 
131  // Time pdf master
134 
135  // Limits
140 
141 public:
143  }
144  void beginFit(){
145  _timePdfMaster->listFitParDependencies();
146  }
147  void endFit(){
148  }
149 
150  inline double un_normalised(IDalitzEvent& evt){
151 
152  //const double t = (double) evt.getValueFromVector(0);
153  //if(t < _min_TAU || t > _max_TAU )return 0.;
154 
155  _timePdfMaster->setAllObservablesAndFitParameters(evt);
156 
157  // C,Cbar,D,Dbar,S,Sbar
158  _timePdfMaster->setCP_coeff(1.,
159  1.,
160  _C,
161  -_C,
162  _k * _D,
163  _k * _D_bar,
164  _k * _S,
165  _k * _S_bar
166  );
167 
168  double val =
169  (
170  _timePdfMaster->get_cosh_term_Val(evt)
171  + _timePdfMaster->get_cos_term_Val(evt)
172  + _timePdfMaster->get_sinh_term_Val(evt)
173  + _timePdfMaster->get_sin_term_Val(evt)
174  );// * _timePdfMaster->get_marginalPdfs_product(evt);
175 
176  return val;
177  }
178 
179  virtual double getVal(IDalitzEvent& evt){
180 
181  double val = un_normalised(evt);
182 
183  double norm =
184  _timePdfMaster->get_cosh_term_Integral(evt)
185  + _timePdfMaster->get_cos_term_Integral(evt)
186  + _timePdfMaster->get_sinh_term_Integral(evt)
187  + _timePdfMaster->get_sin_term_Integral(evt);
188 
189  return val/norm;
190  }
191 
192  double getNorm(IDalitzEvent& evt){
193 
194  _timePdfMaster->setAllObservablesAndFitParameters(evt);
195 
196  // C,Cbar,D,Dbar,S,Sbar
197  _timePdfMaster->setCP_coeff(1.,
198  1.,
199  _C,
200  -_C,
201  _k * _D,
202  _k * _D_bar,
203  _k * _S,
204  _k * _S_bar
205  );
206 
207  double norm =
208  _timePdfMaster->get_cosh_term_Integral(evt)
209  + _timePdfMaster->get_cos_term_Integral(evt)
210  + _timePdfMaster->get_sinh_term_Integral(evt)
211  + _timePdfMaster->get_sin_term_Integral(evt);
212 
213  return norm;
214  }
215 
216  inline double getSampledPdfVal(IDalitzEvent& evt){
217  return _timePdfMaster->getSamplingPdfVal(evt);
218  }
219 
220  std::pair<double, double> getCalibratedMistag_OS(IDalitzEvent& evt){
221  return _timePdfMaster->getCalibratedMistag_OS(evt);
222  }
223 
224  std::pair<double, double> getCalibratedMistag_OS(double& eta_OS){
225  return _timePdfMaster->getCalibratedMistag_OS(eta_OS);
226  }
227 
228  std::pair<double, double> getCalibratedMistag_OS(IDalitzEvent& evt,double& avg_eta_os,double& p0_os,double& p1_os,double& delta_p0_os,double& delta_p1_os ){
229  return _timePdfMaster->getCalibratedMistag_OS(evt, avg_eta_os, p0_os, p1_os, delta_p0_os, delta_p1_os);
230  }
231 
232  std::pair<double, double> getCalibratedMistag_SS(IDalitzEvent& evt){
233  return _timePdfMaster->getCalibratedMistag_SS(evt);
234  }
235 
236  std::pair<double, double> getCalibratedMistag_SS(double& eta_SS){
237  return _timePdfMaster->getCalibratedMistag_SS(eta_SS);
238  }
239 
240  std::pair<double, double> getCalibratedMistag_SS(IDalitzEvent& evt,double& avg_eta_ss,double& p0_ss,double& p1_ss,double& delta_p0_ss,double& delta_p1_ss ){
241  return _timePdfMaster->getCalibratedMistag_SS(evt, avg_eta_ss, p0_ss, p1_ss, delta_p0_ss, delta_p1_ss);
242  }
243 
244  std::pair<double, double> getCalibratedMistag(double eta,double avg_eta,double p0,double p1,double delta_p0,double delta_p1 ){
245  return _timePdfMaster->getCalibratedMistag(eta, avg_eta, p0, p1, delta_p0, delta_p1);
246  }
247 
248  double getCalibratedResolution(double dt){
249  return _timePdfMaster->getCalibratedResolution(dt);
250  }
251 
252  double getCalibratedResolution(double& dt,double& scale_sigma_dt,double& scale_sigma_2_dt){
253  return _timePdfMaster->getCalibratedResolution(dt,scale_sigma_dt,scale_sigma_2_dt);
254  }
255 
256  virtual double getVal_withPs(IDalitzEvent& evt){return getVal(evt);}
257  virtual double getVal_noPs(IDalitzEvent& evt){return getVal(evt);}
258 
259  virtual double getVal(IDalitzEvent* evt){
260  if(0 == evt) return 0;
261  return getVal(*evt);
262  }
263  virtual double getVal_withPs(IDalitzEvent* evt){
264  if(0 == evt) return 0;
265  return getVal_withPs(*evt);
266  }
267  virtual double getVal_noPs(IDalitzEvent* evt){
268  if(0 == evt) return 0;
269  return getVal_noPs(*evt);
270  }
271 
272  RooDataSet* sampleEvents(int N = 10000){
273  return _timePdfMaster->sampleEvents(N);
274  }
275 
276  void generateBkgToys(int N, DalitzEventList& eventListData){
277 
278  DalitzEventList eventList,eventListDataSideband;
279 
280  for(int i=0; i< eventListData.size(); i++)
281  {
282  DalitzEvent evt = eventListData[i];
283  if(abs(evt.getValueFromVector(9) -5370) > 60)eventListDataSideband.Add(evt);
284  }
285  int N_sample = eventListDataSideband.size();
286 
287  vector<int> b_indices;
288  while( b_indices.size() < N )b_indices.push_back(TMath::Nint(gRandom->Uniform(0,N_sample)));
289  sort(b_indices.begin(), b_indices.end());
290 
291  TRandom3 rndm;
292  for(int i=0; i< N; i++)
293  {
294  DalitzEvent evt = eventListDataSideband[b_indices[i]];
295  eventList.Add(evt);
296  }
297  saveEventListToFile(eventList);
298  }
299 
300  DalitzEventList generateToysRooFit(int N = 10000, int run = -1 , int trigger = -1){
301 
302  cout << "Generating " << N << " events" << endl;
303  DalitzEventList eventList;
304 
305  RooDataSet* sample = sampleEvents(N);
306 
307  for(int i = 0; i < sample->numEntries(); i++){
308 
309  RooArgSet* sample_set= (RooArgSet*)sample->get(i);
310 
311  double t_MC = ((RooRealVar*)sample_set->find("t"))->getVal() ;
312  double dt_MC = ((RooRealVar*)sample_set->find("dt"))->getVal() ;
313  double eta_OS_MC = ((RooRealVar*)sample_set->find("eta_OS"))->getVal() ;
314  double eta_SS_MC = ((RooRealVar*)sample_set->find("eta_SS"))->getVal() ;
315 
316  int f_MC = ((RooCategory*)sample_set->find("qf"))->getIndex() ;
317  int q_OS_MC = ((RooCategory*)sample_set->find("q_OS"))->getIndex() ;
318  int q_SS_MC = ((RooCategory*)sample_set->find("q_SS"))->getIndex() ;
319 
320  DalitzEvent evt(_pat,gRandom);
321  evt.setValueInVector(0, t_MC);
322  evt.setValueInVector(1, dt_MC);
323  evt.setValueInVector(2, f_MC);
324  evt.setValueInVector(3, q_OS_MC);
325  evt.setValueInVector(4, eta_OS_MC);
326  evt.setValueInVector(5, q_SS_MC);
327  evt.setValueInVector(6, eta_SS_MC);
328  evt.setValueInVector(7, run);
329  evt.setValueInVector(8, trigger);
330 
331  eventList.Add(evt);
332  }
333  return eventList;
334  }
335 
336  DalitzEventList generateToys(int N = 10000, int run = -1 , int trigger = -1){
337 
338  time_t startTime = time(0);
339 
340  cout << "Generating " << N << " events" << endl;
341  DalitzEventList eventList;
342 
344  vector<double> vals;
345  for(int i = 0; i < 100000; i++){
346  DalitzEvent evt = generateWeightedEvent();
347  double val = getVal(evt)/evt.getGeneratorPdfRelativeToPhaseSpace(); //_timePdfMaster->get_marginalPdfs_product(evt);
348  vals.push_back(val);
349  }
350 
351  cout << "Now calculating maximum val " << vals.size() << endl;
352  double amax,pmax;
353  generalisedPareto_estimateMaximum(vals,0.999,amax,pmax);
354 
355  double pdf_max = 1.;
356  if(!TMath::IsNaN(pmax) && pmax > 0 && pmax < 100 * amax)pdf_max = pmax;
357  else if(!TMath::IsNaN(amax))pdf_max = amax;
358  // for safety
359  pdf_max *= 1.5;
360 
361  cout << "pdf_max " << pdf_max << endl;
362 
363  int N_gen = 0;
364  int N_tot = 0;
365  while(true){
366  DalitzEvent evt = generateWeightedEvent();
367  double pdfVal = getVal(evt)/evt.getGeneratorPdfRelativeToPhaseSpace(); // /_timePdfMaster->get_marginalPdfs_product(evt);
368 
369  const double height = gRandom->Uniform(0,pdf_max);
370 
372  if( pdfVal > pdf_max ){
373  std::cout << "ERROR: PDF above determined maximum." << std::endl;
374  std::cout << pdfVal << " > " << pdf_max << std::endl;
375  pdf_max = pdf_max * 2.;
376  }
377 
379  if( height < pdfVal ) {
380  evt.setValueInVector(7, run);
381  evt.setValueInVector(8, trigger);
382  eventList.Add(evt);
383  N_gen++;
384  //if (0ul == (N_gen % 500ul)) cout << "Generated event " << N_gen << "/" << N << endl;
385  }
386  N_tot ++;
387  if(N_gen == N)break;
388  }
389 
390  cout << " Done. " << " Total time since start " << (time(0) - startTime)/60.0 << " min." << endl;
391  cout << "Generated " << N_gen << " events ! Efficiecy = " << (double)N_gen/(double)N_tot << endl;
392 
393 // saveEventListToFile(eventList);
394  return eventList;
395  }
396 
397  void saveEventListToFile(DalitzEventList& eventList, string name = "toys.root"){
398 
399  TFile* out = new TFile(name.c_str(),"RECREATE");
400  TTree* tree = new TTree("DecayTree","DecayTree");
401 
402  double t,dt;
403  int Ds_ID;
404  int q_OS,q,q_SS;
405  double eta_OS;
406  double eta_SS;
407  double sw,w;
408  int run,trigger;
409  int year;
410 
411  double K[4];
412  double pip[4];
413  double pim[4];
414  double Ds[4];
415  double mB;
416 
417  TBranch* br_mB = tree->Branch( "Bs_DTF_MM", &mB, "Bs_DTF_MM/D" );
418  TBranch* br_sw = tree->Branch( "N_Bs_sw", &sw, "N_Bs_sw/D" );
419  TBranch* br_w = tree->Branch( "weight", &w, "weight/D" );
420 
421  TBranch* br_t = tree->Branch( "Bs_BsDTF_TAU", &t, "Bs_BsDTF_TAU/D" );
422  TBranch* br_dt = tree->Branch( "Bs_BsDTF_TAUERR", &dt, "Bs_BsDTF_TAUERR/D" );
423 
424  TBranch* br_Ds_ID = tree->Branch("Ds_ID",&Ds_ID,"Ds_ID/I");
425 
426  TBranch* br_q_OS =tree->Branch("OS_Combination_DEC",&q_OS,"OS_Combination_DEC/I");
427  TBranch* br_eta_OS = tree->Branch("OS_Combination_PROB",&eta_OS,"OS_Combination_PROB/D");
428  TBranch* br_q_SS = tree->Branch("SS_Kaon_DEC",&q_SS,"SS_Kaon_DEC/I");
429  TBranch* br_eta_SS = tree->Branch("SS_Kaon_PROB",&eta_SS,"SS_Kaon_PROB/D");
430 
431  TBranch* br_run = tree->Branch("run",&run,"run/I");
432  TBranch* br_year = tree->Branch( "year", &year, "year/I" );
433  TBranch* br_trigger = tree->Branch("TriggerCat",&trigger,"TriggerCat/I");
434 
435  TBranch* br_K0 = tree->Branch("BsDTF_Kplus_PX",&K[0],"BsDTF_Kplus_PX/D");
436  TBranch* br_K1 =tree->Branch("BsDTF_Kplus_PY",&K[1],"BsDTF_Kplus_PY/D");
437  TBranch* br_K2 =tree->Branch("BsDTF_Kplus_PZ",&K[2],"BsDTF_Kplus_PZ/D");
438  TBranch* br_K3 =tree->Branch("BsDTF_Kplus_PE",&K[3],"BsDTF_Kplus_PE/D");
439 
440  TBranch* br_pip0 =tree->Branch("BsDTF_piplus_PX",&pip[0],"BsDTF_piplus_PX/D");
441  TBranch* br_pip1 =tree->Branch("BsDTF_piplus_PY",&pip[1],"BsDTF_piplus_PY/D");
442  TBranch* br_pip2 =tree->Branch("BsDTF_piplus_PZ",&pip[2],"BsDTF_piplus_PZ/D");
443  TBranch* br_pip3 =tree->Branch("BsDTF_piplus_PE",&pip[3],"BsDTF_piplus_PE/D");
444 
445  TBranch* br_pim0 =tree->Branch("BsDTF_piminus_PX",&pim[0],"BsDTF_piminus_PX/D");
446  TBranch* br_pim1 =tree->Branch("BsDTF_piminus_PY",&pim[1],"BsDTF_piminus_PY/D");
447  TBranch* br_pim2 =tree->Branch("BsDTF_piminus_PZ",&pim[2],"BsDTF_piminus_PZ/D");
448  TBranch* br_pim3 =tree->Branch("BsDTF_piminus_PE",&pim[3],"BsDTF_piminus_PE/D");
449 
450  TBranch* br_Ds0 =tree->Branch("BsDTF_Ds_PX",&Ds[0],"BsDTF_Ds_PX/D");
451  TBranch* br_Ds1 =tree->Branch("BsDTF_Ds_PY",&Ds[1],"BsDTF_Ds_PY/D");
452  TBranch* br_Ds2 =tree->Branch("BsDTF_Ds_PZ",&Ds[2],"BsDTF_Ds_PZ/D");
453  TBranch* br_Ds3 =tree->Branch("BsDTF_Ds_PE",&Ds[3],"BsDTF_Ds_PE/D");
454 
455  for(int i= 0; i < eventList.size(); i++){
456 
457  t = eventList[i].getValueFromVector(0);
458  dt = eventList[i].getValueFromVector(1);
459 
460  Ds_ID = - eventList[i].getValueFromVector(2);
461 
462  q_OS = eventList[i].getValueFromVector(3);
463  eta_OS = eventList[i].getValueFromVector(4);
464 
465  q_SS = eventList[i].getValueFromVector(5);
466  eta_SS = eventList[i].getValueFromVector(6);
467 
468  run = eventList[i].getValueFromVector(7);
469  if(run == 2) year = 16;
470  else if(run == 3) year = 17;
471  else year = 12;
472  trigger = eventList[i].getValueFromVector(8);
473 
474  mB = eventList[i].p(0).M(); //eventList[i].getValueFromVector(9);
475  sw = eventList[i].getWeight();
476  w = eventList[i].getWeight();
477 
478  Ds[0] = eventList[i].p(1).Px()/MeV;
479  Ds[1] = eventList[i].p(1).Py()/MeV;
480  Ds[2] = eventList[i].p(1).Pz()/MeV;
481  Ds[3] = eventList[i].p(1).E()/MeV;
482 
483  K[0] = eventList[i].p(2).Px()/MeV;
484  K[1] = eventList[i].p(2).Py()/MeV;
485  K[2] = eventList[i].p(2).Pz()/MeV;
486  K[3] = eventList[i].p(2).E()/MeV;
487 
488  pip[0] = eventList[i].p(3).Px()/MeV;
489  pip[1] = eventList[i].p(3).Py()/MeV;
490  pip[2] = eventList[i].p(3).Pz()/MeV;
491  pip[3] = eventList[i].p(3).E()/MeV;
492 
493  pim[0] = eventList[i].p(4).Px()/MeV;
494  pim[1] = eventList[i].p(4).Py()/MeV;
495  pim[2] = eventList[i].p(4).Pz()/MeV;
496  pim[3] = eventList[i].p(4).E()/MeV;
497 
498  tree->Fill();
499  }
500 
501  tree->Write();
502  out->Write();
503  out->Close();
504  }
505 
507 
508  while(true){
509  double t_MC = gRandom->Exp(1./_Gamma);
510 // double t_MC = gRandom->Exp(1./_Gamma)+_min_TAU;
511  if(t_MC > _max_TAU || t_MC < _min_TAU)continue;
512 
513  DalitzEvent evt(_pat,gRandom);
514 
515  vector<double> marginal_vals = _timePdfMaster->getRandom_marginalVals();
516  double dt_MC = marginal_vals[0] ;
517  double eta_OS_MC = marginal_vals[1] ;
518  double eta_SS_MC = marginal_vals[2] ;
519 
520  int f_MC = (gRandom->Uniform() > 0.5) ? 1 : -1;
521 
522  // true flavor
523  int q_MC = (gRandom->Uniform() > 0.5) ? 1 : -1;
524 
525  int q_SS_MC = (gRandom->Uniform() > 2./3.) ? 0 : q_MC ;
526  int q_OS_MC = (gRandom->Uniform() > 2./3.) ? 0 : q_MC ;
527 
528  q_OS_MC = (gRandom->Uniform() < 0.5) ? - q_OS_MC : q_OS_MC;
529  q_SS_MC = (gRandom->Uniform() < 0.5) ? - q_SS_MC : q_SS_MC;
530 
531  eta_OS_MC = (q_OS_MC == 0) ? 0.5 : eta_OS_MC;
532  eta_SS_MC = (q_SS_MC == 0) ? 0.5 : eta_SS_MC;
533 
534  if(f_MC<0)evt.CP_conjugateYourself();
535  evt.setValueInVector(0, t_MC);
536  evt.setValueInVector(1, dt_MC);
537  evt.setValueInVector(2, f_MC);
538  evt.setValueInVector(3, q_OS_MC);
539  evt.setValueInVector(4, eta_OS_MC);
540  evt.setValueInVector(5, q_SS_MC);
541  evt.setValueInVector(6, eta_SS_MC);
542 
543  evt.setGeneratorPdfRelativeToPhaseSpace(_Gamma * exp(-t_MC*_Gamma) / ( ( exp(-_min_TAU*_Gamma) - exp(-_max_TAU * _Gamma) )));
544 // evt.setGeneratorPdfRelativeToPhaseSpace(_Gamma * ( exp(-t_MC*_Gamma) + _min_TAU ) / ( ( 1. - exp(-_max_TAU * _Gamma) ) + _Gamma * _min_TAU * ( _max_TAU - 0.)));
545 
546  return evt;
547  }
548  }
549 
550  TH1D* plotSpline() {
551  return _timePdfMaster->plotSpline();
552  }
553 
555  const MINT::FitParameter& S, const MINT::FitParameter& S_bar, const MINT::FitParameter& k,
556  const MINT::FitParameter& Gamma, const MINT::FitParameter& dGamma, const MINT::FitParameter& dm
557  ,const MINT::FitParameter& offset_sigma_dt, const MINT::FitParameter& scale_mean_dt, const MINT::FitParameter& scale_sigma_dt, const MINT::FitParameter& scale_sigma_2_dt
558  ,const MINT::FitParameter& c0, const MINT::FitParameter& c1, const MINT::FitParameter& c2
559  ,const MINT::FitParameter& c3, const MINT::FitParameter& c4, const MINT::FitParameter& c5
560  ,const MINT::FitParameter& c6, const MINT::FitParameter& c7, const MINT::FitParameter& c8
561  ,const MINT::FitParameter& c9,
562  const MINT::FitParameter& p0_os, const MINT::FitParameter& p1_os, const MINT::FitParameter& delta_p0_os, const MINT::FitParameter& delta_p1_os,
563  const MINT::FitParameter& avg_eta_os, const MINT::FitParameter& tageff_os, const MINT::FitParameter& tageff_asym_os,
564  const MINT::FitParameter& p0_ss, const MINT::FitParameter& p1_ss, const MINT::FitParameter& delta_p0_ss, const MINT::FitParameter& delta_p1_ss,
565  const MINT::FitParameter& avg_eta_ss, const MINT::FitParameter& tageff_ss, const MINT::FitParameter& tageff_asym_ss,
566  const MINT::FitParameter& production_asym, const MINT::FitParameter& detection_asym, string marginalPdfsPrefix = ""
567  ):
568  _C(C),
569  _D(D),
570  _D_bar(D_bar),
571  _S(S),
572  _S_bar(S_bar),
573  _k(k),
574  _Gamma(Gamma),
575  _dGamma(dGamma),
576  _dm(dm),
577  _offset_sigma_dt(offset_sigma_dt),
578  _scale_mean_dt(scale_mean_dt),
579  _scale_sigma_dt(scale_sigma_dt),
580  _scale_sigma_2_dt(scale_sigma_2_dt),
581  _c0(c0),
582  _c1(c1),
583  _c2(c2),
584  _c3(c3),
585  _c4(c4),
586  _c5(c5),
587  _c6(c6),
588  _c7(c7),
589  _c8(c8),
590  _c9(c9),
591  _p0_os(p0_os),
592  _p1_os(p1_os),
593  _delta_p0_os(delta_p0_os),
594  _delta_p1_os(delta_p1_os),
595  _avg_eta_os(avg_eta_os),
596  _tageff_os(tageff_os),
597  _tageff_asym_os(tageff_asym_os),
598  _p0_ss(p0_ss),
599  _p1_ss(p1_ss),
600  _delta_p0_ss(delta_p0_ss),
601  _delta_p1_ss(delta_p1_ss),
602  _avg_eta_ss(avg_eta_ss),
603  _tageff_ss(tageff_ss),
604  _tageff_asym_ss(tageff_asym_ss),
605  _production_asym(production_asym),
606  _detection_asym(detection_asym),
607  _marginalPdfsPrefix(marginalPdfsPrefix),
608  _min_TAU("min_TAU", 0.4),
609  _max_TAU("max_TAU", 10.),
610  _min_TAUERR("min_TAUERR", 0.),
611  _max_TAUERR("max_TAUERR", 0.1)
612  {
613  _timePdfMaster = new TimePdfMaster(_Gamma, _dGamma, _dm
614  ,_offset_sigma_dt, _scale_mean_dt, _scale_sigma_dt, _scale_sigma_2_dt
615  ,_c0, _c1, _c2
616  ,_c3, _c4, _c5
617  ,_c6, _c7, _c8
618  ,_c9,
619  _p0_os, _p1_os, _delta_p0_os, _delta_p1_os,
620  _avg_eta_os, _tageff_os, _tageff_asym_os,
621  _p0_ss, p1_ss, _delta_p0_ss, _delta_p1_ss,
622  _avg_eta_ss, _tageff_ss, _tageff_asym_ss,
623  _production_asym, _detection_asym,_marginalPdfsPrefix);
624 
625  _timePdfMaster->setAllFitParameters();
626 
627  _timePdfMaster->setCP_coeff(1., 1.,
628  _C,-_C,
629  _k * _D, _k * _D_bar,
630  _k * _S, _k * _S_bar );
631 
632  NamedParameter<int> EventPattern("Event Pattern", 521, 321, 211, -211, 443);
633  _pat = DalitzEventPattern(EventPattern.getVector());
634  }
635 
636 };
637 //
638 
639 #endif
640 //
std::pair< double, double > getCalibratedMistag_SS(double &eta_SS)
Definition: FullTimePdf.h:236
virtual double getValueFromVector(unsigned int i) const
const MINT::FitParameter & _c2
Definition: FullTimePdf.h:101
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventList.h:63
vector< double > getRandom_marginalVals()
double getCalibratedResolution(double dt)
Definition: FullTimePdf.h:248
const FitParameter & _D_bar
Definition: FullTimePdf.h:85
std::pair< double, double > getCalibratedMistag_SS(IDalitzEvent &evt)
const MINT::FitParameter & _dGamma
Definition: FullTimePdf.h:91
const MINT::FitParameter & _p1_ss
Definition: FullTimePdf.h:119
const MINT::FitParameter & _scale_sigma_dt
Definition: FullTimePdf.h:96
const MINT::FitParameter & _tageff_asym_ss
Definition: FullTimePdf.h:124
DalitzEventList generateToys(int N=10000, int run=-1, int trigger=-1)
Definition: FullTimePdf.h:336
RooDataSet * sampleEvents(int N=10000)
Definition: FullTimePdf.h:272
NamedParameter< double > _min_TAUERR
Definition: FullTimePdf.h:138
NamedParameter< double > _max_TAU
Definition: FullTimePdf.h:137
virtual void CP_conjugateYourself()
void saveEventListToFile(DalitzEventList &eventList, string name="toys.root")
Definition: FullTimePdf.h:397
DalitzEvent generateWeightedEvent()
Definition: FullTimePdf.h:506
const MINT::FitParameter & _c9
Definition: FullTimePdf.h:108
double un_normalised(IDalitzEvent &evt)
Definition: FullTimePdf.h:150
double get_cosh_term_Integral(IDalitzEvent &evt)
void setCP_coeff(double norm, double norm_bar, double C, double C_bar, double D, double D_bar, double S, double S_bar)
double getNorm(IDalitzEvent &evt)
Definition: FullTimePdf.h:192
const FitParameter & _S_bar
Definition: FullTimePdf.h:87
double generalisedPareto_estimateMaximum(const std::vector< double > &input, double CL=0.001)
virtual void setValueInVector(unsigned int i, double value)
void parametersChanged()
Definition: FullTimePdf.h:142
const MINT::FitParameter & _tageff_ss
Definition: FullTimePdf.h:123
const MINT::FitParameter & _scale_sigma_2_dt
Definition: FullTimePdf.h:97
DalitzEventList generateToysRooFit(int N=10000, int run=-1, int trigger=-1)
Definition: FullTimePdf.h:300
double get_cos_term_Val(IDalitzEvent &evt)
double getCalibratedResolution(double &dt)
virtual double getVal_withPs(IDalitzEvent *evt)
Definition: FullTimePdf.h:263
const FitParameter & _S
Definition: FullTimePdf.h:86
FullTimePdf(const MINT::FitParameter &C, const MINT::FitParameter &D, const MINT::FitParameter &D_bar, const MINT::FitParameter &S, const MINT::FitParameter &S_bar, const MINT::FitParameter &k, const MINT::FitParameter &Gamma, const MINT::FitParameter &dGamma, const MINT::FitParameter &dm, const MINT::FitParameter &offset_sigma_dt, const MINT::FitParameter &scale_mean_dt, const MINT::FitParameter &scale_sigma_dt, const MINT::FitParameter &scale_sigma_2_dt, const MINT::FitParameter &c0, const MINT::FitParameter &c1, const MINT::FitParameter &c2, const MINT::FitParameter &c3, const MINT::FitParameter &c4, const MINT::FitParameter &c5, const MINT::FitParameter &c6, const MINT::FitParameter &c7, const MINT::FitParameter &c8, const MINT::FitParameter &c9, const MINT::FitParameter &p0_os, const MINT::FitParameter &p1_os, const MINT::FitParameter &delta_p0_os, const MINT::FitParameter &delta_p1_os, const MINT::FitParameter &avg_eta_os, const MINT::FitParameter &tageff_os, const MINT::FitParameter &tageff_asym_os, const MINT::FitParameter &p0_ss, const MINT::FitParameter &p1_ss, const MINT::FitParameter &delta_p0_ss, const MINT::FitParameter &delta_p1_ss, const MINT::FitParameter &avg_eta_ss, const MINT::FitParameter &tageff_ss, const MINT::FitParameter &tageff_asym_ss, const MINT::FitParameter &production_asym, const MINT::FitParameter &detection_asym, string marginalPdfsPrefix="")
Definition: FullTimePdf.h:554
TH1D * plotSpline()
Definition: FullTimePdf.h:550
void endFit()
Definition: FullTimePdf.h:147
const MINT::FitParameter & _p0_ss
Definition: FullTimePdf.h:118
const MINT::FitParameter & _c8
Definition: FullTimePdf.h:107
std::pair< double, double > getCalibratedMistag(double eta, double avg_eta, double p0, double p1, double delta_p0, double delta_p1)
Definition: FullTimePdf.h:244
double get_sinh_term_Integral(IDalitzEvent &evt)
double getSamplingPdfVal(IDalitzEvent &evt)
double getSampledPdfVal(IDalitzEvent &evt)
Definition: FullTimePdf.h:216
const MINT::FitParameter & _tageff_asym_os
Definition: FullTimePdf.h:116
const MINT::FitParameter & _c0
Definition: FullTimePdf.h:99
static const double MeV
virtual double getVal(IDalitzEvent *evt)
Definition: FullTimePdf.h:259
void setAllFitParameters()
double get_sin_term_Integral(IDalitzEvent &evt)
TimePdfMaster * _timePdfMaster
Definition: FullTimePdf.h:132
std::pair< double, double > getCalibratedMistag_SS(IDalitzEvent &evt)
Definition: FullTimePdf.h:232
NamedParameter< double > _min_TAU
Definition: FullTimePdf.h:136
const MINT::FitParameter & _production_asym
Definition: FullTimePdf.h:126
const MINT::FitParameter & _c4
Definition: FullTimePdf.h:103
std::pair< double, double > getCalibratedMistag(double eta, double avg_eta, double p0, double p1, double delta_p0, double delta_p1)
std::pair< double, double > getCalibratedMistag_OS(IDalitzEvent &evt)
Definition: FullTimePdf.h:220
const MINT::FitParameter & _c5
Definition: FullTimePdf.h:104
virtual double getVal_withPs(IDalitzEvent &evt)
Definition: FullTimePdf.h:256
virtual double getGeneratorPdfRelativeToPhaseSpace() const
const MINT::FitParameter & _avg_eta_os
Definition: FullTimePdf.h:114
const MINT::FitParameter & _tageff_os
Definition: FullTimePdf.h:115
double getCalibratedResolution(double &dt, double &scale_sigma_dt, double &scale_sigma_2_dt)
Definition: FullTimePdf.h:252
virtual double getVal(IDalitzEvent &evt)
Definition: FullTimePdf.h:179
void beginFit()
Definition: FullTimePdf.h:144
const MINT::FitParameter & _c6
Definition: FullTimePdf.h:105
void listFitParDependencies()
double get_sin_term_Val(IDalitzEvent &evt)
const FitParameter & _C
fit parameters
Definition: FullTimePdf.h:83
const std::vector< T > & getVector() const
double get_cosh_term_Val(IDalitzEvent &evt)
virtual double getVal_noPs(IDalitzEvent &evt)
Definition: FullTimePdf.h:257
const MINT::FitParameter & _c7
Definition: FullTimePdf.h:106
RooDataSet * sampleEvents(int N=10000)
std::pair< double, double > getCalibratedMistag_OS(IDalitzEvent &evt, double &avg_eta_os, double &p0_os, double &p1_os, double &delta_p0_os, double &delta_p1_os)
Definition: FullTimePdf.h:228
const MINT::FitParameter & _c3
Definition: FullTimePdf.h:102
std::pair< double, double > getCalibratedMistag_OS(double &eta_OS)
Definition: FullTimePdf.h:224
const MINT::FitParameter & _avg_eta_ss
Definition: FullTimePdf.h:122
virtual unsigned int size() const
Definition: EventList.h:59
const MINT::FitParameter & _dm
Definition: FullTimePdf.h:92
double get_sinh_term_Val(IDalitzEvent &evt)
const MINT::FitParameter & _offset_sigma_dt
Definition: FullTimePdf.h:94
double get_cos_term_Integral(IDalitzEvent &evt)
const FitParameter & _D
Definition: FullTimePdf.h:84
const MINT::FitParameter & _delta_p1_os
Definition: FullTimePdf.h:113
void generateBkgToys(int N, DalitzEventList &eventListData)
Definition: FullTimePdf.h:276
DalitzEventPattern _pat
Definition: FullTimePdf.h:133
NamedParameter< double > _max_TAUERR
Definition: FullTimePdf.h:139
const FitParameter & _k
Definition: FullTimePdf.h:88
virtual void setGeneratorPdfRelativeToPhaseSpace(double gpdf)
const MINT::FitParameter & _detection_asym
Definition: FullTimePdf.h:127
const MINT::FitParameter & _delta_p1_ss
Definition: FullTimePdf.h:121
const MINT::FitParameter & _p1_os
Definition: FullTimePdf.h:111
const MINT::FitParameter & _c1
Definition: FullTimePdf.h:100
string _marginalPdfsPrefix
Definition: FullTimePdf.h:129
const MINT::FitParameter & _Gamma
Definition: FullTimePdf.h:90
const MINT::FitParameter & _delta_p0_os
Definition: FullTimePdf.h:112
const MINT::FitParameter & _p0_os
Definition: FullTimePdf.h:110
const MINT::FitParameter & _scale_mean_dt
Definition: FullTimePdf.h:95
void setAllObservablesAndFitParameters(IDalitzEvent &evt)
const MINT::FitParameter & _delta_p0_ss
Definition: FullTimePdf.h:120
std::pair< double, double > getCalibratedMistag_SS(IDalitzEvent &evt, double &avg_eta_ss, double &p0_ss, double &p1_ss, double &delta_p0_ss, double &delta_p1_ss)
Definition: FullTimePdf.h:240
TH1D * plotSpline()
virtual double getVal_noPs(IDalitzEvent *evt)
Definition: FullTimePdf.h:267
std::pair< double, double > getCalibratedMistag_OS(IDalitzEvent &evt)