Problems with including headers

Hi,
I run root 5.18 and I’ve made a macro that runs perfectly but when I wanted to add the library it doesn’t run. Actually it runs but does nothing like is jumping over all code.
I also wanted to use the MaxElement function which is in the TMath library under the name space TMath. So when I just included the library the macro did nothing at all just like with the vector library, but when I added the namespace then root complained about too many ‘}’. Here is how I included the libraries

#include <vector>
#include "TMath.h"
using namespace TMath;

Is there some kind of list of the headers for all the different root libraries?

Hi,

I can not reproduce that; v5.18.00f can “run” the three lines you have posted without problems. Can you come up with example code that I can run (!) and that shows the problem?

Cheers, Axel.

Hi

here is a little example that works fine if you comment out the headers but with them it doesn’t work. I don’t use anything from the headers yet but that shouldn’t make a difference.

//#include <vector>
//#include "TMath.h"
//using namespace TMath;

//------------main macro -------------

{
  //stream variables
  ifstream data("sim2_mu");
  //Temporary variables
  double var1,var2,var3,var4,var5,var6;
  string str;

  const int nrf_muons = 132426; //in file
  const int nrf_neutrinos = 224483;// in file
  const int nrf_shower = 10000;// in file

  //particle arrays mu = muons, n= neutrinos, E= energy(kinetic),p= momentum 
  double mu_px[nrf_muons], mu_py[nrf_muons], mu_pz[nrf_muons], mu_E[nrf_muons], mu_x[nrf_muons], mu_y[nrf_muons];

  int num = 0;

  // end of initiations
  //reads xx_mu file 
  while(data>>var1>>var2>>var3>>var4>>var5>>var6){
    
    //filling arrays
    mu_px[num] = var1;
    mu_py[num] = var2;
    mu_pz[num] = var3;
    mu_E[num] = var4;
    mu_x[num] = var5;
    mu_y[num] = var6;
    num ++;
    cerr<< var3<<endl;
  }
  data.close();

}

Hi,

see the users guide; unnamed macros must start with ‘{’. Use a named macro instead, i.e. write the block {…} as a regular function.

Cheers, Axel.