ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.54
Committed: Tue Nov 8 08:45:29 2011 UTC (13 years, 6 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.53: +2 -2 lines
Log Message:
Better detection of host for scans (plus safety check before deleting anything)

File Contents

# User Rev Content
1 buchmann 1.1 #include <iostream>
2     #include <vector>
3     #include <sys/stat.h>
4     #include <fstream>
5 buchmann 1.7 #include <pthread.h>
6 buchmann 1.51 #include <assert.h>
7 buchmann 1.1
8     #include <TCut.h>
9     #include <TROOT.h>
10     #include <TCanvas.h>
11     #include <TMath.h>
12     #include <TColor.h>
13     #include <TPaveText.h>
14     #include <TRandom.h>
15     #include <TH1.h>
16     #include <TH2.h>
17     #include <TF1.h>
18     #include <TSQLResult.h>
19     #include <TProfile.h>
20 buchmann 1.31 #include <TKey.h>
21 buchmann 1.1
22     //#include "TTbar_stuff.C"
23     using namespace std;
24    
25     using namespace PlottingSetup;
26    
27     void susy_scan_axis_labeling(TH2F *histo) {
28 buchmann 1.37 histo->GetXaxis()->SetTitle("m_{#Chi_{2}^{0}}-m_{LSP}");
29 buchmann 1.1 histo->GetXaxis()->CenterTitle();
30     histo->GetYaxis()->SetTitle("m_{#tilde{q}}");
31     histo->GetYaxis()->CenterTitle();
32     }
33    
34 buchmann 1.22 void prepare_scan_axis(TH2 *variablemap,bool ismSUGRA) {
35 buchmann 1.9 variablemap->GetXaxis()->SetTitle("m_{glu}");
36     variablemap->GetYaxis()->SetTitle("m_{LSP}");
37 buchmann 1.35
38 buchmann 1.22 if(ismSUGRA) {
39     variablemap->GetXaxis()->SetTitle("m_{0}");
40     variablemap->GetYaxis()->SetTitle("m_{1/2}");
41     }
42 buchmann 1.35
43 buchmann 1.9 variablemap->GetXaxis()->CenterTitle();
44     variablemap->GetYaxis()->CenterTitle();
45     }
46    
47 buchmann 1.31 void set_SUSY_style() {
48     Int_t MyPalette[100];
49     Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0};
50     Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0};
51     Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0};
52     Double_t stop[] = {0., .25, .50, .75, 1.0};
53     Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 110);
54     for (int i=0;i<100;i++) MyPalette[i] = FI+i;
55 buchmann 1.35
56 buchmann 1.31 gStyle->SetPalette(100, MyPalette);
57 buchmann 1.35
58 buchmann 1.31 float rightmargin=gStyle->GetPadRightMargin();
59     gStyle->SetPadRightMargin(0.15);
60    
61     }
62    
63 buchmann 1.53 bool delete_any_cached_scans() {
64 buchmann 1.50 //This should only be called via CRAB
65 buchmann 1.53 string completehostname=GetCompleteHostname();
66 buchmann 1.54 if((Contains(completehostname,"t3ui")||Contains(completehostname,"t3wn"))&&(Contains(completehostname,"psi.ch"))) return false;
67 buchmann 1.53 else {
68     vector<string> all_files;
69     char currentpath[1024];
70     TString directory=TString(getcwd(currentpath,1024));
71     directory=directory+"/";
72     process_directory(directory,all_files);
73     for(int ifile=0;ifile<all_files.size();ifile++)
74 buchmann 1.50 {
75     if(Contains(all_files[ifile],"_clean_splitup_")) {
76     dout << "About to delete " << all_files[ifile] << endl;
77     gSystem->Exec(((string)"rm "+all_files[ifile]).c_str());
78     }
79     }
80 buchmann 1.53 return true;
81     }
82 buchmann 1.50 }
83    
84     bool initialized_t2=false;
85    
86 buchmann 1.51 int srmcpretries=0;
87    
88 buchmann 1.50 void load_scan_sample(int a, int b, int &scanfileindex,bool ismSUGRA) {
89     dout << "Going to load file with Xzone=" << a << " and Yzone=" << b << endl;
90 buchmann 1.48 stringstream filetoload;
91 buchmann 1.50
92 buchmann 1.53 string completehostname=GetCompleteHostname();
93 buchmann 1.54 if((Contains(completehostname,"t3ui")||Contains(completehostname,"t3wn"))&&(Contains(completehostname,"psi.ch"))) { // local case
94 buchmann 1.50 filetoload << "/shome/buchmann/ntuples/";
95     if(ismSUGRA) filetoload << "mSUGRA/mSUGRA_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root";
96     else filetoload << "SMS_T5zzl/SMS_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root";
97     if(!Contains(((scansample.collection)[(scansample.collection).size()-1]).filename,"_"+any2string(a)+"_"+any2string(b))) {
98     dout << "The last sample is NOT the same one as the current one, possibly popping off last one and adding the new one." << endl;
99 buchmann 1.48 if((scansample.collection).size()>1) {
100     scansample.RemoveLastSample();
101     }
102     scanfileindex=(scansample.collection).size();
103     //New: Loading file when necessary, not before (avoiding high memory usage and startup times)
104     if(scanfileindex!=0) scansample.AddSample(filetoload.str(),"scansample",1,1,false,true,scanfileindex,kRed);
105 buchmann 1.50 } else {
106     dout << "Last sample is the same as the current one. Recycling it." << endl;
107     scanfileindex=(scansample.collection).size()-1;
108     }
109     } // end of t3 case
110     else {
111     write_info(__FUNCTION__,"Hello, CRAB! Might need to load files ...");
112     stringstream copyfile;
113 buchmann 1.52 copyfile << "lcg-cp -b -T srmv2 srm://storage01.lcg.cscs.ch:8443/srm/managerv2?SFN=/pnfs/lcg.cscs.ch/cms/trivcat/store/user/buchmann/bussola/";
114 buchmann 1.50 if(ismSUGRA) copyfile << "mSUGRA/mSUGRA_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root " << "mSUGRA_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root ";
115     else copyfile << "SMS/SMS_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root " << "SMS_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root ";
116     stringstream newfilename;
117     if(ismSUGRA) newfilename << "mSUGRA_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root";
118     else newfilename << "SMS_clean_splitup_" << any2string(a) << "_" << any2string(b) << ".root";
119    
120     if(!Contains(((scansample.collection)[(scansample.collection).size()-1]).filename,"_"+any2string(a)+"_"+any2string(b))||(a==0&&b==0)&&!initialized_t2) {
121     initialized_t2=true;
122     dout << "The last sample is NOT the same one as the current one, possibly popping off last one and downloading as well as adding the new one." << endl;
123     if((scansample.collection).size()>1) {
124     scansample.RemoveLastSample();
125     }
126     scanfileindex=(scansample.collection).size();
127     //New: Loading file when necessary, not before (avoiding high memory usage and startup times)
128     if(scanfileindex!=0) {
129     delete_any_cached_scans();
130     dout << "Going to download the scan file with the following copy command: " << copyfile.str() << endl;
131     gSystem->Exec(copyfile.str().c_str());
132 buchmann 1.51 if(doesROOTFileExist(newfilename.str())) {
133     scansample.AddSample(newfilename.str(),"scansample",1,1,false,true,scanfileindex,kRed);
134     } else {
135     srmcpretries++;
136     if(srmcpretries<5) {
137     dout << "The file could not be loaded correctly - retrying!" << endl;
138 buchmann 1.52 sleep(5);
139 buchmann 1.51 load_scan_sample(a,b,scanfileindex,ismSUGRA);
140     } else {
141     dout << "Have tried 5 times to load this sample. Giving up now and failing the program execution" << endl;
142     assert(0);
143     dout << "The command " << copyfile.str() << " failed to copy the file to the local storage (saving it as " << newfilename.str() << ")" << endl;
144     }
145     }
146 buchmann 1.50 }
147     } else {
148     dout << "Last sample is the same as the current one. Recycling it." << endl;
149 buchmann 1.48 scanfileindex=(scansample.collection).size()-1;
150 buchmann 1.50 }
151    
152 buchmann 1.48 }
153 buchmann 1.50 }
154 buchmann 1.48
155 buchmann 1.50 float get_xs(float &altxs, float mglu, float mlsp, string massgluname, string massLSPname, map < pair<float, float>, map<string, float> > &xsec, string mcjzb, bool requireZ) {
156     altxs=0;
157 buchmann 1.46 for(int iproc=1;iproc<=10;iproc++) {
158 buchmann 1.35 float process_xs = GetXSecForPointAndChannel(mglu,mlsp,xsec,iproc);
159 buchmann 1.49 altxs+=process_xs;
160 buchmann 1.46 }
161 buchmann 1.50 return altxs;
162 buchmann 1.35 }
163    
164 buchmann 1.31 void establish_SUSY_limits(string mcjzb,string datajzb,vector<float> jzb_cut,bool requireZ, float peakerror, TFile *fsyst, int ibin,float njobs=-1, float jobnumber=-1) {
165     bool runninglocally=true;
166     if(njobs>-1&&jobnumber>-1) {
167     runninglocally=false;
168     dout << "Running on the GRID (this is job " << jobnumber << "/" << njobs << ") for a jzb cut at " << jzb_cut[ibin] << endl;
169     } else {
170     dout << "Running locally " << endl;
171 buchmann 1.37 dout << "This will take a really, really long time - if you want to see the results within hours instead of weeks try running the worker script on the grid (DistributedModelCalculation/Limits/)" << endl;
172 buchmann 1.31 }
173 buchmann 1.35
174 buchmann 1.31 string massgluname="MassGlu";
175     string massLSPname="MassLSP";
176 buchmann 1.39 jzbSel=jzb_cut[ibin];
177     geqleq="geq";
178     automatized=true;
179     mcjzbexpression=mcjzb;
180    
181 buchmann 1.31 string prefix="SMS_";
182     // up to here, everything is set up for SMS; now we need to switch stuff around if we're dealing with an mSUGRA scan!
183     bool ismSUGRA=false;
184     TIter nextkey(fsyst->GetListOfKeys());
185     TKey *key;
186     while ((key = (TKey*)nextkey()))
187     {
188     TObject *obj = key->ReadObj();
189     if(Contains((string)(obj->GetName()),"mSUGRA")) ismSUGRA=true;
190     }
191 buchmann 1.35
192     map < pair<float, float>, map<string, float> > xsec;
193 buchmann 1.31
194     if(ismSUGRA) {
195     massgluname="M0"; // this is the "x axis" in the limit plot (like the gluino in the SMS case)
196     massLSPname="M12"; // this is the "y axis" in the limit plot (like the LSP in the SMS case)
197     mglustart=m0start;
198 buchmann 1.48 xsec=getXsec(PlottingSetup::cbafbasedir+"/Plotting/Modules/external/scale_xsection_nlo1.0_m0_m12_10_0_1v1.txt");
199 buchmann 1.31 mgluend=m0end;
200     mglustep=m0step;
201     mLSPstart=m12start;
202     mLSPend=m12end;
203     mLSPstep=m12step;
204     prefix="mSUGRA_";
205 buchmann 1.50 dout << "mSUGRA scan has been set up." << endl;
206 buchmann 1.31 } else {
207 buchmann 1.50 dout << "SMS scan has been set up." << endl;
208 buchmann 1.35 write_warning(__FUNCTION__,"Don't have the correct XS file yet");
209     xsec=getXsec("/scratch/buchmann/C/scale_xsection_nlo1.0_m0_m12_10_0_1v1.txt");
210 buchmann 1.31 }
211 buchmann 1.35
212 buchmann 1.31 set_SUSY_style();
213 buchmann 1.35
214 buchmann 1.31 TCanvas *limcanvas = new TCanvas("limcanvas","Limit canvas");
215 buchmann 1.35
216 buchmann 1.31 int Npoints=0;
217     for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
218 buchmann 1.44 for (int mlsp=mLSPstart;mlsp<=mLSPend&&(ismSUGRA||mlsp<=mglu);mlsp+=mLSPstep) Npoints++;
219 buchmann 1.31 }
220 buchmann 1.37 TH2F *mceff = (TH2F*)fsyst->Get((prefix+"efficiencymap"+any2string(jzb_cut[ibin])).c_str());
221     //write_warning(__FUNCTION__,"Currently the efficiencymap name was switched to Pablo's convention. This NEEDS to be switched BACK!");TH2F *mceff = (TH2F*)fsyst->Get(("efficiency_jzbdiff"+any2string(jzb_cut[ibin])).c_str());
222 buchmann 1.31 TH2F *fullerr = (TH2F*)fsyst->Get((prefix+"systotmap"+any2string(jzb_cut[ibin])).c_str());
223 buchmann 1.33 TH2F *NEvents = (TH2F*)fsyst->Get((prefix+"Neventsmap"+any2string(jzb_cut[ibin])).c_str());
224 buchmann 1.52 TH2F *lflip = (TH2F*)fsyst->Get((prefix+"flipmap"+any2string(jzb_cut[ibin])).c_str());
225 buchmann 1.35
226 buchmann 1.37 TH2F *limitmap = new TH2F((prefix+"limitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//observed limit
227     TH2F *explimitmap = new TH2F((prefix+"explimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit
228     TH2F *exp1plimitmap = new TH2F((prefix+"exp1plimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit + 1 sigma
229     TH2F *exp2plimitmap = new TH2F((prefix+"exp2plimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit + 2 sigma
230     TH2F *exp1mlimitmap = new TH2F((prefix+"exp1mlimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit - 1 sigma
231     TH2F *exp2mlimitmap = new TH2F((prefix+"exp2mlimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit - 2 sigma
232    
233 buchmann 1.32 TH2F *exclmap = new TH2F((prefix+"exclusionmap"+any2string(jzb_cut[ibin])).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
234     TH2F *xsmap = new TH2F((prefix+"crosssectionmap"+any2string(jzb_cut[ibin])).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
235 buchmann 1.49 TH2F *totxsmap = new TH2F((prefix+"absolutecrosssectionmap"+any2string(jzb_cut[ibin])).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
236 buchmann 1.52 TH2F *flipmap = new TH2F((prefix+"limitflipmap"+any2string(jzb_cut[ibin])).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
237    
238    
239 buchmann 1.35
240 buchmann 1.32 if(!fullerr || !mceff || !NEvents) {
241 buchmann 1.31 write_error(__FUNCTION__,"The supplied systematics file did not contain the correct histograms - please check the file");
242 buchmann 1.34 dout << "mc eff address: " << mceff << " , error address: " << fullerr << " , NEvents address: " << NEvents << endl;
243 buchmann 1.31 delete limcanvas;
244     return;
245     }
246 buchmann 1.37
247     bool doexpected=true;
248 buchmann 1.35
249 buchmann 1.31 int ipoint=-1;
250     for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
251 buchmann 1.44 for (int mlsp=mLSPstart;mlsp<=mLSPend&&(ismSUGRA||mlsp<=mglu);mlsp+=mLSPstep)
252 buchmann 1.31 {
253     ipoint++;
254     if(!runninglocally&&!do_this_point(ipoint,Npoints,jobnumber,njobs)) continue;
255     float currmceff=mceff->GetBinContent(mceff->FindBin(mglu,mlsp));
256 buchmann 1.33 float currtoterr=(fullerr->GetBinContent(fullerr->FindBin(mglu,mlsp)))*currmceff;
257 buchmann 1.32 float nevents=NEvents->GetBinContent(NEvents->FindBin(mglu,mlsp));
258 buchmann 1.52 int flipped = (lflip->GetBinContent(lflip->FindBin(mglu,mlsp)));
259     flipmap->Fill(mglu,mlsp,flipped);
260 buchmann 1.34 dout << "Looking at point " << ipoint << " / " << Npoints << " with masses " << massgluname << " = " << mglu << " and " << massLSPname << " = " << mlsp << endl;
261 buchmann 1.35 dout << "Found : MCeff=" << currmceff << " and total error=" << currtoterr << " and Nevents=" << nevents << endl;
262 buchmann 1.31 string plotfilename=(string)(TString(massgluname)+TString(any2string(mglu))+TString("__")+TString(massLSPname)+TString(any2string(mlsp))+TString(".png"));
263 buchmann 1.34 if(currmceff<=0||currtoterr<=0||nevents==0) {
264     dout << " Nothing to work with, skipping this point." << endl;
265     continue;
266     }
267 buchmann 1.31 vector<float> sigmas;
268 buchmann 1.52 sigmas=compute_one_upper_limit(currmceff,currtoterr,ibin,mcjzb,plotfilename,true, flipped);
269 buchmann 1.48
270    
271 buchmann 1.34 if(sigmas[0]>0) limitmap->Fill(mglu,mlsp,sigmas[0]); //anything else is an error code
272 buchmann 1.37 if(sigmas.size()>1) {
273     explimitmap->Fill(mglu,mlsp,sigmas[1]);
274     exp1plimitmap->Fill(mglu,mlsp,sigmas[2]);
275     exp1mlimitmap->Fill(mglu,mlsp,sigmas[3]);
276     exp2plimitmap->Fill(mglu,mlsp,sigmas[4]);
277     exp2mlimitmap->Fill(mglu,mlsp,sigmas[5]);
278     }
279    
280 buchmann 1.35 dout << "An upper limit has been added for this point ( " << massgluname << " = " << mglu << " and " << massLSPname << " = " << mlsp << " ) at " << sigmas[0] << endl;
281 buchmann 1.39 if(ismSUGRA) { // for SMS this is a bit easier at the moment - we have a reference XS file which we use when plotting
282 buchmann 1.35 dout << "Computing exclusion status" << endl;
283     float rel_limit=0;
284 buchmann 1.49 float totxs;
285     float xs=get_xs(totxs,mglu,mlsp,massgluname,massLSPname,xsec,mcjzb,requireZ);
286 buchmann 1.35 if(xs>0) rel_limit=sigmas[0]/xs;
287     exclmap->Fill(mglu,mlsp,rel_limit);
288     xsmap->Fill(mglu,mlsp,xs);
289 buchmann 1.49 totxsmap->Fill(mglu,mlsp,totxs);
290 buchmann 1.32 }
291 buchmann 1.31 }
292     }
293 buchmann 1.35
294 buchmann 1.31 prepare_scan_axis(limitmap,ismSUGRA);
295 buchmann 1.32 TFile *outputfile=new TFile(("output/DistributedLimitsFromSystematics_job"+string(any2string(jobnumber))+"_of_"+string(any2string(njobs))+".root").c_str(),"UPDATE");//needs to be "UPDATE" as we can get to this point for different JZB cuts and don't want to erase the previous data :-)
296     outputfile->cd();
297 buchmann 1.31 limitmap->Write();
298 buchmann 1.52 flipmap->Write();
299 buchmann 1.37 if(doexpected) {
300     explimitmap->Write();
301     exp1plimitmap->Write();
302     exp1mlimitmap->Write();
303     exp2plimitmap->Write();
304     exp2mlimitmap->Write();
305     }
306 buchmann 1.32 if(ismSUGRA) {
307     exclmap->Write();
308     xsmap->Write();
309 buchmann 1.49 totxsmap->Write();
310 buchmann 1.32 }
311     outputfile->Close();
312 buchmann 1.31 delete limcanvas;
313     }
314    
315     void establish_SUSY_limits(string mcjzb,string datajzb,vector<float> jzb_cut,bool requireZ, float peakerror, string fsystfilename, float njobs=-1, float jobnumber=-1) {
316     dout << "Starting the SUSY scan from systematics file now with all " << jzb_cut.size() << " bin(s)" << " and using " << fsystfilename << endl;
317     TFile *fsyst = new TFile(fsystfilename.c_str());
318     if(!fsyst) {
319     write_error(__FUNCTION__,"You provided an invalid systematics file. Please change it ... ");
320     return;
321     }
322     for(int ibin=0;ibin<jzb_cut.size();ibin++) {
323     establish_SUSY_limits(mcjzb,datajzb,jzb_cut,requireZ, peakerror, fsyst, ibin,njobs, jobnumber);
324     }
325     }
326    
327    
328    
329    
330 buchmann 1.13 void scan_SUSY_parameter_space(string mcjzb,string datajzb,vector<float> jzb_cut,bool requireZ, float peakerror, int ibin,float njobs=-1, float jobnumber=-1, bool systematicsonly=false,bool efficiencyonly=false) {
331 buchmann 1.6 bool runninglocally=true;
332     if(njobs>-1&&jobnumber>-1) {
333     runninglocally=false;
334 buchmann 1.13 dout << "Running on the GRID (this is job " << jobnumber << "/" << njobs << ") for a jzb cut at " << jzb_cut[ibin] << endl;
335 buchmann 1.6 } else {
336 buchmann 1.7 dout << "Running locally " << endl;
337 buchmann 1.40 dout << "This will take a really, really long time - if you want to see the results THIS month try running the LimitWorkerScript on the grid (DistributedModelCalculation/Limits/)" << endl;
338 buchmann 1.6 }
339 buchmann 1.35
340 buchmann 1.4 jzbSel=jzb_cut[ibin];
341     geqleq="geq";
342     automatized=true;
343     mcjzbexpression=mcjzb;
344 buchmann 1.35
345 buchmann 1.4 string massgluname="MassGlu";
346     string massLSPname="MassLSP";
347 buchmann 1.35
348 buchmann 1.23 string prefix="SMS_";
349 buchmann 1.22 // up to here, everything is set up for SMS; now we need to switch stuff around if we're dealing with an mSUGRA scan!
350     bool ismSUGRA=false;
351 buchmann 1.24 if(Contains((scansample.collection)[0].samplename,"mSUGRA")) ismSUGRA=true;
352 buchmann 1.22 if(ismSUGRA) {
353     massgluname="M0"; // this is the "x axis" in the limit plot (like the gluino in the SMS case)
354     massLSPname="M12"; // this is the "y axis" in the limit plot (like the LSP in the SMS case)
355     mglustart=m0start;
356     mgluend=m0end;
357     mglustep=m0step;
358     mLSPstart=m12start;
359     mLSPend=m12end;
360     mLSPstep=m12step;
361 buchmann 1.23 prefix="mSUGRA_";
362 buchmann 1.50 dout << "mSUGRA scan has been set up." << endl;
363 buchmann 1.24 } else {
364 buchmann 1.50 dout << "SMS scan has been set up." << endl;
365 buchmann 1.24 }
366 buchmann 1.35
367 buchmann 1.4 Int_t MyPalette[100];
368     Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0};
369     Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0};
370     Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0};
371     Double_t stop[] = {0., .25, .50, .75, 1.0};
372     Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 110);
373     for (int i=0;i<100;i++) MyPalette[i] = FI+i;
374 buchmann 1.35
375 buchmann 1.4 gStyle->SetPalette(100, MyPalette);
376 buchmann 1.35
377 buchmann 1.37 TH2F *limitmap = new TH2F((prefix+"limitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//observed limit
378     TH2F *explimitmap = new TH2F((prefix+"explimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit
379     TH2F *exp1plimitmap = new TH2F((prefix+"exp1plimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit + 1 sigma
380     TH2F *exp2plimitmap = new TH2F((prefix+"exp2plimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit + 2 sigma
381     TH2F *exp1mlimitmap = new TH2F((prefix+"exp1mlimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit - 1 sigma
382     TH2F *exp2mlimitmap = new TH2F((prefix+"exp2mlimitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);//expected limit - 2 sigma
383    
384     TH2F *exclmap = new TH2F((prefix+"exclusionmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
385     TH2F *sysjesmap = new TH2F((prefix+"sysjes"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
386     TH2F *sysjsumap = new TH2F((prefix+"sysjsu"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
387     TH2F *sysresmap = new TH2F((prefix+"sysresmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
388     TH2F *efficiencymap = new TH2F((prefix+"efficiencymap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
389 buchmann 1.47 TH2F *efficiencymapAcc = new TH2F((prefix+"efficiencymapAcc"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
390     TH2F *efficiencymapID = new TH2F((prefix+"efficiencymapID"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
391     TH2F *efficiencymapJets = new TH2F((prefix+"efficiencymapJets"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
392     TH2F *efficiencymapSignal = new TH2F((prefix+"efficiencymapSignal"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
393     TH2F *noscefficiencymap = new TH2F((prefix+"noscefficiencymap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
394 buchmann 1.37 TH2F *Neventsmap = new TH2F((prefix+"Neventsmap"+any2string(jzbSel)).c_str(),"", (mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
395 buchmann 1.38 TH2F *ipointmap = new TH2F((prefix+"ipointmap"+any2string(jzbSel)).c_str(),"", (mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
396 buchmann 1.37 TH2F *syspdfmap = new TH2F((prefix+"syspdfmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
397     TH2F *systotmap = new TH2F((prefix+"systotmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
398     TH2F *sysstatmap = new TH2F((prefix+"sysstatmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
399 buchmann 1.27
400 buchmann 1.37 TH2F *timemap = new TH2F((prefix+"timemap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
401 buchmann 1.36
402 buchmann 1.52 TH2F *flipmap = new TH2F((prefix+"flipmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
403    
404 buchmann 1.29 write_warning(__FUNCTION__,"CURRENTLY SWITCHING AUTOMATIZED MODE OFF!");automatized=false;
405 buchmann 1.35
406 buchmann 1.4 float rightmargin=gStyle->GetPadRightMargin();
407     gStyle->SetPadRightMargin(0.15);
408 buchmann 1.35
409 buchmann 1.4 TCanvas *limcanvas = new TCanvas("limcanvas","Limit canvas");
410 buchmann 1.35
411 buchmann 1.37
412     bool doexpected=true;
413    
414 buchmann 1.6 int Npoints=0;
415     for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
416 buchmann 1.44 for (int mlsp=mLSPstart;mlsp<=mLSPend&&(ismSUGRA||mlsp<=mglu);mlsp+=mLSPstep) Npoints++;
417 buchmann 1.6 }
418 buchmann 1.35
419 buchmann 1.6 int ipoint=-1;
420 buchmann 1.4 for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
421 buchmann 1.44 for (int mlsp=mLSPstart;mlsp<=mLSPend&&(ismSUGRA||mlsp<=mglu);mlsp+=mLSPstep)
422 buchmann 1.4 {
423 buchmann 1.6 ipoint++;
424     if(!runninglocally&&!do_this_point(ipoint,Npoints,jobnumber,njobs)) continue;
425 buchmann 1.52 int flipped=0;
426 buchmann 1.19 float result=-987,resulterr=-987;
427 buchmann 1.50 float m0trees = PlottingSetup::mgluend;
428     float m12trees = PlottingSetup::mLSPend;
429 buchmann 1.42 int a = int((PlottingSetup::ScanXzones*mlsp)/(m12trees+1));
430     int b = int((PlottingSetup::ScanYzones*mglu)/(m0trees+1));
431 buchmann 1.50 int scanfileindex=PlottingSetup::ScanYzones*a+b;
432     load_scan_sample(a,b,scanfileindex,ismSUGRA);
433 buchmann 1.42
434 buchmann 1.36 clock_t start,finish;
435     start = clock(); // starting the clock to measure how long the computation takes!
436 buchmann 1.4 stringstream addcut;
437     addcut << "(TMath::Abs("<<massgluname<<"-"<<mglu<<")<5)&&(TMath::Abs("<<massLSPname<<"-"<<mlsp<<")<5)";
438 buchmann 1.40 (scansample.collection)[scanfileindex].events->Draw("eventNum",addcut.str().c_str(),"goff");
439     float nevents = (scansample.collection)[scanfileindex].events->GetSelectedRows();
440 buchmann 1.4 vector<vector<float> > systematics;
441 buchmann 1.30 if(nevents<10) {
442 buchmann 1.40 dout << "This point ("<<ipoint<<") with configuration ("<<massgluname<<"="<<mglu<<" , "<<massLSPname<<"="<<mlsp << ") does not contain enough events and will be skipped."<< endl;
443     continue;
444 buchmann 1.6 } else {
445 buchmann 1.48 dout << "OK! This point ("<<ipoint<<") with configuration ("<<massgluname<<"="<<mglu<<" , "<<massLSPname<<"="<<mlsp << ") contains " << nevents << " and will therefore not be skipped. " << endl;
446     write_analysis_type(PlottingSetup::RestrictToMassPeak);
447 buchmann 1.22 }
448 buchmann 1.50 if(nevents!=0&&(efficiencyonly||systematicsonly)) {
449 buchmann 1.52 Value effwosigcont = MCefficiency((scansample.collection)[scanfileindex].events,result,resulterr,flipped,mcjzb,requireZ,nevents,addcut.str(),-1);
450     if(result<0) {
451     write_info(__FUNCTION__,"Found negative efficiency (signal distribution populating JZB<0 more than JZB>0) - flipping analysis!");
452     flipped=1;
453     MCefficiency((scansample.collection)[scanfileindex].events,result,resulterr,flipped,mcjzb,requireZ,nevents,addcut.str(),-1);
454     }
455 buchmann 1.36 efficiencymap->Fill(mglu,mlsp,result);
456 buchmann 1.47 efficiencymap->SetBinError(mglu,mlsp,resulterr);
457 buchmann 1.52 flipmap->Fill(mglu,mlsp,flipped);
458 buchmann 1.37 noscefficiencymap->Fill(mglu,mlsp,effwosigcont.getValue());
459     noscefficiencymap->SetBinError(mglu,mlsp,effwosigcont.getError());
460 buchmann 1.47 //Partial efficiencies
461     float resultAcc, resultID, resultJets, resultSignal;
462     float resulterrAcc, resulterrID, resulterrJets, resulterrSignal;
463 buchmann 1.52 MCPartialefficiency((scansample.collection)[scanfileindex].events,resultAcc,resulterrAcc,flipped,mcjzb,requireZ,nevents,addcut.str(),-1, 1);
464     MCPartialefficiency((scansample.collection)[scanfileindex].events,resultID,resulterrID,flipped,mcjzb,requireZ,nevents,addcut.str(),-1, 2);
465     MCPartialefficiency((scansample.collection)[scanfileindex].events,resultJets,resulterrJets,flipped,mcjzb,requireZ,nevents,addcut.str(),-1, 3);
466     MCPartialefficiency((scansample.collection)[scanfileindex].events,resultSignal,resulterrSignal,flipped,mcjzb,requireZ,nevents,addcut.str(),-1, 4);
467 buchmann 1.47 efficiencymapAcc->Fill(mglu,mlsp,resultAcc);
468     efficiencymapAcc->SetBinError(mglu,mlsp,resulterrAcc);
469     efficiencymapID->Fill(mglu,mlsp,resultID);
470     efficiencymapAcc->SetBinError(mglu,mlsp,resulterrID);
471     efficiencymapJets->Fill(mglu,mlsp,resultJets);
472     efficiencymapAcc->SetBinError(mglu,mlsp,resulterrJets);
473     efficiencymapSignal->Fill(mglu, mlsp, resultSignal);
474     efficiencymapAcc->SetBinError(mglu,mlsp,resulterrSignal);
475 buchmann 1.36 finish = clock();
476 buchmann 1.13 }
477 buchmann 1.17 Neventsmap->Fill(mglu,mlsp,nevents);
478 buchmann 1.24 ipointmap->Fill(mglu,mlsp,ipoint);
479 buchmann 1.17 if(efficiencyonly) continue;
480    
481 buchmann 1.52 do_systematics_for_one_file((scansample.collection)[scanfileindex].events,nevents,"SUSY SCAN", systematics,flipped, mcjzb,datajzb,peakerror,requireZ, addcut.str(),true);//mSUGRA is now always true here because we always want to compute PDF systematics
482 buchmann 1.9 float JZBcutat = systematics[0][0];
483     float mceff = systematics[0][1];
484 buchmann 1.22 float mcefferr = systematics[0][2];//MC stat error
485 buchmann 1.9 float toterr = systematics[0][4];
486     float sys_jes = systematics[0][5]; // Jet Energy Scale
487     float sys_jsu = systematics[0][6]; // JZB scale uncertainty
488     float sys_res = systematics[0][7]; // resolution
489 buchmann 1.37 float mcwoscef = systematics[0][8]; // efficiency without signal contamination
490     float mcwoscefr= systematics[0][9]; // error on efficiency without signal contamination
491 buchmann 1.27 float sys_pdf = 0;
492 buchmann 1.37 if(systematics[0].size()>10) sys_pdf = systematics[0][10]; // PDF
493 buchmann 1.52 // efficiencymap->Fill(mglu,mlsp,mceff);
494     // efficiencymap->SetBinError(efficiencymap->FindBin(mglu,mlsp),mcefferr);
495 buchmann 1.37 noscefficiencymap->Fill(mglu,mlsp,mcwoscef);
496     noscefficiencymap->SetBinError(efficiencymap->FindBin(mglu,mlsp),mcwoscefr);
497 buchmann 1.35
498 buchmann 1.47 if(mceff!=mceff||toterr!=toterr||mceff<0 && (!systematicsonly&&!efficiencyonly)) {
499 buchmann 1.35 dout << "Limits can't be calculated for this configuration (mglu="<<mglu<<" , mlsp="<<mlsp << ") as either the efficiency or its error are not positive numbers! (mceff="<<mceff<<" and toterr="<<toterr<<")"<< endl;
500     continue;
501 buchmann 1.5 } else {
502 buchmann 1.35 if(!systematicsonly&&!efficiencyonly) {
503     dout << "Calculating limit now for "<<massgluname<<"="<<mglu<<" , "<<massLSPname<<"="<<mlsp <<endl;
504     vector<float> sigmas;
505 buchmann 1.40 string plotfilename=(string)(TString((scansample.collection)[scanfileindex].samplename)+TString(massgluname)+TString(any2string(mglu))+TString("__")+TString(massLSPname)+TString(any2string(mlsp))+TString(".png"));
506 buchmann 1.52 sigmas=compute_one_upper_limit(mceff,toterr,ibin,mcjzb,plotfilename,true,flipped);
507 buchmann 1.46 // do_limit_wrapper(mceff,toterr,ibin,mcjzb,sigmas,plotfilename);
508 buchmann 1.50 dout << "back in " << __FUNCTION__ << endl;
509 buchmann 1.35 if(sigmas[0]>-0.5) { // negative sigmas are the error signature of do_limit_wrapper, so we want to exclude them.
510     limitmap->Fill(mglu,mlsp,sigmas[0]);
511 buchmann 1.37 if(sigmas.size()>1) {
512     explimitmap->Fill(mglu,mlsp,sigmas[1]);
513     exp1plimitmap->Fill(mglu,mlsp,sigmas[2]);
514     exp1mlimitmap->Fill(mglu,mlsp,sigmas[3]);
515     exp2plimitmap->Fill(mglu,mlsp,sigmas[4]);
516     exp2mlimitmap->Fill(mglu,mlsp,sigmas[5]);
517 buchmann 1.38 }
518 buchmann 1.37
519 buchmann 1.35 sysjesmap->Fill(mglu,mlsp,sys_jes);
520     sysjsumap->Fill(mglu,mlsp,sys_jsu);
521     sysresmap->Fill(mglu,mlsp,sys_res);
522     syspdfmap->Fill(mglu,mlsp,sys_pdf);
523     systotmap->Fill(mglu,mlsp,toterr/mceff);//total relative (!) error
524     sysstatmap->Fill(mglu,mlsp,mcefferr);//total relative (!) error
525     dout << "A limit has been added at " << sigmas[0] << " for m_{glu}="<<mglu << " and m_{lsp}="<<mlsp<<endl;
526     } //end of if sigma is positive
527 buchmann 1.36
528 buchmann 1.35 //end of not systematics only condition
529     }
530     if(systematicsonly) {
531     sysjesmap->Fill(mglu,mlsp,sys_jes);
532     sysjsumap->Fill(mglu,mlsp,sys_jsu);
533     sysresmap->Fill(mglu,mlsp,sys_res);
534     syspdfmap->Fill(mglu,mlsp,sys_pdf);
535     systotmap->Fill(mglu,mlsp,toterr/mceff);//total relative (!) error
536     sysstatmap->Fill(mglu,mlsp,mcefferr);//total relative (!) error
537     }
538 buchmann 1.15 }//efficiency is valid
539 buchmann 1.52 finish = clock();
540     timemap->Fill(mglu,mlsp,((float(finish)-float(start))/CLOCKS_PER_SEC));
541 buchmann 1.4 }
542     }
543 buchmann 1.52
544 buchmann 1.22 prepare_scan_axis(limitmap,ismSUGRA);
545     prepare_scan_axis(sysjesmap,ismSUGRA);
546     prepare_scan_axis(sysjsumap,ismSUGRA);
547     prepare_scan_axis(sysresmap,ismSUGRA);
548 buchmann 1.27 prepare_scan_axis(syspdfmap,ismSUGRA);
549     prepare_scan_axis(systotmap,ismSUGRA);
550     prepare_scan_axis(sysstatmap,ismSUGRA);
551 buchmann 1.36 prepare_scan_axis(timemap,ismSUGRA);
552 buchmann 1.35
553 buchmann 1.13 if(!systematicsonly&&!efficiencyonly) {
554 buchmann 1.9 limcanvas->cd();
555     limitmap->Draw("COLZ");
556 buchmann 1.22 string titletobewritten="Limits in LSP-Glu plane";
557     if(ismSUGRA) titletobewritten="Limits in m_{1/2}-m_{0} plane";
558     TText *title = write_title(titletobewritten);
559 buchmann 1.9 title->Draw();
560     if(runninglocally) {
561     CompleteSave(limcanvas,"SUSYScan/Limits_JZB_geq"+any2string(jzb_cut[ibin]));
562     } else {
563 buchmann 1.12 TFile *outputfile;
564     if(systematicsonly) outputfile=new TFile(("output/DistributedSystematics_job"+string(any2string(jobnumber))+"_of_"+string(any2string(njobs))+".root").c_str(),"UPDATE");//needs to be "UPDATE" as we can get to this point for different JZB cuts and don't want to erase the previous data :-)
565 buchmann 1.35 else outputfile=new TFile(("output/DistributedLimits_job"+string(any2string(jobnumber))+"_of_"+string(any2string(njobs))+".root").c_str(),"UPDATE");//needs to be "UPDATE" as we can get to this point for
566 buchmann 1.9 limitmap->Write();
567 buchmann 1.37 if(doexpected) {
568     explimitmap->Write();
569     exp1plimitmap->Write();
570     exp1mlimitmap->Write();
571     exp2plimitmap->Write();
572     exp2mlimitmap->Write();
573     }
574 buchmann 1.18 sysjesmap->Write();
575     sysjsumap->Write();
576 buchmann 1.28 sysresmap->Write();
577 buchmann 1.18 efficiencymap->Write();
578 buchmann 1.52 flipmap->Write();
579 buchmann 1.47 efficiencymapAcc->Write();
580     efficiencymapID->Write();
581     efficiencymapJets->Write();
582     efficiencymapSignal->Write();
583 buchmann 1.37 noscefficiencymap->Write();
584 buchmann 1.27 syspdfmap->Write();
585     systotmap->Write();
586     sysstatmap->Write();
587 buchmann 1.18 Neventsmap->Write();
588 buchmann 1.24 ipointmap->Write();
589 buchmann 1.36 timemap->Write();
590 buchmann 1.9 outputfile->Close();
591     }
592 buchmann 1.35 }
593 buchmann 1.13 if(systematicsonly) { // systematics only :
594 buchmann 1.9 limcanvas->cd();
595     sysjesmap->Draw("COLZ");
596 buchmann 1.22 string titletobewritten="Jet Energy scale in LSP-Glu plane";
597     if(ismSUGRA) titletobewritten="Limits in m_{1/2}-m_{0} plane";
598     TText *title = write_title(titletobewritten);
599 buchmann 1.9 title->Draw();
600     if(runninglocally) {
601     CompleteSave(limcanvas,"SUSYScan/JES_geq"+any2string(jzb_cut[ibin]));
602     }
603     sysjsumap->Draw("COLZ");
604 buchmann 1.22 titletobewritten="JZB Scale Uncertainty in LSP-Glu plane";
605     if(ismSUGRA) titletobewritten="JZB Scale Uncertainty in m_{1/2}-m_{0} plane";
606     TText *title2 = write_title(titletobewritten);
607 buchmann 1.9 title2->Draw();
608     if(runninglocally) {
609     CompleteSave(limcanvas,"SUSYScan/JSU_geq"+any2string(jzb_cut[ibin]));
610     }
611     sysresmap->Draw("COLZ");
612 buchmann 1.22 titletobewritten="Resolution in LSP-Glu plane";
613     if(ismSUGRA) titletobewritten="Resolution in m_{1/2}-m_{0} plane";
614     TText *title3 = write_title(titletobewritten);
615 buchmann 1.9 title3->Draw();
616     if(runninglocally) {
617     CompleteSave(limcanvas,"SUSYScan/Resolution_geq"+any2string(jzb_cut[ibin]));
618     }
619 buchmann 1.35
620 buchmann 1.9 if(!runninglocally) {
621     TFile *outputfile=new TFile(("output/DistributedSystematics_job"+string(any2string(jobnumber))+"_of_"+string(any2string(njobs))+".root").c_str(),"UPDATE");
622     sysjesmap->Write();
623     sysjsumap->Write();
624     sysresmap->Write();
625 buchmann 1.52 flipmap->Write();
626 buchmann 1.18 efficiencymap->Write();
627 buchmann 1.47 efficiencymapAcc->Write();
628     efficiencymapID->Write();
629     efficiencymapJets->Write();
630     efficiencymapSignal->Write();
631 buchmann 1.37 noscefficiencymap->Write();
632 buchmann 1.18 Neventsmap->Write();
633 buchmann 1.24 ipointmap->Write();
634 buchmann 1.27 syspdfmap->Write();
635     systotmap->Write();
636     sysstatmap->Write();
637 buchmann 1.36 timemap->Write();
638 buchmann 1.9 outputfile->Close();
639     }
640     }//end of systematics only
641 buchmann 1.13 if(efficiencyonly) {
642     limcanvas->cd();
643 buchmann 1.22 string titletobewritten="Efficiencies in LSP-Glu plane";
644     if(ismSUGRA) titletobewritten="Efficiencies in m_{1/2}-m_{0} plane";
645     TText *title = write_title(titletobewritten);
646 buchmann 1.47 efficiencymap->Draw("COLZ");
647 buchmann 1.13 title->Draw();
648     if(runninglocally) {
649     CompleteSave(limcanvas,"SUSYScan/Efficiency_geq"+any2string(jzb_cut[ibin]));
650     }
651     limcanvas->cd();
652 buchmann 1.47 efficiencymapAcc->Draw("COLZ");
653     title->Draw();
654     if(runninglocally) {
655     CompleteSave(limcanvas,"SUSYScan/EfficiencyAcc_geq"+any2string(jzb_cut[ibin]));
656     }
657     limcanvas->cd();
658     efficiencymapID->Draw("COLZ");
659     title->Draw();
660     if(runninglocally) {
661     CompleteSave(limcanvas,"SUSYScan/EfficiencyID_geq"+any2string(jzb_cut[ibin]));
662     }
663     limcanvas->cd();
664     efficiencymapJets->Draw("COLZ");
665     title->Draw();
666     if(runninglocally) {
667     CompleteSave(limcanvas,"SUSYScan/EfficiencyJets_geq"+any2string(jzb_cut[ibin]));
668     }
669     limcanvas->cd();
670     efficiencymapSignal->Draw("COLZ");
671     title->Draw();
672     if(runninglocally) {
673     CompleteSave(limcanvas,"SUSYScan/EfficiencySignal_geq"+any2string(jzb_cut[ibin]));
674     }
675     limcanvas->cd();
676     noscefficiencymap->Draw("COLZ");
677     title->Draw();
678     if(runninglocally) {
679     CompleteSave(limcanvas,"SUSYScan/NoEfficiency_geq"+any2string(jzb_cut[ibin]));
680     }
681     limcanvas->cd();
682 buchmann 1.13 sysjesmap->Draw("COLZ");
683 buchmann 1.22 titletobewritten="N(events) in LSP-Glu plane";
684     if(ismSUGRA) titletobewritten="N(events) in m_{1/2}-m_{0} plane";
685     TText *title2 = write_title(titletobewritten);
686 buchmann 1.13 title2->Draw();
687     if(runninglocally) {
688     CompleteSave(limcanvas,"SUSYScan/Nevents_geq"+any2string(jzb_cut[ibin]));
689     }
690     if(!runninglocally) {
691     TFile *outputfile=new TFile(("output/DistributedSystematics_job"+string(any2string(jobnumber))+"_of_"+string(any2string(njobs))+".root").c_str(),"UPDATE");
692 buchmann 1.24 ipointmap->Write();
693 buchmann 1.13 Neventsmap->Write();
694 buchmann 1.37 noscefficiencymap->Write();
695 buchmann 1.13 efficiencymap->Write();
696 buchmann 1.52 flipmap->Write();
697 buchmann 1.47 efficiencymapAcc->Write();
698     efficiencymapID->Write();
699     efficiencymapJets->Write();
700     efficiencymapSignal->Write();
701 buchmann 1.36 timemap->Write();
702 buchmann 1.13 outputfile->Close();
703     }
704     }//end of efficiencies only
705 buchmann 1.35
706 buchmann 1.31 delete limitmap;
707     delete exclmap;
708     delete sysjesmap;
709     delete sysjsumap;
710     delete sysresmap;
711 buchmann 1.37 delete noscefficiencymap;
712 buchmann 1.31 delete efficiencymap;
713 buchmann 1.47 delete efficiencymapAcc;
714     delete efficiencymapID;
715     delete efficiencymapJets;
716     delete efficiencymapSignal;
717 buchmann 1.31 delete Neventsmap;
718     delete ipointmap;
719     delete syspdfmap;
720     delete systotmap;
721     delete sysstatmap;
722 buchmann 1.13 delete limcanvas;
723 buchmann 1.1 }
724 buchmann 1.4
725 buchmann 1.13 void scan_SUSY_parameter_space(string mcjzb,string datajzb,vector<float> jzb_cut,bool requireZ, float peakerror, float njobs=-1, float jobnumber=-1, bool systonly=false, bool effonly=false) {
726 buchmann 1.10 dout << "Starting the SUSY scan now with all " << jzb_cut.size() << " bin(s)" << endl;
727 buchmann 1.4 for(int ibin=0;ibin<jzb_cut.size();ibin++) {
728 buchmann 1.13 scan_SUSY_parameter_space(mcjzb,datajzb,jzb_cut,requireZ, peakerror, ibin, njobs, jobnumber,systonly,effonly);
729 buchmann 1.4 }
730 buchmann 1.6 }
731 buchmann 1.35