Marking cuts in histograms and stacks

Hi ROOT experts,

I want to mark in my TH1F histograms (and stacks) areas, which are cut away. Is there any way to do this without dealing with absolute coordinates on a canvas?

Thanks in advance,
Benedikt

Hi!

Is there nobody who could help me?

Cheers,
Benedikt

Could you be more precise about “to mark in my TH1F histograms (and stacks) areas, which are cut away” ?

Rene

Hi!

I do the following:

[...]
  TH1F *h1 = (TH1F*) file->Get("TruthSignalMuPt");
  h1->SetFillColor(kRed); // Set histogram fill color to red
  h1->SetFillStyle(3001);
  TH1F *h2 = (TH1F*) file->Get("TruthCascadeMuPt");
  h2->SetFillColor(kBlue);
  h2->SetFillStyle(3001);
  THStack hs("hs","test stacked histograms");
  hs.Add(h1);
  hs.Add(h2);
  hs.Draw();

Now I want to mark areas in that stack, which will be cut in a next step (e.g. Pt<20GeV). Is there a way to do this (for example with a line or a semitransparent pattern) just by giving the x-axis-coordinates of the cut area?
If not, what other possibilities one has to mark areas in a histogram?

Thanks for any help,
Benedikt

see the tutorials
$ROOTSYS/tutorials/graphs/exclusiongraph.C
$ROOTSYS/tutorials/graphs/exclusiongraph2.C

and the example below

Rene

{ TCanvas *c1 = new TCanvas; TH1F *h1 = new TH1F("h1","test1",100,-3,3); h1->FillRandom("gaus",5000); h1->SetFillColor(kRed); // Set histogram fill color to red h1->SetFillStyle(3001); TH1F *h2 = new TH1F("h2","test2",100,-3,3); h2->FillRandom("gaus",2000); h2->SetFillColor(kBlue); h2->SetFillStyle(3001); THStack hs("hs","test stacked histograms"); hs.Add(h1); hs.Add(h2); hs.Draw(); c1->Update(); TGraph *gcut = new TGraph(2); double xcut = -2; gcut->SetPoint(0,xcut,gPad->GetUymin()); gcut->SetPoint(1,xcut,gPad->GetUymax()); gcut->SetFillColor(6); gcut->SetFillStyle(3005); gcut->SetLineColor(6); gcut->SetLineWidth(1903); gcut->Draw("c"); }

Thank you very much! That was exactly what I needed. I have just one question left:

How can I precisely set the width of the exclusion band. For example, if I want to mark everything between x=0 and x=600 I tried to guess a value of ‘LineWidth’ to fill the specific area, but is there a way to do that exactly (by code)?

see tutorials $ROOTSYS/tutorials/graphs/exclusiongraph.C and exclusiongraph2.C

Rene

See also the documentation at root.cern.ch/root/html/TGraphPainter.html#GP02

Philippe.