# Convolution of TGraph with TF1

**URL:** <https://root-forum.cern.ch/t/convolution-of-tgraph-with-tf1/40763>\
**Category:** Newbie\
**Tags:** root\
**Created:** [July 30, 2020, 6:41pm UTC](https://root-forum.cern.ch/t/convolution-of-tgraph-with-tf1/40763 "2020-07-30T18:41:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abhik/32/22998_2.png) [@abhik](https://root-forum.cern.ch/u/abhik)\
**Post date:** [July 30, 2020, 6:41pm UTC](https://root-forum.cern.ch/t/convolution-of-tgraph-with-tf1/40763/1 "2020-07-30T18:41:46Z")

</div>

I have a Current (_I_) vs Time (_t_) graph which I want to convolute with a function of the form _y = te^(-t/10)_. Is there a way to do this in ROOT?

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [July 30, 2020, 7:15pm UTC](https://root-forum.cern.ch/t/convolution-of-tgraph-with-tf1/40763/2 "2020-07-30T19:15:49Z")

</div>

Hi @abhik,  
You could try [TF1Convolution](https://root.cern.ch/doc/master/classTF1Convolution.html) ([example](https://root.cern/doc/master/fitConvolution_8C.html)) or RooFit ([example](https://root.cern/doc/master/rf208__convolution_8C.html)).  
Cheers,  
Vincenzo

---

<div class="post-metadata">

**Author:** ![abhik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abhik/32/22998_2.png) [@abhik](https://root-forum.cern.ch/u/abhik)\
**Post date:** [July 30, 2020, 9:42pm UTC](https://root-forum.cern.ch/t/convolution-of-tgraph-with-tf1/40763/3 "2020-07-30T21:42:24Z")

</div>

Thanks @vpadulan for your quick response.  
I see that [TF1Convolution](https://root.cern.ch/doc/master/classTF1Convolution.html) accepts 2 TF1 objects and produce their convolution. For my case, I have a TGraph and a TF1 object and the convolution between these two is required. Any idea if I can convert my TGraph into a TF1 object?  
I have attached a figure of the graph that I need to convolute with the function.

 ![graph](https://root-forum.cern.ch/uploads/default/original/3X/c/d/cd9d48a608b4861c50202317127d76f5e2be82da.png)

---

<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:** [July 31, 2020, 6:32am UTC](https://root-forum.cern.ch/t/convolution-of-tgraph-with-tf1/40763/4 "2020-07-31T06:32:08Z")

</div>

TF1 offer the possibility to define a function as [C code](https://root.cern/doc/master/classTF1.html#F4) you can try that and in the code call TGraph::Eval(). That way you will have two TF1 et the values of the 2nd one will come form the TGraph…

---

<div class="post-metadata">

**Author:** ![abhik](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/abhik/32/22998_2.png) [@abhik](https://root-forum.cern.ch/u/abhik)\
**Post date:** [August 2, 2020, 6:10pm UTC](https://root-forum.cern.ch/t/convolution-of-tgraph-with-tf1/40763/5 "2020-08-02T18:10:47Z")

</div>

Hi @couet, it worked with some help from the code given [here](https://root-forum.cern.ch/t/creating-tf1-from-tgraph/10522/5).  
Thank you.
