# How exactly does ROOT work

**URL:** <https://root-forum.cern.ch/t/how-exactly-does-root-work/39509>\
**Category:** Newbie\
**Created:** [May 20, 2020, 1:19pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509 "2020-05-20T13:19:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 20, 2020, 1:19pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/1 "2020-05-20T13:19:23Z")

</div>

I am confused about where I should start with working on ROOT. I have installed it but I don’t understand how to run macros on it or what the general syntax is supposed to be like. The only coding I have done so far is compile C++ codes for my school projects etc. Any help would be appreciated.

_ROOT Version:_ 6.18  
_Platform:_ Windows 10

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 20, 2020, 1:23pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/2 "2020-05-20T13:23:31Z")

</div>

[ROOT Primer](https://root.cern.ch/root/htmldoc/guides/primer/ROOTPrimer.html)

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 20, 2020, 2:06pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/3 "2020-05-20T14:06:36Z")

</div>

So I used this code word for word

```auto
root [6] double x=.5
(double) 0.500000
root [7] int N=30
(int) 30
root [8] double geom_series=0
(double) 0.000000
root [9] for (int i=0;i<N;++i)geom_series+=TMath::Power(x,i)
root [10] cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;

```

and this was the output I got:

```auto
ROOT_prompt_6:1:9: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
        ^ ~~~~~~~~~
ROOT_prompt_6:1:37: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]
cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
                                    ^ ~~~~~~~~~~~
input_line_200:2:3: error: use of undeclared identifier 'cout'
 (cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
  ^
input_line_200:2:18: error: expected unqualified-id
 (cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
                 ^
input_line_200:2:40: error: expected '(' for function-style cast or type construction
 (cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
                               ~~~~~~~~ ^
input_line_200:2:42: error: expected expression
 (cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
                                         ^
input_line_200:2:94: error: expected unqualified-id
 (cout << TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Doubl...
                                                                                             ^
input_line_200:2:116: error: expected '(' for function-style cast or type construction
  ...TMath::((*(Double_t (Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Double_t, Int_t...
                                                                                                      ~~~~~~~~ ^
input_line_200:2:118: error: unexpected type name 'Int_t': expected expression
  ...(Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Double_t, Int_t)*)0x155bb0c0))(((*(...
                                                                                            ^
input_line_200:2:125: error: expected expression
  ...(Double_t)*)0x155bb070))(((*(double*)0x1280040)) - (1 - TMath::((*(Double_t (Double_t, Int_t)*)0x155bb0c0))(((*(...
                                                                                                   ^
input_line_200:2:227: error: use of undeclared identifier 'endl'
  ...((*(int*)0x1280038)) - 1)) / (1 - ((*(double*)0x1280030)))) << endl)

```

I don’t understand what’s wrong

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [May 20, 2020, 2:48pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/4 "2020-05-20T14:48:55Z")

</div>

Hi @esh187,  
that snippet works fine on linux, so I guess the problem is with windows (@bellenot might have an idea about the precise cause).

How did you install ROOT on windows? There is a number of features that does not work there, as far as I know.

Cheers,  
Enrico

---

<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:** [May 20, 2020, 2:50pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/5 "2020-05-20T14:50:11Z")

</div>

It is fine on Mac too:

```auto
root [6] double x=.5
(double) 0.50000000
root [7] int N=30
(int) 30
root [8] double geom_series=0
(double) 0.0000000
root [9] for (int i=0;i<N;++i)geom_series+=TMath::Power(x,i)
root [10] cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
1.86265e-09
root [11] 

```

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 20, 2020, 2:54pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/6 "2020-05-20T14:54:54Z")

</div>

Weird, it works also for me:

```auto
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.0
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86'

C:\Users\bellenot>cd temp

C:\Users\bellenot\temp>root\bin\thisroot.bat

C:\Users\bellenot\temp>root -l
root [0] double x=.5
(double) 0.50000000
root [1] int N=30
(int) 30
root [2] double geom_series=0
(double) 0.00000000
root [3] for (int i=0;i<N;++i)geom_series+=TMath::Power(x,i)
root [4] cout << TMath::Abs(geom_series - (1-TMath::Power(x,N-1))/(1-x)) <<endl;
1.86265e-09
root [5]

```

But it might still come from an incompatibility of different versions of Visual Studio (I tried with ROOT v6.18/04). I’m checking right now

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 20, 2020, 3:20pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/7 "2020-05-20T15:20:02Z")

</div>

> [@esh187](#):
>
> root [6] double x=.5

What did you do before in ROOT (i.e. the first five lines/commands)? Can you try to start again from a clean prompt and type only the lines you posted here?

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 21, 2020, 11:45am UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/8 "2020-05-21T11:45:28Z")

</div>

