Hello rooters,
I’m trying to fill a TTree with a std::vector and an Integer value.
This is working fine as long as I use root.
When I use another compiler I get the TTree with the Integer value but with an empty branch for the vector.
Following you can find an example program which shows this behaviour.
Thanks for your help.
Regards,
Christian
#include <iostream>
#include <vector>
#include "TFile.h"
#include "TTree.h"
#include "TROOT.h"
int main(int argc, char*argv[]) {
gROOT->ProcessLine("#include <vector>");
TFile *myFile = TFile::Open("tempfile.root", "RECREATE");
TTree *myTree = new TTree("myTree","myTree data");
std::vector<float> *myvector = new std::vector<float>();
int myInt;
myTree->Branch("myvector",&myvector);
myTree->Branch("myInt",&myInt);
myvector->push_back(11);
myvector->push_back(12);
myInt = 55;
myTree->Fill();
myFile->Write();
myFile->Close();
return EXIT_SUCCESS;
}