Hello, I’m trying to add flags to my simulation.
I’m having a problem using an if.
In my exampleB1.cc I wrote
G4bool CircularTargetFlag=true; //switching on this flag simulation uses circular target
in my B1DetectorConstruction.hh
private:
G4bool fCircularTargetFlag;
and in the B1DetectorConstructio.cc
B1DetectorConstruction::B1DetectorConstruction(G4bool CircularTargetFlag, G4bool SecondTargetFlag, G4int TargMat, G4double pRMin, G4double pRMax, G4double pDz, G4double pSPhi, G4double pDPhi)
: G4VUserDetectorConstruction(),
fCircularTargetFlag(CircularTargetFlag),
and
if (fCircularTargetFlag){
G4Tubs* solidEnv =
new G4Tubs("Circular", //its name
fpRMin, fpRMax, 0.5*fpDz, fpSPhi, fpDPhi); //its size
}
but when I try to compile and run I get this error
159:27: error: ‘solidEnv’ was not declared in this scope
new G4LogicalVolume(solidEnv, //its solid
^~~~~~~~
/data_collamaf/DataFausto/Muon_Collider/II_anno/Simulazione_Geant/2021/231-10-05/B1/src/B1DetectorConstruction.cc:159:27: note: suggested alternative: ‘logicEnv’
new G4LogicalVolume(solidEnv, //its solid
^~~~~~~~
and I don’t understand the reason…
fCircularTargetFlag is initializated fo CircularTargetFlag value by the line
fCircularTargetFlag(CircularTargetFlag),
then if (fCircularTargetFlag){
should work and create the solid…but it looks like that the if doesn’t work…
B1DetectorConstruction.hh (2.7 KB)
exampleB1.cc (4.6 KB)
B1DetectorConstruction.cc (7.5 KB)