Page MenuHomeHEPForge

No OneTemporary

diff --git a/examples/GenFitIncoherent_Bs2KSKpi.cc b/examples/GenFitIncoherent_Bs2KSKpi.cc
new file mode 100644
index 0000000..274ebc7
--- /dev/null
+++ b/examples/GenFitIncoherent_Bs2KSKpi.cc
@@ -0,0 +1,486 @@
+#include <cstdlib>
+#include <iostream>
+#include <vector>
+#include <fstream>
+
+#include "TFile.h"
+#include "TH2.h"
+#include "TString.h"
+#include "TTree.h"
+#include "TLeaf.h"
+
+#include "LauBsCPFitModel.hh"
+#include "LauBkgndDPModel.hh"
+#include "LauDaughters.hh"
+#include "LauEffModel.hh"
+#include "LauWeightedSumEffModel.hh"
+#include "LauIsobarDynamics.hh"
+#include "LauCartesianCPCoeffSet.hh"
+#include "LauRealImagCPCoeffSet.hh"
+#include "LauVetoes.hh"
+#include "LauLASSNRRes.hh"
+#include "LauLASSRes.hh"
+//#include "LauLesniakRes.hh"
+
+void usage( std::ostream& out, const TString& progName )
+{
+ out<<"Usage:\n";
+ out<<progName<<" gen [nExpt = 1] [firstExpt = 0] <KS_type> <DP_type> <Year> <refFitName> <N x [resName-resModel]> "<<std::endl;
+ out<<"or\n";
+ out<<progName<<" <iFit> [nExpt = 1] [firstExpt = 0] <KS_type> <DP_type> <Year> <port> <refFitName> <N x [resName-resModel]> "<<std::endl;
+}
+
+int main( int argc, char** argv )
+{
+ if ( argc < 9 ) {
+ usage( std::cerr, argv[0] );
+ return EXIT_FAILURE;
+ }
+
+ TString command = argv[1];
+ command.ToLower();
+
+ Int_t iFit(0);
+ Int_t nExpt(1);
+ Int_t firstExpt(0);
+ TString KS_type = "";
+ TString DP_type = "";
+ TString Year = "";
+ UInt_t port(5000);
+ TString refFitDir = "";
+ Int_t nPars(0);
+
+ // Resonance list
+ std::multimap<std::string, std::pair<Int_t, std::string> > resList;
+ TString tmp_resName = "";
+ std::string outNameRes = "";
+ Int_t bachelarRef(0);
+ TString resName = "";
+
+ if (command == "gen") {
+ nExpt = atoi( argv[2] );
+ firstExpt = atoi( argv[3] );
+ KS_type = argv[4];
+ DP_type = argv[5];
+ Year = argv[6];
+ refFitDir = argv[7];
+ nPars = 8;
+ } else if (command == "fit") {
+ iFit = atoi( argv[2] );
+ nExpt = atoi( argv[3] );
+ firstExpt = atoi( argv[4] );
+ KS_type = argv[5];
+ DP_type = argv[6];
+ Year = argv[7];
+ port = atoi( argv[8] );
+ refFitDir = argv[9];
+ nPars = 10;
+ } else {
+ usage( std::cerr, argv[0] );
+ return EXIT_FAILURE;
+ }
+
+ // Produce resonance maps
+ char seps[] = ",";
+ for (Int_t i = nPars; i < argc; ++i){
+ std::vector<std::string> split;
+ char *token;
+ token = strtok(argv[i], seps );
+ while( token != NULL )
+ {
+ split.push_back(token);
+ token = strtok( NULL, seps );
+ }
+ tmp_resName = split[0];
+ if (tmp_resName.Contains("-")){
+ std::cout << "FitDP_Bs2KSKpi::ERROR - Wrong configuration of the resonance. Please only use input resonances neutral or positive charged." << std::endl;
+ return EXIT_FAILURE;
+ }
+ if ( DP_type == "KSKpi" ){
+ if ((tmp_resName.Contains("a")) && (tmp_resName.Contains("("))){
+ bachelarRef = 2;
+ } else if (tmp_resName.Contains("K*+")){
+ tmp_resName.ReplaceAll("+","-");
+ bachelarRef = 1;
+ } else if (tmp_resName.Contains("K*0")){
+ bachelarRef = 3;
+ } else if (tmp_resName.Contains("kappa+")){
+ tmp_resName.ReplaceAll("+","-");
+ bachelarRef = 1;
+ } else if (tmp_resName.Contains("kappa0")){
+ bachelarRef = 3;
+ } else if (tmp_resName.Contains("BelleNR+")){
+ tmp_resName.ReplaceAll("+","-");
+ bachelarRef = 1;
+ } else if (tmp_resName == "BelleNR"){
+ bachelarRef = 3;
+ }
+ } else {
+ if ((tmp_resName.Contains("a")) && (tmp_resName.Contains("("))){
+ tmp_resName.ReplaceAll("+","-");
+ bachelarRef = 1;
+ } else if (tmp_resName.Contains("K*+")){
+ bachelarRef = 2;
+ } else if (tmp_resName.Contains("K*0")){
+ bachelarRef = 3;
+ } else if (tmp_resName.Contains("kappa+")){
+ bachelarRef = 2;
+ } else if (tmp_resName.Contains("kappa0")){
+ bachelarRef = 3;
+ } else if (tmp_resName.Contains("BelleNR+")){
+ bachelarRef = 2;
+ } else if (tmp_resName == "BelleNR"){
+ bachelarRef = 3;
+ }
+ }
+
+ // Final resonance 'corrected' name
+ outNameRes = tmp_resName;
+ // Add to the final list
+ resList.insert(std::make_pair(outNameRes, std::make_pair(bachelarRef, split[1])));
+ }
+
+ // Additional configuration
+ TString dataFile("Ntuples/Data/DP/Bs2"+DP_type+"_"+KS_type+"_"+Year+"_Data.root");
+ TString treeName("fitResults");
+ Double_t Yield_sig(0.), Yield_bkg(0.), Yield_cross(0.);
+ TFile *refDataFile = TFile::Open(dataFile, "READ");
+ TTree* refTree = dynamic_cast<TTree*>(refDataFile->Get(treeName));
+ refTree->GetEntry(0);
+ Yield_sig = refTree->GetLeaf("Yield_sig")->GetValue();
+ Yield_bkg = refTree->GetLeaf("Yield_bkg")->GetValue();
+ Yield_cross = refTree->GetLeaf("Yield_cross")->GetValue();
+ std::cout << "Yields: sig = " << Yield_sig << " bkg = " << Yield_bkg << " cross = " << Yield_cross << std::endl;
+ refDataFile->Close();
+
+ // If you want to use square DP histograms for efficiency,
+ // backgrounds or you just want the square DP co-ordinates
+ // stored in the toy MC ntuple then set this to kTRUE
+ Bool_t squareDP = kTRUE;
+
+ // The DP is defined in terms of m13Sq and m23Sq
+ LauDaughters* daughters;
+ LauDaughters* daughters_bar;
+ if ( DP_type == "KSKpi" ){
+ daughters = new LauDaughters("B_s0", "K+", "pi-", "K_S0", squareDP);
+ daughters_bar = new LauDaughters("B_s0_bar", "K+", "pi-", "K_S0", squareDP);
+ } else {
+ daughters = new LauDaughters("B_s0", "pi+", "K-", "K_S0", squareDP);
+ daughters_bar = new LauDaughters("B_s0_bar", "pi+", "K-", "K_S0", squareDP);
+ }
+
+ // Optionally apply some vetoes to the DP
+ LauVetoes* vetoes = new LauVetoes();
+
+ // Define the efficiency model (defaults to unity everywhere)
+ // Can optionally provide a histogram to model variation over DP
+ // (example syntax given in commented-out section)
+
+
+ LauEffModel* effModelTOS = new LauEffModel(daughters, vetoes);
+ LauEffModel* effModelTIS = new LauEffModel(daughters, vetoes);
+ LauWeightedSumEffModel* effModel = new LauWeightedSumEffModel(daughters);
+
+ Bool_t fluctuateBins = kFALSE;
+ Bool_t useInterpolation = kTRUE;
+ Bool_t useUpperHalf = kFALSE;
+
+
+ TString treeFinalState = "";
+ if (DP_type == "KSKpi"){
+ treeFinalState = "Kpi";
+ } else {
+ treeFinalState = "piK";
+ }
+
+
+ TFile *effHistFile_Geom = TFile::Open("Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".root","READ");
+ TFile *effHistFile_Track = TFile::Open("Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".root","READ");
+ TFile *effHistFile_PID = TFile::Open("Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".root","READ");
+ TFile *effHistFile_L0TOS = TFile::Open("Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".root","READ");
+ TFile *effHistFile_L0TIS = TFile::Open("Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".root","READ");
+ TFile *effHistFile_SelTOS = TFile::Open("Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".root","READ");
+ TFile *effHistFile_SelTIS = TFile::Open("Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".root","READ");
+
+ TH2* effHist_Geom = dynamic_cast<TH2*>(effHistFile_Geom->Get("efficiency"));
+ TH2* effHist_Track = dynamic_cast<TH2*>(effHistFile_Track->Get("efficiency"));
+ TH2* effHist_PID = dynamic_cast<TH2*>(effHistFile_PID->Get("efficiency"));
+ TH2* effHist_L0TOS = dynamic_cast<TH2*>(effHistFile_L0TOS->Get("efficiency"));
+ TH2* effHist_L0TIS = dynamic_cast<TH2*>(effHistFile_L0TIS->Get("efficiency"));
+ TH2* effHist_SelTOS = dynamic_cast<TH2*>(effHistFile_SelTOS->Get("efficiency"));
+ TH2* effHist_SelTIS = dynamic_cast<TH2*>(effHistFile_SelTIS->Get("efficiency"));
+
+
+ effModelTOS->setEffSpline(effHist_Geom, fluctuateBins, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTOS->addEffSpline(effHist_Track, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTOS->addEffSpline(effHist_PID, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTOS->addEffSpline(effHist_L0TOS, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTOS->addEffSpline(effHist_SelTOS, 0.0, 0.0, useUpperHalf, squareDP);
+
+ effModelTIS->setEffSpline(effHist_Geom, fluctuateBins, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTIS->addEffSpline(effHist_Track, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTIS->addEffSpline(effHist_PID, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTIS->addEffSpline(effHist_L0TIS, 0.0, 0.0, useUpperHalf, squareDP);
+ effModelTIS->addEffSpline(effHist_SelTIS, 0.0, 0.0, useUpperHalf, squareDP);
+
+ Double_t fracTOS(0.), fracTIS(0.);
+ TString iFilenameTOS = "Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".dat";
+ TString iFilenameTIS = "Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_"+KS_type+"_"+Year+"_"+treeFinalState+".dat";
+
+ std::ifstream iFileTOS(iFilenameTOS);
+ if (iFileTOS.good()){ iFileTOS >> fracTOS; }
+ iFileTOS.close();
+ std::ifstream iFileTIS(iFilenameTIS);
+ if (iFileTIS.good()){ iFileTIS >> fracTIS; }
+ iFileTIS.close();
+
+ effModel->addEffModel(effModelTOS,fracTOS);
+ effModel->addEffModel(effModelTIS,fracTIS);
+
+ //LauEffModel* effModel = new LauEffModel(daughters, vetoes);
+
+ // Create the isobar model
+ LauAbsResonance* res(0);
+ LauIsobarDynamics* sigModel = new LauIsobarDynamics(daughters, effModel);
+ LauIsobarDynamics* sigModel_bar = new LauIsobarDynamics(daughters_bar, effModel);
+ for (std::multimap<std::string, std::pair<Int_t, std::string> >::iterator it_res = resList.begin(); it_res != resList.end(); ++it_res){
+ std::cout << "FitDP_Bs2KSKpi::INFO - adding resonance " << it_res->first << std::endl;
+ resName = it_res->first;
+ if (it_res->second.second == "RelBW"){
+ sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::RelBW);
+ sigModel_bar->addResonance(resName, it_res->second.first, LauAbsResonance::RelBW);
+ } else if (it_res->second.second == "LASS"){
+ sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::LASS);
+ sigModel_bar->addResonance(resName, it_res->second.first, LauAbsResonance::LASS);
+ } else if (it_res->second.second == "Flatte"){
+ sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::Flatte);
+ } else if (it_res->second.second == "FlatNR"){
+ sigModel->addResonance(resName, 0, LauAbsResonance::FlatNR);
+ } else if (it_res->second.second == "LASSNoCutOff"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::LASS);
+ res->fixMass(kFALSE);
+ res->fixWidth(kFALSE);
+ res->floatResonanceParameter("a");
+ res->floatResonanceParameter("r");
+ LauLASSRes* lass = dynamic_cast<LauLASSRes*>( res );
+ lass->setCutOff(10.0);
+ } else if (it_res->second.second == "LASSNoCutOffFix"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::LASS);
+ res->floatResonanceParameter("a");
+ res->floatResonanceParameter("r");
+ LauLASSRes* lass = dynamic_cast<LauLASSRes*>( res );
+ lass->setCutOff(10.0);
+ } else if (it_res->second.second == "LASSNoCutOffGaussian"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::LASS);
+ res->fixMass(kFALSE);
+ res->fixWidth(kFALSE);
+ res->floatResonanceParameter("a");
+ res->floatResonanceParameter("r");
+ LauParameter* Kst_1430_Mass = res->getMassPar();
+ LauParameter* Kst_1430_Width = res->getWidthPar();
+ Kst_1430_Mass->addGaussianConstraint(1.425, 0.001);
+ Kst_1430_Width->addGaussianConstraint(0.270, 0.001);
+ res->fixMass(0);
+ res->fixWidth(0);
+ LauLASSRes* lass = dynamic_cast<LauLASSRes*>( res );
+ lass->setCutOff(10.0);
+// } else if (it_res->second.second == "Lesniak"){
+// LauLesniakRes::setupFormFactor("usfactor.dat");
+// sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::LesniakMassTerm);
+ } else if (it_res->second.second == "FlatteKst"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::Flatte);
+ res->changeResonance(1.513, -1, -1);
+ res->setResonanceParameter("g1", 0.304);
+ res->setResonanceParameter("gRatio", 0.380/0.304);
+ } else if (it_res->second.second == "FlatteKstFloat"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::Flatte);
+ res->changeResonance(1.513, -1, -1);
+ res->fixMass(kFALSE);
+ res->setResonanceParameter("g1", 0.304);
+ res->setResonanceParameter("gRatio", 0.380/0.304);
+ res->floatResonanceParameter("g1");
+ } else if (it_res->second.second == "Kappa"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::Kappa);
+ res->setResonanceParameter("b1", 24.49);
+ res->setResonanceParameter("b2", 0.0);
+ res->setResonanceParameter("A", 2.5);
+ res->setResonanceParameter("m0", 3.3);
+ } else if (it_res->second.second == "KappaFloat"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::Kappa);
+ res->setResonanceParameter("b1", 24.49);
+ res->setResonanceParameter("b2", 0.0);
+ res->setResonanceParameter("A", 2.5);
+ res->setResonanceParameter("m0", 3.3);
+ res->floatResonanceParameter("b1");
+ res->floatResonanceParameter("A");
+ res->floatResonanceParameter("m0");
+ } else if (it_res->second.second == "BelleNR"){
+ res = sigModel->addResonance(resName, it_res->second.first, LauAbsResonance::BelleNR);
+ res->setResonanceParameter("alpha", 0.4);
+ res->floatResonanceParameter("alpha");
+ } else {
+ std::cout << "FitDP_Bs2KSKpi::ERROR - wrong resonance model configuration" << std::endl;
+ return EXIT_FAILURE;
+ }
+ }
+
+ // Reset the maximum signal DP ASq value
+ sigModel->setASqMaxValue(2.0);
+ sigModel_bar->setASqMaxValue(2.0);
+
+ // Create the fit model
+ LauBsCPFitModel* fitModel = new LauBsCPFitModel(sigModel_bar, sigModel, 0.10);
+
+ // Create the complex coefficients for the isobar model
+ std::vector<LauAbsCoeffSet*> coeffset;
+ LauAbsCoeffSet* resAdd = 0;
+ for (std::multimap<std::string, std::pair<Int_t, std::string> >::iterator it_res = resList.begin(); it_res != resList.end(); ++it_res){
+ resName = it_res->first;
+ std::cout << "Initial resonance name: "<< resName << std::endl;
+ if ( DP_type == "KSKpi" ){
+ if (resName.Contains("-")){
+ if ((resName.Contains("K*")) && (resName.Contains("(892)"))){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kTRUE, kTRUE, kTRUE, kTRUE);
+ } else {
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ }
+ if (resName.Contains("BelleNR")){
+ resName.ReplaceAll("-","m_");
+ } else {
+ resName.ReplaceAll("-","m"); resName.ReplaceAll("*","st"); resName.ReplaceAll("(","_"); resName.ReplaceAll(")","_");
+ }
+ } else if (resName.Contains("+")){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("+","p"); resName.ReplaceAll("*","st"); resName.ReplaceAll("(","_"); resName.ReplaceAll(")","_");
+ } else if (resName.Contains("NonReson")){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("Reson","Reson_KSKpi_");
+ } else if (resName == "BelleNR"){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("NR","NR_KSKpi_");
+ } else {
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("*0","stzb"); resName.ReplaceAll("(","_"); resName.ReplaceAll(")","_");
+ }
+ } else {
+ if (resName.Contains("+")){
+ if ((resName.Contains("K*")) && (resName.Contains("(892)"))){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kTRUE, kTRUE, kTRUE, kTRUE);
+ } else {
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ }
+ if (resName.Contains("BelleNR")){
+ resName.ReplaceAll("+","p_");
+ } else {
+ resName.ReplaceAll("+","p"); resName.ReplaceAll("*","st"); resName.ReplaceAll("(","_"); resName.ReplaceAll(")","_");
+ }
+ } else if (resName.Contains("-")){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("-","m"); resName.ReplaceAll("*","st"); resName.ReplaceAll("(","_"); resName.ReplaceAll(")","_");
+ } else if (resName.Contains("NonReson")){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("Reson","Reson_KSpiK_");
+ } else if (resName == "BelleNR"){
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("NR","NR_KSpiK_");
+ } else {
+ resAdd = new LauRealImagCPCoeffSet(resName , 1.0, 0.0, 1.0, 0.0, kFALSE, kFALSE, kFALSE, kFALSE);
+ resName.ReplaceAll("*0","stz"); resName.ReplaceAll("(","_"); resName.ReplaceAll(")","_");
+ }
+ }
+ std::cout << "Adding name : " << resName << " to the list ..." << std::endl;
+ resAdd->baseName(resName);
+ coeffset.push_back(resAdd);
+ }
+
+ for (std::vector<LauAbsCoeffSet*>::iterator iter=coeffset.begin(); iter!=coeffset.end(); ++iter) {
+ fitModel->setAmpCoeffSet(*iter);
+ }
+
+ // Set the signal yield and define whether it is fixed or floated
+ TString sigEventsName = "signalEvents_"+KS_type+"_"+DP_type+"_"+Year;
+ LauParameter * nSigEvents = new LauParameter(sigEventsName,Yield_sig,-2.0*Yield_sig,2.0*Yield_sig,kTRUE);
+ fitModel->setNSigEvents(nSigEvents);
+
+ // Set the number of experiments to generate or fit and which
+ // experiment to start with
+ fitModel->setNExpts( nExpt, firstExpt );
+
+ // Optionally load in continuum background DP model histogram
+ // (example syntax given in commented-out section)
+ std::vector<TString> bkgndNames(2);
+ bkgndNames[0] = "comb"+KS_type+"_"+DP_type+"_"+Year;
+ bkgndNames[1] = "cross"+KS_type+"_"+DP_type+"_"+Year;
+ fitModel->setBkgndClassNames( bkgndNames );
+ LauParameter* nBkgndEvents = new LauParameter(bkgndNames[0], Yield_bkg, -2.0*Yield_bkg, 2.0*Yield_bkg, kTRUE);
+ fitModel->setNBkgndEvents( nBkgndEvents );
+ LauParameter* nBkgndCrossEvents = new LauParameter(bkgndNames[1], Yield_cross, -2.0*Yield_cross, 2.0*Yield_cross, kTRUE);
+ fitModel->setNBkgndEvents( nBkgndCrossEvents );
+
+ // Combinatorial background model
+ TFile *bgFile = TFile::Open("Maps/Bkg/Map_Bkg_RSB_Bs2"+DP_type+"_"+KS_type+"_"+Year+"_BDT_-0.10.root", "READ");
+ TH2* bgDP = dynamic_cast<TH2*>(bgFile->Get("Map"));
+ LauBkgndDPModel* bkgndModel = new LauBkgndDPModel(daughters, vetoes);
+ bkgndModel->setBkgndHisto(bgDP, useInterpolation, fluctuateBins, useUpperHalf, squareDP);
+ fitModel->setBkgndDPModel( bkgndNames[0], bkgndModel );
+
+ // Crossfeed background model
+ TFile *crossFile = TFile::Open("Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_"+KS_type+"_"+treeFinalState+"_"+Year+".root", "READ");
+ TH2* crossDP = dynamic_cast<TH2*>(crossFile->Get("Map"));
+ LauBkgndDPModel* crossModel = new LauBkgndDPModel(daughters, vetoes);
+ crossModel->setBkgndHisto(crossDP, useInterpolation, fluctuateBins, useUpperHalf, squareDP);
+ fitModel->setBkgndDPModel( bkgndNames[1], crossModel );
+
+ // Switch on/off calculation of asymmetric errors.
+ fitModel->useAsymmFitErrors(kFALSE);
+
+ // Randomise initial fit values for the signal mode
+ fitModel->useRandomInitFitPars(kTRUE);
+
+ // Switch on/off Poissonian smearing of total number of events
+ fitModel->doPoissonSmearing(kFALSE);
+
+ // Switch on/off Extended ML Fit option
+ Bool_t emlFit = ( fitModel->nBkgndClasses() > 0 );
+ fitModel->doEMLFit(emlFit);
+
+ // Set the names of the files to read/write
+ TString dirSave("");
+ TString rootFileName("");
+ TString tableFileName("");
+ TString fitToyFileName("fitToyMC_");
+ TString splotFileName("splot_");
+
+ dirSave = "Results/"; dirSave += refFitDir; dirSave += "/";
+ dataFile = dirSave+"/GenToyMC/ToyMC";
+ dataFile += "_nExpt_500_"; dataFile += KS_type; dataFile += "-"; dataFile += DP_type; dataFile += "-"; dataFile += Year; dataFile += ".root";
+ treeName = "genResults";
+ // Files output
+ if (command == "fit") {
+ rootFileName = dirSave+"Fit/FitResults_"; rootFileName += iFit;
+ rootFileName += "-"; rootFileName += KS_type; rootFileName += "-"; rootFileName += DP_type; rootFileName += "-"; rootFileName += Year;
+ rootFileName += ".root";
+ tableFileName = "fitResults_"; tableFileName += iFit;
+ fitToyFileName += iFit;
+ fitToyFileName += ".root";
+ splotFileName += iFit;
+ splotFileName += ".root";
+
+ // Generate toy from the fitted parameters
+ TString toyName = dirSave+"ToyMC/ToyMC-"; toyName += KS_type; toyName += "-";
+ toyName += DP_type; toyName += "-"; toyName += Year; toyName += "-"; toyName += iFit; toyName += ".root";
+ fitModel->compareFitData(100,toyName,"",kTRUE);
+
+ //fitModel->run( command, dataFile, treeName, rootFileName, tableFileName );
+ fitModel->runSlave( dataFile, treeName, rootFileName, tableFileName, "localhost", port );
+
+ } else {
+ rootFileName = "dummy.root";
+ tableFileName = "genResults";
+
+ // Generate samples
+ fitModel->run( command, dataFile, treeName, rootFileName, tableFileName );
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2011_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2011_BDT_-0.10.root
new file mode 100644
index 0000000..67abcad
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2011_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2011_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2011_BDT_0.00.root
new file mode 100644
index 0000000..69613dc
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2011_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012a_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012a_BDT_-0.10.root
new file mode 100644
index 0000000..5f13ed4
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012a_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012a_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012a_BDT_0.00.root
new file mode 100644
index 0000000..7fde71c
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012a_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012b_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012b_BDT_-0.10.root
new file mode 100644
index 0000000..756436b
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012b_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012b_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012b_BDT_0.00.root
new file mode 100644
index 0000000..2e477d4
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_DD_2012b_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2011_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2011_BDT_-0.10.root
new file mode 100644
index 0000000..0d33ce2
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2011_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2011_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2011_BDT_0.00.root
new file mode 100644
index 0000000..b684094
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2011_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012a_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012a_BDT_-0.10.root
new file mode 100644
index 0000000..39a3fff
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012a_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012a_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012a_BDT_0.00.root
new file mode 100644
index 0000000..516ac62
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012a_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012b_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012b_BDT_-0.10.root
new file mode 100644
index 0000000..3f42dd7
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012b_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012b_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012b_BDT_0.00.root
new file mode 100644
index 0000000..c632e19
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSKpi_LL_2012b_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2011_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2011_BDT_-0.10.root
new file mode 100644
index 0000000..b55ec72
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2011_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2011_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2011_BDT_0.00.root
new file mode 100644
index 0000000..207c9b9
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2011_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012a_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012a_BDT_-0.10.root
new file mode 100644
index 0000000..01b15d4
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012a_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012a_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012a_BDT_0.00.root
new file mode 100644
index 0000000..7186fe4
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012a_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012b_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012b_BDT_-0.10.root
new file mode 100644
index 0000000..907753b
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012b_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012b_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012b_BDT_0.00.root
new file mode 100644
index 0000000..a781e8e
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_DD_2012b_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2011_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2011_BDT_-0.10.root
new file mode 100644
index 0000000..147177d
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2011_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2011_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2011_BDT_0.00.root
new file mode 100644
index 0000000..4fc2b0f
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2011_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012a_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012a_BDT_-0.10.root
new file mode 100644
index 0000000..1415a99
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012a_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012a_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012a_BDT_0.00.root
new file mode 100644
index 0000000..06057cb
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012a_BDT_0.00.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012b_BDT_-0.10.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012b_BDT_-0.10.root
new file mode 100644
index 0000000..2d8a849
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012b_BDT_-0.10.root differ
diff --git a/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012b_BDT_0.00.root b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012b_BDT_0.00.root
new file mode 100644
index 0000000..8f39ef7
Binary files /dev/null and b/examples/Maps/Bkg/Map_Bkg_RSB_Bs2KSpiK_LL_2012b_BDT_0.00.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2011.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2011.root
new file mode 100644
index 0000000..8b95294
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2011.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2012a.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2012a.root
new file mode 100644
index 0000000..e6f2d43
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2012a.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2012b.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2012b.root
new file mode 100644
index 0000000..eaa0068
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_Kpi_2012b.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2011.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2011.root
new file mode 100644
index 0000000..36ad7e8
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2011.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2012a.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2012a.root
new file mode 100644
index 0000000..05645fa
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2012a.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2012b.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2012b.root
new file mode 100644
index 0000000..3906db0
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_DD_piK_2012b.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2011.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2011.root
new file mode 100644
index 0000000..6b88ac4
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2011.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2012a.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2012a.root
new file mode 100644
index 0000000..88768be
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2012a.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2012b.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2012b.root
new file mode 100644
index 0000000..0513b83
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_Kpi_2012b.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2011.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2011.root
new file mode 100644
index 0000000..38102f9
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2011.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2012a.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2012a.root
new file mode 100644
index 0000000..027d918
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2012a.root differ
diff --git a/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2012b.root b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2012b.root
new file mode 100644
index 0000000..a7b3405
Binary files /dev/null and b/examples/Maps/Crossfeed/Crossfeed_Map_DP1_Bd2KSpipi_LL_piK_2012b.root differ
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2011_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2011_Kpi.dat
new file mode 100644
index 0000000..1eba508
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2011_Kpi.dat
@@ -0,0 +1 @@
+1.37355
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2011_piK.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2011_piK.dat
new file mode 100644
index 0000000..75a1798
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2011_piK.dat
@@ -0,0 +1 @@
+0.969841
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012a_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012a_Kpi.dat
new file mode 100644
index 0000000..c2a9563
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012a_Kpi.dat
@@ -0,0 +1 @@
+1.2785
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012a_piK.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012a_piK.dat
new file mode 100644
index 0000000..c095c5d
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012a_piK.dat
@@ -0,0 +1 @@
+0.837346
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012b_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012b_Kpi.dat
new file mode 100644
index 0000000..3d597d0
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012b_Kpi.dat
@@ -0,0 +1 @@
+1.08271
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012b_piK.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012b_piK.dat
new file mode 100644
index 0000000..d75f513
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_DD_2012b_piK.dat
@@ -0,0 +1 @@
+1.36671
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2011_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2011_Kpi.dat
new file mode 100644
index 0000000..e0bd2f0
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2011_Kpi.dat
@@ -0,0 +1 @@
+1.19048
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2011_piK.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2011_piK.dat
new file mode 100644
index 0000000..155af93
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2011_piK.dat
@@ -0,0 +1 @@
+1.40365
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012a_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012a_Kpi.dat
new file mode 100644
index 0000000..9df4b29
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012a_Kpi.dat
@@ -0,0 +1 @@
+1.13269
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012a_piK.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012a_piK.dat
new file mode 100644
index 0000000..a38ed79
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012a_piK.dat
@@ -0,0 +1 @@
+0.747828
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012b_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012b_Kpi.dat
new file mode 100644
index 0000000..1ec28b9
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012b_Kpi.dat
@@ -0,0 +1 @@
+0.822112
diff --git a/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012b_piK.dat b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012b_piK.dat
new file mode 100644
index 0000000..74c4c10
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TIS_DP1_Bs2KSKpi_LL_2012b_piK.dat
@@ -0,0 +1 @@
+1.1287
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2011_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2011_Kpi.dat
new file mode 100644
index 0000000..0b90b54
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2011_Kpi.dat
@@ -0,0 +1 @@
+0.92252
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2011_piK.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2011_piK.dat
new file mode 100644
index 0000000..ef123e3
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2011_piK.dat
@@ -0,0 +1 @@
+1.00636
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012a_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012a_Kpi.dat
new file mode 100644
index 0000000..7788aa2
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012a_Kpi.dat
@@ -0,0 +1 @@
+0.895347
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012a_piK.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012a_piK.dat
new file mode 100644
index 0000000..ca6590f
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012a_piK.dat
@@ -0,0 +1 @@
+1.0644
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012b_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012b_Kpi.dat
new file mode 100644
index 0000000..2e52d4a
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012b_Kpi.dat
@@ -0,0 +1 @@
+0.983103
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012b_piK.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012b_piK.dat
new file mode 100644
index 0000000..7712769
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_DD_2012b_piK.dat
@@ -0,0 +1 @@
+0.915709
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2011_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2011_Kpi.dat
new file mode 100644
index 0000000..f5e83dc
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2011_Kpi.dat
@@ -0,0 +1 @@
+0.925926
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2011_piK.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2011_piK.dat
new file mode 100644
index 0000000..6d8acc2
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2011_piK.dat
@@ -0,0 +1 @@
+0.861694
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012a_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012a_Kpi.dat
new file mode 100644
index 0000000..9c90fd5
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012a_Kpi.dat
@@ -0,0 +1 @@
+0.921805
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012a_piK.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012a_piK.dat
new file mode 100644
index 0000000..d4aa3e2
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012a_piK.dat
@@ -0,0 +1 @@
+1.18102
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012b_Kpi.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012b_Kpi.dat
new file mode 100644
index 0000000..a161d7a
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012b_Kpi.dat
@@ -0,0 +1 @@
+1.06649
diff --git a/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012b_piK.dat b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012b_piK.dat
new file mode 100644
index 0000000..5d90bd7
--- /dev/null
+++ b/examples/Maps/Eff/Fraction/fraction_TOS_DP1_Bs2KSKpi_LL_2012b_piK.dat
@@ -0,0 +1 @@
+0.952851
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root
new file mode 100644
index 0000000..c5cc863
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root
new file mode 100644
index 0000000..8a59ec7
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root
new file mode 100644
index 0000000..dff84bc
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root
new file mode 100644
index 0000000..0757700
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root
new file mode 100644
index 0000000..46905df
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root
new file mode 100644
index 0000000..e790f63
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root
new file mode 100644
index 0000000..bd59d42
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root
new file mode 100644
index 0000000..8519cf0
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root
new file mode 100644
index 0000000..7504a28
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root
new file mode 100644
index 0000000..7d068c6
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root
new file mode 100644
index 0000000..089698d
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root
new file mode 100644
index 0000000..8a2301b
Binary files /dev/null and b/examples/Maps/Eff/Geometry/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root
new file mode 100644
index 0000000..e0f914d
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root
new file mode 100644
index 0000000..d4727b5
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root
new file mode 100644
index 0000000..e0f914d
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root
new file mode 100644
index 0000000..d4727b5
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root
new file mode 100644
index 0000000..e0f914d
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root
new file mode 100644
index 0000000..d4727b5
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root
new file mode 100644
index 0000000..2dd3526
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root
new file mode 100644
index 0000000..0876b16
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root
new file mode 100644
index 0000000..2dd3526
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root
new file mode 100644
index 0000000..0876b16
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root
new file mode 100644
index 0000000..2dd3526
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root
new file mode 100644
index 0000000..0876b16
Binary files /dev/null and b/examples/Maps/Eff/L0TIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root
new file mode 100644
index 0000000..0143f5f
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root
new file mode 100644
index 0000000..1c79fe5
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root
new file mode 100644
index 0000000..0143f5f
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root
new file mode 100644
index 0000000..1c79fe5
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root
new file mode 100644
index 0000000..0143f5f
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root
new file mode 100644
index 0000000..1c79fe5
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root
new file mode 100644
index 0000000..937f4cb
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root
new file mode 100644
index 0000000..20b14cf
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root
new file mode 100644
index 0000000..937f4cb
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root
new file mode 100644
index 0000000..20b14cf
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root
new file mode 100644
index 0000000..937f4cb
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root
new file mode 100644
index 0000000..20b14cf
Binary files /dev/null and b/examples/Maps/Eff/L0TOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root
new file mode 100644
index 0000000..8c8300c
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root
new file mode 100644
index 0000000..5db67c4
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root
new file mode 100644
index 0000000..1eb4c19
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root
new file mode 100644
index 0000000..16784c3
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root
new file mode 100644
index 0000000..6096792
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root
new file mode 100644
index 0000000..a1ede0d
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root
new file mode 100644
index 0000000..cfe9a7d
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root
new file mode 100644
index 0000000..3d9429a
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root
new file mode 100644
index 0000000..d697555
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root
new file mode 100644
index 0000000..f2b18a7
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root
new file mode 100644
index 0000000..76a4e96
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root
new file mode 100644
index 0000000..0818740
Binary files /dev/null and b/examples/Maps/Eff/PID/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root
new file mode 100644
index 0000000..1859561
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root
new file mode 100644
index 0000000..d200475
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root
new file mode 100644
index 0000000..cca7365
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root
new file mode 100644
index 0000000..d5448a3
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root
new file mode 100644
index 0000000..582b426
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root
new file mode 100644
index 0000000..f38f4b4
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root
new file mode 100644
index 0000000..9ffaeab
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root
new file mode 100644
index 0000000..75cb404
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root
new file mode 100644
index 0000000..90bc40b
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root
new file mode 100644
index 0000000..932394a
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root
new file mode 100644
index 0000000..1f0e808
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root
new file mode 100644
index 0000000..dda10de
Binary files /dev/null and b/examples/Maps/Eff/SelTIS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root
new file mode 100644
index 0000000..33580e5
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root
new file mode 100644
index 0000000..01c5ef7
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root
new file mode 100644
index 0000000..9fac463
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root
new file mode 100644
index 0000000..f0ea93e
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root
new file mode 100644
index 0000000..b5f9ade
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root
new file mode 100644
index 0000000..f525292
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root
new file mode 100644
index 0000000..f43b216
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root
new file mode 100644
index 0000000..5d69d4b
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root
new file mode 100644
index 0000000..3cc39dd
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root
new file mode 100644
index 0000000..6964866
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root
new file mode 100644
index 0000000..1ae5a8a
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root
new file mode 100644
index 0000000..ecd4ad1
Binary files /dev/null and b/examples/Maps/Eff/SelTOS/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root
new file mode 100644
index 0000000..8744a45
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root
new file mode 100644
index 0000000..10ee443
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2011_piK.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root
new file mode 100644
index 0000000..132bb4f
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root
new file mode 100644
index 0000000..2fdc65f
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012a_piK.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root
new file mode 100644
index 0000000..b485661
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root
new file mode 100644
index 0000000..5dd88ab
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_DD_2012b_piK.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root
new file mode 100644
index 0000000..c05344c
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_Kpi.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root
new file mode 100644
index 0000000..3ea544b
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2011_piK.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root
new file mode 100644
index 0000000..02a4869
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_Kpi.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root
new file mode 100644
index 0000000..acf0f7d
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012a_piK.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root
new file mode 100644
index 0000000..80fd2ec
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_Kpi.root differ
diff --git a/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root
new file mode 100644
index 0000000..e91f42f
Binary files /dev/null and b/examples/Maps/Eff/Tracking/Efficiency_Map_DP1_Bs2KSKpi_LL_2012b_piK.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2011.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2011.root
new file mode 100644
index 0000000..30a38a8
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2011.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2012a.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2012a.root
new file mode 100644
index 0000000..2504032
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2012a.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2012b.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2012b.root
new file mode 100644
index 0000000..ff4351f
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_DD_2012b.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2011.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2011.root
new file mode 100644
index 0000000..d1664e0
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2011.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2012a.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2012a.root
new file mode 100644
index 0000000..51c4dd5
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2012a.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2012b.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2012b.root
new file mode 100644
index 0000000..26c550c
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSKpi_LL_2012b.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2011.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2011.root
new file mode 100644
index 0000000..0f1fec6
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2011.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2012a.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2012a.root
new file mode 100644
index 0000000..d8a13d5
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2012a.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2012b.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2012b.root
new file mode 100644
index 0000000..6a18734
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_DD_2012b.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2011.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2011.root
new file mode 100644
index 0000000..c9010d4
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2011.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2012a.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2012a.root
new file mode 100644
index 0000000..538ee09
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2012a.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2012b.root b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2012b.root
new file mode 100644
index 0000000..59ee94b
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_PID_Bs2KSpiK_LL_2012b.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2011_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2011_sqDP.root
new file mode 100644
index 0000000..cf125a1
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2011_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2012a_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2012a_sqDP.root
new file mode 100644
index 0000000..049f56f
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2012a_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2012b_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2012b_sqDP.root
new file mode 100644
index 0000000..8d8073e
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_DD_2012b_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2011_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2011_sqDP.root
new file mode 100644
index 0000000..b4a0429
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2011_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2012a_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2012a_sqDP.root
new file mode 100644
index 0000000..a2b4de0
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2012a_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2012b_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2012b_sqDP.root
new file mode 100644
index 0000000..c463264
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSKpi_LL_2012b_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2011_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2011_sqDP.root
new file mode 100644
index 0000000..21d0383
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2011_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2012a_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2012a_sqDP.root
new file mode 100644
index 0000000..2ebd5af
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2012a_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2012b_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2012b_sqDP.root
new file mode 100644
index 0000000..eefd3bf
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_DD_2012b_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2011_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2011_sqDP.root
new file mode 100644
index 0000000..ccd4821
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2011_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2012a_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2012a_sqDP.root
new file mode 100644
index 0000000..1aa0fd2
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2012a_sqDP.root differ
diff --git a/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2012b_sqDP.root b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2012b_sqDP.root
new file mode 100644
index 0000000..aa2035f
Binary files /dev/null and b/examples/Maps/Eff/old/Efficiency_Selection_Bs2KSpiK_LL_2012b_sqDP.root differ
diff --git a/examples/Master.cc b/examples/Master.cc
index 20aef17..a7ca86f 100644
--- a/examples/Master.cc
+++ b/examples/Master.cc
@@ -1,53 +1,52 @@
#include <cstdlib>
#include <iostream>
#include <vector>
#include "TFile.h"
#include "TRandom.h"
#include "TString.h"
#include "TSystem.h"
#include "LauSimFitMaster.hh"
void usage( std::ostream& out, const TString& progName )
{
out<<"Usage:\n";
- out<<progName<<" <iFit> <nExpt> [firstExpt = 0] [numSlaves = 2] [port = 0]\n";
+ out<<progName<<" <iFit> <nExpt> [firstExpt = 0] [numSlaves = 12] <refFitDir> \n";
}
int main(const int argc, const char ** argv)
{
- if ( argc < 3 ) {
+ if ( argc < 5 ) {
usage( std::cerr, argv[0] );
return EXIT_FAILURE;
}
UInt_t iFit = atoi( argv[1] );
UInt_t nExpt = atoi( argv[2] );
UInt_t firstExpt = 0;
- UInt_t nSlaves = 2;
+ UInt_t nSlaves = 12;
UInt_t port = 0;
+ TString config = "";
+ TString refDirName = "";
- if ( argc > 3 ) {
- firstExpt = atoi( argv[3] );
+ firstExpt = atoi( argv[3] );
+ nSlaves = atoi( argv[4] );
- if ( argc > 4 ) {
- nSlaves = atoi( argv[4] );
-
- if ( argc > 5 ) {
- port = atoi( argv[5] );
- }
- }
+ TString ntupleName = "/data/lhcb/phrlaj/Ph.D./Analysis/Bs2KSKpi/DalitzPlotFit/DalitzAnalysis/";
+ if ( argc > 5 ) {
+ refDirName = argv[5];
+ ntupleName += refDirName; ntupleName += "/";
}
-
- TString ntupleName = "master-ntuple-";
+
+ ntupleName += "Fit/master-ntuple-";
ntupleName += iFit;
ntupleName += ".root";
LauSimFitMaster master( nSlaves, port );
master.runSimFit( ntupleName, nExpt, firstExpt );
return EXIT_SUCCESS;
}
diff --git a/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2011_Data.root b/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2011_Data.root
new file mode 100644
index 0000000..fa5d7ae
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2012a_Data.root b/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2012a_Data.root
new file mode 100644
index 0000000..dbd2108
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2012b_Data.root b/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2012b_Data.root
new file mode 100644
index 0000000..8aa31f9
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSKpi_DD_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2011_Data.root b/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2011_Data.root
new file mode 100644
index 0000000..8e4c280
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2012a_Data.root b/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2012a_Data.root
new file mode 100644
index 0000000..25cbdf4
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2012b_Data.root b/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2012b_Data.root
new file mode 100644
index 0000000..3bfeaa3
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSKpi_LL_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2011_Data.root b/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2011_Data.root
new file mode 100644
index 0000000..6d1f4c8
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2012a_Data.root b/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2012a_Data.root
new file mode 100644
index 0000000..aaa88ef
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2012b_Data.root b/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2012b_Data.root
new file mode 100644
index 0000000..0af0109
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSpiK_DD_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2011_Data.root b/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2011_Data.root
new file mode 100644
index 0000000..abdddda
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2012a_Data.root b/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2012a_Data.root
new file mode 100644
index 0000000..54217e3
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2012b_Data.root b/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2012b_Data.root
new file mode 100644
index 0000000..21f9b71
Binary files /dev/null and b/examples/Ntuples/Data/DP/Bs2KSpiK_LL_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Combined_Bs2KSKpi_Data.root b/examples/Ntuples/Data/DP/Combined_Bs2KSKpi_Data.root
new file mode 100644
index 0000000..2ebc968
Binary files /dev/null and b/examples/Ntuples/Data/DP/Combined_Bs2KSKpi_Data.root differ
diff --git a/examples/Ntuples/Data/DP/Combined_Bs2KSpiK_Data.root b/examples/Ntuples/Data/DP/Combined_Bs2KSpiK_Data.root
new file mode 100644
index 0000000..d1b610f
Binary files /dev/null and b/examples/Ntuples/Data/DP/Combined_Bs2KSpiK_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2011_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2011_Data.root
new file mode 100644
index 0000000..f0056e9
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2012a_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2012a_Data.root
new file mode 100644
index 0000000..82ec31c
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2012b_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2012b_Data.root
new file mode 100644
index 0000000..eaccbca
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSKpi_DD_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2011_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2011_Data.root
new file mode 100644
index 0000000..22a7824
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2012a_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2012a_Data.root
new file mode 100644
index 0000000..3a7e71e
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2012b_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2012b_Data.root
new file mode 100644
index 0000000..58ec5d5
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSKpi_LL_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2011_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2011_Data.root
new file mode 100644
index 0000000..45ed2a5
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2012a_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2012a_Data.root
new file mode 100644
index 0000000..737867d
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2012b_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2012b_Data.root
new file mode 100644
index 0000000..369baec
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSpiK_DD_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2011_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2011_Data.root
new file mode 100644
index 0000000..7fba2e1
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2011_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2012a_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2012a_Data.root
new file mode 100644
index 0000000..684c75b
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2012a_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2012b_Data.root b/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2012b_Data.root
new file mode 100644
index 0000000..b50fcb4
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Bs2KSpiK_LL_2012b_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Combined_Bs2KSKpi_Data.root b/examples/Ntuples/Data/DP/old/Combined_Bs2KSKpi_Data.root
new file mode 100644
index 0000000..aaa9e0f
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Combined_Bs2KSKpi_Data.root differ
diff --git a/examples/Ntuples/Data/DP/old/Combined_Bs2KSpiK_Data.root b/examples/Ntuples/Data/DP/old/Combined_Bs2KSpiK_Data.root
new file mode 100644
index 0000000..cca4087
Binary files /dev/null and b/examples/Ntuples/Data/DP/old/Combined_Bs2KSpiK_Data.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root
new file mode 100644
index 0000000..04a4a19
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root
new file mode 100644
index 0000000..bd0a91a
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root
new file mode 100644
index 0000000..b598ef0
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root
new file mode 100644
index 0000000..ae1e331
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2011-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root
new file mode 100644
index 0000000..65e0d0d
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root
new file mode 100644
index 0000000..4686683
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root
new file mode 100644
index 0000000..83cef4f
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root
new file mode 100644
index 0000000..346aa95
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012a-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root
new file mode 100644
index 0000000..514322d
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiDD.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root
new file mode 100644
index 0000000..d9d68b0
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSKpiLL.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root
new file mode 100644
index 0000000..b456bf7
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKDD.root differ
diff --git a/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root
new file mode 100644
index 0000000..375b8af
Binary files /dev/null and b/examples/Ntuples/Data/V0hhFitter/B2KShh-2012b-Trigger-Presel-Vetoes-BDT-PID-SingleCand_Bs2KSpiKLL.root differ
diff --git a/examples/runGenFitIncoherent_ToyMC.sh b/examples/runGenFitIncoherent_ToyMC.sh
new file mode 100755
index 0000000..c6bc55a
--- /dev/null
+++ b/examples/runGenFitIncoherent_ToyMC.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+if [ $# -lt 2 ]
+then
+ echo "Usage: $0 <gen> <nExpts>"
+ echo "or"
+ echo "Usage: $0 <fit> <nExpts> <ifit>"
+ exit 1
+fi
+
+config=$1
+nexpt=$2
+firstexpt=0
+numslaves=12
+ifit=$3
+
+# Models condiguration
+model="Model1"
+#res="K*+(892),RelBW K*0(892),RelBW"
+res="K*+(892),RelBW K*0(892),RelBW K*+_0(1430),LASS K*0_0(1430),LASS"
+
+mkdir -p Results/
+mkdir -p Results/$model/logs/
+mkdir -p Results/$model/Fit/
+mkdir -p Results/$model/GenToyMC/
+mkdir -p Results/$model/ToyMC/
+
+# Perform the simultaneous fit
+if [[ $config = "gen" ]]
+then
+ # Printing information about the model for the user
+ echo
+ echo "runMasterSlave::INFO : configuration of the signal model using $model"
+ rm -f Results/$model/input-Sig-Gen-Model.txt
+ echo $model : $res | tee -a Results/$model/input-Sig-Gen-Model.txt
+ echo
+
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt DD KSKpi 2011 $model $res > Results/$model/logs/log-DD-2011-KSKpi-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt LL KSKpi 2011 $model $res > Results/$model/logs/log-LL-2011-KSKpi-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt DD KSKpi 2012a $model $res > Results/$model/logs/log-DD-2012a-KSKpi-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt LL KSKpi 2012a $model $res > Results/$model/logs/log-LL-2012a-KSKpi-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt DD KSKpi 2012b $model $res > Results/$model/logs/log-DD-2012b-KSKpi-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt LL KSKpi 2012b $model $res > Results/$model/logs/log-LL-2012b-KSKpi-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt DD KSpiK 2011 $model $res > Results/$model/logs/log-DD-2011-KSpiK-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt LL KSpiK 2011 $model $res > Results/$model/logs/log-LL-2011-KSpiK-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt DD KSpiK 2012a $model $res > Results/$model/logs/log-DD-2012a-KSpiK-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt LL KSpiK 2012a $model $res > Results/$model/logs/log-LL-2012a-KSpiK-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt DD KSpiK 2012b $model $res > Results/$model/logs/log-DD-2012b-KSpiK-log-gen.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi gen $nexpt $firstexpt LL KSpiK 2012b $model $res > Results/$model/logs/log-LL-2012b-KSpiK-log-gen.out 2>&1
+elif [[ $config = "fit" ]]
+then
+ # Printing information about the model for the user
+ echo
+ echo "runMasterSlave::INFO : configuration of the signal model using $model"
+ rm -f Results/$model/input-Sig-Fit-Model.txt
+ echo $model : $res | tee -a Results/$model/input-Sig-Fit-Model.txt
+ echo
+
+ echo "Running fit ... $ifit"
+
+ ./Master $ifit $nexpt $firstexpt $numslaves Results/$model > Results/$model/logs/master-log-$ifit.out 2>&1 &
+ sleep 5
+
+ port=`tail -1 Results/$model/logs/master-log-$ifit.out | awk '{print $NF}'`
+
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt DD KSKpi 2011 $port $model $res > Results/$model/logs/slave-DD-2011-KSKpi-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt LL KSKpi 2011 $port $model $res > Results/$model/logs/slave-LL-2011-KSKpi-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt DD KSKpi 2012a $port $model $res > Results/$model/logs/slave-DD-2012a-KSKpi-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt LL KSKpi 2012a $port $model $res > Results/$model/logs/slave-LL-2012a-KSKpi-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt DD KSKpi 2012b $port $model $res > Results/$model/logs/slave-DD-2012b-KSKpi-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt LL KSKpi 2012b $port $model $res > Results/$model/logs/slave-LL-2012b-KSKpi-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt DD KSpiK 2011 $port $model $res > Results/$model/logs/slave-DD-2011-KSpiK-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt LL KSpiK 2011 $port $model $res > Results/$model/logs/slave-LL-2011-KSpiK-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt DD KSpiK 2012a $port $model $res > Results/$model/logs/slave-DD-2012a-KSpiK-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt LL KSpiK 2012a $port $model $res > Results/$model/logs/slave-LL-2012a-KSpiK-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt DD KSpiK 2012b $port $model $res > Results/$model/logs/slave-DD-2012b-KSpiK-log-$ifit.out 2>&1 &
+ sleep 1
+ ./GenFitIncoherent_Bs2KSKpi fit $ifit $nexpt $firstexpt LL KSpiK 2012b $port $model $res > Results/$model/logs/slave-LL-2012b-KSpiK-log-$ifit.out 2>&1
+else
+ echo "runMasterSlave_ToyMC::ERROR : wrong configuration -- either 'gen' or 'fit'"
+ exit 1
+fi
+
+
diff --git a/inc/LauBsCPFitModel.hh b/inc/LauBsCPFitModel.hh
new file mode 100644
index 0000000..e3e43c8
--- /dev/null
+++ b/inc/LauBsCPFitModel.hh
@@ -0,0 +1,580 @@
+
+// Copyright University of Warwick 2004 - 2014.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// Authors:
+// Thomas Latham
+// John Back
+// Paul Harrison
+
+/*! \file LauBsCPFitModel.hh
+ \brief File containing declaration of LauBsCPFitModel class.
+*/
+
+/*! \class LauBsCPFitModel
+ \brief Class for defining a CP fit model.
+
+ LauBsCPFitModel is a class that allows the user to define a three-body Dalitz
+ plot according to the isobar model, i.e. defining a set of resonances that
+ have complex amplitudes that can interfere with each other.
+ It extends the LauSimpleFitModel in that it allows simultaneous fitting of
+ two parent flavours simultaneously. By default, it assumes perfect tagging
+ of those flavours but it can also be used in an untagged scenario.
+*/
+
+#ifndef LAU_BS_CP_FIT_MODEL
+#define LAU_BS_CP_FIT_MODEL
+
+#include <vector>
+
+#include "TString.h"
+
+#include "LauAbsFitModel.hh"
+#include "LauParameter.hh"
+
+class TH2;
+class LauAbsBkgndDPModel;
+class LauAbsCoeffSet;
+class LauIsobarDynamics;
+class LauAbsPdf;
+class LauEffModel;
+class LauEmbeddedData;
+class LauKinematics;
+class LauScfMap;
+
+
+class LauBsCPFitModel : public LauAbsFitModel {
+
+ public:
+ //! Constructor
+ /*!
+ \param [in] negModel DP model for the antiparticle
+ \param [in] posModel DP model for the particle
+ \param [in] D the time-integration scaling factor for A_DeltaGamma
+ */
+ LauBsCPFitModel(LauIsobarDynamics* negModel, LauIsobarDynamics* posModel, Double_t D);
+
+ //! Destructor
+ virtual ~LauBsCPFitModel();
+
+ //! Set the signal event yield
+ /*!
+ \param [in] nSigEvents contains the signal yield and option to fix it
+ */
+ virtual void setNSigEvents(LauParameter* nSigEvents);
+
+ //! Set the background event yield(s)
+ /*!
+ The name of the parameter must be that of the corresponding background category (so that it can be correctly assigned)
+
+ \param [in] nBkgndEvents contains the name, yield and option to fix the yield of the background
+ */
+ virtual void setNBkgndEvents(LauParameter* nBkgndEvents);
+
+ //! Set the background DP models
+ /*!
+ \param [in] bkgndClass the name of the background class
+ \param [in] model the DP model of the background
+ */
+ void setBkgndDPModel(const TString& bkgndClass, LauAbsBkgndDPModel* model);
+
+ //! Split the signal component into well-reconstructed and mis-reconstructed parts
+ /*!
+ The nomenclature used here is TM (truth-matched) and SCF (self cross feed)
+ In this option, the SCF fraction is DP-dependent
+ Can also optionally provide a smearing matrix to smear the SCF DP PDF
+
+ \param [in] dpHisto the DP histogram of the SCF fraction value
+ \param [in] upperHalf whether this histogram is only in the upper half of a symmetric DP
+ \param [in] fluctuateBins whether the bins on the histogram should be varied in accordance with their uncertainties (for evaluation of systematic uncertainties)
+ \param [in] scfMap the (optional) smearing matrix
+ */
+ void splitSignalComponent( const TH2* dpHisto, const Bool_t upperHalf = kFALSE, const Bool_t fluctuateBins = kFALSE, LauScfMap* scfMap = 0 );
+
+ //! Split the signal component into well reconstructed and mis-reconstructed parts
+ /*!
+ The nomenclature used here is TM (truth-matched) and SCF (self cross feed)
+ In this option, the SCF fraction is a single global number
+
+ \param [in] scfFrac the SCF fraction value
+ \param [in] fixed whether the SCF fraction is fixed or floated in the fit
+ */
+ void splitSignalComponent( const Double_t scfFrac, const Bool_t fixed );
+
+ //! Determine whether we are splitting the signal into TM and SCF parts
+ Bool_t useSCF() const { return useSCF_; }
+
+ //! Determine whether the SCF fraction is DP-dependent
+ Bool_t useSCFHist() const { return useSCFHist_; }
+
+ //! Determine if we are smearing the SCF DP PDF
+ Bool_t smearSCFDP() const { return (scfMap_ != 0); }
+
+ // Set the DeltaE and mES models, i.e. give us the PDFs
+ //! Set the signal PDFs
+ /*!
+ \param [in] pdf the PDF to be added to the signal model
+ */
+ void setSignalPdf(LauAbsPdf* pdf);
+
+ //! Set the SCF PDF for a given variable
+ /*!
+ \param [in] pdf the PDF to be added to the signal model
+ */
+ void setSCFPdf(LauAbsPdf* pdf);
+
+ //! Set the background PDFs
+ /*!
+ \param [in] bkgndClass the name of the background class
+ \param [in] pdf the PDF to be added to the background model
+ */
+ void setBkgndPdf(const TString& bkgndClass, LauAbsPdf* pdf);
+
+ //! Set the DP amplitude coefficients
+ /*!
+ \param [in] coeffSet the set of coefficients
+ */
+ virtual void setAmpCoeffSet(LauAbsCoeffSet* coeffSet);
+
+ //! Weight events based on the DP model
+ /*!
+ \param [in] dataFileName the name of the data file
+ \param [in] dataTreeName the name of the data tree
+ */
+ virtual void weightEvents( const TString& dataFileName, const TString& dataTreeName );
+
+ protected:
+ //! Define a map to be used to store a category name and numbers
+ typedef std::map< std::pair<TString,Int_t>, std::pair<Int_t,Double_t> > LauGenInfo;
+
+ //! Typedef for a vector of background DP models
+ typedef std::vector<LauAbsBkgndDPModel*> LauBkgndDPModelList;
+
+ //! Typedef for a vector of background PDFs
+ typedef std::vector<LauPdfList> LauBkgndPdfsList;
+
+ //! Typedef for a vector of background yields
+ typedef std::vector<LauParameter*> LauBkgndYieldList;
+
+ //! Typedef for a vector of embedded data objects
+ typedef std::vector<LauEmbeddedData*> LauBkgndEmbDataList;
+
+ //! Typedef for a vector of booleans to flag if events are reused
+ typedef std::vector<Bool_t> LauBkgndReuseEventsList;
+
+
+ //! Initialise the fit
+ virtual void initialise();
+
+ //! Initialise the signal DP models
+ virtual void initialiseDPModels();
+
+ //! Recalculate Normalization the signal DP models
+ virtual void recalculateNormalisation();
+
+ //! Update the coefficients
+ virtual void updateCoeffs();
+
+ //! Toy MC generation and fitting overloaded functions
+ virtual Bool_t genExpt();
+
+ //! Calculate things that depend on the fit parameters after they have been updated by Minuit
+ virtual void propagateParUpdates();
+
+ //! Read in the input fit data variables, e.g. m13Sq and m23Sq
+ virtual void cacheInputFitVars();
+
+ //! Check the initial fit parameters
+ virtual void checkInitFitParams();
+
+ //! Get the fit results and store them
+ /*!
+ \param [in] tablePrefixName prefix for the name of the output file
+ */
+ virtual void finaliseFitResults(const TString& tablePrefixName);
+
+ //! Print the fit fractions, total DP rate and mean efficiency
+ /*!
+ \param [out] output the stream to which to print
+ */
+ virtual void printFitFractions(std::ostream& output);
+
+ //! Save the pdf Plots for all the resonances of experiment number fitExp
+ /*!
+ TODO - not working in this model!!
+ \param [in] label prefix for the file name to be saved
+ */
+ virtual void savePDFPlots(const TString& label);
+
+ //! Save the pdf Plots for the sum of ressonances correspondint to "sin" of experiment number fitExp
+ /*!
+ TODO - not working in this model!!
+ \param [in] label prefix for the file name to be saved
+ \param [in] spin spin of the wave to be saved
+ */
+ virtual void savePDFPlotsWave(const TString& label, const Int_t& spin);
+ //! Print the asymmetries
+ /*!
+ \param [out] output the stream to which to print
+ */
+ virtual void printAsymmetries(std::ostream& output);
+
+ //! Write the fit results in latex table format
+ /*!
+ \param [in] outputFile the name of the output file
+ */
+ virtual void writeOutTable(const TString& outputFile);
+
+ //! Store the per event likelihood values
+ virtual void storePerEvtLlhds();
+
+ // Methods to do with calculating the likelihood functions
+ // and manipulating the fitting parameters.
+ //! Get the total likelihood for each event
+ /*!
+ \param [in] iEvt the event number
+ */
+ virtual Double_t getTotEvtLikelihood(UInt_t iEvt);
+
+ //! Calculate the signal and background likelihoods for the DP for a given event
+ /*!
+ \param [in] iEvt the event number
+ */
+ virtual void getEvtDPLikelihood(UInt_t iEvt);
+
+ //! Calculate the SCF likelihood for the DP for a given event
+ /*!
+ \param [in] iEvt the event number
+ */
+ virtual Double_t getEvtSCFDPLikelihood(UInt_t iEvt);
+
+ //! Determine the signal and background likelihood for the extra variables for a given event
+ /*!
+ \param [in] iEvt the event number
+ */
+ virtual void getEvtExtraLikelihoods(UInt_t iEvt);
+
+ //! Calculate the complete DP amplitude from the B and Bbar parts
+ virtual void calculateDPterms();
+
+ //! Store the decay-time DP normalisation for both f anf fbar final states
+ void calculateAmplitudeNorm();
+
+ //! Calculate the total integral of the interference term
+ void calcInterTermNorm();
+
+ //! Calculate the component integrals of the interference term
+ void calcInterferenceTermIntegrals();
+
+ //! Get the total number of events
+ /*!
+ \return the total number of events
+ */
+ virtual Double_t getEventSum() const;
+
+ //! Set the fit parameters for the DP model
+ void setSignalDPParameters();
+
+ //! Set the fit parameters for the extra PDFs
+ void setExtraPdfParameters();
+
+ //! Set the initial yields
+ void setFitNEvents();
+
+ //! Set-up other parameters that are derived from the fit results, e.g. fit fractions
+ void setExtraNtupleVars();
+
+ //! Randomise the initial fit parameters
+ void randomiseInitFitPars();
+
+ //! Calculate the CP-conserving and CP-violating fit fractions
+ /*!
+ \param [in] initValues is this before or after the fit
+ */
+ void calcExtraFractions(Bool_t initValues = kFALSE);
+
+ //! Calculate the CP asymmetries
+ /*!
+ \param [in] initValues is this before or after the fit
+ */
+ void calcAsymmetries(Bool_t initValues = kFALSE);
+
+ //! Define the length of the background vectors
+ virtual void setupBkgndVectors();
+
+ //! Determine the number of events to generate for each hypothesis
+ LauGenInfo eventsToGenerate();
+
+ //! Generate signal event
+ Bool_t generateSignalEvent();
+
+ //! Generate background event
+ /*!
+ \param [in] bgID ID number of the background class
+ */
+ Bool_t generateBkgndEvent(UInt_t bgID);
+
+ //! Setup the required ntuple branches
+ void setupGenNtupleBranches();
+
+ //! Store all of the DP information
+ void setDPBranchValues();
+
+ //! Generate from the extra PDFs
+ /*!
+ \param [in] extraPdfs the list of extra PDFs
+ */
+ void generateExtraPdfValues(LauPdfList* extraPdfs);
+
+ //! Add sPlot branches for the extra PDFs
+ /*!
+ \param [in] extraPdfs the list of extra PDFs
+ \param [in] prefix the list of prefixes for the branch names
+ */
+ void addSPlotNtupleBranches(const LauPdfList* extraPdfs, const TString& prefix);
+
+ //! Set the branches for the sPlot ntuple with extra PDFs
+ /*!
+ \param [in] extraPdfs the list of extra PDFs
+ \param [in] prefix the list of prefixes for the branch names
+ \param [in] iEvt the event number
+ */
+ Double_t setSPlotNtupleBranchValues(LauPdfList* extraPdfs, const TString& prefix, UInt_t iEvt);
+
+ //! Update the signal events after Minuit sets background parameters
+ void updateSigEvents();
+
+ //! Add branches to store experiment number and the event number within the experiment
+ virtual void setupSPlotNtupleBranches();
+
+ //! Returns the names of all variables in the fit
+ virtual LauSPlot::NameSet variableNames() const;
+
+ //! Returns the names and yields of species that are free in the fit
+ virtual LauSPlot::NumbMap freeSpeciesNames() const;
+
+ //! Returns the names and yields of species that are fixed in the fit
+ virtual LauSPlot::NumbMap fixdSpeciesNames() const;
+
+ //! Returns the species and variables for all 2D PDFs in the fit
+ virtual LauSPlot::TwoDMap twodimPDFs() const;
+
+ //! Check if the signal is split into well-reconstructed and mis-reconstructed types
+ virtual Bool_t splitSignal() const {return this->useSCF();}
+
+ //! Check if the mis-reconstructed signal is to be smeared in the DP
+ virtual Bool_t scfDPSmear() const {return (scfMap_ != 0);}
+
+ //! Append fake data points to the inputData for each bin in the SCF smearing matrix
+ /*!
+ We'll be caching the DP amplitudes and efficiencies of the centres of the true bins.
+ To do so, we attach some fake points at the end of inputData, the number of the entry
+ minus the total number of events corresponding to the number of the histogram for that
+ given true bin in the LauScfMap object. (What this means is that when Laura is provided with
+ the LauScfMap object by the user, it's the latter who has to make sure that it contains the
+ right number of histograms and in exactly the right order!)
+
+ \param [in] inputData the fit data
+ */
+ void appendBinCentres( LauFitDataTree* inputData );
+
+ private:
+ //! Copy constructor (not implemented)
+ LauBsCPFitModel(const LauBsCPFitModel& rhs);
+
+ //! Copy assignment operator (not implemented)
+ LauBsCPFitModel& operator=(const LauBsCPFitModel& rhs);
+
+ //! The B- signal Dalitz plot model
+ LauIsobarDynamics *negSigModel_;
+
+ //! The B+ signal Dalitz plot model
+ LauIsobarDynamics *posSigModel_;
+
+ //! The background Dalitz plot models
+ LauBkgndDPModelList bkgndDPModels_;
+
+ //! The B- Dalitz plot kinematics object
+ LauKinematics *negKinematics_;
+
+ //! The B+ Dalitz plot kinematics object
+ LauKinematics *posKinematics_;
+
+ //! The time-integration scaling factor for A_DeltaGamma
+ const Double_t D_;
+
+ //! The signal PDFs
+ LauPdfList signalPdfs_;
+
+ //! The SCF PDFs
+ LauPdfList scfPdfs_;
+
+ //! The background PDFs
+ LauBkgndPdfsList bkgndPdfs_;
+
+ //! Background boolean
+ Bool_t usingBkgnd_;
+
+ //! Number of signal components
+ UInt_t nSigComp_;
+
+ //! Number of signal DP parameters
+ UInt_t nSigDPPar_;
+
+ //! Number of extra PDF parameters
+ UInt_t nExtraPdfPar_;
+
+ //! Number of normalisation parameters (yields, asymmetries)
+ UInt_t nNormPar_;
+
+ //! Magnitudes and Phases
+ std::vector<LauAbsCoeffSet*> coeffPars_;
+
+ //! Integrals of the efficiency corrected amplitude terms
+ /*! The integrals of the efficiency corrected amplitude cross terms for each pair of amplitude components
+ for the same f final state, e.g. |Abar->f|x |A*-> f|
+ Calculated as the sum of A* x Abar x efficiency
+ */
+ std::vector< std::vector<LauComplex> > fifjEffSum_;
+
+ //! The normalisation for the term Re(|A->f*|Abar->f|*phiMix)
+ Double_t interTermReNorm_;
+
+ //! The normalisation for the complete DP amplitude
+ Double_t normDP_;
+
+ //! The B- fit fractions
+ LauParArray negFitFrac_;
+
+ //! The B+ fit fractions
+ LauParArray posFitFrac_;
+
+ //! Fit B- fractions (uncorrected for the efficiency)
+ LauParArray negFitFracEffUnCorr_;
+
+ //! Fit B+ fractions (uncorrected for the efficiency)
+ LauParArray posFitFracEffUnCorr_;
+
+ //! The CP violating fit fraction
+ LauParArray CPVFitFrac_;
+
+ //! The CP conserving fit fraction
+ LauParArray CPCFitFrac_;
+
+ //! The fit fraction asymmetries
+ std::vector<LauParameter> fitFracAsymm_;
+
+ //! A_CP parameter
+ std::vector<LauParameter> acp_;
+
+ //! The mean efficiency for B- model
+ LauParameter negMeanEff_;
+
+ //! The mean efficiency for B+ model
+ LauParameter posMeanEff_;
+
+ //! The average DP rate for B-
+ LauParameter negDPRate_;
+
+ //! The average DP rate for B+
+ LauParameter posDPRate_;
+
+ //! Signal yield
+ LauParameter* signalEvents_;
+
+ //! Background yield(s)
+ LauBkgndYieldList bkgndEvents_;
+
+ //! Is the signal split into TM and SCF
+ Bool_t useSCF_;
+
+ //! Is the SCF fraction DP-dependent
+ Bool_t useSCFHist_;
+
+ //! The (global) SCF fraction parameter
+ LauParameter scfFrac_;
+
+ //! The histogram giving the DP-dependence of the SCF fraction
+ LauEffModel* scfFracHist_;
+
+ //! The smearing matrix for the SCF DP PDF
+ LauScfMap* scfMap_;
+
+ //! The cached values of the SCF fraction for each event
+ std::vector<Double_t> recoSCFFracs_;
+
+ //! The cached values of the SCF fraction for each bin centre
+ std::vector<Double_t> fakeSCFFracs_;
+
+ //! The cached values of the sqDP jacobians for each event
+ std::vector<Double_t> recoJacobians_;
+
+ //! The cached values of the sqDP jacobians for each true bin
+ std::vector<Double_t> fakeJacobians_;
+
+ //! Run choice variables
+ Bool_t compareFitData_;
+
+ //! Name of the parent particle
+ TString negParent_;
+
+ //! Name of the parent particle
+ TString posParent_;
+
+ //! The complex coefficients for B-
+ std::vector<LauComplex> negCoeffs_;
+
+ //! The complex coefficients for B+
+ std::vector<LauComplex> posCoeffs_;
+
+ // Toy generation stuff
+
+ //! The maximum allowed number of attempts when generating an event
+ Int_t iterationsMax_;
+
+ //! The number of unsucessful attempts to generate an event so far
+ Int_t nGenLoop_;
+
+ //! The value of A squared for the current event
+ Double_t ASq_;
+
+ //! The maximum value of A squared that has been seen so far while generating
+ Double_t aSqMaxVar_;
+
+ //! The maximum allowed value of A squared
+ Double_t aSqMaxSet_;
+
+ // Likelihood values
+ //! Signal DP likelihood value
+ Double_t sigDPLike_;
+
+ //! SCF DP likelihood value
+ Double_t scfDPLike_;
+
+ //! Background DP likelihood value(s)
+ std::vector<Double_t> bkgndDPLike_;
+
+ //! Signal likelihood from extra PDFs
+ Double_t sigExtraLike_;
+
+ //! SCF likelihood from extra PDFs
+ Double_t scfExtraLike_;
+
+ //! Background likelihood value(s) from extra PDFs
+ std::vector<Double_t> bkgndExtraLike_;
+
+ //! Total signal likelihood
+ Double_t sigTotalLike_;
+
+ //! Total SCF likelihood
+ Double_t scfTotalLike_;
+
+ //! Total background likelihood(s)
+ std::vector<Double_t> bkgndTotalLike_;
+
+ ClassDef(LauBsCPFitModel,0) // CP fit/ToyMC model
+
+};
+
+#endif
diff --git a/inc/Laura++_LinkDef.h b/inc/Laura++_LinkDef.h
index ed5a702..0e54919 100644
--- a/inc/Laura++_LinkDef.h
+++ b/inc/Laura++_LinkDef.h
@@ -1,115 +1,116 @@
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class Lau1DHistPdf;
#pragma link C++ class Lau2DAbsDP;
#pragma link C++ class Lau2DAbsDPPdf;
#pragma link C++ class Lau2DAbsHistDP;
#pragma link C++ class Lau2DAbsHistDPPdf;
#pragma link C++ class Lau2DCubicSpline;
#pragma link C++ class Lau2DHistDP;
#pragma link C++ class Lau2DHistDPPdf;
#pragma link C++ class Lau2DHistPdf;
#pragma link C++ class Lau2DSplineDP;
#pragma link C++ class Lau2DSplineDPPdf;
#pragma link C++ class LauAbsBkgndDPModel;
#pragma link C++ class LauAbsCoeffSet;
#pragma link C++ class LauAbsEffModel;
#pragma link C++ class LauAbsFitter;
#pragma link C++ class LauAbsFitModel;
#pragma link C++ class LauAbsIncohRes;
#pragma link C++ class LauAbsPdf;
#pragma link C++ class LauAbsResonance;
#pragma link C++ class LauAbsRValue;
#pragma link C++ class LauArgusPdf;
#pragma link C++ class LauAsymmCalc;
#pragma link C++ class LauBelleCPCoeffSet;
#pragma link C++ class LauBelleNR;
#pragma link C++ class LauBelleSymNR;
#pragma link C++ class LauBifurcatedGaussPdf;
#pragma link C++ class LauBkgndDPModel;
#pragma link C++ class LauBlattWeisskopfFactor;
#pragma link C++ class LauBreitWignerRes;
#pragma link C++ class LauCacheData;
#pragma link C++ class LauCartesianCPCoeffSet;
#pragma link C++ class LauCartesianGammaCPCoeffSet;
#pragma link C++ class LauChebychevPdf;
#pragma link C++ class LauCleoCPCoeffSet;
#pragma link C++ class LauComplex;
#pragma link C++ class LauCPFitModel;
+#pragma link C++ class LauBsCPFitModel;
#pragma link C++ class LauCruijffPdf;
#pragma link C++ class LauCrystalBallPdf;
#pragma link C++ class LauDabbaRes;
#pragma link C++ class LauDatabasePDG;
#pragma link C++ class LauDaughters;
#pragma link C++ class LauDPDepBifurGaussPdf;
#pragma link C++ class LauDPDepCruijffPdf;
#pragma link C++ class LauDPDepGaussPdf;
#pragma link C++ class LauDPDepMapPdf;
#pragma link C++ class LauDPDepSumPdf;
#pragma link C++ class LauDecayTimePdf;
#pragma link C++ class LauEffModel;
#pragma link C++ class LauEmbeddedData;
#pragma link C++ class LauExponentialPdf;
#pragma link C++ class LauFitDataTree;
#pragma link C++ class LauFitNtuple;
#pragma link C++ class LauFitter;
#pragma link C++ class LauFitObject;
#pragma link C++ class LauFlatteRes;
#pragma link C++ class LauFlatNR;
#pragma link C++ class LauFormulaPar;
#pragma link C++ class LauGaussIncohRes;
#pragma link C++ class LauGaussPdf;
#pragma link C++ class LauGenNtuple;
#pragma link C++ class LauGounarisSakuraiRes;
#pragma link C++ class LauIntegrals;
#pragma link C++ class LauDPPartialIntegralInfo;
#pragma link C++ class LauIsobarDynamics;
#pragma link C++ class LauKappaRes;
#pragma link C++ class LauKinematics;
#pragma link C++ class LauKMatrixProdPole;
#pragma link C++ class LauKMatrixProdSVP;
#pragma link C++ class LauKMatrixPropagator;
#pragma link C++ class LauKMatrixPropFactory;
#pragma link C++ class LauLASSBWRes;
#pragma link C++ class LauLASSNRRes;
#pragma link C++ class LauLASSRes;
#pragma link C++ class LauLinearPdf;
#pragma link C++ class LauMagPhaseCoeffSet;
#pragma link C++ class LauMagPhaseCPCoeffSet;
#pragma link C++ class LauMinuit;
#pragma link C++ class LauModIndPartWave;
#pragma link C++ class LauNovosibirskPdf;
#pragma link C++ class LauNRAmplitude;
#pragma link C++ class LauParameter;
#pragma link C++ class LauParametricStepFuncPdf;
#pragma link C++ class LauParamFixed;
#pragma link C++ class LauParticlePDG;
#pragma link C++ class LauPolNR;
#pragma link C++ class LauPolarGammaCPCoeffSet;
#pragma link C++ class LauPrint;
#pragma link C++ class LauRealImagCoeffSet;
#pragma link C++ class LauRealImagCPCoeffSet;
#pragma link C++ class LauRealImagGammaCPCoeffSet;
#pragma link C++ class LauRelBreitWignerRes;
#pragma link C++ class LauResonanceInfo;
#pragma link C++ class LauResonanceMaker;
#pragma link C++ class LauScfMap;
#pragma link C++ class LauSigmaRes;
#pragma link C++ class LauSigmoidPdf;
#pragma link C++ class LauSimpleFitModel;
#pragma link C++ class LauSimFitMaster;
#pragma link C++ class LauSPlot;
#pragma link C++ class LauString;
#pragma link C++ class LauSumPdf;
#pragma link C++ class LauTextFileParser;
#pragma link C++ class LauTimeDepFitModel;
#pragma link C++ class LauVetoes;
#pragma link C++ class LauWeightedSumEffModel;
#pragma link C++ namespace LauConstants;
#pragma link C++ namespace LauRandom;
#endif
diff --git a/src/LauBsCPFitModel.cc b/src/LauBsCPFitModel.cc
new file mode 100644
index 0000000..cfd4e30
--- /dev/null
+++ b/src/LauBsCPFitModel.cc
@@ -0,0 +1,2660 @@
+
+// Copyright University of Warwick 2004 - 2014.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// Authors:
+// Thomas Latham
+// John Back
+// Paul Harrison
+
+/*! \file LauBsCPFitModel.cc
+ \brief File containing implementation of LauBsCPFitModel class.
+ */
+
+#include <iostream>
+#include <iomanip>
+#include <fstream>
+#include <vector>
+
+#include "TVirtualFitter.h"
+#include "TSystem.h"
+#include "TMinuit.h"
+#include "TRandom.h"
+#include "TFile.h"
+#include "TMath.h"
+#include "TH2.h"
+
+#include "LauAbsBkgndDPModel.hh"
+#include "LauAbsCoeffSet.hh"
+#include "LauIsobarDynamics.hh"
+#include "LauAbsPdf.hh"
+#include "LauAsymmCalc.hh"
+#include "LauComplex.hh"
+#include "LauConstants.hh"
+#include "LauBsCPFitModel.hh"
+#include "LauDaughters.hh"
+#include "LauEffModel.hh"
+#include "LauFitNtuple.hh"
+#include "LauKinematics.hh"
+#include "LauPrint.hh"
+#include "LauRandom.hh"
+#include "LauScfMap.hh"
+#include "LauDPPartialIntegralInfo.hh"
+
+ClassImp(LauBsCPFitModel)
+
+
+LauBsCPFitModel::LauBsCPFitModel(LauIsobarDynamics* negModel, LauIsobarDynamics* posModel, Double_t D) : LauAbsFitModel(),
+ negSigModel_(negModel), posSigModel_(posModel),
+ negKinematics_(negModel ? negModel->getKinematics() : 0),
+ posKinematics_(posModel ? posModel->getKinematics() : 0),
+ D_(D),
+ usingBkgnd_(kFALSE),
+ nSigComp_(0),
+ nSigDPPar_(0),
+ nExtraPdfPar_(0),
+ nNormPar_(0),
+ interTermReNorm_(0.0),
+ normDP_(0.0),
+ negMeanEff_("negMeanEff",0.0,0.0,1.0), posMeanEff_("posMeanEff",0.0,0.0,1.0),
+ negDPRate_("negDPRate",0.0,0.0,100.0), posDPRate_("posDPRate",0.0,0.0,100.0),
+ signalEvents_(0),
+ useSCF_(kFALSE),
+ useSCFHist_(kFALSE),
+ scfFrac_("scfFrac",0.0,0.0,1.0),
+ scfFracHist_(0),
+ scfMap_(0),
+ compareFitData_(kFALSE),
+ negParent_("B_s0_bar"), posParent_("B_s0"),
+ iterationsMax_(100000),
+ nGenLoop_(0),
+ ASq_(0.0),
+ aSqMaxVar_(0.0),
+ aSqMaxSet_(1.25),
+ sigDPLike_(0.0),
+ scfDPLike_(0.0),
+ sigExtraLike_(0.0),
+ scfExtraLike_(0.0),
+ sigTotalLike_(0.0),
+ scfTotalLike_(0.0)
+{
+ LauDaughters* negDaug = negSigModel_->getDaughters();
+ if (negDaug != 0) {negParent_ = negDaug->getNameParent();}
+ LauDaughters* posDaug = posSigModel_->getDaughters();
+ if (posDaug != 0) {posParent_ = posDaug->getNameParent();}
+}
+
+LauBsCPFitModel::~LauBsCPFitModel()
+{
+ delete scfFracHist_;
+}
+
+void LauBsCPFitModel::setupBkgndVectors()
+{
+ UInt_t nBkgnds = this->nBkgndClasses();
+ bkgndDPModels_.resize( nBkgnds );
+ bkgndPdfs_.resize( nBkgnds );
+ bkgndEvents_.resize( nBkgnds );
+ bkgndDPLike_.resize( nBkgnds );
+ bkgndExtraLike_.resize( nBkgnds );
+ bkgndTotalLike_.resize( nBkgnds );
+}
+
+void LauBsCPFitModel::setNSigEvents(LauParameter* nSigEvents)
+{
+ if ( nSigEvents == 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setNSigEvents : The LauParameter pointer is null." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ if ( signalEvents_ != 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setNSigEvents : You are trying to overwrite the signal yield." << std::endl;
+ return;
+ }
+
+ signalEvents_ = nSigEvents;
+ TString name = signalEvents_->name();
+ if ( ! name.Contains("signalEvents") && !( name.BeginsWith("signal") && name.EndsWith("Events") ) ) {
+ signalEvents_->name("signalEvents");
+ }
+ Double_t value = nSigEvents->value();
+ signalEvents_->range(-2.0*(TMath::Abs(value)+1.0), 2.0*(TMath::Abs(value)+1.0));
+}
+
+void LauBsCPFitModel::setNBkgndEvents( LauParameter* nBkgndEvents )
+{
+ if ( nBkgndEvents == 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setNBgkndEvents : The background yield LauParameter pointer is null." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+
+ if ( ! this->validBkgndClass( nBkgndEvents->name() ) ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setNBkgndEvents : Invalid background class \"" << nBkgndEvents->name() << "\"." << std::endl;
+ std::cerr << " : Background class names must be provided in \"setBkgndClassNames\" before any other background-related actions can be performed." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+
+ UInt_t bkgndID = this->bkgndClassID( nBkgndEvents->name() );
+
+ if ( bkgndEvents_[bkgndID] != 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setNBkgndEvents : You are trying to overwrite the background yield." << std::endl;
+ return;
+ }
+
+ bkgndEvents_[bkgndID] = nBkgndEvents;
+ bkgndEvents_[bkgndID]->name( nBkgndEvents->name()+"Events" );
+ Double_t value = nBkgndEvents->value();
+ bkgndEvents_[bkgndID]->range(-2.0*(TMath::Abs(value)+1.0), 2.0*(TMath::Abs(value)+1.0));
+
+}
+
+void LauBsCPFitModel::splitSignalComponent( const TH2* dpHisto, const Bool_t upperHalf, const Bool_t fluctuateBins, LauScfMap* scfMap )
+{
+ if ( useSCF_ == kTRUE ) {
+ std::cerr << "ERROR in LauBsCPFitModel::splitSignalComponent : Have already setup SCF." << std::endl;
+ return;
+ }
+
+ if ( dpHisto == 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::splitSignalComponent : The histogram pointer is null." << std::endl;
+ return;
+ }
+
+ LauDaughters* daughters = negSigModel_->getDaughters();
+ scfFracHist_ = new LauEffModel( daughters, 0 );
+ scfFracHist_->setEffHisto( dpHisto, kTRUE, fluctuateBins, 0.0, 0.0, upperHalf, daughters->squareDP() );
+
+ scfMap_ = scfMap;
+
+ useSCF_ = kTRUE;
+ useSCFHist_ = kTRUE;
+}
+
+void LauBsCPFitModel::splitSignalComponent( const Double_t scfFrac, const Bool_t fixed )
+{
+ if ( useSCF_ == kTRUE ) {
+ std::cerr << "ERROR in LauBsCPFitModel::splitSignalComponent : Have already setup SCF." << std::endl;
+ return;
+ }
+
+ scfFrac_.range( 0.0, 1.0 );
+ scfFrac_.value( scfFrac ); scfFrac_.initValue( scfFrac ); scfFrac_.genValue( scfFrac );
+ scfFrac_.fixed( fixed );
+
+ useSCF_ = kTRUE;
+ useSCFHist_ = kFALSE;
+}
+
+void LauBsCPFitModel::setBkgndDPModel(const TString& bkgndClass, LauAbsBkgndDPModel* model)
+{
+ if (model==0){
+ std::cerr << "ERROR in LauBsCPFitModel::setBkgndDPModels : the model pointer is null." << std::endl;
+ return;
+ }
+
+ // check that this background name is valid
+ if ( ! this->validBkgndClass( bkgndClass) ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setBkgndDPModel : Invalid background class \"" << bkgndClass << "\"." << std::endl;
+ std::cerr << " : Background class names must be provided in \"setBkgndClassNames\" before any other background-related actions can be performed." << std::endl;
+ return;
+ }
+
+ UInt_t bkgndID = this->bkgndClassID( bkgndClass );
+ bkgndDPModels_[bkgndID] = model;
+
+ usingBkgnd_ = kTRUE;
+}
+
+void LauBsCPFitModel::setSignalPdf(LauAbsPdf* pdf)
+{
+ // if we're doing an untagged analysis we will only use the negative PDFs
+ if ( pdf==0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setSignalPdfs : The PDF pointer is null." << std::endl;
+ return;
+ }
+ signalPdfs_.push_back(pdf);
+}
+
+void LauBsCPFitModel::setSCFPdf(LauAbsPdf* pdf)
+{
+ // if we're doing an untagged analysis we will only use the negative PDFs
+ if ( pdf==0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setSCFPdfs : The PDF pointer is null." << std::endl;
+ return;
+ }
+ scfPdfs_.push_back(pdf);
+}
+
+void LauBsCPFitModel::setBkgndPdf(const TString& bkgndClass, LauAbsPdf* pdf)
+{
+ // if we're doing an untagged analysis we will only use the negative PDFs
+ if ( pdf==0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setBkgndPdfs : The PDF pointer is null." << std::endl;
+ return;
+ }
+
+ // check that this background name is valid
+ if ( ! this->validBkgndClass( bkgndClass ) ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setBkgndPdfs : Invalid background class \"" << bkgndClass << "\"." << std::endl;
+ std::cerr << " : Background class names must be provided in \"setBkgndClassNames\" before any other background-related actions can be performed." << std::endl;
+ return;
+ }
+
+ UInt_t bkgndID = this->bkgndClassID( bkgndClass );
+ bkgndPdfs_[bkgndID].push_back(pdf);
+
+ usingBkgnd_ = kTRUE;
+}
+
+void LauBsCPFitModel::setAmpCoeffSet(LauAbsCoeffSet* coeffSet)
+{
+ // Is there a component called compName in the signal model?
+ TString compName(coeffSet->name());
+ Bool_t negOK = negSigModel_->hasResonance(compName);
+ Bool_t posOK = posSigModel_->hasResonance(compName);
+ if (!negOK) {
+ std::cerr << "ERROR in LauBsCPFitModel::setMagPhase : " << negParent_ << " signal DP model doesn't contain component \"" << compName << "\"." << std::endl;
+ return;
+ }
+ if (!posOK) {
+ std::cerr << "ERROR in LauBsCPFitModel::setMagPhase : " << posParent_ << " signal DP model doesn't contain component \"" << compName << "\"." << std::endl;
+ return;
+ }
+
+ // Do we already have it in our list of names?
+ for (std::vector<LauAbsCoeffSet*>::const_iterator iter=coeffPars_.begin(); iter!=coeffPars_.end(); ++iter) {
+ if ((*iter)->name() == compName) {
+ std::cerr << "ERROR in LauBsCPFitModel::setAmpCoeffSet : Have already set coefficients for \"" << compName << "\"." << std::endl;
+ return;
+ }
+ }
+
+ coeffSet->index(nSigComp_);
+ coeffPars_.push_back(coeffSet);
+
+ TString parName = coeffSet->baseName(); parName += "FitFracAsym";
+ fitFracAsymm_.push_back(LauParameter(parName, 0.0, -1.0, 1.0));
+
+ acp_.push_back(coeffSet->acp());
+
+ ++nSigComp_;
+
+ std::cout << "INFO in LauBsCPFitModel::setAmpCoeffSet : Added coefficients for component \"" << compName << "\" to the fit model." << std::endl;
+ coeffSet->printParValues();
+}
+
+void LauBsCPFitModel::initialise()
+{
+ // From the initial parameter values calculate the coefficients
+ // so they can be passed to the signal model
+ this->updateCoeffs();
+
+ // Initialisation
+ if (this->useDP() == kTRUE) {
+ this->initialiseDPModels();
+ }
+
+ if (!this->useDP() && signalPdfs_.empty()) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialise : Signal model doesn't exist for any variable." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+
+ if ( this->useDP() ) {
+ // Check that we have all the Dalitz-plot models
+ if ((negSigModel_ == 0) || (posSigModel_ == 0)) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialise : the pointer to one (neg or pos) of the signal DP models is null.\n";
+ std::cerr << " : Removing the Dalitz Plot from the model." << std::endl;
+ this->useDP(kFALSE);
+ }
+ if ( usingBkgnd_ ) {
+ if ( bkgndDPModels_.empty() ) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialise : No background DP models found.\n";
+ std::cerr << " : Removing the Dalitz plot from the model." << std::endl;
+ this->useDP(kFALSE);
+ }
+ for (LauBkgndDPModelList::const_iterator dpmodel_iter = bkgndDPModels_.begin(); dpmodel_iter != bkgndDPModels_.end(); ++dpmodel_iter ) {
+ if ( (*dpmodel_iter) == 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialise : The pointer to one of the background DP models is null.\n";
+ std::cerr << " : Removing the Dalitz Plot from the model." << std::endl;
+ this->useDP(kFALSE);
+ break;
+ }
+ }
+ }
+ }
+
+ // Next check that, if a given component is being used we've got the
+ // right number of PDFs for all the variables involved
+ // TODO - should probably check variable names and so on as well
+
+ UInt_t nsigpdfvars(0);
+ for ( LauPdfList::const_iterator pdf_iter = signalPdfs_.begin(); pdf_iter != signalPdfs_.end(); ++pdf_iter ) {
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nsigpdfvars;
+ }
+ }
+ }
+ if (useSCF_) {
+ UInt_t nscfpdfvars(0);
+ for ( LauPdfList::const_iterator pdf_iter = scfPdfs_.begin(); pdf_iter != scfPdfs_.end(); ++pdf_iter ) {
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nscfpdfvars;
+ }
+ }
+ }
+ if (nscfpdfvars != nsigpdfvars) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialise : There are " << nsigpdfvars << " TM signal PDF variables but " << nscfpdfvars << " SCF signal PDF variables." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+ if (usingBkgnd_) {
+ for (LauBkgndPdfsList::const_iterator bgclass_iter = bkgndPdfs_.begin(); bgclass_iter != bkgndPdfs_.end(); ++bgclass_iter) {
+ UInt_t nbkgndpdfvars(0);
+ const LauPdfList& pdfList = (*bgclass_iter);
+ for ( LauPdfList::const_iterator pdf_iter = pdfList.begin(); pdf_iter != pdfList.end(); ++pdf_iter ) {
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nbkgndpdfvars;
+ }
+ }
+ }
+ if (nbkgndpdfvars != nsigpdfvars) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialise : There are " << nsigpdfvars << " signal PDF variables but " << nbkgndpdfvars << " bkgnd PDF variables." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+ }
+
+ // Clear the vectors of parameter information so we can start from scratch
+ this->clearFitParVectors();
+
+ // Set the fit parameters for signal and background models
+ this->setSignalDPParameters();
+
+ // Set the fit parameters for the various extra PDFs
+ this->setExtraPdfParameters();
+
+ // Set the initial bg and signal events
+ this->setFitNEvents();
+
+ // Check that we have the expected number of fit variables
+ const LauParameterPList& fitVars = this->fitPars();
+ if (fitVars.size() != (nSigDPPar_ + nExtraPdfPar_ + nNormPar_)) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialise : Number of fit parameters not of expected size. Exiting" << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+
+ this->setExtraNtupleVars();
+}
+
+void LauBsCPFitModel::recalculateNormalisation()
+{
+ //std::cout << "INFO in LauBsCPFitModel::recalculateNormalizationInDPModels : Recalc Norm in DP model" << std::endl;
+ negSigModel_->recalculateNormalisation();
+ posSigModel_->recalculateNormalisation();
+ negSigModel_->modifyDataTree();
+ posSigModel_->modifyDataTree();
+ this->calcInterferenceTermIntegrals();
+}
+
+void LauBsCPFitModel::initialiseDPModels()
+{
+ // Need to check that the number of components we have and that the dynamics has matches up
+ UInt_t nNegAmp = negSigModel_->getnTotAmp();
+ UInt_t nPosAmp = posSigModel_->getnTotAmp();
+ if ( nNegAmp != nPosAmp ) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialiseDPModels : Unequal number of signal DP components in the negative and positive models: " << nNegAmp << " != " << nPosAmp << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ if ( nNegAmp != nSigComp_ ) {
+ std::cerr << "ERROR in LauBsCPFitModel::initialiseDPModels : Number of signal DP components in the model (" << nNegAmp << ") not equal to number of coefficients supplied (" << nSigComp_ << ")." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+
+
+ std::cout << "INFO in LauBsCPFitModel::initialiseDPModels : Initialising signal DP model" << std::endl;
+ negSigModel_->initialise(negCoeffs_);
+ posSigModel_->initialise(posCoeffs_);
+
+ if (usingBkgnd_ == kTRUE) {
+ for (LauBkgndDPModelList::iterator iter = bkgndDPModels_.begin(); iter != bkgndDPModels_.end(); ++iter) {
+ (*iter)->initialise();
+ }
+ }
+
+ fifjEffSum_.clear();
+ fifjEffSum_.resize(nSigComp_);
+ for (UInt_t iAmp = 0; iAmp < nSigComp_; ++iAmp) {
+ fifjEffSum_[iAmp].resize(nSigComp_);
+ }
+
+ // calculate the integrals of the A*Abar terms
+ this->calcInterferenceTermIntegrals();
+ this->calcInterTermNorm();
+}
+
+void LauBsCPFitModel::calcInterferenceTermIntegrals()
+{
+ const std::vector<LauDPPartialIntegralInfo*>& integralInfoListB0bar = negSigModel_->getIntegralInfos();
+ const std::vector<LauDPPartialIntegralInfo*>& integralInfoListB0 = posSigModel_->getIntegralInfos();
+
+ LauComplex A, Abar, fifjEffSumTerm;
+
+ for (UInt_t iAmp = 0; iAmp < nSigComp_; ++iAmp) {
+ for (UInt_t jAmp = 0; jAmp < nSigComp_; ++jAmp) {
+ fifjEffSum_[iAmp][jAmp].zero();
+ }
+ }
+
+ const UInt_t nIntegralRegions = integralInfoListB0bar.size();
+ for ( UInt_t iRegion(0); iRegion < nIntegralRegions; ++iRegion ) {
+
+ const LauDPPartialIntegralInfo* integralInfoB0bar = integralInfoListB0bar[iRegion];
+ const LauDPPartialIntegralInfo* integralInfoB0 = integralInfoListB0[iRegion];
+
+ const UInt_t nm13Points = integralInfoB0bar->getnm13Points();
+ const UInt_t nm23Points = integralInfoB0bar->getnm23Points();
+
+ for (UInt_t m13 = 0; m13 < nm13Points; ++m13) {
+ for (UInt_t m23 = 0; m23 < nm23Points; ++m23) {
+
+ const Double_t weight = integralInfoB0bar->getWeight(m13,m23);
+ const Double_t eff = integralInfoB0bar->getEfficiency(m13,m23);
+ const Double_t effWeight = eff*weight;
+
+ for (UInt_t iAmp = 0; iAmp < nSigComp_; ++iAmp) {
+
+ A = integralInfoB0->getAmplitude(m13, m23, iAmp);
+ for (UInt_t jAmp = 0; jAmp < nSigComp_; ++jAmp) {
+
+ Abar = integralInfoB0bar->getAmplitude(m13, m23, jAmp);
+ fifjEffSumTerm = Abar*A.conj();
+ fifjEffSumTerm.rescale(effWeight);
+ fifjEffSum_[iAmp][jAmp] += fifjEffSumTerm;
+ }
+ }
+ }
+ }
+ }
+}
+
+void LauBsCPFitModel::setSignalDPParameters()
+{
+ // Set the fit parameters for the signal model.
+
+ nSigDPPar_ = 0;
+ if ( ! this->useDP() ) {
+ return;
+ }
+
+ std::cout << "INFO in LauBsCPFitModel::setSignalDPParameters : Setting the initial fit parameters for the signal DP model." << std::endl;
+
+ // Place isobar coefficient parameters in vector of fit variables
+ LauParameterPList& fitVars = this->fitPars();
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ LauParameterPList pars = coeffPars_[i]->getParameters();
+ for (LauParameterPList::iterator iter = pars.begin(); iter != pars.end(); ++iter) {
+ if ( !(*iter)->clone() ) {
+ fitVars.push_back(*iter);
+ ++nSigDPPar_;
+ }
+ }
+ }
+
+ // Obtain the resonance parameters and place them in the vector of fit variables and in a separate vector
+ // Need to make sure that they are unique because some might appear in both DP models
+ LauParameterPSet& resVars = this->resPars();
+ resVars.clear();
+
+ LauParameterPList& negSigDPPars = negSigModel_->getFloatingParameters();
+ LauParameterPList& posSigDPPars = posSigModel_->getFloatingParameters();
+
+ for ( LauParameterPList::iterator iter = negSigDPPars.begin(); iter != negSigDPPars.end(); ++iter ) {
+ if ( resVars.insert(*iter).second ) {
+ fitVars.push_back(*iter);
+ ++nSigDPPar_;
+ }
+ }
+ for ( LauParameterPList::iterator iter = posSigDPPars.begin(); iter != posSigDPPars.end(); ++iter ) {
+ if ( resVars.insert(*iter).second ) {
+ fitVars.push_back(*iter);
+ ++nSigDPPar_;
+ }
+ }
+}
+
+void LauBsCPFitModel::setExtraPdfParameters()
+{
+ // Include all the parameters of the PDF in the fit
+ // NB all of them are passed to the fit, even though some have been fixed through parameter.fixed(kTRUE)
+ // With the new "cloned parameter" scheme only "original" parameters are passed to the fit.
+ // Their clones are updated automatically when the originals are updated.
+
+ nExtraPdfPar_ = 0;
+
+ nExtraPdfPar_ += this->addFitParameters(signalPdfs_);
+
+ if (useSCF_ == kTRUE) {
+ nExtraPdfPar_ += this->addFitParameters(scfPdfs_);
+ }
+
+ if (usingBkgnd_ == kTRUE) {
+ for (LauBkgndPdfsList::iterator iter = bkgndPdfs_.begin(); iter != bkgndPdfs_.end(); ++iter) {
+ nExtraPdfPar_ += this->addFitParameters(*iter);
+ }
+ }
+}
+
+void LauBsCPFitModel::setFitNEvents()
+{
+ if ( signalEvents_ == 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setFitNEvents : Signal yield not defined." << std::endl;
+ return;
+ }
+ nNormPar_ = 0;
+
+ // initialise the total number of events to be the sum of all the hypotheses
+ Double_t nTotEvts = signalEvents_->value();
+ for (LauBkgndYieldList::const_iterator iter = bkgndEvents_.begin(); iter != bkgndEvents_.end(); ++iter) {
+ nTotEvts += (*iter)->value();
+ if ( (*iter) == 0 ) {
+ std::cerr << "ERROR in LauBsCPFitModel::setFitNEvents : Background yield not defined." << std::endl;
+ return;
+ }
+ }
+ this->eventsPerExpt(TMath::FloorNint(nTotEvts));
+
+ LauParameterPList& fitVars = this->fitPars();
+
+ // if doing an extended ML fit add the number of signal events into the fit parameters
+ if (this->doEMLFit()) {
+ std::cout << "INFO in LauBsCPFitModel::setFitNEvents : Initialising number of events for signal and background components..." << std::endl;
+ // add the signal fraction to the list of fit parameters
+ fitVars.push_back(signalEvents_);
+ ++nNormPar_;
+ } else {
+ std::cout << "INFO in LauBsCPFitModel::setFitNEvents : Initialising number of events for background components (and hence signal)..." << std::endl;
+ }
+
+ if (useSCF_ && !useSCFHist_) {
+ fitVars.push_back(&scfFrac_);
+ ++nNormPar_;
+ }
+
+ if (usingBkgnd_ == kTRUE) {
+ for (LauBkgndYieldList::iterator iter = bkgndEvents_.begin(); iter != bkgndEvents_.end(); ++iter) {
+ LauParameter* parameter = (*iter);
+ fitVars.push_back(parameter);
+ ++nNormPar_;
+ }
+ }
+}
+
+void LauBsCPFitModel::setExtraNtupleVars()
+{
+ // Set-up other parameters derived from the fit results, e.g. fit fractions.
+
+ if (this->useDP() != kTRUE) {
+ return;
+ }
+
+ // First clear the vectors so we start from scratch
+ this->clearExtraVarVectors();
+
+ LauParameterList& extraVars = this->extraPars();
+
+ // Add the positive and negative fit fractions for each signal component
+ negFitFrac_ = negSigModel_->getFitFractions();
+ if (negFitFrac_.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << negFitFrac_.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (negFitFrac_[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << negFitFrac_[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ posFitFrac_ = posSigModel_->getFitFractions();
+ if (posFitFrac_.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << posFitFrac_.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (posFitFrac_[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << posFitFrac_[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ // Add the positive and negative fit fractions that have not been corrected for the efficiency for each signal component
+ negFitFracEffUnCorr_ = negSigModel_->getFitFractionsEfficiencyUncorrected();
+ if (negFitFracEffUnCorr_.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << negFitFracEffUnCorr_.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (negFitFracEffUnCorr_[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << negFitFracEffUnCorr_[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ posFitFracEffUnCorr_ = posSigModel_->getFitFractionsEfficiencyUncorrected();
+ if (posFitFracEffUnCorr_.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << posFitFracEffUnCorr_.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (posFitFracEffUnCorr_[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::setExtraNtupleVars : Initial Fit Fraction array of unexpected dimension: " << posFitFracEffUnCorr_[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+ TString name = negFitFrac_[i][j].name();
+ name.Insert( name.Index("FitFrac"), "Neg" );
+ negFitFrac_[i][j].name(name);
+ extraVars.push_back(negFitFrac_[i][j]);
+
+ name = posFitFrac_[i][j].name();
+ name.Insert( name.Index("FitFrac"), "Pos" );
+ posFitFrac_[i][j].name(name);
+ extraVars.push_back(posFitFrac_[i][j]);
+
+ name = negFitFracEffUnCorr_[i][j].name();
+ name.Insert( name.Index("FitFrac"), "Neg" );
+ negFitFracEffUnCorr_[i][j].name(name);
+ extraVars.push_back(negFitFracEffUnCorr_[i][j]);
+
+ name = posFitFracEffUnCorr_[i][j].name();
+ name.Insert( name.Index("FitFrac"), "Pos" );
+ posFitFracEffUnCorr_[i][j].name(name);
+ extraVars.push_back(posFitFracEffUnCorr_[i][j]);
+ }
+ }
+
+ // Store any extra parameters/quantities from the DP model (e.g. K-matrix total fit fractions)
+ std::vector<LauParameter> negExtraPars = negSigModel_->getExtraParameters();
+ std::vector<LauParameter>::iterator negExtraIter;
+ for (negExtraIter = negExtraPars.begin(); negExtraIter != negExtraPars.end(); ++negExtraIter) {
+ LauParameter negExtraParameter = (*negExtraIter);
+ extraVars.push_back(negExtraParameter);
+ }
+
+ std::vector<LauParameter> posExtraPars = posSigModel_->getExtraParameters();
+ std::vector<LauParameter>::iterator posExtraIter;
+ for (posExtraIter = posExtraPars.begin(); posExtraIter != posExtraPars.end(); ++posExtraIter) {
+ LauParameter posExtraParameter = (*posExtraIter);
+ extraVars.push_back(posExtraParameter);
+ }
+
+ // Now add in the DP efficiency value
+ Double_t initMeanEff = negSigModel_->getMeanEff().initValue();
+ negMeanEff_.value(initMeanEff);
+ negMeanEff_.genValue(initMeanEff);
+ negMeanEff_.initValue(initMeanEff);
+ extraVars.push_back(negMeanEff_);
+
+ initMeanEff = posSigModel_->getMeanEff().initValue();
+ posMeanEff_.value(initMeanEff);
+ posMeanEff_.genValue(initMeanEff);
+ posMeanEff_.initValue(initMeanEff);
+ extraVars.push_back(posMeanEff_);
+
+ // Also add in the DP rates
+ Double_t initDPRate = negSigModel_->getDPRate().initValue();
+ negDPRate_.value(initDPRate);
+ negDPRate_.genValue(initDPRate);
+ negDPRate_.initValue(initDPRate);
+ extraVars.push_back(negDPRate_);
+
+ initDPRate = posSigModel_->getDPRate().initValue();
+ posDPRate_.value(initDPRate);
+ posDPRate_.genValue(initDPRate);
+ posDPRate_.initValue(initDPRate);
+ extraVars.push_back(posDPRate_);
+
+ // Calculate the CPC and CPV Fit Fractions, ACPs and FitFrac asymmetries
+ this->calcExtraFractions(kTRUE);
+ this->calcAsymmetries(kTRUE);
+
+ // Add the CP violating and CP conserving fit fractions for each signal component
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ for (UInt_t j = i; j < nSigComp_; j++) {
+ extraVars.push_back(CPVFitFrac_[i][j]);
+ }
+ }
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ for (UInt_t j = i; j < nSigComp_; j++) {
+ extraVars.push_back(CPCFitFrac_[i][j]);
+ }
+ }
+
+ // Add the Fit Fraction asymmetry for each signal component
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ extraVars.push_back(fitFracAsymm_[i]);
+ }
+
+ // Add the calculated CP asymmetry for each signal component
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ extraVars.push_back(acp_[i]);
+ }
+}
+
+void LauBsCPFitModel::calcExtraFractions(Bool_t initValues)
+{
+ // Calculate the CP-conserving and CP-violating fit fractions
+
+ if (initValues) {
+ // create the structure
+ CPCFitFrac_.clear();
+ CPVFitFrac_.clear();
+ CPCFitFrac_.resize(nSigComp_);
+ CPVFitFrac_.resize(nSigComp_);
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ CPCFitFrac_[i].resize(nSigComp_);
+ CPVFitFrac_[i].resize(nSigComp_);
+
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+ TString name = negFitFrac_[i][j].name();
+ name.Replace( name.Index("Neg"), 3, "CPC" );
+ CPCFitFrac_[i][j].name( name );
+ CPCFitFrac_[i][j].valueAndRange( 0.0, -100.0, 100.0 );
+
+ name = negFitFrac_[i][j].name();
+ name.Replace( name.Index("Neg"), 3, "CPV" );
+ CPVFitFrac_[i][j].name( name );
+ CPVFitFrac_[i][j].valueAndRange( 0.0, -100.0, 100.0 );
+ }
+ }
+ }
+
+ Double_t denom = negDPRate_ + posDPRate_;
+
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+
+ Double_t negTerm = negFitFrac_[i][j]*negDPRate_;
+ Double_t posTerm = posFitFrac_[i][j]*posDPRate_;
+
+ Double_t cpcFitFrac = (negTerm + posTerm)/denom;
+ Double_t cpvFitFrac = (negTerm - posTerm)/denom;
+
+ CPCFitFrac_[i][j] = cpcFitFrac;
+ CPVFitFrac_[i][j] = cpvFitFrac;
+
+ if (initValues) {
+ CPCFitFrac_[i][j].genValue(cpcFitFrac);
+ CPCFitFrac_[i][j].initValue(cpcFitFrac);
+
+ CPVFitFrac_[i][j].genValue(cpvFitFrac);
+ CPVFitFrac_[i][j].initValue(cpvFitFrac);
+ }
+ }
+ }
+}
+
+void LauBsCPFitModel::calcAsymmetries(Bool_t initValues)
+{
+ // Calculate the CP asymmetries
+ // Also calculate the fit fraction asymmetries
+
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+
+ acp_[i] = coeffPars_[i]->acp();
+
+ LauAsymmCalc asymmCalc(negFitFrac_[i][i].value(), posFitFrac_[i][i].value());
+ Double_t asym = asymmCalc.getAsymmetry();
+ fitFracAsymm_[i] = asym;
+ if (initValues) {
+ fitFracAsymm_[i].genValue(asym);
+ fitFracAsymm_[i].initValue(asym);
+ }
+ }
+}
+
+void LauBsCPFitModel::finaliseFitResults(const TString& tablePrefixName)
+{
+ // Retrieve parameters from the fit results for calculations and toy generation
+ // and eventually store these in output root ntuples/text files
+
+ // Now take the fit parameters and update them as necessary
+ // i.e. to make mag > 0.0, phase in the right range.
+ // This function will also calculate any other values, such as the
+ // fit fractions, using any errors provided by fitParErrors as appropriate.
+ // Also obtain the pull values: (measured - generated)/(average error)
+
+ if (this->useDP() == kTRUE) {
+ for (UInt_t i = 0; i < nSigComp_; ++i) {
+ // Check whether we have "a/b > 0.0", and phases in the right range
+ coeffPars_[i]->finaliseValues();
+ }
+ }
+
+ // update the pulls on the event fractions and asymmetries
+ if (this->doEMLFit()) {
+ signalEvents_->updatePull();
+ }
+ if (useSCF_ && !useSCFHist_) {
+ scfFrac_.updatePull();
+ }
+ if (usingBkgnd_ == kTRUE) {
+ for (LauBkgndYieldList::iterator iter = bkgndEvents_.begin(); iter != bkgndEvents_.end(); ++iter) {
+ (*iter)->updatePull();
+ }
+ }
+
+ // Update the pulls on all the extra PDFs' parameters
+ this->updateFitParameters(signalPdfs_);
+ if (useSCF_ == kTRUE) {
+ this->updateFitParameters(scfPdfs_);
+ }
+ if (usingBkgnd_ == kTRUE) {
+ for (LauBkgndPdfsList::iterator iter = bkgndPdfs_.begin(); iter != bkgndPdfs_.end(); ++iter) {
+ this->updateFitParameters(*iter);
+ }
+ }
+
+ // Fill the fit results to the ntuple
+
+ // update the coefficients and then calculate the fit fractions and ACP's
+ if (this->useDP() == kTRUE) {
+ this->updateCoeffs();
+ negSigModel_->updateCoeffs(negCoeffs_); negSigModel_->calcExtraInfo();
+ posSigModel_->updateCoeffs(posCoeffs_); posSigModel_->calcExtraInfo();
+
+ LauParArray negFitFrac = negSigModel_->getFitFractions();
+ if (negFitFrac.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << negFitFrac.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (negFitFrac[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << negFitFrac[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ LauParArray posFitFrac = posSigModel_->getFitFractions();
+ if (posFitFrac.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << posFitFrac.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (posFitFrac[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << posFitFrac[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ LauParArray negFitFracEffUnCorr = negSigModel_->getFitFractionsEfficiencyUncorrected();
+ if (negFitFracEffUnCorr.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << negFitFracEffUnCorr.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (negFitFracEffUnCorr[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << negFitFracEffUnCorr[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ LauParArray posFitFracEffUnCorr = posSigModel_->getFitFractionsEfficiencyUncorrected();
+ if (posFitFracEffUnCorr.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << posFitFracEffUnCorr.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (posFitFracEffUnCorr[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::finaliseFitResults : Fit Fraction array of unexpected dimension: " << posFitFracEffUnCorr[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+ negFitFrac_[i][j].value(negFitFrac[i][j].value());
+ posFitFrac_[i][j].value(posFitFrac[i][j].value());
+ negFitFracEffUnCorr_[i][j].value(negFitFracEffUnCorr[i][j].value());
+ posFitFracEffUnCorr_[i][j].value(posFitFracEffUnCorr[i][j].value());
+ }
+ }
+
+ negMeanEff_.value(negSigModel_->getMeanEff().value());
+ posMeanEff_.value(posSigModel_->getMeanEff().value());
+ negDPRate_.value(negSigModel_->getDPRate().value());
+ posDPRate_.value(posSigModel_->getDPRate().value());
+
+ this->calcExtraFractions();
+ this->calcAsymmetries();
+
+ // Then store the final fit parameters, and any extra parameters for
+ // the signal model (e.g. fit fractions, FF asymmetries, ACPs, mean efficiency and DP rate)
+
+ this->clearExtraVarVectors();
+ LauParameterList& extraVars = this->extraPars();
+
+ // Add the positive and negative fit fractions for each signal component
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+ extraVars.push_back(negFitFrac_[i][j]);
+ extraVars.push_back(posFitFrac_[i][j]);
+ extraVars.push_back(negFitFracEffUnCorr_[i][j]);
+ extraVars.push_back(posFitFracEffUnCorr_[i][j]);
+ }
+ }
+
+ // Store any extra parameters/quantities from the DP model (e.g. K-matrix total fit fractions)
+ std::vector<LauParameter> negExtraPars = negSigModel_->getExtraParameters();
+ std::vector<LauParameter>::iterator negExtraIter;
+ for (negExtraIter = negExtraPars.begin(); negExtraIter != negExtraPars.end(); ++negExtraIter) {
+ LauParameter negExtraParameter = (*negExtraIter);
+ extraVars.push_back(negExtraParameter);
+ }
+
+ std::vector<LauParameter> posExtraPars = posSigModel_->getExtraParameters();
+ std::vector<LauParameter>::iterator posExtraIter;
+ for (posExtraIter = posExtraPars.begin(); posExtraIter != posExtraPars.end(); ++posExtraIter) {
+ LauParameter posExtraParameter = (*posExtraIter);
+ extraVars.push_back(posExtraParameter);
+ }
+
+ extraVars.push_back(negMeanEff_);
+ extraVars.push_back(posMeanEff_);
+ extraVars.push_back(negDPRate_);
+ extraVars.push_back(posDPRate_);
+
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+ extraVars.push_back(CPVFitFrac_[i][j]);
+ }
+ }
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+ extraVars.push_back(CPCFitFrac_[i][j]);
+ }
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ extraVars.push_back(fitFracAsymm_[i]);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ extraVars.push_back(acp_[i]);
+ }
+
+ this->printFitFractions(std::cout);
+ this->printAsymmetries(std::cout);
+ }
+
+ const LauParameterPList& fitVars = this->fitPars();
+ const LauParameterList& extraVars = this->extraPars();
+ LauFitNtuple* ntuple = this->fitNtuple();
+ ntuple->storeParsAndErrors(fitVars, extraVars);
+
+ // find out the correlation matrix for the parameters
+ ntuple->storeCorrMatrix(this->iExpt(), this->nll(), this->fitStatus(), this->covarianceMatrix());
+
+ // Fill the data into ntuple
+ ntuple->updateFitNtuple();
+
+ // Print out the partial fit fractions, phases and the
+ // averaged efficiency, reweighted by the dynamics (and anything else)
+ if (this->writeLatexTable()) {
+ TString sigOutFileName(tablePrefixName);
+ sigOutFileName += "_"; sigOutFileName += this->iExpt(); sigOutFileName += "Expt.tex";
+ this->writeOutTable(sigOutFileName);
+ }
+}
+
+void LauBsCPFitModel::printFitFractions(std::ostream& output)
+{
+ // Print out Fit Fractions, total DP rate and mean efficiency
+ // First for the B- events
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ const TString compName(coeffPars_[i]->name());
+ output << negParent_ << " FitFraction for component " << i << " (" << compName << ") = " << negFitFrac_[i][i] << std::endl;
+ }
+ output << negParent_ << " overall DP rate (integral of matrix element squared) = " << negDPRate_ << std::endl;
+ output << negParent_ << " average efficiency weighted by whole DP dynamics = " << negMeanEff_ << std::endl;
+
+ // Then for the positive sample
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ const TString compName(coeffPars_[i]->name());
+ //const TString conjName(negSigModel_->getConjResName(compName));
+ output << posParent_ << " FitFraction for component " << i << " (" << compName << ") = " << posFitFrac_[i][i] << std::endl;
+ }
+ output << posParent_ << " overall DP rate (integral of matrix element squared) = " << posDPRate_ << std::endl;
+ output << posParent_ << " average efficiency weighted by whole DP dynamics = " << posMeanEff_ << std::endl;
+}
+
+void LauBsCPFitModel::printAsymmetries(std::ostream& output)
+{
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ const TString compName(coeffPars_[i]->name());
+ output << "Fit Fraction asymmetry for component " << i << " (" << compName << ") = " << fitFracAsymm_[i] << std::endl;
+ }
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ const TString compName(coeffPars_[i]->name());
+ output << "ACP for component " << i << " (" << compName << ") = " << acp_[i] << std::endl;
+ }
+}
+
+void LauBsCPFitModel::writeOutTable(const TString& outputFile)
+{
+ // Write out the results of the fit to a tex-readable table
+ // TODO - need to include the yields in this table
+ std::ofstream fout(outputFile);
+ LauPrint print;
+
+ std::cout << "INFO in LauBsCPFitModel::writeOutTable : Writing out results of the fit to the tex file " << outputFile << std::endl;
+
+ if (this->useDP() == kTRUE) {
+ // print the fit coefficients in one table
+ coeffPars_.front()->printTableHeading(fout);
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ coeffPars_[i]->printTableRow(fout);
+ }
+ fout << "\\hline" << std::endl;
+ fout << "\\end{tabular}" << std::endl << std::endl;
+
+ // print the fit fractions and asymmetries in another
+ fout << "\\begin{tabular}{|l|c|c|c|c|}" << std::endl;
+ fout << "\\hline" << std::endl;
+ fout << "Component & " << negParent_ << " Fit Fraction & " << posParent_ << " Fit Fraction & Fit Fraction Asymmetry & ACP \\\\" << std::endl;
+ fout << "\\hline" << std::endl;
+
+ Double_t negFitFracSum(0.0);
+ Double_t posFitFracSum(0.0);
+
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ TString resName = coeffPars_[i]->name();
+ resName = resName.ReplaceAll("_", "\\_");
+
+ Double_t negFitFrac = negFitFrac_[i][i].value();
+ Double_t posFitFrac = posFitFrac_[i][i].value();
+ negFitFracSum += negFitFrac;
+ posFitFracSum += posFitFrac;
+
+ Double_t fitFracAsymm = fitFracAsymm_[i].value();
+
+ Double_t acp = acp_[i].value();
+ Double_t acpErr = acp_[i].error();
+
+ fout << resName << " & $";
+
+ print.printFormat(fout, negFitFrac);
+ fout << "$ & $";
+ print.printFormat(fout, posFitFrac);
+ fout << "$ & $";
+
+ print.printFormat(fout, fitFracAsymm);
+ fout << "$ & $";
+
+ print.printFormat(fout, acp);
+ fout << " \\pm ";
+ print.printFormat(fout, acpErr);
+ fout << "$ \\\\" << std::endl;
+ }
+ fout << "\\hline" << std::endl;
+
+ // Also print out sum of fit fractions
+ fout << "Fit Fraction Sum & $";
+ print.printFormat(fout, negFitFracSum);
+ fout << "$ & $";
+ print.printFormat(fout, posFitFracSum);
+ fout << "$ & & \\\\" << std::endl;
+ fout << "\\hline" << std::endl;
+
+ fout << "DP rate & $";
+ print.printFormat(fout, negDPRate_.value());
+ fout << "$ & $";
+ print.printFormat(fout, posDPRate_.value());
+ fout << "$ & & \\\\" << std::endl;
+
+ fout << "$< \\varepsilon > $ & $";
+ print.printFormat(fout, negMeanEff_.value());
+ fout << "$ & $";
+ print.printFormat(fout, posMeanEff_.value());
+ fout << "$ & & \\\\" << std::endl;
+ fout << "\\hline" << std::endl;
+ fout << "\\end{tabular}" << std::endl << std::endl;
+ }
+
+ if (!signalPdfs_.empty()) {
+ fout << "\\begin{tabular}{|l|c|}" << std::endl;
+ fout << "\\hline" << std::endl;
+ if (useSCF_ == kTRUE) {
+ fout << "\\Extra TM Signal PDFs' Parameters: & \\\\" << std::endl;
+ } else {
+ fout << "\\Extra Signal PDFs' Parameters: & \\\\" << std::endl;
+ }
+ this->printFitParameters(signalPdfs_, fout);
+ if (useSCF_ == kTRUE && !scfPdfs_.empty()) {
+ fout << "\\hline" << std::endl;
+ fout << "\\Extra SCF Signal PDFs' Parameters: & \\\\" << std::endl;
+ this->printFitParameters(scfPdfs_, fout);
+ }
+ if (usingBkgnd_ == kTRUE && !bkgndPdfs_.empty()) {
+ fout << "\\hline" << std::endl;
+ fout << "\\Extra Background PDFs' Parameters: & \\\\" << std::endl;
+ for (LauBkgndPdfsList::const_iterator iter = bkgndPdfs_.begin(); iter != bkgndPdfs_.end(); ++iter) {
+ this->printFitParameters(*iter, fout);
+ }
+ }
+ fout << "\\hline \n\\end{tabular}" << std::endl << std::endl;
+ }
+}
+
+void LauBsCPFitModel::checkInitFitParams()
+{
+ // Update the number of signal events to be total-sum(background events)
+ this->updateSigEvents();
+
+ // Check whether we want to have randomised initial fit parameters for the signal model
+ if (this->useRandomInitFitPars() == kTRUE) {
+ std::cout << "INFO in LauBsCPFitModel::checkInitFitParams : Setting random parameters for the signal model" << std::endl;
+ this->randomiseInitFitPars();
+ }
+}
+
+void LauBsCPFitModel::randomiseInitFitPars()
+{
+ // Only randomise those parameters that are not fixed!
+ std::cout << "INFO in LauBsCPFitModel::randomiseInitFitPars : Randomising the initial fit magnitudes and phases of the components..." << std::endl;
+
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ coeffPars_[i]->randomiseInitValues();
+ }
+}
+
+LauBsCPFitModel::LauGenInfo LauBsCPFitModel::eventsToGenerate()
+{
+ // Determine the number of events to generate for each hypothesis
+ // If we're smearing then smear each one individually
+
+ LauGenInfo nEvtsGen;
+
+ // Signal
+ Double_t evtWeight(1.0);
+ Double_t nEvts = signalEvents_->genValue();
+ if ( nEvts < 0.0 ) {
+ evtWeight = -1.0;
+ nEvts = TMath::Abs( nEvts );
+ }
+ Double_t asym(0.0);
+ Double_t sigAsym(0.0);
+ Double_t negRate = negSigModel_->getDPNorm();
+ Double_t posRate = posSigModel_->getDPNorm();
+ if (negRate+posRate>1e-30) {
+ sigAsym = (negRate-posRate)/(negRate+posRate);
+ }
+ asym = sigAsym;
+ Int_t nPosEvts = static_cast<Int_t>((nEvts/2.0 * (1.0 - asym)) + 0.5);
+ Int_t nNegEvts = static_cast<Int_t>((nEvts/2.0 * (1.0 + asym)) + 0.5);
+ if (this->doPoissonSmearing()) {
+ nNegEvts = LauRandom::randomFun()->Poisson(nNegEvts);
+ nPosEvts = LauRandom::randomFun()->Poisson(nPosEvts);
+ }
+ nEvtsGen[std::make_pair("signal",-1)] = std::make_pair(nNegEvts,evtWeight);
+ nEvtsGen[std::make_pair("signal",+1)] = std::make_pair(nPosEvts,evtWeight);
+
+ // backgrounds
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ const TString& bkgndClass = this->bkgndClassName(bkgndID);
+ const LauParameter* evtsPar = bkgndEvents_[bkgndID];
+ evtWeight = 1.0;
+ nEvts = TMath::FloorNint( evtsPar->genValue() );
+ if ( nEvts < 0 ) {
+ evtWeight = -1.0;
+ nEvts = TMath::Abs( nEvts );
+ }
+ Int_t nBkgEvts = nEvts;
+ if (this->doPoissonSmearing()) {
+ nBkgEvts = LauRandom::randomFun()->Poisson(nBkgEvts);
+
+ }
+ nEvtsGen[std::make_pair(bkgndClass,+1)] = std::make_pair(nBkgEvts,evtWeight);
+ }
+
+ std::cout << "INFO in LauBsCPFitModel::eventsToGenerate : Generating toy MC with:" << std::endl;
+ std::cout << " : Signal asymmetry = " << sigAsym << " and number of signal events = " << signalEvents_->genValue() << std::endl;
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ const TString& bkgndClass = this->bkgndClassName(bkgndID);
+ const LauParameter* evtsPar = bkgndEvents_[bkgndID];
+ std::cout << " : Number of " << bkgndClass << " events = " << evtsPar->genValue() << std::endl;
+ }
+
+ return nEvtsGen;
+}
+
+Bool_t LauBsCPFitModel::genExpt()
+{
+ // Routine to generate toy Monte Carlo events according to the various models we have defined.
+
+ // Determine the number of events to generate for each hypothesis
+ LauGenInfo nEvts = this->eventsToGenerate();
+
+ Bool_t genOK(kTRUE);
+ Int_t evtNum(0);
+
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ std::vector<TString> bkgndClassNames(nBkgnds);
+ std::vector<TString> bkgndClassNamesGen(nBkgnds);
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ TString name( this->bkgndClassName(iBkgnd) );
+ bkgndClassNames[iBkgnd] = name;
+ bkgndClassNamesGen[iBkgnd] = "gen"+name;
+ }
+
+ const Bool_t storeSCFTruthInfo = useSCF_;
+
+ // Loop over the hypotheses and generate the requested number of events for each one
+ for (LauGenInfo::const_iterator iter = nEvts.begin(); iter != nEvts.end(); ++iter) {
+
+ const TString& type(iter->first.first);
+ Double_t evtWeight( iter->second.second );
+ Int_t nEvtsGen( iter->second.first );
+
+ for (Int_t iEvt(0); iEvt<nEvtsGen; ++iEvt) {
+
+ this->setGenNtupleDoubleBranchValue( "evtWeight", evtWeight );
+ this->setGenNtupleDoubleBranchValue( "efficiency", 1.0 );
+
+ if (type == "signal") {
+ this->setGenNtupleIntegerBranchValue("genSig",1);
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ this->setGenNtupleIntegerBranchValue( bkgndClassNamesGen[iBkgnd], 0 );
+ }
+ genOK = this->generateSignalEvent();
+ this->setGenNtupleDoubleBranchValue( "efficiency", negSigModel_->getEvtEff() );
+
+ } else {
+ this->setGenNtupleIntegerBranchValue("genSig",0);
+ if ( storeSCFTruthInfo ) {
+ this->setGenNtupleIntegerBranchValue("genTMSig",0);
+ this->setGenNtupleIntegerBranchValue("genSCFSig",0);
+ }
+ UInt_t bkgndID(0);
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ Int_t gen(0);
+ if ( bkgndClassNames[iBkgnd] == type ) {
+ gen = 1;
+ bkgndID = iBkgnd;
+ }
+ this->setGenNtupleIntegerBranchValue( bkgndClassNamesGen[iBkgnd], gen );
+ }
+ genOK = this->generateBkgndEvent(bkgndID);
+ }
+ if (!genOK) {
+ // If there was a problem with the generation then break out and return.
+ // The problem model will have adjusted itself so that all should be OK next time.
+ break;
+ }
+ if (this->useDP() == kTRUE) {
+ this->setDPBranchValues();
+ }
+
+ // Store the event number (within this experiment)
+ // and then increment it
+ this->setGenNtupleIntegerBranchValue("iEvtWithinExpt",evtNum);
+ ++evtNum;
+
+ this->fillGenNtupleBranches();
+ if (iEvt%500 == 0) {std::cout << "INFO in LauBsCPFitModel::genExpt : Generated event number " << iEvt << " out of " << nEvtsGen << " " << type << " events." << std::endl;}
+ }
+
+ if (!genOK) {
+ break;
+ }
+ }
+
+ if (this->useDP() && genOK) {
+
+ negSigModel_->checkToyMC(kTRUE,kTRUE);
+ posSigModel_->checkToyMC(kTRUE,kTRUE);
+
+ // Get the fit fractions if they're to be written into the latex table
+ if (this->writeLatexTable()) {
+ LauParArray negFitFrac = negSigModel_->getFitFractions();
+ if (negFitFrac.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::genExpt : Fit Fraction array of unexpected dimension: " << negFitFrac.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (negFitFrac[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::genExpt : Fit Fraction array of unexpected dimension: " << negFitFrac[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+ LauParArray posFitFrac = posSigModel_->getFitFractions();
+ if (posFitFrac.size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::genExpt : Fit Fraction array of unexpected dimension: " << posFitFrac.size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ if (posFitFrac[i].size() != nSigComp_) {
+ std::cerr << "ERROR in LauBsCPFitModel::genExpt : Fit Fraction array of unexpected dimension: " << posFitFrac[i].size() << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ }
+
+ for (UInt_t i(0); i<nSigComp_; ++i) {
+ for (UInt_t j(i); j<nSigComp_; ++j) {
+ negFitFrac_[i][j].value(negFitFrac[i][j].value());
+ posFitFrac_[i][j].value(posFitFrac[i][j].value());
+ }
+ }
+ negMeanEff_.value(negSigModel_->getMeanEff().value());
+ posMeanEff_.value(posSigModel_->getMeanEff().value());
+ negDPRate_.value(negSigModel_->getDPRate().value());
+ posDPRate_.value(posSigModel_->getDPRate().value());
+ }
+ }
+
+ return genOK;
+}
+
+Bool_t LauBsCPFitModel::generateSignalEvent()
+{
+ // Generate signal event
+ Bool_t genOK(kTRUE);
+ Bool_t genSCF(kFALSE);
+ Bool_t generatedEvent(kFALSE);
+
+ //LauPdfList* sigPdfs(0);
+ //LauPdfList* scfPdfs(0);
+
+ if (this->useDP()) {
+
+ nGenLoop_ = 0;
+ while (generatedEvent == kFALSE && nGenLoop_ < iterationsMax_) {
+ // DP variables
+ Double_t m13Sq(0.0), m23Sq(0.0);
+
+ // Generate DP position
+ negKinematics_->genFlatPhaseSpace(m13Sq, m23Sq);
+ posKinematics_->updateKinematics(m13Sq, m23Sq);
+ // Calculate the total A and Abar for the given DP position
+ negSigModel_->calcLikelihoodInfo(m13Sq, m23Sq);
+ posSigModel_->calcLikelihoodInfo(m13Sq, m23Sq);
+
+ // Calculate DP terms
+ this->calculateDPterms();
+
+ //Finally we throw the dice to see whether this event should be generated
+ Double_t randNo = LauRandom::randomFun()->Rndm();
+ if (randNo <= ASq_/aSqMaxSet_ ) {
+ generatedEvent = kTRUE;
+ nGenLoop_ = 0;
+ if (ASq_ > aSqMaxVar_) {aSqMaxVar_ = ASq_;}
+ } else {
+ nGenLoop_++;
+ }
+ }
+
+ // Check whether we have generated the toy MC OK.
+ if (nGenLoop_ >= iterationsMax_) {
+ aSqMaxSet_ = 1.01 * aSqMaxVar_;
+ genOK = kFALSE;
+ std::cerr<<"WARNING in LauTimeDepNonFlavModel::generateSignalEvent : Hit max iterations: setting aSqMaxSet_ to "<<aSqMaxSet_<<std::endl;
+ } else if (aSqMaxVar_ > aSqMaxSet_) {
+ aSqMaxSet_ = 1.01 * aSqMaxVar_;
+ genOK = kFALSE;
+ std::cerr<<"WARNING in LauTimeDepNonFlavModel::generateSignalEvent : Found a larger ASq value: setting aSqMaxSet_ to "<<aSqMaxSet_<<std::endl;
+ }
+
+ if ( genOK && useSCF_ ) {
+ Double_t frac(0.0);
+ if ( useSCFHist_ ) {
+ frac = scfFracHist_->calcEfficiency( negKinematics_ );
+ } else {
+ frac = scfFrac_.genValue();
+ }
+ if ( frac < LauRandom::randomFun()->Rndm() ) {
+ this->setGenNtupleIntegerBranchValue("genTMSig",1);
+ this->setGenNtupleIntegerBranchValue("genSCFSig",0);
+ genSCF = kFALSE;
+ } else {
+ this->setGenNtupleIntegerBranchValue("genTMSig",0);
+ this->setGenNtupleIntegerBranchValue("genSCFSig",1);
+ genSCF = kTRUE;
+
+ // Optionally smear the DP position
+ // of the SCF event
+ if ( scfMap_ != 0 ) {
+ Double_t xCoord(0.0), yCoord(0.0);
+ if ( negKinematics_->squareDP() ) {
+ xCoord = negKinematics_->getmPrime();
+ yCoord = negKinematics_->getThetaPrime();
+ } else {
+ xCoord = negKinematics_->getm13Sq();
+ yCoord = negKinematics_->getm23Sq();
+ }
+
+ // Find the bin number where this event is generated
+ Int_t binNo = scfMap_->binNumber( xCoord, yCoord );
+
+ // Retrieve the migration histogram
+ TH2* histo = scfMap_->trueHist( binNo );
+
+ LauAbsEffModel * effModel = negSigModel_->getEffModel();
+ do {
+ // Get a random point from the histogram
+ histo->GetRandom2( xCoord, yCoord );
+
+ // Update the kinematics
+ if ( negKinematics_->squareDP() ) {
+ negKinematics_->updateSqDPKinematics( xCoord, yCoord );
+ } else {
+ negKinematics_->updateKinematics( xCoord, yCoord );
+ }
+ } while ( ! effModel->passVeto( negKinematics_ ) );
+ }
+ }
+ }
+ } else {
+ if ( useSCF_ ) {
+ Double_t frac = scfFrac_.genValue();
+ if ( frac < LauRandom::randomFun()->Rndm() ) {
+ this->setGenNtupleIntegerBranchValue("genTMSig",1);
+ this->setGenNtupleIntegerBranchValue("genSCFSig",0);
+ genSCF = kFALSE;
+ } else {
+ this->setGenNtupleIntegerBranchValue("genTMSig",0);
+ this->setGenNtupleIntegerBranchValue("genSCFSig",1);
+ genSCF = kTRUE;
+ }
+ }
+ }
+ if (genOK) {
+ // TODO! Check if the removal is right
+ //sigPdfs = &signalPdfs_;
+ //scfPdfs = &scfPdfs_;
+ if ( useSCF_ ) {
+ if ( genSCF ) {
+ this->generateExtraPdfValues(&scfPdfs_);
+ } else {
+ this->generateExtraPdfValues(&signalPdfs_);
+ }
+ } else {
+ this->generateExtraPdfValues(&signalPdfs_);
+ }
+ }
+
+ return genOK;
+}
+
+void LauBsCPFitModel::calculateDPterms()
+{
+
+ // Retrieve the amplitudes and efficiency from the dynamics
+ const LauComplex& Abar = negSigModel_->getEvtDPAmp();
+ const LauComplex& A = posSigModel_->getEvtDPAmp();
+ Double_t eff = negSigModel_->getEvtEff();
+
+ // Calculate the DP terms
+ Double_t aSqSum = A.abs2() + Abar.abs2();
+ LauComplex inter = Abar * A.conj();
+ Double_t interTermRe = inter.re();
+
+ // Total amplitude and multiply by the efficiency
+ ASq_ = aSqSum - 2.0 * D_ * interTermRe;
+ ASq_ *= eff;
+
+}
+
+Bool_t LauBsCPFitModel::generateBkgndEvent(UInt_t bkgndID)
+{
+ // Generate Bkgnd event
+ Bool_t genOK(kTRUE);
+
+ LauAbsBkgndDPModel* model(0);
+ LauPdfList* extraPdfs(0);
+ //LauKinematics* kinematics(0);
+
+ // TODO: Check charge again
+ /*
+ if (curEvtCharge_<0) {
+ model = negBkgndDPModels_[bkgndID];
+ if (this->enableEmbedding()) {
+ embeddedData = negBkgndTree_[bkgndID];
+ }
+ extraPdfs = &negBkgndPdfs_[bkgndID];
+ kinematics = negKinematics_;
+ } else {
+ model = posBkgndDPModels_[bkgndID];
+ if (this->enableEmbedding()) {
+ embeddedData = posBkgndTree_[bkgndID];
+ }
+ if ( tagged_ ) {
+ extraPdfs = &posBkgndPdfs_[bkgndID];
+ } else {
+ extraPdfs = &negBkgndPdfs_[bkgndID];
+ }
+ kinematics = posKinematics_;
+ }
+ */
+ model = bkgndDPModels_[bkgndID];
+ //if (this->enableEmbedding()) {
+ // embeddedData = bkgndTree_[bkgndID];
+ //}
+ extraPdfs = &bkgndPdfs_[bkgndID];
+ //kinematics = negKinematics_;
+ // Finishing here
+
+ if (this->useDP()) {
+ // TODO! Check!
+ /*if (embeddedData) {
+ embeddedData->getEmbeddedEvent(kinematics);
+ } else {*/
+ if (model == 0) {
+ const TString& bkgndClass = this->bkgndClassName(bkgndID);
+ std::cerr << "ERROR in LauBsCPFitModel::generateBkgndEvent : Can't find the DP model for background class \"" << bkgndClass << "\"." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+ genOK = model->generate();
+ //}
+ //} else {
+ // if (embeddedData) {
+ // embeddedData->getEmbeddedEvent(0);
+ // }
+ }
+ if (genOK) {
+ this->generateExtraPdfValues(extraPdfs);
+ }
+
+ return genOK;
+}
+
+void LauBsCPFitModel::setupGenNtupleBranches()
+{
+ // Setup the required ntuple branches
+ this->addGenNtupleDoubleBranch("evtWeight");
+ this->addGenNtupleIntegerBranch("genSig");
+ this->addGenNtupleDoubleBranch("efficiency");
+ if ( useSCF_ ) {
+ this->addGenNtupleIntegerBranch("genTMSig");
+ this->addGenNtupleIntegerBranch("genSCFSig");
+ }
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ TString name( this->bkgndClassName(iBkgnd) );
+ name.Prepend("gen");
+ this->addGenNtupleIntegerBranch(name);
+ }
+ if (this->useDP() == kTRUE) {
+ this->addGenNtupleDoubleBranch("m12");
+ this->addGenNtupleDoubleBranch("m23");
+ this->addGenNtupleDoubleBranch("m13");
+ this->addGenNtupleDoubleBranch("m12Sq");
+ this->addGenNtupleDoubleBranch("m23Sq");
+ this->addGenNtupleDoubleBranch("m13Sq");
+ this->addGenNtupleDoubleBranch("cosHel12");
+ this->addGenNtupleDoubleBranch("cosHel23");
+ this->addGenNtupleDoubleBranch("cosHel13");
+ if (negKinematics_->squareDP() && posKinematics_->squareDP()) {
+ this->addGenNtupleDoubleBranch("mPrime");
+ this->addGenNtupleDoubleBranch("thPrime");
+ }
+ }
+ for (LauPdfList::const_iterator pdf_iter = signalPdfs_.begin(); pdf_iter != signalPdfs_.end(); ++pdf_iter) {
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ this->addGenNtupleDoubleBranch( (*var_iter) );
+ }
+ }
+ }
+}
+
+void LauBsCPFitModel::setDPBranchValues()
+{
+ // Store all the DP information
+ this->setGenNtupleDoubleBranchValue("m12", negKinematics_->getm12());
+ this->setGenNtupleDoubleBranchValue("m23", negKinematics_->getm23());
+ this->setGenNtupleDoubleBranchValue("m13", negKinematics_->getm13());
+ this->setGenNtupleDoubleBranchValue("m12Sq", negKinematics_->getm12Sq());
+ this->setGenNtupleDoubleBranchValue("m23Sq", negKinematics_->getm23Sq());
+ this->setGenNtupleDoubleBranchValue("m13Sq", negKinematics_->getm13Sq());
+ this->setGenNtupleDoubleBranchValue("cosHel12", negKinematics_->getc12());
+ this->setGenNtupleDoubleBranchValue("cosHel23", negKinematics_->getc23());
+ this->setGenNtupleDoubleBranchValue("cosHel13", negKinematics_->getc13());
+ if (negKinematics_->squareDP()) {
+ this->setGenNtupleDoubleBranchValue("mPrime", negKinematics_->getmPrime());
+ this->setGenNtupleDoubleBranchValue("thPrime", negKinematics_->getThetaPrime());
+ }
+}
+
+void LauBsCPFitModel::generateExtraPdfValues(LauPdfList* extraPdfs)
+{
+ if (!extraPdfs) {
+ std::cerr << "ERROR in LauBsCPFitModel::generateExtraPdfValues : Null pointer to PDF list." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+
+ if (extraPdfs->empty()) {
+ //std::cerr << "WARNING in LauBsCPFitModel::generateExtraPdfValues : PDF list is empty." << std::endl;
+ return;
+ }
+
+ // Generate from the extra PDFs
+ for (LauPdfList::iterator pdf_iter = extraPdfs->begin(); pdf_iter != extraPdfs->end(); ++pdf_iter) {
+ LauFitData genValues;
+ genValues = (*pdf_iter)->generate(negKinematics_);
+ for ( LauFitData::const_iterator var_iter = genValues.begin(); var_iter != genValues.end(); ++var_iter ) {
+ TString varName = var_iter->first;
+ if ( varName != "m13Sq" && varName != "m23Sq" ) {
+ Double_t value = var_iter->second;
+ this->setGenNtupleDoubleBranchValue(varName,value);
+ }
+ }
+ }
+}
+
+void LauBsCPFitModel::propagateParUpdates()
+{
+ // Update the signal parameters and then the total normalisation for the signal likelihood
+ if (this->useDP() == kTRUE) {
+ this->updateCoeffs();
+ negSigModel_->updateCoeffs(negCoeffs_);
+ posSigModel_->updateCoeffs(posCoeffs_);
+ }
+
+ // Update the signal fraction from the background fractions if not doing an extended fit
+ if ( !this->doEMLFit() && !signalEvents_->fixed() ) {
+ this->updateSigEvents();
+ }
+}
+
+void LauBsCPFitModel::updateSigEvents()
+{
+ // The background parameters will have been set from Minuit.
+ // We need to update the signal events using these.
+ Double_t nTotEvts = this->eventsPerExpt();
+
+ signalEvents_->range(-2.0*nTotEvts,2.0*nTotEvts);
+ for (LauBkgndYieldList::iterator iter = bkgndEvents_.begin(); iter != bkgndEvents_.end(); ++iter) {
+ (*iter)->range(-2.0*nTotEvts,2.0*nTotEvts);
+ }
+
+ if (signalEvents_->fixed()) {
+ return;
+ }
+
+ // Subtract background events (if any) from signal.
+ Double_t signalEvents = nTotEvts;
+ if (usingBkgnd_ == kTRUE) {
+ for (LauBkgndYieldList::const_iterator iter = bkgndEvents_.begin(); iter != bkgndEvents_.end(); ++iter) {
+ signalEvents -= (*iter)->value();
+ }
+ }
+ signalEvents_->value(signalEvents);
+}
+
+void LauBsCPFitModel::cacheInputFitVars()
+{
+ // Fill the internal data trees of the signal and background models.
+ // Note that we store the events of both charges in both the
+ // negative and the positive models. It's only later, at the stage
+ // when the likelihood is being calculated, that we separate them.
+
+ LauFitDataTree* inputFitData = this->fitData();
+
+ // First the Dalitz plot variables (m_ij^2)
+ if (this->useDP() == kTRUE) {
+
+ // need to append SCF smearing bins before caching DP amplitudes
+ if ( scfMap_ != 0 ) {
+ this->appendBinCentres( inputFitData );
+ }
+
+ negSigModel_->fillDataTree(*inputFitData);
+ posSigModel_->fillDataTree(*inputFitData);
+
+ if (usingBkgnd_ == kTRUE) {
+ for (LauBkgndDPModelList::iterator iter = bkgndDPModels_.begin(); iter != bkgndDPModels_.end(); ++iter) {
+ (*iter)->fillDataTree(*inputFitData);
+ }
+ }
+ }
+
+ // ...and then the extra PDFs
+ this->cacheInfo(signalPdfs_, *inputFitData);
+ this->cacheInfo(scfPdfs_, *inputFitData);
+ for (LauBkgndPdfsList::iterator iter = bkgndPdfs_.begin(); iter != bkgndPdfs_.end(); ++iter) {
+ this->cacheInfo((*iter), *inputFitData);
+ }
+
+ // the SCF fractions and jacobians
+ if ( useSCF_ && useSCFHist_ ) {
+ if ( !inputFitData->haveBranch( "m13Sq" ) || !inputFitData->haveBranch( "m23Sq" ) ) {
+ std::cerr << "ERROR in LauBsCPFitModel::cacheInputFitVars : Input data does not contain DP branches and so can't cache the SCF fraction." << std::endl;
+ gSystem->Exit(EXIT_FAILURE);
+ }
+
+ UInt_t nEvents = inputFitData->nEvents();
+ recoSCFFracs_.clear();
+ recoSCFFracs_.reserve( nEvents );
+ if ( negKinematics_->squareDP() ) {
+ recoJacobians_.clear();
+ recoJacobians_.reserve( nEvents );
+ }
+ for (UInt_t iEvt = 0; iEvt < nEvents; iEvt++) {
+ const LauFitData& dataValues = inputFitData->getData(iEvt);
+ LauFitData::const_iterator m13_iter = dataValues.find("m13Sq");
+ LauFitData::const_iterator m23_iter = dataValues.find("m23Sq");
+ negKinematics_->updateKinematics( m13_iter->second, m23_iter->second );
+ Double_t scfFrac = scfFracHist_->calcEfficiency( negKinematics_ );
+ recoSCFFracs_.push_back( scfFrac );
+ if ( negKinematics_->squareDP() ) {
+ recoJacobians_.push_back( negKinematics_->calcSqDPJacobian() );
+ }
+ }
+ }
+}
+
+void LauBsCPFitModel::appendBinCentres( LauFitDataTree* inputData )
+{
+ // We'll be caching the DP amplitudes and efficiencies of the centres of the true bins.
+ // To do so, we attach some fake points at the end of inputData, the number of the entry
+ // minus the total number of events corresponding to the number of the histogram for that
+ // given true bin in the LauScfMap object. (What this means is that when Laura is provided with
+ // the LauScfMap object by the user, it's the latter who has to make sure that it contains the
+ // right number of histograms and in exactly the right order!)
+
+ // Get the x and y co-ordinates of the bin centres
+ std::vector<Double_t> binCentresXCoords;
+ std::vector<Double_t> binCentresYCoords;
+ scfMap_->listBinCentres(binCentresXCoords, binCentresYCoords);
+
+ // The SCF histograms could be in square Dalitz plot histograms.
+ // The dynamics takes normal Dalitz plot coords, so we might have to convert them back.
+ Bool_t sqDP = negKinematics_->squareDP();
+ UInt_t nBins = binCentresXCoords.size();
+ fakeSCFFracs_.clear();
+ fakeSCFFracs_.reserve( nBins );
+ if ( sqDP ) {
+ fakeJacobians_.clear();
+ fakeJacobians_.reserve( nBins );
+ }
+
+ for (UInt_t iBin = 0; iBin < nBins; ++iBin) {
+
+ if ( sqDP ) {
+ negKinematics_->updateSqDPKinematics(binCentresXCoords[iBin],binCentresYCoords[iBin]);
+ binCentresXCoords[iBin] = negKinematics_->getm13Sq();
+ binCentresYCoords[iBin] = negKinematics_->getm23Sq();
+ fakeJacobians_.push_back( negKinematics_->calcSqDPJacobian() );
+ } else {
+ negKinematics_->updateKinematics(binCentresXCoords[iBin],binCentresYCoords[iBin]);
+ }
+
+ fakeSCFFracs_.push_back( scfFracHist_->calcEfficiency( negKinematics_ ) );
+ }
+
+ // Set up inputFitVars_ object to hold the fake events
+ inputData->appendFakePoints(binCentresXCoords,binCentresYCoords);
+}
+
+Double_t LauBsCPFitModel::getTotEvtLikelihood(UInt_t iEvt)
+{
+ // Find out whether we have B- or B+
+
+ // Get the DP likelihood for signal and backgrounds
+ this->getEvtDPLikelihood(iEvt);
+
+ // Get the combined extra PDFs likelihood for signal and backgrounds
+ this->getEvtExtraLikelihoods(iEvt);
+
+ // If appropriate, combine the TM and SCF likelihoods
+ Double_t sigLike = sigDPLike_ * sigExtraLike_;
+ if ( useSCF_ ) {
+ Double_t scfFrac(0.0);
+ if (useSCFHist_) {
+ scfFrac = recoSCFFracs_[iEvt];
+ } else {
+ scfFrac = scfFrac_.value();
+ }
+ sigLike *= (1.0 - scfFrac);
+ if ( (scfMap_ != 0) && (this->useDP() == kTRUE) ) {
+ // if we're smearing the SCF DP PDF then the SCF frac
+ // is already included in the SCF DP likelihood
+ sigLike += (scfDPLike_ * scfExtraLike_);
+ } else {
+ sigLike += (scfFrac * scfDPLike_ * scfExtraLike_);
+ }
+ }
+
+ // Signal asymmetry is built into the DP model...
+ Double_t signalEvents = signalEvents_->value();
+
+ // Construct the total event likelihood
+ Double_t likelihood(0.0);
+ if (usingBkgnd_) {
+ likelihood = sigLike*signalEvents;
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ Double_t bkgndEvents = bkgndEvents_[bkgndID]->value();
+ likelihood += bkgndEvents*bkgndDPLike_[bkgndID]*bkgndExtraLike_[bkgndID];
+ }
+ } else {
+ // TODO: receives this 1/2 term?
+ //likelihood = sigLike*0.5;
+ likelihood = sigLike;
+ }
+ return likelihood;
+}
+
+Double_t LauBsCPFitModel::getEventSum() const
+{
+ Double_t eventSum(0.0);
+ eventSum += signalEvents_->value();
+ if (usingBkgnd_) {
+ for (LauBkgndYieldList::const_iterator iter = bkgndEvents_.begin(); iter != bkgndEvents_.end(); ++iter) {
+ eventSum += (*iter)->value();
+ }
+ }
+ return eventSum;
+}
+
+void LauBsCPFitModel::getEvtDPLikelihood(UInt_t iEvt)
+{
+ // Function to return the signal and background likelihoods for the
+ // Dalitz plot for the given event evtNo.
+
+ if ( ! this->useDP() ) {
+ // There's always going to be a term in the likelihood for the
+ // signal, so we'd better not zero it.
+ sigDPLike_ = 1.0;
+ scfDPLike_ = 1.0;
+
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ if (usingBkgnd_ == kTRUE) {
+ bkgndDPLike_[bkgndID] = 1.0;
+ } else {
+ bkgndDPLike_[bkgndID] = 0.0;
+ }
+ }
+
+ return;
+ }
+
+ const UInt_t nBkgnds = this->nBkgndClasses();
+
+ // Completely revised
+ posSigModel_->calcLikelihoodInfo(iEvt);
+ negSigModel_->calcLikelihoodInfo(iEvt);
+
+ this->calculateDPterms();
+
+ sigDPLike_ = ASq_;
+
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ if (usingBkgnd_ == kTRUE) {
+ bkgndDPLike_[bkgndID] = bkgndDPModels_[bkgndID]->getLikelihood(iEvt);
+ } else {
+ bkgndDPLike_[bkgndID] = 0.0;
+ }
+ }
+
+ if ( useSCF_ == kTRUE ) {
+ if ( scfMap_ == 0 ) {
+ // we're not smearing the SCF DP position
+ // so the likelihood is the same as the TM
+ scfDPLike_ = sigDPLike_;
+ } else {
+ // calculate the smeared SCF DP likelihood
+ scfDPLike_ = this->getEvtSCFDPLikelihood(iEvt);
+ }
+ }
+
+ // Calculate the signal normalisation
+ // NB the 2.0 is there so that the 0.5 factor is applied to
+ // signal and background in the same place otherwise you get
+ // normalisation problems when you switch off the DP in the fit
+ // TODO: need to fix this
+ //this->calculateAmplitudeNorm();
+
+ sigDPLike_ *= 1.0/normDP_;
+ scfDPLike_ *= 1.0/normDP_;
+}
+
+void LauBsCPFitModel::calculateAmplitudeNorm()
+{
+
+ // Integrals of the sum of the ampltudes to the f(fbar) integral( |A|^2 + |Abar|^2 ) dP
+ Double_t normASq = posSigModel_->getDPNorm();
+ Double_t normAbarSq = negSigModel_->getDPNorm();
+ // Integrals of cross terms Abar*Aconj
+ Double_t normInterTerm = interTermReNorm_;
+
+ // Complete DP normalisation terms
+ normDP_ = normASq + normAbarSq - 2.0 * D_ * normInterTerm;
+
+}
+
+void LauBsCPFitModel::calcInterTermNorm()
+{
+ const std::vector<Double_t> fNormB0 = posSigModel_->getFNorm();
+ const std::vector<Double_t> fNormB0bar = negSigModel_->getFNorm();
+
+ LauComplex norm;
+ for (UInt_t iAmp = 0; iAmp < nSigComp_; ++iAmp) {
+ for (UInt_t jAmp = 0; jAmp < nSigComp_; ++jAmp) {
+
+ LauComplex coeffTerm = negCoeffs_[jAmp]*posCoeffs_[iAmp].conj();
+ coeffTerm *= fifjEffSum_[iAmp][jAmp];
+ coeffTerm.rescale(fNormB0bar[jAmp] * fNormB0[iAmp]);
+
+ norm += coeffTerm;
+ }
+ }
+ interTermReNorm_ = norm.re();
+ //interTermImNorm_f_ = 2.0*norm_f.im();
+}
+
+Double_t LauBsCPFitModel::getEvtSCFDPLikelihood(UInt_t iEvt)
+{
+ Double_t scfDPLike(0.0);
+
+ Double_t recoJacobian(1.0);
+ Double_t xCoord(0.0);
+ Double_t yCoord(0.0);
+
+ Bool_t squareDP = negKinematics_->squareDP();
+ if ( squareDP ) {
+ xCoord = negSigModel_->getEvtmPrime();
+ yCoord = negSigModel_->getEvtthPrime();
+ recoJacobian = recoJacobians_[iEvt];
+ } else {
+ xCoord = negSigModel_->getEvtm13Sq();
+ yCoord = negSigModel_->getEvtm23Sq();
+ }
+
+ // Find the bin that our reco event falls in
+ Int_t recoBin = scfMap_->binNumber( xCoord, yCoord );
+
+ // Find out which true Bins contribute to the given reco bin
+ const std::vector<Int_t>* trueBins = scfMap_->trueBins(recoBin);
+
+ const Int_t nDataEvents = this->eventsPerExpt();
+
+ // Loop over the true bins
+ for (std::vector<Int_t>::const_iterator iter = trueBins->begin(); iter != trueBins->end(); ++iter)
+ {
+ Int_t trueBin = (*iter);
+
+ // prob of a true event in the given true bin migrating to the reco bin
+ Double_t pRecoGivenTrue = scfMap_->prob( recoBin, trueBin );
+ Double_t pTrue(0.0);
+
+ // We've cached the DP amplitudes and the efficiency for the
+ // true bin centres, just after the data points
+ // TODO: Check this!!
+ /*if ( tagged_ ) {
+ LauIsobarDynamics* sigModel(0);
+ if (curEvtCharge_<0) {
+ sigModel = negSigModel_;
+ } else {
+ sigModel = posSigModel_;
+ }
+
+ sigModel->calcLikelihoodInfo( nDataEvents + trueBin );
+
+ pTrue = sigModel->getEvtDPAmp().abs2() * sigModel->getEvtEff();
+ } else {*/
+ posSigModel_->calcLikelihoodInfo( nDataEvents + trueBin );
+ negSigModel_->calcLikelihoodInfo( nDataEvents + trueBin );
+
+ //pTrue = 0.5 * ( posSigModel_->getEvtDPAmp().abs2() * posSigModel_->getEvtEff() +
+ // negSigModel_->getEvtDPAmp().abs2() * negSigModel_->getEvtEff() );
+ const LauComplex& A = posSigModel_->getEvtDPAmp();
+ const LauComplex& Abar = negSigModel_->getEvtDPAmp();
+ const LauComplex AstAbar = A.conj() * Abar;
+ Double_t D = 0.10;
+ pTrue = A.abs2() * posSigModel_->getEvtEff() +
+ Abar.abs2() * negSigModel_->getEvtEff() -
+ 2.0 * D * AstAbar.re();
+ //}
+
+ // Get the cached SCF fraction (and jacobian if we're using the square DP)
+ Double_t scfFraction = fakeSCFFracs_[ trueBin ];
+ Double_t jacobian(1.0);
+ if ( squareDP ) {
+ jacobian = fakeJacobians_[ trueBin ];
+ }
+
+ scfDPLike += pTrue * jacobian * scfFraction * pRecoGivenTrue;
+ }
+
+ // Divide by the reco jacobian
+ scfDPLike /= recoJacobian;
+
+ return scfDPLike;
+}
+
+void LauBsCPFitModel::getEvtExtraLikelihoods(UInt_t iEvt)
+{
+ // Function to return the signal and background likelihoods for the
+ // extra variables for the given event evtNo.
+
+ sigExtraLike_ = 1.0;
+
+ const UInt_t nBkgnds = this->nBkgndClasses();
+
+ // TODO: Not sure here about this!
+ // I will comment out the minimum I can
+ /*if ( ! tagged_ || curEvtCharge_ < 0 ) {
+ sigExtraLike_ = this->prodPdfValue( negSignalPdfs_, iEvt );
+
+ if (useSCF_) {
+ scfExtraLike_ = this->prodPdfValue( negScfPdfs_, iEvt );
+ }
+
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ if (usingBkgnd_) {
+ bkgndExtraLike_[bkgndID] = this->prodPdfValue( negBkgndPdfs_[bkgndID], iEvt );
+ } else {
+ bkgndExtraLike_[bkgndID] = 0.0;
+ }
+ }
+ } else {
+ sigExtraLike_ = this->prodPdfValue( posSignalPdfs_, iEvt );
+
+ if (useSCF_) {
+ scfExtraLike_ = this->prodPdfValue( posScfPdfs_, iEvt );
+ }
+
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ if (usingBkgnd_) {
+ bkgndExtraLike_[bkgndID] = this->prodPdfValue( posBkgndPdfs_[bkgndID], iEvt );
+ } else {
+ bkgndExtraLike_[bkgndID] = 0.0;
+ }
+ }
+ }
+ */
+
+ sigExtraLike_ = this->prodPdfValue( signalPdfs_, iEvt );
+ if (useSCF_) {
+ scfExtraLike_ = this->prodPdfValue( scfPdfs_, iEvt );
+ }
+
+ for ( UInt_t bkgndID(0); bkgndID < nBkgnds; ++bkgndID ) {
+ if (usingBkgnd_) {
+ bkgndExtraLike_[bkgndID] = this->prodPdfValue( bkgndPdfs_[bkgndID], iEvt );
+ } else {
+ bkgndExtraLike_[bkgndID] = 0.0;
+ }
+ }
+}
+
+void LauBsCPFitModel::updateCoeffs()
+{
+ negCoeffs_.clear(); posCoeffs_.clear();
+ negCoeffs_.reserve(nSigComp_); posCoeffs_.reserve(nSigComp_);
+ for (UInt_t i = 0; i < nSigComp_; i++) {
+ negCoeffs_.push_back(coeffPars_[i]->antiparticleCoeff());
+ posCoeffs_.push_back(coeffPars_[i]->particleCoeff());
+ }
+}
+
+void LauBsCPFitModel::setupSPlotNtupleBranches()
+{
+ // add branches for storing the experiment number and the number of
+ // the event within the current experiment
+ this->addSPlotNtupleIntegerBranch("iExpt");
+ this->addSPlotNtupleIntegerBranch("iEvtWithinExpt");
+
+ // Store the efficiency of the event (for inclusive BF calculations).
+ if (this->storeDPEff()) {
+ this->addSPlotNtupleDoubleBranch("efficiency");
+ if ( negSigModel_->usingScfModel() && posSigModel_->usingScfModel() ) {
+ this->addSPlotNtupleDoubleBranch("scffraction");
+ }
+ }
+
+ // Store the total event likelihood for each species.
+ if (useSCF_) {
+ this->addSPlotNtupleDoubleBranch("sigTMTotalLike");
+ this->addSPlotNtupleDoubleBranch("sigSCFTotalLike");
+ this->addSPlotNtupleDoubleBranch("sigSCFFrac");
+ } else {
+ this->addSPlotNtupleDoubleBranch("sigTotalLike");
+ }
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ TString name( this->bkgndClassName(iBkgnd) );
+ name += "TotalLike";
+ this->addSPlotNtupleDoubleBranch(name);
+ }
+ }
+
+ // Store the DP likelihoods
+ if (this->useDP()) {
+ if (useSCF_) {
+ this->addSPlotNtupleDoubleBranch("sigTMDPLike");
+ this->addSPlotNtupleDoubleBranch("sigSCFDPLike");
+ } else {
+ this->addSPlotNtupleDoubleBranch("sigDPLike");
+ }
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ TString name( this->bkgndClassName(iBkgnd) );
+ name += "DPLike";
+ this->addSPlotNtupleDoubleBranch(name);
+ }
+ }
+ }
+
+ // Store the likelihoods for each extra PDF
+ if (useSCF_) {
+ this->addSPlotNtupleBranches(&signalPdfs_, "sigTM");
+ this->addSPlotNtupleBranches(&scfPdfs_, "sigSCF");
+ } else {
+ this->addSPlotNtupleBranches(&signalPdfs_, "sig");
+ }
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ const TString& bkgndClass = this->bkgndClassName(iBkgnd);
+ const LauPdfList* pdfList = &(bkgndPdfs_[iBkgnd]);
+ this->addSPlotNtupleBranches(pdfList, bkgndClass);
+ }
+ }
+}
+
+void LauBsCPFitModel::addSPlotNtupleBranches(const LauPdfList* extraPdfs, const TString& prefix)
+{
+ if (extraPdfs) {
+ // Loop through each of the PDFs
+ for (LauPdfList::const_iterator pdf_iter = extraPdfs->begin(); pdf_iter != extraPdfs->end(); ++pdf_iter) {
+
+ // Count the number of input variables that are not
+ // DP variables (used in the case where there is DP
+ // dependence for e.g. MVA)
+ UInt_t nVars(0);
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nVars;
+ }
+ }
+
+ if ( nVars == 1 ) {
+ // If the PDF only has one variable then
+ // simply add one branch for that variable
+ TString varName = (*pdf_iter)->varName();
+ TString name(prefix);
+ name += varName;
+ name += "Like";
+ this->addSPlotNtupleDoubleBranch(name);
+ } else if ( nVars == 2 ) {
+ // If the PDF has two variables then we
+ // need a branch for them both together and
+ // branches for each
+ TString allVars("");
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ allVars += (*var_iter);
+ TString name(prefix);
+ name += (*var_iter);
+ name += "Like";
+ this->addSPlotNtupleDoubleBranch(name);
+ }
+ TString name(prefix);
+ name += allVars;
+ name += "Like";
+ this->addSPlotNtupleDoubleBranch(name);
+ } else {
+ std::cerr << "WARNING in LauBsCPFitModel::addSPlotNtupleBranches : Can't yet deal with 3D PDFs." << std::endl;
+ }
+ }
+ }
+}
+
+Double_t LauBsCPFitModel::setSPlotNtupleBranchValues(LauPdfList* extraPdfs, const TString& prefix, UInt_t iEvt)
+{
+ // Store the PDF value for each variable in the list
+ Double_t totalLike(1.0);
+ Double_t extraLike(0.0);
+ if (extraPdfs) {
+ for (LauPdfList::iterator pdf_iter = extraPdfs->begin(); pdf_iter != extraPdfs->end(); ++pdf_iter) {
+
+ // calculate the likelihood for this event
+ (*pdf_iter)->calcLikelihoodInfo(iEvt);
+ extraLike = (*pdf_iter)->getLikelihood();
+ totalLike *= extraLike;
+
+ // Count the number of input variables that are not
+ // DP variables (used in the case where there is DP
+ // dependence for e.g. MVA)
+ UInt_t nVars(0);
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nVars;
+ }
+ }
+
+ if ( nVars == 1 ) {
+ // If the PDF only has one variable then
+ // simply store the value for that variable
+ TString varName = (*pdf_iter)->varName();
+ TString name(prefix);
+ name += varName;
+ name += "Like";
+ this->setSPlotNtupleDoubleBranchValue(name, extraLike);
+ } else if ( nVars == 2 ) {
+ // If the PDF has two variables then we
+ // store the value for them both together
+ // and for each on their own
+ TString allVars("");
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ allVars += (*var_iter);
+ TString name(prefix);
+ name += (*var_iter);
+ name += "Like";
+ Double_t indivLike = (*pdf_iter)->getLikelihood( (*var_iter) );
+ this->setSPlotNtupleDoubleBranchValue(name, indivLike);
+ }
+ TString name(prefix);
+ name += allVars;
+ name += "Like";
+ this->setSPlotNtupleDoubleBranchValue(name, extraLike);
+ } else {
+ std::cerr << "WARNING in LauBsCPFitModel::setSPlotNtupleBranchValues : Can't yet deal with 3D PDFs." << std::endl;
+ }
+ }
+ }
+ return totalLike;
+}
+
+LauSPlot::NameSet LauBsCPFitModel::variableNames() const
+{
+ LauSPlot::NameSet nameSet;
+ if (this->useDP()) {
+ nameSet.insert("DP");
+ }
+ // Loop through all the signal PDFs
+ for (LauPdfList::const_iterator pdf_iter = signalPdfs_.begin(); pdf_iter != signalPdfs_.end(); ++pdf_iter) {
+ // Loop over the variables involved in each PDF
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ // If they are not DP coordinates then add them
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ nameSet.insert( (*var_iter) );
+ }
+ }
+ }
+ return nameSet;
+}
+
+LauSPlot::NumbMap LauBsCPFitModel::freeSpeciesNames() const
+{
+ LauSPlot::NumbMap numbMap;
+ if (!signalEvents_->fixed() && this->doEMLFit()) {
+ numbMap["sig"] = signalEvents_->genValue();
+ }
+ if ( usingBkgnd_ ) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ const TString& bkgndClass = this->bkgndClassName(iBkgnd);
+ const LauParameter* par = bkgndEvents_[iBkgnd];
+ if (!par->fixed()) {
+ numbMap[bkgndClass] = par->genValue();
+ }
+ }
+ }
+ return numbMap;
+}
+
+LauSPlot::NumbMap LauBsCPFitModel::fixdSpeciesNames() const
+{
+ LauSPlot::NumbMap numbMap;
+ if (signalEvents_->fixed() && this->doEMLFit()) {
+ numbMap["sig"] = signalEvents_->genValue();
+ }
+ if ( usingBkgnd_ ) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ const TString& bkgndClass = this->bkgndClassName(iBkgnd);
+ const LauParameter* par = bkgndEvents_[iBkgnd];
+ if (par->fixed()) {
+ numbMap[bkgndClass] = par->genValue();
+ }
+ }
+ }
+ return numbMap;
+}
+
+LauSPlot::TwoDMap LauBsCPFitModel::twodimPDFs() const
+{
+ // This makes the assumption that the form of the positive and
+ // negative PDFs are the same, which seems reasonable to me
+
+ LauSPlot::TwoDMap twodimMap;
+
+ for (LauPdfList::const_iterator pdf_iter = signalPdfs_.begin(); pdf_iter != signalPdfs_.end(); ++pdf_iter) {
+ // Count the number of input variables that are not DP variables
+ UInt_t nVars(0);
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nVars;
+ }
+ }
+ if ( nVars == 2 ) {
+ if (useSCF_) {
+ twodimMap.insert( std::make_pair( "sigTM", std::make_pair( varNames[0], varNames[1] ) ) );
+ } else {
+ twodimMap.insert( std::make_pair( "sig", std::make_pair( varNames[0], varNames[1] ) ) );
+ }
+ }
+ }
+
+ if ( useSCF_ ) {
+ for (LauPdfList::const_iterator pdf_iter = scfPdfs_.begin(); pdf_iter != scfPdfs_.end(); ++pdf_iter) {
+ // Count the number of input variables that are not DP variables
+ UInt_t nVars(0);
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nVars;
+ }
+ }
+ if ( nVars == 2 ) {
+ twodimMap.insert( std::make_pair( "sigSCF", std::make_pair( varNames[0], varNames[1] ) ) );
+ }
+ }
+ }
+
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ const TString& bkgndClass = this->bkgndClassName(iBkgnd);
+ const LauPdfList& pdfList = bkgndPdfs_[iBkgnd];
+ for (LauPdfList::const_iterator pdf_iter = pdfList.begin(); pdf_iter != pdfList.end(); ++pdf_iter) {
+ // Count the number of input variables that are not DP variables
+ UInt_t nVars(0);
+ std::vector<TString> varNames = (*pdf_iter)->varNames();
+ for ( std::vector<TString>::const_iterator var_iter = varNames.begin(); var_iter != varNames.end(); ++var_iter ) {
+ if ( (*var_iter) != "m13Sq" && (*var_iter) != "m23Sq" ) {
+ ++nVars;
+ }
+ }
+ if ( nVars == 2 ) {
+ twodimMap.insert( std::make_pair( bkgndClass, std::make_pair( varNames[0], varNames[1] ) ) );
+ }
+ }
+ }
+ }
+
+ return twodimMap;
+}
+
+void LauBsCPFitModel::storePerEvtLlhds()
+{
+ std::cout << "INFO in LauBsCPFitModel::storePerEvtLlhds : Storing per-event likelihood values..." << std::endl;
+
+ // if we've not been using the DP model then we need to cache all
+ // the info here so that we can get the efficiency from it
+
+ LauFitDataTree* inputFitData = this->fitData();
+
+ if (!this->useDP() && this->storeDPEff()) {
+ negSigModel_->initialise(negCoeffs_);
+ posSigModel_->initialise(posCoeffs_);
+ negSigModel_->fillDataTree(*inputFitData);
+ posSigModel_->fillDataTree(*inputFitData);
+ }
+
+ UInt_t evtsPerExpt(this->eventsPerExpt());
+
+ //LauIsobarDynamics* sigModel(0);
+ LauPdfList* sigPdfs(0);
+ LauPdfList* scfPdfs(0);
+ LauBkgndPdfsList* bkgndPdfs(0);
+
+ for (UInt_t iEvt = 0; iEvt < evtsPerExpt; ++iEvt) {
+
+ this->setSPlotNtupleIntegerBranchValue("iExpt",this->iExpt());
+ this->setSPlotNtupleIntegerBranchValue("iEvtWithinExpt",iEvt);
+
+ // Find out whether we have B- or B+
+ // TODO: Check this (Commented out for the time being)
+ /*if ( tagged_ ) {
+ const LauFitData& dataValues = inputFitData->getData(iEvt);
+ LauFitData::const_iterator iter = dataValues.find("charge");
+ curEvtCharge_ = static_cast<Int_t>(iter->second);
+
+ if (curEvtCharge_==+1) {
+ sigModel = posSigModel_;
+ sigPdfs = &posSignalPdfs_;
+ scfPdfs = &posScfPdfs_;
+ bkgndPdfs = &posBkgndPdfs_;
+ } else {
+ sigModel = negSigModel_;
+ sigPdfs = &negSignalPdfs_;
+ scfPdfs = &negScfPdfs_;
+ bkgndPdfs = &negBkgndPdfs_;
+ }
+ } else {
+ sigPdfs = &negSignalPdfs_;
+ scfPdfs = &negScfPdfs_;
+ bkgndPdfs = &negBkgndPdfs_;
+ } */
+ //sigModel = negSigModel_;
+ sigPdfs = &signalPdfs_;
+ scfPdfs = &scfPdfs_;
+ bkgndPdfs = &bkgndPdfs_;
+
+ // the DP information
+ this->getEvtDPLikelihood(iEvt);
+ if (this->storeDPEff()) {
+ if (!this->useDP()) {
+ posSigModel_->calcLikelihoodInfo(iEvt);
+ negSigModel_->calcLikelihoodInfo(iEvt);
+ }
+ /*if ( tagged_ ) {
+ this->setSPlotNtupleDoubleBranchValue("efficiency",sigModel->getEvtEff());
+ if ( negSigModel_->usingScfModel() && posSigModel_->usingScfModel() ) {
+ this->setSPlotNtupleDoubleBranchValue("scffraction",sigModel->getEvtScfFraction());
+ }
+ } else {*/
+ // TODO: Does it matter?
+ this->setSPlotNtupleDoubleBranchValue("efficiency",0.5*(posSigModel_->getEvtEff() + negSigModel_->getEvtEff()) );
+ if ( negSigModel_->usingScfModel() && posSigModel_->usingScfModel() ) {
+ this->setSPlotNtupleDoubleBranchValue("scffraction",0.5*(posSigModel_->getEvtScfFraction() + negSigModel_->getEvtScfFraction()));
+ }
+ //}
+ }
+ if (this->useDP()) {
+ sigTotalLike_ = sigDPLike_;
+ if (useSCF_) {
+ scfTotalLike_ = scfDPLike_;
+ this->setSPlotNtupleDoubleBranchValue("sigTMDPLike",sigDPLike_);
+ this->setSPlotNtupleDoubleBranchValue("sigSCFDPLike",scfDPLike_);
+ } else {
+ this->setSPlotNtupleDoubleBranchValue("sigDPLike",sigDPLike_);
+ }
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ TString name = this->bkgndClassName(iBkgnd);
+ name += "DPLike";
+ this->setSPlotNtupleDoubleBranchValue(name,bkgndDPLike_[iBkgnd]);
+ }
+ }
+ } else {
+ sigTotalLike_ = 1.0;
+ if (useSCF_) {
+ scfTotalLike_ = 1.0;
+ }
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ bkgndTotalLike_[iBkgnd] = 1.0;
+ }
+ }
+ }
+
+ // the signal PDF values
+ if ( useSCF_ ) {
+ sigTotalLike_ *= this->setSPlotNtupleBranchValues(sigPdfs, "sigTM", iEvt);
+ scfTotalLike_ *= this->setSPlotNtupleBranchValues(scfPdfs, "sigSCF", iEvt);
+ } else {
+ sigTotalLike_ *= this->setSPlotNtupleBranchValues(sigPdfs, "sig", iEvt);
+ }
+
+ // the background PDF values
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ const TString& bkgndClass = this->bkgndClassName(iBkgnd);
+ LauPdfList& pdfs = (*bkgndPdfs)[iBkgnd];
+ bkgndTotalLike_[iBkgnd] *= this->setSPlotNtupleBranchValues(&(pdfs), bkgndClass, iEvt);
+ }
+ }
+
+ // the total likelihoods
+ if (useSCF_) {
+ Double_t scfFrac(0.0);
+ if ( useSCFHist_ ) {
+ scfFrac = recoSCFFracs_[iEvt];
+ } else {
+ scfFrac = scfFrac_.value();
+ }
+ this->setSPlotNtupleDoubleBranchValue("sigSCFFrac",scfFrac);
+ sigTotalLike_ *= ( 1.0 - scfFrac );
+ if ( scfMap_ == 0 ) {
+ scfTotalLike_ *= scfFrac;
+ }
+ this->setSPlotNtupleDoubleBranchValue("sigTMTotalLike",sigTotalLike_);
+ this->setSPlotNtupleDoubleBranchValue("sigSCFTotalLike",scfTotalLike_);
+ } else {
+ this->setSPlotNtupleDoubleBranchValue("sigTotalLike",sigTotalLike_);
+ }
+ if (usingBkgnd_) {
+ const UInt_t nBkgnds = this->nBkgndClasses();
+ for ( UInt_t iBkgnd(0); iBkgnd < nBkgnds; ++iBkgnd ) {
+ TString name = this->bkgndClassName(iBkgnd);
+ name += "TotalLike";
+ this->setSPlotNtupleDoubleBranchValue(name,bkgndTotalLike_[iBkgnd]);
+ }
+ }
+ // fill the tree
+ this->fillSPlotNtupleBranches();
+ }
+ std::cout << "INFO in LauBsCPFitModel::storePerEvtLlhds : Finished storing per-event likelihood values." << std::endl;
+}
+/*
+void LauBsCPFitModel::embedNegSignal(const TString& fileName, const TString& treeName,
+ Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment,
+ Bool_t useReweighting)
+{
+ if (negSignalTree_) {
+ std::cerr << "ERROR in LauBsCPFitModel::embedNegSignal : Already embedding signal from a file." << std::endl;
+ return;
+ }
+
+ if (!reuseEventsWithinEnsemble && reuseEventsWithinExperiment) {
+ std::cerr << "WARNING in LauBsCPFitModel::embedNegSignal : Conflicting options provided, will not reuse events at all." << std::endl;
+ reuseEventsWithinExperiment = kFALSE;
+ }
+
+ negSignalTree_ = new LauEmbeddedData(fileName,treeName,reuseEventsWithinExperiment);
+ Bool_t dataOK = negSignalTree_->findBranches();
+ if (!dataOK) {
+ delete negSignalTree_; negSignalTree_ = 0;
+ std::cerr << "ERROR in LauBsCPFitModel::embedNegSignal : Problem creating data tree for embedding." << std::endl;
+ return;
+ }
+ reuseSignal_ = reuseEventsWithinEnsemble;
+ useNegReweighting_ = useReweighting;
+ if (this->enableEmbedding() == kFALSE) {this->enableEmbedding(kTRUE);}
+}
+
+void LauBsCPFitModel::embedBkgnd(const TString& bkgndClass, const TString& fileName, const TString& treeName,
+ Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment)
+{
+ if ( ! this->validBkgndClass( bkgndClass ) ) {
+ std::cerr << "ERROR in LauBsCPFitModel::embedBkgnd : Invalid background class \"" << bkgndClass << "\"." << std::endl;
+ std::cerr << " : Background class names must be provided in \"setBkgndClassNames\" before any other background-related actions can be performed." << std::endl;
+ return;
+ }
+
+ UInt_t bkgndID = this->bkgndClassID( bkgndClass );
+
+ if (bkgndTree_[bkgndID]) {
+ std::cerr << "ERROR in LauBsCPFitModel::embedBkgnd : Already embedding background from a file." << std::endl;
+ return;
+ }
+
+ if (!reuseEventsWithinEnsemble && reuseEventsWithinExperiment) {
+ std::cerr << "WARNING in LauBsCPFitModel::embedBkgnd : Conflicting options provided, will not reuse events at all." << std::endl;
+ reuseEventsWithinExperiment = kFALSE;
+ }
+
+ bkgndTree_[bkgndID] = new LauEmbeddedData(fileName,treeName,reuseEventsWithinExperiment);
+ Bool_t dataOK = bkgndTree_[bkgndID]->findBranches();
+ if (!dataOK) {
+ delete bkgndTree_[bkgndID]; bkgndTree_[bkgndID] = 0;
+ std::cerr << "ERROR in LauBsCPFitModel::embedBkgnd : Problem creating data tree for embedding." << std::endl;
+ return;
+ }
+ reuseBkgnd_[bkgndID] = reuseEventsWithinEnsemble;
+ if (this->enableEmbedding() == kFALSE) {this->enableEmbedding(kTRUE);}
+}
+
+void LauBsCPFitModel::embedPosSignal(const TString& fileName, const TString& treeName,
+ Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment,
+ Bool_t useReweighting)
+{
+ if (posSignalTree_) {
+ std::cerr << "ERROR in LauBsCPFitModel::embedPosSignal : Already embedding signal from a file." << std::endl;
+ return;
+ }
+
+ if (!reuseEventsWithinEnsemble && reuseEventsWithinExperiment) {
+ std::cerr << "WARNING in LauBsCPFitModel::embedPosSignal : Conflicting options provided, will not reuse events at all." << std::endl;
+ reuseEventsWithinExperiment = kFALSE;
+ }
+
+ posSignalTree_ = new LauEmbeddedData(fileName,treeName,reuseEventsWithinExperiment);
+ Bool_t dataOK = posSignalTree_->findBranches();
+ if (!dataOK) {
+ delete posSignalTree_; posSignalTree_ = 0;
+ std::cerr << "ERROR in LauBsCPFitModel::embedPosSignal : Problem creating data tree for embedding." << std::endl;
+ return;
+ }
+ reuseSignal_ = reuseEventsWithinEnsemble;
+ usePosReweighting_ = useReweighting;
+ if (this->enableEmbedding() == kFALSE) {this->enableEmbedding(kTRUE);}
+}
+*/
+void LauBsCPFitModel::weightEvents( const TString& /*dataFileName*/, const TString& /*dataTreeName*/ )
+{
+ std::cerr << "ERROR in LauBsCPFitModel::weightEvents : Method not available for this fit model." << std::endl;
+ return;
+}
+
+void LauBsCPFitModel::savePDFPlots(const TString& /*label*/)
+{
+}
+
+void LauBsCPFitModel::savePDFPlotsWave(const TString& /*label*/, const Int_t& /*spin*/)
+{
+}
+
diff --git a/src/LauResonanceInfo.cc b/src/LauResonanceInfo.cc
index 9d6f589..a9c49d9 100644
--- a/src/LauResonanceInfo.cc
+++ b/src/LauResonanceInfo.cc
@@ -1,187 +1,190 @@
// Copyright University of Warwick 2006 - 2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// Authors:
// Thomas Latham
// John Back
// Paul Harrison
/*! \file LauResonanceInfo.cc
\brief File containing implementation of LauResonanceInfo class.
*/
#include <iostream>
#include "LauParameter.hh"
#include "LauResonanceInfo.hh"
ClassImp(LauResonanceInfo)
LauResonanceInfo::LauResonanceInfo(const TString& name, const Double_t mass, const Double_t width, const Int_t spin, const Int_t charge, const LauBlattWeisskopfFactor::BlattWeisskopfCategory bwCategory, const Double_t bwRadius) :
name_(name),
sanitisedName_(""),
mass_(0),
width_(0),
spin_(spin),
charge_(charge),
bwCategory_(bwCategory),
bwRadius_(bwRadius),
conjugate_(0),
extraPars_()
{
this->sanitiseName();
+ //std::cout << "CHECKING: " << sanitisedName_+"_MASS" << std::endl;
+ //TString checkName_LASS = sanitisedName_;
+ //if ((checkName_LASS.Contains("Kst0_0_1430")) || (checkName_LASS.Contains("Kstp_0_1430"))){
mass_ = new LauParameter(sanitisedName_+"_MASS",mass,0.0,3.0*mass,kTRUE);
- mass_->secondStage(kTRUE);
width_ = new LauParameter(sanitisedName_+"_WIDTH",width,0.0,3.0*width,kTRUE);
+ mass_->secondStage(kTRUE);
width_->secondStage(kTRUE);
}
LauResonanceInfo::~LauResonanceInfo()
{
delete mass_; mass_ = 0;
delete width_; width_ = 0;
}
LauResonanceInfo::LauResonanceInfo( const LauResonanceInfo& other, const TString& newName, const Int_t newCharge ) :
name_(newName),
sanitisedName_(""),
mass_(0),
width_(0),
spin_(other.spin_),
charge_(newCharge),
bwCategory_(other.bwCategory_),
bwRadius_(other.bwRadius_),
conjugate_(0),
extraPars_()
{
this->sanitiseName();
mass_ = other.mass_->createClone( sanitisedName_+"_MASS" );
width_ = other.width_->createClone( sanitisedName_+"_WIDTH" );
for ( std::set<LauParameter*>::iterator iter = other.extraPars_.begin(); iter != other.extraPars_.end(); ++iter ) {
TString parName = (*iter)->name();
parName.Remove(0, parName.Last('_'));
parName.Prepend( sanitisedName_ );
LauParameter* par = (*iter)->createClone( parName );
extraPars_.insert( par );
}
}
LauResonanceInfo* LauResonanceInfo::createChargeConjugate()
{
Int_t newCharge = -charge_;
TString newName( name_ );
Ssiz_t index = newName.Index("+");
if ( index != -1 ) {
newName.Replace( index, 1, "-" );
} else {
index = newName.Index("-");
if ( index != -1 ) {
newName.Replace( index, 1, "+" );
}
}
LauResonanceInfo* conjugate = new LauResonanceInfo( *this, newName, newCharge );
conjugate->conjugate_ = this;
this->conjugate_ = conjugate;
return conjugate;
}
LauResonanceInfo* LauResonanceInfo::createSharedParameterRecord( const TString& name )
{
LauResonanceInfo* newinfo = new LauResonanceInfo( *this, name, charge_ );
sharedParRecords_.push_back(newinfo);
return newinfo;
}
LauParameter* LauResonanceInfo::getExtraParameter( const TString& parName )
{
LauParameter* par(0);
for ( std::set<LauParameter*>::iterator iter = extraPars_.begin(); iter != extraPars_.end(); ++iter ) {
if ( (*iter)->name() == parName ) {
par = (*iter);
}
}
return par;
}
void LauResonanceInfo::addExtraParameter( LauParameter* param )
{
bool ok = extraPars_.insert( param ).second;
if ( !ok ) {
std::cerr << "WARNING in LauResonanceInfo::addExtraParameter : parameter already present, not adding again" << std::endl;
return;
}
if ( conjugate_ != 0 ) {
conjugate_->addCloneOfExtraParameter(param);
}
for ( std::vector<LauResonanceInfo*>::iterator iter = sharedParRecords_.begin(); iter != sharedParRecords_.end(); ++iter ) {
(*iter)->addCloneOfExtraParameter(param);
}
}
void LauResonanceInfo::addCloneOfExtraParameter( LauParameter* param )
{
TString parName = param->name();
parName.Remove(0, parName.Last('_'));
parName.Prepend( sanitisedName_ );
LauParameter* cloneParam = param->createClone( parName );
extraPars_.insert( cloneParam );
}
std::ostream& operator<<( std::ostream& stream, const LauResonanceInfo& infoRecord )
{
stream << infoRecord.getName() << ": ";
stream << "mass = " << infoRecord.getMass()->value() << ", ";
stream << "width = " << infoRecord.getWidth()->value() << ", ";
stream << "spin = " << infoRecord.getSpin() << ", ";
Int_t charge = infoRecord.getCharge();
if ( charge < 0 ) {
stream << "charge = " << infoRecord.getCharge() << ", ";
} else {
stream << "charge = " << infoRecord.getCharge() << ", ";
}
stream << "BW radius = " << infoRecord.getBWRadius();
return stream;
}
void LauResonanceInfo::sanitiseName()
{
sanitisedName_ = name_;
sanitisedName_ = sanitisedName_.ReplaceAll("+","p");
sanitisedName_ = sanitisedName_.ReplaceAll("-","m");
sanitisedName_ = sanitisedName_.ReplaceAll("*","st");
sanitisedName_ = sanitisedName_.ReplaceAll("(","_");
sanitisedName_ = sanitisedName_.ReplaceAll(")","_");
sanitisedName_ = sanitisedName_.ReplaceAll("[","_");
sanitisedName_ = sanitisedName_.ReplaceAll("]","_");
sanitisedName_ = sanitisedName_.ReplaceAll("<","_");
sanitisedName_ = sanitisedName_.ReplaceAll(">","_");
sanitisedName_ = sanitisedName_.ReplaceAll("{","_");
sanitisedName_ = sanitisedName_.ReplaceAll("}","_");
sanitisedName_ = sanitisedName_.ReplaceAll(" ","_");
sanitisedName_ = sanitisedName_.ReplaceAll("$","");
sanitisedName_ = sanitisedName_.ReplaceAll("%","");
sanitisedName_ = sanitisedName_.ReplaceAll("&","");
sanitisedName_ = sanitisedName_.ReplaceAll("/","");
sanitisedName_ = sanitisedName_.ReplaceAll(":","");
sanitisedName_ = sanitisedName_.ReplaceAll(";","");
sanitisedName_ = sanitisedName_.ReplaceAll("=","");
sanitisedName_ = sanitisedName_.ReplaceAll("\\","");
sanitisedName_ = sanitisedName_.ReplaceAll("^","");
sanitisedName_ = sanitisedName_.ReplaceAll("|","");
sanitisedName_ = sanitisedName_.ReplaceAll(",","");
sanitisedName_ = sanitisedName_.ReplaceAll(".","");
sanitisedName_.Remove(TString::kBoth,'_');
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 9:22 PM (23 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3802797
Default Alt Text
(210 KB)

Event Timeline