Hello, I am using root Version 5.14/00e. I have a subrotine that I wrote as a C++ program, which reads some datafrom a file and does some corrections. Later, I wrote a root program that proccesses the same data file, so I tried to make use of the subroutine that I already have. But, it did not work. In the subroutine, I am using vector data type. Now I wrote a stand-alone root program to understand what part does not work. I belive the problem is about vector data type. And I just found out that, I can read the data fine if I don't try to use the puch_back command. I searched the net and found some related topics but no clear answer. My program sometimes gives direct segmentation fault, and sometime gives error like:
root [0] .L aKinem.C
root [1] plot1();
4.236 1 2
0.78 0.865 3.093
-0.777 -0.854 1.171
Loop Compile Internal Error: Illegal instruction 1936946035 _vector.h:235:
0: illegal instruction 0x73737373 1936946035 1: illegal instruction 0x73737373 1936946035
I am printing the simplified version of the program below. Also attaching a sample data file. I will appreciate any help.
Thanks,
gROOT->Reset();
gSystem->Load("libPhysics");
#include <iostream.h>
#include <string.h>
#include "Riostream.h"
#include <stdio.h>
#include <math.h>
#include <TMath.h>
#include <TLorentzVector.h>
#include "TPaveStats.h"
#include <vector>
const int MPS = 5;
//// define global arrays
typedef struct
{
double beam;
int torus;
int run_num;
double zave;
int num_chan;
int sel_flag;
double px[MPS]; double py[MPS]; double pz[MPS];
double dc_theta[MPS];
double dc_phi[MPS];
double mass[MPS];
double tofmass[MPS];
double dedx[MPS];
double v_z[MPS];
int sector[MPS];
int q[MPS];
double beam_corr;
double torus_corr;
double zave_corr;
double px_corr[MPS]; double py_corr[MPS]; double pz_corr[MPS];
} Event_t; //// a custom data type
vector <Event_t> VEvent;
int plot1()
{
Event_t pEvent;
double input;
int part = 0;
ifstream evntin;
evntin.open("DataIn.dat",ios::in);
assert (!evntin.fail());
while(evntin>>input)
{
pEvent.beam = input; evntin >> pEvent.torus; evntin >> pEvent.num_chan; cout << pEvent.beam << "\t" << pEvent.torus << "\t" << pEvent.num_chan << endl; for( part = 1; part <= pEvent.num_chan; part++) { evntin >> pEvent.px[part]; evntin >> pEvent.py[part]; evntin >> pEvent.pz[part]; evntin >> pEvent.tofmass[part]; evntin >> pEvent.dc_theta[part]; evntin >> pEvent.dc_phi[part]; evntin >> pEvent.dedx[part]; evntin >> pEvent.sector[part]; evntin >> pEvent.q[part]; cout << pEvent.px[part] << "\t" << pEvent.py[part] << "\t" << pEvent.pz[part] << endl; } VEvent.push_back(pEvent);
}
evntin.close();
return;
}
Nevzat Guler
This archive was generated by hypermail 2.2.0 : Mon Mar 10 2008 - 17:50:01 CET