RE: [ROOT] one problem

From: Axel Naumann (axel@fnal.gov)
Date: Fri Apr 27 2001 - 20:50:56 MEST


Hi,

you're defining "Particle MCpart" in the wrong way. Look at how the "for"
block looks like for the different iterations (just write it out and
substitute "i" with its actual value)...

So here's how it should be:

Particle* MCpart[2];
for (Int_t i = 0; i < 2; i ++)
   MCpart[i] = new Particle(emcid[i], emcpx[i], emcpy[i], emcpz[i],emcE[i]);

Now the array MCpart is defined once (and correctly), and its entries are
set in the for loop.

Axel.

> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
> [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Junjie Zhu
> Sent: Friday, April 27, 2001 12:20 PM
> To: roottalk@pcroot.cern.ch
> Subject: [ROOT] one problem
>
>
>
> Hi, Rooters:
>
> I have one problem about Root:  for each event, I want to generate two
> particles and I have written the class Particle (this class works very
> well), for the event loop,  the code is as followed:
>
> for (Int_t i = 0; i < 2; i ++){
> Particle MCpart[i] = new Particle(emcid[i], emcpx[i], emcpy[i],
> emcpz[i],emcE[i]);
> }
>
> cout << "MCpart[0] -> pt() = " << MCpart[0] -> pt() << endl;
> cout << "MCpart[1] -> pt() = " << MCpart[1] -> pt() << endl;
> // pt() is a member function of Particle
>
> Then I run it, and got the following error message:
>
> Error: Non-static-const variable in array dimention FILE:electron.C
> LINE:80
>  (cint allows this only in interactive command and special form macro
> which is special extension. It is not allowed in source code. Please
> ignore subsequent errors.)
>
> It seems that this is a syntax problem, but I do not know how to
> solve it,
> any idea about it?
>
> ROOT Version:  2.23/11
> CINT/ROOT C/C++ Interpreter version: 5.14.25
>
> Jim
>
>
>
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:43 MET