error:particleName’ was not declared

Aug 27, 2015 at 12:36pm
Dear All

I have tried to include the compton scattering in one of the examples in geant4.10.01.p02

but in the run section it gave me this error

C1PrimaryGeneratorAction.cc:98:5: error: ‘particleName’ was not declared in this scope
if (particleName == "gamma") {

please any help .

thanks

Aug 27, 2015 at 12:57pm
closed account (48T7M4Gy)
Must declare particleName:-

eg

1
2
3
4
5
6
7
8
9
10
11
12
...
int main() {
string particleName ; // minimum declaration of variable particleName

... some processing to change particleName (maybe)

...

if(particlename == "gammma etc

...
} 




}
Aug 27, 2015 at 3:23pm
thank you so much,

eventhough I did this definition at the begining ,
but once I define the particel again it works

G4string particleName ;

if(particlename == "gamma"

...

}

Aug 27, 2015 at 3:25pm
but now , if you do not mind , how to create the output file to see the results and to be able to analyse them.

thanks
Aug 27, 2015 at 10:27pm
closed account (48T7M4Gy)
There isn't enough information here to answer your question.
Aug 27, 2015 at 11:53pm
I meant to create output.txt file

this is my desired data (shown in terminal) but I want them in file.txt

G4cout <<std::setw(6)<<"Energy Desposited--->"<<""<<std::setw(6)<<edepStep<<""
<<G4endl;

it might be easy but I am still crawl .

thank you so much for your thoughts.
Aug 28, 2015 at 5:06am
closed account (48T7M4Gy)
Your question is a bit too wide-sweeping in nature for a simple answer.

Try http://www.cplusplus.com/doc/tutorial/files/ for a good start but I get the impression you are starting from an earlier position than that so try http://www.cplusplus.com/doc/tutorial/

The tutorials are very helpful.
Cheers and good luck. :)
Last edited on Aug 28, 2015 at 4:24pm
Aug 28, 2015 at 3:22pm
thank you so much kemort

I do appreciate your assistance.
Aug 28, 2015 at 3:43pm
my desired data (shown in terminal) but I want them in file

There is always output redirection. That does not require anything from the program.

Let say that the name of a program is "foo.exe" and it writes "Hello world" to the terminal:
C:\>foo.exe
Hello world
C:\>

Redirecting the output:
C:\>foo.exe > file.txt
C:\>

Topic archived. No new replies allowed.