ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.65
Committed: Fri Nov 25 17:19:49 2011 UTC (13 years, 5 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.64: +3 -1 lines
Log Message:
Update to be ready for GMSB

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