rarDecay.cc

Go to the documentation of this file.
00001 /*****************************************************************************
00002 * Project: BaBar detector at the SLAC PEP-II B-factory
00003 * Package: RooRarFit
00004  *    File: $Id: rarDecay.cc,v 1.12 2011/06/16 13:18:49 fwilson Exp $
00005  * Authors: Lei Zhang
00006  * History:
00007  * 
00008  * Copyright (C) 2005-2012, University of California, Riverside
00009  *****************************************************************************/
00010 
00011 // -- CLASS DESCRIPTION [RooRarFit] --
00012 // This class provides BDecay/Decay model for RooRarFit
00014 //
00015 // BEGIN_HTML
00016 // This class provides BDecay/Decay model for RooRarFit
00017 // END_HTML
00018 //
00019 
00020 #include "RooRarFit/rarVersion.hh"
00021 
00022 #include "Riostream.h"
00023 
00024 #include "RooFitCore/RooArgList.hh"
00025 #include "RooFitCore/RooDataSet.hh"
00026 #include "RooFitCore/RooProdPdf.hh"
00027 #include "RooFitCore/RooRealVar.hh"
00028 #include "RooFitCore/RooStringVar.hh"
00029 
00030 #include "RooFitModels/RooBCPGenDecay.hh"
00031 #include "RooFitModels/RooBDecay.hh"
00032 #include "RooFitModels/RooDecay.hh"
00033 
00034 #include "RooRarFit/rarDecay.hh"
00035 
00036 ClassImp(rarDecay)
00037   ;
00038 
00042 rarDecay::rarDecay()
00043   : rarBasePdf(),
00044     _x(0), _tau(0), _model(0), _decayType("DoubleSided"),
00045     _dm(0), _dgamma(0), _tag(0), _w(0), _dw(0), _mu(0),
00046     _Cb(0), _Sb(0),
00047     _f0(0), _f1(0), _f2(0), _f3(0)
00048 {
00049   init();
00050 }
00051 
00064 rarDecay::rarDecay(const char *configFile, const char *configSec,
00065                    const char *configStr,
00066                    rarDatasets *theDatasets, RooDataSet *theData,
00067                    const char *name, const char *title)
00068   : rarBasePdf(configFile, configSec, configStr, theDatasets, theData,
00069                name, title),
00070     _x(0), _tau(0), _model(0), _decayType("DoubleSided"),
00071     _dm(0), _dgamma(0), _tag(0), _w(0), _dw(0), _mu(0),
00072     _Cb(0), _Sb(0),
00073     _f0(0), _f1(0), _f2(0), _f3(0)
00074 {
00075   init();
00076 }
00077 
00078 rarDecay::~rarDecay()
00079 {
00080 }
00081 
00087 void rarDecay::init()
00088 {
00089   cout<<"init of rarDecay for "<<GetName()<<":"<<endl;
00090   
00091   // first get its obs
00092   _x=(RooRealVar*)createAbsReal("x", "observable"); assert(_x);
00093   RooRealVar *x=(RooRealVar *)RooArgList(_obsSet).at(0); assert(x);
00094   // make sure theDep is not derived
00095   if (_x!=x) {
00096     cout <<"No derived dependent allowed in rarDecay"<<endl;
00097     exit(-1);
00098   }
00099   // Config pdf params
00100   _tau=createAbsReal("tau", "#tau", 1.5, 0, 10, "ps");
00101   if ("BCPGenDecay"==_pdfType||"BDecay"==_pdfType) {
00102     _dm=createAbsReal("dm", "#Delta m", 0.502, 0, 1, "ps^{-1}");
00103     _dgamma=createAbsReal("dgamma", "#Delta#Gamma", 0, "RooConstVar");
00104     //_dgamma=createAbsReal("dgamma", "#Delta#Gamma", 0);
00105     _tag=(RooAbsCategory*)createAbsReal("tag", "tag");
00106     _w=createAbsReal("w", "w", 0.2, 0., 1.);
00107     _dw=createAbsReal("dw", "dw", 0., -2., 2.);
00108     _mu=createAbsReal("mu", "#mu", 0., -2., 2.);
00109     createAbsReal("S", "S_{CP}", .7, -2., 2.);
00110     createAbsReal("C", "C_{CP}", 0., -2., 2.);
00111     // get blind status and blind string
00112     _blindStatus=readConfStr("blindStatus", "blind", getVarSec());
00113     _blindString=readConfStr("blindString", "notSet", getVarSec());
00114     if ("notSet"==_blindString) {
00115       cout<<"You must specify blinding string in section \""
00116           <<getVarSec()<<"\""<<endl;
00117       exit(-1);
00118     }
00119     // let's remove any "
00120     _blindString.ReplaceAll("\"", " ");
00121     // get blinding values
00122     TString bVStr=readConfStr("blindValues", ".2 .2 .2 .2", getVarSec());
00123     rarStrParser bVStrParser=bVStr;
00124     if (bVStrParser.nArgs()<4) {
00125       cout<<"Please specify 4 blind values"<<endl;
00126       exit(-1);
00127     }
00128     Double_t Cv=atof(bVStrParser[0]);
00129     Double_t Cs=atof(bVStrParser[1]);
00130     Double_t Sv=atof(bVStrParser[2]);
00131     Double_t Ss=atof(bVStrParser[3]);
00132     // create blind state cat
00133     RooCategory *blindCat=(RooCategory*)
00134       createAbsVar(Form("%s %s %s", "blindCat RooCategory",
00135                         "\"CP blinding category\"",
00136                         "useIdx    Unblind 0  Blind 1"));
00137     blindCat->setLabel("Blind");
00138     if ("unblind"==_blindStatus) blindCat->setLabel("Unblind");
00139     // put blindCat into ignore list
00140     addToConfStr("Ignored", blindCat->GetName(), getVarSec());
00141     // create blind variables for C and S
00142     _Cb=(RooAbsReal*)createAbsVar(Form("%s \"%s\" %f %f C blindCat kTRUE",
00143                                        "Cb RooUnblindPrecision \"C blind\"",
00144                                        _blindString.Data(), Cv, Cs));
00145     _Sb=(RooAbsReal*)createAbsVar(Form("%s \"%s\" %f %f S blindCat kTRUE",
00146                                        "Sb RooUnblindPrecision \"S blind\"",
00147                                        _blindString.Data(), Sv, Ss));
00148     if ("BDecay"==_pdfType) {
00149       cout<<" Due to bugs in PDF RooBDecay,"
00150           <<" please use RooBCPGenDecay with"<<endl
00151           <<" configStr = BCPGenDecay"<<endl
00152           <<" in config section ["<<_configSec<<"]"<<endl;
00153       exit(-1);
00154       
00155       // creat f0, f1, f2, f3
00156       _f0=(RooAbsReal*)
00157         createAbsVar(Form("%s %s %s", "f0 RooFormulaVar",
00158                           "\"(1-@0*@2+@3*@0*(1.-2.*@1))\"", "tag w dw mu"));
00159       _f1=(RooAbsReal*)createAbsVar("f1 RooConstVar \"f1\" 0.");
00160       //_f1=createAbsReal("f1", "f1", 0);
00161       _f2=(RooAbsReal*)
00162         createAbsVar(Form("%s %s %s", "f2 RooFormulaVar",
00163                           "\"-1.*(@0*(1-2*@1)+@3*(1.-@0*@2))*@4\"",
00164                           "tag w dw mu Cb"));
00165       _f3=(RooAbsReal*)
00166         createAbsVar(Form("%s %s %s", "f3 RooFormulaVar",
00167                           "\"(@0*(1-2*@1)+@3*(1.-@0*@2))*@4\"",
00168                           "tag w dw mu Sb"));
00169     }
00170   }
00171   _params.Print("v");
00172   
00173   // resolution model
00174   _model=createPdfs("model", &_xPdfList);
00175   // let's make sure the default for model is noPdfFit noPdfPlot
00176   _model->setControlBit("noPdfFit", "pdfFit");
00177   _model->setControlBit("noPdfPlot", "pdfPlot");
00178     
00179   // parse the decay type
00180   RooBCPGenDecay::DecayType bcpGenDecayType=RooBCPGenDecay::DoubleSided;
00181   RooBDecay::DecayType bDecayType=RooBDecay::DoubleSided;
00182   RooDecay::DecayType decayType=RooDecay::DoubleSided;
00183   _decayType=readConfStr("decayType", "DoubleSided", getVarSec());
00184   if ("SingleSided"==_decayType) {
00185     decayType=RooDecay::SingleSided;
00186     bDecayType=RooBDecay::SingleSided;
00187     bcpGenDecayType=RooBCPGenDecay::SingleSided;
00188   } else if ("DoubleSided"==_decayType) {
00189     decayType=RooDecay::DoubleSided;
00190     bDecayType=RooBDecay::DoubleSided;
00191     bcpGenDecayType=RooBCPGenDecay::DoubleSided;
00192   } else if ("Flipped"==_decayType) {
00193     decayType=RooDecay::Flipped;
00194     bDecayType=RooBDecay::Flipped;
00195     bcpGenDecayType=RooBCPGenDecay::Flipped;
00196   }
00197   
00198   // create pdf
00199   if ("BCPGenDecay"==_pdfType) {
00200     _thePdf=new
00201       RooBCPGenDecay(Form("the_%s",GetName()), _pdfType+" "+GetTitle(),
00202                      *_x, *_tag, *_tau, *_dm, *_w, *_Cb, *_Sb, *_dw, *_mu,
00203                      *((RooResolutionModel*)_model->getPdf()),bcpGenDecayType);
00204   } else if ("BDecay"==_pdfType) {
00205     _thePdf=new RooBDecay(Form("the_%s",GetName()), _pdfType+" "+GetTitle(),
00206                           *_x, *_tau, *_dgamma, *_f0, *_f1, *_f2, *_f3, *_dm,
00207                           *((RooResolutionModel*)_model->getPdf()),bDecayType);
00208   } else {
00209     _thePdf=new RooDecay(Form("the_%s",GetName()), _pdfType+" "+GetTitle(),
00210                          *_x, *_tau,
00211                          *((RooResolutionModel*)_model->getPdf()), decayType);
00212   }
00213 }
00214 
00219 RooAbsPdf *rarDecay::getProtGen()
00220 {
00221   if (_theProtGen) return _theProtGen;
00222   // do we have model generator?
00223   if (_model) {
00224     RooAbsPdf *modelGen=_model->getProtGen();
00225     if (!_model->protGenIsDummy()) _protGenPdfs.add(*modelGen);
00226   }
00227   // call super class' getProtGen
00228   return rarBasePdf::getProtGen();
00229 }

Generated on 30 Oct 2013 for RooRarFit by  doxygen 1.4.7