ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.50
Committed: Thu Nov 3 10:39:40 2011 UTC (13 years, 6 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.49: +76 -83 lines
Log Message:
Updated usage of cross section reader code; updated susy scan code for usage with crab

File Contents

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