1 |
|
#include <iostream> |
2 |
|
|
3 |
+ |
#include <TVirtualIndex.h> |
4 |
+ |
|
5 |
|
#include <RooRealVar.h> |
6 |
|
#include <RooArgSet.h> |
7 |
|
#include <RooDataSet.h> |
25 |
|
#include "RooStats/HypoTestInverterOriginal.h" |
26 |
|
|
27 |
|
//#include "ParametrizedEdge.C" |
28 |
< |
#include "/shome/pablom/RooFit/Pdfs/RooSUSYTPdf.cxx" |
29 |
< |
#include "/shome/pablom/RooFit/Pdfs/RooSUSYBkgPdf.cxx" |
28 |
> |
#include "EdgeModules/RooSUSYTPdf.cxx" |
29 |
> |
#include "EdgeModules/RooSUSYBkgPdf.cxx" |
30 |
|
|
31 |
|
|
32 |
|
using namespace std; |
53 |
|
|
54 |
|
void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, float jzb_cut, int icut, int is_data, TCut cut, TTree*); |
55 |
|
void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, vector<float> jzb_cut, int is_data, TCut cut, TTree*); |
56 |
< |
void getMedianLimit(RooWorkspace *ws,vector<RooDataSet*> theToys,float &median,float &sigmaDown, float &sigmaUp, float &twoSigmaDown, float &twoSigmaUp); |
56 |
> |
void getMedianLimit(RooWorkspace *ws,vector<RooDataSet> theToys,float &median,float &sigmaDown, float &sigmaUp, float &twoSigmaDown, float &twoSigmaUp); |
57 |
|
void InitializeVariables(float _mllmin, float _mllmax, float _jzbmax, TCut _cut); |
58 |
|
void PrepareDatasets(int); |
59 |
+ |
void DrawDatasetContent(int); |
60 |
|
void DoFit(int is_data, float jzb_cut); |
61 |
|
string RandomStorageFile(); |
62 |
|
Yield Get_Z_estimate(float,int); |
63 |
|
Yield Get_T_estimate(float,int); |
64 |
< |
float calcExclusion(RooWorkspace *ws, RooDataSet *data = NULL); |
65 |
< |
void prepareLimits(RooWorkspace *ws); |
63 |
< |
vector<RooDataSet*> generateToys(RooWorkspace *ws, int nToys); |
64 |
> |
float calcExclusion(RooWorkspace *ws, RooDataSet data, bool calcExclusion); |
65 |
> |
vector<RooDataSet> generateToys(RooWorkspace *ws, int nToys); |
66 |
|
void prepareLimits(RooWorkspace *ws, bool ComputeBands); |
67 |
|
TGraph* prepareLM(float mass, float nEv); |
68 |
|
|
72 |
|
TCut cut; |
73 |
|
|
74 |
|
RooDataSet* AllData; |
75 |
< |
RooDataSet* eeSample; |
76 |
< |
RooDataSet* mmSample; |
77 |
< |
RooDataSet* emSample; |
75 |
> |
RooDataSet* SFSample; |
76 |
> |
RooDataSet* OFSample; |
77 |
> |
|
78 |
> |
bool MarcoDebug=true; |
79 |
> |
|
80 |
> |
float FixedMEdge=-1; |
81 |
> |
float FixedMEdgeChi2=-1; |
82 |
> |
|
83 |
> |
bool RejectPointIfNoConvergence=false; |
84 |
> |
|
85 |
> |
string Mode="UndefinedMode"; |
86 |
|
|
77 |
– |
bool MarcoDebug; |
87 |
|
} |
88 |
|
|
89 |
|
TGraph* EdgeFitter::prepareLM(float mass, float nEv) { |
102 |
|
return lm; |
103 |
|
} |
104 |
|
|
105 |
< |
vector<RooDataSet*> EdgeFitter::generateToys(RooWorkspace *ws, int nToys) { |
105 |
> |
vector<RooDataSet> EdgeFitter::generateToys(RooWorkspace *ws, int nToys) { |
106 |
> |
ws->ls(); |
107 |
|
ws->var("nSig")->setVal(0.); |
108 |
|
ws->var("nSig")->setConstant(true); |
109 |
|
RooFitResult* fit = ws->pdf("combModel")->fitTo(*ws->data("data_obs"),RooFit::Save()); |
110 |
< |
vector<RooDataSet*> theToys; |
110 |
> |
vector<RooDataSet> theToys; |
111 |
|
|
112 |
|
RooMCStudy mcEE(*ws->pdf("combModel"),RooArgSet(*ws->var("inv")),RooFit::Slice(*ws->cat("cat"),"EE")); |
113 |
|
mcEE.generate(nToys,44,true); |
116 |
|
RooMCStudy mcOSOF(*ws->pdf("combModel"),RooArgSet(*ws->var("inv")),RooFit::Slice(*ws->cat("cat"),"OSOF")); |
117 |
|
mcOSOF.generate(nToys,44,true); |
118 |
|
|
119 |
< |
RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}"); |
119 |
> |
RooRealVar mll("m_{ll}","m_{ll}",mllmin,mllmax,"GeV/c^{2}"); |
120 |
|
RooRealVar id1("id1","id1",0,1,"GeV/c^{2}"); |
121 |
|
RooRealVar id2("id2","id2",0,1,"GeV/c^{2}"); |
122 |
|
RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c"); |
130 |
|
stringstream toyname; |
131 |
|
toyname << "theToy_" << i; |
132 |
|
write_warning(__FUNCTION__,"Problem while adding toys"); |
133 |
< |
// 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)); |
134 |
< |
// theToys.push_back(toyData); |
133 |
> |
RooDataSet toyData = RooDataSet(toyname.str().c_str(),toyname.str().c_str(),observables,RooFit::Index(const_cast<RooCategory&>(*ws->cat("cat"))),RooFit::Import("OSOF",*toyOSOF),RooFit::Import("EE",*toyEE),RooFit::Import("MM",*toyMM)); |
134 |
> |
theToys.push_back(toyData); |
135 |
|
} |
136 |
|
ws->var("nSig")->setVal(17.0); |
137 |
|
ws->var("nSig")->setConstant(false); |
138 |
|
return theToys; |
139 |
|
} |
140 |
|
|
141 |
< |
void EdgeFitter::getMedianLimit(RooWorkspace *ws,vector<RooDataSet*> theToys,float &median,float &sigmaDown, float &sigmaUp, float &twoSigmaDown, float &twoSigmaUp) { |
141 |
> |
void EdgeFitter::getMedianLimit(RooWorkspace *ws,vector<RooDataSet> theToys,float &median,float &sigmaDown, float &sigmaUp, float &twoSigmaDown, float &twoSigmaUp) { |
142 |
|
TH1F *gauLimit = new TH1F("gausLimit","gausLimit",60,0.,80./PlottingSetup::luminosity); |
143 |
|
vector<float> theLimits; |
144 |
< |
for(int itoy=0;itoy<theToys.size();itoy++) { |
145 |
< |
float theLimit = calcExclusion(ws,theToys[itoy]); |
144 |
> |
for(int itoy=0;itoy<(int)theToys.size();itoy++) { |
145 |
> |
float theLimit = calcExclusion(ws,theToys[itoy],false); |
146 |
|
if(theLimit > 0 ) gauLimit->Fill(theLimit); |
147 |
|
} |
148 |
|
const Int_t nQ = 4; |
160 |
|
|
161 |
|
void EdgeFitter::prepareLimits(RooWorkspace *ws, bool ComputeBands) { |
162 |
|
if(ComputeBands) { |
163 |
< |
vector<RooDataSet*> theToys = EdgeFitter::generateToys(ws,50); |
163 |
> |
vector<RooDataSet> theToys = EdgeFitter::generateToys(ws,50); |
164 |
|
vector<float> medVals; |
165 |
|
vector<float> medLimits; |
166 |
|
vector<float> sigmaLimitsDown; |
189 |
|
theVals.push_back((float)i); |
190 |
|
ws->var("m0")->setVal((float)i); |
191 |
|
ws->var("m0")->setConstant(true); |
192 |
< |
theLimits.push_back(calcExclusion(ws)); |
192 |
> |
// theLimits.push_back(calcExclusion(ws,(RooDataSet)*ws->data("data_obs"),true)); |
193 |
> |
write_error(__FUNCTION__,"Error while casting roo data set"); |
194 |
|
} |
195 |
|
|
196 |
< |
for(int i=0;i<theLimits.size();i++) { |
196 |
> |
for(int i=0;i<(int)theLimits.size();i++) { |
197 |
|
if((theLimits[i]<2.0/PlottingSetup::luminosity)||(theLimits[i]>40.0/PlottingSetup::luminosity)) { |
198 |
|
cout << i << " : " << theVals[i] << endl; |
199 |
|
theLimits[i] = (theLimits[i+2]+theLimits[i-2])/2.0; |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
< |
float EdgeFitter::calcExclusion(RooWorkspace *ws, RooDataSet *data) { |
208 |
> |
float EdgeFitter::calcExclusion(RooWorkspace *ws, RooDataSet data, bool LoadDataObs) { |
209 |
> |
int numberOfToys=50; |
210 |
|
RooRealVar mu("mu","nSig",0,10000,""); |
211 |
|
RooArgSet poi = RooArgSet(mu); |
212 |
|
RooArgSet *nullParams = (RooArgSet*)poi.snapshot(); |
215 |
|
model->SetWorkspace(*ws); |
216 |
|
model->SetPdf("combModel"); |
217 |
|
model->SetParametersOfInterest(poi); |
218 |
< |
if(!data) data = (RooDataSet*)ws->data("data_obs"); |
218 |
> |
// if(LoadDataObs) data = (RooDataSet)*ws->data("data_obs"); |
219 |
|
|
220 |
< |
RooStats::ProfileLikelihoodCalculator plc(*data, *model); |
220 |
> |
RooStats::ProfileLikelihoodCalculator plc(data, *model); |
221 |
|
plc.SetNullParameters(*nullParams); |
222 |
|
plc.SetTestSize(0.05); |
223 |
+ |
|
224 |
|
RooStats::LikelihoodInterval* interval = plc.GetInterval(); |
225 |
|
RooStats::HypoTestResult *htr = plc.GetHypoTest(); |
226 |
|
double theLimit = interval->UpperLimit( mu ); |
227 |
< |
cout << "Significance " << htr->Significance() << endl; |
227 |
> |
// double significance = htr->Significance(); |
228 |
|
|
229 |
|
ws->defineSet("obs","nB"); |
230 |
|
ws->defineSet("poi","nSig"); |
248 |
|
slrts.SetAltParameters(*sb_model.GetSnapshot()); |
249 |
|
RooStats::ProfileLikelihoodTestStat profll = RooStats::ProfileLikelihoodTestStat(*b_model.GetPdf()); |
250 |
|
|
251 |
< |
RooStats::HybridCalculatorOriginal hc = RooStats::HybridCalculatorOriginal(*data, sb_model, b_model,0,0); |
251 |
> |
RooStats::HybridCalculatorOriginal hc = RooStats::HybridCalculatorOriginal(data, sb_model, b_model,0,0); |
252 |
|
hc.SetTestStatistic(2); |
253 |
< |
hc.SetNumberOfToys(50); |
253 |
> |
hc.SetNumberOfToys(numberOfToys); |
254 |
|
|
255 |
|
RooStats::HypoTestInverterOriginal hcInv = RooStats::HypoTestInverterOriginal(hc,*ws->var("nSig")); |
256 |
|
hcInv.SetTestSize(0.05); |
266 |
|
} |
267 |
|
|
268 |
|
TTree* SkimTree(int isample) { |
269 |
< |
TTree* newTree = allsamples.collection[isample].events->CloneTree(0); |
269 |
> |
string TreeName = allsamples.collection[isample].filename; |
270 |
> |
TTree* newTree = new TTree("NanoTree",TreeName.c_str()); |
271 |
> |
|
272 |
> |
float mll,edgeWeight; |
273 |
> |
int id1,id2; |
274 |
> |
|
275 |
> |
newTree->Branch("edgeWeight",&edgeWeight,"edgeWeight/F"); |
276 |
> |
newTree->Branch("mll",&mll,"mll/F"); |
277 |
> |
newTree->Branch("id1",&id1,"id1/I"); |
278 |
> |
newTree->Branch("id2",&id2,"id2/I"); |
279 |
> |
|
280 |
|
float xsweight=1.0; |
281 |
|
if(allsamples.collection[isample].is_data==false) xsweight=luminosity*allsamples.collection[isample].weight; |
282 |
|
if(EdgeFitter::MarcoDebug) { |
283 |
|
cout << " Original tree contains " << allsamples.collection[isample].events->GetEntries() << endl; |
284 |
|
cout << " Going to reduce it with cut " << EdgeFitter::cut << endl; |
285 |
|
} |
286 |
+ |
|
287 |
+ |
float tmll; |
288 |
+ |
int tid1,tid2; |
289 |
+ |
allsamples.collection[isample].events->SetBranchAddress("mll",&tmll); |
290 |
+ |
allsamples.collection[isample].events->SetBranchAddress("id1",&tid1); |
291 |
+ |
allsamples.collection[isample].events->SetBranchAddress("id2",&tid2); |
292 |
+ |
|
293 |
|
TTreeFormula *select = new TTreeFormula("select", EdgeFitter::cut, allsamples.collection[isample].events); |
294 |
+ |
TTreeFormula *Weight = new TTreeFormula("Weight", cutWeight, allsamples.collection[isample].events); |
295 |
+ |
|
296 |
|
float wgt=1.0; |
265 |
– |
allsamples.collection[isample].events->SetBranchAddress(cutWeight,&wgt); |
297 |
|
for (Int_t entry = 0 ; entry < allsamples.collection[isample].events->GetEntries() ; entry++) { |
298 |
|
allsamples.collection[isample].events->LoadTree(entry); |
299 |
|
if (select->EvalInstance()) { |
300 |
|
allsamples.collection[isample].events->GetEntry(entry); |
301 |
< |
wgt=wgt*xsweight; |
301 |
> |
mll=tmll; |
302 |
> |
id1=tid1; |
303 |
> |
id2=tid2; |
304 |
> |
wgt=Weight->EvalInstance(); |
305 |
> |
edgeWeight=wgt*xsweight; |
306 |
|
newTree->Fill(); |
307 |
|
} |
308 |
|
} |
317 |
|
jzbmax=_jzbmax; |
318 |
|
cut=_cut; |
319 |
|
} |
320 |
< |
|
320 |
> |
|
321 |
> |
TTree* MergeTrees(vector<TTree*> trees) { |
322 |
> |
TTree * newtree = (TTree*)trees[0]->CloneTree(0); |
323 |
> |
trees[0]->GetListOfClones()->Remove(newtree); |
324 |
> |
trees[0]->ResetBranchAddresses(); |
325 |
> |
newtree->ResetBranchAddresses(); |
326 |
> |
|
327 |
> |
for(int itree=0;itree<trees.size();itree++) { |
328 |
> |
newtree->CopyAddresses(trees[itree]); |
329 |
> |
Long64_t nentries = trees[itree]->GetEntries(); |
330 |
> |
for (Long64_t iEntry=0;iEntry<nentries;iEntry++) { |
331 |
> |
trees[itree]->GetEntry(iEntry); |
332 |
> |
newtree->Fill(); |
333 |
> |
} |
334 |
> |
trees[itree]->ResetBranchAddresses(); // Disconnect from new tree |
335 |
> |
if (newtree->GetTreeIndex()) { |
336 |
> |
newtree->GetTreeIndex()->Append(trees[itree]->GetTreeIndex(),kTRUE); |
337 |
> |
} |
338 |
> |
if (newtree && newtree->GetTreeIndex()) { |
339 |
> |
newtree->GetTreeIndex()->Append(0,kFALSE); // Force the sorting |
340 |
> |
} |
341 |
> |
} |
342 |
> |
return newtree; |
343 |
> |
} |
344 |
> |
|
345 |
> |
|
346 |
> |
|
347 |
|
void EdgeFitter::PrepareDatasets(int is_data) { |
287 |
– |
TTree *completetree; |
348 |
|
write_warning(__FUNCTION__,"Need to make this function ready for scans as well (use signal from scan samples)"); |
349 |
< |
bool hashit=0; |
350 |
< |
for(int isample=0;isample<allsamples.collection.size();isample++) { |
349 |
> |
TFile *tempout = new TFile("tempout.root","RECREATE"); |
350 |
> |
vector<TTree*> SkimmedTrees; |
351 |
> |
TTree *SkimmedTree[(int)allsamples.collection.size()]; |
352 |
> |
for(int isample=0;isample<(int)allsamples.collection.size();isample++) { |
353 |
|
if(!allsamples.collection[isample].is_active) continue; |
354 |
|
if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data. |
355 |
|
if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data. |
356 |
|
if(is_data!=1&&allsamples.collection[isample].is_data==true) continue;//kick all data samples when looking for MC |
357 |
|
if(is_data!=2&&allsamples.collection[isample].is_signal==true) continue;//remove signal sample if we don't want it. |
358 |
|
if(EdgeFitter::MarcoDebug) cout << "Considering : " << allsamples.collection[isample].samplename << endl; |
359 |
< |
if(!hashit) { |
360 |
< |
hashit=true; |
361 |
< |
completetree = SkimTree(isample)->CloneTree(); |
362 |
< |
} else { |
301 |
< |
completetree->CopyEntries(SkimTree(isample)); |
302 |
< |
} |
303 |
< |
if(EdgeFitter::MarcoDebug) cout << "Complete tree now contains " << completetree->GetEntries() << " entries " << endl; |
359 |
> |
SkimmedTree[isample] = SkimTree(isample); |
360 |
> |
tempout->cd(); |
361 |
> |
SkimmedTree[isample]->Write(); |
362 |
> |
SkimmedTrees.push_back(SkimmedTree[isample]); |
363 |
|
} |
364 |
|
|
365 |
< |
RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}"); |
365 |
> |
TTree *completetree = MergeTrees(SkimmedTrees); |
366 |
> |
|
367 |
> |
if(EdgeFitter::MarcoDebug) cout << "Complete tree now contains " << completetree->GetEntries() << " entries " << endl; |
368 |
> |
|
369 |
> |
RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}"); |
370 |
|
RooRealVar id1("id1","id1",0,1,"GeV/c^{2}"); |
371 |
|
RooRealVar id2("id2","id2",0,1,"GeV/c^{2}"); |
372 |
< |
RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c"); |
373 |
< |
RooRealVar weight("weight","weight",0,1000,""); |
311 |
< |
RooArgSet observables(mll,jzb,id1,id2,weight); |
372 |
> |
RooRealVar edgeWeight("edgeWeight","edgeWeight",0,1000,""); |
373 |
> |
RooArgSet observables(mll,id1,id2,edgeWeight); |
374 |
|
|
375 |
|
string title="CMS Data"; |
376 |
|
if(is_data!=1) title="CMS SIMULATION"; |
377 |
< |
RooDataSet LAllData("LAllData",title.c_str(),completetree,observables,"","weight"); |
377 |
> |
RooDataSet LAllData("LAllData",title.c_str(),completetree,observables,"","edgeWeight"); |
378 |
> |
tempout->cd(); |
379 |
|
completetree->Write(); |
380 |
< |
// delete completetree; |
380 |
> |
tempout->Close(); |
381 |
> |
|
382 |
|
|
383 |
< |
EdgeFitter::eeSample = (RooDataSet*)LAllData.reduce("id1==id2"); |
384 |
< |
EdgeFitter::mmSample = (RooDataSet*)LAllData.reduce("id1==id2"); |
321 |
< |
EdgeFitter::emSample = (RooDataSet*)LAllData.reduce("id1!=id2"); |
383 |
> |
EdgeFitter::SFSample = (RooDataSet*)LAllData.reduce("id1==id2"); |
384 |
> |
EdgeFitter::OFSample = (RooDataSet*)LAllData.reduce("id1!=id2"); |
385 |
|
EdgeFitter::AllData = (RooDataSet*)LAllData.reduce("id1!=id2||id1==id2"); |
386 |
|
|
387 |
< |
eeSample->SetName("eeSample"); |
388 |
< |
mmSample->SetName("mmSample"); |
326 |
< |
emSample->SetName("emSample"); |
387 |
> |
SFSample->SetName("SFSample"); |
388 |
> |
OFSample->SetName("OFSample"); |
389 |
|
AllData->SetName("AllData"); |
390 |
|
|
391 |
|
if(EdgeFitter::MarcoDebug) { |
392 |
< |
cout << "Number of events in data sample = " << AllData->numEntries() << endl; |
393 |
< |
cout << "Number of events in ee sample = " << eeSample->numEntries() << endl; |
394 |
< |
cout << "Number of events in mm sample = " << mmSample->numEntries() << endl; |
333 |
< |
cout << "Number of events in em sample = " << emSample->numEntries() << endl; |
392 |
> |
cout << "Number of events in data sample = " << AllData->sumEntries() << endl; |
393 |
> |
cout << "Number of events in eemm sample = " << SFSample->sumEntries() << endl; |
394 |
> |
cout << "Number of events in em sample = " << OFSample->sumEntries() << endl; |
395 |
|
} |
396 |
+ |
|
397 |
|
} |
398 |
|
|
399 |
+ |
void EdgeFitter::DrawDatasetContent(int is_data) { |
400 |
+ |
RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}"); |
401 |
+ |
RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("SF sample")) ; |
402 |
+ |
frame1->GetXaxis()->CenterTitle(1); |
403 |
+ |
frame1->GetYaxis()->CenterTitle(1); |
404 |
+ |
SFSample->plotOn(frame1,RooFit::Name("SFdata")) ; |
405 |
+ |
|
406 |
+ |
RooPlot* frame2 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")) ; |
407 |
+ |
frame2->GetXaxis()->CenterTitle(1); |
408 |
+ |
frame2->GetYaxis()->CenterTitle(1); |
409 |
+ |
OFSample->plotOn(frame2,RooFit::Name("OFdata")) ; |
410 |
+ |
|
411 |
+ |
TCanvas* cSFdata = new TCanvas("cSFdata","cSFdata") ; |
412 |
+ |
cSFdata->cd() ; |
413 |
+ |
gPad->SetLeftMargin(0.15); |
414 |
+ |
frame1->GetYaxis()->SetTitleOffset(1.4); |
415 |
+ |
frame1->Draw(); |
416 |
+ |
if(is_data==data) DrawPrelim(); |
417 |
+ |
else DrawPrelim(PlottingSetup::luminosity,true); |
418 |
+ |
CompleteSave(cSFdata,"Edge/SF_NoFit"); |
419 |
+ |
|
420 |
+ |
TCanvas* cOFdata = new TCanvas("cOFdata","cOFdata") ; |
421 |
+ |
cOFdata->cd() ; |
422 |
+ |
gPad->SetLeftMargin(0.15); |
423 |
+ |
frame2->SetMaximum(frame1->GetMaximum()); |
424 |
+ |
frame2->GetYaxis()->SetTitleOffset(1.4); |
425 |
+ |
frame2->Draw(); |
426 |
+ |
if(is_data==data) DrawPrelim(); |
427 |
+ |
else DrawPrelim(PlottingSetup::luminosity,true); |
428 |
+ |
CompleteSave(cOFdata,"Edge/OF_NoFit"); |
429 |
+ |
} |
430 |
+ |
|
431 |
+ |
string WriteWithError(float central, float error, int digits) { |
432 |
+ |
float ref=central; |
433 |
+ |
if(ref<0) ref=-central; |
434 |
+ |
int HighestSigDigit = 0; |
435 |
+ |
if(ref>1) HighestSigDigit = int(log(ref)/log(10))+1; |
436 |
+ |
else HighestSigDigit = int(log(ref)/(log(10))); |
437 |
+ |
|
438 |
+ |
float divider=pow(10.0,(double(HighestSigDigit-digits))); |
439 |
+ |
|
440 |
+ |
stringstream result; |
441 |
+ |
result << divider*int(central/divider+0.5) << " #pm " << divider*int(error/divider+0.5); |
442 |
+ |
return result.str(); |
443 |
+ |
} |
444 |
+ |
|
445 |
+ |
|
446 |
|
string EdgeFitter::RandomStorageFile() { |
447 |
|
TRandom3 *r = new TRandom3(0); |
448 |
|
int rho = (int)r->Uniform(1,10000000); |
465 |
|
} |
466 |
|
|
467 |
|
void EdgeFitter::DoFit(int is_data, float jzb_cut) { |
468 |
< |
RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}"); |
468 |
> |
|
469 |
> |
stringstream prefix; |
470 |
> |
if(is_data==data) prefix << "data_"; |
471 |
> |
if(is_data==mc) prefix << "mc_"; |
472 |
> |
if(is_data==mcwithsignal) prefix << "mcwithS_"; |
473 |
> |
|
474 |
> |
prefix << EdgeFitter::Mode << "_" << jzb_cut; |
475 |
> |
|
476 |
> |
|
477 |
> |
|
478 |
> |
RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}"); |
479 |
> |
RooRealVar edgeWeight("edgeWeight","edgeWeight",0,1000,""); |
480 |
|
RooCategory sample("sample","sample") ; |
481 |
< |
sample.defineType("ee"); |
481 |
> |
sample.defineType("SF"); |
482 |
|
//sample.defineType("mm"); |
483 |
< |
sample.defineType("em"); |
484 |
< |
//RooDataSet combData("combData","combined data",mll,Index(sample),Import("ee",*eeSample),Import("mm",*mmSample),Import("em",*emSample)); |
485 |
< |
RooDataSet combData("combData","combined data",mll,RooFit::Index(sample),RooFit::Import("ee",*eeSample),RooFit::Import("em",*emSample)); |
483 |
> |
sample.defineType("OF"); |
484 |
> |
|
485 |
> |
//RooDataSet combData("combData","combined data",mll,Index(sample),Import("SF",*SFSample),Import("mm",*mmSample),Import("OF",*OFSample)); |
486 |
> |
RooDataSet combData("combData","combined data",RooArgSet(mll,edgeWeight),RooFit::Index(sample),RooFit::Import("SF",*SFSample),RooFit::Import("OF",*OFSample),RooFit::WeightVar(edgeWeight)); |
487 |
> |
|
488 |
|
|
367 |
– |
|
368 |
– |
|
489 |
|
//First we make a fit to opposite flavor |
490 |
< |
RooRealVar fttbarem("fttbarem", "fttbarem", 100, 0, 10000); |
491 |
< |
RooRealVar par1ttbarem("par1ttbarem", "par1ttbarem", 1.6, 0.01, 4.0); |
492 |
< |
RooRealVar par2ttbarem("par2ttbarem", "par2ttbarem", 1.0); |
493 |
< |
RooRealVar par3ttbarem("par3ttbarem", "par3ttbarem", 0.028, 0.001, 1.0); |
494 |
< |
RooRealVar par4ttbarem("par4ttbarem", "par4ttbarem", 2.0); |
495 |
< |
RooSUSYBkgPdf ttbarem("ttbarem","ttbarem", mll , par1ttbarem, par2ttbarem, par3ttbarem, par4ttbarem); |
496 |
< |
RooAddPdf model_em("model_em","model_em", ttbarem, fttbarem); |
490 |
> |
RooRealVar fttbarOF("fttbarOF", "fttbarOF", 100, 0, 10000); |
491 |
> |
RooRealVar par1ttbarOF("par1ttbarOF", "par1ttbarOF", 1.6, 0.01, 4.0); |
492 |
> |
RooRealVar par2ttbarOF("par2ttbarOF", "par2ttbarOF", 1.0); |
493 |
> |
RooRealVar par3ttbarOF("par3ttbarOF", "par3ttbarOF", 0.028, 0.001, 1.0); |
494 |
> |
RooRealVar par4ttbarOF("par4ttbarOF", "par4ttbarOF", 2.0); |
495 |
> |
RooSUSYBkgPdf ttbarOF("ttbarOF","ttbarOF", mll , par1ttbarOF, par2ttbarOF, par3ttbarOF, par4ttbarOF); |
496 |
> |
RooAddPdf model_OF("model_OF","model_OF", ttbarOF, fttbarOF); |
497 |
|
RooSimultaneous simPdfOF("simPdfOF","simultaneous pdf", sample) ; |
498 |
< |
simPdfOF.addPdf(model_em,"em"); |
499 |
< |
RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save()); |
498 |
> |
simPdfOF.addPdf(model_OF,"OF"); |
499 |
> |
RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save(),RooFit::Extended(),RooFit::Minos(true)); |
500 |
> |
cout << "============================= < OF results > =============================" << endl; |
501 |
|
resultOF->Print(); |
502 |
< |
|
503 |
< |
RooRealVar* resultOFpar1_ = (RooRealVar*) resultOF->floatParsFinal().find("par1ttbarem"); |
504 |
< |
float resultOFpar1 = resultOFpar1_->getVal(); |
505 |
< |
//RooRealVar* resultOFpar2_ = (RooRealVar*) resultOF->floatParsFinal().find("par2ttbarem"); |
506 |
< |
//float resultOFpar2 = resultOFpar2_->getVal(); |
507 |
< |
//cout << "caca2.txt" << endl; |
508 |
< |
|
509 |
< |
RooRealVar* resultOFpar3_ = (RooRealVar*) resultOF->floatParsFinal().find("par3ttbarem"); |
510 |
< |
float resultOFpar3 = resultOFpar3_->getVal(); |
511 |
< |
|
512 |
< |
//RooRealVar* resultOFpar4_ = (RooRealVar*) resultOF->floatParsFinal().find("par4ttbarem"); |
513 |
< |
//float resultOFpar4 = resultOFpar4_->getVal(); |
514 |
< |
//cout << "caca4.txt" << endl; |
502 |
> |
cout << "============================= < /OF results > =============================" << endl; |
503 |
> |
|
504 |
> |
|
505 |
> |
RooPlot* frameO = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")); |
506 |
> |
frameO->GetXaxis()->CenterTitle(1); |
507 |
> |
frameO->GetYaxis()->CenterTitle(1); |
508 |
> |
combData.plotOn(frameO,RooFit::Name("OFdata"),RooFit::Cut("sample==sample::OF")) ; |
509 |
> |
simPdfOF.plotOn(frameO,RooFit::Slice(sample,"OF"),RooFit::Name("FullFit"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ; |
510 |
> |
simPdfOF.plotOn(frameO,RooFit::Slice(sample,"OF"),RooFit::Name("TTbarOFonly"),RooFit::Components("ttbarOF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ; |
511 |
> |
|
512 |
> |
TCanvas* pof = new TCanvas("pof","pof") ; |
513 |
> |
pof->cd() ; |
514 |
> |
gPad->SetLeftMargin(0.15); |
515 |
> |
frameO->GetYaxis()->SetTitleOffset(1.4); |
516 |
> |
frameO->Draw(); |
517 |
> |
if(is_data==data) DrawPrelim(); |
518 |
> |
else DrawPrelim(PlottingSetup::luminosity,true); |
519 |
> |
if(EdgeFitter::FixedMEdge>=0) CompleteSave(pof,"Edge/OF__OFFitonly_"+prefix.str()+"__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false); |
520 |
> |
else CompleteSave(pof,"Edge/OF__OFFitonly_"+prefix.str(),false,false); |
521 |
> |
delete pof; |
522 |
> |
|
523 |
> |
if(resultOF->covQual()!=3) { |
524 |
> |
write_error(__FUNCTION__,"OF fit did not converge!!! Cannot continue!"); |
525 |
> |
cout << "covQual is " << resultOF->covQual() << endl; |
526 |
> |
EdgeFitter::FixedMEdgeChi2=-1; |
527 |
> |
if(EdgeFitter::RejectPointIfNoConvergence) return; |
528 |
> |
} else { |
529 |
> |
write_info(__FUNCTION__,"OF fit converged"); |
530 |
> |
} |
531 |
> |
|
532 |
> |
float StartingMedge=70; |
533 |
> |
if(EdgeFitter::FixedMEdge>0) StartingMedge=EdgeFitter::FixedMEdge; |
534 |
|
|
535 |
|
|
536 |
+ |
RooDataSet *ZDataSet = new RooDataSet("ZDataSet","ZDataSet",SFSample,RooArgSet(mll),"abs(mll-91.2)<20"); |
537 |
+ |
float maxZ = ZDataSet->sumEntries(); |
538 |
+ |
cout << "maxZ was set to " << maxZ << endl; |
539 |
+ |
delete ZDataSet; |
540 |
+ |
|
541 |
+ |
|
542 |
+ |
|
543 |
|
// Now same flavor |
544 |
< |
RooRealVar fzee("fzee", "fzee", 5, 0, 100000); |
545 |
< |
RooRealVar meanzee("meanzee", "meanzee", 91.1876, 89, 95); |
546 |
< |
//RooRealVar sigmazee("sigmazee", "sigmazee", 0.5); |
547 |
< |
RooRealVar sigmazee("sigmazee", "sigmazee", 5, 0, 100); |
548 |
< |
RooRealVar widthzee("widthzee", "widthzee", 2.94); |
549 |
< |
|
550 |
< |
RooRealVar fttbaree("fttbaree", "fttbaree", 100, 0, 100000); |
551 |
< |
RooRealVar par1ttbaree("par1ttbaree", "par1ttbaree", resultOFpar1, 0, 100); |
552 |
< |
RooRealVar par2ttbaree("par2ttbaree", "par2ttbaree", 1.0); |
406 |
< |
RooRealVar par3ttbaree("par3ttbaree", "par3ttbaree", resultOFpar3, 0, 100); |
407 |
< |
RooRealVar par4ttbaree("par4ttbaree", "par4ttbaree", 2.0); |
544 |
> |
RooRealVar fzSF("fzSF", "fzSF", 39, 39, maxZ); |
545 |
> |
RooRealVar meanzSF("meanzSF", "meanzSF", 91.1876, 89, 95); |
546 |
> |
//RooRealVar sigmazSF("sigmazSF", "sigmazSF", 0.5); |
547 |
> |
RooRealVar sigmazSF("sigmazSF", "sigmazSF", 5, 0.5, 5); |
548 |
> |
RooRealVar widthzSF("widthzSF", "widthzSF", 2.94); |
549 |
> |
widthzSF.setConstant(); |
550 |
> |
|
551 |
> |
RooRealVar fttbarSF("fttbarSF", "fttbarSF", 100, 0, 100000); |
552 |
> |
RooRealVar par1ttbarSF("par1ttbarSF", "par1ttbarSF", 1.02*par1ttbarOF.getVal(), (1.02-0.07)*par1ttbarOF.getVal(), (1.02+0.07)*par1ttbarOF.getVal()); |
553 |
|
|
554 |
< |
RooRealVar fsignalee("fsignalee", "fsignalee", 10, 0, 400); |
555 |
< |
RooRealVar par1signalee("par1signalee", "par1signalee", 45, 20, 100); |
556 |
< |
RooRealVar par2signalee("par2signalee", "par2signalee", 2, 1, 10); |
557 |
< |
RooRealVar par3signalee("par3signalee", "par3signalee", 45, 0, 200); |
554 |
> |
RooRealVar fsignalSF("fsignalSF", "fsignalSF", 10, 0, 300); |
555 |
> |
RooRealVar par1signalSF("par1signalSF", "par1signalSF", 45, 20, 100); |
556 |
> |
RooRealVar par2signalSF("par2signalSF", "par2signalSF", 2, 1, 10); |
557 |
> |
RooRealVar par3signalSF("par3signalSF", "par3signalSF", StartingMedge, 0, 300); |
558 |
|
|
559 |
< |
RooVoigtian zee("zee", "zee", mll, meanzee, widthzee, sigmazee); |
559 |
> |
RooVoigtian zSF("zSF", "zSF", mll, meanzSF, widthzSF, sigmazSF); |
560 |
|
|
561 |
+ |
if(EdgeFitter::FixedMEdge>0) par3signalSF.setConstant(); |
562 |
|
|
563 |
< |
RooSUSYBkgPdf ttbaree("ttbaree","ttbaree", mll , par1ttbaree, par2ttbaree, par3ttbaree, par4ttbaree); |
564 |
< |
//RooSUSYTPdf signalee("signalee","signalee", mll , par1signalee, par2signalee, par3signalee); |
565 |
< |
RooSUSYTPdf signalee("signalee","signalee", mll , par1signalee, sigmazee, par3signalee); |
566 |
< |
|
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 |
< |
|
563 |
> |
RooSUSYBkgPdf ttbarSF("ttbarSF","ttbarSF", mll , par1ttbarSF, par2ttbarOF, par3ttbarOF, par4ttbarOF); |
564 |
> |
RooSUSYTPdf signalSF("signalSF","signalSF", mll , par1signalSF, sigmazSF, par3signalSF); |
565 |
> |
|
566 |
> |
RooAddPdf model_SF("model_SF","model_SF", RooArgList(zSF, ttbarSF, signalSF), RooArgList(fzSF, fttbarSF, fsignalSF)); |
567 |
|
|
568 |
|
RooSimultaneous simPdf("simPdf","simultaneous pdf",sample) ; |
569 |
< |
simPdf.addPdf(model_ee,"ee") ; |
570 |
< |
simPdf.addPdf(model_emu,"em") ; |
569 |
> |
simPdf.addPdf(model_SF,"SF") ; |
570 |
> |
simPdf.addPdf(model_OF,"OF") ; |
571 |
|
|
572 |
< |
RooFitResult *result = simPdf.fitTo(combData, RooFit::Save()); |
431 |
< |
result->Print(); |
572 |
> |
RooFitResult *result = simPdf.fitTo(combData, RooFit::Save(), RooFit::Extended(),RooFit::Minos(true)); |
573 |
|
|
574 |
< |
RooPlot* frame1 = mll.frame(RooFit::Bins(25),RooFit::Title("EE sample")) ; |
575 |
< |
combData.plotOn(frame1,RooFit::Cut("sample==sample::ee")) ; |
576 |
< |
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ; |
577 |
< |
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("ttbaree"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ; |
578 |
< |
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("zee"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed)); |
579 |
< |
simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("signalee"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen)); |
580 |
< |
|
581 |
< |
RooPlot* frame2 = mll.frame(RooFit::Bins(25),RooFit::Title("MM sample")) ; |
582 |
< |
combData.plotOn(frame2,RooFit::Cut("sample==sample::mm")) ; |
583 |
< |
simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ; |
584 |
< |
simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::Components("ttbarmm"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ; |
585 |
< |
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)); |
574 |
> |
if(result->covQual()!=3) { |
575 |
> |
write_error(__FUNCTION__,"Full fit did not converge!!! Cannot continue!"); |
576 |
> |
cout << "covQual is " << result->covQual() << endl; |
577 |
> |
EdgeFitter::FixedMEdgeChi2=-1; |
578 |
> |
if(EdgeFitter::RejectPointIfNoConvergence) return; |
579 |
> |
} else { |
580 |
> |
write_info(__FUNCTION__,"Full fit converged"); |
581 |
> |
} |
582 |
> |
|
583 |
> |
cout << "============================= < OF results > =============================" << endl; |
584 |
> |
result->Print(); |
585 |
> |
cout << "============================= < /OF results > =============================" << endl; |
586 |
|
|
587 |
|
|
588 |
< |
cout << "Result : " << endl; |
589 |
< |
cout << "f signal : " << fsignalee.getVal() << " +/- " << fsignalee.getError() << endl; |
590 |
< |
cout << "f ttbar : " << fttbaree.getVal() << " +/- " << fttbaree.getError() << endl; |
591 |
< |
cout << "f tt em : " << fttbarem.getVal() << " +/- " << fttbarem.getError() << endl; |
592 |
< |
cout << "f z ee : " << fzee.getVal() << " +/- " << fzee.getError() << endl; |
588 |
> |
RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("EE sample")) ; |
589 |
> |
frame1->GetXaxis()->CenterTitle(1); |
590 |
> |
frame1->GetYaxis()->CenterTitle(1); |
591 |
> |
combData.plotOn(frame1,RooFit::Name("SFdata"),RooFit::Cut("sample==sample::SF")) ; |
592 |
> |
simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("FullFit"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ; |
593 |
> |
simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("TTbarSFonly"),RooFit::Components("ttbarSF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ; |
594 |
> |
simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("DYSFonly"),RooFit::Components("zSF"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed)); |
595 |
> |
simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("SignalSFonly"),RooFit::Components("signalSF"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen)); |
596 |
|
|
597 |
< |
// 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)) ; |
597 |
> |
EdgeFitter::FixedMEdgeChi2 = frame1->chiSquare("FullFit", "SFdata", 3); |
598 |
|
|
460 |
– |
stringstream prefix; |
461 |
– |
if(is_data==data) prefix << "data_"; |
462 |
– |
if(is_data==mc) prefix << "mc_"; |
463 |
– |
if(is_data==mcwithsignal) prefix << "mcwithS_"; |
599 |
|
|
600 |
< |
prefix << "JZB_" << jzb_cut; |
600 |
> |
cout << "Result : " << endl; |
601 |
> |
cout << "f signal : " << fsignalSF.getVal() << " +/- " << fsignalSF.getError() << endl; |
602 |
> |
cout << "f ttbar : " << fttbarSF.getVal() << " +/- " << fttbarSF.getError() << endl; |
603 |
> |
cout << "f tt OF : " << fttbarOF.getVal() << " +/- " << fttbarOF.getError() << endl; |
604 |
> |
cout << "f z SF : " << fzSF.getVal() << " +/- " << fzSF.getError() << endl; |
605 |
> |
cout << "#Chi^{2}/NDF : " << EdgeFitter::FixedMEdgeChi2 << endl; |
606 |
|
|
607 |
< |
/* cout << "fsignalee : " << fsignalee << endl; |
608 |
< |
cout << "fttbaree : " << fttbaree << endl; |
609 |
< |
cout << "fzee : " << fzee << endl;*/ |
607 |
> |
// The same plot for the cointrol sample slice |
608 |
> |
RooPlot* frame3 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")) ; |
609 |
> |
frame3->GetXaxis()->CenterTitle(1); |
610 |
> |
frame3->GetYaxis()->CenterTitle(1); |
611 |
> |
frame3->SetMaximum(frame1->GetMaximum()); |
612 |
> |
combData.plotOn(frame3,RooFit::Cut("sample==sample::OF")) ; |
613 |
> |
simPdf.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ; |
614 |
> |
simPdf.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::Components("ttbarOF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ; |
615 |
|
|
616 |
|
|
617 |
|
TCanvas* c = new TCanvas("rf501_simultaneouspdf","rf403_simultaneouspdf") ; |
621 |
|
frame1->Draw(); |
622 |
|
if(is_data==data) DrawPrelim(); |
623 |
|
else DrawPrelim(PlottingSetup::luminosity,true); |
624 |
< |
CompleteSave(c,"Edge/"+prefix.str()+"eemm"); |
624 |
> |
stringstream infotext; |
625 |
> |
infotext << "#splitline{Fit results (" << EdgeFitter::Mode << ">" << jzb_cut << "): }{#splitline{"; |
626 |
> |
infotext << "N(Data) = " << EdgeFitter::SFSample->sumEntries() << "}{#splitline{"; |
627 |
> |
infotext << "N(Z+Jets) = " << WriteWithError(fzSF.getVal(),fzSF.getError(),3) << "}{#splitline{"; |
628 |
> |
infotext << "N(t#bar{t}) = " << WriteWithError(fttbarSF.getVal(),fttbarSF.getError(),3) << "}{#splitline{"; |
629 |
> |
infotext << "N(signal) = " << WriteWithError(fsignalSF.getVal(),fsignalSF.getError(),3) << "}{"; |
630 |
> |
infotext << "m_{edge} = " << WriteWithError(par3signalSF.getVal(),par3signalSF.getError(),3) << "}}}}}"; |
631 |
> |
|
632 |
> |
TLatex *infobox = new TLatex(0.57,0.75,infotext.str().c_str()); |
633 |
> |
infobox->SetNDC(); |
634 |
> |
infobox->SetTextSize(0.03); |
635 |
> |
infobox->Draw(); |
636 |
> |
if(EdgeFitter::FixedMEdge>=0) CompleteSave(c,"Edge/"+prefix.str()+"_SF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false); |
637 |
> |
else CompleteSave(c,"Edge/"+prefix.str()+"_SF",false,false); |
638 |
|
delete c; |
639 |
|
|
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 |
– |
|
640 |
|
TCanvas* e = new TCanvas("rf501_simultaneouspdfem","rf403_simultaneouspdfem") ; |
641 |
|
e->cd(); |
642 |
|
gPad->SetLeftMargin(0.15); |
644 |
|
frame3->Draw(); |
645 |
|
if(is_data==data) DrawPrelim(); |
646 |
|
else DrawPrelim(PlottingSetup::luminosity,true); |
647 |
< |
CompleteSave(e,"Edge/"+prefix.str()+"emu"); |
647 |
> |
if(EdgeFitter::FixedMEdge>=0) CompleteSave(e,"Edge/"+prefix.str()+"_OF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false); |
648 |
> |
else CompleteSave(e,"Edge/"+prefix.str()+"_OF",false,false); |
649 |
|
delete e; |
650 |
|
|
651 |
+ |
|
652 |
+ |
|
653 |
+ |
|
654 |
|
/* TCanvas* f = new TCanvas("rf501_simultaneouspdfem","rf403_simultaneouspdfem") ; |
655 |
|
f->cd(); |
656 |
|
gPad->SetLeftMargin(0.15); |
658 |
|
frame4->Draw(); |
659 |
|
if(is_data==data) DrawPrelim(); |
660 |
|
else DrawPrelim(PlottingSetup::luminosity,true); |
661 |
< |
CompleteSave(f,"Edge/"+prefix.str()+"eemm"); |
661 |
> |
CompleteSave(f,"Edge/"+prefix.str()+"_SF"); |
662 |
|
delete f;*/ |
663 |
< |
|
663 |
> |
|
664 |
> |
|
665 |
> |
/* |
666 |
> |
float maxZ=200; |
667 |
> |
RooWorkspace* wspace = new RooWorkspace(); |
668 |
> |
stringstream mllvar; |
669 |
> |
mllvar << "mll[" << (mllmax-mllmin)/2 << "," << mllmin << "," << mllmax << "]"; |
670 |
> |
wspace->factory(mllvar.str().c_str()); |
671 |
> |
wspace->var("mll")->setBins(30); |
672 |
> |
wspace->factory("nSig[1.,0.,100.]"); |
673 |
> |
wspace->factory(("nZ[0.04.,0.,"+any2string(maxZ)+"]").c_str()); |
674 |
> |
wspace->factory("rME[1.12,1.05,1.19]"); |
675 |
> |
wspace->factory("effUncert[1.]"); |
676 |
> |
EdgeFitter::prepareLimits(wspace, true); |
677 |
> |
*/ |
678 |
> |
|
679 |
> |
write_warning(__FUNCTION__," A lot missing here to calculate limits"); |
680 |
> |
|
681 |
|
} |
682 |
|
|
683 |
|
void EdgeFitter::DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, float jzb_cut, int icut, int is_data, TCut cut, TTree *signalevents=0) { |
690 |
|
|
691 |
|
EdgeFitter::PrepareDatasets(is_data); |
692 |
|
|
693 |
+ |
EdgeFitter::DrawDatasetContent(is_data); |
694 |
+ |
|
695 |
|
RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow(); |
696 |
|
RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL); |
697 |
+ |
|
698 |
+ |
|
699 |
+ |
bool ScanMassRange=true; |
700 |
+ |
float ScanSteps=5.0;//GeV |
701 |
+ |
|
702 |
+ |
|
703 |
+ |
|
704 |
+ |
if(ScanMassRange) { |
705 |
+ |
TFile *fscan = new TFile("fscan.root","UPDATE"); |
706 |
+ |
TGraph *gr = new TGraph(); |
707 |
+ |
stringstream GrName; |
708 |
+ |
GrName << "ScanGraphFor_" << EdgeFitter::Mode << "_" << jzb_cut; |
709 |
+ |
gr->SetName(GrName.str().c_str()); |
710 |
+ |
|
711 |
+ |
int i=0; |
712 |
+ |
for(float tempMedge=10;tempMedge<=300;tempMedge+=ScanSteps) { |
713 |
+ |
write_info(__FUNCTION__,"Now testing Medge="+any2string(tempMedge)+" for "+EdgeFitter::Mode+">"+any2string(jzb_cut)); |
714 |
+ |
EdgeFitter::FixedMEdge=tempMedge; |
715 |
+ |
EdgeFitter::DoFit(is_data, jzb_cut); |
716 |
+ |
if(EdgeFitter::FixedMEdgeChi2<0) continue; |
717 |
+ |
gr->SetPoint(i,tempMedge,EdgeFitter::FixedMEdgeChi2); |
718 |
+ |
i++; |
719 |
+ |
} |
720 |
+ |
|
721 |
+ |
TCanvas *ScanCan = new TCanvas("ScanCan","ScanCan",500,500); |
722 |
+ |
gr->GetXaxis()->SetTitle("m_{edge}"); |
723 |
+ |
gr->GetXaxis()->CenterTitle(); |
724 |
+ |
gr->GetYaxis()->SetTitle("#Chi^{2} / NDF"); |
725 |
+ |
gr->GetYaxis()->CenterTitle(); |
726 |
+ |
gr->GetYaxis()->SetTitleOffset(0.95); |
727 |
+ |
gr->GetXaxis()->SetTitleOffset(0.9); |
728 |
+ |
gr->SetLineColor(kBlue); |
729 |
+ |
gr->SetTitle(""); |
730 |
+ |
gr->Draw("AL"); |
731 |
+ |
stringstream ScanCanSave; |
732 |
+ |
ScanCanSave << "Edge/MEdgeScan_"+EdgeFitter::Mode+"_" << jzb_cut; |
733 |
+ |
if(is_data) DrawPrelim(); |
734 |
+ |
else DrawMCPrelim(); |
735 |
+ |
CompleteSave(ScanCan,ScanCanSave.str()); |
736 |
+ |
fscan->cd(); |
737 |
+ |
gr->Write(); |
738 |
+ |
delete ScanCan; |
739 |
+ |
fscan->Close(); |
740 |
+ |
} else { |
741 |
+ |
EdgeFitter::DoFit(is_data, jzb_cut); |
742 |
+ |
} |
743 |
+ |
|
744 |
+ |
|
745 |
+ |
|
746 |
+ |
|
747 |
|
EdgeFitter::DoFit(is_data, jzb_cut); |
748 |
|
RooMsgService::instance().setGlobalKillBelow(msglevel); |
749 |
|
|
753 |
|
} |
754 |
|
|
755 |
|
void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, vector<float> jzb_cut, int is_data, TCut cut, TTree *signalevents=0) { |
756 |
< |
for(int icut=0;icut<jzb_cut.size();icut++) { |
756 |
> |
|
757 |
> |
EdgeFitter::Mode="JZB"; |
758 |
> |
if(mcjzb=="met[4]") EdgeFitter::Mode="MET"; |
759 |
> |
|
760 |
> |
for(int icut=0;icut<(int)jzb_cut.size();icut++) { |
761 |
|
stringstream addcut; |
762 |
|
if(is_data==1) addcut << "(" << datajzb << ">" << jzb_cut[icut] << ")"; |
763 |
|
if(is_data!=1) addcut << "(" << mcjzb << ">" << jzb_cut[icut] << ")"; |