Hello,
I am a new root user and I am trying to store in a rootfile (“doesnotwork.root”) some events selected from another rootfile (whose path is “FILENAME”).
I can create the output one and make root write the tree (t3) into it, because when I try to open the rootfile via Tbrowser I find my variables (“e” and “time”), but if I try to see an histogramme of the contents of one of these two variables I get this error so many times:
Error in TFile::ReadBuffer: error reading all requested bytes from file doesnotwork.root, got 0 of 1919
I’ve tried everything I know, someone please help me out.
Thanks
Guido
// --------------------------------------------------------------------------
// Open rootfile and get # of events
// --------------------------------------------------------------------------
TFile *f=new TFile("doesnotwork.root","RECREATE"); // there I will write the result of the selection
TFile *rootfile=new TFile(FILENAME,"UPDATE"); // from here I load data
if (!(rootfile->IsOpen())){
printf("I had trouble opening the rootfile.\n");
printf("I'm sorry, but I have to terminate here.\n");
exit(EXIT_FAILURE);
}
// go to folder
gDirectory->cd("PROD2NTU");
// go to tree
TTree *alberello;
gDirectory->GetObject("h1;1",alberello);
NEVENTI = alberello->GetEntries();
cout << "In " << FILENAME << " sono registrati " << NEVENTI << "eventi." << endl;
gDirectory->pwd();
// some code ….
///*--------------------------------------------------------------- needs debugging
// make a new TTree to organize data of interesting tracks
TTree *t3=new TTree("t3","A nice TTree");
Float_t e,time;
TBranch *br1 = t3->Branch("e",&e,"e/F");
TBranch *br2 = t3->Branch("time",&time,"time/F");
//*/
for(i=0;i<NEVENTI;i++){
alberello->GetEntry(i);
// some other code...
if(crystal[evento.cry[k]]==1){ // if track hits the crystal which gave a signal add the signal to histogramme
//* ------------------------------------- needs debugging
e=(Float_t)evento.e[k];
time=(Float_t)evento.time[k];
t3->Fill();
// cout << "e vale " << e << " time vale " << time << endl; // DEBUG
//*/
if(evento.time[k]>1500 && evento.time[k]<2500){ // cut on TDC counts
hADC->Fill(evento.e[k]);
hTDC->Fill(evento.time[k]);
}
}
}
padup->cd();
hADC->Draw();
hADC->Write();
paddown->cd();
hTDC->Draw();
hTDC->Write();
///* ------------------------------------------------------- needs debugging
f->cd();
gDirectory->pwd();
t3->Write();
f->Close();
//*/