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.8 by buchmann, Wed Jul 27 12:16:15 2011 UTC vs.
Revision 1.19 by buchmann, Fri Sep 2 12:55:22 2011 UTC

# Line 168 | Line 168 | ratio_binning.push_back(80);
168    
169   }
170  
171 < vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, bool doobserved=false) {
172 <  float sigma95=0.0,sigma95A=0.0;
173 <  int nuisancemodel=1;
171 > vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, string plotfilename, bool doobserved) {
172 >  float sigma95=-9.9,sigma95A=-9.9;
173 >  int nuisancemodel=0;
174 > /*
175 > USAGE OF ROOSTATS_CL95
176 > " Double_t             limit = roostats_cl95(ilum, slum, eff, seff, bck, sbck, n, gauss = false, nuisanceModel, method, plotFileName, seed); \n"
177 > " LimitResult expected_limit = roostats_clm(ilum, slum, eff, seff, bck, sbck, ntoys, nuisanceModel, method, seed); \n"
178 > " Double_t     average_limit = roostats_cla(ilum, slum, eff, seff, bck, sbck, nuisanceModel, method, seed); \n"
179 > "                                                                     \n"
180 > "
181 > " Double_t obs_limit = limit.GetObservedLimit();                      \n"
182 > " Double_t exp_limit = limit.GetExpectedLimit();                      \n"
183 > " Double_t exp_up    = limit.GetOneSigmaHighRange();                  \n"
184 > " Double_t exp_down  = limit.GetOneSigmaLowRange();                   \n"
185 > " Double_t exp_2up   = limit.GetTwoSigmaHighRange();                  \n"
186 > " Double_t exp_2down = limit.GetTwoSigmaLowRange();                   \n"
187 > */
188 >  if(mceff<=0) {
189 >    write_warning(__FUNCTION__,"Cannot compute upper limit in this configuration as the efficiency is negative:");
190 >    dout << "mc efficiency=" << mceff << " +/- " << mcefferr;
191 >    vector<float> sigmas;
192 >    sigmas.push_back(-1);
193 >    sigmas.push_back(-1);
194 >    return sigmas;
195 >  } else {
196 >    int nlimittoysused=1;
197 >    //if(doobserved) nlimittoysused=nlimittoys;
198 >    nlimittoysused=nlimittoys;
199    dout << "Now calling : CL95(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl;
200    sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel);
201 +  sigma95 = CL95(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], Nobs[ibin], false, nuisancemodel);
202 +  
203 + /*  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;
204 + /*  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;
205 +  LimitResult limit = roostats_limit(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0);
206 +  dout << "Now interpreting and saving results ... " << endl;
207 +  vector<float> sigmas;
208 +  sigmas.push_back(limit.GetExpectedLimit());//expected
209 +  sigmas.push_back(limit.GetObservedLimit());//observed
210 +  //up to here for backward compatibility
211 +  sigmas.push_back(limit.GetOneSigmaHighRange());//expected, up
212 +  sigmas.push_back(limit.GetTwoSigmaHighRange());//expected, 2 up
213 +  sigmas.push_back(limit.GetOneSigmaLowRange());//expected, down
214 +  sigmas.push_back(limit.GetTwoSigmaLowRange());//expected, 2 down
215 + */
216 + //  float limit = roostats_cl95(luminosity,lumiuncert*luminosity,mceff,mcefferr,Npred[ibin],Nprederr[ibin],nlimittoysused,false,nuisancemodel,limitmethod,plotfilename,0);
217    if(doobserved) {
218 <    dout << "Now calling : CLA(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl;
219 <    sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel);
218 > write_warning(__FUNCTION__,"OBSERVED LIMITS HAVE BEEN SWITCHED OFF TEMPORARILY");
219 > //    dout << "Now calling : CLA(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << nuisancemodel<< ") " << endl;
220 > //    sigma95A = CLA(luminosity, lumiuncert*luminosity, mceff, mcefferr, Npred[ibin], Nprederr[ibin], nuisancemodel);
221    }
222 + //  vector<float> sigmas;
223 + //  sigmas.push_back(limit);
224    vector<float> sigmas;
225    sigmas.push_back(sigma95);
226    sigmas.push_back(sigma95A);
227    return sigmas;
228 +  
229 +
230 +  }
231 +  write_warning(__FUNCTION__,"STILL MISSING SIGMAS, LIMITS, EVERYTHING ...");
232   }
233  
234   void compute_upper_limits_from_counting_experiment(vector<vector<float> > uncertainties,vector<float> jzbcuts, string mcjzb, bool doobserved) {
# Line 201 | Line 249 | void compute_upper_limits_from_counting_
249        float staterr=uncertainties[isample*jzbcuts.size()+ibin][2];
250        float systerr=uncertainties[isample*jzbcuts.size()+ibin][3];
251        float toterr =uncertainties[isample*jzbcuts.size()+ibin][4];
252 <      float observed,null,result;
205 <      fill_result_histos(observed, null,null,null,null,null,null,null,mcjzb,JZBcutat,(int)5,result,(signalsamples.FindSample(signalsamples.collection[isample].filename)),signalsamples);
206 <      observed-=result;//this is the actual excess we see!
207 <      float expected=observed/luminosity;
252 >      float observed,observederr,null,result;
253        
254 + //      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);
255 + //      observed-=result;//this is the actual excess we see!
256 + //      float expected=observed/luminosity;
257 +      string plotfilename=(string)(TString(signalsamples.collection[isample].samplename)+TString("___JZB_geq_")+TString(any2string(JZBcutat))+TString(".png"));
258        dout << "Sample: " << signalsamples.collection[isample].samplename << ", JZB>"<<JZBcutat<< " : " << mceff << " +/- " << staterr << " (stat) +/- " << systerr << " (syst) --> toterr = " << toterr << endl;
259 <      vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,doobserved);
259 >      vector<float> sigmas = compute_one_upper_limit(mceff,toterr,ibin,mcjzb,plotfilename,doobserved);
260        
261        if(doobserved) {
262 <        rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")");
262 > //      rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(expected)+")");
263 >        rows.push_back(any2string(sigmas[0])+";"+any2string(sigmas[1])+";"+"("+any2string(signalsamples.collection[isample].xs)+")");
264          vrows.push_back(sigmas[0]);
265          vrows.push_back(sigmas[1]);
266 <        vrows.push_back(expected);
266 > //      vrows.push_back(expected);
267 >        vrows.push_back(signalsamples.collection[isample].xs);
268        }
269        else {
270 <        rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")");
270 > //      rows.push_back(any2string(sigmas[0])+"("+any2string(expected)+")");
271 >        rows.push_back(any2string(sigmas[0]));
272          vrows.push_back(sigmas[0]);
273 <        vrows.push_back(expected);
273 >        vrows.push_back(signalsamples.collection[isample].xs);
274 > //      vrows.push_back(expected);
275        }
276      }//end of bin loop
277      limits.push_back(rows);
278      vlimits.push_back(vrows);
279    }//end of sample loop
280 <  dout << endl << endl << "PAS table 3: " << endl << endl;
280 >  dout << endl << endl << endl << "_________________________________________________________________________________________________" << endl << endl;
281 >  dout << endl << endl << "PAS table 3:   (notation: limit [95%CL])" << endl << endl;
282    dout << "\t";
283    for (int irow=0;irow<jzbcuts.size();irow++) {
284      dout << jzbcuts[irow] << "\t";
# Line 232 | Line 286 | void compute_upper_limits_from_counting_
286    dout << endl;
287    for(int irow=0;irow<limits.size();irow++) {
288      for(int ientry=0;ientry<limits[irow].size();ientry++) {
289 <      dout << limits[irow][ientry] << "\t";
289 >      if (limits[irow][ientry]>0) dout << limits[irow][ientry] << "\t";
290 >      else dout << " (N/A) \t";
291      }
292      dout << endl;
293    }
294    
295    if(!doobserved) {
296 <    dout << endl << endl << "LIMITS: " << endl;
297 <    dout << "\t";
296 >    dout << endl << endl << "LIMITS: (Tex)" << endl;
297 >    tout << "\\begin{table}[hbtp]" << endl;
298 >    tout << "\\renewcommand{\arraystretch}{1.3}" << endl;
299 >    tout << "\\begin{center}" << endl;
300 >    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;
301 >    tout << "" << endl;
302 >    tout << "\\begin{tabular}{ | l | ";
303 >    for (int irow=0;irow<jzbcuts.size();irow++) tout << " l |";
304 >    tout << "} " << endl << " \\hline " << endl << "& \t ";
305      for (int irow=0;irow<jzbcuts.size();irow++) {
306 <      dout << jzbcuts[irow] << "\t";
306 >      tout << "JZB $>$ " << jzbcuts[irow] << " GeV & \t ";
307      }
308 <    dout << endl;
308 >    tout << " \\\\ \\hline " << endl;
309      for(int irow=0;irow<limits.size();irow++) {
310 <      dout << limits[irow][0] << "\t";
310 >      tout << limits[irow][0] << " \t";
311        for(int ientry=0;ientry<jzbcuts.size();ientry++) {
312 <        dout << Round(vlimits[irow][2*ientry] / vlimits[irow][2*ientry+1],3)<< "\t";
312 >        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";
313 >        else tout << " & ( N / A ) \t";
314 > //      dout << Round(vlimits[irow][2*ientry],3) << " / " << Round(vlimits[irow][2*ientry+1],3)<< "\t";
315        }
316 <      dout << endl;
316 >      tout << " \\\\ \\hline " << endl;
317      }
318 +      tout << "\\end{tabular}" << endl;
319 +      tout << "      \\end{tabular}"<< endl;
320 +      tout << "\\end{center}"<< endl;
321 +      tout << "\\end{table} "<< endl;
322 +
323    }//do observed
324    
325    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;
326 <  dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t Prediction [pb]" << endl;
326 >  dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t \\sigma [pb]" << endl;
327    for(int icut=0;icut<jzbcuts.size();icut++) {
328 <    dout << "Region with JZB>" << jzbcuts[icut] << endl;
328 >    dout << "Region with JZB>" << jzbcuts[icut] << (ConsiderSignalContaminationForLimits?"  (accounting for signal contamination)":"  (not accounting for signal contamination)") << endl;
329      for(int isample=0;isample<signalsamples.collection.size();isample++) {
330 <      dout << limits[isample][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;
330 >      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;
331      }
332      dout << endl;
333    }
334    
335 <  write_warning("compute_upper_limits_from_counting_experiment","Still need to update the script");
335 >  write_warning(__FUNCTION__,"Still need to update the script");
336   }
337  
338  
# Line 442 | Line 511 | void prepare_limits(string mcjzb, string
511    limfile->Close();
512    write_info("prepare_limits","limitfile.root and datacard.txt have been generated. You can now use them to calculate limits!");
513    
514 < }
514 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines