149 |
|
TH1F* plotEff(TTree* events, TCut kbase, TString informalname, int flipped) { |
150 |
|
iplot++; |
151 |
|
int count=iplot; |
152 |
+ |
iplot++; |
153 |
+ |
int count2=iplot; |
154 |
|
// Define new histogram |
155 |
|
char hname[30]; sprintf(hname,"hJzbEff%d",count); |
156 |
< |
TH1F* hJzbEff = new TH1F(hname,"JZB selection efficiency ; JZB (GeV/c); Efficiency", |
157 |
< |
nBins,jzbMin,jzbMax); |
156 |
> |
char hname2[30]; sprintf(hname2,"hJzbEff%d",count2); |
157 |
> |
TH1F* hJzbEff = new TH1F(hname,"JZB selection efficiency ; JZB [GeV]; Efficiency",nBins,jzbMin,jzbMax); |
158 |
> |
TH1F* hJzbEff2= new TH1F(hname2,"JZB selection efficiency ; JZB [GeV]; Efficiency",1,-14000,14000); |
159 |
|
Float_t step = (jzbMax-jzbMin)/static_cast<Float_t>(nBins); |
160 |
< |
|
161 |
< |
if(flipped==0) events->Draw(mcjzbexpression.c_str(),"genJZB>-400"&&kbase,"goff"); |
162 |
< |
else events->Draw(("-"+mcjzbexpression).c_str(),"genJZB>-14000"&&kbase,"goff"); |
163 |
< |
Float_t maxEff = events->GetSelectedRows(); |
160 |
> |
|
161 |
> |
if(flipped==0) events->Draw((mcjzbexpression+">>"+(string)hname2).c_str(),("genJZB>-400"&&kbase),"goff"); |
162 |
> |
else events->Draw(("(-"+mcjzbexpression+")>>"+(string)hname2).c_str(),("genJZB>-400"&&kbase),"goff"); |
163 |
> |
Float_t maxEff = hJzbEff2->Integral(); |
164 |
|
if(verbose>0) dout << hname << " (" << informalname <<") " << maxEff << std::endl; |
165 |
|
|
166 |
|
if(verbose>0) dout << "JZB max = " << jzbMax << std::endl; |
168 |
|
char cut[256]; |
169 |
|
for ( Int_t iBin = 0; iBin<nBins; ++iBin ) { |
170 |
|
sprintf(cut,"genJZB>%3f",jzbMin+iBin*step); |
171 |
< |
events->Draw(mcjzbexpression.c_str(),TCut(cut)&&kbase,"goff"); |
172 |
< |
Float_t eff = static_cast<Float_t>(events->GetSelectedRows())/maxEff; |
173 |
< |
// dout << "COUCOU " << __LINE__ << std::endl; |
171 |
> |
if(flipped==0) events->Draw((mcjzbexpression+">>"+(string)hname2).c_str(),(TCut(cut)&&kbase),"goff"); |
172 |
> |
if(flipped>0) events->Draw(("(-"+mcjzbexpression+")>>"+(string)hname2).c_str(),(TCut(cut)&&kbase),"goff"); |
173 |
> |
Float_t eff = static_cast<Float_t>(hJzbEff2->Integral())/maxEff; |
174 |
|
hJzbEff->SetBinContent(iBin+1,eff); |
175 |
|
hJzbEff->SetBinError(iBin+1,TMath::Sqrt(eff*(1-eff)/maxEff)); |
176 |
|
} |
177 |
+ |
delete hJzbEff2; |
178 |
|
return hJzbEff; |
175 |
– |
|
176 |
– |
|
179 |
|
} |
180 |
|
|
181 |
|
|
182 |
+ |
|
183 |
|
//________________________________________________________________________________________ |
184 |
|
// Master Formula |
185 |
|
void master_formula(std::vector<float> eff, float &errHi, float &errLo) { |
297 |
|
} |
298 |
|
if(TMath::Abs(rescent-resup)>TMath::Abs(rescent-resdown)) result=(TMath::Abs(rescent-resup)/(float)rescent); |
299 |
|
else result=(TMath::Abs(rescent-resdown)/(float)rescent); |
300 |
+ |
cout << " " << result << endl; |
301 |
|
} |
302 |
|
|
303 |
|
|
370 |
|
result=(sel)/ntotal; |
371 |
|
resulterr=TMath::Sqrt(sel/ntotal*(1+sel/ntotal)/ntotal); |
372 |
|
|
373 |
+ |
delete effh; |
374 |
|
} |
375 |
|
|
376 |
|
//____________________________________________________________________________________ |
429 |
|
string emnewNegSide = "((id1!=id2)&&(" + snegSide + "))*" + svar; // only used for off peak analysis |
430 |
|
|
431 |
|
TH1F *effh= new TH1F("effh","effh",1,-14000,14000); |
432 |
< |
if(k>=0)events->Draw((mcjzbexpression+">>effh").c_str(), newPosSide.c_str(),"goff"); |
433 |
< |
else events->Draw((mcjzbexpression+">>effh").c_str(), (sposSide+"&&(id1==id2)").c_str(),"goff");//the OSSF condition is added for the offpeak analysis, in onpeak case it's there already but doesn't change anything. |
432 |
> |
if(k>=0)events->Draw((mcjzbexpression+">>effh").c_str(), TCut(newPosSide.c_str())*PlottingSetup::Weight,"goff"); |
433 |
> |
else events->Draw((mcjzbexpression+">>effh").c_str(), TCut((sposSide+"&&(id1==id2)").c_str())*PlottingSetup::Weight,"goff");//the OSSF condition is added for the offpeak analysis, in onpeak case it's there already but doesn't change anything. |
434 |
> |
|
435 |
|
Float_t sel = effh->Integral(); |
436 |
|
Float_t nsel=0; |
437 |
|
|
440 |
|
if(ConsiderSignalContaminationForLimits) { |
441 |
|
flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak |
442 |
|
if(PlottingSetup::RestrictToMassPeak) { |
443 |
< |
events->Draw((mcjzbexpression+">>effh").c_str(), newNegSide.c_str(),"goff"); |
443 |
> |
events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(newNegSide.c_str()))*PlottingSetup::Weight,"goff"); |
444 |
|
nsel += effh->Integral(); |
445 |
|
} else { |
446 |
< |
events->Draw((mcjzbexpression+">>effh").c_str(), newNegSide.c_str(),"goff"); |
446 |
> |
events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(newNegSide.c_str()))*PlottingSetup::Weight,"goff"); |
447 |
|
nsel += effh->Integral(); |
448 |
< |
events->Draw((mcjzbexpression+">>effh").c_str(), emnewPosSide.c_str(),"goff"); |
448 |
> |
events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(emnewPosSide.c_str()))*PlottingSetup::Weight,"goff"); |
449 |
|
nsel += effh->Integral(); |
450 |
< |
events->Draw((mcjzbexpression+">>effh").c_str(), emnewNegSide.c_str(),"goff"); |
450 |
> |
events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(emnewNegSide.c_str()))*PlottingSetup::Weight,"goff"); |
451 |
|
nsel -= effh->Integral(); |
452 |
|
} |
453 |
|
} |
458 |
|
sel = sel/normFactor; |
459 |
|
nsel = nsel/normFactor; |
460 |
|
|
455 |
– |
// events->Draw(mcjzbexpression.c_str(),kbase,"goff"); |
456 |
– |
// Float_t tot = events->GetSelectedRows(); |
461 |
|
Float_t tot = Neventsinfile; |
462 |
|
|
463 |
|
Value result_wo_signalcont; |
528 |
|
if ( !(plotName.Length()>1) ) plotName = informalname; |
529 |
|
|
530 |
|
nBins = 1; jzbMin = jzbSel*0.95; jzbMax = jzbSel*1.05; |
531 |
< |
TH1F* hist = plotEff(events,(kbase&&ksel&&nJets),informalname,flipped); |
528 |
< |
|
531 |
> |
TH1F* hist = plotEff(events,(kbase&&ksel&&nJets),informalname,flipped); |
532 |
|
TH1F* histp = plotEff(events,(kbase&&ksel&&nJetsP),informalname,flipped); |
530 |
– |
|
533 |
|
TH1F* histm = plotEff(events,(kbase&&ksel&&nJetsM),informalname,flipped); |
534 |
|
|
535 |
|
// Dump some information |
573 |
|
|
574 |
|
//________________________________________________________________________ |
575 |
|
// JZB response (true/reco. vs. true) |
576 |
< |
void JZBresponse(TTree *events, bool requireZ, float &resp, float &resperr, int flipped, string addcut="", bool isMET = kFALSE, Float_t myJzbMax = 200., Int_t nPeriods = 9 ) { |
576 |
> |
void JZBresponse(TTree *events, string name, bool requireZ, float &resp, float &resperr, int flipped, string addcut="", bool isMET = kFALSE, Float_t myJzbMax = 200., Int_t nPeriods = 9 ) { |
577 |
|
|
578 |
|
jzbMin = 20; |
579 |
|
flag_this_change(__FUNCTION__,__LINE__,false);//PlottingSetup::RestrictToMassPeak |
659 |
|
if(PlottingSetup::computeJZBefficiency) JZBefficiency(events,informalname,jzbeff,jzbefferr,flipped,requireZ,addcut); |
660 |
|
if(!automatized) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << endl; |
661 |
|
|
662 |
< |
if(!automatized) dout << "Error from Peak position:" << endl; |
662 |
> |
if(!automatized) dout << "Error from Peak position:"; |
663 |
|
float sysfrompeak=0; |
664 |
|
PeakError(events,sysfrompeak,mcjzb,peakerror,flipped,addcut); |
665 |
|
|
666 |
< |
if(!automatized) dout << "Jet energy scale: " << std::endl; |
666 |
> |
if(!automatized) dout << "Jet energy scale (JES): " << std::endl; |
667 |
|
float jesup,jesdown; |
668 |
|
JZBjetScale(events,jesdown,jesup,informalname,flipped,requireZ,addcut); |
669 |
< |
|
669 |
> |
|
670 |
|
if(!automatized) dout << "JZB scale: " << std::endl; |
671 |
|
float scaleup,scaledown,scalesyst; |
672 |
|
doJZBscale(events,scaledown,scaleup,scalesyst,JZBScaleUncert,informalname,flipped,requireZ,addcut); |
675 |
|
float resp,resperr; |
676 |
|
if(PlottingSetup::computeJZBresponse) { |
677 |
|
if(!automatized) dout << "JZB response: " << std::endl; |
678 |
< |
if(!ismSUGRA) JZBresponse(events,requireZ,resp,resperr,flipped,addcut); |
678 |
> |
if(!ismSUGRA) JZBresponse(events,informalname,requireZ,resp,resperr,flipped,addcut); |
679 |
|
} |
680 |
|
|
681 |
|
if(!automatized) dout << "Pileup: " << std::endl; |
727 |
|
if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup)); else res.push_back(fabs(jesdown)); |
728 |
|
if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)); else res.push_back(fabs(scaledown)); |
729 |
|
// res.push_back(fabs(resolution)); |
730 |
+ |
res.push_back(0.0); |
731 |
|
res.push_back(mceff_nosigcont.getValue()); |
732 |
|
res.push_back(mceff_nosigcont.getError()); |
733 |
|
if(ismSUGRA) res.push_back(PDFuncert); |
738 |
|
automatized=true; |
739 |
|
vector< vector<float> > systematics; |
740 |
|
for (int isignal=0; isignal<signalsamples.collection.size();isignal++) { |
741 |
< |
dout << "Looking at signal " << (signalsamples.collection)[isignal].filename << endl; |
742 |
< |
for(int ibin=0;ibin<bins.size();ibin++) { |
743 |
< |
jzbSel=bins[ibin]; |
744 |
< |
geqleq="geq"; |
745 |
< |
do_systematics_for_one_file((signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].Nentries,(signalsamples.collection)[isignal].samplename,systematics,flipped,mcjzb,datajzb,mcpeakerror,requireZ); |
746 |
< |
}//end of bin loop |
741 |
> |
dout << "Looking at signal " << (signalsamples.collection)[isignal].filename << endl; |
742 |
> |
for(int ibin=0;ibin<bins.size();ibin++) { |
743 |
> |
jzbSel=bins[ibin]; |
744 |
> |
geqleq="geq"; |
745 |
> |
do_systematics_for_one_file((signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].Nentries,(signalsamples.collection)[isignal].samplename,systematics,flipped,mcjzb,datajzb,mcpeakerror,requireZ); |
746 |
> |
}//end of bin loop |
747 |
|
}//end of signal loop |
748 |
|
return systematics; |
749 |
|
} |