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.23 by pablom, Wed Aug 31 10:21:17 2011 UTC vs.
Revision 1.27 by buchmann, Thu Sep 1 15:41:32 2011 UTC

# Line 190 | Line 190 | void master_formula(std::vector<float> e
190   // Get normalization factor for the PDFs
191   float get_norm_pdf_factor(TTree *events, int k) {
192  
193 <  TH1F *haux = new TH1F("haux", "", 1000, 0, 15);
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 factor = haux->Integral();
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  
# Line 293 | Line 297 | void MCefficiency(TTree *events,float &r
297          string newPosSide = "(" + sposSide + ")*" + svar;
298          string newNegSide = "(" + snegSide + ")*" + svar;
299  
300 <        events->Draw(mcjzbexpression.c_str(), newPosSide.c_str(),"goff");
301 <        Float_t sel = events->GetSelectedRows();
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 <          events->Draw(mcjzbexpression.c_str(), newNegSide.c_str(),"goff");
307 <          nsel = events->GetSelectedRows();
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 = get_norm_pdf_factor(events, k);
311 >        float normFactor = 1;
312 >        if(k>=0) get_norm_pdf_factor(events, k);
313          sel = sel/normFactor;
314          nsel = nsel/normFactor;
315  
# Line 316 | Line 324 | void MCefficiency(TTree *events,float &r
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 << ")" << std::endl;
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   void JZBefficiency(TTree *events, string informalname, float &jzbeff, float &jzbefferr, bool requireZ, string addcut="") {
# Line 422 | Line 431 | void JZBresponse(TTree *events, bool req
431  
432   //________________________________________________________________________________________
433   // PDF uncertainty  
434 < float get_pdf_uncertainty(TTree *events, string mcjzb, bool requireZ, int Neventsinfile, string addcut="") {
426 <
427 <  int numberOfPDFs = 44;
434 > float get_pdf_uncertainty(TTree *events, string mcjzb, bool requireZ, int Neventsinfile, int NPdfs, string addcut="") {
435    std::vector<float> efficiency;
436 <  for(int k = 1; k < numberOfPDFs; k++) {
436 >  for(int k = 1; k < NPdfs; k++) {
437      float result, resulterr;
438      MCefficiency(events, result, resulterr, mcjzb, requireZ, Neventsinfile, addcut, k);  
439      efficiency.push_back(result);
440    }
441 <  float errHi, errLow;
441 >  float errHi, errLow,err;
442    master_formula(efficiency, errHi, errLow);
443 <  if(errHi>errLow) return errHi;
444 <  return errLow;
443 >  err=errLow;
444 >  if(errHi>errLow) err=errHi;
445 >  if(!automatized) dout << "  Uncertainty from PDF: " << errLow << " (low) and " << errHi << "(high) ---> Picked " << err << endl;
446 >  return err;
447  
448   }
449  
450 <
450 > int get_npdfs(TTree *events) {
451 >  int NPDFs;
452 >  events->SetBranchAddress("NPdfs",&NPDFs);
453 >  events->GetEntry(1);
454 >  return NPDFs;
455 > }
456 >  
457  
458   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) {
444  
459    float JetEnergyScaleUncert=0.1;
460    float JZBScaleUncert=0.1;
461    mcjzbexpression=mcjzb;
# Line 450 | Line 464 | void do_systematics_for_one_file(TTree *
464    float leptonseleff=2.0/100;// in range [0,1]
465    dout << "Lepton selection efficiency not implemented in this script  yet, still using external one" << endl;
466    
467 +  int NPdfs=0;
468 +  if(ismSUGRA) NPdfs = get_npdfs(events);
469 +
470    float mceff,mcefferr,jzbeff,jzbefferr;
471    if(!automatized) dout << "MC efficiencies:" << endl;
472 <  MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,Neventsinfile,addcut);
472 >  MCefficiency(events,mceff,mcefferr,mcjzb,requireZ,Neventsinfile,addcut,-1);
473    JZBefficiency(events,informalname,jzbeff,jzbefferr,requireZ,addcut);
474    if(!automatized) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << endl;
475    
# Line 476 | Line 493 | void do_systematics_for_one_file(TTree *
493    float resolution=pileup(events,requireZ,informalname,addcut);
494  
495    float PDFuncert=0;
496 <  if(ismSUGRA) PDFuncert = get_pdf_uncertainty(events, mcjzb, requireZ, Neventsinfile, addcut);
496 >  if(ismSUGRA) PDFuncert = get_pdf_uncertainty(events, mcjzb, requireZ, Neventsinfile, NPdfs, addcut);
497  
498    dout << "_______________________________________________" << endl;
499    dout << "                 SUMMARY FOR " << informalname << " with JZB>" << jzbSel << "  (all in %) ";
# Line 489 | Line 506 | void do_systematics_for_one_file(TTree *
506    dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << endl; // in range [0,1]
507    dout << "Resolution : " << resolution << endl; // in range [0,1]
508    dout << "From peak : " << sysfrompeak << endl; // in range [0,1]
509 <  dout << "PDF uncertainty  : " << PDFuncert << " (not yet included below) " << endl; // in range [0,1]
509 >  if(ismSUGRA) dout << "PDF uncertainty  : " << PDFuncert << endl; // in range [0,1]
510    dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1]
511    dout << "JZB response  : " << resp << " +/-" << resperr << " (not yet included below) " << endl; // in range [0,1]
512    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines