ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.68
Committed: Thu Jan 19 08:45:48 2012 UTC (13 years, 3 months ago) by buchmann
Content type: text/plain
Branch: MAIN
CVS Tags: cbaf_4_98ifb_paper, beforeFR20120418, cbaf_4p7ifb, HEAD
Changes since 1.67: +25 -5 lines
Error occurred while calculating annotation data.
Log Message:
Added maps containing the imposed x value (read from directory name) and the measured x value (if available); adapted CRAB caching method (for retries)

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