ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.32
Committed: Wed Sep 7 06:30:25 2011 UTC (13 years, 8 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.31: +31 -4 lines
Log Message:
This version contains the new format for systematics files; these files are then used by the LimitsFromSystematics scripts to compute upper limits and make exclusion plots. The systematics scan part is done, the part computing exclusion maps and so on is still being worked on

File Contents

# Content
1 #include <iostream>
2 #include <vector>
3 #include <sys/stat.h>
4 #include <fstream>
5 #include <pthread.h>
6
7 #include <TCut.h>
8 #include <TROOT.h>
9 #include <TCanvas.h>
10 #include <TMath.h>
11 #include <TColor.h>
12 #include <TPaveText.h>
13 #include <TRandom.h>
14 #include <TH1.h>
15 #include <TH2.h>
16 #include <TF1.h>
17 #include <TSQLResult.h>
18 #include <TProfile.h>
19 #include <TKey.h>
20
21 //#include "TTbar_stuff.C"
22 using namespace std;
23
24 using namespace PlottingSetup;
25
26 void susy_scan_axis_labeling(TH2F *histo) {
27 histo->GetXaxis()->SetTitle("#Chi_{2}^{0}-LSP");
28 histo->GetXaxis()->CenterTitle();
29 histo->GetYaxis()->SetTitle("m_{#tilde{q}}");
30 histo->GetYaxis()->CenterTitle();
31 }
32
33 bool isThreadActive=false;
34
35 struct limit_args {
36 float mceff;
37 float toterr;
38 int ibin;
39 string mcjzb;
40 vector<float> sigmas;
41 string plotfilename;
42 };
43
44 void* compute_one_upper_limit_wrapper(void* data) {
45 isThreadActive=true;
46 limit_args* args = (limit_args*) data;
47 std::cout << "Thread to compute limits has been started" << std::endl;
48 args->sigmas=compute_one_upper_limit(args->mceff,args->toterr,args->ibin,args->mcjzb,args->plotfilename,true);
49 std::cout << "Thread to compute limits has finished" << std::endl;
50 isThreadActive=false;
51 return NULL; // oder in C++: return 0;// Damit kann man Werte zurückgeben
52 }
53
54 void do_limit_wrapper(float mceff,float toterr,int ibin,string mcjzb,vector<float> &sigmas,string plotfilename) {
55 pthread_t limitthread;
56 limit_args limargs={mceff,toterr,ibin,mcjzb,sigmas,plotfilename};
57 pthread_create( &limitthread, NULL, compute_one_upper_limit_wrapper, (void*) &limargs);
58 int counter=0;
59 int counterinterval=5;
60 sleep(1); //waiting a second for the process to become active
61 while(counter<limitpatience*60 && isThreadActive) {
62 std::cout << "Limits are being calculated; Checking round " << counter << " ( corresponds to " << seconds_to_time(counter) << " ) , patience will end in " << seconds_to_time(60*limitpatience-counter) << std::endl;
63 counter+=counterinterval;
64 sleep(counterinterval);
65 }
66
67 if(!isThreadActive) {
68 cout << "Thread finished sucessfully" << endl;
69 pthread_join( limitthread, NULL );
70 std::cout<< __FUNCTION__ << " : going to save sigmas " << std::endl;
71 sigmas=limargs.sigmas;
72 } else {
73 pthread_cancel(limitthread);
74 std::cout << "DID NOT TERMINATE IN TIME - ABORTED!" << std::endl;
75 sigmas.push_back(-1);sigmas.push_back(-1);sigmas.push_back(-1);
76 }
77 }
78
79 void prepare_scan_axis(TH2 *variablemap,bool ismSUGRA) {
80 variablemap->GetXaxis()->SetTitle("m_{glu}");
81 variablemap->GetYaxis()->SetTitle("m_{LSP}");
82
83 if(ismSUGRA) {
84 variablemap->GetXaxis()->SetTitle("m_{0}");
85 variablemap->GetYaxis()->SetTitle("m_{1/2}");
86 }
87
88 variablemap->GetXaxis()->CenterTitle();
89 variablemap->GetYaxis()->CenterTitle();
90 }
91
92 void set_SUSY_style() {
93 Int_t MyPalette[100];
94 Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0};
95 Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0};
96 Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0};
97 Double_t stop[] = {0., .25, .50, .75, 1.0};
98 Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 110);
99 for (int i=0;i<100;i++) MyPalette[i] = FI+i;
100
101 gStyle->SetPalette(100, MyPalette);
102
103 float rightmargin=gStyle->GetPadRightMargin();
104 gStyle->SetPadRightMargin(0.15);
105
106 }
107
108 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) {
109 bool runninglocally=true;
110 if(njobs>-1&&jobnumber>-1) {
111 runninglocally=false;
112 dout << "Running on the GRID (this is job " << jobnumber << "/" << njobs << ") for a jzb cut at " << jzb_cut[ibin] << endl;
113 } else {
114 dout << "Running locally " << endl;
115 dout << "This will take a really, really long time - if you want to see the results THIS week try running the LimitWorkerScript on the grid (DistributedModelCalculation/Limits/)" << endl;
116 }
117
118 string massgluname="MassGlu";
119 string massLSPname="MassLSP";
120
121 string prefix="SMS_";
122 // up to here, everything is set up for SMS; now we need to switch stuff around if we're dealing with an mSUGRA scan!
123 bool ismSUGRA=false;
124 TIter nextkey(fsyst->GetListOfKeys());
125 TKey *key;
126 while ((key = (TKey*)nextkey()))
127 {
128 TObject *obj = key->ReadObj();
129 if(Contains((string)(obj->GetName()),"mSUGRA")) ismSUGRA=true;
130 }
131
132 if(ismSUGRA) {
133 massgluname="M0"; // this is the "x axis" in the limit plot (like the gluino in the SMS case)
134 massLSPname="M12"; // this is the "y axis" in the limit plot (like the LSP in the SMS case)
135 mglustart=m0start;
136 mgluend=m0end;
137 mglustep=m0step;
138 mLSPstart=m12start;
139 mLSPend=m12end;
140 mLSPstep=m12step;
141 prefix="mSUGRA_";
142 cout << "mSUGRA scan has been set up." << endl;
143 } else {
144 cout << "SMS scan has been set up." << endl;
145 }
146
147 set_SUSY_style();
148
149 TCanvas *limcanvas = new TCanvas("limcanvas","Limit canvas");
150
151 int Npoints=0;
152 for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
153 for (int mlsp=mLSPstart;mlsp<=mLSPend&&mlsp<=mglu;mlsp+=mLSPstep) Npoints++;
154 }
155
156 TH2F *fullerr = (TH2F*)fsyst->Get((prefix+"systotmap"+any2string(jzb_cut[ibin])).c_str());
157 TH2F *mceff = (TH2F*)fsyst->Get((prefix+"efficiencymap"+any2string(jzb_cut[ibin])).c_str());
158 TH2F *NEvents = (TH2F*)fsyst->Get((prefix+"Nevents"+any2string(jzb_cut[ibin])).c_str());
159
160 TH2F *limitmap = new TH2F((prefix+"limitmap"+any2string(jzb_cut[ibin])).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
161 TH2F *exclmap = new TH2F((prefix+"exclusionmap"+any2string(jzb_cut[ibin])).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
162 TH2F *xsmap = new TH2F((prefix+"crosssectionmap"+any2string(jzb_cut[ibin])).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
163
164 if(!fullerr || !mceff || !NEvents) {
165 write_error(__FUNCTION__,"The supplied systematics file did not contain the correct histograms - please check the file");
166 delete limcanvas;
167 return;
168 }
169
170 int ipoint=-1;
171 for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
172 for (int mlsp=mLSPstart;mlsp<=mLSPend&&mlsp<=mglu;mlsp+=mLSPstep)
173 {
174 ipoint++;
175 if(!runninglocally&&!do_this_point(ipoint,Npoints,jobnumber,njobs)) continue;
176 float currmceff=mceff->GetBinContent(mceff->FindBin(mglu,mlsp));
177 float currtoterr=fullerr->GetBinContent(fullerr->FindBin(mglu,mlsp));
178 float nevents=NEvents->GetBinContent(NEvents->FindBin(mglu,mlsp));
179 dout << "Looking at point " << ipoint << " with masses " << massgluname << " = " << mglu << " and " << massLSPname << " = " << mlsp << endl;
180 dout << "Found : systerr=" << currtoterr << " and eff=" << currmceff << " and nevents=" << nevents << endl;
181 string plotfilename=(string)(TString(massgluname)+TString(any2string(mglu))+TString("__")+TString(massLSPname)+TString(any2string(mlsp))+TString(".png"));
182 if(currmceff<=0||currtoterr<=0) continue;
183 vector<float> sigmas;
184 //do_limit_wrapper(currmceff,currtoterr,ibin,mcjzb,sigmas,plotfilename); // no threading right now.
185 sigmas=compute_one_upper_limit(currmceff,currtoterr,ibin,mcjzb,plotfilename,true);
186 limitmap->Fill(mglu,mlsp,sigmas[0]);
187 dout << "An upper limit has been added for this point ( " << massgluname << " = " << mglu << " and " << massLSPname << " = " << mlsp << " )at " << sigmas[0] << endl;
188 if(ismSUGRA) {
189 dout << "Computing XS" << endl;
190 float rel_limit=0;
191 float xs=-1;
192 stringstream addcut;
193 addcut << "(TMath::Abs("<<massgluname<<"-"<<mglu<<")<5)&&(TMath::Abs("<<massLSPname<<"-"<<mlsp<<")<5)";
194
195 vector<float> xs_weights = processMCefficiency((scansample.collection)[0].events,mcjzb,requireZ,nevents, addcut.str());
196
197 exclmap->Fill(mglu,mlsp,rel_limit);
198 xsmap->Fill(mglu,mlsp,xs);
199 }
200
201 }
202 }
203
204 prepare_scan_axis(limitmap,ismSUGRA);
205 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 :-)
206 outputfile->cd();
207 limitmap->Write();
208 if(ismSUGRA) {
209 exclmap->Write();
210 xsmap->Write();
211 }
212 outputfile->Close();
213 delete limcanvas;
214 }
215
216 void establish_SUSY_limits(string mcjzb,string datajzb,vector<float> jzb_cut,bool requireZ, float peakerror, string fsystfilename, float njobs=-1, float jobnumber=-1) {
217 dout << "Starting the SUSY scan from systematics file now with all " << jzb_cut.size() << " bin(s)" << " and using " << fsystfilename << endl;
218 TFile *fsyst = new TFile(fsystfilename.c_str());
219 if(!fsyst) {
220 write_error(__FUNCTION__,"You provided an invalid systematics file. Please change it ... ");
221 return;
222 }
223 for(int ibin=0;ibin<jzb_cut.size();ibin++) {
224 establish_SUSY_limits(mcjzb,datajzb,jzb_cut,requireZ, peakerror, fsyst, ibin,njobs, jobnumber);
225 }
226 }
227
228
229
230
231 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) {
232 bool runninglocally=true;
233 if(njobs>-1&&jobnumber>-1) {
234 runninglocally=false;
235 dout << "Running on the GRID (this is job " << jobnumber << "/" << njobs << ") for a jzb cut at " << jzb_cut[ibin] << endl;
236 } else {
237 dout << "Running locally " << endl;
238 dout << "This will take a really, really long time - if you want to see the results THIS week try running the LimitWorkerScript on the grid (DistributedModelCalculation/Limits/)" << endl;
239 }
240
241 cout << "FILE USED: " << (scansample.collection)[0].filename << endl;
242 cout << "FILE USED (name): " << (scansample.collection)[0].samplename << endl;
243 jzbSel=jzb_cut[ibin];
244 geqleq="geq";
245 automatized=true;
246 mcjzbexpression=mcjzb;
247
248 string massgluname="MassGlu";
249 string massLSPname="MassLSP";
250
251 string prefix="SMS_";
252 // up to here, everything is set up for SMS; now we need to switch stuff around if we're dealing with an mSUGRA scan!
253 bool ismSUGRA=false;
254 if(Contains((scansample.collection)[0].samplename,"mSUGRA")) ismSUGRA=true;
255 if(ismSUGRA) {
256 massgluname="M0"; // this is the "x axis" in the limit plot (like the gluino in the SMS case)
257 massLSPname="M12"; // this is the "y axis" in the limit plot (like the LSP in the SMS case)
258 mglustart=m0start;
259 mgluend=m0end;
260 mglustep=m0step;
261 mLSPstart=m12start;
262 mLSPend=m12end;
263 mLSPstep=m12step;
264 prefix="mSUGRA_";
265 cout << "mSUGRA scan has been set up." << endl;
266 } else {
267 cout << "SMS scan has been set up." << endl;
268 }
269
270 Int_t MyPalette[100];
271 Double_t r[] = {0., 0.0, 1.0, 1.0, 1.0};
272 Double_t g[] = {0., 0.0, 0.0, 1.0, 1.0};
273 Double_t b[] = {0., 1.0, 0.0, 0.0, 1.0};
274 Double_t stop[] = {0., .25, .50, .75, 1.0};
275 Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 110);
276 for (int i=0;i<100;i++) MyPalette[i] = FI+i;
277
278 gStyle->SetPalette(100, MyPalette);
279
280 TH2F *limitmap = new TH2F((prefix+"limitmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
281 TH2F *exclmap = new TH2F((prefix+"exclusionmap"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
282 TH2F *sysjesmap = new TH2F((prefix+"sysjes"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
283 TH2F *sysjsumap = new TH2F((prefix+"sysjsu"+any2string(jzbSel)).c_str(), "",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
284 TH2F *sysresmap = new TH2F((prefix+"sysresmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
285 TH2F *efficiencymap = new TH2F((prefix+"efficiencymap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
286 TH2F *Neventsmap = new TH2F((prefix+"Neventsmap"+any2string(jzbSel)).c_str(),"", (mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
287 TH2F *ipointmap = new TH2F((prefix+"Neventsmap"+any2string(jzbSel)).c_str(),"", (mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
288 TH2F *syspdfmap = new TH2F((prefix+"syspdfmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
289 TH2F *systotmap = new TH2F((prefix+"systotmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
290 TH2F *sysstatmap = new TH2F((prefix+"sysstatmap"+any2string(jzbSel)).c_str(),"",(mgluend-mglustart)/mglustep+1,mglustart-0.5*mglustep,mgluend+0.5*mglustep,(mLSPend-mLSPstart)/mLSPstep+1,mLSPstart-0.5*mLSPstep,mLSPend+0.5*mLSPstep);
291
292
293
294 write_warning(__FUNCTION__,"CURRENTLY SWITCHING AUTOMATIZED MODE OFF!");automatized=false;
295
296 float rightmargin=gStyle->GetPadRightMargin();
297 gStyle->SetPadRightMargin(0.15);
298
299 TCanvas *limcanvas = new TCanvas("limcanvas","Limit canvas");
300
301 int Npoints=0;
302 for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
303 for (int mlsp=mLSPstart;mlsp<=mLSPend&&mlsp<=mglu;mlsp+=mLSPstep) Npoints++;
304 }
305
306 int ipoint=-1;
307 for(int mglu=mglustart;mglu<=mgluend;mglu+=mglustep) {
308 for (int mlsp=mLSPstart;mlsp<=mLSPend&&mlsp<=mglu;mlsp+=mLSPstep)
309 {
310 ipoint++;
311 if(!runninglocally&&!do_this_point(ipoint,Npoints,jobnumber,njobs)) continue;
312 float result=-987,resulterr=-987;
313 stringstream addcut;
314 addcut << "(TMath::Abs("<<massgluname<<"-"<<mglu<<")<5)&&(TMath::Abs("<<massLSPname<<"-"<<mlsp<<")<5)";
315 (scansample.collection)[0].events->Draw("eventNum",addcut.str().c_str(),"goff");
316 float nevents = (scansample.collection)[0].events->GetSelectedRows();
317 vector<vector<float> > systematics;
318 if(nevents<10) {
319 dout << "This point ("<<ipoint<<") with configuration ("<<massgluname<<"="<<mglu<<" , "<<massLSPname<<"="<<mlsp << ") does not contain enough events and will be skipped."<< endl;
320 continue;
321 } else {
322 dout << "OK! This point ("<<ipoint<<") with configuration ("<<massgluname<<"="<<mglu<<" , "<<massLSPname<<"="<<mlsp << ") contains " << nevents << " and will therefore not be skipped."<< endl;
323 }
324 if(nevents!=0&&efficiencyonly) {
325 MCefficiency((scansample.collection)[0].events,result,resulterr,mcjzb,requireZ,nevents,addcut.str(),-1);
326 efficiencymap->Fill(mglu,mlsp,result);
327 }
328 Neventsmap->Fill(mglu,mlsp,nevents);
329 ipointmap->Fill(mglu,mlsp,ipoint);
330 if(efficiencyonly) continue;
331
332 do_systematics_for_one_file((scansample.collection)[0].events,nevents,"SUSY SCAN", systematics,mcjzb,datajzb,peakerror,requireZ, addcut.str(),ismSUGRA);
333 float JZBcutat = systematics[0][0];
334 float mceff = systematics[0][1];
335 float mcefferr = systematics[0][2];//MC stat error
336 float toterr = systematics[0][4];
337 float sys_jes = systematics[0][5]; // Jet Energy Scale
338 float sys_jsu = systematics[0][6]; // JZB scale uncertainty
339 float sys_res = systematics[0][7]; // resolution
340 float sys_pdf = 0;
341 if(systematics[0].size()>9) sys_pdf = systematics[0][9]; // PDF
342 efficiencymap->Fill(mglu,mlsp,mceff);
343 efficiencymap->SetBinError(efficiencymap->FindBin(mglu,mlsp),mcefferr);//blublu
344
345 if(mceff!=mceff||toterr!=toterr||mceff<0) {
346 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;
347 continue;
348 } else {
349 if(!systematicsonly&&!efficiencyonly) {
350 dout << "Calculating limit now for "<<massgluname<<"="<<mglu<<" , "<<massLSPname<<"="<<mlsp <<endl;
351 vector<float> sigmas;
352 string plotfilename=(string)(TString((scansample.collection)[0].samplename)+TString(massgluname)+TString(any2string(mglu))+TString("__")+TString(massLSPname)+TString(any2string(mlsp))+TString(".png"));
353 do_limit_wrapper(mceff,toterr,ibin,mcjzb,sigmas,plotfilename);
354 cout << "back in " << __FUNCTION__ << endl;
355 if(sigmas[0]>-0.5) { // negative sigmas are the error signature of do_limit_wrapper, so we want to exclude them.
356 limitmap->Fill(mglu,mlsp,sigmas[0]);
357 sysjesmap->Fill(mglu,mlsp,sys_jes);
358 sysjsumap->Fill(mglu,mlsp,sys_jsu);
359 sysresmap->Fill(mglu,mlsp,sys_res);
360 syspdfmap->Fill(mglu,mlsp,sys_pdf);
361 systotmap->Fill(mglu,mlsp,toterr/mceff);//total relative (!) error
362 sysstatmap->Fill(mglu,mlsp,mcefferr);//total relative (!) error
363 efficiencymap->Fill(mglu,mlsp,result);
364 dout << "A limit has been added at " << sigmas[0] << " for m_{glu}="<<mglu << " and m_{lsp}="<<mlsp<<endl;
365 } //end of if sigma is positive
366 //end of not systematics only condition
367 }
368 if(systematicsonly) {
369 sysjesmap->Fill(mglu,mlsp,sys_jes);
370 sysjsumap->Fill(mglu,mlsp,sys_jsu);
371 sysresmap->Fill(mglu,mlsp,sys_res);
372 syspdfmap->Fill(mglu,mlsp,sys_pdf);
373 systotmap->Fill(mglu,mlsp,toterr/mceff);//total relative (!) error
374 sysstatmap->Fill(mglu,mlsp,mcefferr);//total relative (!) error
375 efficiencymap->Fill(mglu,mlsp,mceff);
376 }
377 }//efficiency is valid
378 }
379 }
380
381 prepare_scan_axis(limitmap,ismSUGRA);
382 prepare_scan_axis(sysjesmap,ismSUGRA);
383 prepare_scan_axis(sysjsumap,ismSUGRA);
384 prepare_scan_axis(sysresmap,ismSUGRA);
385 prepare_scan_axis(syspdfmap,ismSUGRA);
386 prepare_scan_axis(systotmap,ismSUGRA);
387 prepare_scan_axis(sysstatmap,ismSUGRA);
388
389 if(!systematicsonly&&!efficiencyonly) {
390 limcanvas->cd();
391 limitmap->Draw("COLZ");
392 string titletobewritten="Limits in LSP-Glu plane";
393 if(ismSUGRA) titletobewritten="Limits in m_{1/2}-m_{0} plane";
394 TText *title = write_title(titletobewritten);
395 title->Draw();
396 if(runninglocally) {
397 CompleteSave(limcanvas,"SUSYScan/Limits_JZB_geq"+any2string(jzb_cut[ibin]));
398 } else {
399 TFile *outputfile;
400 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 :-)
401 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
402 limitmap->Write();
403 sysjesmap->Write();
404 sysjsumap->Write();
405 sysresmap->Write();
406 efficiencymap->Write();
407 syspdfmap->Write();
408 systotmap->Write();
409 sysstatmap->Write();
410 Neventsmap->Write();
411 ipointmap->Write();
412 outputfile->Close();
413 }
414 }
415 if(systematicsonly) { // systematics only :
416 limcanvas->cd();
417 sysjesmap->Draw("COLZ");
418 string titletobewritten="Jet Energy scale in LSP-Glu plane";
419 if(ismSUGRA) titletobewritten="Limits in m_{1/2}-m_{0} plane";
420 TText *title = write_title(titletobewritten);
421 title->Draw();
422 if(runninglocally) {
423 CompleteSave(limcanvas,"SUSYScan/JES_geq"+any2string(jzb_cut[ibin]));
424 }
425 sysjsumap->Draw("COLZ");
426 titletobewritten="JZB Scale Uncertainty in LSP-Glu plane";
427 if(ismSUGRA) titletobewritten="JZB Scale Uncertainty in m_{1/2}-m_{0} plane";
428 TText *title2 = write_title(titletobewritten);
429 title2->Draw();
430 if(runninglocally) {
431 CompleteSave(limcanvas,"SUSYScan/JSU_geq"+any2string(jzb_cut[ibin]));
432 }
433 sysresmap->Draw("COLZ");
434 titletobewritten="Resolution in LSP-Glu plane";
435 if(ismSUGRA) titletobewritten="Resolution in m_{1/2}-m_{0} plane";
436 TText *title3 = write_title(titletobewritten);
437 title3->Draw();
438 if(runninglocally) {
439 CompleteSave(limcanvas,"SUSYScan/Resolution_geq"+any2string(jzb_cut[ibin]));
440 }
441
442 if(!runninglocally) {
443 TFile *outputfile=new TFile(("output/DistributedSystematics_job"+string(any2string(jobnumber))+"_of_"+string(any2string(njobs))+".root").c_str(),"UPDATE");
444 sysjesmap->Write();
445 sysjsumap->Write();
446 sysresmap->Write();
447 efficiencymap->Write();
448 Neventsmap->Write();
449 ipointmap->Write();
450 syspdfmap->Write();
451 systotmap->Write();
452 sysstatmap->Write();
453 outputfile->Close();
454 }
455 }//end of systematics only
456 if(efficiencyonly) {
457 limcanvas->cd();
458 efficiencymap->Draw("COLZ");
459 string titletobewritten="Efficiencies in LSP-Glu plane";
460 if(ismSUGRA) titletobewritten="Efficiencies in m_{1/2}-m_{0} plane";
461 TText *title = write_title(titletobewritten);
462 title->Draw();
463 if(runninglocally) {
464 CompleteSave(limcanvas,"SUSYScan/Efficiency_geq"+any2string(jzb_cut[ibin]));
465 }
466 limcanvas->cd();
467 sysjesmap->Draw("COLZ");
468 titletobewritten="N(events) in LSP-Glu plane";
469 if(ismSUGRA) titletobewritten="N(events) in m_{1/2}-m_{0} plane";
470 TText *title2 = write_title(titletobewritten);
471 title2->Draw();
472 if(runninglocally) {
473 CompleteSave(limcanvas,"SUSYScan/Nevents_geq"+any2string(jzb_cut[ibin]));
474 }
475 if(!runninglocally) {
476 TFile *outputfile=new TFile(("output/DistributedSystematics_job"+string(any2string(jobnumber))+"_of_"+string(any2string(njobs))+".root").c_str(),"UPDATE");
477 ipointmap->Write();
478 Neventsmap->Write();
479 efficiencymap->Write();
480 outputfile->Close();
481 }
482 }//end of efficiencies only
483
484 delete limitmap;
485 delete exclmap;
486 delete sysjesmap;
487 delete sysjsumap;
488 delete sysresmap;
489 delete efficiencymap;
490 delete Neventsmap;
491 delete ipointmap;
492 delete syspdfmap;
493 delete systotmap;
494 delete sysstatmap;
495 delete limcanvas;
496 }
497
498 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) {
499 dout << "Starting the SUSY scan now with all " << jzb_cut.size() << " bin(s)" << endl;
500 for(int ibin=0;ibin<jzb_cut.size();ibin++) {
501 scan_SUSY_parameter_space(mcjzb,datajzb,jzb_cut,requireZ, peakerror, ibin, njobs, jobnumber,systonly,effonly);
502 }
503 }