ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/DistributedModelCalculations/ShapeLimits/Utilities/ReadLimitsAndPrepareJobs.C
Revision: 1.1
Committed: Wed Apr 18 14:05:20 2012 UTC (13 years ago) by buchmann
Content type: text/plain
Branch: MAIN
Log Message:
Added first limit shape scripts for testing purposes

File Contents

# User Rev Content
1 buchmann 1.1 #include <iostream>
2     #include <fstream>
3    
4     #include "TKey.h"
5     #include "TFile.h"
6     #include "TH1.h"
7     #include "TH2.h"
8    
9    
10    
11     #include "../../../Plotting/Modules/GeneralToolBox.C"
12     #include "../../../Plotting/Modules/SampleClass.C"
13     #include "../../../Plotting/Modules/Setup.C"
14     #include "../../../Plotting/Modules/PeakFinder.C"
15     #include "../../../Plotting/Modules/Poisson_Calculator.C"
16     #include "../../../Plotting/Modules/setTDRStyle.C"
17     #include "../../../Plotting/Modules/ActiveSamples.C"
18     #include "../../../Plotting/Modules/UpperLimitsWithShape.C"
19     #include "../../../Plotting/Modules/Plotting_Functions.C"
20     #include "../../../Plotting/Modules/LimitCalculation.C"
21     #include "../../../Plotting/Modules/ResultModule.C"
22     #include "../../../Plotting/Modules/CrossSectionReader.C"
23     #include "../../../Plotting/Modules/Systematics.C"
24     #include "../../../Plotting/Modules/SUSYScan.C"
25     #include "../../../Plotting/Modules/SugarCoating.C"
26     #include "../../../Plotting/Modules/ExclusionPlot.C"
27    
28    
29     using namespace std;
30    
31     ofstream myfile;
32     string massgluname;
33     string massLSPname;
34    
35     void run_this_job(int scantype,float x, float y, float min, float max) {
36     cout << "Running a job ... (x=" << x << " , y=" << y << ")" << endl;
37     stringstream Config;
38     Config << massgluname << "_" << x << "__" << massLSPname << "_" << y << ";" << min << ";" << max ;
39     cout << " Config: " << Config.str() << endl;
40     myfile << Config.str() << ";\n";
41     }
42    
43    
44     void compute_jobs(vector<TH2F*> histos, int scantype) {
45     for(int i=0;i<histos.size();i++) {
46     cout << "Remaining histos: i=" << i << " : " << histos[i]->GetName() << endl;
47     }
48    
49     TH2F *hstrength;
50     hstrength= (TH2F*)histos[0]->Clone("hstrength");
51     if(scantype!=PlottingSetup::mSUGRA) {
52     xsecfilename=PlottingSetup::cbafbasedir+"/"+PlottingSetup::SMSReferenceXSFile;
53     TFile *xsecfile = new TFile(xsecfilename.c_str());
54     if(xsecfile->IsZombie()&&(scantype!=PlottingSetup::mSUGRA)) {
55     write_error(__FUNCTION__,"Cross section file is invalid!!!!");
56     return;
57     }
58     xsecfile->Close();
59     hstrength->Scale(1./0.19); // because for T5zz we forced one z to decay leptonically
60     TH2F *xsec = adjust_histo(get_XS(xsecfilename,"gluino",histos[0]),histos[0]);
61     hstrength->Divide(xsec);
62     }
63    
64    
65     for(int i=1;i<=histos[0]->GetNbinsX();i++) {
66     for(int j=1;j<=histos[0]->GetNbinsX();j++) {
67     float strength=hstrength->GetBinContent(i,j);
68     float limit=histos[0]->GetBinContent(i,j);
69     if(scantype==PlottingSetup::mSUGRA) limit=histos[1]->GetBinContent(i,j);
70     if(strength>0.8&&strength<1.2) run_this_job(scantype,histos[0]->GetXaxis()->GetBinCenter(i),histos[0]->GetYaxis()->GetBinCenter(j),0.5*limit,2*limit);
71     }
72     }
73     return;
74     }
75    
76     int main(int nargs, char** args) {
77     cout << nargs << " arguments were given " << endl;
78     if(nargs<2||nargs>2) {
79     cout << "You're supposed to provide one argument only: The file containing all limits!!" << endl;
80     return -1;
81     }
82     myfile.open("JobStrings.txt");
83    
84     gROOT->SetStyle("Plain");
85     setTDRStyle();
86     gStyle->SetTextFont(42);
87     bool showList=false;
88     set_directory(PlottingSetup::directoryname);
89     set_treename("events");//you can set the treename here to be used; options are "events" (for reco) for "PFevents" (for particle flow)
90     define_SMS_sample(showList,allsamples,signalsamples,scansample);
91     setlumi(luminosity);
92    
93    
94     string filename = args[1];
95     cout <<"You provided the argument \"" << filename << "\"" << endl;
96    
97     TFile *file = new TFile(filename.c_str());
98     TIter nextkey(file->GetListOfKeys());
99     TKey *key;
100    
101     int scantype=PlottingSetup::SMS;
102     std::string scanx = "0"; // Just for the legend
103     if (TString(file->GetName()).Contains("T5zzl")) scanx = "0.75";
104     else if(TString(file->GetName()).Contains("T5zzh")) scanx = "0.25";
105     else if(TString(file->GetName()).Contains("T5zz")) scanx = "0.5";
106    
107     vector<TH2F*> limits_histos;
108     while ((key = (TKey*)nextkey()))
109     {
110     TObject *obj = key->ReadObj();
111     if (!(obj->IsA()->InheritsFrom("TH2"))) continue;
112     TString name=(TString)(obj->GetName());
113     bool is_limit=false;
114    
115     if(name.Contains("_limitmap")) is_limit=true;
116     if(name.Contains("crosssectionmap")) is_limit=true;
117     if(name.Contains("XS")) is_limit=true;
118     if(name.Contains("absXS")) is_limit=true;
119     if(name.Contains("exclusionmap")) is_limit=true;
120     if(is_limit) limits_histos.push_back((TH2F*) obj);
121     if(name.Contains("mSUGRA")) scantype=PlottingSetup::mSUGRA;
122     if(name.Contains("GMSB")) scantype=PlottingSetup::GMSB;
123     }
124    
125     massgluname="MassGlu";
126     massLSPname="MassLSP";
127    
128     if(scantype==PlottingSetup::mSUGRA) {
129     massgluname="M0";
130     massLSPname="M12";
131     }
132    
133     if(scantype==GMSB) {
134     massgluname="MassGMSBGlu";
135     massLSPname="MassGMSBChi";
136     }
137    
138    
139    
140     if(scantype==PlottingSetup::mSUGRA) {
141     //mSUGRA case
142     vector<TH2F*> final_limit_histo;
143     bool do_all_points=false;
144     for(int i=0;i<limits_histos.size();i++) {
145     TString name=limits_histos[i]->GetName();
146     if(name.Contains("_exclusionmap")) final_limit_histo.push_back(limits_histos[i]);
147     }
148     for(int i=0;i<limits_histos.size();i++) {
149     TString name=limits_histos[i]->GetName();
150     if(name.Contains("_explimitmap")) final_limit_histo.push_back(limits_histos[i]);
151     }
152     compute_jobs(final_limit_histo,scantype);
153     } else {
154     //SMS case
155     vector<TH2F*> final_limit_histo;
156     bool do_all_points=false;
157     for(int i=0;i<limits_histos.size();i++) {
158     TString name=limits_histos[i]->GetName();
159     if(name.Contains("_limitmap")) final_limit_histo.push_back(limits_histos[i]);
160     }
161     for(int i=0;i<limits_histos.size();i++) {
162     TString name=limits_histos[i]->GetName();
163     if(name.Contains("_explimitmap")) final_limit_histo.push_back(limits_histos[i]);
164     }
165     compute_jobs(final_limit_histo,scantype);
166     }
167     myfile.close();
168     write_warning(__FUNCTION__,"Need to write from the file!");
169     return 0;
170     }