Comment 1 for bug 1255632

Revision history for this message
Olivier Mattelaer (olivier-mattelaer) wrote : Re: [Bug 1255632] [NEW] Problem with static variables in standalone_cpp

Hi,

> the problem is that the second time the function is being called, the static members already exist in the memory and the 0s are not being assigned as the constructors are not called.

That's exactly the expected behavior that we want for those three variables.

But by looking at that code, I'm surprise to see the line:
sum_hel = min(sum_hel, ngood);
while I would have expect
sum_hel = max(sum_hel, ngood);
This forces sum_hel to always stay at zero and therefore you never pass by the optimized part (summing only on the non zero helicities.

So clearly, I don't understand what your problem is.

Cheers,

Olivier

On Nov 27, 2013, at 6:50 PM, Aurelijus Rinkevicius <email address hidden> wrote:

> Public bug reported:
>
> In some cases while using standalone_cpp classes multiple times, the
> static variables start to cause problems. In particular, the following:
>
> in void CPPProcess::sigmaKin() { ...
> static int ntry = 0, sum_hel = 0, ngood = 0;
> ...}
>
> the problem is that the second time the function is being called, the static members already exist in the memory and the 0s are not being assigned as the constructors are not called. The possible solution could be:
> static int ntry, sum_hel, ngood;
> ntry = 0, sum_hel = 0, ngood = 0;
>
> ** Affects: madgraph5
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are a member of MadTeam,
> which is subscribed to MadGraph5.
> https://bugs.launchpad.net/bugs/1255632
>
> Title:
> Problem with static variables in standalone_cpp
>
> Status in The MadGraph Matrix Element Generator version 5:
> New
>
> Bug description:
> In some cases while using standalone_cpp classes multiple times, the
> static variables start to cause problems. In particular, the
> following:
>
> in void CPPProcess::sigmaKin() { ...
> static int ntry = 0, sum_hel = 0, ngood = 0;
> ...}
>
> the problem is that the second time the function is being called, the static members already exist in the memory and the 0s are not being assigned as the constructors are not called. The possible solution could be:
> static int ntry, sum_hel, ngood;
> ntry = 0, sum_hel = 0, ngood = 0;
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/madgraph5/+bug/1255632/+subscriptions