85 const char* pdfName,
const char* muName) {
92 TList likelihoodFactors;
97 new RooRealVar(muName,
"masterSignal",1., 0., 3.);
101 for(
Int_t i=0; i<nbins; ++i){
103 std::stringstream str;
106 new RooRealVar((
"expected_s"+str.str()).c_str(),(
"expected_s"+str.str()).c_str(),sig[i], 0., 2*sig[i]);
110 new RooProduct((
"s"+str.str()).c_str(),(
"s"+str.str()).c_str(),
RooArgSet(*masterSignal, *expectedSignal));
113 new RooRealVar((
"b"+str.str()).c_str(),(
"b"+str.str()).c_str(), .5, 0.,1.);
115 new RooRealVar((
"tau"+str.str()).c_str(),(
"tau"+str.str()).c_str(), .5, 0., 1.);
119 new RooAddition((
"splusb"+str.str()).c_str(),(
"s"+str.str()+
"+"+
"b"+str.str()).c_str(),
124 new RooRealVar((
"x"+str.str()).c_str(),(
"x"+str.str()).c_str(), 0.5 , 0., 1.);
126 new RooRealVar((
"y"+str.str()).c_str(),(
"y"+str.str()).c_str(), 0.5, 0., 1.);
130 new RooPoisson((
"sigRegion"+str.str()).c_str(),(
"sigRegion"+str.str()).c_str(), *
x,*splusb);
134 new RooPoisson((
"sideband"+str.str()).c_str(),(
"sideband"+str.str()).c_str(), *
y,*bTau,
true);
136 likelihoodFactors.
Add(sigRegion);
137 likelihoodFactors.
Add(sideband);
141 RooArgSet likelihoodFactorSet(likelihoodFactors);
142 RooProdPdf joint(pdfName,
"joint", likelihoodFactorSet );
163 std::vector<double> mainMeas(nbins);
166 for(
Int_t i=0; i<nbins; ++i){
167 mainMeas[i] = sig[i] + back[i];
169 return AddData(&mainMeas[0], back, back_syst, nbins, ws, dsName);
183 std::vector<double> mainMeas(nbins);
184 std::vector<double> sideband(nbins);
185 for(
Int_t i=0; i<nbins; ++i){
186 mainMeas[i] = sigExp[i] + backExp[i];
187 sideband[i] = backExp[i]*tau[i];
207 double value,
double maximum) {
212 x->setMax( max(
x->getMax(), 10*
value ) );
234 TList observablesCollection;
237 std::vector<double> xForTree(nbins);
238 std::vector<double> yForTree(nbins);
241 for(
Int_t i=0; i<nbins; ++i){
242 std::stringstream str;
247 double err = back_syst[i];
248 double _tau = (1.0 + sqrt(1 + 4 * err * err))/ (2. * err * err)/ back[i];
253 " to be consistent with background and its uncertainty. " <<
254 " Also stored these values of tau into workspace with name . " << (string(tau->
GetName())+string(dsName)).c_str() <<
255 " if you test with a different dataset, you should adjust tau appropriately.\n"<< endl;
266 observablesCollection.
Add(
x);
267 observablesCollection.
Add(
y);
269 xForTree[i] = mainMeas[i];
270 yForTree[i] = back[i]*_tau;
272 tree->Branch((
"x"+str.str()).c_str(), &xForTree[i] ,(
"x"+str.str()+
"/D").c_str());
273 tree->Branch((
"y"+str.str()).c_str(), &yForTree[i] ,(
"y"+str.str()+
"/D").c_str());
275 ws->
var(
"b"+str.str())->
setMax( 1.2*back[i]+MaxSigma*(sqrt(back[i])+back[i]*back_syst[i]) );
276 ws->
var(
"b"+str.str())->
setVal( back[i] );
314 TList observablesCollection;
318 std::vector<double> xForTree(nbins);
319 std::vector<double> yForTree(nbins);
323 for(
Int_t i=0; i<nbins; ++i){
324 std::stringstream str;
327 double _tau = tauForTree[i];
328 double back_syst = 1./sqrt(sideband[i]);
329 double back = (sideband[i]/_tau);
335 " to be consistent with background and its uncertainty. " <<
336 " Also stored these values of tau into workspace with name . " << (string(tau->
GetName())+string(dsName)).c_str() <<
337 " if you test with a different dataset, you should adjust tau appropriately.\n"<< endl;
349 observablesCollection.
Add(
x);
350 observablesCollection.
Add(
y);
352 xForTree[i] = mainMeas[i];
353 yForTree[i] = sideband[i];
355 tree->Branch((
"x"+str.str()).c_str(), &xForTree[i] ,(
"x"+str.str()+
"/D").c_str());
356 tree->Branch((
"y"+str.str()).c_str(), &yForTree[i] ,(
"y"+str.str()+
"/D").c_str());
358 ws->
var(
"b"+str.str())->
setMax( 1.2*back+MaxSigma*(sqrt(back)+back*back_syst) );
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
void setConstant(bool value=true)
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooDataSet is a container class to hold unbinned data.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooProdPdf is an efficient implementation of a product of PDFs of the form.
A RooProduct represents the product of a given set of RooAbsReal objects.
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
TObject * clone(const char *newname) const override
void setMax(const char *name, double value)
Set maximum of name range to given value.
A factory for building PDFs and data for a number counting combination.
virtual ~NumberCountingPdfFactory()
destructor
NumberCountingPdfFactory()
need one for expected and one for observed
void AddExpData(double *sigExp, double *bkgExp, double *db, Int_t nbins, RooWorkspace *ws, const char *dsName="ExpectedNumberCountingData")
Arguments are an array of expected signal, expected background, and relative background uncertainty (...
void AddData(double *mainMeas, double *bkgMeas, double *db, Int_t nbins, RooWorkspace *ws, const char *dsName="NumberCountingData")
Arguments are an array of results from a main measurement, a measured background, and relative backgr...
void AddExpDataWithSideband(double *sigExp, double *bkgExp, double *tau, Int_t nbins, RooWorkspace *ws, const char *dsName="NumberCountingData")
Arguments are an array of expected signal, expected background, and relative ratio of background expe...
RooRealVar * SafeObservableCreation(RooWorkspace *ws, const char *varName, double value)
need to be careful here that the range of observable in the dataset is consistent with the one in the...
void AddDataWithSideband(double *mainMeas, double *sideband, double *tau, Int_t nbins, RooWorkspace *ws, const char *dsName="ExpectedNumberCountingData")
Arguments are an array of expected signal, expected background, and relative background uncertainty (...
void AddModel(double *sigExp, Int_t nchan, RooWorkspace *ws, const char *pdfName="CombinedPdf", const char *masterSignalName="masterSignal")
This method produces a PDF for N channels with uncorrelated background uncertainty.
The RooWorkspace is a persistable container for RooFit projects.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
void Add(TObject *obj) override
const char * GetName() const override
Returns name of object.
A TTree represents a columnar dataset.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.