ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.48
Committed: Thu Oct 27 13:56:29 2011 UTC (13 years, 6 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.47: +39 -13 lines
Log Message:
Updated mSUGRA xs

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