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.26 by buchmann, Thu Sep 1 09:27:46 2011 UTC vs.
Revision 1.33 by buchmann, Mon Sep 26 15:09:41 2011 UTC

# Line 1 | Line 1
1   #include <iostream>
2   #include <vector>
3   #include <sys/stat.h>
4 + #include <algorithm>
5 + #include <cmath>
6  
7   #include <TMath.h>
8   #include <TColor.h>
# Line 276 | Line 278 | void PeakError(TTree *events,float &resu
278  
279   //____________________________________________________________________________________
280   // Total selection efficiency (MC)
281 < void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="", int k = 0) {
281 > //returns the efficiency WITHOUT signal contamination, and the result and resulterr contain the result and the corresponding error
282 > Value MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="", int k = 0) {
283          
284          char jzbSelStr[256]; sprintf(jzbSelStr,"%f",jzbSel);
285          // All acceptance cuts at gen. level
# Line 317 | Line 320 | void MCefficiency(TTree *events,float &r
320   //      Float_t tot = events->GetSelectedRows();
321          Float_t tot = Neventsinfile;
322          
323 +        Value result_wo_signalcont;
324 +
325          if(ConsiderSignalContaminationForLimits) {
326            result=(sel-nsel)/tot;
327            resulterr=(1.0/tot)*TMath::Sqrt(sel+nsel+(sel-nsel)*(sel-nsel)/tot);
328 +          result_wo_signalcont=Value(sel/tot,TMath::Sqrt(sel/tot*(1+sel/tot)/tot));
329          } else {//no signal contamination considered:
330            result=(sel)/tot;
331            resulterr=TMath::Sqrt(sel/tot*(1+sel/tot)/tot);
332 +          result_wo_signalcont=Value(result,resulterr);
333          }
334 +        if(!automatized && k>0 ) dout << "PDF assessment: ";
335          if(!automatized) dout << "  MC efficiency: " << result << "+-" << resulterr << "  ( JZB>" << jzbSel << " : " << sel << " , JZB<-" << jzbSel << " : " << nsel << " and nevents=" << tot << ") with normFact=" << normFactor << std::endl;
336          delete effh;
337   }
338  
339 +
340 + //____________________________________________________________________________________
341 + // Selection efficiency for one process (MC)
342 + vector<float> processMCefficiency(TTree *events,string mcjzb,bool requireZ,int Neventsinfile, string addcut) {
343 +  vector<float> process_efficiencies;
344 +  for(int iprocess=0;iprocess<=10;iprocess++) {
345 +    float this_process_efficiency,efferr;
346 +    stringstream addcutplus;
347 +    addcutplus<<addcut<<"&&(process=="<<iprocess<<")";
348 +    MCefficiency(events,this_process_efficiency, efferr,mcjzb,requireZ,Neventsinfile, addcutplus.str(),-1);
349 +    process_efficiencies.push_back(this_process_efficiency);
350 +  }
351 +  return process_efficiencies;
352 + }
353 +        
354 +
355   void JZBefficiency(TTree *events, string informalname, float &jzbeff, float &jzbefferr, bool requireZ, string addcut="") {
356          TCut kbase("abs(genMll-91.2)<20&&genNjets>2&&genZPt>0&&abs(mll-91.2)<20&&((id1+1)*(id2+1)*ch1*ch2)!=-2");
357          if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses)
# Line 396 | Line 420 | void doJZBscale(TTree *events, float &do
420          Float_t eff  = Interpolate(jzbSel,hist);
421          Float_t effp = Interpolate(jzbSel*(1.+systematic),hist);
422          Float_t effm = Interpolate(jzbSel*(1.-systematic),hist);
423 <        if(!automatized) dout << "  efficiency at JZB==" << jzbSel*(1.+systematic)  << "(-"<<syst*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)"  << std::endl;
423 >        if(!automatized) dout << "  efficiency at JZB==" << jzbSel*(1.+systematic)  << "(-"<<systematic*100<<"%) : " << effp << " (" << ((effp-eff)/eff)*100. << "%)"  << std::endl;
424          if(!automatized) dout << "  efficiency at JZB==" << jzbSel  << ": " << eff << std::endl;
425 <        if(!automatized) dout << "  efficiency at JZB==" << jzbSel*(1.-systematic)  << "(-"<<syst*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)"  << std::endl;
425 >        if(!automatized) dout << "  efficiency at JZB==" << jzbSel*(1.-systematic)  << "(-"<<systematic*100<<"%) : " << effm << " (" << ((effm-eff)/eff)*100. << "%)"  << std::endl;
426          up=((effp-eff)/eff);
427          down=((effm-eff)/eff);
428   }
# Line 422 | Line 446 | void JZBresponse(TTree *events, bool req
446          hJzbResp->SetMinimum(0.2);
447          hJzbResp->Fit("pol0","Q");
448          TF1 *fittedfunction = hJzbResp->GetFunction("pol0");
449 <        resp=fittedfunction->GetParameter(0);
450 <        resperr=fittedfunction->GetParError(0);
451 <        if(!automatized) dout << "  Response: " << resp << " +/- " << resperr << endl;
449 >        if(!fittedfunction) {
450 >                // in case there are not enough points passing our selection
451 >                cout << "OOPS response function invalid, assuming 100% error !!!!" << endl;
452 >                resp=1;
453 >                resperr=1;
454 >        } else {
455 >                resp=fittedfunction->GetParameter(0);
456 >                resperr=fittedfunction->GetParError(0);
457 >                if(!automatized) dout << "  Response: " << resp << " +/- " << resperr << endl;
458 >        }
459          delete hJzbResp;
460   }
461  
# Line 459 | Line 490 | void do_systematics_for_one_file(TTree *
490    float JetEnergyScaleUncert=0.1;
491    float JZBScaleUncert=0.1;
492    mcjzbexpression=mcjzb;
493 <  float triggereff=4.0/100;// in range [0,1]
493 >  float triggereff=5.0/100;// in range [0,1]
494    dout << "Trigger efficiency not implemented in this script  yet, still using external one" << endl;
495    float leptonseleff=2.0/100;// in range [0,1]
496 +  leptonseleff=TMath::Sqrt(leptonseleff*leptonseleff+leptonseleff*leptonseleff); // because the 2% is per lepton
497    dout << "Lepton selection efficiency not implemented in this script  yet, still using external one" << endl;
498    
499 <  int NPdfs=get_npdfs(events);
500 <
499 >  int NPdfs=0;
500 >  if(ismSUGRA) NPdfs = get_npdfs(events);
501 >  
502    float mceff,mcefferr,jzbeff,jzbefferr;
503    if(!automatized) dout << "MC efficiencies:" << endl;
504    MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,Neventsinfile,addcut,-1);
505 <  JZBefficiency(events,informalname,jzbeff,jzbefferr,requireZ,addcut);
505 >  if(PlottingSetup::computeJZBefficiency) JZBefficiency(events,informalname,jzbeff,jzbefferr,requireZ,addcut);
506    if(!automatized) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << endl;
507    
508    if(!automatized) dout << "Error from Peak position:" << endl;
# Line 486 | Line 519 | void do_systematics_for_one_file(TTree *
519    
520    if(!automatized) dout << "JZB response: " << std::endl;
521    float resp,resperr;
522 <  JZBresponse(events,requireZ,resp,resperr,addcut);
522 >  if(PlottingSetup::computeJZBresponse) {
523 >        if(!automatized) dout << "JZB response: " << std::endl;
524 >        JZBresponse(events,requireZ,resp,resperr,addcut);
525 >  }
526  
527    if(!automatized) dout << "Pileup: " << std::endl;
528 <  float resolution=pileup(events,requireZ,informalname,addcut);
528 >  float resolution;
529 >  resolution=pileup(events,requireZ,informalname,addcut);
530  
531    float PDFuncert=0;
532 +  if(!automatized) dout << "Assessing PDF uncertainty: " << std::endl;
533    if(ismSUGRA) PDFuncert = get_pdf_uncertainty(events, mcjzb, requireZ, Neventsinfile, NPdfs, addcut);
534  
535    dout << "_______________________________________________" << endl;
# Line 506 | Line 544 | void do_systematics_for_one_file(TTree *
544    dout << "Resolution : " << resolution << endl; // in range [0,1]
545    dout << "From peak : " << sysfrompeak << endl; // in range [0,1]
546    if(ismSUGRA) dout << "PDF uncertainty  : " << PDFuncert << endl; // in range [0,1]
547 <  dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1]
548 <  dout << "JZB response  : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1]
547 >  if(PlottingSetup::computeJZBefficiency) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1]
548 >  if(PlottingSetup::computeJZBresponse)dout << "JZB response  : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1]
549    
550    float toterr=0;
551    toterr+=(triggereff)*(triggereff);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines