Geant4系列講座二_第1頁
Geant4系列講座二_第2頁
Geant4系列講座二_第3頁
Geant4系列講座二_第4頁
Geant4系列講座二_第5頁
已閱讀5頁,還剩23頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、提 綱一、Geant4運行模式“purely hard-coded” batch modeBatch mode,macro commandsInteractive mode,command lines二、材料定義簡單物質(zhì)分子定義混合物同位素Geant4自定義三、Geant4中使用物理量的單位基本單位輸入輸出四、幾何結(jié)構定義簡單結(jié)構定義復雜結(jié)構定義顏色顯示五PrimaryGeneratorAction一、Geant4運行模式 Geant4運行模式:“purely hard-coded” batch modeBatch mode,macro commandsInteractive mode,com

2、mand lines每種模式的選擇必須在Main文件中編制相應的代碼以實現(xiàn)其對應模式。通常采用混合模式。.頭文件 Purely batch-coded main(). . . G4runManager初始化. . . class初始化G4核初始化 runManager-Initialize();/start runG4int numberOfEvent = 3; runManager-BeamOn(numberOfEvent);delete runManager; return 0;.頭文件 Batch-coded with macro file main(

3、int argc,char* argv). . . G4runManager初始化. . . class初始化G4核初始化 runManager-Initialize();/ Get the pointer to the UI manager G4UImanager* UI = G4UImanager:GetUIpointer();G4String command = /control/execute ;G4String fileName = argv1;UI-applyCommand(command+fileName);delete runManager; return 0;.頭文件 Int

4、eractive by command line mode.#include G4UIterminal.hh#include G4UIsession.hhint main(int argc,char* argv). . . G4runManager初始化. . . class初始化G4核初始化 runManager-Initialize();/ Terminal initialization;G4UIsession* session = new G4UIterminal;session-SessionStart();delete runManager; return 0;Macro file:

5、命令行序列:#2008.6.9 #mac file for visulization/vis/scene/create/vis/open OGLIX/vis/scene/add/trajectories/vis/scene/add/hits/vis/scene/endOfEventAction accumulate/vis/viewer/set/viewpointThetaPhi 72 25 /vis/viewer/zoom 16/run/beamOn 10000/vis/viewer/set/style w/vis/viewer/set/style s以文本格式保存#include G4UI

6、manager.hh Mixed mode#include G4RunManager.hh .#include G4VisManager.hh#include G4VisExecutive.hh#include G4UItcsh.hh#include G4UIterminal.hh#include G4UIsession.hhint main(int argc,char* argv)G4RunManager* MyRun = new G4RunManager;/this part is for the visualizationG4VisManager* VisManager = new G4

7、VisExecutive;VisManager-Initialize();MyRun-Initialize();/G4UIsession* session = new G4UIterminal(new G4UItcsh);G4UImanager* UI = G4UImanager:GetUIpointer(); Mixed modeif(argc=1)UI-ApplyCommand(/run/verbose 2);G4String command=/control/execute /g4work/pphotonelectron/vis.mac;UI-ApplyCommand(command);

8、/session-SessionStart();elseUI-ApplyCommand(/run/verbose 2);G4String command=/control/execute /g4work/pphotonelectron/;G4String fileName = argv1;UI-ApplyCommand(command+fileName);/session-SessionStart();/delete session;delete VisManager;delete MyRun;return 0;二、材料定義 一般的物質(zhì)(化合物,混合物)是由元素構成,元素又由同位素組成。按照這

9、種物質(zhì)的劃分層次,可以通過類似的概念定義宏觀世界中的物質(zhì)。 Geant4中定義的物質(zhì)類(class)有兩種:G4ElementG4Material G4Element class 描述微觀層面的原子的性質(zhì)如:原子序數(shù)核子數(shù)殼層能量諸如原子截面等 G4Isotope class 描述微觀層面的原子的性質(zhì)如:原子序數(shù)核子數(shù)莫爾質(zhì)量等 G4Material class 描述微觀層面的原子的性質(zhì)如:原子序數(shù)核子數(shù)殼層能量諸如原子截面等簡單物質(zhì)定義:G4double density = 1.390*g/cm3;G4double a = 39.95*g/mole;G4Material* lAr = new

