Can anyone find a reason why this wouldn’t work? When I execute the code, I don’t get any errors, but a completely blank tree and nothing in the while loop seems to be executed.
[code]
#include
#include
#include
#include
#include “TDatime.h”
#include “TTree.h”
#include “TFile.h”
#include “TSystem.h”
void main()
{
bool infile;
std::string output=“BCTdata”;
std::string title=“BCTdata”;
const int Npoints = 12000, Nfiles=119;
int ret =-1, j=0, k=0;
float in, vb, vsmb, arr[Nfiles][Npoints], sum1[Npoints], av;
float v[Npoints], vsm[Npoints];
TFile fc2011((output+".root").c_str(),“recreate”); //creates new ROOT file
TTree tc2011(output.c_str(),title.c_str()); //creates new tree
tc2011.Branch(“vsmb”,&vsmb,“vsmb/F”);
tc2011.Branch(“voltage”,&vsmb,“voltage/F”);
tc2011.Branch(“j”,&j,“j/I”);
tc2011.Branch(“k”,&k,“k/I”);
tc2011.Branch(“av”,&av,“av/F”);
void *dirp=gSystem->OpenDirectory(“Users/Charlie/root/BCTdata”);
const char *pathandfile= (“Users/Charlie/root/BCTdata/”+infile);
while(infile= gSystem->GetDirEntry(dirp))
{
FILE *file;
file = fopen(pathandfile,"r");
for(int i=0; i<=Npoints;i++)
{
ret = fscanf(file,"%g%*c",&in);
v[i] = in;
tc2011.Fill();
}
cout <<hello<<endl;
fclose(file); //close file
}
tc2011.Print(); //print tree in terminal
tc2011.Write(); //write tree to file
gSystem->FreeDirectory(dirp);
}[/code]
I went through the errors that had previously appeared and fixed them as root suggested me too, but it didn’t really seem to solve anything. Thanks for any help!