182 |
|
if(!automatized) dout << " PU: " << funcUp->Eval(jzbSel) << " " << func->Eval(jzbSel) |
183 |
|
<< "(" << (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel)*100. << "%)" << std::endl; |
184 |
|
|
185 |
< |
return (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel)*100.; |
185 |
> |
return (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel); |
186 |
|
|
187 |
|
} |
188 |
|
|
218 |
|
else if(i==1) resdown=res; |
219 |
|
else if(i==2) resup=res; |
220 |
|
} |
221 |
< |
if(TMath::Abs(rescent-resup)>TMath::Abs(rescent-resdown)) result=(TMath::Abs(rescent-resup)/rescent)*100; |
222 |
< |
else result=(TMath::Abs(rescent-resdown)/rescent)*100; |
221 |
> |
if(TMath::Abs(rescent-resup)>TMath::Abs(rescent-resdown)) result=(TMath::Abs(rescent-resup)/rescent); |
222 |
> |
else result=(TMath::Abs(rescent-resdown)/rescent); |
223 |
|
} |
224 |
|
|
225 |
|
//____________________________________________________________________________________ |
237 |
|
TCut ksel2("pfJetGoodNum>2&&abs(mll-91.2)<20&&id1==id2&&"+TString(mcjzb)+ngeq_or_leq()+TString("-")+TString(jzbSelStr)); |
238 |
|
events->Draw(mcjzbexpression.c_str(),kbase&&ksel,"goff"); |
239 |
|
Float_t sel = events->GetSelectedRows(); |
240 |
< |
events->Draw(mcjzbexpression.c_str(),kbase&&ksel2,"goff"); |
241 |
< |
Float_t nsel = events->GetSelectedRows(); |
240 |
> |
Float_t nsel=0; |
241 |
> |
if(ConsiderSignalContaminationForLimits) { |
242 |
> |
events->Draw(mcjzbexpression.c_str(),kbase&&ksel2,"goff"); |
243 |
> |
nsel = events->GetSelectedRows(); |
244 |
> |
} |
245 |
|
// events->Draw(mcjzbexpression.c_str(),kbase,"goff"); |
246 |
|
// Float_t tot = events->GetSelectedRows(); |
247 |
|
Float_t tot = Neventsinfile; |
248 |
|
|
249 |
< |
result=(sel-nsel)/tot; |
250 |
< |
cout << "~~~~~~~~~~~~~ MCefficiency: Result : (" << sel << " - " << nsel << " / " << tot << " = " << result << endl; |
251 |
< |
resulterr=TMath::Sqrt(sel/tot*(1-sel/tot)/tot); |
252 |
< |
if(!automatized) dout << " MC efficiency: " << result << "+-" << resulterr << std::endl; |
249 |
> |
if(ConsiderSignalContaminationForLimits) { |
250 |
> |
result=(sel-nsel)/tot; |
251 |
> |
resulterr=(1.0/tot)*TMath::Sqrt(sel+nsel+(sel-nsel)*(sel-nsel)/tot); |
252 |
> |
} else {//no signal contamination considered: |
253 |
> |
result=(sel)/tot; |
254 |
> |
resulterr=TMath::Sqrt(sel/tot*(1+sel/tot)/tot); |
255 |
> |
} |
256 |
> |
if(!automatized) dout << " MC efficiency: " << result << "+-" << resulterr << " ( JZB>" << jzbSel << " : " << sel << " , JZB<-" << jzbSel << " : " << nsel << " and nevents=" << tot << ")" << std::endl; |
257 |
|
} |
258 |
|
|
259 |
|
void JZBefficiency(TTree *events, string informalname, float &jzbeff, float &jzbefferr, bool requireZ, string addcut="") { |
260 |
|
TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
254 |
– |
cout << "Getting started with JZB efficiency" << endl; |
261 |
|
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
262 |
|
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
263 |
|
TH1F* hLM4 = plotEff(events,kbase,informalname); |
301 |
|
if(!automatized) dout << " JESup: " << effp << " (" << (effp-eff)/eff*100. << "%)" << std::endl; |
302 |
|
if(!automatized) dout << " central: " << eff << std::endl; |
303 |
|
if(!automatized) dout << " JESdown: " << effm << " (" << (effm-eff)/eff*100. << "%)" << std::endl; |
304 |
< |
jesup=(effp-eff)/eff*100.; |
305 |
< |
jesdown=(effm-eff)/eff*100.; |
304 |
> |
jesup=(effp-eff)/eff; |
305 |
> |
jesdown=(effm-eff)/eff; |
306 |
|
} |
307 |
|
|
308 |
|
//________________________________________________________________________ |
327 |
|
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.+systematic) << "(-"<<syst*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)" << std::endl; |
328 |
|
if(!automatized) dout << " efficiency at JZB==" << jzbSel << ": " << eff << std::endl; |
329 |
|
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.-systematic) << "(-"<<syst*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)" << std::endl; |
330 |
< |
up=((effp-eff)/eff)*100; |
331 |
< |
down=((effm-eff)/eff)*100; |
330 |
> |
up=((effp-eff)/eff); |
331 |
> |
down=((effm-eff)/eff); |
332 |
|
} |
333 |
|
|
334 |
|
//________________________________________________________________________ |
362 |
|
float JetEnergyScaleUncert=0.1; |
363 |
|
float JZBScaleUncert=0.1; |
364 |
|
mcjzbexpression=mcjzb; |
365 |
< |
float triggereff=4;//percent! |
365 |
> |
float triggereff=4.0/100;// in range [0,1] |
366 |
|
dout << "Trigger efficiency not implemented in this script yet, still using external one" << endl; |
367 |
< |
float leptonseleff=2;//percent! |
367 |
> |
float leptonseleff=2.0/100;// in range [0,1] |
368 |
|
dout << "Lepton selection efficiency not implemented in this script yet, still using external one" << endl; |
369 |
|
|
370 |
|
float mceff,mcefferr,jzbeff,jzbefferr; |
396 |
|
dout << " SUMMARY FOR " << informalname << " with JZB>" << jzbSel << " (all in %) "; |
397 |
|
if(addcut!="") dout << "With additional cut: " << addcut; |
398 |
|
dout << endl; |
399 |
< |
dout << "MC efficiency: " << 100*mceff << "+/-" << 100*mcefferr << endl; |
400 |
< |
dout << "Trigger efficiency: " << triggereff << endl; |
401 |
< |
dout << "Lepton Sel Eff: " << leptonseleff << endl; |
402 |
< |
dout << "Jet energy scale: " << jesup << " " << jesdown << endl; |
403 |
< |
dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << endl; |
404 |
< |
dout << "Resolution : " << resolution << endl; |
405 |
< |
dout << "From peak : " << sysfrompeak << endl; |
406 |
< |
dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; |
407 |
< |
dout << "JZB response : " << resp << " +/-" << resperr << " (not yet included below) " << endl; |
399 |
> |
dout << "MC efficiency: " << mceff << "+/-" << mcefferr << endl; // in range [0,1] |
400 |
> |
dout << "Trigger efficiency: " << triggereff << endl; // in range [0,1] |
401 |
> |
dout << "Lepton Sel Eff: " << leptonseleff << endl; // in range [0,1] |
402 |
> |
dout << "Jet energy scale: " << jesup << " " << jesdown << endl; // in range [0,1] |
403 |
> |
dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << endl; // in range [0,1] |
404 |
> |
dout << "Resolution : " << resolution << endl; // in range [0,1] |
405 |
> |
dout << "From peak : " << sysfrompeak << endl; // in range [0,1] |
406 |
> |
dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1] |
407 |
> |
dout << "JZB response : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1] |
408 |
|
|
409 |
|
float toterr=0; |
410 |
< |
toterr+=(triggereff/100)*(triggereff/100); |
411 |
< |
toterr+=(leptonseleff/100)*(leptonseleff/100); |
412 |
< |
if(fabs(jesup)>fabs(jesdown)) toterr+=(jesup/100)*(jesup/100); else toterr+=(jesdown/100)*(jesdown/100); |
413 |
< |
if(fabs(scaleup)>fabs(scaledown)) toterr+=(scaleup/100)*(scaleup/100); else toterr+=(scaledown/100)*(scaledown/100); |
414 |
< |
toterr+=(resolution/100)*(resolution/100); |
415 |
< |
toterr+=(sysfrompeak/100)*(sysfrompeak/100); |
416 |
< |
toterr=TMath::Sqrt(toterr); |
417 |
< |
dout << "FINAL RESULT : " << 100*mceff << " +/- "<< 100*mcefferr << " (stat) +/- " << 100*toterr << " (syst) %" << endl; |
418 |
< |
dout << " we thus use the sqrt of the sum of the squares which is : " << 100*TMath::Sqrt(mcefferr*mcefferr+(toterr*toterr)) << endl; |
410 |
> |
toterr+=(triggereff)*(triggereff); |
411 |
> |
toterr+=(leptonseleff)*(leptonseleff); |
412 |
> |
if(fabs(jesup)>fabs(jesdown)) toterr+=(jesup*jesup); else toterr+=(jesdown*jesdown); |
413 |
> |
if(fabs(scaleup)>fabs(scaledown)) toterr+=(scaleup*scaleup); else toterr+=(scaledown*scaledown); |
414 |
> |
toterr+=(resolution*resolution); |
415 |
> |
toterr+=(sysfrompeak*sysfrompeak); |
416 |
> |
dout << "TOTAL SYSTEMATICS: " << TMath::Sqrt(toterr) << " --> " << TMath::Sqrt(toterr)*mceff << endl; |
417 |
> |
float systerr=TMath::Sqrt(toterr)*mceff; |
418 |
> |
toterr=TMath::Sqrt(toterr*mceff*mceff+mcefferr*mcefferr);//also includes stat err! |
419 |
> |
|
420 |
> |
dout << "FINAL RESULT : " << 100*mceff << " +/- "<< 100*mcefferr << " (stat) +/- " << 100*systerr << " (syst) %" << endl; |
421 |
> |
dout << " we thus use the sqrt of the sum of the squares of the stat & syst err, which is : " << 100*toterr << endl; |
422 |
> |
|
423 |
> |
//Do not modify the lines below or mess with the order; this order is expected by all limit calculating functions! |
424 |
|
vector<float> res; |
425 |
|
res.push_back(jzbSel); |
426 |
|
res.push_back(mceff); |
427 |
|
res.push_back(mcefferr); |
428 |
|
res.push_back(toterr); |
429 |
|
res.push_back(TMath::Sqrt((mcefferr)*(mcefferr)+(toterr*toterr))); |
430 |
< |
if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup/100)); else res.push_back(fabs(jesdown)/100); |
431 |
< |
if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)/100); else res.push_back(fabs(scaledown)/100); |
432 |
< |
res.push_back(fabs(resolution)/100); |
430 |
> |
if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup)); else res.push_back(fabs(jesdown)); |
431 |
> |
if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)); else res.push_back(fabs(scaledown)); |
432 |
> |
res.push_back(fabs(resolution)); |
433 |
|
results.push_back(res); |
434 |
|
} |
435 |
|
|