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

Comparing UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C (file contents):
Revision 1.25 by buchmann, Fri Jun 15 08:41:04 2012 UTC vs.
Revision 1.29 by buchmann, Mon Jun 18 16:26:07 2012 UTC

# Line 30 | Line 30 | void todo() {
30    dout << "Info : The lepton requirement is currently set to " << (const char*) leptoncut << endl;
31   }  
32  
33 < void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true )
33 >
34 >
35 > void find_one_peak_combination(TCut specialcut, float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, float &MCSigma, float &DataSigma, stringstream &result, bool doPUreweighting = true, string saveas="")
36   {
37    // Temporarily switch off PU reweighting, if asked
38    TCut weightbackup=cutWeight;
# Line 40 | Line 42 | void find_peaks(float &MCPeak,float &MCP
42    if(PlottingSetup::DoBTag) nbins=25;
43    
44    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
45 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
46 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
47 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
48 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
45 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,mc, luminosity);
46 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&specialcut,data, luminosity);
47 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,mc, luminosity);
48 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets&&specialcut,data, luminosity);
49    TH1F *rawttbarjzbeemmMC;
50  
51    if(method==doKM) {
52      //we only need this histo for the KM fitting...
53 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
54 <    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
55 <    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
53 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&specialcut,mc,luminosity,allsamples.FindSample("TTJet"));
54 >    MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
55 >    DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
56 >    delete rawttbarjzbeemmMC;
57    }
58    else {
59      TH1F *reducedMC = (TH1F*)rawJZBeemmMC->Clone();
# Line 58 | Line 61 | void find_peaks(float &MCPeak,float &MCP
61      reducedMC->Add(rawJZBemMC,-1);
62      reducedData->Add(rawJZBemData,-1);
63      //this is Kostas' way of doing it - we subtract em to get rid of some of the ttbar contribution (in reality, of flavor-symmetric contribution)
64 <    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
65 <    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
66 <    
64 >    MCPeak=find_peak(reducedMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method,saveas);
65 >    DataPeak=find_peak(reducedData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method,saveas);
66 >    delete reducedMC;
67 >    delete reducedData;
68    }
69  
70    // Revert to original PU reweighting
# Line 68 | Line 72 | void find_peaks(float &MCPeak,float &MCP
72      
73   //  MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
74   //  DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
75 <  dout << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
76 <  result << "We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 <  dout << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
78 <  result << "We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
75 >  dout   << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
76 >  result << "   We have found the peak in Data at " << DataPeak << " +/- " << DataPeakError << " with sigma=" << DataSigma << " +/- ?? (not impl.)" << endl;
77 >  dout   << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
78 >  result << "   We have found the peak in MC at " << MCPeak << " +/- " << MCPeakError << " with sigma=" << MCSigma << " +/- ?? (not impl.)" << endl;
79 >  delete rawJZBeemmData;
80 >  delete rawJZBeemmMC;
81 >  delete rawJZBemData;
82 >  delete rawJZBemMC;
83    delete tempcan;
84   }
85  
86 + void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb)
87 + {
88 +  float mcpeak, datapeak;
89 +  float mcpeakerr, datapeakerr;
90 +  
91 +  float mceepeak,mcmmpeak;
92 +  float mceepeakerr,mcmmpeakerr;
93 +  
94 +  float datammpeak,dataeepeak;
95 +  float datammpeakerr,dataeepeakerr;
96 +  
97 +  float mcSigma, dataSigma;
98 +  
99 +  dout << "Finding global peak : " << endl;
100 +  find_one_peak_combination(TCut(""),mcpeak,mcpeakerr, datapeak,datapeakerr,mcSigma, dataSigma,result,doPUreweighting,"");
101 +  dout << "Finding peak for electrons : " << endl;
102 +  find_one_peak_combination(TCut("id1==0"),mceepeak,mceepeakerr, dataeepeak,dataeepeakerr,mcSigma, dataSigma,result,doPUreweighting,"_ele");
103 +  dout << "Finding peak for muons : " << endl;
104 +  find_one_peak_combination(TCut("id1==1"),mcmmpeak,mcmmpeakerr, datammpeak,datammpeakerr,mcSigma, dataSigma,result,doPUreweighting,"_mu");
105 +  
106 +  datajzb << "(" << jzbvariabledata;
107 +  mcjzb << "(" << jzbvariablemc;
108 +  
109 +  if(dataeepeak>0) datajzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
110 +  else datajzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(dataeepeak) << " ";
111 +  
112 +  if(datammpeak>0) datajzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
113 +  else datajzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(datammpeak) << " ";
114 +  
115 +  if(datapeak>0) datajzb << "- (id1!=id2)*" << TMath::Abs(datapeak) << " ";
116 +  else datajzb << "+ (id1!=id2)*" << TMath::Abs(datapeak) << " ";
117 +  
118 +  datajzb << ")";
119 +  
120 +  if(mceepeak>0) mcjzb << "- (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
121 +  else mcjzb << "+ (id1==id2)*(id1==0)*" << TMath::Abs(mceepeak) << " ";
122 +  
123 +  if(mcmmpeak>0) mcjzb << "- (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
124 +  else mcjzb << "+ (id1==id2)*(id1==1)*" << TMath::Abs(mcmmpeak) << " ";
125 +  
126 +  if(mcpeak>0) mcjzb << "- (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
127 +  else mcjzb << "+ (id1!=id2)*" << TMath::Abs(mcpeak) << " ";
128 +  
129 +  mcjzb << ")";
130 + }
131 +
132   void make_special_obs_pred_mll_plot(string mcjzb, float jzbthreshold) {
133    float min=70.0;
134    float max=115.0;
# Line 436 | Line 490 | void do_kinematic_plots(string mcjzb, st
490    float mll_low=50;
491    float mll_hi=160;
492    if(!PlottingSetup::RestrictToMassPeak) {
493 <        mll_low=iMllLow;
493 >        mll_low=20;
494          mll_hi=210;
495    }
496    
# Line 861 | Line 915 | if you want to start from scratch (witho
915    return return_functions;
916   }
917  
918 < void do_prediction_plot(string jzb, TCanvas *globalcanvas, float sigma, float high, int use_data, bool overlay_signal = false,string subdir="" )
918 > void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
919   {
866  // note: sigma is not used ATM
920    switch_overunderflow(true);
921    bool is_data=false;
922    bool use_signal=false;
# Line 939 | Line 992 | void do_prediction_plot(string jzb, TCan
992    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
993    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
994      
995 <  TH1F *BpredSys = (TH1F*)LcorrJZBeemm->Clone("Bpredsys");
995 >  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
996    ClearHisto(BpredSys);
944    write_error(__FUNCTION__,"Implemented systematic error but NOT drawing it yet. Need to still implement drawing, particularly in ratio.");
997      
998    if(PlottingSetup::RestrictToMassPeak) {
999      Bpred->Add(RcorrJZBem,1.0/3.);
# Line 967 | Line 1019 | void do_prediction_plot(string jzb, TCan
1019      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
1020        
1021      //Systematics:
1022 <    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1023 <    AddSquared(BpredSys,RcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1024 <    AddSquared(BpredSys,LcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1025 <    AddSquared(BpredSys,RcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1026 <    AddSquared(BpredSys,LcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1027 <    AddSquared(BpredSys,RcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1028 <    AddSquared(BpredSys,LcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1022 >    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
1023 >    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1024 >    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
1025 >    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1026 >    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
1027 >    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1028 >    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
1029    } else {
1030      Bpred->Add(RcorrJZBem,1.0);
1031      Bpred->Add(LcorrJZBem,-1.0);
# Line 985 | Line 1037 | void do_prediction_plot(string jzb, TCan
1037      JBpred->Add(JLcorrJZBem,-1.0);
1038        
1039      //Systematics
1040 <    AddSquared(BpredSys,LcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1041 <    AddSquared(BpredSys,RcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1042 <    AddSquared(BpredSys,LcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1040 >    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
1041 >    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1042 >    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
1043  
1044    }
1045      
1046    SQRT(BpredSys);
1047 +  BpredSys->Divide(JBpred);
1048  
1049    
1050    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
# Line 1172 | Line 1225 | void do_prediction_plot(string jzb, TCan
1225    string ytitle("ratio");
1226    if ( use_data==1 ) ytitle = "data/pred";
1227    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1228 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle);//not extending the y range anymore up to 4
1228 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle,BpredSys);//not extending the y range anymore up to 4
1229  
1230    
1231    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
# Line 1267 | Line 1320 | void do_prediction_plot(string jzb, TCan
1320  
1321   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1322    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1323 <  do_prediction_plot(datajzb,globalcanvas,DataSigma,jzbHigh ,data,overlay_signal);
1323 >  do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1324    if ( !PlottingSetup::Approved ) {
1325 <    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mc,overlay_signal);
1326 <    do_prediction_plot(mcjzb,globalcanvas,MCSigma,jzbHigh ,mcwithsignal,overlay_signal);
1325 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mc,overlay_signal);
1326 >    do_prediction_plot(mcjzb,globalcanvas,jzbHigh ,mcwithsignal,overlay_signal);
1327    } else {
1328      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1329    }
# Line 1705 | Line 1758 | void diboson_plots(string mcjzb, string
1758    dout << "Going to produce JZB plots" << endl;
1759    produce_stretched_jzb_plots(mcjzb,datajzb,ratio_binning);
1760    TCanvas *gloca = new TCanvas("gloca","gloca");
1708  float sigma=123456;
1761    
1762    dout << "Going to produce prediction plots" << endl;
1763 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1764 <  do_prediction_plot(mcjzb, gloca, sigma, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1763 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do only MC plots, no signal
1764 >  do_prediction_plot(mcjzb, gloca, PlottingSetup::jzbHigh, 0, false,"Dibosons/Bpred/" ); // do MC plots with signal
1765    delete gloca;
1766  
1767    dout << "Going to reset the cross section for diboson samples ... " << endl;
# Line 2092 | Line 2144 | void draw_ttbar_and_zjets_shape(string m
2144    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2145   }
2146  
2147 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2096 <  //first: colorful plots
2147 > float find_one_correction_factor(string FindKeyword, TCut SpecialCut, string SaveAs) {
2148    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2149    cancorr->SetLogz();
2150    cancorr->SetRightMargin(0.13);
2151 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2101 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2151 >  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)"&&SpecialCut);
2152    if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2153    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2154 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2154 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2155 >  for(int iSample=0;iSample<SampleIndices.size();iSample++) {
2156 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << endl;
2157 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",zptforresponsepresentation*cutWeight);
2158 >  }
2159 >    
2160    niceresponseplotd->SetStats(0);
2161    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2162    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 2112 | Line 2167 | void find_correction_factors(string &jzb
2167    profd->SetMarkerSize(DataMarkerSize);
2168    profd->Fit("pol0","","same,e1",100,400);
2169    DrawPrelim();
2170 <  TText* title = write_text(0.5,0.7,"Data");
2170 >  string stitle="Data";
2171 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2172 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2173    title->SetTextAlign(12);
2174    title->Draw();
2175    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2176 <  float datacorrection=datapol->GetParameter(0);
2177 <  stringstream dataresstring;
2178 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2179 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2176 >  float correction=datapol->GetParameter(0);
2177 >  stringstream resstring;
2178 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2179 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2180    restitle->SetTextAlign(12);
2181    restitle->SetTextSize(0.03);
2182    restitle->Draw();
2183 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2183 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2184 >  delete cancorr;
2185 >  delete niceresponseplotd;
2186 >  return correction;
2187 > }
2188 >
2189 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2190    
2191 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2192 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation*cutWeight);
2193 <  niceresponseplotm->SetStats(0);
2194 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2195 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
2196 <  niceresponseplotm->GetXaxis()->CenterTitle();
2134 <  niceresponseplotm->GetYaxis()->CenterTitle();
2135 <  niceresponseplotm->Draw("COLZ");
2136 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2137 <  TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2138 <  profm->SetMarkerSize(DataMarkerSize);
2139 <  profm->Fit("pol0","","same,e1",100,400);
2140 <  DrawMCPrelim();
2141 <  title = write_text(0.5,0.7,"MC simulation");
2142 <  title->SetTextAlign(12);
2143 <  title->Draw();
2144 <  TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
2145 <  float mccorrection=mcpol->GetParameter(0);
2146 <  stringstream mcresstring;
2147 <  mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
2148 <  TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
2149 <  mcrestitle->SetTextAlign(12);
2150 <  mcrestitle->SetTextSize(0.03);
2151 <  mcrestitle->Draw();
2152 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
2191 >  //Step 1 : Get results
2192 >  float datacorrection=find_one_correction_factor("Data","","Data");
2193 >  float mccorrection=find_one_correction_factor("DY","","MC");
2194 >  
2195 >  float dataEEcorrection=find_one_correction_factor("Data","id1==0","Data_ee");
2196 >  float mcEEcorrection=find_one_correction_factor("DY","id1==0","MC_ee");
2197    
2198 +  float dataMMcorrection=find_one_correction_factor("Data","id1==1","Data_mm");
2199 +  float mcMMcorrection=find_one_correction_factor("DY","id1==1","MC_mm");
2200    
2201 <  //Step 2: Getting the result
2202 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2201 >  cout << "Corrections : " << endl;
2202 >  cout << "   Data : " << datacorrection << endl;
2203 >  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2204 >  cout << "   MC : " << mccorrection << endl;
2205 >  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2206 >  
2207 >  cout << "        result from new one for data: " << 0.937097 << endl;
2208 >  cout << "        result from old one for data: " << 0.937097 << endl;
2209 >  cout << "        result from new one for MC: " << 0.96848 << endl;
2210 >  cout << "        result from old one for MC: " << 0.963502 << endl;
2211 >  
2212 >  
2213 >  //Step 2: Processing the result and making it into something useful :-)
2214    stringstream jzbvardatas;
2215 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2216 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2215 >  jzbvardatas << "(";
2216 >  
2217 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2218 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2219 >  
2220 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2221 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2222 >  
2223 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2224 >  
2225 >  if(averagecorrection>1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << averagecorrection-1 << "*pt))";
2226 >  if(averagecorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << 1-averagecorrection << "*pt))";
2227 >  
2228 >  jzbvardatas << ")";
2229    jzbvardata=jzbvardatas.str();
2230 +  
2231    stringstream jzbvarmcs;
2232 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2233 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2232 >  jzbvarmcs << "(";
2233 >  
2234 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2235 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2236 >  
2237 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2238 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2239 >  
2240 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2241 >  
2242 >  if(averagemccorrection>1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << averagemccorrection-1 << "*pt))";
2243 >  if(averagemccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << 1-averagemccorrection << "*pt))";
2244 >  
2245 >  jzbvarmcs << ")";
2246    jzbvarmc=jzbvarmcs.str();
2247 +
2248    dout << "JZB Z pt correction summary : " << endl;
2249    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2250    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2251 +  
2252   }
2253  
2254   void pick_up_events(string cut) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines