How to make a dictionary of a user defined class in root

Dear Experts

I have a user defined class stored in ntuples. You can see the structure of the class(*).
I would like to access this class in root. In order to access this class in a root, I have to
make a dictionary of my class. Kinldy correct me if I am wrong.

Could someone please tell me how to make a dictionary of a class in a root and how I can access the
information which I have in the class(ie map. structure).
Any link or an example where it is described how to make a dictionary of the class and an example explaining how to access the class information in a root will help me a lot.

Regards
Bhawna

(*)
class TriggerObject
{
public:
struct {
double pt[20];
double eta[20];
double phi[20];
} ;

map(int, std::map(int, struct);
void objectinfo();

TriggerObject();

};

Hi,

I suggest you re-read the User’s Guide (in particular the chapter on adding your own class) and the FAQ How to generate a dictionary,

Cheers,
Philippe.

Hello Phillipe

Thanks for the information. I will go through the FAQ which you suggested.

Regards
Bhawna

Hello

I followed the instructions which you sent,
Kindly see the trgobji.h file and Linkdef.h file (*).

When I am compiling, I am still getting errors(1).
What I understood I have to include map and struc also in the LinkDef.h.
Could someone pls provide any example how can I include map and struct in the
LinkDef.h which are present in the class.

Regards
Bhawna

(*)


trigobj.h file

#include
#include
#include “TObject.h”

class trigobj : public TObject {

public:
trigobj(){};
virtual ~trigobj(){};
struct P4{
Double_t objpt[40];
Double_t objeta[40];
Double_t objphi[40];
} struct1;

typedef std::map <int, P4> M1;
typedef std::map <int, M1> M2;

ClassDef(trigobj,1)

};
ClassImp(trigobj)


LinkDef.h file


#include “trigobj.h”

#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class trigobj;


(1)
Error :
undefined reference to typeinfo for trigobj' undefined reference toROOT::GenerateInitInstance(trigobj const*)‘
undefined reference to `vtable for trigobj’

Hi,

[quote]undefined reference to typeinfo for trigobj' undefined reference toROOT::GenerateInitInstance(trigobj const*)‘
undefined reference to `vtable for trigobj’[/quote]Did you compile link and load both the dictionary and the source implementing your class. There is nothing special about the map and the nested class, so any example should do (see $ROOTSYS/test/Event)

Cheers,
Philippe

Hello

Now its compiling fine, but when I am doing cmsRun config.py
then it is giving error:

Could you pls tell now where I am wrong?

Regards
Bhawna Gomber


%MSG
%MSG-s CMSException: AfterModBeginJob 13-May-2011 16:34:14 CEST pre-events
cms::Exception caught in cmsRun
---- FatalRootError BEGIN
Fatal Root Error: @SUB=TTree::Branch
The pointer specified for name is not of a class or type known to ROOT
A cms::Exception is going through WorkerT:
Analyzer/demo
---- FatalRootError END

Hi,

The library that contains the dictionary is not loaded. See you local CMS software expert for the best way to load your library in the CMS environment.

Cheers,
Philippe.