I will try to summarize my question:
If i write the end of my code like this:
auto solidDetector = new G4Tubs("solidDetector", 0, raiofioouro, comprimento, 0, twopi);
auto logicDetector = new G4LogicalVolume(solidDetector, Ouro, "logicDetector");
auto fiointFisico = new G4PVPlacement(0, {0,0,0}, logicDetector, "Ânodo de Ouro", gasativoLogico, false, 0);
MySensitiveDetector *sensDet = new MySensitiveDetector("Ânodo de Ouro");
logicDetector->SetSensitiveDetector(sensDet);
return physWorld;
}
void MyDetectorConstruction::ConstructSDandField()
{}
It runs normally.
But, if i wrote the end part like this:
auto solidDetector = new G4Tubs("solidDetector", 0, raiofioouro, comprimento, 0, twopi);
auto logicDetector = new G4LogicalVolume(solidDetector, Ouro, "logicDetector");
auto fiointFisico = new G4PVPlacement(0, {0,0,0}, logicDetector, "Ânodo de Ouro", gasativoLogico, false, 0);
return physWorld;
}
void MyDetectorConstruction::ConstructSDandField()
{MySensitiveDetector *sensDet = new MySensitiveDetector("Ânodo de Ouro");
logicDetector->SetSensitiveDetector(sensDet);
}
It gives a segmentation fault.
The problem is that i have learned the second way to do the code. Now, i can’t understand why it is not running when i wrote in the void.
Is there any difference between one and another? How can i fix this error so that i can use it like the second way?