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];
189 return AddDataWithSideband(&mainMeas[0], &sideband[0],
tau, nbins,
ws, dsName);
198 return SafeObservableCreation(
ws, varName, value, 10.*value);
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;
236 TTree*
tree =
new TTree();
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];
250 RooRealVar*
tau = SafeObservableCreation(
ws, (
"tau"+str.str()).c_str(), _tau );
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;
257 ws->import(*((
RooRealVar*)
tau->clone( (
string(
tau->GetName())+
string(dsName)).c_str() ) ) );
261 RooRealVar*
x = SafeObservableCreation(
ws, (
"x"+str.str()).c_str(), mainMeas[i]);
264 RooRealVar*
y = SafeObservableCreation(
ws, (
"y"+str.str()).c_str(), back[i]*_tau );
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;
316 TTree*
tree =
new TTree();
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;
332 RooRealVar*
tau = SafeObservableCreation(
ws, (
"tau"+str.str()).c_str(), _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;
339 ws->import(*((
RooRealVar*)
tau->clone( (
string(
tau->GetName())+
string(dsName)).c_str() ) ) );
343 RooRealVar*
x = SafeObservableCreation(
ws, (
"x"+str.str()).c_str(), mainMeas[i]);
346 RooRealVar*
y = SafeObservableCreation(
ws, (
"y"+str.str()).c_str(), sideband[i] );
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 );
RooProdPdf is an efficient implementation of a product of PDFs of the form.
A factory for building PDFs and data for a number counting combination.
static RooMsgService & instance()
Return reference to singleton instance.
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 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...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t tau
RooRealVar represents a fundamental (non-derived) real valued object.
void setConstant(Bool_t value=kTRUE)
void setGlobalKillBelow(RooFit::MsgLevel level)
NumberCountingPdfFactory()
constructor
RooDataSet is a container class to hold unbinned data.
RooProduct a RooAbsReal implementation that represent the product of a given set of other RooAbsReal ...
Namespace for the RooStats classes.
virtual ~NumberCountingPdfFactory()
destructor
static constexpr double s
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 (...
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...
virtual void Add(TObject *obj)
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...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
RooAddition calculates the sum of a set of RooAbsReal terms, or when constructed with two sets...
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.
The RooWorkspace is a persistable container for RooFit projects.