10、 G4Material(name=liquidArgon, z=18., a, density);分子定義:a = 1.01*g/mole;G4Element* elH = new G4Element(name=Hydrogen,symbol=H , z= 1., a);a = 16.00*g/mole;G4Element* elO = new G4Element(name=Oxygen ,symbol=O , z= 8., a);density = 1.000*g/cm3;G4Material* H2O = new G4Material(name=Water,density,ncompone

11、nts=2);H2O-AddElement(elH, natoms=2);H2O-AddElement(elO, natoms=1);混合物定義(質(zhì)量份數(shù)):a = 14.01*g/mole;G4Element* elN = new G4Element(name=Nitrogen,symbol=N , z= 7., a);a = 16.00*g/mole;G4Element* elO = new G4Element(name=Oxygen ,symbol=O , z= 8., a);density = 1.290*mg/cm3;G4Material* Air = new G4Material(

12、name=Air ,density,ncomponents=2);Air-AddElement(elN, fractionmass=70*perCent);Air-AddElement(elO, fractionmass=30*perCent);Geant4自定義:G4NistManager* man = G4NistManager:Instance();G4Material* H2O = man-FindOrBuildMaterial(G4_WATER);G4Material* Air = man-FindOrBuildMaterial(G4_AIR);同位素定義:G4Isotope* U5

13、 = new G4Isotope(name=U235, iz=92, n=235, a=235.01*g/mole);G4Isotope* U8 = new G4Isotope(name=U238, iz=92, n=238, a=238.03*g/mole);G4Element* elU = new G4Element(name=“enriched Uranium”, symbol=“U”, ncomponents );elU-AddIsotope(U5, abundance= 90.*perCent);elU-AddIsotope(U8, abundance= 10.*perCent);三

14、、Geant4中使用物理量的單位基本單位:Geant4中用戶可以為選定的物理量選擇各種單位,但是Geant4內(nèi)核內(nèi)定義了如下基本單位:millimeter (mm)nanosecond (ns)Mega electron Volt (MeV)positron charge (eplus)degree Kelvin (kelvin)the amount of substance (mole)luminous intensity (candela)radian (radian)steradian (steradian)其它所有單位都以上述單位為基礎得到,如:Millimeter mm 1;Mete

15、r m 1000*mm;用戶輸入數(shù)據(jù)單位: Geant4中用戶輸入的數(shù)據(jù)必須帶有單位(系統(tǒng)默認強烈建議不使用),如: G4double Size = 15*km, KineticEnergy = 90.3*GeV, density = 11*mg/cm3; 同樣,如果數(shù)據(jù)為數(shù)組格式或者從文件讀入,也必須帶有單位,如: for (int j=0, jjmax, j+) CrossSectionj *= millibarn;數(shù)據(jù)輸出單位: 帶單位數(shù)據(jù)輸出格式如: G4cout KineticEnergy/keV keV; G4cout density/(g/cm3) g/cm3; 或者給出Gean

16、t4選擇的最優(yōu)化單位: G4cout G4BestUnit(StepSize, Length);四、幾何結(jié)構定義 Geant4中以“體”(Volume)的概念定義幾何形狀。模型中最大的“體”稱為“世界體”(World Volume),其它的體都位于世界體內(nèi)部。“世界體”內(nèi)的“體”之間是包含和被包含關系,被包含的稱包含它的體為母體(mother Volume)。 Geant4中的體的定義包含三個層次:1.定義幾何形狀;2.定義物理屬性;3.定義所在母體的位置; 定義幾何形狀(solid):G4double expHall_x = 30.0*m; G4double expHall_y = 40.0

17、*m; G4double expHall_z = 60.0*m; G4Box* experimentalHall_box = new G4Box(expHall_box,expHall_x,expHall_y,expHall_z); 指定幾何形狀的名稱、尺寸等信息。 定義物理屬性:G4LogicalVolume* experimentalHall_log = new G4LogicalVolume(experimentalHall_box,Ar,expHall_log);給定物理屬性指向的幾何體,該幾何體對應的物質(zhì),該幾何體的名稱等信息。G4LogicalVolume* tracker_log

18、 = new G4LogicalVolume(tracker_tube,Al,tracker_log); 定義物理位置 G4double trackerPos_x = -1.0*meter; G4double trackerPos_y = 0.0*meter; G4double trackerPos_z = 0.0*meter; G4VPhysicalVolume* tracker_phys = new G4PVPlacement(0, / no rotation G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z), / translat

