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_t> 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_t> mainMeas(nbins);
184 std::vector<Double_t> 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];
210 x =
new RooRealVar(varName, varName, value, 0, maximum );
211 if(
x->getMax() < value )
212 x->setMax( max(
x->getMax(), 10*value ) );
234 TList observablesCollection;
237 std::vector<Double_t> xForTree(nbins);
238 std::vector<Double_t> yForTree(nbins);
241 for(
Int_t i=0; i<nbins; ++i){
242 std::stringstream str;
248 Double_t _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()).c_str())->setMax( 1.2*back[i]+MaxSigma*(sqrt(back[i])+back[i]*back_syst[i]) );
276 ws->var((
"b"+str.str()).c_str())->setVal( back[i] );
314 TList observablesCollection;
318 std::vector<Double_t> xForTree(nbins);
319 std::vector<Double_t> yForTree(nbins);
323 for(
Int_t i=0; i<nbins; ++i){
324 std::stringstream str;
328 Double_t back_syst = 1./sqrt(sideband[i]);
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()).c_str())->setMax( 1.2*back+MaxSigma*(sqrt(back)+back*back_syst) );
359 ws->var((
"b"+str.str()).c_str())->setVal( back );
void setConstant(Bool_t value=kTRUE)
Double_t 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.
virtual TObject * clone(const char *newname) const
A factory for building PDFs and data for a number counting combination.
virtual ~NumberCountingPdfFactory()
destructor
NumberCountingPdfFactory()
constructor
void AddExpDataWithSideband(Double_t *sigExp, Double_t *bkgExp, Double_t *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...
void AddModel(Double_t *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.
RooRealVar * SafeObservableCreation(RooWorkspace *ws, const char *varName, Double_t value)
need to be careful here that the range of observable in the dataset is consistent with the one in the...
void AddData(Double_t *mainMeas, Double_t *bkgMeas, Double_t *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_t *sigExp, Double_t *bkgExp, Double_t *db, Int_t nbins, RooWorkspace *ws, const char *dsName="ExpectedNumberCountingData")
Arguments are an array of expected signal, expected background, and relative background uncertainty (...
void AddDataWithSideband(Double_t *mainMeas, Double_t *sideband, Double_t *tau, Int_t nbins, RooWorkspace *ws, const char *dsName="ExpectedNumberCountingData")
Arguments are an array of expected signal, expected background, and relative background uncertainty (...
The RooWorkspace is a persistable container for RooFit projects.
virtual void Add(TObject *obj)
virtual const char * GetName() const
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.