ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/SUSYScan.C
Revision: 1.47
Committed: Thu Oct 27 08:53:43 2011 UTC (13 years, 6 months ago) by buchmann
Content type: text/plain
Branch: MAIN
Changes since 1.46: +71 -4 lines
Log Message:
Merging Pablo's changes to obtain partial scan efficiencies in the framework

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