Using Doubles vs. Floats In TTree

Hi All,

I have been trying to set up a simple TTree that includes Ints and Doubles, each as separate branches. My program crashes when I go to draw a scatter plot if I choose doubles but runs fine if I use floats.

The error I am getting is:

*** Break *** segmentation violation
/Users/Jon/BNL/projects/beamlab/beamlab.app/Contents/MacOS/11627: No such file or directory
Attaching to process 11627.
Reading symbols for shared libraries . done
Reading symbols for shared libraries … done
0x923e0cb5 in wait4 ()

Here is the relevant code:

    Int_t regn;

Double_t Z, Bz, eperp, elong, e6D, Ldim, Pzavg, beta, alpha, betaL, alphaL, n0, n1, n2, Lcan_eVs, sigmaE, sigmaT, corrE, corrT, sigmaE_c, xavg, yavg, Dx, Dy, Dr, Dr2;


std::cout << "Reading ECALC9 data into ROOT tree.\n";

std::vector<Double_t> v;
TFile *f=new TFile("ECALC9.root", "CREATE");
ecalc9data->Branch("regn", &regn, "regn/I");
ecalc9data->Branch("Z", &Z, "Z/D"); 
ecalc9data->Branch("Bz", &Bz, "Bz/D"); 

for(int y=0;y<v.size();y+=27)
{
regn=v[y];
Z=v[y+1];
Bz=v[y+2];
}

ecalc9data->Fill();

}

ecalc9data->Print();

f->Write();
f->Close();

And, then in a different method I have:

void TICOOLout::drawecalc9data(TQtWidget*& widget)
{

ecalc9data->SetMarkerColor(kWhite);
widget->GetCanvas()->cd();
ecalc9data->Draw("Bz:Regn","", "");
widget->GetCanvas()->Update();

}

The code runs fine if I use “/F” in my tree definition and set all variables as Float_t.

Could anybody shed some light on what may be going awry?

Thanks in advance.

-Jon

Hi,

The code you copied seems fine, most likely there is a memory over-write somewhere in your code (try valgrind to pinpoint it) that is ‘moved’ to a fatal location when you use the large size type.

Cheers,
Philippe.

PS. Also the logic for setting your variable seems odd, it look like you are looping over the vector but only using its end (i.e. the last iteration).