/// @file AllPixDetectorMessenger.cc /// @brief Implementation of the Allpix detector messenger class. #include "AllPixDetectorMessenger.hh" #include "G4UIdirectory.hh" #include "G4UIcmdWithAString.hh" #include "G4UIcmdWithAnInteger.hh" #include "G4UIcmdWithADoubleAndUnit.hh" #include "G4UIcmdWithoutParameter.hh" #include "G4UIcmdWith3VectorAndUnit.hh" #include "G4UIcmdWithADoubleAndUnit.hh" // Allpix include statements. #include "AllPixDetectorConstruction.hh" // // AllPixDetectorMessenger constructor. // AllPixDetectorMessenger::AllPixDetectorMessenger( AllPixDetectorConstruction* AllPixDet) : m_AllPixDetector(AllPixDet) { // Setup the directory for Allpix commands. m_allpixDir = new G4UIdirectory("/allpix/"); m_allpixDir->SetGuidance("UI commands MedipixG4"); // Setup the directory for Allpix commands. m_detDir = new G4UIdirectory("/allpix/det/"); m_detDir->SetGuidance("detector control"); // Setup the directory for the configuration commands. m_configDir = new G4UIdirectory("/allpix/config/"); m_configDir->SetGuidance("Allpix configuration"); // Setup the directory for the "extra" commands. m_detDir = new G4UIdirectory("/allpix/extras/"); m_detDir->SetGuidance("extras"); // Setup the directory for the laboratory configuration commands. m_labDir = new G4UIdirectory("/allpix/lab/"); m_labDir->SetGuidance("Configuration of the laboratory."); #ifdef _EUTELESCOPE m_detDir = new G4UIdirectory("/allpix/eudet/"); m_detDir->SetGuidance("EUDET"); #endif // Command for setting the detector ID. m_detIdCmd = new G4UIcmdWithAnInteger("/allpix/det/setId", this); m_detIdCmd->SetGuidance("Detector ID"); m_detIdCmd->SetParameterName("ID", true); m_detIdCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The detector position. m_detPosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/det/setPosition", this); m_detPosCmd->SetGuidance("Set position of the center of the Si wafer,"); m_detPosCmd->SetGuidance("If you call this function N times there will be N detectors."); m_detPosCmd->SetParameterName("posx", "posy", "posz", false, false); // non omittable, no default m_detPosCmd->SetUnitCategory("Length"); m_detPosCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The detector rotation. m_detRotCmd = new G4UIcmdWith3VectorAndUnit("/allpix/det/setRotation", this); m_detRotCmd->SetGuidance("Set rotation of a medipix. If you don't call this command the medipix"); m_detRotCmd->SetGuidance("will be placed without rotation."); m_detRotCmd->SetParameterName("rotx", "roty", "rotz", false, false); // non omittable, no default m_detRotCmd->SetUnitCategory("Angle"); m_detRotCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The detector foil thickness. m_detFoilThicknessCmd = new G4UIcmdWithADoubleAndUnit("/allpix/det/setFoilThickness",this); m_detFoilThicknessCmd->SetGuidance("Sets the detector's aluminium foil thickness."); m_detFoilThicknessCmd->SetParameterName("FoilThickness",false); m_detFoilThicknessCmd->SetUnitCategory("Length"); m_detFoilThicknessCmd->AvailableForStates(G4State_PreInit,G4State_Idle); /////////// m_UpdateCmd = new G4UIcmdWithoutParameter("/allpix/det/update",this); m_UpdateCmd->SetGuidance("Update geometry."); m_UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); m_UpdateCmd->SetGuidance("if you changed geometrical value(s)."); m_UpdateCmd->AvailableForStates(G4State_Idle); /////////// m_HighTHLCmd = new G4UIcmdWithADoubleAndUnit("/allpix/det/setHighTHL",this); m_HighTHLCmd->SetGuidance("High Threshold."); m_HighTHLCmd->SetParameterName("highTHL", false, false); m_HighTHLCmd->SetUnitCategory("Energy"); m_HighTHLCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_LowTHLCmd = new G4UIcmdWithADoubleAndUnit("/allpix/det/setLowTHL",this); m_LowTHLCmd->SetGuidance("Low Threshold."); m_LowTHLCmd->SetParameterName("lowTHL", false, false); m_LowTHLCmd->SetUnitCategory("Energy"); m_LowTHLCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_AcqTimeCmd = new G4UIcmdWithADoubleAndUnit("/allpix/det/setAcqTime",this); m_AcqTimeCmd->SetGuidance("Aquisition time."); m_AcqTimeCmd->SetParameterName("acqTime", false, false); m_AcqTimeCmd->SetUnitCategory("Time"); m_AcqTimeCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_HVCmd = new G4UIcmdWithADoubleAndUnit("/allpix/det/setHV",this); m_HVCmd->SetGuidance("Bias voltage."); m_HVCmd->SetParameterName("HV", false, false); //m_HVCmd->SetUnitCategory(""); m_HVCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_ClockCmd = new G4UIcmdWithADoubleAndUnit("/allpix/det/setClock",this); m_ClockCmd->SetGuidance("The clock."); m_ClockCmd->SetParameterName("Clock", false, false); m_ClockCmd->SetUnitCategory("Frequency"); m_ClockCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // Detector information //---------------------- // // Chip ID // m_chipIdCmd = new G4UIcmdWithAString("/allpix/extras/setChipId", this); // m_chipIdCmd->SetGuidance("Set the chip ID (UUU-WWWW)"); // m_chipIdCmd->SetParameterName("Chip ID", false); // non omittable, no default // m_chipIdCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // Simulation configuration commands //----------------------------------- m_StepLengthSensor = new G4UIcmdWithADoubleAndUnit("/allpix/det/setMaxStepLengthSensor",this); m_StepLengthSensor->SetGuidance("User Limit. Max step length. Applies only to the sensor."); m_StepLengthSensor->SetParameterName("MaxStepLengthSensor", false, false); m_StepLengthSensor->SetUnitCategory("Length"); m_StepLengthSensor->AvailableForStates(G4State_PreInit, G4State_Idle); // // The output prefix (with path) // // TW - 2014-02-17 - do we want to do this here? // m_outputPrefix = new G4UIcmdWithAString("/allpix/config/setOutputPrefixWithPath", this); // m_outputPrefix->SetGuidance("Set output file prefix (path can be included). If no path is specified, the file will be written to ./"); // m_outputPrefix->SetParameterName("OutputPrefix", false); // m_outputPrefix->SetDefaultValue("allpixoutput"); // m_outputPrefix->AvailableForStates(G4State_PreInit, G4State_Idle); // // // The number of events to store per frame. // m_eventsPerFrame = new G4UIcmdWithAnInteger("/allpix/config/setEventsPerFrame", this); // m_eventsPerFrame->SetGuidance("The number of events (source particles) to store per frame"); // m_eventsPerFrame->SetParameterName("EventsPerFrame", true); // m_eventsPerFrame->AvailableForStates(G4State_PreInit, G4State_Idle); // Extras // Appliance structure placed with respect to the wrapper (medipix) m_detAppliancePosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/extras/setAppliancePosition", this); m_detAppliancePosCmd->SetGuidance("Set position of the detector appliance. If you don't call this command the"); m_detAppliancePosCmd->SetGuidance("structure will not be built."); m_detAppliancePosCmd->SetParameterName("posx", "posy", "posz", false, false); // non omittable, no default m_detAppliancePosCmd->SetUnitCategory("Length"); m_detAppliancePosCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // m_wrapperEnhancementCmd = new G4UIcmdWith3VectorAndUnit("/allpix/extras/setWrapperEnhancement", this); // m_wrapperEnhancementCmd->SetGuidance("Enhace the wrapper volume to include appliances, if needed"); // m_wrapperEnhancementCmd->SetParameterName("offsetx", "offsety", "offsetz", false, false); // non omittable, no default // m_wrapperEnhancementCmd->SetUnitCategory("Length"); // m_wrapperEnhancementCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The test structure is placed with respect to the lab frame. // This command lets the user select which test structure to use. m_testStructureNameCmd = new G4UIcmdWithAString("/allpix/extras/setTestStructure", this); m_testStructureNameCmd->SetGuidance("Choose the test structure. (string: \"None\", \"SourceTestBench\", \"LUCID\", \"TestBeam\")"); m_testStructureNameCmd->SetParameterName("TestStructure", false); // non omittable, no default m_testStructureNameCmd->SetDefaultValue("None"); m_testStructureNameCmd->SetCandidates("None SourceTestBench LUCID TestBeam"); m_testStructureNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The test structure position. m_testStructPosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/extras/setTestStructurePosition", this); m_testStructPosCmd->SetGuidance("Set position of the test structure. If you don't call this command the"); m_testStructPosCmd->SetGuidance("test structure will not be built."); m_testStructPosCmd->SetParameterName("posx", "posy", "posz", false, false); // non omittable, no default m_testStructPosCmd->SetUnitCategory("Length"); m_testStructPosCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The test structure rotation. m_testStructRotCmd = new G4UIcmdWith3VectorAndUnit("/allpix/extras/setTestStructureRotation", this); m_testStructRotCmd->SetGuidance("Set rotation of the test structure."); m_testStructRotCmd->SetParameterName("rotx", "roty", "rotz", false, false); // non omittable, no default m_testStructRotCmd->SetUnitCategory("Angle"); m_testStructRotCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The detector ID for the related sensor. m_testStructDetLinkCmd = new G4UIcmdWithAnInteger("/allpix/extras/setTestStructureDetLink", this); m_testStructDetLinkCmd->SetGuidance("Detector ID for related sensor"); m_testStructDetLinkCmd->SetParameterName("ID", true); m_testStructDetLinkCmd->AvailableForStates(G4State_PreInit, G4State_Idle); // The test structure shielding thickness. m_testStructureShieldingThicknessCmd = new G4UIcmdWithADoubleAndUnit("/allpix/extras/setTestStructureShieldingThickness",this); m_testStructureShieldingThicknessCmd->SetGuidance("Sets the test structure shielding thickness."); m_testStructureShieldingThicknessCmd->SetParameterName("ShieldingThickness",false); m_testStructureShieldingThicknessCmd->SetUnitCategory("Length"); m_testStructureShieldingThicknessCmd->AvailableForStates(G4State_PreInit,G4State_Idle); // Set the material for the world volume. m_worldMaterial = new G4UIcmdWithAString("/allpix/extras/setWorldMaterial", this); m_worldMaterial->SetGuidance("Set material for world volume. (string: \"Air\", \"Vacuum\")"); m_worldMaterial->SetParameterName("Material", false); // non omittable, no default m_worldMaterial->SetDefaultValue("Air"); m_worldMaterial->SetCandidates("Air Vacuum"); m_worldMaterial->AvailableForStates(G4State_PreInit, G4State_Idle); // Set the peak magnetic field. m_magFieldCmd = new G4UIcmdWithADoubleAndUnit("/allpix/extras/setPeakField",this); m_magFieldCmd->SetGuidance("Define magnetic field peak value."); m_magFieldCmd->SetGuidance("Magnetic field will be in Z direction."); m_magFieldCmd->SetParameterName("Bz",false); m_magFieldCmd->SetUnitCategory("Magnetic flux density"); m_magFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); // The laboratory configuration commands //--------------------------------------- m_labLatCmd = new G4UIcmdWithADoubleAndUnit("/allpix/lab/setLatitude",this); m_labLatCmd->SetGuidance("The latitude of the laboratory frame."); m_labLatCmd->SetParameterName("Latitude", false, false); m_labLatCmd->SetUnitCategory("Angle"); m_labLatCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_labLonCmd = new G4UIcmdWithADoubleAndUnit("/allpix/lab/setLongitude",this); m_labLonCmd->SetGuidance("The longitude of the laboratory frame."); m_labLonCmd->SetParameterName("Longitude", false, false); m_labLonCmd->SetUnitCategory("Angle"); m_labLonCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_labAltCmd = new G4UIcmdWithADoubleAndUnit("/allpix/lab/setAltitude",this); m_labAltCmd->SetGuidance("The altitude of the laboratory frame."); m_labAltCmd->SetParameterName("Altitude", false, false); m_labAltCmd->SetUnitCategory("Length"); m_labAltCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_labRollCmd = new G4UIcmdWithADoubleAndUnit("/allpix/lab/setRollAngle",this); m_labRollCmd->SetGuidance("The roll angle of the laboratory frame."); m_labRollCmd->SetParameterName("Roll", false, false); m_labRollCmd->SetUnitCategory("Angle"); m_labRollCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_labPitchCmd = new G4UIcmdWithADoubleAndUnit("/allpix/lab/setPitchAngle",this); m_labPitchCmd->SetGuidance("The pitch angle of the laboratory frame."); m_labPitchCmd->SetParameterName("Pitch", false, false); m_labPitchCmd->SetUnitCategory("Angle"); m_labPitchCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_labYawCmd = new G4UIcmdWithADoubleAndUnit("/allpix/lab/setYawAngle",this); m_labYawCmd->SetGuidance("The yaw angle of the laboratory frame."); m_labYawCmd->SetParameterName("Yaw", false, false); m_labYawCmd->SetUnitCategory("Angle"); m_labYawCmd->AvailableForStates(G4State_PreInit, G4State_Idle); m_sourceIdCmd = new G4UIcmdWithAString("/allpix/lab/setSourceId", this); m_sourceIdCmd->SetGuidance("Set the source ID."); m_sourceIdCmd->SetParameterName("SourceId", false); // non omittable, no default m_sourceIdCmd->AvailableForStates(G4State_PreInit, G4State_Idle); #ifdef _EUTELESCOPE // Specific EUTelescope m_scint1PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint1Pos", this); m_scint2PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint2Pos", this); m_scint3PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint3Pos", this); m_scint4PosCmd = new G4UIcmdWith3VectorAndUnit("/allpix/eudet/scint4Pos", this); #endif } // // AllPixDetectorMessenger destructor. // AllPixDetectorMessenger::~AllPixDetectorMessenger() { // Detector configuration commands. delete m_detIdCmd; delete m_detPosCmd; delete m_detRotCmd; delete m_detFoilThicknessCmd; // Test structure commands. delete m_testStructPosCmd; delete m_testStructRotCmd; delete m_testStructureShieldingThicknessCmd; delete m_detAppliancePosCmd; delete m_UpdateCmd; delete m_worldMaterial; delete m_labLatCmd; delete m_labLonCmd; delete m_labAltCmd; delete m_labRollCmd; delete m_labPitchCmd; delete m_labYawCmd; delete m_sourceIdCmd; // Detector information //---------------------- // delete m_chipIdCmd; // Configuration settings //------------------------ //delete m_outputPrefix; //delete m_eventsPerFrame; delete m_detDir; delete m_allpixDir; delete m_labDir; #ifdef _EUTELESCOPE delete m_scint1PosCmd; delete m_scint2PosCmd; delete m_scint3PosCmd; delete m_scint4PosCmd; #endif } // // AllPixDetectorMessenger::SetNewValue method. // void AllPixDetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) { //G4cout << "Setting up : " << newValue << G4endl; // Detector ID (integer, from XML detector database). if (command == m_detIdCmd) { m_AllPixDetector->SetDetectorID(m_detIdCmd->GetNewIntValue(newValue)); } // // Chip ID // if (command == m_chipIdCmd) { // m_AllPixDetector->SetChipID(newValue); // } if (command == m_detPosCmd) { m_AllPixDetector->SetDetectorPosition( m_detPosCmd->GetNew3VectorValue(newValue) ); } if (command == m_detRotCmd) { m_AllPixDetector->SetDetectorRotation( m_detPosCmd->GetNew3VectorValue(newValue) ); }//end of detector rotation setting check. if (command == m_detFoilThicknessCmd) { m_AllPixDetector->SetFoilThickness( m_detFoilThicknessCmd->GetNewDoubleValue(newValue) ); } if (command == m_UpdateCmd) { m_AllPixDetector->UpdateGeometry(); } if (command == m_LowTHLCmd) { m_AllPixDetector->SetLowTHL(m_LowTHLCmd->GetNewDoubleValue(newValue)); } // The test structure commands //----------------------------- // The test structure name. if (command == m_testStructureNameCmd) { m_AllPixDetector->SetBuildTestStructure(true); m_AllPixDetector->SetTestStructureName(newValue); } // // The test structure position. if (command == m_testStructPosCmd) { m_AllPixDetector->SetTestStructurePosition( m_testStructPosCmd->GetNew3VectorValue(newValue) ); } // // The test structure rotation. if (command == m_testStructRotCmd) { m_AllPixDetector->SetTestStructureRotation( m_testStructRotCmd->GetNew3VectorValue(newValue) ); } // if( command == m_testStructDetLinkCmd ) { m_AllPixDetector->SetTestStructureDetectorLink( m_testStructDetLinkCmd->GetNewIntValue(newValue) ); } // // The test structure shielding thickness. if (command == m_testStructureShieldingThicknessCmd) { m_AllPixDetector->SetTestStructureShieldingThickness( m_testStructureShieldingThicknessCmd->GetNewDoubleValue(newValue) ); } if (command == m_detAppliancePosCmd) { //G4cout << "** DEBUG: The appliance position command has been used." << G4endl; m_AllPixDetector->SetBuildAppliances(true); m_AllPixDetector->SetAppliancePosition( m_detAppliancePosCmd->GetNew3VectorValue(newValue) ); } // if( command == m_wrapperEnhancementCmd ) // { // m_AllPixDetector->SetWrapperEnhancement( // m_wrapperEnhancementCmd->GetNew3VectorValue(newValue) // ); // } // Set the world material. if (command == m_worldMaterial) { m_AllPixDetector->SetWorldMaterial(newValue); } if (command==m_labLatCmd) { m_AllPixDetector->SetLabLatitude(m_labLatCmd->GetNewDoubleValue(newValue)); } if (command==m_labLonCmd) { m_AllPixDetector->SetLabLongitude(m_labLonCmd->GetNewDoubleValue(newValue)); } if (command==m_labAltCmd) { m_AllPixDetector->SetLabAltitude(m_labAltCmd->GetNewDoubleValue(newValue)); } if (command==m_labRollCmd) { m_AllPixDetector->SetLabRollAngle(m_labRollCmd->GetNewDoubleValue(newValue)); } if (command==m_labPitchCmd) { m_AllPixDetector->SetLabPitchAngle(m_labPitchCmd->GetNewDoubleValue(newValue)); } if (command==m_labYawCmd) { m_AllPixDetector->SetLabYawAngle(m_labYawCmd->GetNewDoubleValue(newValue)); } if (command==m_sourceIdCmd) { m_AllPixDetector->SetSourceID(newValue); } if (command == m_magFieldCmd) { G4cout << "Setting up magnetic field " << m_magFieldCmd->GetNewDoubleValue(newValue) << G4endl; m_AllPixDetector->SetPeakMagField( m_magFieldCmd->GetNewDoubleValue(newValue) ); } // // Set the output prefix. // if (command == m_outputPrefix) { // G4cout // << "* INFO: Setting the output file prefix to '" // << newValue << "'" << G4endl; // m_AllPixDetector->SetOutputFilePrefix(newValue); // } // // // Set the events per frame. // if (command == m_eventsPerFrame) { // G4cout // << "* INFO: Setting the events per frame to " << newValue << G4endl; // // // Set the new value. // m_AllPixDetector->SetEventsPerFrame( // m_eventsPerFrame->GetNewIntValue(newValue) // ); // } // Set the maximum step length. if (command == m_StepLengthSensor) { G4cout << "* INFO: Setting the max. step length to " << newValue << G4endl; m_AllPixDetector->SetMaxStepLengthSensor( m_StepLengthSensor->GetNewDoubleValue(newValue) ); } #ifdef _EUTELESCOPE if( command == m_scint1PosCmd ) { m_AllPixDetector->SetScintPos( m_scint1PosCmd->GetNew3VectorValue(newValue) ); } if( command == m_scint2PosCmd ) { m_AllPixDetector->SetScintPos( m_scint2PosCmd->GetNew3VectorValue(newValue) ); } if( command == m_scint3PosCmd ) { m_AllPixDetector->SetScintPos( m_scint3PosCmd->GetNew3VectorValue(newValue) ); } if( command == m_scint4PosCmd ) { m_AllPixDetector->SetScintPos( m_scint4PosCmd->GetNew3VectorValue(newValue) ); } #endif }