ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/various_studies.C
Revision: 1.10
Committed: Wed Mar 27 07:59:28 2013 UTC (12 years, 1 month ago) by buchmann
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +0 -22 lines
Log Message:
Removed picking up events (this is now in Selective_Plot_Generator)

File Contents

# User Rev Content
1 buchmann 1.1 #include <iostream>
2     #include <vector>
3     #include <sys/stat.h>
4 buchmann 1.2 #include <getopt.h>
5 buchmann 1.1 #include "Modules/GeneralToolBox.C"
6     #include "Modules/SampleClass.C"
7     #include "Modules/Setup.C"
8     #include "Modules/PeakFinder.C"
9     #include "Modules/Poisson_Calculator.C"
10 buchmann 1.9 #include "Modules/JSON/JSONSampleLoader.C"
11 buchmann 1.1 #include "Modules/setTDRStyle.C"
12     #include "Modules/ActiveSamples.C"
13     #include "Modules/UpperLimitsWithShape.C"
14     #include "Modules/Plotting_Functions.C" //also included for peak finding etc.
15     #include "Modules/LimitCalculation.C"
16     #include "Modules/ResultModule.C"
17 buchmann 1.5 #include "Modules/CrossSectionReader.C"
18     #include "Modules/Systematics.C"
19 buchmann 1.1 #include "Modules/ExperimentalModule.C"
20     #include "Modules/StudyModule.C" //also included for peak finding etc.
21    
22     #include <TCut.h>
23     #include <TROOT.h>
24     #include <TCanvas.h>
25     #include <TMath.h>
26     #include <TColor.h>
27     #include <TPaveText.h>
28     #include <TRandom.h>
29     #include <TH1.h>
30     #include <TH2.h>
31     #include <TF1.h>
32     #include <TSQLResult.h>
33    
34     #ifndef Verbosity
35     #define Verbosity 0
36     #endif
37     #ifndef HUSH
38     #define HUSH 1
39     #endif
40    
41     using namespace std;
42    
43     using namespace PlottingSetup;
44    
45 buchmann 1.2 void usage(int passed=0 ) {
46     std::cout << "USAGE : " << std::endl;
47     std::cout << "You can use different options when running this program : " << std::endl;
48     std::cout << std::endl;
49     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;
50 buchmann 1.5 std::cout << "\033[1;34m simUL\033[0m \t\t Simulate upper limits using pre-defined cuts (see do_simulate_upper_limits function)" << std::endl;
51 buchmann 1.2 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;
52     std::cout << "\033[1;34m offpeak\033[0m \t Sets offpeak to true (i.e. carry out off-peak analysis!)" << std::endl;
53     std::cout << "\033[1;34m onpeak\033[0m \t Sets onpeak to true (i.e. carry out standard on-peak analysis!)" << std::endl;
54     std::cout << std::endl;
55     std::cout << "\033[1;34m dir (d)\033[0m\t Directory where all plots will be saved" << std::endl;
56     std::cout << "\033[1;34m public \033[0m\t Switch to be activated when using the algorithm in public (no branding etc.)" << std::endl;
57     exit(-1);
58     }
59    
60     int main (int argc, char ** argv)
61 buchmann 1.1 {
62 buchmann 1.2 //what to do :
63     int do_all=false;/// DONE
64     int do_peak_finding=false; /// DONE
65     int study_sidebands=false; /// FOR REAL
66     int do_test=false;/// DONE (just any test you wish)
67     int do_jzb_correction=false; //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
68     int do_find_sideband_definition=false;
69     int do_ttbar_with_shapes=false;
70     int do_upper_limits=false;
71     int do_run_check=false;
72     int do_kinematic_dist_of_pred_and_obs=false;//former do_plot_list
73    
74     int do_show_dibosons=false;
75    
76     int do_show_rare_samples=false;
77    
78     int overlay_signal=false;
79    
80     int do_efficiency_scan_in_susy_space=false; /// NOW OUTSOURCED TO T3
81     bool requireZ=true;
82    
83     int do_beautiful_ratio_plots=false;
84    
85 buchmann 1.4 int do_jzb_negative_generator_study=false;
86     int do_generator_study_plots=true;
87     int do_LM4_SMS_comparison=false;
88 buchmann 1.5
89     int do_compare_offpeak_onpeak=false;
90    
91     vector<float> jzb_cut;
92     jzb_cut.push_back(50);
93     //jzb_cut.push_back(75);
94     // jzb_cut.push_back(100);
95     //jzb_cut.push_back(125);
96     // jzb_cut.push_back(150);
97     //jzb_cut.push_back(175);
98     // jzb_cut.push_back(200);
99     //jzb_cut.push_back(225);
100     // jzb_cut.push_back(250);
101     //jzb_cut.push_back(275);
102     //jzb_cut.push_back(300);
103 buchmann 1.2
104     //-------------------------------------------------------------------------------------------------------------//
105     int savepdf=true;
106     int saveC=true;
107     int saveRoot=true;
108     int savepng=true;
109     int saveeps=false;
110    
111 buchmann 1.5 int dooffpeak=true;
112 buchmann 1.2 int doonpeak=false;
113    
114     std::string directory="";
115     int option_iterator;
116     int option_counter=0;
117     bool moreoptions=true;
118 buchmann 1.5 int simulate_upper_limits=0;
119 buchmann 1.2 string jzbcuts_string="";
120    
121     while(moreoptions) {
122     static struct option long_options[] =
123     {
124     /* These options set a flag. */
125     {"all", no_argument, &do_all, 1},
126     {"peak", no_argument, &do_peak_finding, 1},
127     {"side", no_argument, &study_sidebands, 1},
128     {"test", no_argument, &do_test, 1},
129     {"corr", no_argument, &do_jzb_correction, 1},
130     {"limits", no_argument, &do_upper_limits, 1},
131     {"runcheck", no_argument, &do_run_check, 1},
132     {"kinpredobs",no_argument, &do_kinematic_dist_of_pred_and_obs, 1},
133     {"diboson", no_argument, &do_show_dibosons, 1},
134     {"rare", no_argument, &do_show_rare_samples, 1},
135     {"signaloverlay",no_argument, &do_show_rare_samples, 1},
136     {"ratioplus",no_argument, &do_beautiful_ratio_plots, 1},
137     {"jzbnegative",no_argument, &do_jzb_negative_generator_study, 1},
138 buchmann 1.5 {"simUL", no_argument, &simulate_upper_limits, 1},
139 buchmann 1.4 {"genplots", no_argument,&do_generator_study_plots,1},
140 buchmann 1.2 {"png", no_argument, &savepng,1},
141     {"eps", no_argument, &saveeps,1},
142     {"pdf", no_argument, &savepdf,1},
143     {"root", no_argument, &saveRoot,1},
144     {"C", no_argument, &saveC,1},
145     {"offpeak", no_argument, &dooffpeak,1},
146     {"onpeak", no_argument, &doonpeak,1},
147     {"public", no_argument, &PlottingSetup::publicmode,1},
148     {"paper", no_argument, &PlottingSetup::PaperMode,1},
149     /* The following options store values.*/
150     {"jzbcuts", required_argument, 0, 'j'},
151     {"dir", required_argument, 0, 'd'},
152     {0, 0, 0, 0}
153     };
154     int option_index = 0;
155     option_iterator = getopt_long(argc, argv, "ad:j:",long_options, &option_index);
156     if(option_iterator == -1) moreoptions=false;
157     else {
158     option_counter++;
159     switch (option_iterator)
160     {
161     case 0:
162     if (long_options[option_index].flag != 0)
163     break;
164     printf ("option %s", long_options[option_index].name);
165     if (optarg)
166     printf (" with arg %s", optarg);
167     printf ("\n");
168     break;
169     case 'a':
170     do_all=true;
171     break;
172     case 'd':
173     directory=(std::string)optarg;
174     std::cout<<"Option directory was passed with argument " << optarg << std::endl;
175     break;
176     case 'j':
177     jzbcuts_string=(std::string)optarg;
178     std::cout<<"JZB cuts were manually defined:" << optarg << std::endl;
179     break;
180     case '?':
181     usage(option_iterator);
182     break;
183     default:
184     usage(option_iterator);
185     }
186     }
187     }
188    
189     if(directory!="") PlottingSetup::directoryname=directory;
190     if(dooffpeak) PlottingSetup::RestrictToMassPeak=false;
191     if(doonpeak) PlottingSetup::RestrictToMassPeak=true;
192     if(option_counter==0) usage();
193    
194 buchmann 1.1 gROOT->SetStyle("Plain");
195     bool do_fat_line=false; // if you want to have HistLineWidth=1 and FuncWidth=1 as it was before instead of 2
196     setTDRStyle(do_fat_line);
197     gStyle->SetTextFont(42);
198 buchmann 1.2 bool showList=true;
199     set_directory(directoryname);//Indicate the directory name where you'd like to save the output files in Setup.C
200 buchmann 1.1 set_treename("events");//you can set the treename here to be used; options are "events" (for reco) for "PFevents" (for particle flow)
201 buchmann 1.8 define_samples(showList,allsamples,signalsamples,scansample,raresample,systsamples,qcdsamples,comparesamples);
202 buchmann 1.1 setlumi(luminosity);
203     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!
204     stringstream resultsummary;
205    
206 buchmann 1.6 write_analysis_type(PlottingSetup::RestrictToMassPeak,PlottingSetup::DoBTag);
207 buchmann 1.3 do_png(savepng);
208     do_pdf(savepdf);
209     do_eps(saveeps);
210     do_C(saveC);
211     do_root(saveRoot);
212    
213    
214    
215 buchmann 1.1
216 buchmann 1.2 //-------------------------------------------------------------------------------------------------------------//
217    
218 buchmann 1.1
219     //**** part 1 : peak finding
220     float MCPeak=0,MCPeakError=0,DataPeak=0,DataPeakError=0,MCSigma=10,DataSigma=10;
221     method=Kostasmethod;//Kostasmethod;//dogaus3sigma;// options: dogaus,doKM,dogaus2sigma,dogaus3sigma
222     stringstream datajzb;
223     stringstream mcjzb;
224 buchmann 1.7 //write_warning(__FUNCTION__,"NOT DOING ANY PEAK FINDING ATM");
225     if(do_peak_finding||do_show_dibosons||do_show_rare_samples||do_all) find_peaks(MCPeak,MCPeakError, DataPeak, DataPeakError,resultsummary,true,datajzb,mcjzb);
226    
227     if(datajzb.str().size()<1) datajzb<<"("<<jzbvariabledata<<")";
228     if(mcjzb.str().size()<1) mcjzb<<"("<<jzbvariablemc<<")";
229    
230 buchmann 1.1 dout << "With peak correction, we get : " << endl;
231     dout << " Data : " << datajzb.str() << endl;
232     dout << " MC : " << mcjzb.str() << endl;
233 buchmann 1.7
234    
235 buchmann 1.1
236     if(do_find_sideband_definition) find_sideband_definition();
237    
238     if(do_jzb_correction) {
239     find_correction_factors(jzbvariabledata,jzbvariablemc);
240     dout << "Please update Modules/Setup.C to reflect the following values (round them first ... )" <<endl;
241     dout << "Corrected JZB variable definition " << endl << " Data: " << jzbvariabledata << " and MC: " << jzbvariablemc << endl;
242     dout << endl;
243     dout << "If you're feeling lazy, copy & paste this : " << endl;
244     dout << " string jzbvariabledata=\""<<jzbvariabledata<<"\";"<<endl;
245     dout << " string jzbvariablemc=\"" <<jzbvariablemc<<"\";"<<endl;
246     }
247    
248     if(study_sidebands) look_at_sidebands(mcjzb.str(),datajzb.str());
249    
250     vector<float>jzb_limit_bins;
251     jzb_limit_bins.push_back(50);
252     //jzb_limit_bins.push_back(75);jzb_limit_bins.push_back(100);
253     //jzb_limit_bins.push_back(150);jzb_limit_bins.push_back(200);jzb_limit_bins.push_back(500);
254    
255    
256     if(do_ttbar_with_shapes) prepare_ttbar_limits(mcjzb.str(),datajzb.str(),DataPeakError,MCPeakError,jzb_limit_bins);
257    
258     if(do_upper_limits) calculate_upper_limits(mcjzb.str(),datajzb.str());
259    
260     if(do_run_check) run_check();
261     if(do_show_dibosons) show_dibosons(datajzb.str(),mcjzb.str());
262     if(do_show_rare_samples) show_rare_samples(datajzb.str(),mcjzb.str());
263    
264     if(do_kinematic_dist_of_pred_and_obs) kinematic_dist_of_pred_and_obs();
265    
266     if(do_test) test();
267    
268     vector<float> ratio_binning;
269     ratio_binning.push_back(0);
270     ratio_binning.push_back(5);
271     ratio_binning.push_back(10);
272     ratio_binning.push_back(20);
273     ratio_binning.push_back(50);
274     ratio_binning.push_back(100);
275     ratio_binning.push_back(200);
276     ratio_binning.push_back(350);
277     //ratio_binning.push_back(500);
278     if(do_beautiful_ratio_plots) Poisson_ratio_plots(mcjzb.str(),datajzb.str(),ratio_binning,MCPeakError,DataPeakError);
279    
280 buchmann 1.2
281     if(do_jzb_negative_generator_study) jzb_negative_generator_study();
282 buchmann 1.4 if(do_generator_study_plots) generator_study_plots();
283    
284    
285     if(do_LM4_SMS_comparison) compare_LM4_and_SMS();
286 buchmann 1.5 // write_warning(__FUNCTION__,"Need to remove the next line:");
287 buchmann 1.1 // do_new_prediction_plots(mcjzb.str(),datajzb.str(),DataSigma,MCSigma,overlay_signal);
288    
289     // ttbar_sidebands_comparison(mcjzb.str());
290    
291 buchmann 1.2 // lm0_illustration();
292 buchmann 1.5
293     if(simulate_upper_limits) do_simulate_upper_limits(mcjzb.str(),datajzb.str(),MCPeakError,jzb_cut);
294     if(do_compare_offpeak_onpeak) compare_onpeak_offpeak_signal_distributions(mcjzb.str(),datajzb.str());
295    
296 buchmann 1.1 return 0;
297     }
298    
299