19、ion position tracker_log, / its logical volume tracker, / its name experimentalHall_log, / its mother (logical) volume false, / no boolean operations 0); / its copy number 復雜幾何體結(jié)構C循環(huán)設計 G4double calo_x = 1.*cm; G4double calo_y = 40.*cm; G4double calo_z = 40.*cm; G4Box* calorimeterLayer_box = new G4Bo

20、x(caloLayer_box, calo_x,calo_y,calo_z); calorimeterLayer_log = new G4LogicalVolume(calorimeterLayer_box, Al,caloLayer_log,0,0,0); for(G4int i=0;iSetVisAttributes(G4Colour(0,0,0);tracker_log-SetVisAttributes(G4Colour(1,0,0);calorimeterBlock_log-SetVisAttributes(G4Colour(0,2,0,0);calorimeterLayer_log-

21、SetVisAttributes(G4Colour(0,1,1,0);RGB配色,G4Colour(0,1,1,0)五、PrimaryGeneratorAction G4VUserPrimaryGeneratorAction是Geant4要求的強制類之一,通過該類指定產(chǎn)生的主粒子事件。在該類中,用戶可以指定粒子產(chǎn)生的方式。 在G4VUserPrimaryGeneratorAction中,用戶必須對主粒子產(chǎn)生器實例化。實際上,在G4VUserPrimaryGeneratorAction中,用戶定義的是主粒子產(chǎn)生的排列順序及初始化設定。 產(chǎn)生主粒子事件的方法射線束,可以選擇粒子類型、能量、射線束極

22、化度等信息許多是以FORTRAN編寫的高能物理過程所需的粒子事件ASCII 文件輸入提供了很多方便的函數(shù)描述粒子源模擬空間環(huán)境、地下放射性源等;(類似于現(xiàn)實中的源) 例子N01中PrimaryGeneratorAction使用ParticleGun作為的主粒子產(chǎn)生器PrimaryGeneratorAction示例(N01)每次產(chǎn)生一個粒子(Geantino),圖中綠色線條;GPS的使用和ParticleGun類似,替代即可;#ifndef ExN01PrimaryGeneratorAction_h#define ExN01PrimaryGeneratorAction_h 1#include G

23、4VUserPrimaryGeneratorAction.hhclass G4ParticleGun;class G4Event;class ExN01PrimaryGeneratorAction : public G4VUserPrimaryGeneratorActionpublic:ExN01PrimaryGeneratorAction();ExN01PrimaryGeneratorAction();public:void generatePrimaries(G4Event* anEvent);private:G4ParticleGun* particleGun; #endif Prima

24、ryGeneratorAction.hh N01ParticleGun實例化#include ExN01PrimaryGeneratorAction.hh#include G4Event.hh#include G4ParticleGun.hh#include G4ThreeVector.hh#include G4Geantino.hh#include globals.hhExN01PrimaryGeneratorAction:ExN01PrimaryGeneratorAction()G4int n_particle = 1;particleGun = new G4ParticleGun(n_p

25、article);particleGun-SetParticleDefinition(G4Geantino:GeantinoDefinition();particleGun-SetParticleEnergy(1.0*GeV);particleGun-SetParticlePosition(G4ThreeVector(-2.0*m,0.0*m,0.0*m);ExN01PrimaryGeneratorAction:ExN01PrimaryGeneratorAction()delete particleGun;PrimaryGeneratorAction.cc N01void ExN01Prima

26、ryGeneratorAction:generatePrimaries(G4Event* anEvent)G4int i = anEvent-get_eventID() % 3;switch(i)case 0:particleGun-SetParticleMomentumDirection(G4ThreeVector(1.0,0.0,0.0);break;case 1:particleGun-SetParticleMomentumDirection(G4ThreeVector(1.0,0.1,0.0);break;case 2:particleGun-SetParticleMomentumDirection(G4ThreeVector(1.0,0.0,0.1);break;particleGun-generatePrimaryVertex(anEvent);PrimaryGeneratorAction.cc N01G4ParticleGun 方法 void SetParticleDefinition(G4ParticleDefinition*) void SetParticleMomentum(G4Part

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論