Dictionary for maps usage

hello,

I am trying to create a dictionary in order to use maps in root. In my code there is a structure named cluster which I want to use as value in a map,

what exactly I have to do?

I am begginer in root, so I would really appreciate if somebody could give me detailed instructions.

I use root 5.34 in windows 10.

Hi,

You can go through root.cern.ch/how/how-create-dictionary

Cheers,
Danilo

thanks again danilo,

my file name is run15160.cpp
I have also a header file named run15160.h

if i write the command .L run15160.cxx+ in root I take this :
Error in TRint::ProcessLine: macro run15160.cxx not found in path .;C:\root_v5.34.32/macros;

what do I do wrong?

hi,

root is not finding the file. In which directory did you put it?

D

.L run15160.cpp++

danilo the files are inside root file

pepe with this command I took

Info in TWinNTSystem::ACLiC: creating shared library C:\root_v5.34.32\run15160_cpp.dll
’cl.exe’ is not recognized as an internal or external command,
operable program or batch file.
Error: external preprocessing failed. (0)
!!!Removing C:\root_v5.34.32\run15160_cpp_ACLiC_dict.cxx C:\root_v5.34.32\run15160_cpp_ACLiC_dict.h !!!
Error: C:\root_v5.34.32\bin\rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity

and two files were generated , run15160_cpp.d and run15160_cpp_ACLiC_dict.def


I used a simple program containing a map to create a dictionary in lxplus

[code]
//map.cpp
#include
#include
#include

using namespace std;

struct cluster{
int n;
} J12;

map <string, cluster> mymap;

 int main(){

mymap[“J12”] = J12;
mymap[“J12”].n=50;
cout<<mymap[“J12”].n<<endl;
}[/code]

With the command .L map.cpp+ two files were created : map_cpp.d and map_cpp.so

How to use them? What to do next?

Hi,

if you want to run a macro compiled with aclic, you should rename the main function to “map”.
Since you are on lxplus, which is linux, you can move to ROOT6 (this is not yet possible for windows).
ROOT6 does not need any dictionary for interactivity and your code just runs - maybe this could be the simplest solution:

~$ root -l
root [0] using namespace std;
root [1] 
root [1] struct cluster{
root (cont'ed, cancel with .@) [2]     int n;
root (cont'ed, cancel with .@) [3]          } J12;
root [4] 
root [4] map <string, cluster> mymap;
root [5] mymap["J12"] = J12;
root [6] mymap["J12"].n=50;
root [7] cout<<mymap["J12"].n<<endl;
50
root [8] .q

To setup ROOT6 on lxplus, follow the instructions here
root.cern.ch/content/release-60600
or in short:

. /afs/cern.ch/sw/lcg/external/gcc/4.9/x86_64-slc6-gcc49-opt/setup.sh
. /afs/cern.ch/sw/lcg/app/releases/ROOT/6.06.00/x86_64-slc6-gcc49-opt/root/bin/thisroot.sh

Cheers,
D

yes I think this is the best solution!!

Thanks!!!