1 |
|
#include <iostream> |
2 |
|
#include <vector> |
3 |
|
#include <sys/stat.h> |
4 |
+ |
#include <algorithm> |
5 |
+ |
#include <cmath> |
6 |
|
|
7 |
|
#include <TMath.h> |
8 |
|
#include <TColor.h> |
278 |
|
|
279 |
|
//____________________________________________________________________________________ |
280 |
|
// Total selection efficiency (MC) |
281 |
< |
void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="", int k = 0) { |
281 |
> |
//returns the efficiency WITHOUT signal contamination, and the result and resulterr contain the result and the corresponding error |
282 |
> |
Value MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="", int k = 0) { |
283 |
|
|
284 |
|
char jzbSelStr[256]; sprintf(jzbSelStr,"%f",jzbSel); |
285 |
|
// All acceptance cuts at gen. level |
320 |
|
// Float_t tot = events->GetSelectedRows(); |
321 |
|
Float_t tot = Neventsinfile; |
322 |
|
|
323 |
+ |
Value result_wo_signalcont; |
324 |
+ |
|
325 |
|
if(ConsiderSignalContaminationForLimits) { |
326 |
|
result=(sel-nsel)/tot; |
327 |
|
resulterr=(1.0/tot)*TMath::Sqrt(sel+nsel+(sel-nsel)*(sel-nsel)/tot); |
328 |
+ |
result_wo_signalcont=Value(sel/tot,TMath::Sqrt(sel/tot*(1+sel/tot)/tot)); |
329 |
|
} else {//no signal contamination considered: |
330 |
|
result=(sel)/tot; |
331 |
|
resulterr=TMath::Sqrt(sel/tot*(1+sel/tot)/tot); |
332 |
+ |
result_wo_signalcont=Value(result,resulterr); |
333 |
|
} |
334 |
+ |
if(!automatized && k>0 ) dout << "PDF assessment: "; |
335 |
|
if(!automatized) dout << " MC efficiency: " << result << "+-" << resulterr << " ( JZB>" << jzbSel << " : " << sel << " , JZB<-" << jzbSel << " : " << nsel << " and nevents=" << tot << ") with normFact=" << normFactor << std::endl; |
336 |
|
delete effh; |
337 |
+ |
return result_wo_signalcont; |
338 |
|
} |
339 |
|
|
340 |
|
|
421 |
|
Float_t eff = Interpolate(jzbSel,hist); |
422 |
|
Float_t effp = Interpolate(jzbSel*(1.+systematic),hist); |
423 |
|
Float_t effm = Interpolate(jzbSel*(1.-systematic),hist); |
424 |
< |
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.+systematic) << "(-"<<syst*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)" << std::endl; |
424 |
> |
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.+systematic) << "(-"<<systematic*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)" << std::endl; |
425 |
|
if(!automatized) dout << " efficiency at JZB==" << jzbSel << ": " << eff << std::endl; |
426 |
< |
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.-systematic) << "(-"<<syst*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)" << std::endl; |
426 |
> |
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.-systematic) << "(-"<<systematic*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)" << std::endl; |
427 |
|
up=((effp-eff)/eff); |
428 |
|
down=((effm-eff)/eff); |
429 |
|
} |
447 |
|
hJzbResp->SetMinimum(0.2); |
448 |
|
hJzbResp->Fit("pol0","Q"); |
449 |
|
TF1 *fittedfunction = hJzbResp->GetFunction("pol0"); |
450 |
< |
resp=fittedfunction->GetParameter(0); |
451 |
< |
resperr=fittedfunction->GetParError(0); |
452 |
< |
if(!automatized) dout << " Response: " << resp << " +/- " << resperr << endl; |
450 |
> |
if(!fittedfunction) { |
451 |
> |
// in case there are not enough points passing our selection |
452 |
> |
cout << "OOPS response function invalid, assuming 100% error !!!!" << endl; |
453 |
> |
resp=1; |
454 |
> |
resperr=1; |
455 |
> |
} else { |
456 |
> |
resp=fittedfunction->GetParameter(0); |
457 |
> |
resperr=fittedfunction->GetParError(0); |
458 |
> |
if(!automatized) dout << " Response: " << resp << " +/- " << resperr << endl; |
459 |
> |
} |
460 |
|
delete hJzbResp; |
461 |
|
} |
462 |
|
|
494 |
|
float triggereff=5.0/100;// in range [0,1] |
495 |
|
dout << "Trigger efficiency not implemented in this script yet, still using external one" << endl; |
496 |
|
float leptonseleff=2.0/100;// in range [0,1] |
497 |
+ |
leptonseleff=TMath::Sqrt(leptonseleff*leptonseleff+leptonseleff*leptonseleff); // because the 2% is per lepton |
498 |
|
dout << "Lepton selection efficiency not implemented in this script yet, still using external one" << endl; |
499 |
|
|
500 |
|
int NPdfs=0; |
502 |
|
|
503 |
|
float mceff,mcefferr,jzbeff,jzbefferr; |
504 |
|
if(!automatized) dout << "MC efficiencies:" << endl; |
505 |
< |
MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,Neventsinfile,addcut,-1); |
506 |
< |
JZBefficiency(events,informalname,jzbeff,jzbefferr,requireZ,addcut); |
505 |
> |
Value mceff_nosigcont = MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,Neventsinfile,addcut,-1); |
506 |
> |
if(!automatized) cout << " Without signal contamination, we find an efficiency of " << mceff_nosigcont << endl; |
507 |
> |
|
508 |
> |
if(PlottingSetup::computeJZBefficiency) JZBefficiency(events,informalname,jzbeff,jzbefferr,requireZ,addcut); |
509 |
|
if(!automatized) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << endl; |
510 |
|
|
511 |
|
if(!automatized) dout << "Error from Peak position:" << endl; |
522 |
|
|
523 |
|
if(!automatized) dout << "JZB response: " << std::endl; |
524 |
|
float resp,resperr; |
525 |
< |
JZBresponse(events,requireZ,resp,resperr,addcut); |
525 |
> |
if(PlottingSetup::computeJZBresponse) { |
526 |
> |
if(!automatized) dout << "JZB response: " << std::endl; |
527 |
> |
JZBresponse(events,requireZ,resp,resperr,addcut); |
528 |
> |
} |
529 |
|
|
530 |
|
if(!automatized) dout << "Pileup: " << std::endl; |
531 |
< |
float resolution=pileup(events,requireZ,informalname,addcut); |
531 |
> |
float resolution; |
532 |
> |
resolution=pileup(events,requireZ,informalname,addcut); |
533 |
|
|
534 |
|
float PDFuncert=0; |
535 |
+ |
if(!automatized) dout << "Assessing PDF uncertainty: " << std::endl; |
536 |
|
if(ismSUGRA) PDFuncert = get_pdf_uncertainty(events, mcjzb, requireZ, Neventsinfile, NPdfs, addcut); |
537 |
|
|
538 |
|
dout << "_______________________________________________" << endl; |
547 |
|
dout << "Resolution : " << resolution << endl; // in range [0,1] |
548 |
|
dout << "From peak : " << sysfrompeak << endl; // in range [0,1] |
549 |
|
if(ismSUGRA) dout << "PDF uncertainty : " << PDFuncert << endl; // in range [0,1] |
550 |
< |
dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1] |
551 |
< |
dout << "JZB response : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1] |
550 |
> |
if(PlottingSetup::computeJZBefficiency) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1] |
551 |
> |
if(PlottingSetup::computeJZBresponse)dout << "JZB response : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1] |
552 |
|
|
553 |
|
float toterr=0; |
554 |
|
toterr+=(triggereff)*(triggereff); |
575 |
|
if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup)); else res.push_back(fabs(jesdown)); |
576 |
|
if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)); else res.push_back(fabs(scaledown)); |
577 |
|
res.push_back(fabs(resolution)); |
578 |
+ |
res.push_back(mceff_nosigcont.getValue()); |
579 |
+ |
res.push_back(mceff_nosigcont.getError()); |
580 |
|
if(ismSUGRA) res.push_back(PDFuncert); |
581 |
|
results.push_back(res); |
582 |
|
} |