Re: TGraph2DErrors

From: Bakur Parsamyan <bakur_at_cern.ch>
Date: Mon, 16 Mar 2009 17:03:14 +0100

Margar Simonyan wrote:
> Hi Bakur
>
> yes, that is one solution. My understanding was that TGraph (2D) is a
> dynamic object and internally extends the arrays when needed.
yes indeed, it does..! At least that's what I've understood from this:

http://root.cern.ch/root/htmldoc/src/TGraph2DErrors.cxx.html#LJGvWB

You just need to give some initial value (g->Set(n)). For example I tried the following and it works..

root [0] TGraph2DErrors * g = new TGraph2DErrors()
root [1] g->SetNameTitle("a", "b")                
root [2] g->Set(1)                                
root [3] g->SetPoint(0, 1.0, 1.0, 1.0)             
root [4] g->SetPointError(0, 0.1, 0.1, 0.1)        
root [5] g->SetPoint(1, 2.0, 2.0, 2.0)     
root [6] g->SetPointError(1, 0.1, 0.1, 0.1)
root [7] g->SetPoint(2, 3.0, 3.0, 3.0)     
root [8] g->SetPointError(2, 0.1, 0.1, 0.1)
root [9] g->SetPoint(3, 4.0, 4.0, 4.0)     
root [10] g->SetPointError(3, 0.1, 0.1, 0.1)
root [11] g->SetPoint(4, 5.0, 5.0, 5.0)     
root [12] g->SetPointError(4, 0.1, 0.1, 0.1)
root [13] g->SetPoint(5, 10.0, 10.0, 10.0)  
root [14] g->SetPointError(5, 0.1, 0.1, 0.1)
root [15] g->Draw("P")


regards,

Bakur.

> In my
> code at the time of creation of TGraph I don't know the number of
> points, of course the points can be filled into dynamic array and when
> the length is known one can create a TGraph with required number of
> points.
>
> Thanks,
> Margar
>
> PS. sorry for double posting, in the past it was impossible to send
> email to roottalk from gmail account
>
> On Mon, Mar 16, 2009 at 3:25 PM, Bakur Parsamyan <bakur_at_cern.ch> wrote:
>
>> Hi Margar,
>>
>> I guess you need to define number of points in your graph..
>> Try to use g->Set(n);
>> http://root.cern.ch/root/htmldoc/TGraph2DErrors.html#TGraph2DErrors:Set
>>
>> regards,
>>
>> Bakur.
>>
>>
>>
>> Margar Simonyan wrote:
>>
>>> Hello ROOT team
>>>
>>> I don't understand why the following few lines result into ROOT crush
>>>
>>> root [0] TGraph2DErrors * g = new TGraph2DErrors()
>>> root [1] g->SetNameTitle("a", "b")
>>> root [2] g->SetPoint(0, 1.0, 1.0, 1.0)
>>> root [3] g->SetPointError(0, 1.0, 1.0, 1.0)
>>>
>>> I have tested on ROOT version 5.16/00 (lxplus) and 5.20/00 (my
>>> laptop). Any explanation ?
>>>
>>> Thanks,
>>> Margar
>>>
>>>
>>> *** Break *** segmentation violation
>>> (no debugging symbols found)
>>> Using host libthread_db library "/lib64/tls/libthread_db.so.1".
>>> Attaching to program: /proc/25479/exe, process 25479
>>> (no debugging symbols found)...done.
>>> [Thread debugging using libthread_db enabled]
>>> [New Thread 182913018112 (LWP 25479)]
>>>
>>>
>>> ------------------------------------------------------------------------------------------------------
>>> Margar Simonyan ------ post-doctoral researcher, ATLAS
>>> LAPP, 9 Chemin de Bellevue, BP 110 F-74941, Annecy-le-Vieux
>>> Tel: +33450091785 +41227671123 (CERN)
>>>
>>> -----------------------------------------------------------------------------------------------------
>>>
>>>
>>>
>>
>
>
Received on Mon Mar 16 2009 - 17:03:37 CET

This archive was generated by hypermail 2.2.0 : Mon Mar 16 2009 - 17:50:02 CET