Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!
Geant4 Version: 11.2
Operating System: Debian 11
Compiler/Version:
CMake Version:
Hello Geant4 experts,
I have another question regarding my detector set up, but this time I am stuck on the magnetic field for my set up. I want to create a homogeneous magnetic field only for a small part of my world volume. Therefore I define my magnet as a cylinder pointing along the z axis, as the z axis is my beam axis. Just before the magnet the target should be placed, such that the beam is deflected after the interaction in the target.
My beam starts at -50cm and the target is positioned at (0,0,0). The Magnet starts at (0,0,0)m and extends to (0,0,1)m. Now the beam spot that I record with my ECal is not deflected if I place the beam at -1mm in front of the target, however it is deflected if I place the beam -50cm in front of the target. Why is that so? Should the beam position not be irrelevant, as the magnetic field starts after the target and only deflects particles then?
I have created the magnetic field and magnet the same way as described in the G4 book for application developers and simply cannot find the error.
This is the part in my DetectorConstruction.cc file with the magnetic field and magnet:
G4ThreeVector magFieldValue = G4ThreeVector(0, 0.9*tesla, 0); // defines the field strength;
G4UniformMagField* magField = new G4UniformMagField(magFieldValue); // created magnetic field
G4FieldManager* fieldManager = G4TransportationManager::GetTransportationManager()->GetFieldManager(); // create a field manager
fieldManager->SetDetectorField(magField); // and set field here
G4Mag_UsualEqRhs* equation = new G4Mag_UsualEqRhs(magField); // create EoM
G4ChordFinder* chordFinder = new G4ChordFinder(magField, 1.0e-2*mm, new G4ClassicalRK4(equation)); // create chord finder
fieldManager->SetChordFinder(chordFinder);
// Magnet
G4double innerR = 50*cm;
G4double outerR = 90*cm;
G4double height = 1.0*m; // magnet will be in total this 'long'
G4double startAngle = 2.86*deg;
G4double spanningAngle = (360-2.86)*deg;
G4Tubs* solidMagnet = new G4Tubs("magnet", innerR, outerR, height/2, startAngle, spanningAngle);
//G4NistManager* nist = G4NistManager::Instance();
G4Material* iron = nist->FindOrBuildMaterial("G4_Fe");
G4LogicalVolume* magnetLogical= new G4LogicalVolume(solidMagnet, iron, "LogicalMagnet");
G4ThreeVector magnPosition = G4ThreeVector(0,0,height/2);
new G4PVPlacement(0, magnPosition, magnetLogical, "magnet", worldLogical, false, 0, true);
magnetLogical->SetFieldManager(fieldManager, true);
And see my DetectorConstruction.cc attached.
DetectorConstruction.cc (16.6 KB)
I would be very happy for any kind of help!
Thanks in advance & kind regards,
Laney Klipphahn