ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/LimitCalculation.C
(Generate patch)

Comparing UserCode/cbrown/AnalysisFramework/Plotting/Modules/LimitCalculation.C (file contents):
Revision 1.5 by buchmann, Wed Jul 20 14:34:31 2011 UTC vs.
Revision 1.21 by buchmann, Wed Sep 14 12:02:01 2011 UTC

# Line 1 | Line 1
1   #include <iostream>
2   #include <vector>
3   #include <sys/stat.h>
4 + #include <fstream>
5  
6   #include <TCut.h>
7   #include <TROOT.h>
# Line 14 | Line 15
15   #include <TF1.h>
16   #include <TSQLResult.h>
17   #include <TProfile.h>
18 + #include <TSystem.h>
19 + #include "LimitDroplet.C"
20  
21   //#include "TTbar_stuff.C"
22   using namespace std;
# Line 167 | Line 170 | ratio_binning.push_back(80);
170    
171   }
172  
173 < vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, bool doobserved=false) {
174 <  float sigma95=0.0,sigma95A=0.0;
175 <  int nuisancemodel=1;
176 <  dout << "Now calling : CL95(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl;
177 <  sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel);
173 > vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, string plotfilename, bool doobserved) {
174 >  float sigma95=-9.9,sigma95A=-9.9;
175 > /*
176 > USAGE OF ROOSTATS_CL95
177 > " Double_t             limit = roostats_cl95(ilum, slum, eff, seff, bck, sbck, n, gauss = false, nuisanceModel, method, plotFileName, seed); \n"
178 > " LimitResult expected_limit = roostats_clm(ilum, slum, eff, seff, bck, sbck, ntoys, nuisanceModel, method, seed); \n"
179 > " Double_t     average_limit = roostats_cla(ilum, slum, eff, seff, bck, sbck, nuisanceModel, method, seed); \n"
180 > "                                                                     \n"
181 > "
182 > " Double_t obs_limit = limit.GetObservedLimit();                      \n"
183 > " Double_t exp_limit = limit.GetExpectedLimit();                      \n"
184 > " Double_t exp_up    = limit.GetOneSigmaHighRange();                  \n"
185 > " Double_t exp_down  = limit.GetOneSigmaLowRange();                   \n"
186 > " Double_t exp_2up   = limit.GetTwoSigmaHighRange();                  \n"
187 > " Double_t exp_2down = limit.GetTwoSigmaLowRange();                   \n"
188 > */
189 >  if(mceff<=0) {
190 >    write_warning(__FUNCTION__,"Cannot compute upper limit in this configuration as the efficiency is negative:");
191 >    dout << "mc efficiency=" << mceff << " +/- " << mcefferr;
192 >    vector<float> sigmas;
193 >    sigmas.push_back(-1);
194 >    sigmas.push_back(-1);
195 >    return sigmas;
196 >  } else {
197 >    int nlimittoysused=1;
198 >    
199 >    ///------------------------------------------ < NEW > ----------------------------------------------------------
200 >    
201 >    int secondssince1970=time(NULL);
202 >    stringstream repname;
203 >    repname << PlottingSetup::cbafbasedir << "/exchange/report_" << secondssince1970 << "_"<<plotfilename<< "__"<< ".txt";
204 >    
205 >      /* - report filename [1]
206 >         - luminosity [2]
207 >         - lumi uncert [3]
208 >         - MC efficiency [4]
209 >         - MC efficiency error [5]
210 >         - Npred [6]
211 >         - Nprederr [7]
212 >         - Nobs [8]
213 >         - JZB cut [9]
214 >         - plot name  [10]*/
215 >
216 >  dout << "Calling limit capsule instead of calling : CL95(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl;
217 >    
218 >    stringstream command;
219 >    command << PlottingSetup::cbafbasedir << "/DistributedModelCalculations/Limits/LimitCapsule.exec " << repname.str() << " " << luminosity << " " << luminosity*lumiuncert << " " << mceff << " " << mcefferr << " " << Npred[ibin] << " " << Nprederr[ibin] << " " << Nobs[ibin] << " " << -1 << " " << plotfilename;
220 >    dout << command.str() << endl;
221 >    
222 >    int retval = 256;
223 >    int attempts=0;
224 >    while(!(retval==0||attempts>=5)) {//try up to 5 times
225 >        attempts++;
226 >        dout << "Starting limit calculation (LimitCapsule) now : Attempt " << attempts << endl;
227 >        retval=gSystem->Exec(command.str().c_str());
228 >    }
229 >    
230 >    LimitDroplet limres;
231 >    limres.readDroplet(repname.str());
232 >    dout << limres << endl;
233 >    remove(repname.str().c_str());
234 >    sigma95=limres.expected;
235 >
236 >    
237 >    ///------------------------------------------ < /NEW > ----------------------------------------------------------
238 >    //if(doobserved) nlimittoysused=nlimittoys;
239 > //    nlimittoysused=nlimittoys;
240 > //  dout << "Now calling : CL95(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl;
241 > //  sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel);
242 > //  sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel);
243 >  
244 > /*  dout << "Now calling : roostats_cl95(" << luminosity << "," << lumiuncert*luminosity << ","<<mceff <<","<<mcefferr<<","<<Npred[ibin]<<","<<Nprederr[ibin] << ",n=" << nlimittoysused << ",gauss=" << false << ",nuisanceModel="<<nuisancemodel<<",method="<<limitmethod<<",plotfilename="<<plotfilename<<",seed=0) " << endl;
245 > /*  dout << "Now calling : roostats_limit(" << luminosity << "," << lumiuncert*luminosity << ","<<mceff <<","<<mcefferr<<","<<Npred[ibin]<<","<<Nprederr[ibin] << ",n=" << nlimittoysused << ",gauss=" << false << ", nuisanceModel="<<nuisancemodel<<",method="<<limitmethod<<",plotfilename="<<plotfilename<<",seed=1) " << endl;
246 >  LimitResult limit = roostats_limit(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0);
247 >  dout << "Now interpreting and saving results ... " << endl;
248 >  vector<float> sigmas;
249 >  sigmas.push_back(limit.GetExpectedLimit());//expected
250 >  sigmas.push_back(limit.GetObservedLimit());//observed
251 >  //up to here for backward compatibility
252 >  sigmas.push_back(limit.GetOneSigmaHighRange());//expected, up
253 >  sigmas.push_back(limit.GetTwoSigmaHighRange());//expected, 2 up
254 >  sigmas.push_back(limit.GetOneSigmaLowRange());//expected, down
255 >  sigmas.push_back(limit.GetTwoSigmaLowRange());//expected, 2 down
256 > */
257 > //  float limit = roostats_cl95(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0);
258    if(doobserved) {
259 <    dout << "Now calling : CLA(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl;
260 <    sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel);
259 > write_warning(__FUNCTION__,"OBSERVED LIMITS HAVE BEEN SWITCHED OFF TEMPORARILY");
260 > //    dout << "Now calling : CLA(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl;
261 > //    sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel);
262    }
263 + //  vector<float> sigmas;
264 + //  sigmas.push_back(limit);
265    vector<float> sigmas;
266    sigmas.push_back(sigma95);
267    sigmas.push_back(sigma95A);
268    return sigmas;
269 +  
270 +
271 +  }
272 +  write_warning(__FUNCTION__,"STILL MISSING SIGMAS, LIMITS, EVERYTHING ...");
273   }
274  
275   void compute_upper_limits_from_counting_experiment(vector<vector<float> > uncertainties,vector<float> jzbcuts, string mcjzb, bool doobserved) {
# Line 200 | Line 290 | void compute_upper_limits_from_counting_
290        float staterr=uncertainties[isample*jzbcuts.size()+ibin][2];
291        float systerr=uncertainties[isample*jzbcuts.size()+ibin][3];
292        float toterr =uncertainties[isample*jzbcuts.size()+ibin][4];
293 <      float observed,null,result;
204 <      fill_result_histos(observed, null,null,null,null,null,null,null,mcjzb,JZBcutat,(int)5,result,(signalsamples.FindSample(signalsamples.collection[isample].filename)),signalsamples);
205 <      observed-=result;//this is the actual excess we see!
206 <      float expected=observed/luminosity;
293 >      float observed,observederr,null,result;
294        
295 + //      fill_result_histos(observed,observederr, null,null,null,null,null,null,null,mcjzb,JZBcutat,14000,(int)5,result,(signalsamples.FindSample(signalsamples.collection[isample].filename)),signalsamples);
296 + //      observed-=result;//this is the actual excess we see!
297 + //      float expected=observed/luminosity;
298 +      string plotfilename=(string)(TString(signalsamples.collection[isample].samplename)+TString("___JZB_geq_")+TString(any2string(JZBcutat))+TString(".png"));
299        dout << "Sample: " << signalsamples.collection[isample].samplename << ", JZB>"<<JZBcutat<< " : " << mceff << " +/- " << staterr << " (stat) +/- " << systerr << " (syst) --> toterr = " << toterr << endl;
300 <      vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,doobserved);
300 >      vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,plotfilename,doobserved);
301        
302        if(doobserved) {
303 <        rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")");
303 > //      rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")");
304 >        rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(signalsamples.collection[isample].xs)+")");
305          vrows.push_back(sigmas[0]);
306          vrows.push_back(sigmas[1]);
307 <        vrows.push_back(expected);
307 > //      vrows.push_back(expected);
308 >        vrows.push_back(signalsamples.collection[isample].xs);
309        }
310        else {
311 <        rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")");
311 > //      rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")");
312 >        rows.push_back(any2string(sigmas[0]));
313          vrows.push_back(sigmas[0]);
314 <        vrows.push_back(expected);
314 >        vrows.push_back(signalsamples.collection[isample].xs);
315 > //      vrows.push_back(expected);
316        }
317      }//end of bin loop
318      limits.push_back(rows);
319      vlimits.push_back(vrows);
320    }//end of sample loop
321 <  dout << endl << endl << "PAS table 3: " << endl << endl;
321 >  dout << endl << endl << endl << "_________________________________________________________________________________________________" << endl << endl;
322 >  dout << endl << endl << "PAS table 3:   (notation: limit [95%CL])" << endl << endl;
323    dout << "\t";
324    for (int irow=0;irow<jzbcuts.size();irow++) {
325      dout << jzbcuts[irow] << "\t";
# Line 231 | Line 327 | void compute_upper_limits_from_counting_
327    dout << endl;
328    for(int irow=0;irow<limits.size();irow++) {
329      for(int ientry=0;ientry<limits[irow].size();ientry++) {
330 <      dout << limits[irow][ientry] << "\t";
330 >      if (limits[irow][ientry]>0) dout << limits[irow][ientry] << "\t";
331 >      else dout << " (N/A) \t";
332      }
333      dout << endl;
334    }
335    
336    if(!doobserved) {
337 <    dout << endl << endl << "LIMITS: " << endl;
338 <    dout << "\t";
337 >    dout << endl << endl << "LIMITS: (Tex)" << endl;
338 >    tout << "\\begin{table}[hbtp]" << endl;
339 >    tout << "\\renewcommand{\\arraystretch}{1.3}" << endl;
340 >    tout << "\\begin{center}" << endl;
341 >    tout << "\\caption{Observed upper limits on the cross section of different LM benchmark points " << (ConsiderSignalContaminationForLimits?"  (accounting for signal contamination)":"  (not accounting for signal contamination)") << "}\\label{tab:lmresults}" << endl;
342 >    tout << "" << endl;
343 >    tout << "\\begin{tabular}{ | l | ";
344 >    for (int irow=0;irow<jzbcuts.size();irow++) tout << " l |";
345 >    tout << "} " << endl << " \\hline " << endl << "& \t ";
346      for (int irow=0;irow<jzbcuts.size();irow++) {
347 <      dout << jzbcuts[irow] << "\t";
347 >      tout << "JZB $>$ " << jzbcuts[irow] << " GeV & \t ";
348      }
349 <    dout << endl;
349 >    tout << " \\\\ \\hline " << endl;
350      for(int irow=0;irow<limits.size();irow++) {
351 <      dout << limits[irow][0] << "\t";
351 >      tout << limits[irow][0] << " \t";
352        for(int ientry=0;ientry<jzbcuts.size();ientry++) {
353 <        dout << Round(vlimits[irow][2*ientry] / vlimits[irow][2*ientry+1],3)<< "\t";
353 >        if(vlimits[irow][2*ientry]>0) tout << " & " << Round(vlimits[irow][2*ientry],2) << " \t (" << Round(vlimits[irow][2*ientry] / vlimits[irow][2*ientry+1],3)<< "x \\sigma ) \t";
354 >        else tout << " & ( N / A ) \t";
355 > //      dout << Round(vlimits[irow][2*ientry],3) << " / " << Round(vlimits[irow][2*ientry+1],3)<< "\t";
356        }
357 <      dout << endl;
357 >      tout << " \\\\ \\hline " << endl;
358      }
359 +      tout << "\\end{tabular}" << endl;
360 +      tout << "      \\end{tabular}"<< endl;
361 +      tout << "\\end{center}"<< endl;
362 +      tout << "\\end{table} "<< endl;
363 +
364    }//do observed
365    
366    dout << endl << endl << "Final selection efficiencies with total statistical and systematic errors, and corresponding observed and expected upper limits (UL) on ($\\sigma\\times$  BR $\\times$ acceptance) for the LM4 and LM8 scenarios, in the different regions. The last column contains the predicted ($\\sigma \\times $BR$\\times$ acceptance) at NLO obtained from Monte Carlo simulation." << endl;
367 <  dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t Prediction [pb]" << endl;
367 >  dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t \\sigma [pb]" << endl;
368    for(int icut=0;icut<jzbcuts.size();icut++) {
369 <    dout << "Region with JZB>" << jzbcuts[icut] << endl;
369 >    dout << "Region with JZB>" << jzbcuts[icut] << (ConsiderSignalContaminationForLimits?"  (accounting for signal contamination)":"  (not accounting for signal contamination)") << endl;
370      for(int isample=0;isample<signalsamples.collection.size();isample++) {
371 <      dout << limits[icut][0] << "\t" << Round(100*uncertainties[isample*jzbcuts.size()+icut][1],1) << "+/-" << Round(100*uncertainties[isample*jzbcuts.size()+icut][2],1) << " (stat) +/- " << Round(100*uncertainties[isample*jzbcuts.size()+icut][3],1) << " (syst) \t" << Round((vlimits[isample][2*icut]),3) << "\t" << Round(vlimits[isample][2*icut+1],3) << endl;
371 >      dout << limits[isample][0] << "\t" << Round(100*uncertainties[isample*jzbcuts.size()+icut][1],3) << "+/-" << Round(100*uncertainties[isample*jzbcuts.size()+icut][2],3) << " (stat) +/- " << Round(100*uncertainties[isample*jzbcuts.size()+icut][3],3) << " (syst) \t" << Round((vlimits[isample][2*icut]),3) << "\t" << Round(vlimits[isample][2*icut+1],3) << endl;
372      }
373      dout << endl;
374    }
375    
376 <  write_warning("compute_upper_limits_from_counting_experiment","Still need to update the script");
376 >  write_warning(__FUNCTION__,"Still need to update the script");
377   }
378  
268 void susy_scan_axis_labeling(TH2F *histo) {
269  histo->GetXaxis()->SetTitle("#Chi_{2}^{0}-LSP");
270  histo->GetXaxis()->CenterTitle();
271  histo->GetYaxis()->SetTitle("m_{#tilde{q}}");
272  histo->GetYaxis()->CenterTitle();
273 }
379  
380 < void scan_susy_space(string mcjzb, string datajzb) {
381 <  TCanvas *c3 = new TCanvas("c3","c3");
277 <  vector<float> binning;
278 <  binning=allsamples.get_optimal_binsize(mcjzb,cutmass&&cutOSSF&&cutnJets,20,50,800);
279 <  float arrbinning[binning.size()];
280 <  for(int i=0;i<binning.size();i++) arrbinning[i]=binning[i];
281 <  TH1F *puredata   = allsamples.Draw("puredata",  datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
282 <  puredata->SetMarkerSize(DataMarkerSize);
283 <  TH1F *allbgs   = allsamples.Draw("allbgs",  "-"+datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
284 <  TH1F *allbgsb   = allsamples.Draw("allbgsb",  "-"+datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity);
285 <  TH1F *allbgsc   = allsamples.Draw("allbgsc",  datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,luminosity);
286 <  allbgs->Add(allbgsb,-1);
287 <  allbgs->Add(allbgsc);
288 <  int ndata=puredata->Integral();
289 <  ofstream myfile;
290 <  myfile.open ("susyscan_log.txt");
291 <  TFile *susyscanfile = new TFile("/scratch/fronga/SMS/T5z_SqSqToQZQZ_38xFall10.root");
292 <  TTree *suevents = (TTree*)susyscanfile->Get("events");
293 <  TH2F *exclusionmap = new TH2F("exclusionmap","",20,0,500,20,0,1000);
294 <  TH2F *exclusionmap1s = new TH2F("exclusionmap1s","",20,0,500,20,0,1000);
295 <  TH2F *exclusionmap2s = new TH2F("exclusionmap2s","",20,0,500,20,0,1000);
296 <  TH2F *exclusionmap3s = new TH2F("exclusionmap3s","",20,0,500,20,0,1000);
297 <  
298 <  susy_scan_axis_labeling(exclusionmap);
299 <  susy_scan_axis_labeling(exclusionmap1s);
300 <  susy_scan_axis_labeling(exclusionmap2s);
301 <  susy_scan_axis_labeling(exclusionmap3s);
302 <  
303 <  Int_t MyPalette[100];
304 <  Double_t r[]    = {0., 0.0, 1.0, 1.0, 1.0};
305 <  Double_t g[]    = {0., 0.0, 0.0, 1.0, 1.0};
306 <  Double_t b[]    = {0., 1.0, 0.0, 0.0, 1.0};
307 <  Double_t stop[] = {0., .25, .50, .75, 1.0};
308 <  Int_t FI = TColor::CreateGradientColorTable(5, stop, r, g, b, 100);
309 <  for (int i=0;i<100;i++) MyPalette[i] = FI+i;
310 <  
311 <  gStyle->SetPalette(100, MyPalette);
312 <  
313 <  for(int m23=50;m23<500;m23+=25) {
314 <    for (int m0=(2*(m23-50)+150);m0<=1000;m0+=50)
315 <    {
316 <      c3->cd();
317 <      stringstream drawcondition;
318 <      drawcondition << "pfJetGoodNum>=3&&(TMath::Abs(masses[0]-"<<m0<<")<10&&TMath::Abs(masses[2]-masses[3]-"<<m23<<")<10)&&mll>5&&id1==id2";
319 <      TH1F *puresignal = new TH1F("puresignal","puresignal",binning.size()-1,arrbinning);
320 <      TH1F *puresignall= new TH1F("puresignall","puresignal",binning.size()-1,arrbinning);
321 <      stringstream drawvar,drawvar2;
322 <      drawvar<<mcjzb<<">>puresignal";
323 <      drawvar2<<"-"<<mcjzb<<">>puresignall";
324 <      suevents->Draw(drawvar.str().c_str(),drawcondition.str().c_str());
325 <      suevents->Draw(drawvar2.str().c_str(),drawcondition.str().c_str());
326 <      if(puresignal->Integral()<60) {
327 <        delete puresignal;
328 <        continue;
329 <      }
330 <      puresignal->Add(puresignall,-1);//we need to correct for the signal contamination - we effectively only see (JZB>0)-(JZB<0) !!
331 <      puresignal->Scale(ndata/(20*puresignal->Integral()));//normalizing it to 5% of the data
332 <      stringstream saveas;
333 <      saveas<<"Model_Scan/m0_"<<m0<<"__m23_"<<m23;
334 <      dout << "PLEASE KEEP IN MIND THAT SIGNAL CONTAMINATION IS NOT REALLY TAKEN CARE OF YET DUE TO LOW STATISTICS! SHOULD BE SOMETHING LIKE THIS : "<< endl;
335 < //        TH1F *signalpredlo   = allsamples.Draw("signalpredlo",  "-"+mcjzb,  binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc,  luminosity,allsamples.FindSample("LM4"));
336 < //        TH1F *signalpredro   = allsamples.Draw("signalpredro",      mcjzb,  binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc,  luminosity,allsamples.FindSample("LM4"));
337 < //        TH1F *puredata       = allsamples.Draw("puredata",          datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
338 < //        signalpred->Add(signalpredlo,-1);
339 < //        signalpred->Add(signalpredro);
340 < //        puresignal->Add(signalpred,-1);//subtracting signal contamination
341 < //---------------------
342 < //      dout << "(m0,m23)=("<<m0<<","<<m23<<") contains " << puresignal->Integral() << endl;
343 < //    TH1F *puresignal = allsamples.Draw("puresignal",mcjzb,  binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc,  luminosity,allsamples.FindSample("LM4"));
344 <      vector<float> results=establish_upper_limits(puredata,allbgs,puresignal,saveas.str(),myfile);  
345 <      if(results.size()==0) {
346 <        delete puresignal;
347 <        continue;
348 <      }
349 <      exclusionmap->Fill(m23,m0,results[0]);
350 <      exclusionmap1s->Fill(m23,m0,results[1]);
351 <      exclusionmap2s->Fill(m23,m0,results[2]);
352 <      exclusionmap3s->Fill(m23,m0,results[3]);
353 <      delete puresignal;
354 <      dout << "(m0,m23)=("<<m0<<","<<m23<<") : 3 sigma at " << results[3] << endl;
355 <    }
356 <  }//end of model scan for loop
357 <  
358 <  dout << "Exclusion Map contains" << exclusionmap->Integral() << " (integral) and entries: " << exclusionmap->GetEntries() << endl;
359 <  c3->cd();
360 <  exclusionmap->Draw("CONTZ");
361 <  CompleteSave(c3,"Model_Scan/CONT/Model_Scan_Mean_values");
362 <  exclusionmap->Draw("COLZ");
363 <  CompleteSave(c3,"Model_Scan/COL/Model_Scan_Mean_values");
364 <  
365 <  exclusionmap1s->Draw("CONTZ");
366 <  CompleteSave(c3,"Model_Scan/CONT/Model_Scan_1sigma_values");
367 <  exclusionmap1s->Draw("COLZ");
368 <  CompleteSave(c3,"Model_Scan/COL/Model_Scan_1sigma_values");
369 <  
370 <  exclusionmap2s->Draw("CONTZ");
371 <  CompleteSave(c3,"Model_Scan/CONT/Model_Scan_2sigma_values");
372 <  exclusionmap2s->Draw("COLZ");
373 <  CompleteSave(c3,"Model_Scan/COL/Model_Scan_2sigma_values");
374 <  
375 <  exclusionmap3s->Draw("CONTZ");
376 <  CompleteSave(c3,"Model_Scan/CONT/Model_Scan_3sigma_values");
377 <  exclusionmap3s->Draw("COLZ");
378 <  CompleteSave(c3,"Model_Scan/COL/Model_Scan_3sigma_values");
379 <  
380 <  TFile *exclusion_limits = new TFile("exclusion_limits.root","RECREATE");
381 <  exclusionmap->Write();
382 <  exclusionmap1s->Write();
383 <  exclusionmap2s->Write();
384 <  exclusionmap3s->Write();
385 <  exclusion_limits->Close();
386 <  susyscanfile->Close();
387 <  
388 <  myfile.close();
389 < }
380 >
381 > /********************************************************************** new : Limits using SHAPES ***********************************
382  
383  
384 +   SSSSSSSSSSSSSSS hhhhhhh                                                                                      
385 + SS:::::::::::::::Sh:::::h                                                                                      
386 + S:::::SSSSSS::::::Sh:::::h                                                                                      
387 + S:::::S     SSSSSSSh:::::h                                                                                      
388 + S:::::S             h::::h hhhhh         aaaaaaaaaaaaa  ppppp   ppppppppp       eeeeeeeeeeee        ssssssssss  
389 + S:::::S             h::::hh:::::hhh      a::::::::::::a p::::ppp:::::::::p    ee::::::::::::ee    ss::::::::::s  
390 + S::::SSSS          h::::::::::::::hh    aaaaaaaaa:::::ap:::::::::::::::::p  e::::::eeeee:::::eess:::::::::::::s
391 +  SS::::::SSSSS     h:::::::hhh::::::h            a::::app::::::ppppp::::::pe::::::e     e:::::es::::::ssss:::::s
392 +    SSS::::::::SS   h::::::h   h::::::h    aaaaaaa:::::a p:::::p     p:::::pe:::::::eeeee::::::e s:::::s  ssssss
393 +       SSSSSS::::S  h:::::h     h:::::h  aa::::::::::::a p:::::p     p:::::pe:::::::::::::::::e    s::::::s      
394 +            S:::::S h:::::h     h:::::h a::::aaaa::::::a p:::::p     p:::::pe::::::eeeeeeeeeee        s::::::s  
395 +            S:::::S h:::::h     h:::::ha::::a    a:::::a p:::::p    p::::::pe:::::::e           ssssss   s:::::s
396 + SSSSSSS     S:::::S h:::::h     h:::::ha::::a    a:::::a p:::::ppppp:::::::pe::::::::e          s:::::ssss::::::s
397 + S::::::SSSSSS:::::S h:::::h     h:::::ha:::::aaaa::::::a p::::::::::::::::p  e::::::::eeeeeeee  s::::::::::::::s
398 + S:::::::::::::::SS  h:::::h     h:::::h a::::::::::aa:::ap::::::::::::::pp    ee:::::::::::::e   s:::::::::::ss  
399 + SSSSSSSSSSSSSSS    hhhhhhh     hhhhhhh  aaaaaaaaaa  aaaap::::::pppppppp        eeeeeeeeeeeeee    sssssssssss    
400 +                                                         p:::::p                                                
401 +                                                         p:::::p                                                
402 +                                                        p:::::::p                                                
403 +                                                        p:::::::p                                                
404 +                                                        p:::::::p                                                
405 +                                                        ppppppppp                                                
406 +                                                                                                                
407 +
408 + *********************************************************************** new : Limits using SHAPES ***********************************/
409  
393
394 //********************************************************************** new : Limits using SHAPES ***********************************
410  
411   void limit_shapes_for_systematic_effect(TFile *limfile, string identifier, string mcjzb, string datajzb, int JES,vector<float> binning, TCanvas *limcan) {
412    dout << "Creatig shape templates ... ";
413    if(identifier!="") dout << "for systematic called "<<identifier;
414    dout << endl;
415    int dataormc=mcwithsignal;//this is only for tests - for real life you want dataormc=data !!!
416 <  if(dataormc!=data) write_warning("limit_shapes_for_systematic_effect","WATCH OUT! Not using data for limits!!!! this is ok for tests, but not ok for anything official!");
416 >  if(dataormc!=data) write_warning(__FUNCTION__,"WATCH OUT! Not using data for limits!!!! this is ok for tests, but not ok for anything official!");
417    
418    TCut limitnJetcut;
419    if(JES==noJES) limitnJetcut=cutnJets;
# Line 498 | Line 513 | void prepare_datacard(TFile *f) {
513  
514   ofstream datacard;
515   ensure_directory_exists(get_directory()+"/limits");
516 < datacard.open ((get_directory()+"/limits/susylm4datacard.txt").c_str());
516 > datacard.open ((get_directory()+"/limits/susydatacard.txt").c_str());
517   datacard << "Writing this to a file.\n";
518   datacard << "imax 1\n";
519   datacard << "jmax 1\n";
# Line 534 | Line 549 | void prepare_limits(string mcjzb, string
549    limit_shapes_for_systematic_effect(limfile,"JESDown",mcjzb,datajzb,JESdown,jzbbins,limcan);
550    
551    prepare_datacard(limfile);
537  
538  write_info("prepare_limits","limitfile.root and datacard.txt have been generated. You can now use them to calculate limits!");
552    limfile->Close();
553 +  write_info("prepare_limits","limitfile.root and datacard.txt have been generated. You can now use them to calculate limits!");
554    
555 < }
555 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines