ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Selective_Plot_Generator.C
Revision: 1.30
Committed: Tue Aug 28 13:56:08 2012 UTC (12 years, 8 months ago) by fronga
Content type: text/plain
Branch: MAIN
Changes since 1.29: +7 -2 lines
Log Message:
Turn on over- and under-flow bin merging (but NOT for peak finding!).

File Contents

# User Rev Content
1 buchmann 1.1 #include <iostream>
2     #include <vector>
3     #include <sys/stat.h>
4     #include <getopt.h>
5     #include <stdio.h>
6     #include <stdlib.h>
7 fronga 1.24
8     #ifndef Verbosity
9     #define Verbosity 0
10     #endif
11     #ifndef HUSH
12     #define HUSH 1
13     #endif
14    
15 buchmann 1.1 #include "Modules/GeneralToolBox.C"
16     #include "Modules/SampleClass.C"
17     #include "Modules/setTDRStyle.C"
18     #include "Modules/Setup.C"
19     #include "Modules/Poisson_Calculator.C"
20     #include "Modules/ActiveSamples.C"
21     #include "Modules/PeakFinder.C"
22     #include "Modules/UpperLimitsWithShape.C"
23     #include "Modules/Plotting_Functions.C"
24     #include "Modules/LimitCalculation.C"
25     #include "Modules/ResultModule.C"
26 buchmann 1.4 #include "Modules/CrossSectionReader.C"
27 buchmann 1.1 #include "Modules/Systematics.C"
28 buchmann 1.10 #include "Modules/SugarCoating.C"
29     #include "Modules/ExclusionPlot.C"
30 buchmann 1.1 #include "Modules/SUSYScan.C"
31 buchmann 1.21 #include "Modules/AachenCompatibility.C"
32 buchmann 1.26 #include "Modules/MetPlotting.C"
33 buchmann 1.1
34 buchmann 1.10
35    
36 buchmann 1.1 #include <TCut.h>
37     #include <TROOT.h>
38     #include <TCanvas.h>
39     #include <TMath.h>
40     #include <TColor.h>
41     #include <TPaveText.h>
42     #include <TRandom.h>
43     #include <TH1.h>
44     #include <TH2.h>
45     #include <TF1.h>
46     #include <TSQLResult.h>
47    
48     using namespace PlottingSetup;
49    
50     void usage(int passed=0 ) {
51     std::cout << "USAGE : " << std::endl;
52     std::cout << "You can use different options when running this program : " << std::endl;
53     std::cout << std::endl;
54     std::cout << "\033[1;34m all\033[0m \t\t All processes of the standard workflow" << std::endl;
55     std::cout << "\033[1;34m peak\033[0m \t\t Peak finding" << std::endl;
56     std::cout << "\033[1;34m kin\033[0m \t\t Kinematic plots" << std::endl;
57     std::cout << "\033[1;34m pfkin\033[0m \t Kinematic plots for PF variables" << std::endl;
58     std::cout << "\033[1;34m region\033[0m \t Region comparison plots" << std::endl;
59     std::cout << "\033[1;34m lepton\033[0m \t Lepton comparison plots" << std::endl;
60     std::cout << "\033[1;34m jzb\033[0m \t\t JZB plots" << std::endl;
61     std::cout << "\033[1;34m pred\033[0m \t\t Prediction plots" << std::endl;
62     std::cout << "\033[1;34m ratio\033[0m \t Ratio plots (standalone ratio plot)" << std::endl;
63     std::cout << "\033[1;34m signalbg\033[0m \t Signal vs. background plots (shape comparison)" << std::endl;
64     std::cout << "\033[1;34m ttbar\033[0m \t TTbar sideband comparison" << std::endl;
65     std::cout << "\033[1;34m zjets\033[0m \t ZJets plots" << std::endl;
66 buchmann 1.7 std::cout << "\033[1;34m diboson\033[0m \t Diboson plots" << std::endl;
67 buchmann 1.1 std::cout << "\033[1;34m results\033[0m \t Compute results (JZB>X)" << std::endl;
68     std::cout << "\033[1;34m syst\033[0m \t\t Compute systematics" << std::endl;
69     std::cout << "\033[1;34m eff\033[0m \t\t Compute all (partial) efficiencies" << std::endl;
70     std::cout << "\033[1;34m shapes\033[0m \t Prepare ROOT files for computing limits using shapes" << std::endl;
71     std::cout << "\033[1;34m counting\033[0m \t Establish limits with counting experiment" << std::endl;
72 buchmann 1.14 std::cout << "\033[1;34m shapelimit\033[0m \t Establish limits with shapes" << std::endl;
73 buchmann 1.15 std::cout << "\033[1;34m qcd\033[0m \t\t Show that QCD is negligible" << endl;
74 buchmann 1.1 std::cout << "\033[1;34m response\033[0m \t Compute response correction" << std::endl;
75     std::cout << "\033[1;34m pickup\033[0m \t Pick up interesting events" << std::endl;
76     std::cout << "\033[1;34m yields\033[0m \t Compute MC yields for this lumi" << std::endl;
77     std::cout << "\033[1;34m sideassess\033[0m\t Assessment of the mass sidebands definition in the data" << std::endl;
78     std::cout << "\033[1;34m jes\033[0m \t\t Make Jet Energy Scale (JES) plot" << std::endl;
79 buchmann 1.28 std::cout << "\033[1;34m nosidebands\033[0m \t\t Switch off sidebands for cJZB" << std::endl;
80 buchmann 1.15 std::cout << "\033[1;34m effcurve\033[0m \t\t Make JZB efficiency plot" << std::endl;
81 buchmann 1.1 std::cout << "\033[1;34m save\033[0m \t\t Save results in a template file (for reuse when establishing limits for scans)" << std::endl;
82     std::cout << "\033[1;34m png\033[0m \t\t Save all plots as pngs (also available: --pdf, --root, --eps, --C) standard: png&pdf" << std::endl;
83     std::cout << "\033[1;34m offpeak\033[0m \t Sets offpeak to true (i.e. carry out off-peak analysis!)" << std::endl;
84     std::cout << "\033[1;34m onpeak\033[0m \t Sets onpeak to true (i.e. carry out standard on-peak analysis!)" << std::endl;
85 buchmann 1.16 std::cout << "\033[1;34m btagged (b)\033[0m \t Sets DoBTag to true (i.e. carry out b tagged analysis)" << std::endl;
86 buchmann 1.2 std::cout << "\033[1;34m jzbcuts\033[0m \t Sets the jzb cuts (please provide them in the format 50,100,150,200 and so on (comma separated)" << endl;
87     std::cout << "\033[1;34m ptsanity\033[0m \t Checks whether all samples have the correct pt range (additional canvas for you to check)" << endl;
88 buchmann 1.15 std::cout << "\033[1;34m mlls\033[0m \t Draw dilepton invariant mass for all signals" << endl;
89 buchmann 1.18 std::cout << "\033[1;34m edge\033[0m \t Be on the edge of development and try out the new edge fitter :-)" << endl;
90 buchmann 1.1 std::cout << std::endl;
91     std::cout << "\033[1;34m dir (d)\033[0m\t Directory where all plots will be saved" << std::endl;
92     std::cout << "\033[1;34m public \033[0m\t Switch to be activated when using the algorithm in public (no branding etc.)" << std::endl;
93     std::cout << std::endl;
94     std::cout << std::endl;
95     std::cout << "\033[1;34m met\033[0m \t\t Compute obs/pred for met cut vs jzb cut (in data, lm4 and lm8)" << std::endl;
96 buchmann 1.26 std::cout << "\033[1;34m metplots\033[0m \t\t Produce the MET plots (i.e. mll plots with MET cut etc.)" << std::endl;
97 buchmann 1.15 std::cout << "\033[1;34m metvsjzb\033[0m \t\t Produce MET:JZB plots" << std::endl;
98 buchmann 1.22 std::cout << "\033[1;34m aachen\033[0m \t\t Produce Aachen root file (please provide source root file)" << std::endl;
99 buchmann 1.1 std::cout << std::endl;
100     std::cout << std::endl;
101     std::cout << "\033[1;34m paper\033[0m \t\t Switch paper mode on (no \" Preliminary \" on plots)" << std::endl;
102 buchmann 1.15 std::cout << "\033[1;34m approved\033[0m \t\t Only approved plots" << std::endl;
103 buchmann 1.1 exit(-1);
104     }
105    
106     int main (int argc, char ** argv)
107     {
108     int do_all = false;/// DONE
109     int do_peak_finding = false; /// DONE
110     int do_kinematic_variables = false; ///DONE
111     int do_kinematic_PF_variables = false; ///DONE
112     int do_region_comparison = false; /// Comparison between signal and control regions
113     int do_lepton_comparison = false; ///DONE
114     int do_jzb_plots = false; /// DONE
115     int do_pred = false; /// DONE
116     bool overlay_signal = false; /// Overlay LM4 signal to predictions
117     int do_ratio = false; /// DONE ------------------------------------------- still need to adapt the legend!
118     int do_signal_bg_comparison_plot = false; /// DONE
119     int do_ttbar_comparison = false; /// DONE
120     int do_jzb_efficiency_curve = false; /// DONE
121     int do_zjets_comparison = false; /// DONE
122 buchmann 1.7 int do_diboson_plots = false;
123 buchmann 1.1 // int calculate_pred_and_observed = false; /// DONE -- now rerouted to the new way of computing results
124     // int calculate_yields = false; ///DONE /// superfluous (replaced by get_new_results)
125     int get_new_results = false; ///DONE
126     bool dopoisson = false;//should we calculate stat err with poisson? ///DONE
127     bool verbose = false;//prints out a lot more information ... ///DONE
128     //--------------------------------------------
129     // Systematics and limits
130     int do_compute_systematics=false; /// DONE (might want to add something related to the peak?)
131     bool requireZ=true; // should we require a Z for MC efficiency?
132     int do_compute_efficiency=false; /// DONE (might want to add something related to the peak?)
133     int do_prepare_limits_using_shapes=false; /// ALMOST DONE **************************************
134     int do_compute_upper_limits_from_counting_experiment=false; /// DONE
135     bool doobserved=false; // want to get the observed limit as well?
136     int doquick=1; // this will cause the number of predicted/observed events to hurry up (0 = do mc and all results, 1 = all results but no mc, 2 = don't save results in library and don't compute mc stuff)
137 buchmann 1.14 int do_compute_upper_limits_from_shapes=false;
138 buchmann 1.1
139     //--------------------------------------------
140     // More not-so-standard stuff
141     int do_model_scan=false; // this can take days - use the grid version!
142     int do_zjet_ttbar_shapes=false; /// DONE
143     int do_test=false;/// DONE (just any test you wish)
144     int do_pick_up_events=false; ///DONE
145    
146     //--------------------------------------------
147     // To be run manually !
148     int do_response_correction=false; ///DONE
149     //use this to find out the correction factor; originally this was done automatically but now you should do this separately and update Modules/Setup.C
150    
151     int do_sideband_assessment=false;
152 buchmann 1.2 int do_qcd=false;
153 buchmann 1.1
154     int do_save_template=false;
155     int do_mc_yields=false; // compute MC yields
156     int do_metjzb=false;
157    
158     int savepdf=true;
159     int saveC=true;
160     int saveRoot=true;
161     int savepng=true;
162     int saveeps=false;
163    
164 buchmann 1.3 int dooffpeak=true;
165 buchmann 1.1 int doonpeak=false;
166 buchmann 1.16 int dobtag=false;
167 buchmann 1.1
168     int do_JES=false;
169 buchmann 1.2 int do_ptsanity=false;
170 buchmann 1.3 int do_mlls=false;
171 buchmann 1.18 int do_edge=false;
172 buchmann 1.5 int do_met_vs_jzb=false;
173 buchmann 1.21 int do_aachen=false;
174 buchmann 1.26 int do_metplots=false;
175 buchmann 1.22 string AachenFileName="";
176 buchmann 1.1
177     std::string directory="";
178     int option_iterator;
179     int option_counter=0;
180     bool moreoptions=true;
181 buchmann 1.28
182     int SwitchOffSidebands=0;
183 buchmann 1.1
184     string jzbcuts_string="";
185    
186     while(moreoptions) {
187     static struct option long_options[] =
188     {
189     /* These options set a flag. */
190     {"all", no_argument, &do_all, 1},
191     {"peak", no_argument, &do_peak_finding, 1},
192     {"kin", no_argument, &do_kinematic_variables, 1},
193     {"pfkin", no_argument, &do_kinematic_PF_variables, 1},
194     {"region", no_argument, &do_region_comparison, 1},
195     {"lepton", no_argument, &do_lepton_comparison, 1},
196     {"jzb", no_argument, &do_jzb_plots, 1},
197     {"pred", no_argument, &do_pred, 1},
198     {"ratio", no_argument, &do_ratio, 1},
199     {"signalbg", no_argument, &do_signal_bg_comparison_plot, 1},
200     {"ttbar", no_argument, &do_ttbar_comparison, 1},
201     {"zjets", no_argument, &do_zjets_comparison, 1},
202 buchmann 1.7 {"diboson", no_argument, &do_diboson_plots, 1},
203 buchmann 1.1 {"results", no_argument, &get_new_results, 1},
204     {"syst", no_argument, &do_compute_systematics, 1},
205     {"eff", no_argument, &do_compute_efficiency, 1},
206     {"shapes", no_argument, &do_prepare_limits_using_shapes, 1},
207     {"counting", no_argument, &do_compute_upper_limits_from_counting_experiment, 1},
208 buchmann 1.14 {"shapelimit",no_argument, &do_compute_upper_limits_from_shapes, 1},
209 buchmann 1.2 {"ptsanity", no_argument, &do_ptsanity, 1},
210 buchmann 1.1 {"response", no_argument, &do_response_correction, 1},
211     {"pickup", no_argument, &do_pick_up_events, 1},
212     {"yields", no_argument, &do_mc_yields, 1},
213     {"sideassess",no_argument, &do_sideband_assessment, 1},
214 buchmann 1.5 {"metvsjzb", no_argument, &do_met_vs_jzb, 1},
215 buchmann 1.2 {"qcd", no_argument, &do_qcd, 1},
216 buchmann 1.1 {"save", no_argument, &do_save_template,1},
217     {"png", no_argument, &savepng,1},
218     {"eps", no_argument, &saveeps,1},
219     {"pdf", no_argument, &savepdf,1},
220     {"root", no_argument, &saveRoot,1},
221     {"C", no_argument, &saveC,1},
222     {"offpeak", no_argument, &dooffpeak,1},
223     {"onpeak", no_argument, &doonpeak,1},
224 buchmann 1.16 {"btagged", no_argument, &dobtag,1},
225 buchmann 1.1 {"met", no_argument, &do_metjzb,1},
226     {"jes", no_argument, &do_JES,1},
227     {"effcurve", no_argument, &do_jzb_efficiency_curve,1},
228     {"public", no_argument, &PlottingSetup::publicmode,1},
229     {"paper", no_argument, &PlottingSetup::PaperMode,1},
230 buchmann 1.26 {"approved", no_argument, &PlottingSetup::Approved,1},
231 buchmann 1.28 {"nosidebands",no_argument, &SwitchOffSidebands,1},
232 buchmann 1.3 {"mlls", no_argument, &do_mlls,1},
233 buchmann 1.18 {"edge", no_argument, &do_edge,1},
234 buchmann 1.26 {"metplots", no_argument, &do_metplots,1},
235 buchmann 1.1 /* The following options store values.*/
236     {"jzbcuts", required_argument, 0, 'j'},
237     {"dir", required_argument, 0, 'd'},
238 buchmann 1.22 {"aachen", required_argument, 0, 'c'},
239 buchmann 1.1 {0, 0, 0, 0}
240     };
241     int option_index = 0;
242 buchmann 1.22 option_iterator = getopt_long(argc, argv, "abc:d:j:",long_options, &option_index);
243 buchmann 1.1 if(option_iterator == -1) moreoptions=false;
244     else {
245     option_counter++;
246     switch (option_iterator)
247     {
248     case 0:
249     if (long_options[option_index].flag != 0)
250     break;
251     printf ("option %s", long_options[option_index].name);
252     if (optarg)
253     printf (" with arg %s", optarg);
254     printf ("\n");
255     break;
256     case 'a':
257     do_all=true;
258     break;
259 buchmann 1.16 case 'b':
260     dobtag=true;
261     break;
262 buchmann 1.22 case 'c':
263     do_aachen=true;
264     AachenFileName=(std::string)optarg;
265     cout << "Received file to convert to Aachen format: " << AachenFileName << endl;
266     break;
267 buchmann 1.1 case 'd':
268     directory=(std::string)optarg;
269     std::cout<<"Option directory was passed with argument " << optarg << std::endl;
270     break;
271     case 'j':
272     jzbcuts_string=(std::string)optarg;
273     std::cout<<"JZB cuts were manually defined:" << optarg << std::endl;
274     break;
275     case '?':
276     usage(option_iterator);
277     break;
278     default:
279     usage(option_iterator);
280     }
281     }
282     }
283    
284     if(directory!="") PlottingSetup::directoryname=directory;
285     if(dooffpeak) PlottingSetup::RestrictToMassPeak=false;
286     if(doonpeak) PlottingSetup::RestrictToMassPeak=true;
287 buchmann 1.16 if(dobtag) PlottingSetup::DoBTag=true;
288 buchmann 1.1 if(option_counter==0) usage();
289 buchmann 1.28 if(SwitchOffSidebands) PlottingSetup::UseSidebandsForcJZB=false;
290 buchmann 1.16
291 buchmann 1.1 ///----------------------------------- BELOW THIS LINE: NO MORE OPTIONS BUT ACTUAL FUNCTION CALLS! ---------------------------------------------------------
292     gROOT->SetStyle("Plain");
293     bool do_fat_line=false; // if you want to have HistLineWidth=1 and FuncWidth=1 as it was before instead of 2
294     setTDRStyle(do_fat_line);
295     gStyle->SetTextFont(42);
296     bool showList=true;
297     set_directory(directoryname);//Indicate the directory name where you'd like to save the output files in Setup.C
298     set_treename("events");//you can set the treename here to be used; options are "events" (for reco) for "PFevents" (for particle flow)
299     // define_samples(showList,allsamples);
300 buchmann 1.2 define_samples(showList,allsamples,signalsamples,scansample,raresample,systsamples,qcdsamples);
301 buchmann 1.1 setlumi(luminosity);
302     setessentialcut(essential);//this sets the essential cut; this one is used in the draw command so it is AUTOMATICALLY applied everywhere. IMPORTANT: Do NOT store weights here!
303     stringstream resultsummary;
304    
305 buchmann 1.11 write_analysis_type(PlottingSetup::RestrictToMassPeak,PlottingSetup::DoBTag);
306 buchmann 1.1 do_png(savepng);
307     do_pdf(savepdf);
308     do_eps(saveeps);
309     do_C(saveC);
310     do_root(saveRoot);
311    
312 fronga 1.30 switch_overunderflow(true);
313 buchmann 1.1
314     global_ratio_binning.push_back(0);
315     global_ratio_binning.push_back(5);
316     global_ratio_binning.push_back(10);
317     global_ratio_binning.push_back(20);
318     global_ratio_binning.push_back(50);
319     global_ratio_binning.push_back(100);
320 buchmann 1.22 global_ratio_binning.push_back(150);
321 buchmann 1.1 global_ratio_binning.push_back(200);
322 buchmann 1.21 global_ratio_binning.push_back(PlottingSetup::jzbHigh);
323 buchmann 1.1 //global_ratio_binning.push_back(500);
324    
325     //these are the JZB cuts defining our search regions
326     vector<float> jzb_cut; //starting where, please?
327     if(jzbcuts_string=="") {
328     jzb_cut.push_back(50);
329     // jzb_cut.push_back(75);
330 fronga 1.24 jzb_cut.push_back(80);
331 buchmann 1.1 jzb_cut.push_back(100);
332     // jzb_cut.push_back(125);
333     jzb_cut.push_back(150);
334     // jzb_cut.push_back(175);
335     jzb_cut.push_back(200);
336     // jzb_cut.push_back(225);
337     jzb_cut.push_back(250);
338     // jzb_cut.push_back(275);
339     // jzb_cut.push_back(300);
340     } else {
341     manually_set_jzb_cuts(jzb_cut,jzbcuts_string);
342     if(jzb_cut.size()==0) {
343     write_error(__FUNCTION__,"There are no jzb cuts!");
344     return -1;
345     }
346     }
347    
348     todo();
349 fronga 1.30
350     switch_overunderflow(false);
351 buchmann 1.2
352 buchmann 1.1 //**** part 1 : peak finding
353     float MCPeak=0,MCPeakError=0,DataPeak=0,DataPeakError=0,MCSigma=10,DataSigma=10;
354     method=Kostasmethod;//Kostasmethod;//dogaus3sigma;// options: dogaus,doKM,dogaus2sigma,dogaus3sigma
355 buchmann 1.19 stringstream datajzb;
356     stringstream mcjzb;
357 fronga 1.24
358 fronga 1.30 //write_warning(__FUNCTION__,"NOT DOING ANY PEAK FINDING ATM");
359     if(do_peak_finding||do_pick_up_events||PlottingSetup::Approved||do_mlls||do_edge||do_zjets_comparison||do_sideband_assessment||do_metjzb||do_zjet_ttbar_shapes||do_diboson_plots||do_region_comparison||do_jzb_plots||do_lepton_comparison||do_signal_bg_comparison_plot||do_pred||do_ratio||do_mc_yields||do_save_template||do_compute_upper_limits_from_counting_experiment||do_compute_upper_limits_from_shapes||do_compute_systematics||do_model_scan||do_prepare_limits_using_shapes||do_all||get_new_results||do_kinematic_variables||do_kinematic_PF_variables||do_aachen) find_peaks(MCPeak,MCPeakError, DataPeak, DataPeakError,resultsummary,true,datajzb,mcjzb);
360 buchmann 1.19
361     if(datajzb.str().size()<1) datajzb<<"("<<jzbvariabledata<<")";
362     if(mcjzb.str().size()<1) mcjzb<<"("<<jzbvariablemc<<")";
363 buchmann 1.1
364     dout << "With peak correction, we get : " << endl;
365     dout << " Data : " << datajzb.str() << endl;
366     dout << " MC : " << mcjzb.str() << endl;
367 fronga 1.30
368     switch_overunderflow(true);
369 buchmann 1.1
370     //**** part 2 : kinematic plots
371 buchmann 1.9 if(do_kinematic_variables||(do_all&&!PlottingSetup::Approved)) do_kinematic_plots(mcjzb.str(),datajzb.str());
372 buchmann 1.1 if(do_kinematic_PF_variables) do_kinematic_PF_plots(mcjzb.str(),datajzb.str());
373    
374     //**** part 3: Leptonic comparison (ee vs mm, eemm vs emu)
375 buchmann 1.9 if(do_lepton_comparison||(do_all&&!PlottingSetup::Approved)) lepton_comparison_plots();
376 buchmann 1.1
377    
378     //**** part 3b: comparison between control regions (SFZPJZBPOS,SFZPJZBNEG,...)
379 fronga 1.25 if (do_region_comparison||(do_all&&!PlottingSetup::Approved)) region_comparison_plots(mcjzb.str(),datajzb.str(),jzb_cut);
380 buchmann 1.1
381     //**** part 4: JZB plots (OSOF, OSSF)
382     if(do_jzb_plots||do_all) jzb_plots(mcjzb.str(),datajzb.str(),global_ratio_binning);
383    
384     //**** part 5 : Prediction plots
385     if(do_pred||do_all) do_prediction_plots(mcjzb.str(),datajzb.str(),DataSigma,MCSigma,overlay_signal);
386    
387     //**** part 6: Ratio plots
388 buchmann 1.9 if(do_ratio||(do_all&&!PlottingSetup::Approved)) do_ratio_plots(mcjzb.str(),datajzb.str(),global_ratio_binning);
389 buchmann 1.1
390     //**** part 7: Some systematics plots
391 buchmann 1.9 if(do_signal_bg_comparison_plot||(do_all&&!PlottingSetup::Approved)) signal_bg_comparison();
392     if(do_ttbar_comparison||(do_all&&!PlottingSetup::Approved)) ttbar_sidebands_comparison(mcjzb.str(),global_ratio_binning);
393 buchmann 1.13 if(do_zjets_comparison||(do_all&&!PlottingSetup::Approved)) zjets_prediction_comparison(mcjzb.str());
394 buchmann 1.7
395     if(do_diboson_plots) diboson_plots(mcjzb.str(),datajzb.str(),global_ratio_binning);
396 buchmann 1.1
397 fronga 1.24 if(do_JES||(do_all&&!PlottingSetup::Approved)) {
398     make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
399     make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
400     }
401 buchmann 1.1
402 buchmann 1.9 if (do_jzb_efficiency_curve) plot_jzb_sel_eff(mcjzb.str(),signalsamples,jzb_cut);
403 buchmann 1.1
404     //**** part 8: observed and predicted!
405     if(do_all||get_new_results) doquick=0;
406     if(do_save_template) doquick=2;
407 buchmann 1.18 if(do_edge&&doquick>1) doquick=1;//we need at least doquick=1 (i.e. with storage) for edge fitting
408    
409 fronga 1.25 if(do_all||do_save_template||do_edge||do_compute_upper_limits_from_counting_experiment||do_model_scan||get_new_results) {
410     get_result(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,jzb_cut,verbose,dopoisson,doquick);
411     // Also exclusive bins for low JZB
412     get_exclusive_result(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,0.,30.,verbose,dopoisson,doquick);
413     get_exclusive_result(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,30.,50.,verbose,dopoisson,doquick);
414     }
415    
416 buchmann 1.1
417     vector<float>jzb_shape_limit_bins;
418 buchmann 1.14 jzb_shape_limit_bins.push_back(50);
419     jzb_shape_limit_bins.push_back(65.05);
420     jzb_shape_limit_bins.push_back(73.4);
421     jzb_shape_limit_bins.push_back(88.7);
422     jzb_shape_limit_bins.push_back(115.25);
423 buchmann 1.12 jzb_shape_limit_bins.push_back(200);
424     // jzb_shape_limit_bins.push_back(250);
425 buchmann 1.1 if(do_prepare_limits_using_shapes) prepare_limits(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,jzb_shape_limit_bins);
426    
427 buchmann 1.18 if(do_edge) {
428     // write_info(__FUNCTION__,"Doing edge fit for data");
429 buchmann 1.21 // DoEdgeFit(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,jzb_cut,data,cutmass&&cutnJets);
430     write_info(__FUNCTION__,"Doing edge fit for MC");
431     DoEdgeFit(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,jzb_cut,mc,cutmass&&cutnJets);
432     // write_info(__FUNCTION__,"Doing edge fit for MC with signal");
433     // DoEdgeFit(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,jzb_cut,mcwithsignal,cutmass&&cutnJets);
434 buchmann 1.18 }
435    
436 buchmann 1.1 //------------------------ end of standard functions
437    
438     // if(calculate_yields||do_all) calculate_all_yields(mcjzb.str(),jzb_cut); // now outdated - get_results now replaces this.
439    
440    
441     vector<vector<float> > all_systematics;
442     vector<vector<float> > all_efficiency;
443    
444     if(do_compute_systematics||do_compute_upper_limits_from_counting_experiment||do_all) all_systematics=compute_systematics(mcjzb.str(),MCPeakError,alwaysflip,datajzb.str(),signalsamples,jzb_cut,requireZ);
445     // if(do_compute_efficiency) compute_efficiency(mcjzb.str(),allsamples, 50, -200, 300);
446     if(do_compute_efficiency) write_warning(__FUNCTION__,"efficiency computation deactivated");
447    
448     if(do_compute_upper_limits_from_counting_experiment||do_all) compute_upper_limits_from_counting_experiment(all_systematics,jzb_cut,mcjzb.str(),doobserved,alwaysflip);
449    
450     //------------------------ end of analysis parts - below: special applications
451    
452 buchmann 1.5 if(do_model_scan) scan_SUSY_parameter_space(mcjzb.str(),datajzb.str(),jzb_cut,requireZ,MCPeakError,DataPeakError);
453 buchmann 1.1
454     if(do_zjet_ttbar_shapes) draw_ttbar_and_zjets_shape(mcjzb.str(),datajzb.str());
455    
456     if(do_response_correction) {
457     find_correction_factors(jzbvariabledata,jzbvariablemc);
458     dout << "Please update Modules/Setup.C to reflect the following values (round them first ... )" <<endl;
459 buchmann 1.20 dout << "Corrected JZB variable definition " << endl;
460     cout << " Data: " << jzbvariabledata << endl;
461     cout << " MC: " << jzbvariablemc << endl;
462 buchmann 1.1 dout << endl;
463     dout << "If you're feeling lazy, copy & paste this : " << endl;
464     dout << " string jzbvariabledata=\""<<jzbvariabledata<<"\";"<<endl;
465     dout << " string jzbvariablemc=\"" <<jzbvariablemc<<"\";"<<endl;
466     }
467    
468     if(do_pick_up_events) {
469    
470 buchmann 1.21
471 buchmann 1.1 dout << "Observed: " << endl;
472 buchmann 1.21 pick_up_events((const char*)(cutmass&&cutOSSF&&cutnJets&&basiccut&&((string)"(("+datajzb.str()+")"+">100)").c_str()));
473 buchmann 1.1 dout << "Predicted (JZB<-100) OSSF" << endl;
474 buchmann 1.21 pick_up_events((const char*)(cutmass&&cutOSSF&&cutnJets&&basiccut&&((string)"(("+datajzb.str()+")"+"<-100)").c_str()));
475 buchmann 1.1 dout << "Predicted (emu, JZB>100) OSOF" << endl;
476 buchmann 1.21 pick_up_events((const char*)(cutmass&&cutOSOF&&cutnJets&&basiccut&&((string)"(("+datajzb.str()+")"+">100)").c_str()));
477 buchmann 1.1 dout << "Predicted (emu, JZB<-100) OSOF" << endl;
478 buchmann 1.21 pick_up_events((const char*)(cutmass&&cutOSOF&&cutnJets&&basiccut&&((string)"(("+datajzb.str()+")"+"<-100)").c_str()));
479 buchmann 1.1 dout << "Predicted (SB SF, JZB>100) OSSF" << endl;
480 buchmann 1.21 pick_up_events((const char*)(sidebandcut&&cutOSSF&&cutnJets&&basiccut&&((string)"(("+datajzb.str()+")"+">100)").c_str()));
481 buchmann 1.1 dout << "Predicted (SB SF, JZB<-100) OSSF" << endl;
482 buchmann 1.21 pick_up_events((const char*)(sidebandcut&&cutOSSF&&cutnJets&&basiccut&&((string)"(("+datajzb.str()+")"+"<-100)").c_str()));
483 buchmann 1.1 dout << "Predicted (SB emu, JZB>100) OSOF" << endl;
484 buchmann 1.21 pick_up_events((const char*)(sidebandcut&&cutOSOF&&cutnJets&&basiccut&&((string)"(("+datajzb.str()+")"+">100)").c_str()));
485 buchmann 1.1 dout << "Predicted (SB emu, JZB<-100) OSOF" << endl;
486 buchmann 1.21 pick_up_events((const char*)(cutOSOF&&cutnJets&&basiccut&&sidebandcut&&((string)"(("+datajzb.str()+")"+"<-100)").c_str()));
487 buchmann 1.1 }
488    
489 buchmann 1.14 if(do_save_template||do_compute_upper_limits_from_shapes) {
490 buchmann 1.17 // write_error(__FUNCTION__,"Currently commented out shape storage");
491 buchmann 1.16 save_template(mcjzb.str(),datajzb.str(),jzb_cut,MCPeakError,DataPeakError,jzb_shape_limit_bins);
492     PrepareDataShapes(mcjzb.str(), datajzb.str(), jzb_shape_limit_bins, DataPeakError);
493 buchmann 1.17 PrepareEdgeShapes(mcjzb.str(), datajzb.str(), jzb_shape_limit_bins, DataPeakError);
494 buchmann 1.6 }
495 buchmann 1.14
496     if(do_compute_upper_limits_from_shapes) compute_upper_limits_from_shapes(mcjzb.str(),datajzb.str(),jzb_cut,requireZ, MCPeakError, DataPeakError);
497 buchmann 1.1
498     if(do_sideband_assessment) sideband_assessment(datajzb.str(),30.0,50.0);
499    
500     if(do_mc_yields) compute_MC_yields(mcjzb.str(),jzb_cut);
501    
502     if(do_metjzb) met_jzb_cut(datajzb.str(),mcjzb.str(),jzb_cut);
503    
504 buchmann 1.2 if(do_qcd||do_all) qcd_plots(datajzb.str(),mcjzb.str(),jzb_cut);
505    
506 buchmann 1.3 if(do_mlls) do_mlls_plot(mcjzb.str());
507    
508 buchmann 1.2 if(do_ptsanity) check_ptsanity();
509 buchmann 1.3
510 buchmann 1.27 if(do_met_vs_jzb) met_vs_jzb_plots(datajzb.str(),mcjzb.str());
511 buchmann 1.21
512 buchmann 1.22 if(do_aachen) {
513     if(Contains(AachenFileName,"Data")) CastETHtoAachenNtuple(datajzb.str(),AachenFileName);
514     else CastETHtoAachenNtuple(mcjzb.str(),AachenFileName);
515     }
516 buchmann 1.21
517 buchmann 1.26 if(do_metplots) {
518     DoMetPlots();
519     }
520 buchmann 1.1 if(do_test) test();
521    
522     return 0;
523     }
524    
525