root [0] double x=.5  
(double) 0.50000000  
root [1] int N=30  
(int) 30  
root [2] double geom\_series = 0  
(double) 0.00000000  
root [3] for( int i=0; i\<N ; ++i)geom\_series+= TMath::Power(x,i)  
root [4] cout\<\< TMath::Abs(geom\_series - (1-TMath::Power(x,N-1))/(1-x)) \<\<endl;  
ROOT\_prompt\_4:1:8: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]  
cout\<\< TMath::Abs(geom\_series - (1-TMath::Power(x,N-1))/(1-x)) \<\<endl;  
^ ~~~~~~~~~  
ROOT\_prompt\_4:1:36: warning: implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension [-Wmicrosoft-cast]  
cout\<\< TMath::Abs(geom\_series - (1-TMath::Power(x,N-1))/(1-x)) \<\<endl;  
^ ~~~~~~~~~~~  
input\_line\_14:2:3: error: use of undeclared identifier ‘cout’  
(cout \<\< TMath::((_(Double\_t (Double\_t)_)0xade5070))(((_(double_)0xae00030)) - (1 - TMath::((_(Double\_t (Double…  
^  
input\_line\_14:2:18: error: expected unqualified-id  
(cout \<\< TMath::((_(Double\_t (Double\_t)_)0xade5070))(((_(double\*)0xae00030)) - (1 - TMath::((_(Double\_t (Double…  
^  
input\_line\_14:2:40: error: expected ‘(’ for function-style cast or type construction  
(cout \<\< TMath::((_(Double\_t (Double\_t)_)0xade5070))(((_(double\*)0xae00030)) - (1 - TMath::((\*(Double\_t (Double…  
~~~~~~~~ ^  
input\_line\_14:2:42: error: expected expression  
(cout \<\< TMath::((_(Double\_t (Double\_t)_)0xade5070))(((_(double_)0xae00030)) - (1 - TMath::((_(Double\_t (Double…  
^  
input\_line\_14:2:93: error: expected unqualified-id  
(cout \<\< TMath::((_(Double\_t (Double\_t)_)0xade5070))(((_(double\*)0xae00030)) - (1 - TMath::((_(Double\_t (Double…  
^  
input\_line\_14:2:115: error: expected ‘(’ for function-style cast or type construction  
…TMath::((_(Double\_t (Double\_t)_)0xade5070))(((_(double\*)0xae00030)) - (1 - TMath::((_(Double\_t (Double\_t, Int\_t)…  
~~~~~~~~ ^  
input\_line\_14:2:117: error: unexpected type name ‘Int\_t’: expected expression  
…(Double\_t)_)0xade5070))(((_(double_)0xae00030)) - (1 - TMath::((_(Double\_t (Double\_t, Int\_t)_)0xade50c0))(((_(do…  
^  
input\_line\_14:2:124: error: expected expression  
…(Double\_t)_)0xade5070))(((_(double_)0xae00030)) - (1 - TMath::((_(Double\_t (Double\_t, Int\_t)_)0xade50c0))(((_(do…  
^  
input\_line\_14:2:225: error: use of undeclared identifier ‘endl’  
…((_(int\*)0xae00028)) - 1)) / (1 - ((_(double_)0xae00020)))) \<\< endl)

* * *

And then it simply exits the ROOT session and I’m back where I started. Maybe I didn’t install it right?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 21, 2020, 11:46am UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/9 "2020-05-21T11:46:57Z")

</div>

Try with: `std::cout << ... << std::endl;`

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 21, 2020, 11:50am UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/10 "2020-05-21T11:50:16Z")

</div>

or start with `#include <iostream>`

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 21, 2020, 11:54am UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/11 "2020-05-21T11:54:03Z")

</div>

> [@bellenot](#):
>
> or start with `#include <iostream>`

Did this and this time the result was:  
ROOT\_prompt\_5:1:35: error: expression is not assignable  
cout\<\< TMath::Abs(geom\_series - (1–TMath::Power(x,N-1))/(1-x)) \<\< endl;  
~^  
ROOT\_prompt\_5:1:68: error: use of undeclared identifier ‘endl’  
cout\<\< TMath::Abs(geom\_series - (1–TMath::Power(x,N-1))/(1-x)) \<\< endl;  
^  
root [6]

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 21, 2020, 11:55am UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/12 "2020-05-21T11:55:02Z")

</div>

> [@Wile\_E\_Coyote](#):
>
> Try with: `std::cout << ... << std::endl;`

error: expression is not assignable  
This is what I got.

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 21, 2020, 11:56am UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/13 "2020-05-21T11:56:55Z")

</div>

I have verison v6.18/04 downloaded on my Windows10 with Visual Studio 2019 at the moment. Maybe I should install an earlier version @bellenot ?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 21, 2020, 12:04pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/14 "2020-05-21T12:04:49Z")

</div>

can you try to use another variable name than `geom_series`?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 21, 2020, 12:05pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/15 "2020-05-21T12:05:15Z")

</div>

> [@esh187](#):
>
> should install an earlier version @bellenot ?

Nope…

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 21, 2020, 12:09pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/16 "2020-05-21T12:09:27Z")

</div>

> [@bellenot](#):
>
> can you try to use another variable name than `geom_series` ?

Did that, stills shows errors. Maybe it has something to do with the way I installed or something?

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 21, 2020, 12:12pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/17 "2020-05-21T12:12:07Z")

</div>

Any particular thing I need to know about the Folders and such in which I have installed the root version v6.18/04?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 21, 2020, 12:13pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/18 "2020-05-21T12:13:35Z")

</div>

The only restriction is to install it in a path not containing any white space. Why? where did you install it?

---

<div class="post-metadata">

**Author:** ![esh187](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/esh187/32/24961_2.png) [@esh187](https://root-forum.cern.ch/u/esh187)\
**Post date:** [May 21, 2020, 12:19pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/19 "2020-05-21T12:19:06Z")

</div>

No there is no white space or anything of the sort in the path. It won’t even accept " cout " and “endl” for some reason and I don’t understand why that is

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 21, 2020, 12:21pm UTC](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509/20 "2020-05-21T12:21:09Z")

</div>

Which version of Visual Studio 2019 do you have?

[Next page](https://root-forum.cern.ch/t/how-exactly-does-root-work/39509.md?page=2)
