Creating an executable from an unnamed macro

Dear ROOTers,
I have an unnamed macro than read a text data file to fill a TTree and save it to a ROOT file.

Is possible (and easy to do ^^) to compile it and generate an executable file in order to speed up execution?

Should I use gcc or the ROOT compiler? I’m not an expert of gcc and makefiles…

I think i’m using, in addition to std libraries such as iostream and fstream, the following ROOT classes:
TFile, TTree, TMath, TGFileDialog
In the help I can found the .h file, but which libraries should i include?

Moreover i have two classes made by me and compiled by AcLib… how can i link the .so files?

Otherwise i could try to change the unnamed macro in a dummy class that do the work, compiling it with AcLib… which solution is the simplest?

Thanks a lot
Matteo

Hi,

[quote=“alfonsi”]I have an unnamed macro than read a text data file to fill a TTree and save it to a ROOT file.

Is possible (and easy to do ^^) to compile it and generate an executable file in order to speed up execution?[/quote] Make it a named one. Compilers cannot understand unnamed macros.

[quote=“alfonsi”]Should I use gcc or the ROOT compiler? I’m not an expert of gcc and makefiles…[/quote]Use ACLiC, i.e. .L mycode.C+.

[quote=“alfonsi”]I think i’m using, in addition to std libraries such as iostream and fstream, the following ROOT classes:
TFile, TTree, TMath, TGFileDialog
In the help I can found the .h file, but which libraries should i include?[/quote]Don’t worry, ACLiC will take care of that. FYI, the libraries are stated in the doc, too, just below the include files.

[quote=“alfonsi”]Moreover i have two classes made by me and compiled by AcLib… how can i link the .so files?[/quote]ACLiC will take care of that, too. Just load them before building your dependent code with ACLiC.

[quote=“alfonsi”]Otherwise i could try to change the unnamed macro in a dummy class that do the work, compiling it with AcLib… which solution is the simplest?[/quote]It doesn’t have to be a class; you can just convert that unnamed macro into a regular free function.

Cheers, Axel.

Ok. But i have some doubts:

  1. I have to remove the initial gROOT->Reset(), right?

  2. I include two home-made classes in the Tree. In the unnamed macro i simply load the .so using:

if (!TClassTable::GetDict(“GenericDAQBoard”)) {
gSystem->Load("./GenericDAQBoard_cxx.so");
}
if (!TClassTable::GetDict(“LHCbM1R1_3GEMChamber”)) {
gSystem->Load("./LHCbM1R1_3GEMChamber_cpp.so");
}

How do i change this?

Thx a lot
Matteo

Hi Matteo,

[quote=“alfonsi”]I have to remove the initial gROOT->Reset(), right?[/quote]YES.

[quote=“alfonsi”]I include two home-made classes in the Tree. In the unnamed macro i simply load the .so using:

if (!TClassTable::GetDict(“GenericDAQBoard”)) {
gSystem->Load("./GenericDAQBoard_cxx.so");
}
if (!TClassTable::GetDict(“LHCbM1R1_3GEMChamber”)) {
gSystem->Load("./LHCbM1R1_3GEMChamber_cpp.so");
}

How do i change this?[/quote]Depends. If your currently unnamed macro depends on these files you could create a lib loading script, where you add your new library, just like you did for the other two. If it doesn’t depend on it code-wise (e.g. you don’t #include one of their headers) you can load them from within the new library. Or you put them into a rootmap file, and ROOT will load these libs automatically when needed. See the help provided by running rlibmap without arguments. I’ve put some doc (for a different context) on how to generate that rootmap file here: root.cern.ch/root/html/THtml.html#conf:liblink

Cheers, Axel.