Problems with temporary variables in macros

From: Volker Hejny (V.Hejny@fz-juelich.de)
Date: Thu Nov 18 1999 - 08:56:32 MET


Hallo,

the problem:

I have an array of TLorentzVector defined, from which I want to
build invariant masses of every possible pair:

void ana() {
...
TLorentzVector ph[10];
...
// the vector is filled in the meanwhile
...
for(Int_t k1=0; k1<NumPh; k1++) {
  for(Int_t k2=k1+1;k2<NumPh; k2++) {
    TLorentzVector temp = ph[k1] + ph[k2];
    invmass->Fill(temp.M());
    }
  }
}
...
}

ok, it's not very effective to have this temporary variable, which
gets constructed and destructed, but it should run. I observed, that
temp is initialized only in a few loops, in the rest the value of
the loop(s) before is used, i.e. temp is some kind of static, but
not totally. The code runs fine, when I move the declaration of
temp just before the for()-loops.

This behaviour starts with the first version of 2.23, before I had no 
such problems.


Best regards,
Volker Hejny

-- 
Volker Hejny                    Tel: 02461/616853                      ** 
Institut f. Kernphysik          Fax: 02461/613930                     **
---------------------------------------------------------------- **  ** ---  
Forschungszentrum Juelich GmbH, D-52425 Juelich                    **



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:43 MET