ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/Systematics.C
(Generate patch)

Comparing UserCode/cbrown/AnalysisFramework/Plotting/Modules/Systematics.C (file contents):
Revision 1.4 by buchmann, Tue Jul 19 15:00:10 2011 UTC vs.
Revision 1.5 by buchmann, Wed Jul 20 08:51:33 2011 UTC

# Line 89 | Line 89 | TH1F* plotEff(TTree* events, TCut kbase,
89          
90          events->Draw(mcjzbexpression.c_str(),"genJZBSel>-400"&&kbase,"goff");
91          Float_t maxEff = events->GetSelectedRows();
92 <        if(verbose>0) std::cout << hname << " (" << informalname <<") " << maxEff <<  std::endl;
92 >        if(verbose>0) dout << hname << " (" << informalname <<") " << maxEff <<  std::endl;
93          
94 <        if(verbose>0) std::cout <<  "JZB max = " << jzbMax << std::endl;
94 >        if(verbose>0) dout <<  "JZB max = " << jzbMax << std::endl;
95          // Loop over steps to get efficiency curve
96          char cut[256];
97          for ( Int_t iBin = 0; iBin<nBins; ++iBin ) {
98                  sprintf(cut,"genJZBSel>%3f",jzbMin+iBin*step);
99                  events->Draw(mcjzbexpression.c_str(),TCut(cut)&&kbase,"goff");
100                  Float_t eff = static_cast<Float_t>(events->GetSelectedRows())/maxEff;
101 <                //     std::cout << "COUCOU " << __LINE__ << std::endl;
101 >                //     dout << "COUCOU " << __LINE__ << std::endl;
102                  hJzbEff->SetBinContent(iBin+1,eff);
103                  hJzbEff->SetBinError(iBin+1,TMath::Sqrt(eff*(1-eff)/maxEff));
104          }
# Line 129 | Line 129 | float pileup(TTree *events, string infor
129          // Pimped-up function
130          TF1* funcUp = (TF1*)func->Clone();
131          funcUp->SetParameter( 0., func->GetParameter(0)/1.1); // 10% systematic error (up in sigma => 0.1 in erfc)
132 <        if(!automatized) std::cout << "  PU: " << funcUp->Eval(jzbSel) << " " <<  func->Eval(jzbSel)
132 >        if(!automatized) dout << "  PU: " << funcUp->Eval(jzbSel) << " " <<  func->Eval(jzbSel)
133          << "(" << (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel)*100. << "%)" << std::endl;
134          
135          return (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel)*100.;
# Line 153 | Line 153 | void MCefficiency(TTree *events,float &r
153          
154          result=sel/tot;
155          resulterr=TMath::Sqrt(sel/tot*(1-sel/tot)/tot);
156 <        if(!automatized) std::cout << "  MC efficiency: " << result << "+-" << resulterr << std::endl;
156 >        if(!automatized) dout << "  MC efficiency: " << result << "+-" << resulterr << std::endl;
157   }
158  
159   float JZBefficiency(TTree *events, string informalname) {
160          TCut kbase("abs(genMllSel-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2");
161          TH1F* hLM4 = plotEff(events,kbase,informalname);
162          Int_t bin = hLM4->FindBin(jzbSel); // To get the error
163 <        if(!automatized) std::cout << "  Efficiency at JZB==" << jzbSel  << std::endl;
164 <        if(!automatized) std::cout << "    " << Interpolate(jzbSel,hLM4) << "+-" << hLM4->GetBinError(bin)  << std::endl;
163 >        if(!automatized) dout << "  Efficiency at JZB==" << jzbSel  << std::endl;
164 >        if(!automatized) dout << "    " << Interpolate(jzbSel,hLM4) << "+-" << hLM4->GetBinError(bin)  << std::endl;
165          return -1;
166   }
167  
# Line 193 | Line 193 | void JZBjetScale(TTree *events, float &j
193          Float_t eff  = Interpolate(jzbSel,hist);
194          Float_t effp = Interpolate(jzbSel,histp);
195          Float_t effm = Interpolate(jzbSel,histm);
196 <        if(!automatized) std::cout << "  Efficiency at JZB==" << jzbSel  << std::endl;
197 <        if(!automatized) std::cout << "    JESup: " << effp << " (" << (effp-eff)/eff*100. << "%)" << std::endl;
198 <        if(!automatized) std::cout << "    central:  " << eff << std::endl;
199 <        if(!automatized) std::cout << "    JESdown: " << effm << " (" << (effm-eff)/eff*100. << "%)" << std::endl;
196 >        if(!automatized) dout << "  Efficiency at JZB==" << jzbSel  << std::endl;
197 >        if(!automatized) dout << "    JESup: " << effp << " (" << (effp-eff)/eff*100. << "%)" << std::endl;
198 >        if(!automatized) dout << "    central:  " << eff << std::endl;
199 >        if(!automatized) dout << "    JESdown: " << effm << " (" << (effm-eff)/eff*100. << "%)" << std::endl;
200          jesup=(effp-eff)/eff*100.;
201          jesdown=(effm-eff)/eff*100.;
202   }
# Line 218 | Line 218 | void doJZBscale(TTree *events, float &do
218          Float_t eff  = Interpolate(jzbSel,hist);
219          Float_t effp = Interpolate(jzbSel*(1.+systematic),hist);
220          Float_t effm = Interpolate(jzbSel*(1.-systematic),hist);
221 <        if(!automatized) std::cout << "  efficiency at JZB==" << jzbSel*(1.+systematic)  << "(-"<<syst*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)"  << std::endl;
222 <        if(!automatized) std::cout << "  efficiency at JZB==" << jzbSel  << ": " << eff << std::endl;
223 <        if(!automatized) std::cout << "  efficiency at JZB==" << jzbSel*(1.-systematic)  << "(-"<<syst*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)"  << std::endl;
221 >        if(!automatized) dout << "  efficiency at JZB==" << jzbSel*(1.+systematic)  << "(-"<<syst*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)"  << std::endl;
222 >        if(!automatized) dout << "  efficiency at JZB==" << jzbSel  << ": " << eff << std::endl;
223 >        if(!automatized) dout << "  efficiency at JZB==" << jzbSel*(1.-systematic)  << "(-"<<syst*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)"  << std::endl;
224          up=((effp-eff)/eff)*100;
225          down=((effm-eff)/eff)*100;
226   }
# Line 243 | Line 243 | void JZBresponse(TTree *events, bool isM
243          hJzbResp->SetMinimum(0.2);
244          hJzbResp->Fit("pol0","Q");
245          TF1 *fittedfunction = hJzbResp->GetFunction("pol0");
246 <        if(!automatized) cout << "  Response: " << fittedfunction->GetParameter(0) << " +/- " << fittedfunction->GetParError(0) << endl;
246 >        if(!automatized) dout << "  Response: " << fittedfunction->GetParameter(0) << " +/- " << fittedfunction->GetParError(0) << endl;
247 >        delete hJzbResp;
248   }
249  
250  
# Line 254 | Line 255 | void do_systematics_for_one_file(TTree *
255    mcjzbexpression=mcjzb;
256    
257    float triggereff=4;//percent!
258 <  cout << "Trigger efficiency not implemented in this script  yet, still using external one" << endl;
258 >  dout << "Trigger efficiency not implemented in this script  yet, still using external one" << endl;
259    float leptonseleff=2;//percent!
260 <  cout << "Lepton selection efficiency not implemented in this script  yet, still using external one" << endl;
260 >  dout << "Lepton selection efficiency not implemented in this script  yet, still using external one" << endl;
261    
262    float mceff,mcefferr;
263 <  if(!automatized) cout << "MC efficiencies:" << endl;
263 >  if(!automatized) dout << "MC efficiencies:" << endl;
264    MCefficiency(events,mceff,mcefferr,mcjzb);
265    JZBefficiency(events,informalname);
266    
267 <  if(!automatized) std::cout << "Jet energy scale: " << std::endl;
267 >  if(!automatized) dout << "Jet energy scale: " << std::endl;
268    float jesup,jesdown;
269    JZBjetScale(events,jesdown,jesup,informalname,JetEnergyScaleUncert);
270    
271 <  if(!automatized) std::cout << "JZB scale: " << std::endl;
271 >  if(!automatized) dout << "JZB scale: " << std::endl;
272    float scaleup,scaledown,scalesyst;
273    doJZBscale(events,scaledown,scaleup,scalesyst,JZBScaleUncert,informalname);
274    
275 <  if(!automatized) std::cout << "JZB response: " << std::endl;
275 >  if(!automatized) dout << "JZB response: " << std::endl;
276    JZBresponse(events);
277  
278 <  if(!automatized) std::cout << "Pileup: " << std::endl;
278 >  if(!automatized) dout << "Pileup: " << std::endl;
279    float resolution=pileup(events,informalname);
280    
281 <  cout << "_______________________________________________" << endl;
282 <  cout << "                 SUMMARY FOR " << informalname << " with JZB>" << jzbSel << endl;
283 <  cout << "MC efficiency: " << mceff << "+/-" << mcefferr << endl;
284 <  cout << "Trigger efficiency: " << triggereff << endl;
285 <  cout << "Lepton Sel Eff: " << leptonseleff << endl;
286 <  cout << "For JZB>" << jzbSel << endl;
287 <  cout << "Jet energy scale: " << jesup << " " << jesdown << " --> suggesting: " << Round(0.5*(fabs(jesup)+fabs(jesdown)),1) << endl;
288 <  cout << "JZB Scale Uncert: " << scaledown << " " << scaleup << " --> suggesting: " << Round(0.5*(fabs(scaledown)+fabs(scaleup)),1) << endl;
289 <  cout << "Resolution : " << resolution << endl;
281 >  dout << "_______________________________________________" << endl;
282 >  dout << "                 SUMMARY FOR " << informalname << " with JZB>" << jzbSel << endl;
283 >  dout << "MC efficiency: " << mceff << "+/-" << mcefferr << endl;
284 >  dout << "Trigger efficiency: " << triggereff << endl;
285 >  dout << "Lepton Sel Eff: " << leptonseleff << endl;
286 >  dout << "For JZB>" << jzbSel << endl;
287 >  dout << "Jet energy scale: " << jesup << " " << jesdown << " --> suggesting: " << Round(0.5*(fabs(jesup)+fabs(jesdown)),1) << endl;
288 >  dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << " --> suggesting: " << Round(0.5*(fabs(scaledown)+fabs(scaleup)),1) << endl;
289 >  dout << "Resolution : " << resolution << endl;
290    
291    
292    float toterr=0;
# Line 295 | Line 296 | void do_systematics_for_one_file(TTree *
296    if(fabs(scaleup)>fabs(scaledown)) toterr+=(scaleup/100)*(scaleup/100); else toterr+=(scaledown/100)*(scaledown/100);
297    toterr+=(resolution/100)*(resolution/100);
298    toterr=TMath::Sqrt(toterr);
299 <  cout << "FINAL RESULT : " << mceff << " +/- "<< mcefferr << " (stat) +/- " << 100*toterr << " (syst)" << endl;
300 <  cout << "     we thus use the sqrt of the sum of the squares which is : " << 100*TMath::Sqrt(mcefferr*mcefferr+(toterr*toterr)) << endl;
299 >  dout << "FINAL RESULT : " << mceff << " +/- "<< mcefferr << " (stat) +/- " << 100*toterr << " (syst)" << endl;
300 >  dout << "     we thus use the sqrt of the sum of the squares which is : " << 100*TMath::Sqrt(mcefferr*mcefferr+(toterr*toterr)) << endl;
301    vector<float> res;
302    res.push_back(jzbSel);
303    res.push_back(mceff);
# Line 311 | Line 312 | vector<vector<float> > compute_systemati
312    automatized=true;
313    vector< vector<float> > systematics;
314    for (int isignal=0; isignal<signalsamples.collection.size();isignal++) {
315 <      cout << "Looking at signal " << (signalsamples.collection)[isignal].filename << endl;
315 >      dout << "Looking at signal " << (signalsamples.collection)[isignal].filename << endl;
316        for(int ibin=0;ibin<bins.size();ibin++) {
317          jzbSel=bins[ibin];
318          geqleq="geq";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines