Locked History Actions

Geant4_B4c

Geant4 B4c サンプルプログラム

Memos

  • 初期化する前としたあとでは、プロンプトが違う。
  • PreInit>  
    PreInit> /run/initialize
    ...
    Idle>  
  • SensitiveDetector を含むジオメトリのアップデート

  • example/extended/electromagnetic/TestEm8 が参考になる。
  • UI でPhysicsListを変更

  • example/extended/electromagnetic/TestEm5 の PhysicsList をまるごとコピーしてきた。 UI や macro の中で PhysicsList を変更しようとすると、以下のメッセージがでる。

  • idle>
    /B4/phys/addPhysics local
    illegal application state -- command refused
  • /B4/phys/addPhysics local
    ***** Illegal application state </B4/phys/addPhysics local> *****
  • exampleB4.cc の中で runManager->Initialize(); を実行していたため。後から PhysicsList を変更する場合、exampleB4.cc の中で runManager->Initialize(); を実行してはいけない。マクロの中で、/run/initialize を実行。

  • 自分の独自関数(メソッド)を追加

    • メソッドは基本的に仮想関数とする (virtual 修飾子を付けて宣言する)。ただし、なんでもかんでも仮想関数にしてはいけないらしい (参考: 何でもかんでも virtual にしてはいけない)。

    • クラス内でのみの使用が想定される関数は、private のメンバ関数とし、virtual は付けない。
      • B4cDetectorConstruction.hh の DefineMaterials() はこうなっている。

  • Sensitive Detector

    • イベントごと (またはステップごと etc...) にデータを取り出すことの出来る Logical volume を Sensitive Detector という?使い方は以下の通り。
      1. まず Sensitive Detector を作成。普通は G4VUserDetectorConstruction::Construct() をオーバライドしたメソッド内でインスタンスが作られる。B4c のサンプルプログラムでは B4cDetectorConstruction::Construct() が B4cDetectorConstruction::DefineVolumes() を呼出し、その中で Sensitive Detector クラス (B4cCalorimeterSD という G4VSensitiveDetector を継承したクラス) のインスタンスが作成される。Sensitive Detector クラス のコンストラクタでは、detector の hit 情報を貯めておくため Hit collection というものの名前を G4VSensitiveDetector の持つ G4CollectionNameVector 型の メンバ変数に登録している。

      2. そのインスタンスを G4SDMangager に登録。
      3. Sensitive Detector にしたい Logical volume を Sensitive Detector に set する。
      4. 具体的には、以下のようなコードで実現する。
        • G4VPhysicalVolume* B4cDetectorConstruction::Construct()
          {
          ...
            return DefineVolumes();
          ...
          }
          
          G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
          {
          ...
            B4cCalorimeterSD* absoSD 
              = new B4cCalorimeterSD("AbsorberSD", "AbsorberHitsCollection", nofLayers);
            G4SDManager::GetSDMpointer()->AddNewDetector(absoSD );
            absorberLV->SetSensitiveDetector(absoSD);
          
            B4cCalorimeterSD* gapSD 
              = new B4cCalorimeterSD("GapSD", "GapHitsCollection", nofLayers);
            G4SDManager::GetSDMpointer()->AddNewDetector(gapSD );
            gapLV->SetSensitiveDetector(gapSD);
          ...
  • Hit と Hit collection

    • 上述の手順によって Sensitive Detector を Geant4 に登録する (?) と、イベントの始まりと終わりとその間 (?) に以下の メソッドが Geant4 によって自動的に飛び出される。
      • イベントの初め : void B4cCalorimeterSD::Initialize(G4HCofThisEvent* hce)
      • イベントの間 (?) : G4bool B4cCalorimeterSD::ProcessHits(G4Step* step, G4TouchableHistory*)

      • イベントの最後 : void B4cCalorimeterSD::EndOfEvent(G4HCofThisEvent*)

    • イベントの初めの Initialize() では、B4cCalorHitsCollection のインスタンスを作り、hce にこのインスタンスを Add している (なにをやっているかよくわからない) 。さらに、各 layer ごとの Hit の情報を持たせる B4cCalorHit() のインスタンスを B4cCalorHitsCollection のインスタンスに insert している (登録しているようなものか?)。

    • イベントの間 (?) の ProcessHits では、引数として与えられた G4Step, G4TouchableHistory 型のインスタンスから、各 Step ごとのエネルギー損失などを所得する。さらに、先程作った B4cCalorHit() のインスタンスのポインタを取得しなおし、そこにエネルギー損失などの情報を Add する。

      •   hit->Add(edep, stepLength);
          hitTotal->Add(edep, stepLength); 
    • イベントの最後の EndOfEvent() では特になにもしない。表示したいメッセージなどがあれば、ここで表示する。