in the "B1ActionInitialization.cc SetUserAction(new B1SteppingAction(eventAction, PrimaryPositronElectronExitFlag));
but I get this error
C:\B1\src\B1ActionInitialization.cc(67,51): error C2065: 'PrimaryPositronElectronExitFlag': identificatore non dichiara
to [C:\B1\B1-build\exampleB1.vcxproj]
PrimaryPositronElectronExitFlag is not known in your B1ActionInitialization.
You could create for example a fPrimaryPositronElectronExitFlag in B1ActionInitialization.hhas you did in steppingaction.hh, and pass the parameter in line 100 in exampleB1.cc:
and SetUserAction(new B1SteppingAction(eventAction, PrimaryPositronElectronExitFlag));
in B1Actioninizialization.hh B1ActionInitialization(G4bool PrimaryPositronElectronExitFlag);
private:
G4bool fPrimaryPositronElectronExitFlag;
in ExampleB1.cc runManager->SetUserInitialization(new B1ActionInitialization(PrimaryPositronElectronExitFlag));
but I get this error
PhysicsList.cc
C:\B1\include\B1ActionInitialization.hh(40,28): error C2061: errore di sintassi: identificatore 'G4bool' (compilazione del file di origine C:\B1\src\B1Acti
onInitialization.cc) [C:\B1\B1-build\exampleB1.vcxproj]
C:\B1\include\B1ActionInitialization.hh(48,12): error C3646: 'fPrimaryPositronElectronExitFlag': identificatore di override sconosciuto (compilazione del f
ile di origine C:\B1\src\B1ActionInitialization.cc) [C:\B1\B1-build\exampleB1.vcxproj]
C:\B1\include\B1ActionInitialization.hh(48,44): error C4430: identificatore di tipo mancante, verrà utilizzato int. Nota: default-int non è più supportato
in C++ (compilazione del file di origine C:\B1\src\B1ActionInitialization.cc) [C:\B1\B1-build\exampleB1.vcxproj]
C:\B1\src\B1ActionInitialization.cc(39,2): error C2511: 'B1ActionInitialization::B1ActionInitialization(G4bool)': funzione membro in overload non trovata i
n 'B1ActionInitialization' [C:\B1\B1-build\exampleB1.vcxproj]
C:\B1\include\B1ActionInitialization.hh(37): message : vedere la dichiarazione di 'B1ActionInitialization' [C:\B1\B1-build\exampleB1.vcxproj]
C:\B1\src\B1ActionInitialization.cc(40,34): error C2612: 'identificatore' finale non valido nell'elenco degli inizializzatori di basi/membri [C:\B1\B1-buil
d\exampleB1.vcxproj]
C:\B1\src\B1ActionInitialization.cc(72,1): fatal error C1004: fine del file imprevista [C:\B1\B1-build\exampleB1.vcxproj]
PhysicsListMessenger.cc
StepMax.cc
You are running into basic C++ programming issues, nothing specific to Geant4. C++ is a strongy typed language. Every variable you use must be declared, and initialized with a specific value, before you reference it. I would recommend a good, introductory C++ text in order to understand these issues.
Thank you @mkelsey i compiled and I runned (but I really didn’t see the comma…I did copy and paste from the stepping action and I did a mistake during the copy and paste without see it!)
…but now I think to have a Geant 4 problem…
in the steppingaction I’ve
Please get some basic texts and instruction in writing C++. This is not Python.
You don’t create strings and expect them to be “interpreted” at run time. You write actual code.
G4String var1 = "This is a text string"; // this is just a bunch of characters
G4String var2 = "E>0 && x<5*cm"; // this is *also* just a bunch of characters
if (var2) { // This tests whether the var2 variable is not equal to zero
That if statement does not evaluate the string as math. The string is just a bunch of characters (bytes in memory). All it is doing is testing that the variable var2 is located at a memory location which is not 0x00000000.
If you want to evaluate a condition, then you put the condition into the if statement:
if (E>0 && x < 5*cm) { // This tests the _variables_ E and x
Thank you @mkelsey i see…and isn’t there a way to do what I wanted to do (i.e. to define a text to be evalueted?
I explain…I have there possibilities
Primari particles outgoing the targets
Secondary muons outgoing the targets
Photons outgoing the world (ie cracking for no step )…then I would like to define the 3 cases.
Them i should define a “string” or other kind of variable to write in the if that It’s interpreted by the if
No. Geant4 is a C++ application. You write C++ code, using the features and limitations of the language. You already wrote the conditional expression, just stop putting it in quotes, and put into the if expression directly. Please learn the basics of C++, so that you will have a clear understanding of how the software is written.
I have heard of a Python interface to C++, which lets you do things in Python instead, but I have never used it myself.