I have a root file which I was trying to analyse. I created a class for this root file using MakeClass method. ( Please find the code attached with this mail.)
I am reading the data from the root file ..do some caclulation and store output in other output root file with a tree. During this process I use TLorenzeVector which make things little easier for me.
As soon as I add the following line at the last part of my code it gives me segmentation voliation.... otherwise it works fine. Infact If i add these line at some other place it gives the same errror. Error occures at Tree.Fill() line!!
You must provide a dictionary for the vector in order for the I/O to work.
To do so is as simple as adding the following lines towards the top of your file:#include <vector>
#include "TLorentzVector.h"
#ifdef __MAKECINT__
#pragma link C++ class vector<TLorentzVector>;
#endif and you need to compile the result with ACLiC:.L Analyzer.C+Note: you may have to correct C++ syntax error if you took advantages of CINT shortcuts
Thanks for the help.
I have included the lines you sent........I am just confused when to run this command .L Analyzer.C+ ???
As I use a makefile to make "Analyser.so" and then run the code as :
Now should I generated the dictionary before doing these or have to modified my make file?? and how?
Meantime it seems the dictionary is not gereated… with .L Anlyser.C+ command… I am using 5.14 version.
Here is the output of .L Analyser.C+
Info in TUnixSystem::ACLiC: creating shared library /home/sushil/CIT/./Analyzer_C.so
In file included from /tmp/file1A1GAf_rootcint.h:3,
from /tmp/lyp0NW_cint.cxx:1:
/home/sushil/CIT/./Analyzer.C:19:2: invalid preprocessing directive #pragmak
Error: external preprocessing failed. :0:
!!!Removing /home/sushil/CIT/./fileTDzkDJ.cxx /home/sushil/CIT/./fileTDzkDJ.h !!!
Error: rootcint: error loading headers…
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity
In file included from /home/sushil/CIT/./Analyzer.C:2:
/home/sushil/CIT/./Analyzer.h:1235: warning: unused parameter ‘entry’
In file included from /usr/lib/gcc/i386-redhat-linux/3.4.6/…/…/…/…/include/c++/3.4.6/backward/iostream.h:31,
from /home/sushil/CIT/./Analyzer.C:6:
/usr/lib/gcc/i386-redhat-linux/3.4.6/…/…/…/…/include/c++/3.4.6/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the <X.h> header for C++ includes, or instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
/home/sushil/CIT/./Analyzer.C: In member function `virtual void Analyzer::Loop()’:
/home/sushil/CIT/./Analyzer.C:281: warning: comparison between signed and unsigned integer expressions
/home/sushil/CIT/./Analyzer.C:384: warning: comparison between signed and unsigned integer expressions
/home/sushil/CIT/./Analyzer.C:39: warning: unused variable ‘rPhot_r9’
/home/sushil/CIT/./Analyzer.C:41: warning: unused variable ‘pPhotJet_CosTheta’
/home/sushil/CIT/./Analyzer.C:152: warning: unused variable ‘idebug1’
/home/sushil/CIT/./Analyzer.C:153: warning: unused variable ‘idebug2’
/home/sushil/CIT/./Analyzer.C:154: warning: unused variable ‘idebug3’
/home/sushil/CIT/./Analyzer.C:155: warning: unused variable ‘idebug4’
/home/sushil/CIT/./Analyzer.C:156: warning: unused variable ‘idebug5’
/home/sushil/CIT/./Analyzer.C:157: warning: unused variable ‘idebug6’
/home/sushil/CIT/./Analyzer.C:158: warning: unused variable ‘idebug7’
/home/sushil/CIT/./Analyzer.C:159: warning: unused variable ‘idebug8’
/home/sushil/CIT/./Analyzer.C:166: warning: unused variable 'RecJet_PtLow_'
Info in : The compiler has not found any problem with your macro.
Probably your macro uses something rootcint can’t parse.
Check root.cern.ch/root/Cint.phtml?limitations for Cint’s limitations.
root [1]
[quote]Meantime it seems the dictionary is not generated… with .L Anlyser.C+ command… I am using 5.14 version. [/quote]Sorry, there was a typo in my example (i.e. there was pragmak where pragma is needed)
[quote] As I use a makefile to make “Analyser.so” and then run the code as : [/quote]Since you have your own makefile and, seemingly, you are already running rootcint and compiling the result of running rootcint, you simply need to add the line#pragma link C++ class vector<TLorentzVector>; to you linkdef file.
Making Analyzerdict.C Analyzerdict.h
rm -f Analyzerdict.C Analyzerdict.h
rootcint Analyzerdict.C -c -I/home/sushil/ROOT_5.16/root_514/include Analyzer.h LinkDef.h
Error: class,struct,union or type TLorentzVector not defined prec_stl/memory:37:
Error: class,struct,union or type TLorentzVector not defined prec_stl/memory:38:
Error: class,struct,union or type TLorentzVector not defined prec_stl/memory:43:
Error: class,struct,union or type TLorentzVector not defined prec_stl/memory:44:
Error: class,struct,union or type TLorentzVector not defined prec_stl/memory:45:
Error: class,struct,union or type TLorentzVector not defined prec_stl/vector:51:
Error: Function TLorentzVector() is not defined in current scope prec_stl/vector:422:
Error: Function TLorentzVector() is not defined in current scope prec_stl/vector:422:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing Analyzerdict.C Analyzerdict.h !!!
Error: rootcint: error loading headers…
make: *** [Analyzerdict] Error 1
How I can make a linkdef.h file and complie it also ??
Now the code compiles but again the same problem!!! If I declare one more TLorenzeVector then I get the segmentation voilation…This is excactly I was getting in the beginng.
Then I don’t know what the problem really is and I would need a complete running example to be able to debug the problem and/or you might be able to find the cause by using valgrind.
You must initialize your variable, in particular the array size (by the way, they are actually never set but I assume this is work in progress):[code] Int_t pPhot_N = 0;
Int_t pJet_N = 0;
Int_t gJet_N = 0;
Int_t Events = 0;
…