Re: vector data type

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Mon, 10 Mar 2008 12:03:51 +0100


Hi Nevzat,

could you please use
gSystem->Load("libPhysics");
.L aKinem.C+
It will speed up your script and circumvent this problem with CINT's bytecode optimization. You must remove

   gROOT->Reset();
   gSystem->Load("libPhysics");
from the script. If you need to have it working as interpreted script then please create a dictionary for vector<Event_t> using e.g. the loader.C approach shown here <http://root.cern.ch/phpBB2/viewtopic.php?t=2294#8622>.

Cheers, Axel.

On 2008-03-10 11:08, Nevzat Guler wrote:
> Hello,
> I am using root Version 5.14/00e.
> I have a subrotine that I wrote as a C++ program, which reads some data
> from 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 p[MPS];
> double e[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];
> double e_corr[MPS];
> double v_z_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
>
Received on Mon Mar 10 2008 - 12:03:58 CET

This archive was generated by hypermail 2.2.0 : Mon Mar 10 2008 - 17:50:01 CET