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.46 by buchmann, Wed Nov 9 10:55:25 2011 UTC vs.
Revision 1.50 by buchmann, Wed Nov 9 16:50:36 2011 UTC

# Line 149 | Line 149 | float allcontributionsplot(TTree* events
149   TH1F* plotEff(TTree* events, TCut kbase, TString informalname, int flipped) {
150          iplot++;
151          int count=iplot;
152 +        iplot++;
153 +        int count2=iplot;
154          // Define new histogram
155          char hname[30]; sprintf(hname,"hJzbEff%d",count);
156 <        TH1F* hJzbEff = new TH1F(hname,"JZB selection efficiency ; JZB (GeV/c); Efficiency",
157 <                                                         nBins,jzbMin,jzbMax);
156 >        char hname2[30]; sprintf(hname2,"hJzbEff%d",count2);
157 >        TH1F* hJzbEff = new TH1F(hname,"JZB selection efficiency ; JZB (GeV/c); Efficiency",nBins,jzbMin,jzbMax);
158 >        TH1F* hJzbEff2= new TH1F(hname2,"JZB selection efficiency ; JZB (GeV/c); Efficiency",1,-14000,14000);
159          Float_t step = (jzbMax-jzbMin)/static_cast<Float_t>(nBins);
160 <        
161 <        if(flipped==0) events->Draw(mcjzbexpression.c_str(),"genJZB>-400"&&kbase,"goff");
162 <        else events->Draw(("-"+mcjzbexpression).c_str(),"genJZB>-14000"&&kbase,"goff");
163 <        Float_t maxEff = events->GetSelectedRows();
160 >
161 >        if(flipped==0) events->Draw((mcjzbexpression+">>"+(string)hname2).c_str(),("genJZB>-400"&&kbase),"goff");
162 >        else events->Draw(("-"+mcjzbexpression).c_str(),("genJZB<400"&&kbase),"goff");
163 >        Float_t maxEff = hJzbEff2->Integral();
164          if(verbose>0) dout << hname << " (" << informalname <<") " << maxEff <<  std::endl;
165          
166          if(verbose>0) dout <<  "JZB max = " << jzbMax << std::endl;
# Line 165 | Line 168 | TH1F* plotEff(TTree* events, TCut kbase,
168          char cut[256];
169          for ( Int_t iBin = 0; iBin<nBins; ++iBin ) {
170                  sprintf(cut,"genJZB>%3f",jzbMin+iBin*step);
171 <                events->Draw(mcjzbexpression.c_str(),TCut(cut)&&kbase,"goff");
172 <                Float_t eff = static_cast<Float_t>(events->GetSelectedRows())/maxEff;
173 <                //     dout << "COUCOU " << __LINE__ << std::endl;
171 >                if(flipped>0) sprintf(cut,"genJZB<-%3f",jzbMin+iBin*step);
172 >                if(flipped==0) events->Draw((mcjzbexpression+">>"+(string)hname2).c_str(),(TCut(cut)&&kbase),"goff");
173 >                if(flipped==1) events->Draw(("-"+mcjzbexpression+">>"+(string)hname2).c_str(),(TCut(cut)&&kbase),"goff");
174 >                Float_t eff = static_cast<Float_t>(hJzbEff2->Integral())/maxEff;
175                  hJzbEff->SetBinContent(iBin+1,eff);
176                  hJzbEff->SetBinError(iBin+1,TMath::Sqrt(eff*(1-eff)/maxEff));
177          }
178 +        delete hJzbEff2;
179          return hJzbEff;
175        
176        
180   }
181  
182  
# Line 252 | Line 255 | float pileup(TTree *events, bool require
255          
256          // Pimped-up function
257          TF1* funcUp = (TF1*)func->Clone();
258 <        funcUp->SetParameter( 0., func->GetParameter(0)/1.1); // 10% systematic error (up in sigma => 0.1 in erfc)
258 >        funcUp->SetParameter( 0, func->GetParameter(0)/1.1); // 10% systematic error (up in sigma => 0.1 in erfc)
259          if(!automatized) dout << "  PU: " << funcUp->Eval(jzbSel) << " " <<  func->Eval(jzbSel)
260          << "(" << (funcUp->Eval(jzbSel)-func->Eval(jzbSel))/func->Eval(jzbSel)*100. << "%)" << std::endl;
261          
# Line 424 | Line 427 | Value MCefficiency(TTree *events,float &
427          string emnewNegSide = "((id1!=id2)&&(" + snegSide + "))*" + svar; // only used for off peak analysis
428  
429          TH1F *effh= new TH1F("effh","effh",1,-14000,14000);
430 <        if(k>=0)events->Draw((mcjzbexpression+">>effh").c_str(), newPosSide.c_str(),"goff");
431 <        else events->Draw((mcjzbexpression+">>effh").c_str(), (sposSide+"&&(id1==id2)").c_str(),"goff");//the OSSF condition is added for the offpeak analysis, in onpeak case it's there already but doesn't change anything.
430 >        if(k>=0)events->Draw((mcjzbexpression+">>effh").c_str(), TCut(newPosSide.c_str())*PlottingSetup::Weight,"goff");
431 >        else events->Draw((mcjzbexpression+">>effh").c_str(), TCut((sposSide+"&&(id1==id2)").c_str())*PlottingSetup::Weight,"goff");//the OSSF condition is added for the offpeak analysis, in onpeak case it's there already but doesn't change anything.
432          Float_t sel = effh->Integral();
433          Float_t nsel=0;
434          
# Line 434 | Line 437 | Value MCefficiency(TTree *events,float &
437          if(ConsiderSignalContaminationForLimits) {
438            flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
439            if(PlottingSetup::RestrictToMassPeak) {
440 <            events->Draw((mcjzbexpression+">>effh").c_str(), newNegSide.c_str(),"goff");
440 >            events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(newNegSide.c_str()))*PlottingSetup::Weight,"goff");
441              nsel += effh->Integral();
442            } else {
443 <            events->Draw((mcjzbexpression+">>effh").c_str(), newNegSide.c_str(),"goff");
443 >            events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(newNegSide.c_str()))*PlottingSetup::Weight,"goff");
444              nsel += effh->Integral();
445 <            events->Draw((mcjzbexpression+">>effh").c_str(), emnewPosSide.c_str(),"goff");
445 >            events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(emnewPosSide.c_str()))*PlottingSetup::Weight,"goff");
446              nsel += effh->Integral();
447 <            events->Draw((mcjzbexpression+">>effh").c_str(), emnewNegSide.c_str(),"goff");
447 >            events->Draw((mcjzbexpression+">>effh").c_str(), (TCut(emnewNegSide.c_str()))*PlottingSetup::Weight,"goff");
448              nsel -= effh->Integral();
449            }
450          }
# Line 506 | Line 509 | void JZBefficiency(TTree *events, string
509  
510   //________________________________________________________________________
511   // Effect of energy scale on efficiency
512 < void JZBjetScale(TTree *events, float &jesdown, float &jesup, string informalname, int flipped, bool requireZ,string addcut="",float syst=0.1, Float_t jzbSelection=-1, TString plotName = "" ) {
512 > void JZBjetScale(TTree *events, float &jesdown, float &jesup, string informalname, int flipped, bool requireZ,string addcut="",Float_t jzbSelection=-1, TString plotName = "" ) {
513          TCut kbase(genMassCut&&"genZPt>0");
514          if(addcut!="") kbase=kbase&&addcut.c_str();//this is mostly for SUSY scans (adding requirements on masses)
515          flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
# Line 515 | Line 518 | void JZBjetScale(TTree *events, float &j
518          TCut ksel(cutmass&&cutOSSF);
519          TCut nJets("pfJetGoodNum>2");
520          stringstream down,up;
521 <        down << "pfJetGoodNum"<<30*(1-syst)<<">=3";
522 <        up << "pfJetGoodNum"<<30*(1+syst)<<">=3";
521 >        down << "pfJetGoodNumn1sigma>=3";
522 >        up << "pfJetGoodNump1sigma>=3";
523          
524          TCut nJetsP(up.str().c_str());
525          TCut nJetsM(down.str().c_str());
# Line 637 | Line 640 | int get_npdfs(TTree *events) {
640    
641  
642   void do_systematics_for_one_file(TTree *events,int Neventsinfile,string informalname, vector<vector<float> > &results,int flipped, string mcjzb,string datajzb,float peakerror,bool requireZ=false, string addcut="", bool ismSUGRA=false) {
643 <  float JetEnergyScaleUncert=0.1;
641 <  float JZBScaleUncert=0.1;
643 >  float JZBScaleUncert=0.05;
644    mcjzbexpression=mcjzb;
645 <  float triggereff=5.0/100;// in range [0,1]
645 >  float triggereff=2.0/100;// in range [0,1]
646    dout << "Trigger efficiency not implemented in this script  yet, still using external one" << endl;
647    float leptonseleff=2.0/100;// in range [0,1]
648    leptonseleff=TMath::Sqrt(leptonseleff*leptonseleff+leptonseleff*leptonseleff); // because the 2% is per lepton
# Line 664 | Line 666 | void do_systematics_for_one_file(TTree *
666      
667    if(!automatized) dout << "Jet energy scale: " << std::endl;
668    float jesup,jesdown;
669 <  JZBjetScale(events,jesdown,jesup,informalname,flipped,requireZ,addcut,JetEnergyScaleUncert);
669 >  JZBjetScale(events,jesdown,jesup,informalname,flipped,requireZ,addcut);
670    
671    if(!automatized) dout << "JZB scale: " << std::endl;
672    float scaleup,scaledown,scalesyst;
# Line 674 | Line 676 | void do_systematics_for_one_file(TTree *
676    float resp,resperr;
677    if(PlottingSetup::computeJZBresponse) {
678          if(!automatized) dout << "JZB response: " << std::endl;
679 <        JZBresponse(events,requireZ,resp,resperr,flipped,addcut);
679 >        if(!ismSUGRA) JZBresponse(events,requireZ,resp,resperr,flipped,addcut);
680    }
681  
682    if(!automatized) dout << "Pileup: " << std::endl;
683 <  float resolution;
684 <  resolution=pileup(events,requireZ,informalname,flipped,addcut);
683 > //  float resolution;
684 >  //resolution=pileup(events,requireZ,informalname,flipped,addcut);
685  
686    float PDFuncert=0;
687    if(!automatized) dout << "Assessing PDF uncertainty: " << std::endl;
# Line 694 | Line 696 | void do_systematics_for_one_file(TTree *
696    dout << "Lepton Sel Eff: " << leptonseleff << endl; // in range [0,1]
697    dout << "Jet energy scale: " << jesup << " " << jesdown << endl; // in range [0,1]
698    dout << "JZB Scale Uncert: " << scaledown << " " << scaleup << endl; // in range [0,1]
699 <  dout << "Resolution : " << resolution << endl; // in range [0,1]
699 > //  dout << "Resolution : " << resolution << endl; // in range [0,1]
700    dout << "From peak : " << sysfrompeak << endl; // in range [0,1]
701    if(ismSUGRA) dout << "PDF uncertainty  : " << PDFuncert << endl; // in range [0,1]
702    if(PlottingSetup::computeJZBefficiency) dout << "JZB efficiency: " << jzbeff << "+/-" << jzbefferr << " (not yet included below) " << endl; // in range [0,1]
# Line 705 | Line 707 | void do_systematics_for_one_file(TTree *
707    toterr+=(leptonseleff)*(leptonseleff);
708    if(fabs(jesup)>fabs(jesdown)) toterr+=(jesup*jesup); else toterr+=(jesdown*jesdown);
709    if(fabs(scaleup)>fabs(scaledown)) toterr+=(scaleup*scaleup); else toterr+=(scaledown*scaledown);
710 <  toterr+=(resolution*resolution);
710 > //  toterr+=(resolution*resolution);
711    toterr+=(sysfrompeak*sysfrompeak);
712    if(ismSUGRA) toterr+=(PDFuncert*PDFuncert);
713    dout << "TOTAL SYSTEMATICS: " << TMath::Sqrt(toterr) << " --> " << TMath::Sqrt(toterr)*mceff << endl;
# Line 725 | Line 727 | void do_systematics_for_one_file(TTree *
727    res.push_back(TMath::Sqrt((mcefferr)*(mcefferr)+(toterr*toterr)));
728    if(fabs(jesup)>fabs(jesdown)) res.push_back(fabs(jesup)); else res.push_back(fabs(jesdown));
729    if(fabs(scaleup)>fabs(scaledown)) res.push_back(fabs(scaleup)); else res.push_back(fabs(scaledown));
730 <  res.push_back(fabs(resolution));
730 > //  res.push_back(fabs(resolution));
731 >  res.push_back(0.0);
732    res.push_back(mceff_nosigcont.getValue());
733    res.push_back(mceff_nosigcont.getError());
734    if(ismSUGRA) res.push_back(PDFuncert);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines