44 |
|
return TString("GEQ_OR_LEQ_ERROR"); |
45 |
|
} |
46 |
|
|
47 |
+ |
TString ngeq_or_leq() { |
48 |
+ |
if(geqleq=="geq") return TString("<="); |
49 |
+ |
if(geqleq=="leq") return TString(">="); |
50 |
+ |
return TString("NGEQ_OR_LEQ_ERROR"); |
51 |
+ |
} |
52 |
+ |
|
53 |
|
//______________________________________________________________________________ |
54 |
|
Double_t Interpolate(Double_t x, TH1 *histo) |
55 |
|
{ |
81 |
|
} |
82 |
|
} |
83 |
|
|
84 |
+ |
//____________________________________________________________________________________ |
85 |
+ |
// Plotting with all contributions, i.e. sidebands, peak, osof,ossf ... (for a systematic) |
86 |
+ |
float allcontributionsplot(TTree* events, TCut kBaseCut, TCut kMassCut, TCut kSidebandCut, TCut JZBPosCut, TCut JZBNegCut) { |
87 |
+ |
iplot++; |
88 |
+ |
int count=iplot; |
89 |
+ |
// Define new histogram |
90 |
+ |
string hname=GetNumericHistoName(); |
91 |
+ |
TH1F* hossfp = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
92 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kMassCut&&JZBPosCut&&cutOSSF,"goff"); |
93 |
+ |
hname=GetNumericHistoName(); |
94 |
+ |
TH1F* hossfn = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
95 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kMassCut&&JZBNegCut&&cutOSSF,"goff"); |
96 |
+ |
|
97 |
+ |
hname=GetNumericHistoName(); |
98 |
+ |
TH1F* hosofp = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
99 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kMassCut&&JZBPosCut&&cutOSOF,"goff"); |
100 |
+ |
hname=GetNumericHistoName(); |
101 |
+ |
TH1F* hosofn = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
102 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kMassCut&&JZBNegCut&&cutOSOF,"goff"); |
103 |
+ |
|
104 |
+ |
hname=GetNumericHistoName(); |
105 |
+ |
TH1F* sbhossfp = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
106 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kSidebandCut&&JZBPosCut&&cutOSSF,"goff"); |
107 |
+ |
hname=GetNumericHistoName(); |
108 |
+ |
TH1F* sbhossfn = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
109 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kSidebandCut&&JZBNegCut&&cutOSSF,"goff"); |
110 |
+ |
|
111 |
+ |
hname=GetNumericHistoName(); |
112 |
+ |
TH1F* sbhosofp = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
113 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kSidebandCut&&JZBPosCut&&cutOSOF,"goff"); |
114 |
+ |
hname=GetNumericHistoName(); |
115 |
+ |
TH1F* sbhosofn = new TH1F(hname.c_str(),hname.c_str(),1,-14000,14000); |
116 |
+ |
events->Draw(TString(mcjzbexpression)+">>"+TString(hname),kBaseCut&&kSidebandCut&&JZBNegCut&&cutOSOF,"goff"); |
117 |
+ |
|
118 |
+ |
float obs = hossfp->Integral(); |
119 |
+ |
float pred= hossfn->Integral() + (1.0/3)*( hosofp->Integral() - hosofn->Integral() + sbhossfp->Integral() - sbhossfn->Integral() + sbhosofp->Integral() - sbhosofn->Integral()); |
120 |
+ |
|
121 |
+ |
delete hossfp,hossfn,hosofp,hosofn; |
122 |
+ |
delete sbhossfp,sbhossfn,sbhosofp,sbhosofn; |
123 |
+ |
return obs-pred; |
124 |
+ |
} |
125 |
+ |
|
126 |
|
|
127 |
|
//____________________________________________________________________________________ |
128 |
|
// Efficiency plot |
135 |
|
nBins,jzbMin,jzbMax); |
136 |
|
Float_t step = (jzbMax-jzbMin)/static_cast<Float_t>(nBins); |
137 |
|
|
138 |
< |
events->Draw(mcjzbexpression.c_str(),"genJZBSel>-400"&&kbase,"goff"); |
138 |
> |
events->Draw(mcjzbexpression.c_str(),"genJZB>-400"&&kbase,"goff"); |
139 |
|
Float_t maxEff = events->GetSelectedRows(); |
140 |
|
if(verbose>0) dout << hname << " (" << informalname <<") " << maxEff << std::endl; |
141 |
|
|
143 |
|
// Loop over steps to get efficiency curve |
144 |
|
char cut[256]; |
145 |
|
for ( Int_t iBin = 0; iBin<nBins; ++iBin ) { |
146 |
< |
sprintf(cut,"genJZBSel>%3f",jzbMin+iBin*step); |
146 |
> |
sprintf(cut,"genJZB>%3f",jzbMin+iBin*step); |
147 |
|
events->Draw(mcjzbexpression.c_str(),TCut(cut)&&kbase,"goff"); |
148 |
|
Float_t eff = static_cast<Float_t>(events->GetSelectedRows())/maxEff; |
149 |
|
// dout << "COUCOU " << __LINE__ << std::endl; |
157 |
|
|
158 |
|
|
159 |
|
//________________________________________________________________________________________ |
160 |
+ |
// Master Formula |
161 |
+ |
void master_formula(std::vector<float> eff, float &errHi, float &errLo) { |
162 |
+ |
|
163 |
+ |
float x0 = eff[0]; |
164 |
+ |
float deltaPos = 0, deltaNeg = 0; |
165 |
+ |
for(int k = 0; k < (eff.size()-1)/2; k++) { |
166 |
+ |
float xneg = eff[2*k+2]; |
167 |
+ |
float xpos = eff[2*k+1]; |
168 |
+ |
if(xpos-x0>0 || xneg-x0>0) { |
169 |
+ |
if(xpos-x0 > xneg-x0) { |
170 |
+ |
deltaPos += (xpos-x0)*(xpos-x0); |
171 |
+ |
} else { |
172 |
+ |
deltaPos += (xneg-x0)*(xneg-x0); |
173 |
+ |
} |
174 |
+ |
} |
175 |
+ |
if(x0-xpos>0 || x0-xneg>0) { |
176 |
+ |
if(x0-xpos > x0-xneg) { |
177 |
+ |
deltaNeg += (xpos-x0)*(xpos-x0); |
178 |
+ |
} else { |
179 |
+ |
deltaNeg += (xneg-x0)*(xneg-x0); |
180 |
+ |
} |
181 |
+ |
} |
182 |
+ |
} |
183 |
+ |
errHi = sqrt(deltaPos); |
184 |
+ |
errLo = sqrt(deltaNeg); |
185 |
+ |
|
186 |
+ |
} |
187 |
+ |
|
188 |
+ |
|
189 |
+ |
//________________________________________________________________________________________ |
190 |
+ |
// Get normalization factor for the PDFs |
191 |
+ |
float get_norm_pdf_factor(TTree *events, int k) { |
192 |
+ |
|
193 |
+ |
TH1F *haux = new TH1F("haux", "", 10000, 0, 5); |
194 |
+ |
char nameVar[20]; |
195 |
+ |
sprintf(nameVar, "pdfW[%d]", k); |
196 |
+ |
events->Project("haux", nameVar); |
197 |
+ |
float thisW = haux->Integral(); |
198 |
+ |
events->Project("haux", "pdfW[0]"); |
199 |
+ |
float normW = haux->Integral(); |
200 |
+ |
|
201 |
+ |
float factor=thisW/normW; |
202 |
+ |
|
203 |
+ |
delete haux; |
204 |
+ |
|
205 |
+ |
return factor; |
206 |
+ |
|
207 |
+ |
} |
208 |
+ |
|
209 |
+ |
|
210 |
+ |
|
211 |
+ |
//________________________________________________________________________________________ |
212 |
|
// Pile-up efficiency |
213 |
< |
float pileup(TTree *events, string informalname, Float_t myJzbMax = 140. ) { |
213 |
> |
float pileup(TTree *events, bool requireZ, string informalname, string addcut="",Float_t myJzbMax = 140. ) { |
214 |
|
nBins = 16; |
215 |
|
jzbMax = myJzbMax; |
216 |
|
|
217 |
|
// Acceptance cuts |
218 |
< |
TCut kbase("abs(genMllSel-91.2)<20&&genNjets>2&&genZPtSel>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
218 |
> |
TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
219 |
> |
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
220 |
|
|
221 |
+ |
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
222 |
|
TH1F* hLM4 = plotEff(events,kbase,informalname); |
223 |
|
hLM4->SetMinimum(0.); |
224 |
|
|
234 |
|
if(!automatized) dout << " PU: " << funcUp->Eval(jzbSel) << " " << func->Eval(jzbSel) |
235 |
|
<< "(" << (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel)*100. << "%)" << std::endl; |
236 |
|
|
237 |
< |
return (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel)*100.; |
237 |
> |
return (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel); |
238 |
|
|
239 |
|
} |
240 |
|
|
241 |
|
//____________________________________________________________________________________ |
242 |
+ |
// Effect of peak shifting |
243 |
+ |
void PeakError(TTree *events,float &result, string mcjzb, float peakerr,string addcut="") { |
244 |
+ |
TString peakup("("+TString(mcjzb)+"+"+TString(any2string(TMath::Abs(peakerr)))+")"+geq_or_leq()+TString(any2string(jzbSel))); |
245 |
+ |
TString peakdown("("+TString(mcjzb)+"-"+TString(any2string(TMath::Abs(peakerr)))+")"+geq_or_leq()+TString(any2string(jzbSel))); |
246 |
+ |
TString peakcentral("("+TString(mcjzb)+")"+geq_or_leq()+TString(any2string(jzbSel))); |
247 |
+ |
TString npeakup("("+TString(mcjzb)+"+"+TString(any2string(TMath::Abs(peakerr)))+")"+ngeq_or_leq()+"-"+TString(any2string(jzbSel))); |
248 |
+ |
TString npeakdown("("+TString(mcjzb)+"-"+TString(any2string(TMath::Abs(peakerr)))+")"+ngeq_or_leq()+"-"+TString(any2string(jzbSel))); |
249 |
+ |
TString npeakcentral("("+TString(mcjzb)+")"+ngeq_or_leq()+"-"+TString(any2string(jzbSel))); |
250 |
+ |
|
251 |
+ |
nBins = 1; |
252 |
+ |
string informalname="PeakErrorCalculation"; |
253 |
+ |
float resup,resdown,rescent; |
254 |
+ |
for(int i=0;i<3;i++) { |
255 |
+ |
string poscut,negcut; |
256 |
+ |
if(i==0) { |
257 |
+ |
poscut=peakcentral; |
258 |
+ |
negcut=npeakcentral; |
259 |
+ |
} else if(i==1) { |
260 |
+ |
poscut=peakdown; |
261 |
+ |
negcut=npeakdown; |
262 |
+ |
} else if(i==2) { |
263 |
+ |
poscut=peakup; |
264 |
+ |
negcut=npeakup; |
265 |
+ |
} |
266 |
+ |
float res; |
267 |
+ |
if(addcut=="") res=allcontributionsplot(events,cutnJets,cutmass,sidebandcut,poscut.c_str(),negcut.c_str()); |
268 |
+ |
else res=allcontributionsplot(events,cutnJets&&addcut.c_str(),cutmass,sidebandcut,poscut.c_str(),negcut.c_str()); |
269 |
+ |
if(i==0) rescent=res; |
270 |
+ |
else if(i==1) resdown=res; |
271 |
+ |
else if(i==2) resup=res; |
272 |
+ |
} |
273 |
+ |
if(TMath::Abs(rescent-resup)>TMath::Abs(rescent-resdown)) result=(TMath::Abs(rescent-resup)/rescent); |
274 |
+ |
else result=(TMath::Abs(rescent-resdown)/rescent); |
275 |
+ |
} |
276 |
+ |
|
277 |
+ |
//____________________________________________________________________________________ |
278 |
|
// Total selection efficiency (MC) |
279 |
< |
void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb) { |
279 |
> |
void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="", int k = 0) { |
280 |
|
|
281 |
|
char jzbSelStr[256]; sprintf(jzbSelStr,"%f",jzbSel); |
282 |
|
// All acceptance cuts at gen. level |
283 |
< |
TCut kbase("abs(genMllSel-91.2)<20&&genNjets>2&&genZPt>0&&genJZB"+geq_or_leq()+TString(jzbSelStr)+"&&genId1==-genId2"); |
283 |
> |
//TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&genJZB"+geq_or_leq()+TString(jzbSelStr)+"&&genId1==-genId2"); |
284 |
> |
TCut kbase(""); |
285 |
> |
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
286 |
> |
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
287 |
|
// Corresponding reco. cuts |
288 |
< |
TCut ksel("abs(mll-91.2)<20&&id1==id2&&"+TString(mcjzb)+geq_or_leq()+TString(jzbSelStr)); |
289 |
< |
|
290 |
< |
events->Draw(mcjzbexpression.c_str(),kbase&&ksel,"goff"); |
291 |
< |
Float_t sel = events->GetSelectedRows(); |
292 |
< |
events->Draw(mcjzbexpression.c_str(),kbase,"goff"); |
293 |
< |
Float_t tot = events->GetSelectedRows(); |
294 |
< |
|
295 |
< |
result=sel/tot; |
296 |
< |
resulterr=TMath::Sqrt(sel/tot*(1-sel/tot)/tot); |
297 |
< |
if(!automatized) dout << " MC efficiency: " << result << "+-" << resulterr << std::endl; |
288 |
> |
TCut ksel("pfJetGoodNum>2&&abs(mll-91.2)<20&&id1==id2&&"+TString(mcjzb)+geq_or_leq()+TString(jzbSelStr)); |
289 |
> |
TCut ksel2("pfJetGoodNum>2&&abs(mll-91.2)<20&&id1==id2&&"+TString(mcjzb)+ngeq_or_leq()+TString("-")+TString(jzbSelStr)); |
290 |
> |
TCut posSide = kbase&&ksel; |
291 |
> |
TCut negSide = kbase&&ksel2; |
292 |
> |
string sposSide(posSide); |
293 |
> |
string snegSide(negSide); |
294 |
> |
char var[20]; |
295 |
> |
sprintf(var, "pdfW[%d]", k); |
296 |
> |
string svar(var); |
297 |
> |
string newPosSide = "(" + sposSide + ")*" + svar; |
298 |
> |
string newNegSide = "(" + snegSide + ")*" + svar; |
299 |
> |
|
300 |
> |
TH1F *effh= new TH1F("effh","effh",1,-14000,14000); |
301 |
> |
if(k>=0)events->Draw((mcjzbexpression+">>effh").c_str(), newPosSide.c_str(),"goff"); |
302 |
> |
else events->Draw((mcjzbexpression+">>effh").c_str(), sposSide.c_str(),"goff"); |
303 |
> |
Float_t sel = effh->Integral(); |
304 |
> |
Float_t nsel=0; |
305 |
> |
if(ConsiderSignalContaminationForLimits) { |
306 |
> |
if(k>=0)events->Draw((mcjzbexpression+">>effh").c_str(), newNegSide.c_str(),"goff"); |
307 |
> |
else events->Draw((mcjzbexpression+">>effh").c_str(), snegSide.c_str(),"goff"); |
308 |
> |
nsel = effh->Integral(); |
309 |
> |
} |
310 |
> |
//Corrections due to normalization in the PDF. This has to be applied as well to the number of events in a file if the definition changes at some point. |
311 |
> |
float normFactor = 1; |
312 |
> |
if(k>=0) get_norm_pdf_factor(events, k); |
313 |
> |
sel = sel/normFactor; |
314 |
> |
nsel = nsel/normFactor; |
315 |
> |
|
316 |
> |
// events->Draw(mcjzbexpression.c_str(),kbase,"goff"); |
317 |
> |
// Float_t tot = events->GetSelectedRows(); |
318 |
> |
Float_t tot = Neventsinfile; |
319 |
> |
|
320 |
> |
if(ConsiderSignalContaminationForLimits) { |
321 |
> |
result=(sel-nsel)/tot; |
322 |
> |
resulterr=(1.0/tot)*TMath::Sqrt(sel+nsel+(sel-nsel)*(sel-nsel)/tot); |
323 |
> |
} else {//no signal contamination considered: |
324 |
> |
result=(sel)/tot; |
325 |
> |
resulterr=TMath::Sqrt(sel/tot*(1+sel/tot)/tot); |
326 |
> |
} |
327 |
> |
if(!automatized) dout << " MC efficiency: " << result << "+-" << resulterr << " ( JZB>" << jzbSel << " : " << sel << " , JZB<-" << jzbSel << " : " << nsel << " and nevents=" << tot << ") with normFact=" << normFactor << std::endl; |
328 |
> |
delete effh; |
329 |
> |
} |
330 |
> |
|
331 |
> |
|
332 |
> |
//____________________________________________________________________________________ |
333 |
> |
// Selection efficiency for one process (MC) |
334 |
> |
vector<float> processMCefficiency(TTree *events,string mcjzb,bool requireZ,int Neventsinfile, string addcut) { |
335 |
> |
vector<float> process_efficiencies; |
336 |
> |
for(int iprocess=0;iprocess<=10;iprocess++) { |
337 |
> |
float this_process_efficiency,efferr; |
338 |
> |
stringstream addcutplus; |
339 |
> |
addcutplus<<addcut<<"&&(process=="<<iprocess<<")"; |
340 |
> |
MCefficiency(events,this_process_efficiency, efferr,mcjzb,requireZ,Neventsinfile, addcutplus.str(),-1); |
341 |
> |
process_efficiencies.push_back(this_process_efficiency); |
342 |
> |
} |
343 |
> |
return process_efficiencies; |
344 |
|
} |
345 |
+ |
|
346 |
|
|
347 |
< |
float JZBefficiency(TTree *events, string informalname) { |
348 |
< |
TCut kbase("abs(genMllSel-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
347 |
> |
void JZBefficiency(TTree *events, string informalname, float &jzbeff, float &jzbefferr, bool requireZ, string addcut="") { |
348 |
> |
TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
349 |
> |
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
350 |
> |
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
351 |
|
TH1F* hLM4 = plotEff(events,kbase,informalname); |
352 |
|
Int_t bin = hLM4->FindBin(jzbSel); // To get the error |
353 |
+ |
jzbeff=Interpolate(jzbSel,hLM4); |
354 |
+ |
jzbefferr=hLM4->GetBinError(bin); |
355 |
|
if(!automatized) dout << " Efficiency at JZB==" << jzbSel << std::endl; |
356 |
< |
if(!automatized) dout << " " << Interpolate(jzbSel,hLM4) << "+-" << hLM4->GetBinError(bin) << std::endl; |
165 |
< |
return -1; |
356 |
> |
if(!automatized) dout << " " << jzbeff << "+-" << jzbefferr << std::endl; |
357 |
|
} |
358 |
|
|
359 |
|
//________________________________________________________________________ |
360 |
|
// Effect of energy scale on efficiency |
361 |
< |
void JZBjetScale(TTree *events, float &jesdown, float &jesup, string informalname="",float syst=0.1, Float_t jzbSelection=-1, TString plotName = "" ) { |
362 |
< |
TCut kbase("abs(genMllSel-91.2)<20&&genZPt>0"); |
361 |
> |
void JZBjetScale(TTree *events, float &jesdown, float &jesup, string informalname,bool requireZ,string addcut="",float syst=0.1, Float_t jzbSelection=-1, TString plotName = "" ) { |
362 |
> |
TCut kbase("abs(genMll-91.2)<20&&genZPt>0"); |
363 |
> |
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
364 |
> |
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
365 |
> |
|
366 |
|
TCut ksel("abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
367 |
|
TCut nJets("pfJetGoodNum>2"); |
368 |
|
stringstream down,up; |
372 |
|
TCut nJetsP(up.str().c_str()); |
373 |
|
TCut nJetsM(down.str().c_str()); |
374 |
|
|
181 |
– |
if ( jzbSelection>0 ) jzbSel = jzbSelection; |
182 |
– |
|
375 |
|
if ( !(plotName.Length()>1) ) plotName = informalname; |
376 |
|
|
377 |
|
nBins = 1; jzbMin = jzbSel*0.95; jzbMax = jzbSel*1.05; |
389 |
|
if(!automatized) dout << " JESup: " << effp << " (" << (effp-eff)/eff*100. << "%)" << std::endl; |
390 |
|
if(!automatized) dout << " central: " << eff << std::endl; |
391 |
|
if(!automatized) dout << " JESdown: " << effm << " (" << (effm-eff)/eff*100. << "%)" << std::endl; |
392 |
< |
jesup=(effp-eff)/eff*100.; |
393 |
< |
jesdown=(effm-eff)/eff*100.; |
392 |
> |
jesup=(effp-eff)/eff; |
393 |
> |
jesdown=(effm-eff)/eff; |
394 |
|
} |
395 |
|
|
396 |
|
//________________________________________________________________________ |
397 |
|
// Effect of energy scale on JZB efficiency |
398 |
< |
void doJZBscale(TTree *events, float &down, float &up, float &syst, float systematic, string informalname) { |
398 |
> |
void doJZBscale(TTree *events, float &down, float &up, float &syst, float systematic, string informalname, bool requireZ, string addcut) { |
399 |
|
|
400 |
< |
TCut kbase("abs(genMllSel-91.2)<20&&genZPt>0&&genNjets>2"); |
400 |
> |
TCut kbase("abs(genMll-91.2)<20&&genZPt>0&&genNjets>2"); |
401 |
> |
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
402 |
> |
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
403 |
|
TCut ksel("abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
404 |
|
|
405 |
|
nBins = 50; |
415 |
|
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.+systematic) << "(-"<<syst*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)" << std::endl; |
416 |
|
if(!automatized) dout << " efficiency at JZB==" << jzbSel << ": " << eff << std::endl; |
417 |
|
if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.-systematic) << "(-"<<syst*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)" << std::endl; |
418 |
< |
up=((effp-eff)/eff)*100; |
419 |
< |
down=((effm-eff)/eff)*100; |
418 |
> |
up=((effp-eff)/eff); |
419 |
> |
down=((effm-eff)/eff); |
420 |
|
} |
421 |
|
|
422 |
|
//________________________________________________________________________ |
423 |
|
// JZB response (true/reco. vs. true) |
424 |
< |
void JZBresponse(TTree *events, bool isMET = kFALSE, Float_t myJzbMax = 200., Int_t nPeriods = 9 ) { |
424 |
> |
void JZBresponse(TTree *events, bool requireZ, float &resp, float &resperr, string addcut="",bool isMET = kFALSE, Float_t myJzbMax = 200., Int_t nPeriods = 9 ) { |
425 |
|
|
426 |
|
jzbMin = 20; |
427 |
< |
TCut kbase("abs(genMllSel-91.2)<20&&genZPtSel>0&&genNjets>2"); |
427 |
> |
TCut kbase("abs(genMll-91.2)<20&&genZPt>0&&genNjets>2"); |
428 |
> |
if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses) |
429 |
> |
if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23"; |
430 |
|
TCut ksel("abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2"); |
431 |
|
|
432 |
< |
TProfile* hJzbResp = new TProfile("hJzbResp","JZB response ; JZB true (GeV/c); JZB reco. / JZB true", |
237 |
< |
nPeriods, jzbMin, myJzbMax, "" ); |
432 |
> |
TProfile* hJzbResp = new TProfile("hJzbResp","JZB response ; JZB true (GeV/c); JZB reco. / JZB true", nPeriods, jzbMin, myJzbMax, "" ); |
433 |
|
|
434 |
< |
if (!isMET) events->Project("hJzbResp","("+TString(mcjzbexpression)+")/genJZBSel:genJZBSel",kbase&&ksel); |
434 |
> |
if (!isMET) events->Project("hJzbResp","("+TString(mcjzbexpression)+")/genJZB:genJZB",kbase&&ksel); |
435 |
|
else events->Project("hJzbResp","met[4]/genMET:genMET",kbase&&ksel); |
436 |
|
|
437 |
|
hJzbResp->SetMaximum(1.2); |
438 |
|
hJzbResp->SetMinimum(0.2); |
439 |
|
hJzbResp->Fit("pol0","Q"); |
440 |
|
TF1 *fittedfunction = hJzbResp->GetFunction("pol0"); |
441 |
< |
if(!automatized) dout << " Response: " << fittedfunction->GetParameter(0) << " +/- " << fittedfunction->GetParError(0) << endl; |
441 |
> |
resp=fittedfunction->GetParameter(0); |
442 |
> |
resperr=fittedfunction->GetParError(0); |
443 |
> |
if(!automatized) dout << " Response: " << resp << " +/- " << resperr << endl; |
444 |
|
delete hJzbResp; |
445 |
|
} |
446 |
|
|
447 |
|
|
448 |
< |
void do_systematics_for_one_file(TTree *events,string informalname, vector<vector<float> > &results,string mcjzb,string datajzb) { |
448 |
> |
//________________________________________________________________________________________ |
449 |
> |
// PDF uncertainty |
450 |
> |
float get_pdf_uncertainty(TTree *events, string mcjzb, bool requireZ, int Neventsinfile, int NPdfs, string addcut="") { |
451 |
> |
std::vector<float> efficiency; |
452 |
> |
for(int k = 1; k < NPdfs; k++) { |
453 |
> |
float result, resulterr; |
454 |
> |
MCefficiency(events, result, resulterr, mcjzb, requireZ, Neventsinfile, addcut, k); |
455 |
> |
efficiency.push_back(result); |
456 |
> |
} |
457 |
> |
float errHi, errLow,err; |
458 |
> |
master_formula(efficiency, errHi, errLow); |
459 |
> |
err=errLow; |
460 |
> |
if(errHi>errLow) err=errHi; |
461 |
> |
if(!automatized) dout << " Uncertainty from PDF: " << errLow << " (low) and " << errHi << "(high) ---> Picked " << err << endl; |
462 |
> |
return err; |
463 |
> |
|
464 |
> |
} |
465 |
> |
|
466 |
> |
int get_npdfs(TTree *events) { |
467 |
> |
int NPDFs; |
468 |
> |
events->SetBranchAddress("NPdfs",&NPDFs); |
469 |
> |
events->GetEntry(1); |
470 |
> |
return NPDFs; |
471 |
> |
} |
472 |
|
|
473 |
+ |
|
474 |
+ |
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="", bool ismSUGRA=false) { |
475 |
|
float JetEnergyScaleUncert=0.1; |
476 |
|
float JZBScaleUncert=0.1; |
477 |
|
mcjzbexpression=mcjzb; |
478 |
< |
|
257 |
< |
float triggereff=4;//percent! |
478 |
> |
float triggereff=5.0/100;// in range [0,1] |
479 |
|
dout << "Trigger efficiency not implemented in this script yet, still using external one" << endl; |
480 |
< |
float leptonseleff=2;//percent! |
480 |
> |
float leptonseleff=2.0/100;// in range [0,1] |
481 |
|
dout << "Lepton selection efficiency not implemented in this script yet, still using external one" << endl; |
482 |
|
|
483 |
< |
float mceff,mcefferr; |
483 |
> |
int NPdfs=0; |
484 |
> |
if(ismSUGRA) NPdfs = get_npdfs(events); |
485 |
> |
|
486 |
> |
float mceff,mcefferr,jzbeff,jzbefferr; |
487 |
|
if(!automatized) dout << "MC efficiencies:" << endl; |
488 |
< |
MCefficiency(events,mceff,mcefferr,mcjzb); |
489 |
< |
JZBefficiency(events,informalname); |
488 |
> |
MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,Neventsinfile,addcut,-1); |
489 |
> |
JZBefficiency(events,informalname,jzbeff,jzbefferr,requireZ,addcut); |
490 |
> |
if(!automatized) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << endl; |
491 |
|
|
492 |
+ |
if(!automatized) dout << "Error from Peak position:" << endl; |
493 |
+ |
float sysfrompeak=0; |
494 |
+ |
PeakError(events,sysfrompeak,mcjzb,peakerror,addcut); |
495 |
+ |
|
496 |
|
if(!automatized) dout << "Jet energy scale: " << std::endl; |
497 |
|
float jesup,jesdown; |
498 |
< |
JZBjetScale(events,jesdown,jesup,informalname,JetEnergyScaleUncert); |
498 |
> |
JZBjetScale(events,jesdown,jesup,informalname,requireZ,addcut,JetEnergyScaleUncert); |
499 |
|
|
500 |
|
if(!automatized) dout << "JZB scale: " << std::endl; |
501 |
|
float scaleup,scaledown,scalesyst; |
502 |
< |
doJZBscale(events,scaledown,scaleup,scalesyst,JZBScaleUncert,informalname); |
502 |
> |
doJZBscale(events,scaledown,scaleup,scalesyst,JZBScaleUncert,informalname,requireZ,addcut); |
503 |
|
|
504 |
|
if(!automatized) dout << "JZB response: " << std::endl; |
505 |
< |
JZBresponse(events); |
505 |
> |
float resp,resperr; |
506 |
> |
JZBresponse(events,requireZ,resp,resperr,addcut); |
507 |
|
|
508 |
|
if(!automatized) dout << "Pileup: " << std::endl; |
509 |
< |
float resolution=pileup(events,informalname); |
510 |
< |
|
509 |
> |
float resolution=pileup(events,requireZ,informalname,addcut); |
510 |
> |
|
511 |
> |
float PDFuncert=0; |
512 |
> |
if(ismSUGRA) PDFuncert = get_pdf_uncertainty(events, mcjzb, requireZ, Neventsinfile, NPdfs, addcut); |
513 |
> |
|
514 |
|
dout << "_______________________________________________" << endl; |
515 |
< |
dout << " SUMMARY FOR " << informalname << " with JZB>" << jzbSel << endl; |
516 |
< |
dout << "MC efficiency: " << mceff << "+/-" << mcefferr << endl; |
517 |
< |
dout << "Trigger efficiency: " << triggereff << endl; |
518 |
< |
dout << "Lepton Sel Eff: " << leptonseleff << endl; |
519 |
< |
dout << "For JZB>" << jzbSel << endl; |
520 |
< |
dout << "Jet energy scale: " << jesup << " " << jesdown << " --> suggesting: " << Round(0.5*(fabs(jesup)+fabs(jesdown)),1) << endl; |
521 |
< |
dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << " --> suggesting: " << Round(0.5*(fabs(scaledown)+fabs(scaleup)),1) << endl; |
522 |
< |
dout << "Resolution : " << resolution << endl; |
523 |
< |
|
515 |
> |
dout << " SUMMARY FOR " << informalname << " with JZB>" << jzbSel << " (all in %) "; |
516 |
> |
if(addcut!="") dout << "With additional cut: " << addcut; |
517 |
> |
dout << endl; |
518 |
> |
dout << "MC efficiency: " << mceff << "+/-" << mcefferr << endl; // in range [0,1] |
519 |
> |
dout << "Trigger efficiency: " << triggereff << endl; // in range [0,1] |
520 |
> |
dout << "Lepton Sel Eff: " << leptonseleff << endl; // in range [0,1] |
521 |
> |
dout << "Jet energy scale: " << jesup << " " << jesdown << endl; // in range [0,1] |
522 |
> |
dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << endl; // in range [0,1] |
523 |
> |
dout << "Resolution : " << resolution << endl; // in range [0,1] |
524 |
> |
dout << "From peak : " << sysfrompeak << endl; // in range [0,1] |
525 |
> |
if(ismSUGRA) dout << "PDF uncertainty : " << PDFuncert << endl; // in range [0,1] |
526 |
> |
dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1] |
527 |
> |
dout << "JZB response : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1] |
528 |
|
|
529 |
|
float toterr=0; |
530 |
< |
toterr+=(triggereff/100)*(triggereff/100); |
531 |
< |
toterr+=(leptonseleff/100)*(leptonseleff/100); |
532 |
< |
if(fabs(jesup)>fabs(jesdown)) toterr+=(jesup/100)*(jesup/100); else toterr+=(jesdown/100)*(jesdown/100); |
533 |
< |
if(fabs(scaleup)>fabs(scaledown)) toterr+=(scaleup/100)*(scaleup/100); else toterr+=(scaledown/100)*(scaledown/100); |
534 |
< |
toterr+=(resolution/100)*(resolution/100); |
535 |
< |
toterr=TMath::Sqrt(toterr); |
536 |
< |
dout << "FINAL RESULT : " << mceff << " +/- "<< mcefferr << " (stat) +/- " << 100*toterr << " (syst)" << endl; |
537 |
< |
dout << " we thus use the sqrt of the sum of the squares which is : " << 100*TMath::Sqrt(mcefferr*mcefferr+(toterr*toterr)) << endl; |
530 |
> |
toterr+=(triggereff)*(triggereff); |
531 |
> |
toterr+=(leptonseleff)*(leptonseleff); |
532 |
> |
if(fabs(jesup)>fabs(jesdown)) toterr+=(jesup*jesup); else toterr+=(jesdown*jesdown); |
533 |
> |
if(fabs(scaleup)>fabs(scaledown)) toterr+=(scaleup*scaleup); else toterr+=(scaledown*scaledown); |
534 |
> |
toterr+=(resolution*resolution); |
535 |
> |
toterr+=(sysfrompeak*sysfrompeak); |
536 |
> |
if(ismSUGRA) toterr+=(PDFuncert*PDFuncert); |
537 |
> |
dout << "TOTAL SYSTEMATICS: " << TMath::Sqrt(toterr) << " --> " << TMath::Sqrt(toterr)*mceff << endl; |
538 |
> |
float systerr=TMath::Sqrt(toterr)*mceff; |
539 |
> |
toterr=TMath::Sqrt(toterr*mceff*mceff+mcefferr*mcefferr);//also includes stat err! |
540 |
> |
|
541 |
> |
dout << "FINAL RESULT : " << 100*mceff << " +/- "<< 100*mcefferr << " (stat) +/- " << 100*systerr << " (syst) %" << endl; |
542 |
> |
dout << " we thus use the sqrt of the sum of the squares of the stat & syst err, which is : " << 100*toterr << endl; |
543 |
> |
|
544 |
> |
//Do not modify the lines below or mess with the order; this order is expected by all limit calculating functions! |
545 |
|
vector<float> res; |
546 |
|
res.push_back(jzbSel); |
547 |
|
res.push_back(mceff); |
548 |
|
res.push_back(mcefferr); |
549 |
|
res.push_back(toterr); |
550 |
|
res.push_back(TMath::Sqrt((mcefferr)*(mcefferr)+(toterr*toterr))); |
551 |
< |
|
551 |
> |
if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup)); else res.push_back(fabs(jesdown)); |
552 |
> |
if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)); else res.push_back(fabs(scaledown)); |
553 |
> |
res.push_back(fabs(resolution)); |
554 |
> |
if(ismSUGRA) res.push_back(PDFuncert); |
555 |
|
results.push_back(res); |
556 |
|
} |
557 |
|
|
558 |
< |
vector<vector<float> > compute_systematics(string mcjzb, string datajzb, samplecollection &signalsamples, vector<float> bins) { |
558 |
> |
vector<vector<float> > compute_systematics(string mcjzb, float mcpeakerror, string datajzb, samplecollection &signalsamples, vector<float> bins, bool requireZ=false) { |
559 |
|
automatized=true; |
560 |
|
vector< vector<float> > systematics; |
561 |
|
for (int isignal=0; isignal<signalsamples.collection.size();isignal++) { |
563 |
|
for(int ibin=0;ibin<bins.size();ibin++) { |
564 |
|
jzbSel=bins[ibin]; |
565 |
|
geqleq="geq"; |
566 |
< |
do_systematics_for_one_file((signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].samplename,systematics,mcjzb,datajzb); |
566 |
> |
do_systematics_for_one_file((signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].Nentries,(signalsamples.collection)[isignal].samplename,systematics,mcjzb,datajzb,mcpeakerror,requireZ); |
567 |
|
}//end of bin loop |
568 |
|
}//end of signal loop |
569 |
|
return systematics; |