Hi,
I have my own main program vecDraw.cxx using ROOT. A simple TTree::Draw crashes for vector, but no problem with vector or vector.
#include <TSystem.h>
#include <TFile.h>
#include <TTree.h>
#include <TROOT.h>
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
//usage information
if(argc < 4)
{
cout << "Usage: " << argv[0] << " filename treename varname1 varname2" << endl;
cout << " or " << argv[0] << " filename treename varname" << endl;
cout << "\nEXITING!" << endl;
gSystem->Exit(1);
}
const char* filename = argv[1];
const char* treeName = argv[2];
const char* var1 = argv[3];
const char* var2 = 0;
if (argc > 4) var2 = argv[4];
// gROOT->ProcessLine("#include <vector>");
TFile *rfile = TFile::Open(filename);
TTree *tree = 0;
if (rfile) {
tree = (TTree*)rfile->Get(treeName);
cout << "Drawing " << var1 << endl;
tree->Draw(var1);
cout << "After drawing " << var1 << endl;
if (var2) {
cout << "Drawing " << var2 << endl;
tree->Draw(var2);
cout << "After drawing " << var2 << endl;
}
}
return 0;
}
If I Draw first any variable other than vetor, the following drawing of vector will already crash.
The root file treeVector.root contains a TTree “tvec” which is composed of branches:
[ul]
[] nvec: nvec/I [/]
[] vFloat: vector [/]
[] vDouble: vector [/]
[] vInt: vector [/]
[/ul]
I checked the list of gROOT->GetListOfTypes(), and found both types vector and vector, but no vector. However this crash can be removed by adding the following line in my code:
gROOT->ProcessLine("#include <vector>");
Should vector be included automatically in a ROOT main program as for vector and vector?
–Shuwei