The Virtual MonteCarlo D.Adamova 2, V.Berejnoi 1, R.Brun 1, F.Carminati 1, A.Fassó 1, E.Futo 1,...

26
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

Transcript of The Virtual MonteCarlo D.Adamova 2, V.Berejnoi 1, R.Brun 1, F.Carminati 1, A.Fassó 1, E.Futo 1,...

Page 1: 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;

The Virtual MonteCarlo

D.Adamova2, V.Berejnoi1, R.Brun1, F.Carminati1, A.Fassó1, E.Futo1, I.Gonzalez3, I.Hrivnacova4, A.Morsch1

1CERN, Geneva; 2NPI, Rez; 3IFCA, Cantabria; 4IPN, Orsay

For the ALICE CollaborationPresented by I. Hrivnacova

Conference forComputing in High Energy and Nuclear Physics

La Jolla, 27 March 2003

Page 2: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 2

Outline

Interfaces Available MCs Examples Distribution Future

Page 3: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 3

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

Page 4: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 4

VMC Concept

UserCode

VMC

Geant4 VMC

ParticlesHits

Geant4

Geant3

Output

Fluka VMC

Fluka

Input

Geant3 VMC

Page 5: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 5

Virtual Monte Carlo

Page 6: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 6

Interfaces (1)

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

Methods For Building & Accessing Geometry

Methods For Building & Accessing Materials

Methods For Setting Physics

Methods For Accessing Tracked ParticleDuring Stepping

Methods For Run Control

Virtual MC

Page 7: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 7

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

ConstructGeometryInitGeometryGeneratePrimaries

BeginEventBeginPrimaryPreTrackSteppingPostTrackFinishPrimaryFinishEvent

Virtual MC Application

Page 8: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 8

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

Page 9: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 9

ConstructGeometryInitGeometryGeneratePrimaries

BeginEventBeginPrimaryPreTrackSteppingPostTrackFinishPrimaryFinishEvent

User MC Application

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"); }

Use of VMC

Geometry Construction

Geometry is defined by calls to TVirtualMC interface

Page 10: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 10

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,

…);

}

Use of VMC

Primary Particles

Primary particles are defined by calls to the TVirtualMCStack interface

ConstructGeometryInitGeometryGeneratePrimaries

BeginEventBeginPrimaryPreTrackSteppingPostTrackFinishPrimaryFinishEvent

User MC Application

Page 11: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 11

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);}

Use of VMC

Hits Production

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

ConstructGeometryInitGeometryGeneratePrimaries

BeginEventBeginPrimaryPreTrackSteppingPostTrackFinishPrimaryFinishEvent

User MC Application

Page 12: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 12

Available MCs

Geant3, Geant4 – Geant3 VMC and Geant4 VMC in production

Fluka– Fluka VMC in development

Page 13: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 13

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

Page 14: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 14

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

Page 15: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 15

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)

Page 16: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 16

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

Page 17: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 17

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

Page 18: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 18

{ // Load basic libraries gROOT->LoadMacro(“basiclibs.C”); basiclibs();

// Load this example library gSystem->Load("libexample01");

// MC application Ex01MCApplication* appl = new Ex01MCApplication("Example01", "The example01 MC application");

appl->RunMC(1);}

E01run_g3.Crun_g4.C

// Load Geant3 libraries gROOT->LoadMacro(“g3libs.C”); g3libs();

// Load Geant4 libraries gROOT->LoadMacro(“g4libs.C”); g4libs();

appl->InitMC("g3Config.C"); appl->InitMC("g4Config.C");

Page 19: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 19

void Config() {

// RunConfiguration for Geant4 TG4RunConfiguration* runConfiguration = new TG4RunConfiguration();

// Geant4 VMC new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);}

void Config(){ new TGeant3("C++ Interface to Geant3");}

E01g3Config.Cg4Config.C

Page 20: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 20

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)

Page 21: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 21

Dimuon Arm

AliRoot Geometry

Page 22: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 22

AliRoot Hits Production

Geant3 Geant4

Page 23: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 23

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

Page 24: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 24

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)

Page 25: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 25

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

Page 26: 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;

I. Hrivnacova CHEP 2003, La Jolla, 27 March 2003 26

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