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