Hello all,
My root version is 5.22. I can’t shift to v5.24 as this is the version
suggested by the CMS community.
I am writitng a 2D vector of pointers as my tree variable. I writing it like this :
vector< std::vector<double> > *ptarr;
ptarr = new std::vector< std::vector<double> >;
myTree->Branch("pt","vector< std::vector<double> >",&ptarr);
for(int i = 0; i<somevalue;i++)
ptarr[i]->push_back(pt_photon[i]);
but when I compile this I get the error as :
error: base operand of ->' has non-pointer typestd::vector<std::vector<double, std::allocator >, std::allocator<std::vector<double, std::allocator > > >’
Could someone tell me where I am going wrong?
Apologies if I am asking c++ specific question.
Thanks much for your reply. It worked
Now I am facing other problem of dictionary generation on which I have seen
many posts in this forum.
I am getting error as :
I have postAnalyzer.C and .h got by doing MakeClass.
Then I make myClass.C &.h which inherits from postAnalyzer class.
I have main.C which is something like :
[code]#include “myClass.C” #include “TROOT.h”
int main(){
gROOT->ProcessLine("#include ");
myClass m(21);
}[/code]
I compile this main.C and then do ./main.exe on my lxplus machine.
Following the posts, I add the following lines in myClass.C (after I have included other header files)
#include <vector>
#ifdef __MAKECINT__
#pragma link C++ class vector< vector<double> >+;
#endif
Regarding the problem I mentioned in my previous post :
After including those lines in myClass.C which I mentioned in the previous post,
I did :
.L myClass.C+
and it compiled successfully.
Then I try running this code but this time I am getting the problem of segmentation violation because of the line :
Instead if I do :
then I do not get any problem with segmentation violation!
I could have used :
but that will not solve my problem.
I am doing something like :
for(int i=0; i<noOfPhotons;i++)
{
if(some condition for that particular photon)
{
(*ptarr)[i].push_back(pt of that photon);
}
}
So I want pt of 0th photon to go inside ptarr[0][0], pt of 1st photon to go inside ptarr[1][0]
If supposing 0th photon doesn’t satify that condition then still I want pt of 1st photon to go inside ptarr[1][0] and so on