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

Comparing UserCode/cbrown/AnalysisFramework/Plotting/Modules/ExclusionPlot.C (file contents):
Revision 1.12 by buchmann, Tue Nov 29 11:44:36 2011 UTC vs.
Revision 1.13 by buchmann, Mon Dec 5 14:26:51 2011 UTC

# Line 46 | Line 46 | void set_range(TH2F *histo, int scantype
46   void smooth_line(TGraph *gr);
47   void decorate_mSUGRA(TH2F *cleanhisto, TVirtualPad *cvsSys,TGraph *expected,TGraph *expected2,TGraph *observed);
48   TH2F* adjust_histo(TH2F *oldhist, TH2F *refhisto);
49 + TGraph* get_mSUGRA_exclusion_line(TH2F *exclusionhisto, int scantype);
50 + TGraph* thin_line(TGraph *gr);
51 + TGraph *MarcosExclusionLine(TH2F *exclusionshape, int scantype);
52  
53 < void fill_with_text(TH2F *real, TH2F *down, TH2F *up, TVirtualPad *can, int scantype) {
53 > void fill_with_text(TGraph *real, TGraph *down, TGraph *up, TVirtualPad *can, int scantype) {
54    can->cd();
55    TLegend* this_leg = new TLegend(0.18,0.6,0.38,0.75);
56    this_leg->SetFillColor(0);
# Line 65 | Line 68 | void fill_with_text(TH2F *real, TH2F *do
68    
69    string legT5zz="pp #rightarrow  #tilde{g} #tilde{g}, #tilde{g} #rightarrow 2j + #chi^{0}_{2}, #chi^{0}_{2} #rightarrow Z + LSP";
70    string legT5zzl2="m(#tilde{q}) >> m(#tilde{g})";
71 +  string legT5zzl3=" GMSB";
72    TText *title = write_text(0.18,0.85,legT5zz);
73    title->SetTextAlign(11);
74    title->SetTextSize(0.035);
# Line 73 | Line 77 | void fill_with_text(TH2F *real, TH2F *do
77    title2->SetTextAlign(11);
78    title2->SetTextSize(0.035);
79    if(scantype!=PlottingSetup::mSUGRA) title2->Draw("same");
80 +  TText *title3 = write_text(0.40,0.79,legT5zzl3);
81 +  title3->SetTextAlign(11);
82 +  title3->SetTextSize(0.035);
83 +  title3->SetTextColor(kRed);
84 + //  if(scantype==PlottingSetup::GMSB) title3->Draw("same");
85    DrawPrelim();
86    TLine *line;
87 <  line = new TLine(50.+75., 50., 1200., 1200-75.);
87 >  float verticaloffset=0.0;
88 >  if(scantype==PlottingSetup::GMSB) verticaloffset=75.0;
89 >  line = new TLine(50.+75.0, 50.0+verticaloffset, 1200., 1200.0-75.0+verticaloffset);
90    line->SetLineStyle(2);
91    line->SetLineWidth(2);
92    line->Draw("same");
# Line 108 | Line 119 | TH2F* make_exclusion_shape(TH2F *excl, i
119    return exclusion;
120   }
121  
122 < void produce_extensive_plots(TH2F *xsec,TH2F *limits,TH2F *exclusionshape,TH2F *exclusionshapet3,TH2F *exclusionshaped3, int scantype) {
122 > void produce_extensive_plots(TH2F *xsec,TH2F *limits,TH2F *rellimits, TH2F *rellimitsd3, TH2F *rellimitst3, int scantype) {
123    TCanvas *ca = new TCanvas("ca","ca",1200,1200);
124    ca->Divide(2,2);
125    ca->cd(1);
# Line 139 | Line 150 | void produce_extensive_plots(TH2F *xsec,
150  
151    limits->GetZaxis()->SetTitleOffset(0.95);
152    limits->GetZaxis()->CenterTitle();
142  exclusionshapet3->SetLineStyle(2);
143  exclusionshaped3->SetLineStyle(3);
144  exclusionshape->GetZaxis()->SetRangeUser(0,500*0.1);
145  exclusionshapet3->GetZaxis()->SetRangeUser(0,500*0.1);
146  exclusionshaped3->GetZaxis()->SetRangeUser(0,500*0.1);
153    limits->Draw("COLZ");
154 <  exclusionshape->Draw("CONT1,same");
155 <  exclusionshapet3->Draw("CONT1,same");
156 <  exclusionshaped3->Draw("CONT1,same");
154 >
155 >  TGraph *exclline = MarcosExclusionLine(rellimits, scantype);
156 >  TGraph *thinexclline = thin_line(exclline);
157 >
158 >  TGraph *excllinet3 = MarcosExclusionLine(rellimitst3, scantype);
159 >  excllinet3->SetLineStyle(2);
160 >  TGraph *thinexcllinet3 = thin_line(excllinet3);
161 >
162 >  TGraph *excllined3 = MarcosExclusionLine(rellimitsd3, scantype);
163 >  excllined3->SetLineStyle(3);
164 >  TGraph *thinexcllined3 = thin_line(excllined3);
165 >
166 >  ca->cd(4);
167 >  exclline->Draw();
168 >  thinexclline->Draw();
169 >  excllinet3->Draw();
170 >  thinexcllinet3->Draw();
171 >  excllined3->Draw();
172 >  thinexcllined3->Draw();
173    stringstream partial;
174    partial << "Limits/exclusion__" << limits->GetName();
175 <  fill_with_text(exclusionshape,exclusionshaped3,exclusionshapet3,ca->cd(4),scantype);
175 >  fill_with_text(exclline,excllined3,excllinet3,ca->cd(4),scantype);
176    CompleteSave(ca,partial.str());
177    delete ca;
178   }
179  
180 + bool fail(double xs, double xsLimit) {return xsLimit>1 or !xsLimit;}
181  
182 + void get_Marias_exclusion_line(TH2F *limit_ref, float pointsX[200], float pointsY[200], int &ixNew, int &counter, int &foundDiag) {
183 + // part of Mariarosaria's getRefXsecGraph function
184 +  double refMult = 3.0;
185 +  bool enough = false;
186 +  Int_t  nBinX= limit_ref->GetXaxis()->GetNbins();
187 +  Int_t  nBinY= limit_ref->GetYaxis()->GetNbins();
188 +  for(int i=1; i<(nBinX+1); i++) {
189 +    for(int j=1; j<(nBinY+1); j++) {
190 +      if( limit_ref->GetBinContent(i,j)>0. && limit_ref->GetBinContent(i,j)<=1.) {
191 +        double xsLimitAbove = limit_ref->GetBinContent(i, j+1);
192 +        double xsLimitBelow = limit_ref->GetBinContent(i, j-1);
193 +
194 +        double xsLimit = limit_ref->GetBinContent(i, j);
195 +        if((fail(1.0,xsLimitAbove)) && (!fail(1.0,xsLimit)) ) {
196 +          pointsX[counter]=limit_ref->GetXaxis()->GetBinCenter(i);
197 +          pointsY[counter]=limit_ref->GetYaxis()->GetBinCenter(j);
198 +          counter++;
199 +          enough = !xsLimitAbove;          
200 +          if(!enough && !foundDiag) foundDiag=counter;
201 + //                cout << "enough " << enough << " foundDiag " << foundDiag << endl;
202 +        }
203 +      }
204 +    }
205 +  }
206 +  
207 + }
208 +
209 + TH2F* flipth2f(TH2F *histo) {
210 +   if(histo->GetNbinsX()!=histo->GetNbinsY()) {
211 +        write_error(__FUNCTION__,"number of bins is not the same for x & y !!!");
212 +        return NULL;
213 +   }
214 +   TH2F *rethisto = (TH2F*)histo->Clone();
215 +   for(int i=1;i<histo->GetNbinsX();i++) {
216 +        for(int j=1;j<histo->GetNbinsY();j++) {
217 +                rethisto->SetBinContent(j,i,histo->GetBinContent(i,j));
218 +        }
219 +   }
220 +   return rethisto;
221 + }
222 +
223 + TGraph* get_exclusion_line(TH2F *limit_ref) {
224 +  
225 + float pointsX[200];
226 + float pointsY[200];
227 + int ixNew=0;
228 + int counter=0;
229 + int foundDiag=0;
230 +
231 + TH2F *fakehisto = flipth2f(limit_ref);
232 + get_Marias_exclusion_line(fakehisto,pointsY,pointsX,ixNew,counter,foundDiag);// x&y deliberately switched!
233 +  if(counter>1) {
234 +    pointsX[counter]=pointsX[counter-1];
235 +    pointsY[counter]=50;  
236 +  }
237 +
238 +  const int newCounter=counter;
239 +  Double_t newPointsX[newCounter+1];
240 +  Double_t newPointsY[newCounter+1];
241 +  
242 +  for (int ix = 0; ix < counter+1; ++ix) {
243 +    if(ix<(foundDiag-2)) continue;
244 +    if(ix!=counter && pointsX[ix+1]==pointsX[ix]) continue;
245 +   newPointsX[ixNew]=pointsX[ix];
246 +   newPointsY[ixNew]=pointsY[ix];
247 +   ixNew++;
248 +  }
249 +  string titleHisto="tester";
250 + //  sprintf(titleHisto,"graph_%s_%f",limit_ref->GetName(),refMult);
251 + //  cout << "HERE " << titleHisto << endl;
252 +
253 + TGraph * gr = new TGraph(ixNew,newPointsX,newPointsY);
254 + gr->SetName(titleHisto.c_str());
255 + gr->Draw("same");
256 + return gr;
257 + }
258 + TGraph *MarcosExclusionLine(TH2F *exclusionshape, int scantype) {
259 +  TH2F *fakehisto = flipth2f(exclusionshape);
260 +  TGraph *fakegraph = get_mSUGRA_exclusion_line(fakehisto, scantype);
261 +  TGraph *realgraph = new TGraph(fakegraph->GetN());
262 +  double x,y;
263 +  for(int i=0;i<fakegraph->GetN();i++) {
264 +        fakegraph->GetPoint(i,x,y);
265 +        realgraph->SetPoint(i,y,x);
266 +  }
267 +  realgraph->SetLineColor(TColor::GetColor("#2E2EFE")); //dark blue
268 +  realgraph->SetLineWidth(3);
269 +
270 +  return realgraph;
271 + }
272 +  
273 + TGraph* thin_line(TGraph *gr) {
274 +  TGraph *thin = (TGraph*) gr->Clone(concatenate("thin",gr->GetTitle()));
275 +  thin->SetLineWidth(1);
276 +  thin->SetLineColor(kWhite);
277 +  return thin;
278 + }
279  
280   void make_SMS_exclusion(TH2F *rawlimits,TH2F *xsec,int scantype) {
281    TH2F *limits = prep_histo(rawlimits,scantype); // this is to be independent of the style used at creation time
# Line 180 | Line 300 | void make_SMS_exclusion(TH2F *rawlimits,
300    }
301    
302  
303 <  TH2F *exclusionshape = make_exclusion_shape(rellimits,1);
304 <  TH2F *exclusionshapet3 = make_exclusion_shape(rellimitst3,2);
305 <  TH2F *exclusionshaped3 = make_exclusion_shape(rellimitsd3,3);
303 > //  TH2F *exclusionshape = make_exclusion_shape(rellimits,1);
304 > //  TH2F *exclusionshapet3 = make_exclusion_shape(rellimitst3,2);
305 > //  TH2F *exclusionshaped3 = make_exclusion_shape(rellimitsd3,3);
306    
307    //Now let's produce the plots!
308    
309    set_range(xsec,scantype,false);
310    set_range(limits,scantype,false);
311 <  set_range(exclusionshape,scantype,false);
312 <  set_range(exclusionshaped3,scantype,false);
313 <  set_range(exclusionshapet3,scantype,false);
314 <  
315 <  produce_extensive_plots(xsec,limits,exclusionshape,exclusionshapet3,exclusionshaped3,scantype);
311 >
312 >  TGraph *exclline = MarcosExclusionLine(rellimits, scantype);
313 >  TGraph *thinexcline = thin_line(exclline);
314 >
315 >  TGraph *excllinet3 = MarcosExclusionLine(rellimitst3, scantype);
316 >  excllinet3->SetLineStyle(2);
317 >  TGraph *thinexclinet3 = thin_line(excllinet3);
318 >
319 >  TGraph *excllined3 = MarcosExclusionLine(rellimitsd3, scantype);
320 >  excllined3->SetLineStyle(3);
321 >  TGraph *thinexclined3 = thin_line(excllined3);
322 >
323 >  produce_extensive_plots(xsec,limits,rellimits, rellimitst3, rellimitsd3,scantype);
324    
325    TCanvas *finalcanvas = new TCanvas("finalcanvas","finalcanvas");
326    finalcanvas->SetLogz(1);
327    finalcanvas->cd();
328    limits->Draw("COLZ");
329 <  exclusionshape->Draw("CONT1,same");
330 <  exclusionshapet3->Draw("CONT1,same");
203 <  exclusionshaped3->Draw("CONT1,same");
329 >
330 >
331    TLine *desertline;
332    if(drawefficiencydesertline) {
333          desertline = new TLine(375,50,1200,875);
# Line 209 | Line 336 | void make_SMS_exclusion(TH2F *rawlimits,
336          desertline->Draw("same");
337    }
338  
339 <  fill_with_text(exclusionshape,exclusionshaped3,exclusionshapet3,finalcanvas,scantype);
339 >  fill_with_text(exclline,excllined3,excllinet3,finalcanvas,scantype);
340    stringstream real;
341    real << "Limits/final_exclusion__" << limits->GetName();
342 +  exclline->Draw("");
343 +  thinexcline->Draw("");
344 +  excllinet3->Draw("");
345 +  thinexclinet3->Draw("");
346 +  excllined3->Draw("");
347 +  thinexclined3->Draw("");
348    CompleteSave(finalcanvas,real.str());
349  
350    delete finalcanvas;
# Line 329 | Line 462 | pair <float,float> find_interpolated_poi
462    return anything;
463   }
464  
465 < TGraph* get_exclusion_line(TH2F *exclusionhisto) {
465 > void project_to_last_point_on_line(float x2, float y2, float x1, float y1, float &x, float &y, int scantype) {
466 >  float deltax=x2-x1;
467 >  float deltay=y2-y1;
468 >  float b = (y1-x1)/(deltax-deltay);
469 >  if(scantype==PlottingSetup::SMS) b = (y1-75.-x1)/(deltax-deltay);
470 >  x = x1 + b * deltax;
471 >  y = y1 + b * deltay;
472 >  if(x<0||y<0) x=-1;
473 >  if((scantype==PlottingSetup::GMSB||scantype==PlottingSetup::SMS) && (x>PlottingSetup::mgluend||y>PlottingSetup::mLSPend)) x=-1;
474 > }
475 >
476 > TGraph* get_mSUGRA_exclusion_line(TH2F *exclusionhisto, int scantype) {
477    exclusionhisto->SetStats(0);
478    exclusionhisto->GetZaxis()->SetRangeUser(0,2);
479  
# Line 340 | Line 484 | TGraph* get_exclusion_line(TH2F *exclusi
484      pair<float,float> intthing = find_interpolated_point(exclusionhisto,i);
485      float value=anything.second;
486      if(intthing.second>anything.second) anything.second=intthing.second;
487 <    if(anything.second>100&&anything.second<1000) points.push_back(anything);
487 >    if(anything.second>100&&anything.second<1500) points.push_back(anything);
488    }
489    
490    Double_t xpoints[points.size()];
491    Double_t spoints[points.size()];
492    
493 <  TGraph *graph = new TGraph(points.size());
493 >  TGraph *graph = new TGraph(points.size()+1);
494    graph->SetLineColor(kBlack);
495    graph->SetLineWidth(2);
496    
497 +  int pointcounter=0;
498 +  float lastx=0;
499 +  float lasty=0;
500 +  float lastx2=0;
501 +  float lasty2=0;
502 +  
503    for(int i=0;i<points.size();i++) {
504      xpoints[i]=points[i].first;
505 <    if(i>1&&i<points.size()-1) spoints[i]=(1.0/3.0)*(points[i-1].second+points[i].second+points[i+1].second);
506 <    if(i>2&&i<points.size()-2) spoints[i]=(1.0/5.0)*(points[i-2].second+points[i-1].second+points[i].second+points[i+1].second+points[i+2].second);
507 <    if(i>3&&i<points.size()-3) spoints[i]=(1.0/7.0)*(points[i-3].second+points[i-2].second+points[i-1].second+points[i].second+points[i+1].second+points[i+2].second+points[i+3].second);
508 <    else spoints[i]=points[i].second;
509 <    graph->SetPoint(i,points[i].first,spoints[i]);
505 >    spoints[i]=points[i].second;
506 >    if(scantype==PlottingSetup::mSUGRA) {
507 >        if(i>1&&i<points.size()-1) spoints[i]=(1.0/3.0)*(points[i-1].second+points[i].second+points[i+1].second);
508 >        if(i>2&&i<points.size()-2) spoints[i]=(1.0/5.0)*(points[i-2].second+points[i-1].second+points[i].second+points[i+1].second+points[i+2].second);
509 >        if(i>3&&i<points.size()-3) spoints[i]=(1.0/7.0)*(points[i-3].second+points[i-2].second+points[i-1].second+points[i].second+points[i+1].second+points[i+2].second+points[i+3].second);
510 >    }
511 >
512 >    bool usethispoint=true;
513 >    if(scantype==PlottingSetup::GMSB) {
514 >        if(spoints[i]<points[i].first) usethispoint=false;
515 >    }
516 >    if(scantype==PlottingSetup::SMS) {
517 >        if(spoints[i]-50.<points[i].first) usethispoint=false;
518 >    }
519 >    if((scantype==PlottingSetup::GMSB||scantype==PlottingSetup::SMS) && (spoints[i]>PlottingSetup::mgluend||points[i].first>PlottingSetup::mLSPend)) usethispoint=false;
520 >
521 >    if(usethispoint) {
522 >        graph->SetPoint(pointcounter,points[i].first,spoints[i]);
523 >        lastx2=lastx;
524 >        lasty2=lasty;
525 >        lastx=points[i].first;
526 >        lasty=spoints[i];
527 >        pointcounter++;
528 >    }
529    }
530 +  for(int i=pointcounter;i<points.size();i++) graph->SetPoint(i,lastx,lasty);
531 +  if(scantype==PlottingSetup::GMSB||scantype==PlottingSetup::SMS) {
532 +        //The final point will be a continuation of the last one, towards the diagonal
533 +        float x,y;
534 +        project_to_last_point_on_line(lastx,lasty,lastx2,lasty2,x,y,scantype);
535 +        if(x>0) graph->SetPoint(points.size(),x,y);
536 +        else graph->SetPoint(points.size(),lastx,lasty);
537 +  }
538 +
539    return graph;
540   }
541  
# Line 377 | Line 555 | void draw_mSUGRA_exclusion(TH2F *crossse
555    exp2minusmap->Divide(crosssection);
556    exp2plusmap->Divide(crosssection);
557    expmap->Divide(crosssection);
558 <  TGraph *observed = get_exclusion_line(limitmap);
558 >  TGraph *observed = get_mSUGRA_exclusion_line(limitmap, PlottingSetup::mSUGRA);
559    observed->SetLineColor(kRed);
560 <  TGraph *expminus = get_exclusion_line(expminusmap);
561 <  TGraph *expplus  = get_exclusion_line(expplusmap);
560 >  TGraph *expminus = get_mSUGRA_exclusion_line(expminusmap, PlottingSetup::mSUGRA);
561 >  TGraph *expplus  = get_mSUGRA_exclusion_line(expplusmap, PlottingSetup::mSUGRA);
562    TGraph *exp2minus;
563 <  if(draw2sigma) exp2minus = get_exclusion_line(exp2minusmap);
563 >  if(draw2sigma) exp2minus = get_mSUGRA_exclusion_line(exp2minusmap, PlottingSetup::mSUGRA);
564    TGraph *exp2plus;
565 <  if(draw2sigma) exp2plus = get_exclusion_line(exp2plusmap);
565 >  if(draw2sigma) exp2plus = get_mSUGRA_exclusion_line(exp2plusmap, PlottingSetup::mSUGRA);
566  
567    TGraph *expected = new TGraph(expminus->GetN()+expplus->GetN());
568    TGraph *expected2;
# Line 603 | Line 781 | void create_exclusion_plots(vector<TH2F*
781    vector<TH2F*> flipmaps;
782    vector<TH2F*> crosssections;
783    
606 cout << __LINE__ << endl;
784    for(int ilim=0;ilim<limits.size();ilim++) {
785      if(TString(limits[ilim]->GetName()).Contains("_explimitmap")) explimits.push_back(limits[ilim]);
786      if(scantype==PlottingSetup::mSUGRA && TString(limits[ilim]->GetName()).Contains("_exp1plimitmap")) exp1plimits.push_back(limits[ilim]);
# Line 832 | Line 1009 | void set_range(TH2F *histo, int scantype
1009      histo->GetXaxis()->SetRangeUser(100,1200);
1010      histo->GetYaxis()->SetRangeUser(100,1200);
1011      histo->GetXaxis()->SetTitle("m_{#tilde{g}} [GeV]");
1012 <    histo->GetYaxis()->SetTitle("m_{Chi} [GeV]");
1012 >    histo->GetYaxis()->SetTitle("m_{#chi} [GeV]");
1013      histo->GetXaxis()->SetTitleSize(0.04);
1014      histo->GetYaxis()->SetTitleSize(0.04);
1015      histo->GetZaxis()->SetTitleSize(0.04);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines