Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4TrackingMessenger class implementation << 23 // >> 24 // $Id: G4TrackingMessenger.cc,v 1.10 2005/11/21 23:37:19 asaim Exp $ >> 25 // GEANT4 tag $Name: geant4-08-00 $ >> 26 // >> 27 // >> 28 //--------------------------------------------------------------- >> 29 // >> 30 // G4TrackingMessenger.cc >> 31 // >> 32 // Description: >> 33 // This is a messenger class to interface to exchange information >> 34 // between tracking and stepping managers and UI. 27 // 35 // 28 // Contact: 36 // Contact: 29 // Questions and comments to this code shoul 37 // Questions and comments to this code should be sent to 30 // Katsuya Amako (e-mail: Katsuya.Amako@k 38 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) 31 // Makoto Asai (e-mail: asai@slac.stanf << 39 // Makoto Asai (e-mail: asai@kekvax.kek.jp) 32 // Takashi Sasaki (e-mail: Takashi.Sasaki@ 40 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) 33 // ------------------------------------------- << 41 // >> 42 //--------------------------------------------------------------- 34 43 35 #include "G4TrackingMessenger.hh" 44 #include "G4TrackingMessenger.hh" 36 << 37 #include "G4IdentityTrajectoryFilter.hh" << 38 #include "G4PropagatorInField.hh" << 39 #include "G4SteppingManager.hh" << 40 #include "G4TrackStatus.hh" << 41 #include "G4TrackingManager.hh" << 42 #include "G4TransportationManager.hh" << 43 #include "G4UIcmdWithAnInteger.hh" << 44 #include "G4UIcmdWithoutParameter.hh" << 45 #include "G4UIdirectory.hh" 45 #include "G4UIdirectory.hh" >> 46 #include "G4UIcmdWithoutParameter.hh" >> 47 #include "G4UIcmdWithAnInteger.hh" 46 #include "G4UImanager.hh" 48 #include "G4UImanager.hh" 47 #include "G4Threading.hh" << 48 #include "G4ClonedTrajectory.hh" << 49 #include "G4ClonedTrajectoryPoint.hh" << 50 #include "G4ClonedRichTrajectory.hh" << 51 #include "G4ClonedRichTrajectoryPoint.hh" << 52 #include "G4ClonedSmoothTrajectory.hh" << 53 #include "G4ClonedSmoothTrajectoryPoint.hh" << 54 #include "G4ios.hh" << 55 #include "globals.hh" 49 #include "globals.hh" >> 50 #include "G4TrackingManager.hh" >> 51 #include "G4SteppingManager.hh" >> 52 #include "G4TrackStatus.hh" >> 53 #include "G4ios.hh" 56 54 57 ////////////////////////////////////////////// 55 /////////////////////////////////////////////////////////////////// 58 G4TrackingMessenger::G4TrackingMessenger(G4Tra << 56 G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager * trMan) 59 //////////////////////////////////////////// << 57 /////////////////////////////////////////////////////////////////// 60 : trackingManager(trMan) << 58 : trackingManager(trMan) 61 { 59 { 62 steppingManager = trackingManager->GetSteppi 60 steppingManager = trackingManager->GetSteppingManager(); 63 61 64 TrackingDirectory = new G4UIdirectory("/trac 62 TrackingDirectory = new G4UIdirectory("/tracking/"); 65 TrackingDirectory->SetGuidance("TrackingMana 63 TrackingDirectory->SetGuidance("TrackingManager and SteppingManager control commands."); 66 64 67 AbortCmd = new G4UIcmdWithoutParameter("/tra << 65 AbortCmd = new G4UIcmdWithoutParameter("/tracking/abort",this); 68 AbortCmd->SetGuidance("Abort current G4Track 66 AbortCmd->SetGuidance("Abort current G4Track processing."); 69 67 70 ResumeCmd = new G4UIcmdWithoutParameter("/tr << 68 >> 69 ResumeCmd = new G4UIcmdWithoutParameter("/tracking/resume",this); 71 ResumeCmd->SetGuidance("Resume current G4Tra 70 ResumeCmd->SetGuidance("Resume current G4Track processing."); 72 71 73 StoreTrajectoryCmd = new G4UIcmdWithAnIntege << 72 StoreTrajectoryCmd = new G4UIcmdWithAnInteger("/tracking/storeTrajectory",this); 74 StoreTrajectoryCmd->SetGuidance("Store traje 73 StoreTrajectoryCmd->SetGuidance("Store trajectories or not."); >> 74 StoreTrajectoryCmd->SetGuidance(" 1 : Store trajectories."); 75 StoreTrajectoryCmd->SetGuidance(" 0 : Don't 75 StoreTrajectoryCmd->SetGuidance(" 0 : Don't Store trajectories."); 76 StoreTrajectoryCmd->SetGuidance(" !=0 : Stor << 76 StoreTrajectoryCmd->SetParameterName("Store",true); 77 StoreTrajectoryCmd->SetGuidance(" 1 : Choose << 78 StoreTrajectoryCmd->SetGuidance(" 2 : Choose << 79 StoreTrajectoryCmd->SetGuidance(" 3 : Choose << 80 StoreTrajectoryCmd->SetGuidance(" 4 : Choose << 81 StoreTrajectoryCmd->SetParameterName("Store" << 82 StoreTrajectoryCmd->SetDefaultValue(0); 77 StoreTrajectoryCmd->SetDefaultValue(0); 83 StoreTrajectoryCmd->SetRange("Store >=0 && S << 78 StoreTrajectoryCmd->SetRange("Store >=0 && Store <= 1"); >> 79 84 80 85 VerboseCmd = new G4UIcmdWithAnInteger("/trac << 81 VerboseCmd = new G4UIcmdWithAnInteger("/tracking/verbose",this); 86 #ifdef G4VERBOSE 82 #ifdef G4VERBOSE 87 VerboseCmd->SetGuidance("Set Verbose level o 83 VerboseCmd->SetGuidance("Set Verbose level of tracking category."); 88 VerboseCmd->SetGuidance(" -1 : Silent."); << 89 VerboseCmd->SetGuidance(" 0 : Silent."); 84 VerboseCmd->SetGuidance(" 0 : Silent."); 90 VerboseCmd->SetGuidance(" 1 : Minimum inform << 85 VerboseCmd->SetGuidance(" 1 : Minium information of each Step."); 91 VerboseCmd->SetGuidance(" 2 : Addition to Le 86 VerboseCmd->SetGuidance(" 2 : Addition to Level=1, info of secondary particles."); 92 VerboseCmd->SetGuidance(" 3 : Addition to Le 87 VerboseCmd->SetGuidance(" 3 : Addition to Level=1, pre/postStepoint information"); 93 VerboseCmd->SetGuidance(" after all Alon 88 VerboseCmd->SetGuidance(" after all AlongStep/PostStep process executions."); 94 VerboseCmd->SetGuidance(" 4 : Addition to Le 89 VerboseCmd->SetGuidance(" 4 : Addition to Level=3, pre/postStepoint information"); 95 VerboseCmd->SetGuidance(" at each AlongS << 90 VerboseCmd->SetGuidance(" at each AlongStepPostStep process execuation."); 96 VerboseCmd->SetGuidance(" 5 : Addition to Le 91 VerboseCmd->SetGuidance(" 5 : Addition to Level=4, proposed Step length information"); 97 VerboseCmd->SetGuidance(" from each Alon << 92 VerboseCmd->SetGuidance(" from each AlongStepPostStep process."); 98 VerboseCmd->SetParameterName("verbose_level" << 93 VerboseCmd->SetParameterName("verbose_level",true); 99 VerboseCmd->SetDefaultValue(0); 94 VerboseCmd->SetDefaultValue(0); 100 VerboseCmd->SetRange("verbose_level >=-1 ") << 95 VerboseCmd->SetRange("verbose_level >=0 "); 101 #else << 96 #else 102 VerboseCmd->SetGuidance("You need to recompi << 97 VerboseCmd->SetGuidance("You need to recompile the tracking category defining G4VERBOSE "); 103 #endif 98 #endif 104 } 99 } 105 100 106 //////////////////////////////////////////// 101 //////////////////////////////////////////// 107 G4TrackingMessenger::~G4TrackingMessenger() 102 G4TrackingMessenger::~G4TrackingMessenger() 108 //////////////////////////////////////////// 103 //////////////////////////////////////////// 109 { 104 { 110 delete TrackingDirectory; 105 delete TrackingDirectory; 111 delete AbortCmd; 106 delete AbortCmd; 112 delete ResumeCmd; 107 delete ResumeCmd; 113 delete StoreTrajectoryCmd; 108 delete StoreTrajectoryCmd; 114 delete VerboseCmd; 109 delete VerboseCmd; 115 delete auxiliaryPointsFilter; << 116 } 110 } 117 111 118 ////////////////////////////////////////////// 112 /////////////////////////////////////////////////////////////////////////////// 119 void G4TrackingMessenger::SetNewValue(G4UIcomm << 113 void G4TrackingMessenger::SetNewValue(G4UIcommand * command,G4String newValues) 120 ////////////////////////////////////////////// 114 /////////////////////////////////////////////////////////////////////////////// 121 { 115 { 122 if (command == VerboseCmd) { << 116 if( command == VerboseCmd ){ 123 trackingManager->SetVerboseLevel(VerboseCm 117 trackingManager->SetVerboseLevel(VerboseCmd->ConvertToInt(newValues)); 124 } 118 } 125 119 126 if (command == AbortCmd) { << 120 if( command == AbortCmd ){ 127 steppingManager->GetTrack()->SetTrackStatu 121 steppingManager->GetTrack()->SetTrackStatus(fStopAndKill); 128 G4UImanager::GetUIpointer()->ApplyCommand( 122 G4UImanager::GetUIpointer()->ApplyCommand("/control/exit"); 129 } 123 } 130 124 131 if (command == ResumeCmd) { << 125 if( command == ResumeCmd ){ 132 G4UImanager::GetUIpointer()->ApplyCommand( << 126 G4UImanager::GetUIpointer()->ApplyCommand("/control/exit"); 133 } 127 } 134 128 135 if (command == StoreTrajectoryCmd) { << 129 if( command == StoreTrajectoryCmd ){ 136 G4int trajType = StoreTrajectoryCmd->Conve << 130 trackingManager->SetStoreTrajectory(StoreTrajectoryCmd->ConvertToBool(newValues)); 137 if (trajType == 2 || trajType == 4) { << 138 << 139 if (nullptr == auxiliaryPointsFilter) { << 140 auxiliaryPointsFilter = new G4IdentityTrajec << 141 } << 142 G4TransportationManager::GetTransportati << 143 ->GetPropagatorInField() << 144 ->SetTrajectoryFilter(auxiliaryPointsF << 145 } << 146 else { << 147 G4TransportationManager::GetTransportati << 148 ->GetPropagatorInField() << 149 ->SetTrajectoryFilter(nullptr); << 150 } << 151 trackingManager->SetStoreTrajectory(trajTy << 152 << 153 // Make sure cloning works for sub-event p << 154 if(G4Threading::IsMasterThread() && trajTy << 155 static G4bool traj_1 = false, traj_2 = f << 156 G4VTrajectory* traj = nullptr; << 157 G4VTrajectoryPoint* trajp = nullptr; << 158 switch (trajType) { << 159 case 1: << 160 if(!traj_1) { << 161 traj = new G4ClonedTrajectory(); << 162 trajp = new G4ClonedTrajectoryPoint( << 163 traj_1 = true; << 164 } << 165 break; << 166 case 2: << 167 if(!traj_2) { << 168 traj = new G4ClonedSmoothTrajectory( << 169 trajp = new G4ClonedSmoothTrajectory << 170 traj_2 = true; << 171 } << 172 break; << 173 case 3: << 174 case 4: << 175 if(!traj_3) { << 176 traj = new G4ClonedRichTrajectory(); << 177 trajp = new G4ClonedRichTrajectoryPo << 178 traj_3 = true; << 179 } << 180 break; << 181 default: << 182 break; << 183 } << 184 if(traj!=nullptr) delete traj; << 185 if(trajp!=nullptr) delete trajp; << 186 } << 187 } 131 } 188 << 189 } 132 } 190 133 >> 134 191 ////////////////////////////////////////////// 135 //////////////////////////////////////////////////////////////////// 192 G4String G4TrackingMessenger::GetCurrentValue( << 136 G4String G4TrackingMessenger::GetCurrentValue(G4UIcommand * command) 193 ////////////////////////////////////////////// 137 //////////////////////////////////////////////////////////////////// 194 { 138 { 195 if (command == VerboseCmd) { << 139 if( command == VerboseCmd ){ 196 return VerboseCmd->ConvertToString(trackin 140 return VerboseCmd->ConvertToString(trackingManager->GetVerboseLevel()); 197 } 141 } 198 if (command == StoreTrajectoryCmd) { << 142 else if( command == StoreTrajectoryCmd ){ 199 return StoreTrajectoryCmd->ConvertToString << 143 G4String ll = "0"; >> 144 if(trackingManager->GetStoreTrajectory()) ll = "1"; >> 145 return ll; 200 } 146 } 201 return G4String(1, '\0'); << 147 return G4String('\0'); 202 } 148 } >> 149 >> 150 >> 151 >> 152 >> 153 >> 154 >> 155 >> 156 >> 157 >> 158 >> 159 >> 160 >> 161 203 162