Hello all,
I am running a macro using c++ compiler by loading root library.
To use TLorentzVector, I need to load libPhysics (gSystem->Load(“libPhysics”);). But How could I add it into my cpp file (anaPhantom.cpp (17.8 KB)).
I tried to add it but I am getting error saying:
[quote]
error: ‘gSystem’ was not declared in this scope
gSystem->Load(“libPhysics”);
^
anaPhantom.cpp:75:60: error: invalid use of incomplete type ‘class TClonesArray’
TClonesArray *LMuon = new TClonesArray(“TLorentzVector”);[/quote]
I am running this as
c++ -o anaPhantom ‘root-config --glibs --cflags’ anaPhantom.cpp
Thanks,
Ram
Thanks for reply.
I tried but now it is giving me error
[quote]anaPhantom.cpp: In function ‘int main(int, char**)’:
anaPhantom.cpp:80:60: error: invalid use of incomplete type 'class TClonesArray’
TClonesArray *LMuon = new TClonesArray(“TLorentzVector”);
^
In file included from /cvmfs/cms.cern.ch/slc6_amd64_gcc491/cms/cmssw/CMSSW_7_4_0_pre2/external/slc6_amd64_gcc491/bin/…/…/…/…/…/…/lcg/root/5.34.22/include/TNamed.h:26:0,
from /cvmfs/cms.cern.ch/slc6_amd64_gcc491/cms/cmssw/CMSSW_7_4_0_pre2/external/slc6_amd64_gcc491/bin/…/…/…/…/…/…/lcg/root/5.34.22/include/TDirectory.h:25,
from /cvmfs/cms.cern.ch/slc6_amd64_gcc491/cms/cmssw/CMSSW_7_4_0_pre2/external/slc6_amd64_gcc491/bin/…/…/…/…/…/…/lcg/root/5.34.22/include/TROOT.h:29,
from anaPhantom.cpp:5:
/cvmfs/cms.cern.ch/slc6_amd64_gcc491/cms/cmssw/CMSSW_7_4_0_pre2/external/slc6_amd64_gcc491/bin/…/…/…/…/…/…/lcg/root/5.34.22/include/TObject.h:212:17: error: forward declaration of 'class TClonesArray’
friend class TClonesArray; // needs to reset kNotDeleted in fBits[/quote]
Actually I would like to add the fill the trees with TLorentzVector so for that the simple code below is working fine and I need to implement the same into the above code.
[code]{
gSystem->Load(“libPhysics”);
TFile *f = new TFile(“zzz.root”, “RECREATE”);
TTree *tree = new TTree(“T”, “Testing TClonesArrays”);
TClonesArray *a = new TClonesArray(“TLorentzVector”);
TClonesArray &aa = *a;
tree->Branch(“test”, &a);
for (Int_t i=0;i<1000;i++) {
new(aa[i]) TLorentzVector(1,2,3,i);
}
tree->Fill();
f->Write();
delete f;
}
[/code]
Please suggest what should I do?
Thanks.
#include “TClonesArray.h”