ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.67
Committed: Thu Dec 15 12:34:39 2011 UTC (13 years, 4 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.66: +3 -2 lines
Log Message:
Fixed exception when downloading the first file fails to download (initilize variable is only set after the first file is successfully loaded)

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