224 |
|
|
225 |
|
//____________________________________________________________________________________ |
226 |
|
// Total selection efficiency (MC) |
227 |
< |
void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,string addcut="") { |
227 |
> |
void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="") { |
228 |
|
|
229 |
|
char jzbSelStr[256]; sprintf(jzbSelStr,"%f",jzbSel); |
230 |
|
// All acceptance cuts at gen. level |
231 |
< |
TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&genJZB"+geq_or_leq()+TString(jzbSelStr)+"&&genId1==-genId2"); |
231 |
> |
//TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&genJZB"+geq_or_leq()+TString(jzbSelStr)+"&&genId1==-genId2"); |
232 |
> |
TCut kbase(""); |
233 |
|
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
234 |
|
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
235 |
|
// Corresponding reco. cuts |
236 |
|
TCut ksel("pfJetGoodNum>2&&abs(mll-91.2)<20&&id1==id2&&"+TString(mcjzb)+geq_or_leq()+TString(jzbSelStr)); |
237 |
< |
|
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,"goff"); |
241 |
< |
Float_t tot = events->GetSelectedRows(); |
240 |
> |
events->Draw(mcjzbexpression.c_str(),kbase&&ksel2,"goff"); |
241 |
> |
Float_t nsel = events->GetSelectedRows(); |
242 |
> |
// events->Draw(mcjzbexpression.c_str(),kbase,"goff"); |
243 |
> |
// Float_t tot = events->GetSelectedRows(); |
244 |
> |
Float_t tot = Neventsinfile; |
245 |
|
|
246 |
< |
result=sel/tot; |
246 |
> |
result=(sel-nsel)/tot; |
247 |
|
resulterr=TMath::Sqrt(sel/tot*(1-sel/tot)/tot); |
248 |
< |
if(!automatized) dout << " MC efficiency: " << result << "+-" << resulterr << std::endl; |
248 |
> |
dout << " MC efficiency: " << result << "+-" << resulterr << " ( JZB>" << jzbSel << " : " << sel << " , JZB<-" << jzbSel << " : " << nsel << " and nevents=" << tot << ")" << std::endl; |
249 |
|
} |
250 |
|
|
251 |
|
void JZBefficiency(TTree *events, string informalname, float &jzbeff, float &jzbefferr, bool requireZ, string addcut="") { |
252 |
|
TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
253 |
+ |
cout << "Getting started with JZB efficiency" << endl; |
254 |
|
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
255 |
|
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
256 |
|
TH1F* hLM4 = plotEff(events,kbase,informalname); |
350 |
|
} |
351 |
|
|
352 |
|
|
353 |
< |
void do_systematics_for_one_file(TTree *events,string informalname, vector<vector<float> > &results,string mcjzb,string datajzb,float peakerror,bool requireZ=false, string addcut="") { |
353 |
> |
void do_systematics_for_one_file(TTree *events,int Neventsinfile,string informalname, vector<vector<float> > &results,string mcjzb,string datajzb,float peakerror,bool requireZ=false, string addcut="") { |
354 |
|
|
355 |
|
float JetEnergyScaleUncert=0.1; |
356 |
|
float JZBScaleUncert=0.1; |
357 |
|
mcjzbexpression=mcjzb; |
353 |
– |
|
358 |
|
float triggereff=4;//percent! |
359 |
|
dout << "Trigger efficiency not implemented in this script yet, still using external one" << endl; |
360 |
|
float leptonseleff=2;//percent! |
362 |
|
|
363 |
|
float mceff,mcefferr,jzbeff,jzbefferr; |
364 |
|
if(!automatized) dout << "MC efficiencies:" << endl; |
365 |
< |
MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,addcut); |
365 |
> |
MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,Neventsinfile,addcut); |
366 |
|
JZBefficiency(events,informalname,jzbeff,jzbefferr,requireZ,addcut); |
367 |
|
if(!automatized) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << endl; |
368 |
|
|
415 |
|
res.push_back(mcefferr); |
416 |
|
res.push_back(toterr); |
417 |
|
res.push_back(TMath::Sqrt((mcefferr)*(mcefferr)+(toterr*toterr))); |
418 |
< |
|
418 |
> |
if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup/100)); else res.push_back(fabs(jesdown)/100); |
419 |
> |
if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)/100); else res.push_back(fabs(scaledown)/100); |
420 |
> |
res.push_back(fabs(resolution)/100); |
421 |
|
results.push_back(res); |
422 |
|
} |
423 |
|
|
429 |
|
for(int ibin=0;ibin<bins.size();ibin++) { |
430 |
|
jzbSel=bins[ibin]; |
431 |
|
geqleq="geq"; |
432 |
< |
do_systematics_for_one_file((signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,systematics,mcjzb,datajzb,mcpeakerror,requireZ); |
432 |
> |
do_systematics_for_one_file((signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].Nentries,(signalsamples.collection)[isignal].samplename,systematics,mcjzb,datajzb,mcpeakerror,requireZ); |
433 |
|
}//end of bin loop |
434 |
|
}//end of signal loop |
435 |
|
return systematics; |