[ROOT] SIGSEGV in TLorentzVector addition !!

From: Stanislav NESTEROV (Stanislav.Nesterov@cern.ch)
Date: Fri Aug 02 2002 - 15:35:35 MEST


    Hi Rene,
    I've try to run script that uses TLorentzVector and TVector3, and in 
some very simple cases this script is aborted via segfault.

  This is it (at the end it crashes on tmp=vpk[0]+vpk[3])

   To run this script see 
"/afs/cern.ch/user/n/nesterov/public/"
 for neccessary files (pi_nodedx_all.root).
----------------------------------------------------------------------
	#define PIM 139.56995*1e-3
#define KM  493.677*1e-3
#define PZM 134.9764*1e-3
#define NTPNUM  "h96"
void testLorentz(){
  gSystem->Load("libPhysics.so");
  Double_t M[4] = {KM,KM,KM,KM};
  Double_t M1122[4] = {KM,KM,PIM,PIM};
  TFile f("pi_nodedx_all.root");
  TTree * tree = (TTree*)f.Get(NTPNUM);
  
  if (!tree) {cout <<"Bad luck"<<endl; return;}  
  Float_t ptpi[4],thtpi[4],phpi[4];
  tree->SetBranchAddress("Ptpi",ptpi);
  tree->SetBranchAddress("Phipi",phpi);
  tree->SetBranchAddress("Thtpi",thtpi);
  TVector3 p[4];
  TLorentzVector v[4],g,vpk[4];
  for (Int_t i=0;i<tree->GetEntries();i++)
  {
    if (i%1000 == 0 ) cout <<i<<endl;
    tree->GetEntry(i);
    for (Int_t j=0;j<4;j++) // Setting vectors;
    {
      p[j].SetPtThetaPhi(TMath::Abs(ptpi[j]),thtpi[j],phpi[j]);
      v[j].SetVectM(p[j],M[j]);
    }
    g = v[0]+v[1]+v[2]+v[3];

    Float_t lb=g.M();
    if ((lb<2.11)) {
           TLorentzVector tmp; //   Local declaration
                for (Int_t j=0;j<4;j++) {
                        vpk[j].SetVectM(p[j],M1122[j]);
                }
                tmp = vpk[0]+vpk[3];  // Seg. fault!!!!!!!!!
                cout<<"Success"<<endl;
    }

  }
}
---------------------------------------------------------

1) If I moved `tmp' declaration outside if(lb<2.11) scope, everything is 
OK.

2) If I go into debug mode and jump onto local declaration -- everything 
is OK

3) If I don't read tree values --- everything is OK.

It's just mistics!!

		Best regards,
				Stanislav.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:03 MET