ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.56
Committed: Wed Nov 9 12:13:46 2011 UTC (13 years, 6 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.55: +51 -51 lines
Log Message:
Reduced verbose compiling output (e.g. double instead of float and such)

File Contents

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