I have installed root 4.04.02f, and now when I recompile and run some code I get:
Error in TTree::Fill: Failed filling branch:event.p, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.p, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.p, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.Vertz, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.Vertd, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.E, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.P, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.p, nbytes=-1
Error in TTree::Fill: Failed filling branch:event.Charge, nbytes=-1
When previously, with version 4.03.02, I got no such errors. The pertinent piece of code is in a source file main.cpp, and is as follows:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "test_file.h"
#include "TROOT.h"
#include "TTree.h"
#include "do_kinematics.h"
#include "slow_cuts.h"
#include "track_cuts.h"
#include "check_method.h"
#include "get_lumi.h"
void init_bb(int ibb[][33]);
int main(int argc, char **argv)
{
Int_t nevent;
int i,j;
char filename[100];
char outfilename[100]="rho_kin.root";
TRACK track;
SLOW slow;
EVENT event;
//int igbb[5][33]; // i.e. for year [0..4] and bad bit [0..32]
int ignore_bb[5][33];
int passed_slow = 0, failed_slow = 0;
int passed_track = 0, failed_track = 0;
int bb_count[33];
float int_abs_lumi = 0; // integrated absolute lumi == int lumi*coeff*target const
for(i=0;i<33;i++)
bb_count[i] = 0;
if(argc > 2 && argv[2] != NULL)
strcpy(outfilename, argv[2]);
test_file(argv[1], filename);
TFile *f = new TFile(filename); // input root file
TTree *h1 = (TTree*)f->Get("h1");
TTree *out = new TTree("event", "DIS events");
nevent = h1->GetEntries();
h1->SetBranchAddress("Vertz", track.VertZ);
h1->SetBranchAddress("Vertd", track.VertD);
h1->SetBranchAddress("Theta", track.Theta);
h1->SetBranchAddress("Phi", track.Phi);
h1->SetBranchAddress("E", track.E);
h1->SetBranchAddress("P", track.P);
h1->SetBranchAddress("Px", track.Px);
h1->SetBranchAddress("Py", track.Py);
h1->SetBranchAddress("Pz", track.Pz);
h1->SetBranchAddress("Type", track.Type);
h1->SetBranchAddress("rxoff", track.rxoff);
h1->SetBranchAddress("ryoff", track.ryoff);
h1->SetBranchAddress("rxpos", track.rxpos);
h1->SetBranchAddress("rypos", track.rypos);
h1->SetBranchAddress("rxslope", track.rxslope);
h1->SetBranchAddress("ryslope", track.ryslope);
h1->SetBranchAddress("Charge", track.Charge);
h1->SetBranchAddress("Method", track.Method);
h1->SetBranchAddress("bb", slow.bb);
h1->SetBranchAddress("year", &slow.year);
h1->SetBranchAddress("ebeam", &slow.ebeam);
h1->SetBranchAddress("Gastype", &slow.GasType);
h1->SetBranchAddress("Burstnum", &slow.BurstNum);
h1->SetBranchAddress("Burstlen", &slow.BurstLen);
h1->SetBranchAddress("Evnum", &event.Evnum);
h1->SetBranchAddress("Lumi", &slow.Lumi);
h1->SetBranchAddress("rbpol", &slow.rbPol);
h1->SetBranchAddress("rbpolfit", &slow.rbPolFit);
h1->SetBranchAddress("rbpolerr", &slow.rbPolErr);
out->Branch("Vertz", track.VertZ, "Vertz[3]/F");
out->Branch("Vertd", track.VertD, "Vertd[3]/F");
out->Branch("Theta", track.Theta, "Theta/F");
out->Branch("Phi", track.Phi, "Phi/F");
out->Branch("year", &slow.year, "year/I");
out->Branch("ebeam", &slow.ebeam, "ebeam/F");
out->Branch("E", track.E, "E[3]/F");
out->Branch("P", track.P, "P[3]/F");
out->Branch("p", track.p, "p[3][4]/F");
out->Branch("Charge", track.Charge, "Charge[3]/I");
out->Branch("Gastype", &slow.GasType, "Gastype/I");
out->Branch("Beampol", &slow.rbPol, "Beampol/F");
out->Branch("Beampolfit", &slow.rbPolFit, "Beampolfit/F");
out->Branch("Beampolerr", &slow.rbPolErr, "Beampolerr/F");
out->Branch("Mv", &event.Mv, "Mv/F");
out->Branch("DE", &event.DE, "DE/F");
out->Branch("tp", &event.tp, "tp/F");
out->Branch("bjx", &event.bjx, "bjx/F");
out->Branch("Q2", &event.Q2, "Q2/F");
out->Branch("W", &event.W, "W/F");
out->Branch("nu", &event.nu, "nu/F");
out->Branch("Mx2", &event.Mx2, "Mx2/F");
out->Branch("Mx", &event.Mx, "Mx/F");
out->Branch("t", &event.t, "t/F");
out->Branch("t0", &event.t0, "t0/F");
out->Branch("PdotP", &event.PdotP, "PdotP/F");
out->Branch("bjy", &event.bjy, "bjy/F");
out->Branch("Mkk", &event.Mkk, "Mkk/F");
out->Branch("y", &event.y, "y/F");
init_bb(ignore_bb);
for(i=0;i<nevent;i++)
{
h1->GetEvent(i);
for(j=0;j<3;j++)
{
track.p[j][0] = track.E[j];
track.p[j][1] = track.Px[j];
track.p[j][2] = track.Py[j];
track.p[j][3] = track.Pz[j];
}
if(track_cuts_satisfied(track)) // track level (fiducial) cuts
{
passed_track++;
if(slow_cuts_satisfied(slow, ignore_bb, bb_count) && check_method(track)) // slow control cuts
{
passed_slow++;
do_ev_level_kinematics(track, slow, &event);
int_abs_lumi += get_lumi_burst(slow, event); // get abs lumi for this burst (will return zero for non-first event in burst)
out->Fill();
}
else
failed_slow++;
}
else
failed_track++;
}
TFile outf(outfilename, "RECREATE"); //output root file
out->Write();
outf.Close();
for(i=0;i<33;i++)
printf("bb_count[%d]: Number of events with bit %d bad: %d\n", i, i, bb_count[i]);
printf("Track cuts: events passed %d, events failed %d\n", passed_track, failed_track);
printf("Slow cuts: events passed %d, events failed %d\n", passed_slow, failed_slow);
printf("Total events = %d\n", nevent);
printf("integrated absolute luminosity = %f\n", int_abs_lumi);
return 0;
}
The code reads an existing root file with the tree “h1”, makes some kinematical calulations and applies cuts, then creates a new root file containing the tree “event”. I can’t see how what I did differs from the TTree example (root.cern.ch/root/html/examples/ … t.cxx.html). Anyone have any ideas? I read somewhere that the nbytes = -1 indicated that the output file was opened read-only, but if I comment out the three lines:
TFile outf(outfilename, "RECREATE"); //output root file
out->Write();
outf.Close();
The error persists, desipte no I/O taking place (at least, not for the output file).
Additionally, I found compiling version 4.03.02 problematic in that I had to add the line:
#include <errno.h>
below the other includes in krb5auth/src/TKSocket.cxx, otherwise the compiler would complain that in line 131, errno and ECONNABORTED were undefined. Anyone else experienced this?
Cheers,
Andy