Drawing lines over histograms

I have a file with coordinates for some horizontal and vertical lines (like a net) and I would like to draw them over a 2D histogram, and I need to do it with several histograms, i.e., to plot the histogram and my net in the same draw. Is there any way to do it?
Cheers

You should use TLine.

root [0] TH2D *h2 = new TH2D("h2","h2",40,-4,4,40,-4,4)
root [1] h2->FillRandom("gaus",40000);
root [2] h2->Draw()
root [3] TLine *l = new TLine(-3,-3,3,3)
root [4] l->Draw()

Yes, I did that for an example, but I have to draw over a 100 lines in various histograms, so I was wondering if there is some option to draw a net or something similar and call it every time I need it. By the way, I have problems passing arguments to the TLine, instead of numbers by themselves. I thought to do a loop over TLine to change the x,y coordinates, so I do not write too many TLines.
Thank you for your help.
Cheers, Eric

It depends what you call a " net" … the only “net” which can be drawn automatically is the grid on x and y axis. But I guess that is not what you want because you would have found that option yourself.

The best is to send me an example showing what you want and we can have a look how to make a function to draw these " nets" …

Hi, this is what I want to do:

First step:
I have these data (rows):

1.- y=10
2.- y=25
3.- y=30

for horizontal lines, and between them I need to include vertical lines:

Between 1 and 2:

x=5
x=15
x=24
x=38

Between 2 and 3:

x=2
x=20
x=33

Between 3 and 4

x=6
x=35
x=50

It is just a simple example, but the idea is to draw a lot of lines in a histogram.

Second step:
Later on, I’ll need to put each cell in a bin of a 2D histogram and fill it with some events. For example:

Between line 1 and 2 in cell #1: fill with 3 events
Between line 1 and 2 in cell #2: fill with 4 events

Like a 2D histogram with variable size bins.

Make a small script having the histo as input parameter. The script will first draw the histo then draw the line on top. Then it will be really easy to draw all your histos just calling that script.