ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.51
Committed: Fri Nov 4 10:41:32 2011 UTC (13 years, 6 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.50: +16 -1 lines
Log Message:
change in susy scan (systematics&efficiencies): when using crab try to load the file from cscs; if it fails, retry up to 4 times. in case of constant failure give up and report error

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