1 / 41

LC ツール講習会 Jupiter part

LC ツール講習会 Jupiter part. 2005/06/06 LC tools lecture @kek Hiroaki Ono Niigata University ono@hep.sc.niigata-u.ac.jp. Contents. Jupiter の全般について Jupiter とは ドキュメントなど セットアップ、 CVS など Jupiter で新しい検出器を作る Forward CAL(fw) を例えば作るとしたら J4FW 部分の実装方法 CAL のジオメトリを例として SD 登録と Hit( 軽く ). Jupiter とは?.

anoush
Download Presentation

LC ツール講習会 Jupiter part

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LCツール講習会Jupiter part 2005/06/06 LC tools lecture @kek Hiroaki Ono Niigata University ono@hep.sc.niigata-u.ac.jp LC tools lecture, Jupiter part

  2. Contents • Jupiterの全般について • Jupiterとは • ドキュメントなど • セットアップ、CVSなど • Jupiterで新しい検出器を作る • Forward CAL(fw)を例えば作るとしたら • J4FW部分の実装方法 • CALのジオメトリを例として • SD登録とHit(軽く) LC tools lecture, Jupiter part

  3. Jupiterとは? JUPITERとは JLC Unified Particle Interaction andTracking EmulatoR の略で  Geant4をベースとしたLC実験用シミュレータです。 LC実験の検出器パラメータ、ジオメトリの変更、 インストールを簡単に行えるように構築されています (現千葉大学の保科琴代さんが作成) LC tools lecture, Jupiter part

  4. For real data Tools for simulation Tools Satellites LEDA URANUS JUPITER Input/Output module set IO JLC Unified Particle Interaction and Tracking EmulatoR Unified Reconstructionand ANalysis Utility Set Library Extention forData Analysis METIS Monte-Calro Exact hits To Intermediate Simulated output Full geometry/mc generator Clustering/smearing Geant4 based Simulator JSF/ROOT based Framework MC truth generator Event Reconstruction シミュレーションツール群 LC tools lecture, Jupiter part

  5. Jupiterに関するドキュメント • Jupiterのマニュアルについて(Japanese) 保科さんが書いたマニュアルを以下に置きました。 http://www.hep.sc.niigata-u.ac.jp/~ono/acfa-sim-j/Jupiter_manual.pdf 保科さんの昔のホームページにもいくつかドキュメントが残っています。 http://wwwjlc.kek.jp/~hoshina/cdc/geant4/diary/diary.htm • Geant4のジオメトリ、ヒットの実装について Geant4 lecture 2003のページが役に立ちます。 http://geant4.kek.jp/g4users/tutorial03/  私の説明で足りない部分はこれらを参考にしてみてください。 LC tools lecture, Jupiter part

  6. JupiterのSetup • Jupiterでは以下のツールが必要です。 • Geant4 (G4INSTALLなどいろいろ) • CLHEP (CLHEP_BASE_DIR) • 環境変数としてJUPITERROOTを設定する必要があります。 % export JUPITERROOT=${HOME}/Jupiter(bash) % setenv JUPITERROOT ${HOME}/Jupiter(csh) 等とします。 LC tools lecture, Jupiter part

  7. CVSによるファイルの管理 CVSでファイルを入手できます。 jlclogin上で持ってくるには % cvs co Jupiter 外部から持ってくるには % cvs -d :pserver:anonymous@jlccvs.kek.jp/home/cvs/soft login password : <return> % cvs -d :pserver:anonymous@jlccvs.kek.jp/home/cvs/soft co Jupiter ファイルのアップデートは % cvs update ファイルのコミットは % cvs commit filename CVSでファイルは管理されており 最新のファイルを入手できます LC tools lecture, Jupiter part

  8. Jupiterのディレクトリ構造 CVSでファイルは管理されており 最新のファイルを入手できます PhysicsListやG4の継承クラス ユーザーが変更する部分 LC tools lecture, Jupiter part

  9. 新しい検出器の作成 たとえば forward cal(fw) を作るとしたら? • source ディレクトリの中に新しく fw を作成。 • source/Makefile に fw を追加。 • source/ 以下に fw/src、fw/include を作る。 • Detector componet, Solidを実装。(Geometry) • SD (Sensitive Detector)とHit を実装。 • source/main/Jupiter.cc の中に fw を追加。 • テストランとジオメトリのチェック。 LC tools lecture, Jupiter part

  10. Jupiter ベースクラス G4VSensitiveDetector J4VComponent virtual InstallIn( mother, pRot, tlate, copyNo=0 )=0 virtual Assemble()=0 Virtual Cabling() Virtual OpenMaterialStore() OutPutAll() static GetDCPtrByName(detectorname) J4VSensitiveDetector OutputAll() J4VHit J4VSD MakeHitBuf() OutputAll() G4VHit J4VDetectorComponent J4VFWDetectorComponent J4VFWMaterialStore J4VMaterialStore OpenMaterialStore() Create(name) Order(matelial) virtual Create(name) LC tools lecture, Jupiter part

  11. FW検出器の実装 source/fw ディレクトリ以下に最低限必要なファイル J4VFWDetectorComponent.hh/cc J4FWMaterialStore.hh/cc J4FW.hh/cc J4FWParameterList.hh/cc J4VDetectorComponetの継承クラス ユーザーが定義するマテリアル 検出器本体の実装(PV,LV,Solid) 各種パラメータ J4FWLayer.hh/cc 娘ボリューム Hit情報を残すのであれば J4FWSD.hh/cc J4FWHit.hh/cc J4VSDの継承、SDの実装 J4VHitの継承、Hitの実装 これらのファイルは、他の検出器からコピーして 名前を付け替えて使うのが早道です。 LC tools lecture, Jupiter part

  12. 1. 検出器 base class の実装 検出器の base class を作成する際にはJ4VComponentを継承して作ります J4VComponent fDaughters (娘Components) fMother(親Component) fSD(Sensitive Detectorへのポインタ) fNbrothers (同じクラスから作られたオブジェクトの数) fNclones(Copy, Replicaで作られたオブジェクトの数) fMyID(fNbrothersの何番目か) fCopyNo(コピーされた場合のコピーナンバー) 新しく検出器 base class を作成する際には、 これらの引数をJ4VComponentに渡してやる必要があります。 実際には他の検出器のものをコピーして名前を変えただけで動くと思います。 J4VCALDetectorComponet -> J4VFWDetectorComponent LC tools lecture, Jupiter part

  13. 2. J4VFWDetectorComponentの実装 J4VFWDetectorComponet.cc の中身 #include “J4VFWDetectorComponent.hh” J4FWMaterialStore* J4VFWDetectorComponet;;fgMatrialStore=0; G4String J4VFSDetectorComponent::fgSubGroup(“FW”) staticで名前の宣言 J4VFWDetectorComponent( const G4String &name, J4VDetectorComponent *parent, G4int nclones, G4int nbrothers, G4int me, G4int copyno ) : J4VDetectorComponent( fgSubGroup, name, parent, nclones, nbrothers, me, copyno) 先程のbase class J4VDetectorComponet に渡す。 J4VMaterialStore* J4VFWDetectorComponet::OpenMaterialStore() { fMaterialStore = new J4FWMaterialStore(); } MaterialStoreをnew LC tools lecture, Jupiter part

  14. 3. J4MaterialStoreの実装 J4FWMaterialStore.cc の中身 #include "J4FWMaterialStore.hh" #include "G4Element.hh" #include "G4Material.hh" G4Material* J4FWMaterialStore::Create( const G4String& /*name*/, G4MaterialPropertiesTable * /* mtable */ ) { G4Material* material = 0; return material; } J4MaterialCatalogにないものは 自分でここで作成しておく 基本的な物質はJ4MaterialCatalogに入っているので (scintillator, Pb, Fe, Si...)componetを作る際には OpenMaterialStore()->Order(“scintillator”)とするだけで良い。 混合ガスなど定義されていないものを使うときははここで定義しておく。 G4でMaterialを作るときと同じ要領。 LC tools lecture, Jupiter part

  15. 4. Componentの実装 ついに検出器コンポーネントの実装です。J4FW.cc の中身です。 G4String J4MUD::fFirstName( “FW" ); staticで名前の宣言 J4FW::J4FW( J4VDetectorComponent* parent, G4int nclones, G4int nbrothers, G4int me, G4int copyno ) : J4VFWDetectorComponent( fFirstName, parent, nclones, nbrothers, me, copyno ) コンストラクタの引数 先程のベースクラス J4VFWDetectorComponet に引数を渡す。 Logica Volumeの生成、Solidを作成する Assemble() Cabling()InstallIn() SDの生成、登録 Physical Volumeの生成 これらの関数の実装で Componetの作成、SD登録を行います。 必ず実装する必要があります。 LC tools lecture, Jupiter part

  16. len rmax dphi rmin 5. Assemble()関数の実装 void J4FW::Assemble(){ if ( !GetLV() ) { J4FWParameterList *list = OpenParameterList(); G4double rmin = list->GetFWInnerR(); G4double rmax = list->GetFWOuterR(); G4double len = list->GetSOLHalfZ(); G4double dphi = 360.*deg; // MakeSolid ----------// OrderNewTubs( rmin, rmax, len, dphi ); // MakeLogicalVolume --// MakeLVWith(OpenMaterialStore()->Order(list->GetFWMaterial())); // SetVisAttribute ----// PaintLV(list->GetFWVisAtt(), list->GetFWColor()); } } 2重に作るのを防ぎます。 parameters Solidを作ります。 単なるシリンダーを 簡単に作成できます。 物質名を渡して LVを作ります。 表示の設定です。 LC tools lecture, Jupiter part

  17. 6. Solidの作り方 (OrderNewTubs()) 便利な関数の使い方 OrderNewTubs( rmin, rmax, halflenZ, totalPhi, endcapHalfThick, endcaprmin, sphi ) halflenZ エンドキャップつきの シリンダーを作成できます。 totalPhi rmax endcaprmin rmin エンドキャップ無しの シリンダーも作成可能です。 endcaHalfThick LC tools lecture, Jupiter part

  18. Solidの作り方 (一般) Assemble()関数内でG4VSolid継承クラス (CSG,specific,BREPS,Bolean,STEP)から適切なものを選んで作る http://www-jlc.kek.jp/~hoshina/geant4/Geant4Lecture2003/2-2b.htmlが参考になります。 // MakeSolid ----------// G4Box* box = new G4Box( GetName(),halfX, halfY, halfZ ); Register( box ); SetSolid( box ); G4Box (四角) G4Sphere (曲面) G4Trap (台形) // MakeSolid ----------// G4Sphere* cone = new G4Sphere( GetName(), rmin, rmax, sphi, dphi, stheta, dtheta ); Register(cone); SetSolid(cone); 自分でSolidを作成した場合には Register(solid) SetSolid(solid) 関数を呼んで登録する LC tools lecture, Jupiter part

  19. Solidの作り方 (その他) 基本図形にない複雑な形状は Boolean Solid を用いて Solidをくっつけたり切り抜いたりして作る 例) シリンダーにシリンダーがくっついたような形状を作る   シリンダーは G4Tubs で作ることが出来る。 G4VSolid* solid1 = new G4Tubs( “solid1”, rmin1, rmax1, halfL1, sphi, dphi ); G4VSolid* solid2 = new G4Tubs( “solid2”, rmin2, rmax2, halfL2, sphi, dphi ); G4VSolid* solidUnion = new J4UnionSolid( “Union”, solid1, solid2, rotMat, transV ); Register( solidUnion ); SetSolid( solidUnion ); LC tools lecture, Jupiter part

  20. 7. 娘Solidの作り方 J4FW の内部に layer 構造を作る場合 J4FWLayer を作成し、J4FW の Assemble() 関数内でオブジェクトを作る。 J4FW::Assemble() { // MakeSolid ----------// OrderNewTubs( rmin, rmax, len, dphi ); // MakeLogicalVolume --// MakeLVWith(OpenMaterialStore()->Order(list->GetFWMaterial())); // SetVisAttribute ----// PaintLV(list->GetFWVisAtt(), list->GetFWColor()); J4FWLayer* fLayers = Create( this, nLayers ); Register( fLayers ); fLayerss -> InstallIn( this ); SetDaughter( fLayers ); } 親のボリュームから はみ出してはいけない 娘ボリュームのInstallIn()関数 娘登録 LC tools lecture, Jupiter part

  21. n 1 2 1 8. InstallIn()関数の実装 InstallIn()関数は親のコンポーネントの中で 呼ばれることに注意 同じ形状のlayer をおく場合でも。。。 void J4FW::InstallIn( J4VComponent* /* mother */, G4RotationMatrix* /* prot */, const G4ThreeVector& /* tlate */) { Assemble(); SetPVPlacement(); または SetPVReplica(); // Cabling function for SD object... //Cabling(); } PVPlacement PVReplica 同じ形状のオブジェクトを 一つのオブジェクトを n分割して作成する。 メモリーの節約になる。 オブジェクトを 一つ一つ配置していく LC tools lecture, Jupiter part

  22. PVPlacementで置く場合 Placementで置く場合には 親のAssemble()関数の中で娘オブジェクトを作る際に 引数にnbrothers, copyNoを与える。nClonesは1になる。 J4FW::Assemble( component, ) { for ( G4int i = 0; i < nLayers; i++ ) { J4FWLayer* Layer = Create( this, 1, nLayers, i ); .... Layer -> InstallIn( this ); } } PVPlacement n J4FWLayer::InstallIn(){ SetPVPlacement( rotationMatrix, tlateVector ); (回転させながら置くことも可能) } 2 1 LC tools lecture, Jupiter part

  23. PVReplica 1 Replicaを使う場合 Replicaする際には 親のAssemble()関数の中で娘オブジェクトを作る際に 引数にnClones(Replicaする数)を与える J4FW::Assemble() { ...... J4FWLayer* fLayers = Create( this, nphi ); fLayers->InstallIn(this); ....... } J4FWLayer::InstallIn() { Assemble(); SetPVReplica( 分割方向, 分割ステップ, offset ); } LC tools lecture, Jupiter part

  24. (例)CALのジオメトリについて CALは以下のような構造になっています。 OrderNewTubs() J4CAL J4CAL以外はG4Sphere()で作成 J4VCALBlock EM/HD J4CALCone J4VCALMiniCone EM/HD J4CALTower J4VCALMiniTower EM/HD J4VCALLayer EM/HD J4VCALSubLayer EM/HD Abs/Active LC tools lecture, Jupiter part

  25. (例)CALのジオメトリについて MiniTower Cone Tower Block Layer HD Replica Replica Abs Active EM MiniCone EM, HDで異なる分割にできる。 セルサイズを分割量で変更 SubLayer LC tools lecture, Jupiter part

  26. 9. Cabling()関数の実装 Hit情報を出すにはSD登録する必要があります。 SD登録を行うのはCabling()関数です。 J4FW内でCabling()関数をとりあえず実装します。 その後J4FWHit/J4FWSD の実装を行います。 void J4FW::Cabling() { if ( !GetSD() ) { J4FWSD* sd = new J4FWSD( this ); Register( sd ); SetSD( sd ); } } Hit情報を残すコンポーネントは全てSDを作る必要があります。 LayerのHit情報が欲しければ、 J4FWLayerSD/J4FWLayerHit を作成するということです。 Solid同様に Register(sd) SetSolid(sd) 関数を呼んで登録します ここまでで、 J4FW の実装は終わりです。 LC tools lecture, Jupiter part

  27. ParameterListの作成 J4FWと同時進行で作成するものとして、 J4FWParameterListの作成があります。各種パラメータをまとめます。 void J4FWParameterList::SetMaterial(){ fFWMaterial = J4ParameterTable::GetValue("J4FW.Material",“scintillator"); ... } void J4FWParameterList::SetParameters(){ fFWOuterR = J4ParameterTable::GetValue("J4FW.OuterR",100.0)*cm; .... } J4FWParameterList::SetVisAttributes() { fFWVisAtt = J4ParameterTable::GetValue("J4FW.VisAtt",false); .... } void J4FWParameterList::SetColors(){ std::vector<double> col; col=J4ParameterTable::GetDValue("J4MUD.Color","1.0 0.0 0.0 1.0",4); SetMUDColor( G4Color( col[0], col[1], col[2], col[3] ) ); .... } LC tools lecture, Jupiter part

  28. 10. HitとSD実装 Hit情報を出すにはSDを作成する必要があります。 J4VSDを継承してJ4FWSDを作成します。 先にJ4VHitを継承してJ4FWHitを作る必要があります。 J4FWSD.hh (ヘッダファイル) class J4FWSD : public J4VSD<J4FWHit> { public: J4CALSD( J4VDetectorComponent* detector ); ~J4CALSD(); virtual G4bool ProcessHits( G4Step* aStep, G4TouchableHistory* ROhist ); virtual void Initialize ( G4HCofThisEvent* HCTE ); virtual void EndOfEvent ( G4HCofThisEvent* HCTE ); virtual void OutputAll( HCTE ) { J4VSD<J4FWHit>::OutputAll( HCTE ) } }; コピーして名前を付け替える だけでいいとおもいます。 LC tools lecture, Jupiter part

  29. Hitの実装 J4FWHit.hh(ヘッダファイル) 基本的な部分はコピーして名前を付け替えるだけでOKです。 各検出器ごとに何のデータを残すかでこの部分が違います。 J4FWHit::J4FWHit( J4VComponent* ptrDetector, // He is in "location" now G4int preHitID, // pre Hit ID G4int cellID, // cell address id G4bool isEM, // ( 0, 1 ) = ( HD, EM ) G4bool isBarrel, // ( 0, 1 ) = ( Endcap, barrel ) G4double edep, // Energy Deposit G4double tof, // TOF G4ParticleDefinition* particle, // Particle data const G4ThreeVector& Xcm, // Edep*position vector const G4ThreeVector& Xcell ) // cell center position) : J4VHit( detector, trackID, mothertrackID, particle, tof, edep, totalE, momentum, pre, pos ) LC tools lecture, Jupiter part

  30. Hit、Output()関数の実装 Output()関数を実装し何のデータをhit.datに残すか決めます。 void J4FWHit::Output( G4HCofThisEvent* /* HCTE */ ) { if ( fgOutput ) fgOutput -> Output( this ); // output hitdata to output file .... if ( !ofs.good() ) { const G4String& errorMessage = "J4FWHit::Output(): write error."; G4cerr << errorMessage << G4endl; } else { std::ofstream& ofs = GetOutputFileStream(); ofs << “fwhit " << std::setw(3) << fPreHitID << " " << std::setw(5) << GetPDGEncoding() << " " ........ << std::endl; } } LC tools lecture, Jupiter part

  31. 11. SDの実装 J4FWSD では ProcessHits() 部分の実装がメインです。 下記の場合にはSD登録した部分に粒子が入射されると全てのhit情報を残します。 G4bool J4FWSD::ProcessHits(G4Step *aStep, G4TouchableHistory *) { //In order to use Get function, you must call SetNewStep() at first. SetNewStep(aStep) J4VComponent* location = GetComponent(); G4int trackID = GetTrackID(); G4int mothertrackID = GetMotherTrackID(); G4ParticleDefinition *particle = GetParticle(); G4double tof = GetTof(); .... J4FWHit* hit = new J4FWHit( location, trackID, mothertrackID, particle, tof, edep, etot, p, pre, pos); ((J4FWHitBuf*)GetHitBuf())->insert( hit ); return true; } LC tools lecture, Jupiter part

  32. (例)CALのHit/SDについて Layer CALSD Abs Active Hit SubLayerSD PreHit PostHit LC tools lecture, Jupiter part

  33. Source/main/Jupiter.ccの実装 #define __INSTALLIR__ #define __INSTALLBD__ #define __INSTALLVTX__ #define __INSTALLIT__ #if 0 #define __INSTALLCDC__ #else #define __INSTALLTPC__ #endif #define __INSTALLCAL__ #define __INSTALLSOL__ #define __INSTALLMUD__ #define __INSTALLFW__ #ifdef __INSTALLFW_ J4FW *fwptr = new J4FW(); fwptr->SetMother(dtcptr->GetEXPHall()); dtcptr->AddComponent(fwptr); #endif LC tools lecture, Jupiter part

  34. 検出器実装の完了 以上で最低限の検出器実装が終了しました。 他に残っているのは PostHit、PreHit など 検出器の入り口、出口での情報を残すようにするか? などの検討が必要です。これはSD、Hitを新しく書く必要があります。 実装がすんだら実際に検出器の絵を描いたり geometry test、正しいhit情報が出ているか などもチェックします。 LC tools lecture, Jupiter part

  35. dawnを用いたジオメトリの描画 • Jupiterのジオメトリを作った後に確認する手段としてdawnがあります。 • Jupiter/macros 以下にdawnで絵を描くためのマクロがあります。 % ./bin/Linux-g++/Jupiter >/control/execute macros/visdawnf.g4mac >/control/execute macros/view.g4mac Jupiter/images/dawn/g4_00.prim といった primファイル、epsファイルが作成されます。 LC tools lecture, Jupiter part

  36. dawnを用いたジオメトリの描画 カメラで見る向き polar 90 なら横から ズームアップ ビューモード このようなGUIが立ち上がるので、カメラの方向や位置、 モード(wireframe, surface 等)選んでください。 LC tools lecture, Jupiter part

  37. dawnを用いたジオメトリの描画 % dawn xxx.prim で出来たprimファイルを表示 surfaceだと断面が見えない。 wireframe surface LC tools lecture, Jupiter part

  38. dawncutを用いた描画 dawncut で完成した prim file を x, y, z 平面でカットします % dawncut a b c d g4_00.prim input.prim cut.prim ( ax+by+cz+d = 0 平面でカット ) z=0 x=0 LC tools lecture, Jupiter part

  39. 3次元立体図で切り取られた絵を描くには? まず、下記のシェルスクリプトを用いてprimファイルを合わせる #!/bin/sh dawncut 0.0 -1.0 0.0 0.0 gr.prim gr-ycut.prim dawncut 0.0 1.0 0.0 0.0 gr.prim gr+ycut.prim dawncut -1.0 0.0 0.0 0.0 gr-ycut.prim gr-xcut.prim dawncut 1.0 0.0 0.0 0.0 gr-ycut.prim gr+xcut.prim dawncut 0.0 0.0 1.0 0.0 gr-xcut.prim gr+zcut.prim cat gr+ycut.prim gr+xcut.prim gr+zcut.prim > sum.prim その後sum.primの最初と最後以外の以下の項目を消す。 /BoundingBox ****** ******* !SetCamera !OpenDevice !BeginModeling !EndModeling !DrawAll !CloseDevice LC tools lecture, Jupiter part

  40. まとめ Jupiterのジオメトリのインストールについて述べました。 基本的には変更したりする必要はないかもしれませんが、 SDやHitなどは変更する必要がある場合があるかもしれません。 LC tools lecture, Jupiter part

  41. CALのジオメトリについて MiniTower Cone Tower Block Layer HD Abs Active EM MiniCone EM, HDで異なる分割にできる。 セルサイズを分割量で変更 SubLayer LC tools lecture, Jupiter part

More Related