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

Comparing UserCode/cbrown/Development/Plotting/Modules/LimitCalculation.C (file contents):
Revision 1.2 by buchmann, Thu Mar 15 20:35:39 2012 UTC vs.
Revision 1.6 by buchmann, Mon Apr 30 08:39:09 2012 UTC

# Line 55 | Line 55 | void rediscover_the_top(string mcjzb, st
55    TH1F *puresignal     = allsamples.Draw("puresignal",    datajzb,  binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,  luminosity);
56   //  TH1F *puresignal     = allsamples.Draw("puresignal",        mcjzb,  binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc,  luminosity,allsamples.FindSample("TTJets"));
57    TH1F *observed       = allsamples.Draw("observed",          datajzb,binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data,luminosity);
58 <  /*
58 >  
59    ofstream myfile;
60    TH1F *ratio = (TH1F*)observed->Clone();
61    ratio->Divide(dataprediction);
# Line 148 | Line 148 | ratio_binning.push_back(80);
148    TH1F *datapredictiontbo = allsamples.Draw("datapredictiontbo",    "-"+datajzb, ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data,  luminosity);
149    datapredictiontb->Add(datapredictiontbo,-1);
150    TH1F *analytical_background_predictionb = allsamples.Draw("analytical_background_predictionb",datajzb, ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"mll<2",data,  luminosity);
151 <  for(int i=0;i<=ratio_binning.size();i++) {
151 >  for(int i=0;i<=(int)ratio_binning.size();i++) {
152      analytical_background_predictionb->SetBinContent(i+1,functions[1]->Eval(analytical_background_predictionb->GetBinCenter(i)));
153      analytical_background_predictionb->SetBinError(i+1,TMath::Sqrt(functions[1]->Eval(analytical_background_predictionb->GetBinCenter(i))));
154    }
# Line 156 | Line 156 | ratio_binning.push_back(80);
156    TH1F *ratio = (TH1F*) observedtb->Clone();
157    ratio->Divide(datapredictiontb);
158    
159 <  for (int i=0;i<=ratio_binning.size();i++) {
159 >  for (int i=0;i<=(int)ratio_binning.size();i++) {
160      dout << observedtb->GetBinLowEdge(i+1) << ";"<<observedtb->GetBinContent(i+1) << ";" << datapredictiontb->GetBinContent(i+1) << " --> " << ratio->GetBinContent(i+1) << "+/-" << ratio->GetBinError(i+1) << endl;
161    }
162    
# Line 184 | Line 184 | ratio_binning.push_back(80);
184   }
185  
186   vector<float> compute_one_upper_limit(float mceff,float mcefferr, int ibin, string mcjzb, string plotfilename, bool doexpected, int flipped, bool doasymptotic=false) {
187 <  float sigma95=-9.9,sigma95A=-9.9;
187 >  float sigma95=-9.9;
188   /*
189   USAGE OF ROOSTATS_CL95
190   " Double_t             limit = roostats_cl95(ilum, slum, eff, seff, bck, sbck, n, gauss = false, nuisanceModel, method, plotFileName, seed); \n"
# Line 207 | Line 207 | USAGE OF ROOSTATS_CL95
207      sigmas.push_back(-1);
208      return sigmas;
209    } else {
210    int nlimittoysused=1;
211    
210      ///------------------------------------------ < NEW > ----------------------------------------------------------
211      
212      int secondssince1970=time(NULL);
# Line 228 | Line 226 | USAGE OF ROOSTATS_CL95
226  
227    if(flipped==0) dout << "Calling limit capsule instead of calling : CL95(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << Npred[ibin] << "," << Nprederr[ibin] << "," << Nobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl;
228    if(flipped>0) dout << "Calling limit capsule instead of calling : CL95(" << luminosity << "," <<  lumiuncert*luminosity << "," << mceff << "," << mcefferr << "," << flippedNpred[ibin] << "," << flippedNprederr[ibin] << "," << flippedNobs[ibin] << "," << false << "," << nuisancemodel<< ") " << endl;
229 +  
230 +  stringstream command;
231 +  if(flipped==0) command << PlottingSetup::cbafbasedir << "/DistributedModelCalculations/Limits/TimedLimitCapsule.exec " << repname.str() << " " << luminosity << " " << luminosity*lumiuncert << " " << mceff << " " << mcefferr << " " << Npred[ibin] << " " << Nprederr[ibin] << " " << Nobs[ibin] << " " << -1 << " " << PlottingSetup::basedirectory << "/" << plotfilename << " " << doexpected << " " << doasymptotic;
232 +  if(flipped>0) command << PlottingSetup::cbafbasedir << "/DistributedModelCalculations/Limits/TimedLimitCapsule.exec " << repname.str() << " " << luminosity << " " << luminosity*lumiuncert << " " << mceff << " " << mcefferr << " " << flippedNpred[ibin] << " " << flippedNprederr[ibin] << " " << flippedNobs[ibin] << " " << -1 << " " << PlottingSetup::basedirectory << "/" << plotfilename << " " << doexpected<< " " << doasymptotic;
233 +  
234 +  dout << command.str() << endl;
235      
236 <    stringstream command;
237 <    if(flipped==0) command << PlottingSetup::cbafbasedir << "/DistributedModelCalculations/Limits/TimedLimitCapsule.exec " << repname.str() << " " << luminosity << " " << luminosity*lumiuncert << " " << mceff << " " << mcefferr << " " << Npred[ibin] << " " << Nprederr[ibin] << " " << Nobs[ibin] << " " << -1 << " " << PlottingSetup::basedirectory << "/" << plotfilename << " " << doexpected << " " << doasymptotic;
238 <    if(flipped>0) command << PlottingSetup::cbafbasedir << "/DistributedModelCalculations/Limits/TimedLimitCapsule.exec " << repname.str() << " " << luminosity << " " << luminosity*lumiuncert << " " << mceff << " " << mcefferr << " " << flippedNpred[ibin] << " " << flippedNprederr[ibin] << " " << flippedNobs[ibin] << " " << -1 << " " << PlottingSetup::basedirectory << "/" << plotfilename << " " << doexpected<< " " << doasymptotic;
239 <    dout << command.str() << endl;
240 <    
237 <    int retval = 256;
238 <    int attempts=0;
239 <    while(!(retval==0||attempts>=3)) {//try up to 3 times
236 >  if(doasymptotic) write_warning(__FUNCTION__, "DOING ASYMPTOTIC LIMIT!");
237 >  
238 >  int retval = 256;
239 >  int attempts=0;
240 >  while(!(retval==0||attempts>=3)) {//try up to 3 times
241          attempts++;
242          dout << "Starting limit calculation (TimedLimitCapsule) now : Attempt " << attempts << endl;
243          retval=gSystem->Exec(command.str().c_str());
# Line 255 | Line 256 | USAGE OF ROOSTATS_CL95
256      remove(repname.str().c_str());
257      sigma95=limres.observed;
258  
258    
259      ///------------------------------------------ < /NEW > ----------------------------------------------------------
260    vector<float> sigmas;
261    sigmas.push_back(sigma95);
# Line 279 | Line 279 | vector<float> compute_upper_limits_from_
279    vector<vector<float> > vlimits;
280    
281    
282 <  for(int isample=0;isample<signalsamples.collection.size();isample++) {
282 >  for(int isample=0;isample<(int)signalsamples.collection.size();isample++) {
283      vector<string> rows;
284      vector<float> vrows;
285      dout << "Considering sample " << signalsamples.collection[isample].samplename << endl;
286      rows.push_back(signalsamples.collection[isample].samplename);
287 <    for(int ibin=0;ibin<jzbcuts.size();ibin++) {
287 >    for(int ibin=0;ibin<(int)jzbcuts.size();ibin++) {
288        dout << "_________________________________________________________________________________" << endl;
289        float JZBcutat=uncertainties[isample*jzbcuts.size()+ibin][0];
290        float mceff=uncertainties[isample*jzbcuts.size()+ibin][1];
291        float staterr=uncertainties[isample*jzbcuts.size()+ibin][2];
292        float systerr=uncertainties[isample*jzbcuts.size()+ibin][3];
293        float toterr =uncertainties[isample*jzbcuts.size()+ibin][4];
294 <      float observed,observederr,null,result;
294 > //      float observed,observederr,null,result;
295        
296        string plotfilename=(string)(TString(signalsamples.collection[isample].samplename)+TString("___JZB_geq_")+TString(any2string(JZBcutat))+TString(".png"));
297        dout << "Sample: " << signalsamples.collection[isample].samplename << ", JZB>"<<JZBcutat<< " : " << mceff << " +/- " << staterr << " (stat) +/- " << systerr << " (syst) --> toterr = " << toterr << endl;
# Line 322 | Line 322 | vector<float> compute_upper_limits_from_
322  
323    dout << endl << endl << "_______________________________________________________________________________________" << endl;
324    dout << "Going to store upper limit on event yield in result library: " << endl;
325 <  for(int ibin=0;ibin<jzbcuts.size();ibin++) {
325 >  for(int ibin=0;ibin<(int)jzbcuts.size();ibin++) {
326        int resultindex=PlottingSetup::allresults.Find(jzbcuts[ibin]);
327        vector<float> Normsigmas = compute_one_upper_limit(1.0,0.0, resultindex, mcjzb, "UPPERLIMIT", false, 0);
328        (allresults.predictions[resultindex]).UpperLimit=Normsigmas[0]*PlottingSetup::luminosity;
# Line 332 | Line 332 | vector<float> compute_upper_limits_from_
332    dout << endl << endl << endl << "_________________________________________________________________________________________________" << endl << endl;
333    dout << endl << endl << "PAS table 3:   (notation: limit [95%CL])" << endl << endl;
334    dout << "\t";
335 <  for (int irow=0;irow<jzbcuts.size();irow++) {
335 >  for (int irow=0;irow<(int)jzbcuts.size();irow++) {
336      dout << jzbcuts[irow] << "\t";
337    }
338    dout << endl;
339 <  for(int irow=0;irow<limits.size();irow++) {
340 <    for(int ientry=0;ientry<limits[irow].size();ientry++) {
339 >  for(int irow=0;irow<(int)limits.size();irow++) {
340 >    for(int ientry=0;ientry<(int)limits[irow].size();ientry++) {
341        if (limits[irow][ientry]>0) dout << limits[irow][ientry] << "\t";
342        else dout << " (N/A) \t";
343      }
# Line 352 | Line 352 | vector<float> compute_upper_limits_from_
352      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;
353      tout << "" << endl;
354      tout << "\\begin{tabular}{ | l | ";
355 <    for (int irow=0;irow<jzbcuts.size();irow++) tout << " l |";
355 >    for (int irow=0;irow<(int)jzbcuts.size();irow++) tout << " l |";
356      tout << "} " << endl << " \\hline " << endl << "& \t ";
357 <    for (int irow=0;irow<jzbcuts.size();irow++) {
357 >    for (int irow=0;irow<(int)jzbcuts.size();irow++) {
358        tout << "JZB $>$ " << jzbcuts[irow] << " GeV & \t ";
359      }
360      tout << " \\\\ \\hline " << endl;
361 <    for(int irow=0;irow<limits.size();irow++) {
361 >    for(int irow=0;irow<(int)limits.size();irow++) {
362        tout << limits[irow][0] << " \t";
363 <      for(int ientry=0;ientry<jzbcuts.size();ientry++) {
363 >      for(int ientry=0;ientry<(int)jzbcuts.size();ientry++) {
364          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";
365          else tout << " & ( N / A ) \t";
366   //      dout << Round(vlimits[irow][2*ientry],3) << " / " << Round(vlimits[irow][2*ientry+1],3)<< "\t";
# Line 376 | Line 376 | vector<float> compute_upper_limits_from_
376    
377    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;
378    dout << "Scenario \t Efficiency [%] \t Upper limits [pb] \t \\sigma [pb]" << endl;
379 <  for(int icut=0;icut<jzbcuts.size();icut++) {
379 >  for(int icut=0;icut<(int)jzbcuts.size();icut++) {
380      dout << "Region with JZB>" << jzbcuts[icut] << (ConsiderSignalContaminationForLimits?"  (accounting for signal contamination)":"  (not accounting for signal contamination)") << endl;
381 <    for(int isample=0;isample<signalsamples.collection.size();isample++) {
381 >    for(int isample=0;isample<(int)signalsamples.collection.size();isample++) {
382        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;
383      }
384      dout << endl;
# Line 388 | Line 388 | vector<float> compute_upper_limits_from_
388    //---------------------------------------------
389    
390    vector<float> lowestULs;
391 <  for(int isample=0;isample<signalsamples.collection.size();isample++) {
391 >  for(int isample=0;isample<(int)signalsamples.collection.size();isample++) {
392      float lowestUL=-1;
393 <    for(int icut=0;icut<jzbcuts.size();icut++) {
393 >    for(int icut=0;icut<(int)jzbcuts.size();icut++) {
394        float currUL=Round((vlimits[isample][2*icut]),3);
395        if(currUL>0) {
396          if(lowestUL<0) lowestUL=currUL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines