[Rivet] [Fastjet] PseudoJets constructor

Gavin Salam salam at lpthe.jussieu.fr
Tue Oct 5 14:23:15 BST 2010


Hi David,

That's not a bug but a design decision! Initialising the members takes 
some extra time (specifically if the PseudoJet is on the stack rather than 
the heap) and there are use cases where the initialisation might not be 
wanted (e.g. if you then pass the PseudoJet to a function that sets it, 
as happens with some of the subjet routines).

So instead you should write

   PseudoJet sum(0,0,0,0);
   for (...)
      sum += jet;

Having said that, for the next release we're revisiting the decision about 
default initialisation, so in the future PseudoJet() may well give a 
sensible object.

Cheers,
Gavin

- Gavin Salam ------------------------------------------------------------
   CERN, Princeton & LPTHE Paris              |    tel:  +41 22 767 2462
   http://www.lpthe.jussieu.fr/~salam/        |    fax:  +41 22 767 3850
------------------------------------------------- salam at lpthe.jussieu.fr -

On Tue, 5 Oct 2010, David Grellscheid wrote:

> Date: Tue, 5 Oct 2010 13:56:38
> From: David Grellscheid <david.grellscheid at durham.ac.uk>
> Reply-To: "Email the developers \\(subscription not required\\)"
>     <fastjet at projects.hepforge.org>
> To: fastjet at projects.hepforge.org
> Cc: d.e.winn at durham.ac.uk, Rivet <rivet at projects.hepforge.org>
> Subject: [Fastjet] PseudoJets constructor
> 
> Hi!
>
> David Winn and I noticed a bug in FastJet: the empty constructor for
> PseudoJet leaves the member variables undefined instead of zeroing them.
>
> This makes it impossible to write constructs like
>
> PseudoJet sum;
> for (....)
>    sum += jet;
>
> because the initial 'sum' has undefined values.
>
>
> Instead of PseudoJet() {}, you need to explicitly set the values as
> PseudoJet() : _px(), _py(), _pz(), _E() {}
>
> This is a problem for any class that can be default-constructed.
>
> See you,
>
>   David
> _______________________________________________
> Fastjet mailing list
> Fastjet at projects.hepforge.org
> http://www.hepforge.org/lists/listinfo/fastjet
>


More information about the Rivet mailing list