ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Selective_Plot_Generator.C
Revision: 1.40
Committed: Mon Feb 18 18:53:34 2013 UTC (12 years, 2 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.39: +19 -2 lines
Log Message:
Added possibility to get a list of all events for our MET selection and that of Aachen

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