ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/Systematics.C
Revision: 1.18
Committed: Wed Aug 17 17:07:18 2011 UTC (13 years, 8 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.17: +30 -29 lines
Log Message:
Replaced the percent jungle with numbers in the [0,1] range, making the code much more legible

File Contents

# Content
1 #include <iostream>
2 #include <vector>
3 #include <sys/stat.h>
4
5 #include <TMath.h>
6 #include <TColor.h>
7 #include <TPaveText.h>
8 #include <TRandom.h>
9 #include <TF1.h>
10
11 #ifndef SampleClassLoaded
12 #include "ActiveSamples.C"
13 #endif
14
15 #ifndef Verbosity
16 #define Verbosity 0
17 #endif
18
19 #include <TFile.h>
20 #include <TTree.h>
21 #include <TH1.h>
22 #include <TCut.h>
23 #include <TMath.h>
24 #include <TLine.h>
25 #include <TCanvas.h>
26 #include <TProfile.h>
27 #include <TF1.h>
28
29
30
31 Int_t nBins = 100;
32 Float_t jzbMin = -207;
33 Float_t jzbMax = 243;
34 Float_t jzbSel = 100;
35 int iplot=0;
36 int verbose=0;
37 string geqleq;
38 string mcjzbexpression;
39 bool automatized=false;//if we're running this fully automatized we don't want each function to flood the screen
40
41 TString geq_or_leq() {
42 if(geqleq=="geq") return TString(">=");
43 if(geqleq=="leq") return TString("<=");
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 {
56 // Given a point x, approximates the value via linear interpolation
57 // based on the two nearest bin centers
58 // Andy Mastbaum 10/21/08
59 // in newer ROOT versions but not in the one I have so I had to work around that ...
60
61 Int_t xbin = histo->FindBin(x);
62 Double_t x0,x1,y0,y1;
63
64 if(x<=histo->GetBinCenter(1)) {
65 return histo->GetBinContent(1);
66 } else if(x>=histo->GetBinCenter(histo->GetNbinsX())) {
67 return histo->GetBinContent(histo->GetNbinsX());
68 } else {
69 if(x<=histo->GetBinCenter(xbin)) {
70 y0 = histo->GetBinContent(xbin-1);
71 x0 = histo->GetBinCenter(xbin-1);
72 y1 = histo->GetBinContent(xbin);
73 x1 = histo->GetBinCenter(xbin);
74 } else {
75 y0 = histo->GetBinContent(xbin);
76 x0 = histo->GetBinCenter(xbin);
77 y1 = histo->GetBinContent(xbin+1);
78 x1 = histo->GetBinCenter(xbin+1);
79 }
80 return y0 + (x-x0)*((y1-y0)/(x1-x0));
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
129 TH1F* plotEff(TTree* events, TCut kbase, TString informalname) {
130 iplot++;
131 int count=iplot;
132 // Define new histogram
133 char hname[30]; sprintf(hname,"hJzbEff%d",count);
134 TH1F* hJzbEff = new TH1F(hname,"JZB selection efficiency ; JZB (GeV/c); Efficiency",
135 nBins,jzbMin,jzbMax);
136 Float_t step = (jzbMax-jzbMin)/static_cast<Float_t>(nBins);
137
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
142 if(verbose>0) dout << "JZB max = " << jzbMax << std::endl;
143 // Loop over steps to get efficiency curve
144 char cut[256];
145 for ( Int_t iBin = 0; iBin<nBins; ++iBin ) {
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;
150 hJzbEff->SetBinContent(iBin+1,eff);
151 hJzbEff->SetBinError(iBin+1,TMath::Sqrt(eff*(1-eff)/maxEff));
152 }
153 return hJzbEff;
154
155
156 }
157
158
159 //________________________________________________________________________________________
160 // Pile-up efficiency
161 float pileup(TTree *events, bool requireZ, string informalname, string addcut="",Float_t myJzbMax = 140. ) {
162 nBins = 16;
163 jzbMax = myJzbMax;
164
165 // Acceptance cuts
166 TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2");
167 if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses)
168
169 if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23";
170 TH1F* hLM4 = plotEff(events,kbase,informalname);
171 hLM4->SetMinimum(0.);
172
173 // Nominal function
174 TF1* func = new TF1("func","0.5*TMath::Erfc([0]*x-[1])",jzbMin,jzbMax);
175 func->SetParameter(0,0.03);
176 func->SetParameter(1,0.);
177 hLM4->Fit(func,"Q");
178
179 // Pimped-up function
180 TF1* funcUp = (TF1*)func->Clone();
181 funcUp->SetParameter( 0., func->GetParameter(0)/1.1); // 10% systematic error (up in sigma => 0.1 in erfc)
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);
186
187 }
188
189 //____________________________________________________________________________________
190 // Effect of peak shifting
191 void PeakError(TTree *events,float &result, string mcjzb, float peakerr,string addcut="") {
192 TString peakup("("+TString(mcjzb)+"+"+TString(any2string(TMath::Abs(peakerr)))+")"+geq_or_leq()+TString(any2string(jzbSel)));
193 TString peakdown("("+TString(mcjzb)+"-"+TString(any2string(TMath::Abs(peakerr)))+")"+geq_or_leq()+TString(any2string(jzbSel)));
194 TString peakcentral("("+TString(mcjzb)+")"+geq_or_leq()+TString(any2string(jzbSel)));
195 TString npeakup("("+TString(mcjzb)+"+"+TString(any2string(TMath::Abs(peakerr)))+")"+ngeq_or_leq()+"-"+TString(any2string(jzbSel)));
196 TString npeakdown("("+TString(mcjzb)+"-"+TString(any2string(TMath::Abs(peakerr)))+")"+ngeq_or_leq()+"-"+TString(any2string(jzbSel)));
197 TString npeakcentral("("+TString(mcjzb)+")"+ngeq_or_leq()+"-"+TString(any2string(jzbSel)));
198
199 nBins = 1;
200 string informalname="PeakErrorCalculation";
201 float resup,resdown,rescent;
202 for(int i=0;i<3;i++) {
203 string poscut,negcut;
204 if(i==0) {
205 poscut=peakcentral;
206 negcut=npeakcentral;
207 } else if(i==1) {
208 poscut=peakdown;
209 negcut=npeakdown;
210 } else if(i==2) {
211 poscut=peakup;
212 negcut=npeakup;
213 }
214 float res;
215 if(addcut=="") res=allcontributionsplot(events,cutnJets,cutmass,sidebandcut,poscut.c_str(),negcut.c_str());
216 else res=allcontributionsplot(events,cutnJets&&addcut.c_str(),cutmass,sidebandcut,poscut.c_str(),negcut.c_str());
217 if(i==0) rescent=res;
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);
222 else result=(TMath::Abs(rescent-resdown)/rescent);
223 }
224
225 //____________________________________________________________________________________
226 // Total selection efficiency (MC)
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");
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 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();
242 // events->Draw(mcjzbexpression.c_str(),kbase,"goff");
243 // Float_t tot = events->GetSelectedRows();
244 Float_t tot = Neventsinfile;
245
246 result=(sel-nsel)/tot;
247 resulterr=TMath::Sqrt(sel/tot*(1-sel/tot)/tot);
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);
257 Int_t bin = hLM4->FindBin(jzbSel); // To get the error
258 jzbeff=Interpolate(jzbSel,hLM4);
259 jzbefferr=hLM4->GetBinError(bin);
260 if(!automatized) dout << " Efficiency at JZB==" << jzbSel << std::endl;
261 if(!automatized) dout << " " << jzbeff << "+-" << jzbefferr << std::endl;
262 }
263
264 //________________________________________________________________________
265 // Effect of energy scale on efficiency
266 void JZBjetScale(TTree *events, float &jesdown, float &jesup, string informalname,bool requireZ,string addcut="",float syst=0.1, Float_t jzbSelection=-1, TString plotName = "" ) {
267 TCut kbase("abs(genMll-91.2)<20&&genZPt>0");
268 if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses)
269 if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23";
270
271 TCut ksel("abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2");
272 TCut nJets("pfJetGoodNum>2");
273 stringstream down,up;
274 down << "pfJetGoodNum"<<30*(1-syst)<<">=3";
275 up << "pfJetGoodNum"<<30*(1+syst)<<">=3";
276
277 TCut nJetsP(up.str().c_str());
278 TCut nJetsM(down.str().c_str());
279
280 if ( !(plotName.Length()>1) ) plotName = informalname;
281
282 nBins = 1; jzbMin = jzbSel*0.95; jzbMax = jzbSel*1.05;
283 TH1F* hist = plotEff(events,(kbase&&ksel&&nJets),informalname);
284
285 TH1F* histp = plotEff(events,(kbase&&ksel&&nJetsP),informalname);
286
287 TH1F* histm = plotEff(events,(kbase&&ksel&&nJetsM),informalname);
288
289 // Dump some information
290 Float_t eff = Interpolate(jzbSel,hist);
291 Float_t effp = Interpolate(jzbSel,histp);
292 Float_t effm = Interpolate(jzbSel,histm);
293 if(!automatized) dout << " Efficiency at JZB==" << jzbSel << std::endl;
294 if(!automatized) dout << " JESup: " << effp << " (" << (effp-eff)/eff*100. << "%)" << std::endl;
295 if(!automatized) dout << " central: " << eff << std::endl;
296 if(!automatized) dout << " JESdown: " << effm << " (" << (effm-eff)/eff*100. << "%)" << std::endl;
297 jesup=(effp-eff)/eff;
298 jesdown=(effm-eff)/eff;
299 }
300
301 //________________________________________________________________________
302 // Effect of energy scale on JZB efficiency
303 void doJZBscale(TTree *events, float &down, float &up, float &syst, float systematic, string informalname, bool requireZ, string addcut) {
304
305 TCut kbase("abs(genMll-91.2)<20&&genZPt>0&&genNjets>2");
306 if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses)
307 if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23";
308 TCut ksel("abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2");
309
310 nBins = 50;
311 jzbMin = 0.5*jzbSel;
312 jzbMax = 2.0*jzbSel;
313
314 TH1F* hist = plotEff(events,kbase&&ksel,informalname);
315
316 // Dump some information
317 Float_t eff = Interpolate(jzbSel,hist);
318 Float_t effp = Interpolate(jzbSel*(1.+systematic),hist);
319 Float_t effm = Interpolate(jzbSel*(1.-systematic),hist);
320 if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.+systematic) << "(-"<<syst*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)" << std::endl;
321 if(!automatized) dout << " efficiency at JZB==" << jzbSel << ": " << eff << std::endl;
322 if(!automatized) dout << " efficiency at JZB==" << jzbSel*(1.-systematic) << "(-"<<syst*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)" << std::endl;
323 up=((effp-eff)/eff);
324 down=((effm-eff)/eff);
325 }
326
327 //________________________________________________________________________
328 // JZB response (true/reco. vs. true)
329 void JZBresponse(TTree *events, bool requireZ, float &resp, float &resperr, string addcut="",bool isMET = kFALSE, Float_t myJzbMax = 200., Int_t nPeriods = 9 ) {
330
331 jzbMin = 20;
332 TCut kbase("abs(genMll-91.2)<20&&genZPt>0&&genNjets>2");
333 if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses)
334 if(requireZ) kbase=kbase&&"TMath::Abs(genMID)==23";
335 TCut ksel("abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2");
336
337 TProfile* hJzbResp = new TProfile("hJzbResp","JZB response ; JZB true (GeV/c); JZB reco. / JZB true", nPeriods, jzbMin, myJzbMax, "" );
338
339 if (!isMET) events->Project("hJzbResp","("+TString(mcjzbexpression)+")/genJZB:genJZB",kbase&&ksel);
340 else events->Project("hJzbResp","met[4]/genMET:genMET",kbase&&ksel);
341
342 hJzbResp->SetMaximum(1.2);
343 hJzbResp->SetMinimum(0.2);
344 hJzbResp->Fit("pol0","Q");
345 TF1 *fittedfunction = hJzbResp->GetFunction("pol0");
346 resp=fittedfunction->GetParameter(0);
347 resperr=fittedfunction->GetParError(0);
348 if(!automatized) dout << " Response: " << resp << " +/- " << resperr << endl;
349 delete hJzbResp;
350 }
351
352
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;
358 float triggereff=4.0/100;// in range [0,1]
359 dout << "Trigger efficiency not implemented in this script yet, still using external one" << endl;
360 float leptonseleff=2.0/100;// in range [0,1]
361 dout << "Lepton selection efficiency not implemented in this script yet, still using external one" << endl;
362
363 float mceff,mcefferr,jzbeff,jzbefferr;
364 if(!automatized) dout << "MC efficiencies:" << endl;
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
369 if(!automatized) dout << "Error from Peak position:" << endl;
370 float sysfrompeak=0;
371 PeakError(events,sysfrompeak,mcjzb,peakerror,addcut);
372
373 if(!automatized) dout << "Jet energy scale: " << std::endl;
374 float jesup,jesdown;
375 JZBjetScale(events,jesdown,jesup,informalname,requireZ,addcut,JetEnergyScaleUncert);
376
377 if(!automatized) dout << "JZB scale: " << std::endl;
378 float scaleup,scaledown,scalesyst;
379 doJZBscale(events,scaledown,scaleup,scalesyst,JZBScaleUncert,informalname,requireZ,addcut);
380
381 if(!automatized) dout << "JZB response: " << std::endl;
382 float resp,resperr;
383 JZBresponse(events,requireZ,resp,resperr,addcut);
384
385 if(!automatized) dout << "Pileup: " << std::endl;
386 float resolution=pileup(events,requireZ,informalname,addcut);
387
388 dout << "_______________________________________________" << endl;
389 dout << " SUMMARY FOR " << informalname << " with JZB>" << jzbSel << " (all in %) ";
390 if(addcut!="") dout << "With additional cut: " << addcut;
391 dout << endl;
392 dout << "MC efficiency: " << mceff << "+/-" << mcefferr << endl; // in range [0,1]
393 dout << "Trigger efficiency: " << triggereff << endl; // in range [0,1]
394 dout << "Lepton Sel Eff: " << leptonseleff << endl; // in range [0,1]
395 dout << "Jet energy scale: " << jesup << " " << jesdown << endl; // in range [0,1]
396 dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << endl; // in range [0,1]
397 dout << "Resolution : " << resolution << endl; // in range [0,1]
398 dout << "From peak : " << sysfrompeak << endl; // in range [0,1]
399 dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1]
400 dout << "JZB response : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1]
401
402 float toterr=0;
403 toterr+=(triggereff)*(triggereff);
404 toterr+=(leptonseleff)*(leptonseleff);
405 if(fabs(jesup)>fabs(jesdown)) toterr+=(jesup*jesup); else toterr+=(jesdown*jesdown);
406 if(fabs(scaleup)>fabs(scaledown)) toterr+=(scaleup*scaleup); else toterr+=(scaledown*scaledown);
407 toterr+=(resolution*resolution);
408 toterr+=(sysfrompeak*sysfrompeak);
409 dout << "TOTAL SYSTEMATICS: " << TMath::Sqrt(toterr) << " --> " << TMath::Sqrt(toterr)*mceff << endl;
410 toterr=TMath::Sqrt(toterr)*mceff;
411 dout << "FINAL RESULT : " << 100*mceff << " +/- "<< 100*mcefferr << " (stat) +/- " << 100*toterr << " (syst) %" << endl;
412 dout << " we thus use the sqrt of the sum of the squares which is : " << 100*toterr << endl;
413 vector<float> res;
414 res.push_back(jzbSel);
415 res.push_back(mceff);
416 res.push_back(mcefferr);
417 res.push_back(toterr);
418 res.push_back(TMath::Sqrt((mcefferr)*(mcefferr)+(toterr*toterr)));
419 if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup)); else res.push_back(fabs(jesdown));
420 if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)); else res.push_back(fabs(scaledown));
421 res.push_back(fabs(resolution));
422 results.push_back(res);
423 }
424
425 vector<vector<float> > compute_systematics(string mcjzb, float mcpeakerror, string datajzb, samplecollection &signalsamples, vector<float> bins, bool requireZ=false) {
426 automatized=true;
427 vector< vector<float> > systematics;
428 for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
429 dout << "Looking at signal " << (signalsamples.collection)[isignal].filename << endl;
430 for(int ibin=0;ibin<bins.size();ibin++) {
431 jzbSel=bins[ibin];
432 geqleq="geq";
433 do_systematics_for_one_file((signalsamples.collection)[isignal].events,(signalsamples.collection)[isignal].Nentries,(signalsamples.collection)[isignal].samplename,systematics,mcjzb,datajzb,mcpeakerror,requireZ);
434 }//end of bin loop
435 }//end of signal loop
436 return systematics;
437 }