I have the following problem. I want to use TNtuple, and for that I made the following program to test it:
#include <iostream>
#include <TTree.h>
#include <TNtuple.h>
#include <TFile.h>
using namespace std;
int main(int argc, char **argv) {
TFile * outPut = new TFile("outPut.root","RECREATE");
TNtuple * myTree = new TNtuple("meins", "", "a:b:c:d");
myTree->Fill(1,2,3,4);
myTree->Fill(1,2,5,6);
myTree->Fill(1,2,7,8);
myTree->Fill(1,2,9,10);
outPut->Write();
outPut->Close();
}
}
the compiling works without any error, but if I try to start the program, there come the error:
Warning in <TFile::Write>: file outPut.root not opened in write mode
Warning in <TFile::Write>: file outPut.root not opened in write mode
*** Break *** segmentation violation
Error: Symbol myTree is not defined in current scope (tmpfile):1:
Error: Failed to evaluate myTree->Project("tmp","a:b","")
*** Interpreter error recovered ***
Unless you ntuple was named ‘myTree’ (in which case CINT would have done the load of the object for you) you are missing the reading the ntuple:root [0] TFile *_file0=TFile::Open("outPut.root")
root [1] TTree*myTree = 0; _file0->GetObject("meins",myTree);
root [2] TH2D* tmp = new TH2D("tmp","",100,0,100,100,0,100)
root [3] myTree->Project("tmp","a:b","")