67 TList likelihoodFactors;
72 new RooRealVar(muName,
"masterSignal",1., 0., 3.);
76 for(
Int_t i=0; i<nbins; ++i){
78 std::stringstream str;
81 new RooRealVar((
"expected_s"+str.str()).c_str(),(
"expected_s"+str.str()).c_str(),sig[i], 0., 2*sig[i]);
85 new RooProduct((
"s"+str.str()).c_str(),(
"s"+str.str()).c_str(),
RooArgSet(*masterSignal, *expectedSignal));
88 new RooRealVar((
"b"+str.str()).c_str(),(
"b"+str.str()).c_str(), .5, 0.,1.);
90 new RooRealVar((
"tau"+str.str()).c_str(),(
"tau"+str.str()).c_str(), .5, 0., 1.);
94 new RooAddition((
"splusb"+str.str()).c_str(),(
"s"+str.str()+
"+"+
"b"+str.str()).c_str(),
99 new RooRealVar((
"x"+str.str()).c_str(),(
"x"+str.str()).c_str(), 0.5 , 0., 1.);
101 new RooRealVar((
"y"+str.str()).c_str(),(
"y"+str.str()).c_str(), 0.5, 0., 1.);
105 new RooPoisson((
"sigRegion"+str.str()).c_str(),(
"sigRegion"+str.str()).c_str(), *
x,*splusb);
109 new RooPoisson((
"sideband"+str.str()).c_str(),(
"sideband"+str.str()).c_str(), *
y,*bTau,
true);
111 likelihoodFactors.
Add(sigRegion);
112 likelihoodFactors.
Add(sideband);
116 RooArgSet likelihoodFactorSet(likelihoodFactors);
117 RooProdPdf joint(pdfName,
"joint", likelihoodFactorSet );
135 std::vector<double> mainMeas(nbins);
138 for(
Int_t i=0; i<nbins; ++i){
139 mainMeas[i] = sig[i] + back[i];
141 return AddData(&mainMeas[0], back, back_syst, nbins, ws, dsName);
152 std::vector<double> mainMeas(nbins);
153 std::vector<double> sideband(nbins);
154 for(
Int_t i=0; i<nbins; ++i){
155 mainMeas[i] = sigExp[i] + backExp[i];
156 sideband[i] = backExp[i]*tau[i];
177 double value,
double maximum)
181 x =
new RooRealVar(varName, varName, value, 0, maximum );
182 if(
x->getMax() < value )
183 x->setMax( std::max(
x->getMax(), 10*value ) );
199 TList observablesCollection;
202 std::vector<double> xForTree(nbins);
203 std::vector<double> yForTree(nbins);
206 for(
Int_t i=0; i<nbins; ++i){
207 std::stringstream str;
212 double err = back_syst[i];
213 double _tau = (1.0 + sqrt(1 + 4 *
err *
err))/ (2. *
err *
err)/ back[i];
217 oocoutW(ws,ObjectHandling) <<
"NumberCountingPdfFactory: changed value of " << tau->
GetName() <<
" to " << tau->
getVal() <<
218 " to be consistent with background and its uncertainty. " <<
219 " Also stored these values of tau into workspace with name . " << (std::string{tau->
GetName()}+dsName).c_str() <<
220 " if you test with a different dataset, you should adjust tau appropriately.\n"<< std::endl;
222 ws->
import(*(
static_cast<RooRealVar*
>(tau->
clone( (std::string{tau->GetName()}+dsName).c_str() )) ) );
231 observablesCollection.
Add(
x);
232 observablesCollection.
Add(
y);
234 xForTree[i] = mainMeas[i];
235 yForTree[i] = back[i]*_tau;
237 tree->
Branch((
"x"+str.str()).c_str(), &xForTree[i] ,(
"x"+str.str()+
"/D").c_str());
238 tree->
Branch((
"y"+str.str()).c_str(), &yForTree[i] ,(
"y"+str.str()+
"/D").c_str());
240 ws->
var(
"b"+str.str())->
setMax( 1.2*back[i]+MaxSigma*(sqrt(back[i])+back[i]*back_syst[i]) );
241 ws->
var(
"b"+str.str())->
setVal( back[i] );
271 TList observablesCollection;
275 std::vector<double> xForTree(nbins);
276 std::vector<double> yForTree(nbins);
280 for(
Int_t i=0; i<nbins; ++i){
281 std::stringstream str;
284 double _tau = tauForTree[i];
285 double back_syst = 1./sqrt(sideband[i]);
286 double back = (sideband[i]/_tau);
291 oocoutW(ws,ObjectHandling) <<
"NumberCountingPdfFactory: changed value of " << tau->
GetName() <<
" to " << tau->
getVal() <<
292 " to be consistent with background and its uncertainty. " <<
293 " Also stored these values of tau into workspace with name . " << (std::string{tau->
GetName()}+dsName).c_str() <<
294 " if you test with a different dataset, you should adjust tau appropriately.\n"<< std::endl;
296 ws->
import(*(
static_cast<RooRealVar*
>(tau->
clone( (std::string{tau->GetName()}+dsName).c_str() )) ) );
306 observablesCollection.
Add(
x);
307 observablesCollection.
Add(
y);
309 xForTree[i] = mainMeas[i];
310 yForTree[i] = sideband[i];
312 tree->
Branch((
"x"+str.str()).c_str(), &xForTree[i] ,(
"x"+str.str()+
"/D").c_str());
313 tree->
Branch((
"y"+str.str()).c_str(), &yForTree[i] ,(
"y"+str.str()+
"/D").c_str());
315 ws->
var(
"b"+str.str())->
setMax( 1.2*back+MaxSigma*(sqrt(back)+back*back_syst) );
321 RooArgList observableList{observablesCollection};
int Int_t
Signed integer 4 bytes (int).
void setConstant(bool value=true)
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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.
Container class to hold unbinned data.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
Efficient implementation of a product of PDFs of the form.
Represents the product of a given set of RooAbsReal objects.
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
TObject * clone(const char *newname=nullptr) const override
void setMax(const char *name, double value, bool shared=true)
Set maximum of name range to given value.
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.
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 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 (...
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 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...
Persistable container for RooFit projects.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
void Add(TObject *obj) override
const char * GetName() const override
Returns name of object.
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
RooCmdArg Import(const char *state, TH1 &histo)