# Load existing cut files and plot the TCutg on existing 2d hists in diff sub-canvas

**URL:** <https://root-forum.cern.ch/t/load-existing-cut-files-and-plot-the-tcutg-on-existing-2d-hists-in-diff-sub-canvas/59650>\
**Category:** Newbie\
**Tags:** root\
**Created:** [June 14, 2024, 5:27pm UTC](https://root-forum.cern.ch/t/load-existing-cut-files-and-plot-the-tcutg-on-existing-2d-hists-in-diff-sub-canvas/59650 "2024-06-14T17:27:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thegame](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@thegame](https://root-forum.cern.ch/u/thegame)\
**Post date:** [June 14, 2024, 5:27pm UTC](https://root-forum.cern.ch/t/load-existing-cut-files-and-plot-the-tcutg-on-existing-2d-hists-in-diff-sub-canvas/59650/1 "2024-06-14T17:27:52Z")

</div>

Hi everyone, I am having trouble plotting the previously created TCutG files (filenames: x2vsx1\_0\_0.C, x2\_x1\_0\_1.C, etc., and TCutG of the form TCutG \*cutx\_0\_0, and so on, inside a directory) on top of the existing 2D histograms on each sub-canvas, i.e., attempting to overplot cutx\_0\_0 on cd(1), cutx\_0\_1 on cd(2), and so on.

This is a summary of what the macro does.

Open the ROOT file: The file contains a tree of data that I need to plot.  
Create canvas and sub-canvases: Multiple canvases are created to display the plots.  
Draw Data: For each canvas, specific data points are plotted from the tree.

upto this point it works fine. the problem begins in the next step loading and plotting the cuts.

To load, I’m doing the following:

> TString cutFileName = Form(“%sX2vsX1\_%d\_%d.C”, cutDir.Data(), j, i);  
> gROOT-\>LoadMacro(Form(“%s”, cutFileName.Data()));

My question is basically how to draw the cut in the same sub-canvas using the Draw (same") command or something similar so that it overplots on the existing hists.

this is how the cut files look

> {  
> //========= Macro generated from object: cutx\_0\_0/Graph  
> //========= by ROOT version 6.10/04
> 
> TCutG \*cutx\_0\_0 = new TCutG(“cutx\_0\_0”,10);  
> cutx\_0\_0-\>SetVarY(“X2[0][0]”);  
> cutx\_0\_0-\>SetVarX(“X1[0][0]”);  
> cutx\_0\_0-\>SetTitle(“Graph”);  
> cutx\_0\_0-\>SetFillColor(1);  
> cutx\_0\_0-\>SetPoint(0,42.5,53.1579);  
> cutx\_0\_0-\>SetPoint(1,43.7,51.7571);  
> cutx\_0\_0-\>SetPoint(2,47.3667,46.3542);  
> cutx\_0\_0-\>SetPoint(3,53.3667,41.1513);  
> cutx\_0\_0-\>SetPoint(4,55.5667,44.153);  
> cutx\_0\_0-\>SetPoint(5,55.1,47.5548);  
> cutx\_0\_0-\>SetPoint(6,53.3,50.7566);  
> cutx\_0\_0-\>SetPoint(7,49.0333,54.7588);  
> cutx\_0\_0-\>SetPoint(8,46.3667,55.7593);  
> cutx\_0\_0-\>SetPoint(9,42.5,53.1579);  
> //cutx\_0\_0-\>Draw(“”);  
> }

Thanks for your time and consideration.

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 15, 2024, 5:18am UTC](https://root-forum.cern.ch/t/load-existing-cut-files-and-plot-the-tcutg-on-existing-2d-hists-in-diff-sub-canvas/59650/2 "2024-06-15T05:18:52Z")

</div>

Hi,

Adding in the loop @couet.

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [June 17, 2024, 11:37am UTC](https://root-forum.cern.ch/t/load-existing-cut-files-and-plot-the-tcutg-on-existing-2d-hists-in-diff-sub-canvas/59650/3 "2024-06-17T11:37:55Z")

</div>

TCutG is TGraph. The macro you post builds it. At the end of the macro simply do:

```auto
cutx_0_0->Draw(“L”)

```

If you want to draw it on top of an exiting canvas

_(sorry for the late reply, I was off end of last week)._
