Transcript The Virtual MonteCarlo
The Virtual MonteCarlo
D.Adamova
2 , V.Berejnoi
1 , R.Brun
1 , F.Carminati
1 , A.Fassó 1 , E.Futo
1 , I.Gonzalez
3 , I.Hrivnacova
4 , A.Morsch
1 1 CERN, Geneva; 2 NPI, Rez; 3 IFCA, Cantabria; 4 IPN, Orsay For the ALICE Collaboration Presented by I. Hrivnacova Conference for Computing in High Energy and Nuclear Physics La Jolla, 27 March 2003
Outline
Interfaces Available MCs Examples Distribution Future I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 2
The VMC Concept
The Virtual MonteCarlo (VMC) has been developed in order to – Run the same user application with all supported transport Monte Carlos – Run different transport Monte Carlo programs without changing the user code and therefore the geometry definition, the detector response simulation, or input and output formats VMC decouples the dependence of a user code from a concrete MC I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 3
VMC Concept
User Code
Input
I. Hrivnacova VMC Geant3 Geant4 Geant3 VMC Fluka Geant4 VMC Fluka VMC CHEP 2003, La Jolla, 27 March 2003 Particles Hits
Output
4
Virtual Monte Carlo
I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 5
Interfaces (1) Virtual MC
TVirtualMC – Interface to the Monte Carlo program – Generalization of Geant3 functions for definition of simulation task • Provides methods for definition of geometry and physics setup; for access to tracked particle properties during stepping; for run control – Implementations: TGeant3, TGeant4, TFluka (coming soon) • Are provided for the user I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 Methods For Building & Accessing Geometry Methods For Building & Accessing Materials Methods For Setting Physics Methods For Accessing Tracked Particle During Stepping Methods For Run Control 6
Interfaces (2)
TVirtualMCApplication – Interface to a user application – Defines user actions at each stage of a simulation run – Mandatory – Implementation has to be done by a user CHEP 2003, La Jolla, 27 March 2003
Virtual MC Application
ConstructGeometry InitGeometry GeneratePrimaries BeginEvent BeginPrimary PreTrack Stepping PostTrack FinishPrimary FinishEvent I. Hrivnacova 7
Interfaces (3)
TVirtualMCStack – Interface to a user defined particles stack – Mandatory – User can use the concrete stack classes provided in the examples or implement their own stack class TVirtualMCDecayer – Interface to an external decayer – Eg. Pythia6 – Optional I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 8
Use of VMC
Geometry Construction
User MC Application
ConstructGeometry
InitGeometry GeneratePrimaries BeginEvent BeginPrimary PreTrack Stepping PostTrack FinishPrimary FinishEvent I. Hrivnacova
void MyMCApplication::Construct Geometry()
{ Double_t trackerTube[3]; trackerTube[0] = 0.; trackerTube[1] = 60.; trackerTube[2] = 50.; gMC->Gsvolu("TRTU", "TUBE", fImedAl, trackerTube, 3); Double_t posX = -100.; Double_t posY = 0.; Double_t posZ = 0.; } gMC->Gspos("TRTU", 1 , "EXPH", posX, posY, posZ, 0, "ONLY"); Geometry is defined by calls to TVirtualMC interface CHEP 2003, La Jolla, 27 March 2003 9
Use of VMC
Primary Particles
User MC Application ConstructGeometry InitGeometry
GeneratePrimaries
BeginEvent BeginPrimary PreTrack Stepping PostTrack FinishPrimary FinishEvent I. Hrivnacova
void MyMCApplication::GeneratePrimaries()
{ // Define particle properties: // PDG encoding // position: vx, vy, vz, vt // momentum: px py, pz, e // … } // Add particle to MC stack gMC->GetStack() ->SetTrack(toBeDone, -1, pdg, px, py, pz, e, vx, vy, vz, t, …); Primary particles are defined by calls to the TVirtualMCStack interface CHEP 2003, La Jolla, 27 March 2003 10
User MC Application ConstructGeometry InitGeometry GeneratePrimaries BeginEvent BeginPrimary PreTrack
Stepping
PostTrack FinishPrimary FinishEvent Use of VMC
Hits Production
void
{
MyMCApplication:: Stepping()
// Get track position Double_t x, y, z; gMC->TrackPosition(x, y, z); // Get energy deposit Double_t edep = gMC->Edep(); } // Create user hit mySD->AddHit(x, y, z, edep); The user stepping function is called by MC at each step User gets the properties of the tracked particle by calls to TVirtualMC and saves them in their own hits objects CHEP 2003, La Jolla, 27 March 2003 11 I. Hrivnacova
Available MCs
Geant3, Geant4 – Geant3 VMC and Geant4 VMC in production Fluka – Fluka VMC in development I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 12
Available MCs
Geant3 VMC
Provided within a single package together with Geant321 (FORTRAN) Straightforward implementation – VirtualMC was largely inspired by Geant3 Geant3 Geometry Browser – Provided within TGeant3 – http://alisoft.cern.ch/ people/morsch/Geant3GUI.html
I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 13
Available MCs
Geant4 VMC (1)
Provided within a package - geant4_vmc – Requires Geant4 installation Access to Geant4 – Switching between Root UI and Geant4 UI – Geant4 classes are not processed by CINT – G4 objects are not accessible from the Root UI Use of G3toG4 – TVirtualMC has been inspired by Geant3 – An effort has been made to minimize the limitations of the G3toG4 tool – in Geant4 4.0: • Support for reflections • Limited support for “MANY” volume positions I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 14
Available MCs
Geant4 VMC (2)
Geant4 VMC extensions: – Geant4 VMC Geometry Browser • Analogy to Geant3 Geometry browser – Geometry XML Convertor • Enables to export Geant4 geometry to XML (AGDD) and then to browse and visualize using GraXML • More on GraXML: in the presentation: “GraXML – Modular Geometric Modeller” (J. Hrivnac) I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 15
Available MCs
Fluka VMC
In development by the ALICE collaboration and FLUKA team – TFluka in AliRoot Implemented: – Functions for building/accessing geometry • Use of Geant4 VMC + Flugg – Functions for accessing tracked particle during stepping – Recording particles in VMC stack – Functions for run management To be done: – Functions for setting physics – External decayer I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 16
Examples
3 examples provided in geant4_vmc – In spite of being provided within Geant4 VMC, they are built independently and do not require Geant4 installation in case a user wants to run them with Geant3 only Geant4 novice examples N01, N02 and N03 rewritten with use of Virtual Monte Carlo Implement MC Application and MC Stack All examples are executed in the same way: – cd geant4_vmc/examples/E0n – root – root[0] .x run_g3.C or run_g4.C I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 17
{
// Load basic libraries
gROOT->LoadMacro(“basiclibs.C”); basiclibs();
// Load Geant3 libraries
gROOT->LoadMacro(“g3libs.C”); g3libs();
E01 run_g3.C
run_g4.C
// Load Geant4 libraries
gROOT->LoadMacro(“g4libs.C”); g4libs();
// Load this example library
gSystem->Load("libexample01");
// MC application
Ex01MCApplication* appl = new Ex01MCApplication("Example01", "The example01 MC application"); appl->InitMC("g3Config.C"); appl->InitMC("g4Config.C"); I. Hrivnacova } appl->RunMC(1); CHEP 2003, La Jolla, 27 March 2003 18
E01 g3Config.C
g4Config.C
} { void Config() new TGeant3("C++ Interface to Geant3"); void Config() {
// RunConfiguration for Geant4
TG4RunConfiguration* runConfiguration = new TG4RunConfiguration(); }
// Geant4 VMC
new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration); I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 19
Examples
AliRoot
AliRoot Framework – Integrates simulation, reconstruction and analysis software for the ALICE experiment Simulation based on Virtual Monte Carlo – A complex “example” of VMC usage – No MC specific code in user code – PPR production with Geant3 More on AliRoot – in the presentations: – “The AliRoot Framework, status and perspectives” (F.Carminati) – “Simulation in ALICE” (A. Morsch) – “ALICE experience with Geant4” (I. Gonzalez) I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 20
AliRoot Geometry Dimuon Arm I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 21
AliRoot Hits Production I. Hrivnacova Geant3 CHEP 2003, La Jolla, 27 March 2003 Geant4 22
VMC Future (1)
Integration of the new Root geometrical modeller (TGeo) in VMC – in progress – Will then be able to define MC geometry directly via TGeo Geant3, Fluka – Replacement of the native geometry with TGeo inside the program itself – Geant3: • Already operational, close to completion • Production release in coming weeks – Fluka: • Work is ongoing I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 23
VMC Future (2)
Geant4 – Discussions about using the Root geometry modeller through an abstract interface to Geant4 geometry have been started – RootToG4 converter • Converter from Root geometry to Geant4 native geometry • Already operational, close to completion • Production release will follow the release of the new Geant3 version More on TGeo – in the presentation: “A Geometrical Modeller for HEP” (A. Gheata) I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 24
Distribution
ROOT CVS server – mc – core package (interfaces), in Root – geant3, geant4_vmc • 2 independent modules (parallel to root): – cvs -d :pserver:[email protected]:/user/cvs co –P geant3 – cvs -d :pserver:[email protected]:/user/cvs co –P geant4_vmc ROOT Web – http://root.cern.ch/root/vmc/VirtualMC.html
– Distribution of sources: • geant321+_vmc.version.tar.gz • geant4_vmc.version.tar.gz
I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 25
Summary
VMC allows the user to run different transport MonteCarlo’s from the same user code – On the menu today: Geant3, Geant4 – Coming soon: Fluka VMC available from – http://root.cern.ch/root/vmc/VirtualMC.html
I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 26