1 |
buchmann |
1.1 |
#include <iostream>
|
2 |
|
|
|
3 |
buchmann |
1.2 |
#include <RooRealVar.h>
|
4 |
|
|
#include <RooArgSet.h>
|
5 |
|
|
#include <RooDataSet.h>
|
6 |
buchmann |
1.4 |
#include <RooMCStudy.h>
|
7 |
|
|
#include <RooCategory.h>
|
8 |
|
|
|
9 |
buchmann |
1.5 |
#include <RooPlot.h>
|
10 |
|
|
#include <RooSimultaneous.h>
|
11 |
|
|
#include <RooAddPdf.h>
|
12 |
|
|
#include <RooFitResult.h>
|
13 |
|
|
#include <RooVoigtian.h>
|
14 |
|
|
#include <RooMsgService.h>
|
15 |
|
|
|
16 |
buchmann |
1.3 |
#include <RooStats/ModelConfig.h>
|
17 |
|
|
#include "RooStats/ProfileLikelihoodCalculator.h"
|
18 |
|
|
#include "RooStats/LikelihoodInterval.h"
|
19 |
|
|
#include "RooStats/HypoTestResult.h"
|
20 |
|
|
#include "RooStats/SimpleLikelihoodRatioTestStat.h"
|
21 |
|
|
#include "RooStats/ProfileLikelihoodTestStat.h"
|
22 |
|
|
#include "RooStats/HybridCalculatorOriginal.h"
|
23 |
|
|
#include "RooStats/HypoTestInverterOriginal.h"
|
24 |
|
|
|
25 |
buchmann |
1.5 |
//#include "ParametrizedEdge.C"
|
26 |
|
|
#include "/shome/pablom/RooFit/Pdfs/RooSUSYTPdf.cxx"
|
27 |
|
|
#include "/shome/pablom/RooFit/Pdfs/RooSUSYBkgPdf.cxx"
|
28 |
|
|
|
29 |
buchmann |
1.2 |
|
30 |
buchmann |
1.1 |
using namespace std;
|
31 |
|
|
using namespace PlottingSetup;
|
32 |
|
|
|
33 |
|
|
|
34 |
buchmann |
1.2 |
|
35 |
|
|
|
36 |
buchmann |
1.1 |
ShapeDroplet LimitsFromEdge(float low_fullCLs, float high_CLs, TTree *events, string addcut, string name, string mcjzb, string datajzb, vector<float> jzbbins, float jzbpeakerrormc, float jzbpeakerrordata) {
|
37 |
|
|
write_error(__FUNCTION__,"Not implemented edge limits yet (returning crap)");
|
38 |
|
|
ShapeDroplet beta;beta.observed=-12345;beta.SignalIntegral=1;return beta;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
void PrepareEdgeShapes(string mcjzb, string datajzb, vector<float> jzbbins, float jzbpeakerrordata) {
|
43 |
|
|
write_error(__FUNCTION__,"Not implemented edge shape storage yet");
|
44 |
|
|
}
|
45 |
|
|
|
46 |
|
|
|
47 |
buchmann |
1.2 |
///------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
namespace EdgeFitter {
|
51 |
|
|
|
52 |
|
|
void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, float jzb_cut, int icut, int is_data, TCut cut, TTree*);
|
53 |
|
|
void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, vector<float> jzb_cut, int is_data, TCut cut, TTree*);
|
54 |
buchmann |
1.4 |
void getMedianLimit(RooWorkspace *ws,vector<RooDataSet*> theToys,float &median,float &sigmaDown, float &sigmaUp, float &twoSigmaDown, float &twoSigmaUp);
|
55 |
buchmann |
1.2 |
void InitializeVariables(float _mllmin, float _mllmax, float _jzbmax, TCut _cut);
|
56 |
|
|
void PrepareDatasets(int);
|
57 |
buchmann |
1.5 |
void DoFit(int is_data, float jzb_cut);
|
58 |
buchmann |
1.2 |
string RandomStorageFile();
|
59 |
|
|
Yield Get_Z_estimate(float,int);
|
60 |
|
|
Yield Get_T_estimate(float,int);
|
61 |
buchmann |
1.4 |
float calcExclusion(RooWorkspace *ws, RooDataSet *data = NULL);
|
62 |
|
|
void prepareLimits(RooWorkspace *ws);
|
63 |
|
|
vector<RooDataSet*> generateToys(RooWorkspace *ws, int nToys);
|
64 |
|
|
void prepareLimits(RooWorkspace *ws, bool ComputeBands);
|
65 |
|
|
TGraph* prepareLM(float mass, float nEv);
|
66 |
buchmann |
1.2 |
|
67 |
|
|
float jzbmax;
|
68 |
|
|
float mllmin;
|
69 |
|
|
float mllmax;
|
70 |
|
|
TCut cut;
|
71 |
|
|
|
72 |
|
|
RooDataSet* AllData;
|
73 |
|
|
RooDataSet* eeSample;
|
74 |
|
|
RooDataSet* mmSample;
|
75 |
|
|
RooDataSet* emSample;
|
76 |
|
|
|
77 |
|
|
bool MarcoDebug;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
buchmann |
1.4 |
TGraph* EdgeFitter::prepareLM(float mass, float nEv) {
|
81 |
|
|
float massLM[1];
|
82 |
|
|
massLM[0]=mass;
|
83 |
|
|
float accEffLM[1];
|
84 |
|
|
accEffLM[0]=nEv/PlottingSetup::luminosity;
|
85 |
|
|
TGraph *lm = new TGraph(1, massLM, accEffLM);
|
86 |
|
|
lm->GetXaxis()->SetNoExponent(true);
|
87 |
|
|
lm->GetXaxis()->SetTitle("m_{cut} [GeV]");
|
88 |
|
|
lm->GetYaxis()->SetTitle("#sigma #times A [pb] 95% CL UL");
|
89 |
|
|
lm->GetXaxis()->SetLimits(0.,300.);
|
90 |
|
|
lm->GetYaxis()->SetRangeUser(0.,0.08);
|
91 |
|
|
lm->SetMarkerStyle(34);
|
92 |
|
|
lm->SetMarkerColor(kRed);
|
93 |
|
|
return lm;
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
vector<RooDataSet*> EdgeFitter::generateToys(RooWorkspace *ws, int nToys) {
|
97 |
|
|
ws->var("nSig")->setVal(0.);
|
98 |
|
|
ws->var("nSig")->setConstant(true);
|
99 |
|
|
RooFitResult* fit = ws->pdf("combModel")->fitTo(*ws->data("data_obs"),RooFit::Save());
|
100 |
|
|
vector<RooDataSet*> theToys;
|
101 |
|
|
|
102 |
|
|
RooMCStudy mcEE(*ws->pdf("combModel"),RooArgSet(*ws->var("inv")),RooFit::Slice(*ws->cat("cat"),"EE"));
|
103 |
|
|
mcEE.generate(nToys,44,true);
|
104 |
|
|
RooMCStudy mcMM(*ws->pdf("combModel"),RooArgSet(*ws->var("inv")),RooFit::Slice(*ws->cat("cat"),"MM"));
|
105 |
|
|
mcMM.generate(nToys,44,true);
|
106 |
|
|
RooMCStudy mcOSOF(*ws->pdf("combModel"),RooArgSet(*ws->var("inv")),RooFit::Slice(*ws->cat("cat"),"OSOF"));
|
107 |
|
|
mcOSOF.generate(nToys,44,true);
|
108 |
|
|
|
109 |
|
|
RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}");
|
110 |
|
|
RooRealVar id1("id1","id1",0,1,"GeV/c^{2}");
|
111 |
|
|
RooRealVar id2("id2","id2",0,1,"GeV/c^{2}");
|
112 |
|
|
RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c");
|
113 |
|
|
RooRealVar weight("weight","weight",0,1000,"");
|
114 |
|
|
RooArgSet observables(mll,jzb,id1,id2,weight);
|
115 |
|
|
|
116 |
|
|
for(int i=0;i<nToys;i++) {
|
117 |
|
|
RooDataSet* toyEE = (RooDataSet*)mcEE.genData(i);
|
118 |
|
|
RooDataSet* toyMM = (RooDataSet*)mcMM.genData(i);
|
119 |
|
|
RooDataSet* toyOSOF = (RooDataSet*)mcOSOF.genData(i);
|
120 |
|
|
stringstream toyname;
|
121 |
|
|
toyname << "theToy_" << i;
|
122 |
|
|
write_warning(__FUNCTION__,"Problem while adding toys");
|
123 |
|
|
// RooDataSet *toyData = RooDataSet(toyname.str(),toyname.str(),observables,RooFit::Index(ws->cat("cat")),RooFit::Import("OSOF",*toyOSOF),RooFit::Import("EE",*toyEE),RooFit::Import("MM",*toyMM));
|
124 |
|
|
// theToys.push_back(toyData);
|
125 |
|
|
}
|
126 |
|
|
ws->var("nSig")->setVal(17.0);
|
127 |
|
|
ws->var("nSig")->setConstant(false);
|
128 |
|
|
return theToys;
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
void EdgeFitter::getMedianLimit(RooWorkspace *ws,vector<RooDataSet*> theToys,float &median,float &sigmaDown, float &sigmaUp, float &twoSigmaDown, float &twoSigmaUp) {
|
132 |
|
|
TH1F *gauLimit = new TH1F("gausLimit","gausLimit",60,0.,80./PlottingSetup::luminosity);
|
133 |
|
|
vector<float> theLimits;
|
134 |
|
|
for(int itoy=0;itoy<theToys.size();itoy++) {
|
135 |
|
|
float theLimit = calcExclusion(ws,theToys[itoy]);
|
136 |
|
|
if(theLimit > 0 ) gauLimit->Fill(theLimit);
|
137 |
|
|
}
|
138 |
|
|
const Int_t nQ = 4;
|
139 |
|
|
Double_t yQ[nQ] = {0.,0.,0.,0.};
|
140 |
|
|
Double_t xQ[nQ] = {0.022750132,0.1586552539,0.84134474609999998,0.977249868};
|
141 |
|
|
gauLimit->GetQuantiles(nQ,yQ,xQ);
|
142 |
|
|
median = gauLimit->GetMean();
|
143 |
|
|
// median = median1(gauLimit);
|
144 |
|
|
twoSigmaDown = abs(yQ[0]-median);
|
145 |
|
|
sigmaDown = abs(yQ[1]-median);
|
146 |
|
|
sigmaUp = abs(yQ[2]-median);
|
147 |
|
|
twoSigmaUp = abs(yQ[3]-median);
|
148 |
|
|
cout << median * PlottingSetup::luminosity << " " << sigmaUp * PlottingSetup::luminosity << endl;
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
void EdgeFitter::prepareLimits(RooWorkspace *ws, bool ComputeBands) {
|
152 |
|
|
if(ComputeBands) {
|
153 |
|
|
vector<RooDataSet*> theToys = EdgeFitter::generateToys(ws,50);
|
154 |
|
|
vector<float> medVals;
|
155 |
|
|
vector<float> medLimits;
|
156 |
|
|
vector<float> sigmaLimitsDown;
|
157 |
|
|
vector<float> sigmaLimitsUp;
|
158 |
|
|
vector<float> twoSigmaLimitsDown;
|
159 |
|
|
vector<float> twoSigmaLimitsUp;
|
160 |
|
|
for(int i=20;i<=320;i+=40) {
|
161 |
|
|
ws->var("nSig")->setVal(10.0);
|
162 |
|
|
medVals.push_back((float)i);
|
163 |
|
|
ws->var("m0")->setVal((float)i);
|
164 |
|
|
ws->var("m0")->setConstant(true);
|
165 |
|
|
float Smedian,SsigmaDown,SsigmaUp,StwoSigmaDown,StwoSigmaUp;
|
166 |
|
|
EdgeFitter::getMedianLimit(ws,theToys,Smedian,SsigmaDown,SsigmaUp,StwoSigmaDown,StwoSigmaUp);
|
167 |
|
|
medLimits.push_back(Smedian);
|
168 |
|
|
sigmaLimitsDown.push_back(SsigmaDown);
|
169 |
|
|
sigmaLimitsUp.push_back(SsigmaUp);
|
170 |
|
|
twoSigmaLimitsDown.push_back(StwoSigmaDown);
|
171 |
|
|
twoSigmaLimitsUp.push_back(StwoSigmaUp);
|
172 |
|
|
}
|
173 |
|
|
write_warning(__FUNCTION__,"Still need to store limits");
|
174 |
|
|
} else {
|
175 |
|
|
vector<float> theVals;
|
176 |
|
|
vector<float> theLimits;
|
177 |
|
|
for(int i=20;i<300;i+=5) {
|
178 |
|
|
ws->var("nSig")->setVal(0.0);
|
179 |
|
|
theVals.push_back((float)i);
|
180 |
|
|
ws->var("m0")->setVal((float)i);
|
181 |
|
|
ws->var("m0")->setConstant(true);
|
182 |
|
|
theLimits.push_back(calcExclusion(ws));
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
for(int i=0;i<theLimits.size();i++) {
|
186 |
|
|
if((theLimits[i]<2.0/PlottingSetup::luminosity)||(theLimits[i]>40.0/PlottingSetup::luminosity)) {
|
187 |
|
|
cout << i << " : " << theVals[i] << endl;
|
188 |
|
|
theLimits[i] = (theLimits[i+2]+theLimits[i-2])/2.0;
|
189 |
|
|
write_warning(__FUNCTION__,"Need to store limits");
|
190 |
|
|
}
|
191 |
|
|
write_warning(__FUNCTION__,"Need to store limits");
|
192 |
|
|
}
|
193 |
|
|
}
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
float EdgeFitter::calcExclusion(RooWorkspace *ws, RooDataSet *data) {
|
198 |
buchmann |
1.3 |
RooRealVar mu("mu","nSig",0,10000,"");
|
199 |
|
|
RooArgSet poi = RooArgSet(mu);
|
200 |
|
|
RooArgSet *nullParams = (RooArgSet*)poi.snapshot();
|
201 |
|
|
nullParams->setRealValue("nSig",0);
|
202 |
|
|
RooStats::ModelConfig *model = new RooStats::ModelConfig();
|
203 |
|
|
model->SetWorkspace(*ws);
|
204 |
|
|
model->SetPdf("combModel");
|
205 |
|
|
model->SetParametersOfInterest(poi);
|
206 |
buchmann |
1.4 |
if(!data) data = (RooDataSet*)ws->data("data_obs");
|
207 |
buchmann |
1.3 |
|
208 |
|
|
RooStats::ProfileLikelihoodCalculator plc(*data, *model);
|
209 |
|
|
plc.SetNullParameters(*nullParams);
|
210 |
|
|
plc.SetTestSize(0.05);
|
211 |
|
|
RooStats::LikelihoodInterval* interval = plc.GetInterval();
|
212 |
|
|
RooStats::HypoTestResult *htr = plc.GetHypoTest();
|
213 |
|
|
double theLimit = interval->UpperLimit( mu );
|
214 |
|
|
cout << "Significance " << htr->Significance() << endl;
|
215 |
|
|
|
216 |
|
|
ws->defineSet("obs","nB");
|
217 |
|
|
ws->defineSet("poi","nSig");
|
218 |
|
|
|
219 |
|
|
RooStats::ModelConfig b_model = RooStats::ModelConfig("B_model", ws);
|
220 |
|
|
b_model.SetPdf(*ws->pdf("combModel"));
|
221 |
|
|
b_model.SetObservables(*ws->set("obs"));
|
222 |
|
|
b_model.SetParametersOfInterest(*ws->set("poi"));
|
223 |
|
|
ws->var("nSig")->setVal(0.0); //# important!
|
224 |
|
|
b_model.SetSnapshot(*ws->set("poi"));
|
225 |
|
|
|
226 |
|
|
RooStats::ModelConfig sb_model = RooStats::ModelConfig("S+B_model", ws);
|
227 |
|
|
sb_model.SetPdf(*ws->pdf("combModel"));
|
228 |
|
|
sb_model.SetObservables(*ws->set("obs"));
|
229 |
|
|
sb_model.SetParametersOfInterest(*ws->set("poi"));
|
230 |
|
|
ws->var("nSig")->setVal(64.0); //# important!
|
231 |
|
|
sb_model.SetSnapshot(*ws->set("poi"));
|
232 |
|
|
|
233 |
|
|
RooStats::SimpleLikelihoodRatioTestStat slrts = RooStats::SimpleLikelihoodRatioTestStat(*b_model.GetPdf(),*sb_model.GetPdf());
|
234 |
|
|
slrts.SetNullParameters(*b_model.GetSnapshot());
|
235 |
|
|
slrts.SetAltParameters(*sb_model.GetSnapshot());
|
236 |
|
|
RooStats::ProfileLikelihoodTestStat profll = RooStats::ProfileLikelihoodTestStat(*b_model.GetPdf());
|
237 |
|
|
|
238 |
|
|
RooStats::HybridCalculatorOriginal hc = RooStats::HybridCalculatorOriginal(*data, sb_model, b_model,0,0);
|
239 |
|
|
hc.SetTestStatistic(2);
|
240 |
|
|
hc.SetNumberOfToys(50);
|
241 |
|
|
|
242 |
|
|
RooStats::HypoTestInverterOriginal hcInv = RooStats::HypoTestInverterOriginal(hc,*ws->var("nSig"));
|
243 |
|
|
hcInv.SetTestSize(0.05);
|
244 |
|
|
hcInv.UseCLs(true);
|
245 |
|
|
hcInv.RunFixedScan(5,theLimit-0.5,theLimit+0.5);;
|
246 |
|
|
RooStats::HypoTestInverterResult* hcInt = hcInv.GetInterval();
|
247 |
|
|
float ulError = hcInt->UpperLimitEstimatedError();
|
248 |
|
|
theLimit = hcInt->UpperLimit();
|
249 |
|
|
cout << "Found upper limit : " << theLimit << "+/-" << ulError << endl;
|
250 |
|
|
|
251 |
|
|
return theLimit/PlottingSetup::luminosity;
|
252 |
|
|
|
253 |
|
|
}
|
254 |
|
|
|
255 |
buchmann |
1.2 |
TTree* SkimTree(int isample) {
|
256 |
|
|
TTree* newTree = allsamples.collection[isample].events->CloneTree(0);
|
257 |
|
|
float xsweight=1.0;
|
258 |
|
|
if(allsamples.collection[isample].is_data==false) xsweight=luminosity*allsamples.collection[isample].weight;
|
259 |
|
|
if(EdgeFitter::MarcoDebug) {
|
260 |
|
|
cout << " Original tree contains " << allsamples.collection[isample].events->GetEntries() << endl;
|
261 |
|
|
cout << " Going to reduce it with cut " << EdgeFitter::cut << endl;
|
262 |
|
|
}
|
263 |
|
|
TTreeFormula *select = new TTreeFormula("select", EdgeFitter::cut, allsamples.collection[isample].events);
|
264 |
|
|
float wgt=1.0;
|
265 |
|
|
allsamples.collection[isample].events->SetBranchAddress(cutWeight,&wgt);
|
266 |
|
|
for (Int_t entry = 0 ; entry < allsamples.collection[isample].events->GetEntries() ; entry++) {
|
267 |
|
|
allsamples.collection[isample].events->LoadTree(entry);
|
268 |
|
|
if (select->EvalInstance()) {
|
269 |
|
|
allsamples.collection[isample].events->GetEntry(entry);
|
270 |
|
|
wgt=wgt*xsweight;
|
271 |
|
|
newTree->Fill();
|
272 |
|
|
}
|
273 |
|
|
}
|
274 |
|
|
|
275 |
|
|
if(EdgeFitter::MarcoDebug) cout << " Reduced tree contains " << newTree->GetEntries() << " entries " << endl;
|
276 |
|
|
return newTree;
|
277 |
|
|
}
|
278 |
|
|
|
279 |
|
|
void EdgeFitter::InitializeVariables(float _mllmin, float _mllmax, float _jzbmax, TCut _cut) {
|
280 |
|
|
mllmin=_mllmin;
|
281 |
|
|
mllmax=_mllmax;
|
282 |
|
|
jzbmax=_jzbmax;
|
283 |
|
|
cut=_cut;
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
void EdgeFitter::PrepareDatasets(int is_data) {
|
287 |
|
|
TTree *completetree;
|
288 |
buchmann |
1.5 |
write_warning(__FUNCTION__,"Need to make this function ready for scans as well (use signal from scan samples)");
|
289 |
buchmann |
1.2 |
bool hashit=0;
|
290 |
|
|
for(int isample=0;isample<allsamples.collection.size();isample++) {
|
291 |
|
|
if(!allsamples.collection[isample].is_active) continue;
|
292 |
|
|
if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data.
|
293 |
|
|
if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data.
|
294 |
|
|
if(is_data!=1&&allsamples.collection[isample].is_data==true) continue;//kick all data samples when looking for MC
|
295 |
|
|
if(is_data!=2&&allsamples.collection[isample].is_signal==true) continue;//remove signal sample if we don't want it.
|
296 |
|
|
if(EdgeFitter::MarcoDebug) cout << "Considering : " << allsamples.collection[isample].samplename << endl;
|
297 |
|
|
if(!hashit) {
|
298 |
|
|
hashit=true;
|
299 |
|
|
completetree = SkimTree(isample)->CloneTree();
|
300 |
|
|
} else {
|
301 |
|
|
completetree->CopyEntries(SkimTree(isample));
|
302 |
|
|
}
|
303 |
|
|
if(EdgeFitter::MarcoDebug) cout << "Complete tree now contains " << completetree->GetEntries() << " entries " << endl;
|
304 |
|
|
}
|
305 |
|
|
|
306 |
|
|
RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}");
|
307 |
|
|
RooRealVar id1("id1","id1",0,1,"GeV/c^{2}");
|
308 |
|
|
RooRealVar id2("id2","id2",0,1,"GeV/c^{2}");
|
309 |
|
|
RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c");
|
310 |
|
|
RooRealVar weight("weight","weight",0,1000,"");
|
311 |
|
|
RooArgSet observables(mll,jzb,id1,id2,weight);
|
312 |
|
|
|
313 |
|
|
string title="CMS Data";
|
314 |
|
|
if(is_data!=1) title="CMS SIMULATION";
|
315 |
|
|
RooDataSet LAllData("LAllData",title.c_str(),completetree,observables,"","weight");
|
316 |
|
|
completetree->Write();
|
317 |
|
|
// delete completetree;
|
318 |
|
|
|
319 |
buchmann |
1.5 |
EdgeFitter::eeSample = (RooDataSet*)LAllData.reduce("id1==id2");
|
320 |
|
|
EdgeFitter::mmSample = (RooDataSet*)LAllData.reduce("id1==id2");
|
321 |
buchmann |
1.2 |
EdgeFitter::emSample = (RooDataSet*)LAllData.reduce("id1!=id2");
|
322 |
|
|
EdgeFitter::AllData = (RooDataSet*)LAllData.reduce("id1!=id2||id1==id2");
|
323 |
|
|
|
324 |
|
|
eeSample->SetName("eeSample");
|
325 |
|
|
mmSample->SetName("mmSample");
|
326 |
|
|
emSample->SetName("emSample");
|
327 |
|
|
AllData->SetName("AllData");
|
328 |
|
|
|
329 |
|
|
if(EdgeFitter::MarcoDebug) {
|
330 |
|
|
cout << "Number of events in data sample = " << AllData->numEntries() << endl;
|
331 |
|
|
cout << "Number of events in ee sample = " << eeSample->numEntries() << endl;
|
332 |
|
|
cout << "Number of events in mm sample = " << mmSample->numEntries() << endl;
|
333 |
|
|
cout << "Number of events in em sample = " << emSample->numEntries() << endl;
|
334 |
|
|
}
|
335 |
|
|
}
|
336 |
|
|
|
337 |
|
|
string EdgeFitter::RandomStorageFile() {
|
338 |
|
|
TRandom3 *r = new TRandom3(0);
|
339 |
|
|
int rho = (int)r->Uniform(1,10000000);
|
340 |
|
|
stringstream RandomFile;
|
341 |
|
|
RandomFile << PlottingSetup::cbafbasedir << "/exchange/TempEdgeFile_" << rho << ".root";
|
342 |
|
|
delete r;
|
343 |
|
|
return RandomFile.str();
|
344 |
|
|
}
|
345 |
|
|
|
346 |
|
|
Yield EdgeFitter::Get_Z_estimate(float jzb_cut, int icut) {
|
347 |
|
|
if(MarcoDebug) write_error(__FUNCTION__,"Returning random Z yield");
|
348 |
|
|
Yield a(123,45,67); return a;
|
349 |
|
|
return PlottingSetup::allresults.predictions[icut].Zbkg;
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
Yield EdgeFitter::Get_T_estimate(float jzb_cut, int icut) {
|
353 |
|
|
if(MarcoDebug) write_error(__FUNCTION__,"Returning random TTbar yield");
|
354 |
|
|
Yield a(1234,56,78); return a;
|
355 |
|
|
return PlottingSetup::allresults.predictions[icut].Flavorsym;
|
356 |
|
|
}
|
357 |
|
|
|
358 |
buchmann |
1.5 |
void EdgeFitter::DoFit(int is_data, float jzb_cut) {
|
359 |
|
|
RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}");
|
360 |
|
|
RooCategory sample("sample","sample") ;
|
361 |
|
|
sample.defineType("ee");
|
362 |
|
|
//sample.defineType("mm");
|
363 |
|
|
sample.defineType("em");
|
364 |
|
|
//RooDataSet combData("combData","combined data",mll,Index(sample),Import("ee",*eeSample),Import("mm",*mmSample),Import("em",*emSample));
|
365 |
|
|
RooDataSet combData("combData","combined data",mll,RooFit::Index(sample),RooFit::Import("ee",*eeSample),RooFit::Import("em",*emSample));
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
|
369 |
|
|
//First we make a fit to opposite flavor
|
370 |
|
|
RooRealVar fttbarem("fttbarem", "fttbarem", 100, 0, 10000);
|
371 |
|
|
RooRealVar par1ttbarem("par1ttbarem", "par1ttbarem", 1.6, 0.01, 4.0);
|
372 |
|
|
RooRealVar par2ttbarem("par2ttbarem", "par2ttbarem", 1.0);
|
373 |
|
|
RooRealVar par3ttbarem("par3ttbarem", "par3ttbarem", 0.028, 0.001, 1.0);
|
374 |
|
|
RooRealVar par4ttbarem("par4ttbarem", "par4ttbarem", 2.0);
|
375 |
|
|
RooSUSYBkgPdf ttbarem("ttbarem","ttbarem", mll , par1ttbarem, par2ttbarem, par3ttbarem, par4ttbarem);
|
376 |
|
|
RooAddPdf model_em("model_em","model_em", ttbarem, fttbarem);
|
377 |
|
|
RooSimultaneous simPdfOF("simPdfOF","simultaneous pdf", sample) ;
|
378 |
|
|
simPdfOF.addPdf(model_em,"em");
|
379 |
|
|
RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save());
|
380 |
|
|
resultOF->Print();
|
381 |
|
|
|
382 |
|
|
RooRealVar* resultOFpar1_ = (RooRealVar*) resultOF->floatParsFinal().find("par1ttbarem");
|
383 |
|
|
float resultOFpar1 = resultOFpar1_->getVal();
|
384 |
|
|
//RooRealVar* resultOFpar2_ = (RooRealVar*) resultOF->floatParsFinal().find("par2ttbarem");
|
385 |
|
|
//float resultOFpar2 = resultOFpar2_->getVal();
|
386 |
|
|
//cout << "caca2.txt" << endl;
|
387 |
|
|
|
388 |
|
|
RooRealVar* resultOFpar3_ = (RooRealVar*) resultOF->floatParsFinal().find("par3ttbarem");
|
389 |
|
|
float resultOFpar3 = resultOFpar3_->getVal();
|
390 |
|
|
|
391 |
|
|
//RooRealVar* resultOFpar4_ = (RooRealVar*) resultOF->floatParsFinal().find("par4ttbarem");
|
392 |
|
|
//float resultOFpar4 = resultOFpar4_->getVal();
|
393 |
|
|
//cout << "caca4.txt" << endl;
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
// Now same flavor
|
397 |
|
|
RooRealVar fzee("fzee", "fzee", 5, 0, 100000);
|
398 |
|
|
RooRealVar meanzee("meanzee", "meanzee", 91.1876, 89, 95);
|
399 |
|
|
//RooRealVar sigmazee("sigmazee", "sigmazee", 0.5);
|
400 |
|
|
RooRealVar sigmazee("sigmazee", "sigmazee", 5, 0, 100);
|
401 |
|
|
RooRealVar widthzee("widthzee", "widthzee", 2.94);
|
402 |
|
|
|
403 |
|
|
RooRealVar fttbaree("fttbaree", "fttbaree", 100, 0, 100000);
|
404 |
|
|
RooRealVar par1ttbaree("par1ttbaree", "par1ttbaree", resultOFpar1, 0, 100);
|
405 |
|
|
RooRealVar par2ttbaree("par2ttbaree", "par2ttbaree", 1.0);
|
406 |
|
|
RooRealVar par3ttbaree("par3ttbaree", "par3ttbaree", resultOFpar3, 0, 100);
|
407 |
|
|
RooRealVar par4ttbaree("par4ttbaree", "par4ttbaree", 2.0);
|
408 |
|
|
|
409 |
|
|
RooRealVar fsignalee("fsignalee", "fsignalee", 10, 0, 400);
|
410 |
|
|
RooRealVar par1signalee("par1signalee", "par1signalee", 45, 20, 100);
|
411 |
|
|
RooRealVar par2signalee("par2signalee", "par2signalee", 2, 1, 10);
|
412 |
|
|
RooRealVar par3signalee("par3signalee", "par3signalee", 45, 0, 200);
|
413 |
|
|
|
414 |
|
|
RooVoigtian zee("zee", "zee", mll, meanzee, widthzee, sigmazee);
|
415 |
|
|
|
416 |
|
|
|
417 |
|
|
RooSUSYBkgPdf ttbaree("ttbaree","ttbaree", mll , par1ttbaree, par2ttbaree, par3ttbaree, par4ttbaree);
|
418 |
|
|
//RooSUSYTPdf signalee("signalee","signalee", mll , par1signalee, par2signalee, par3signalee);
|
419 |
|
|
RooSUSYTPdf signalee("signalee","signalee", mll , par1signalee, sigmazee, par3signalee);
|
420 |
|
|
|
421 |
|
|
//RooAddPdf model_ee("model_ee","model_ee", RooArgList(zee, ttbaree, signalee), RooArgList(fzee, fttbaree, fsignalee));
|
422 |
|
|
RooAddPdf model_ee("model_ee","model_ee", RooArgList(zee, ttbaree, signalee), RooArgList(fzee, fttbaree, fsignalee));
|
423 |
|
|
RooAddPdf model_emu("model_emu","model_emu", RooArgList(ttbaree), RooArgList(fttbaree));
|
424 |
|
|
|
425 |
|
|
|
426 |
|
|
RooSimultaneous simPdf("simPdf","simultaneous pdf",sample) ;
|
427 |
|
|
simPdf.addPdf(model_ee,"ee") ;
|
428 |
|
|
simPdf.addPdf(model_emu,"em") ;
|
429 |
|
|
|
430 |
|
|
RooFitResult *result = simPdf.fitTo(combData, RooFit::Save());
|
431 |
|
|
result->Print();
|
432 |
|
|
|
433 |
|
|
RooPlot* frame1 = mll.frame(RooFit::Bins(25),RooFit::Title("EE sample")) ;
|
434 |
|
|
combData.plotOn(frame1,RooFit::Cut("sample==sample::ee")) ;
|
435 |
|
|
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
|
436 |
|
|
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("ttbaree"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
|
437 |
|
|
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("zee"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
|
438 |
|
|
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("signalee"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen));
|
439 |
|
|
|
440 |
|
|
RooPlot* frame2 = mll.frame(RooFit::Bins(25),RooFit::Title("MM sample")) ;
|
441 |
|
|
combData.plotOn(frame2,RooFit::Cut("sample==sample::mm")) ;
|
442 |
|
|
simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
|
443 |
|
|
simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::Components("ttbarmm"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
|
444 |
|
|
simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::Components("zmm"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
|
445 |
|
|
simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::Components("signalmm"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen));
|
446 |
|
|
|
447 |
|
|
|
448 |
|
|
cout << "Result : " << endl;
|
449 |
|
|
cout << "f signal : " << fsignalee.getVal() << " +/- " << fsignalee.getError() << endl;
|
450 |
|
|
cout << "f ttbar : " << fttbaree.getVal() << " +/- " << fttbaree.getError() << endl;
|
451 |
|
|
cout << "f tt em : " << fttbarem.getVal() << " +/- " << fttbarem.getError() << endl;
|
452 |
|
|
cout << "f z ee : " << fzee.getVal() << " +/- " << fzee.getError() << endl;
|
453 |
|
|
|
454 |
|
|
// The same plot for the cointrol sample slice
|
455 |
|
|
RooPlot* frame3 = mll.frame(RooFit::Bins(25),RooFit::Title("EM sample")) ;
|
456 |
|
|
combData.plotOn(frame3,RooFit::Cut("sample==sample::em")) ;
|
457 |
|
|
simPdfOF.plotOn(frame3,RooFit::Slice(sample,"em"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
|
458 |
|
|
simPdfOF.plotOn(frame3,RooFit::Slice(sample,"em"),RooFit::Components("ttbarem"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
|
459 |
|
|
|
460 |
|
|
stringstream prefix;
|
461 |
|
|
if(is_data==data) prefix << "data_";
|
462 |
|
|
if(is_data==mc) prefix << "mc_";
|
463 |
|
|
if(is_data==mcwithsignal) prefix << "mcwithS_";
|
464 |
|
|
|
465 |
|
|
prefix << "JZB_" << jzb_cut;
|
466 |
|
|
|
467 |
|
|
/* cout << "fsignalee : " << fsignalee << endl;
|
468 |
|
|
cout << "fttbaree : " << fttbaree << endl;
|
469 |
|
|
cout << "fzee : " << fzee << endl;*/
|
470 |
|
|
|
471 |
|
|
|
472 |
|
|
TCanvas* c = new TCanvas("rf501_simultaneouspdf","rf403_simultaneouspdf") ;
|
473 |
|
|
c->cd() ;
|
474 |
|
|
gPad->SetLeftMargin(0.15);
|
475 |
|
|
frame1->GetYaxis()->SetTitleOffset(1.4);
|
476 |
|
|
frame1->Draw();
|
477 |
|
|
if(is_data==data) DrawPrelim();
|
478 |
|
|
else DrawPrelim(PlottingSetup::luminosity,true);
|
479 |
|
|
CompleteSave(c,"Edge/"+prefix.str()+"eemm");
|
480 |
|
|
delete c;
|
481 |
|
|
|
482 |
|
|
TCanvas* d = new TCanvas("rf501_simultaneouspdf","rf403_simultaneouspdf") ;
|
483 |
|
|
d->cd() ;
|
484 |
|
|
gPad->SetLeftMargin(0.15);
|
485 |
|
|
frame2->GetYaxis()->SetTitleOffset(1.4);
|
486 |
|
|
frame2->Draw();
|
487 |
|
|
if(is_data==data) DrawPrelim();
|
488 |
|
|
else DrawPrelim(PlottingSetup::luminosity,true);
|
489 |
|
|
CompleteSave(d,"Edge/"+prefix.str()+"mm");
|
490 |
|
|
delete d;
|
491 |
|
|
//c->cd(2) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.4) ; frame2->Draw();
|
492 |
|
|
|
493 |
|
|
TCanvas* e = new TCanvas("rf501_simultaneouspdfem","rf403_simultaneouspdfem") ;
|
494 |
|
|
e->cd();
|
495 |
|
|
gPad->SetLeftMargin(0.15);
|
496 |
|
|
frame3->GetYaxis()->SetTitleOffset(1.4);
|
497 |
|
|
frame3->Draw();
|
498 |
|
|
if(is_data==data) DrawPrelim();
|
499 |
|
|
else DrawPrelim(PlottingSetup::luminosity,true);
|
500 |
|
|
CompleteSave(e,"Edge/"+prefix.str()+"emu");
|
501 |
|
|
delete e;
|
502 |
|
|
|
503 |
|
|
/* TCanvas* f = new TCanvas("rf501_simultaneouspdfem","rf403_simultaneouspdfem") ;
|
504 |
|
|
f->cd();
|
505 |
|
|
gPad->SetLeftMargin(0.15);
|
506 |
|
|
frame4->GetYaxis()->SetTitleOffset(1.4);
|
507 |
|
|
frame4->Draw();
|
508 |
|
|
if(is_data==data) DrawPrelim();
|
509 |
|
|
else DrawPrelim(PlottingSetup::luminosity,true);
|
510 |
|
|
CompleteSave(f,"Edge/"+prefix.str()+"eemm");
|
511 |
|
|
delete f;*/
|
512 |
|
|
|
513 |
|
|
}
|
514 |
|
|
|
515 |
buchmann |
1.2 |
void EdgeFitter::DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, float jzb_cut, int icut, int is_data, TCut cut, TTree *signalevents=0) {
|
516 |
|
|
|
517 |
buchmann |
1.5 |
TCut _cut(cut&&PlottingSetup::basiccut&&PlottingSetup::passtrig);
|
518 |
|
|
|
519 |
|
|
TFile *f = new TFile("workingfile.root","RECREATE");
|
520 |
|
|
|
521 |
|
|
EdgeFitter::InitializeVariables(PlottingSetup::iMllLow,PlottingSetup::iMllHigh,PlottingSetup::jzbHigh,_cut);
|
522 |
buchmann |
1.2 |
|
523 |
|
|
EdgeFitter::PrepareDatasets(is_data);
|
524 |
buchmann |
1.5 |
|
525 |
|
|
RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow();
|
526 |
|
|
RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
|
527 |
|
|
EdgeFitter::DoFit(is_data, jzb_cut);
|
528 |
|
|
RooMsgService::instance().setGlobalKillBelow(msglevel);
|
529 |
|
|
|
530 |
buchmann |
1.2 |
|
531 |
|
|
f->Close();
|
532 |
|
|
|
533 |
|
|
}
|
534 |
|
|
|
535 |
|
|
void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, vector<float> jzb_cut, int is_data, TCut cut, TTree *signalevents=0) {
|
536 |
|
|
for(int icut=0;icut<jzb_cut.size();icut++) {
|
537 |
|
|
stringstream addcut;
|
538 |
|
|
if(is_data==1) addcut << "(" << datajzb << ">" << jzb_cut[icut] << ")";
|
539 |
|
|
if(is_data!=1) addcut << "(" << mcjzb << ">" << jzb_cut[icut] << ")";
|
540 |
|
|
TCut jcut(addcut.str().c_str());
|
541 |
|
|
|
542 |
buchmann |
1.5 |
|
543 |
buchmann |
1.2 |
EdgeFitter::DoEdgeFit(mcjzb, datajzb, DataPeakError, MCPeakError, jzb_cut[icut], icut, is_data, jcut&&cut, signalevents);
|
544 |
|
|
|
545 |
|
|
}
|
546 |
|
|
}
|