error:particleName’ was not declared

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

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

...
} 




}
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"

...

}

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
closed account (48T7M4Gy)
There isn't enough information here to answer your question.
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.
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
thank you so much kemort

I do appreciate your assistance.
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.