When calculating a*a-b*b the form (a-b)*(a+b) is usually more numerically stable.
[u/mrichter/AliRoot.git] / macros / g4Config.C
CommitLineData
1fccbbe0 1// $Id$
2//
3// Configuration macro for running aliroot with Geant4.
4// All AliRoot specifics are defined in g4ConfigCommon.C
5//
6// In order to run aliroot with Geant4, you have to Initialize
7// AliRun with this g4Config.C
8//
9// aliroot
10// root [0] gAlice->Init("g4Config.C");
11// root [1] gAlice->Run();
12//
13// You can also start from a mini GUI - g4menu.C.
14// See description in this macro.
e14b4d5a 15//
16// By I. Hrivnacova, IPN Orsay
1fccbbe0 17
18
19void Config()
20{
e14b4d5a 21 cout << "Running g4Config.C ... " << endl;
22
9ac91a91 23 // AliRoot setup
24 //
e14b4d5a 25 gROOT->LoadMacro("$ALICE_ROOT/macros/g4ConfigCommon.C");
9ac91a91 26 ConfigCommon();
1fccbbe0 27
28 // Load Geant4 + Geant4 VMC libraries
29 //
30 if (gClassTable->GetID("TGeant4") == -1) {
31 // Load Geant4 libraries
32 if (!gInterpreter->IsLoaded("$ALICE/geant4_vmc/examples/macro/g4libs.C")) {
33 gROOT->LoadMacro("$ALICE/geant4_vmc/examples/macro/g4libs.C");
34 gInterpreter->ProcessLine("g4libs()");
35 }
36 }
37
38 // Create Geant4 VMC
39 //
9ac91a91 40 TGeant4 *geant4 = 0;
1fccbbe0 41 if (!gMC) {
1fccbbe0 42 TG4RunConfiguration* runConfiguration
e14b4d5a 43 = new TG4RunConfiguration("geomRoot",
44 "emStandard+optical",
8d121203 45 "specialCuts+specialControls+stackPopper",
46 true);
e14b4d5a 47// = new TG4RunConfiguration("geomRootToGeant4",
48// "emStandard+optical",
49// "specialCuts+specialControls+stackPopper",
50// true);
9ac91a91 51
1fccbbe0 52
9ac91a91 53 geant4 = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
1fccbbe0 54 cout << "Geant4 has been created." << endl;
9ac91a91 55 } else {
1fccbbe0 56 cout << "Monte Carlo has been already created." << endl;
9ac91a91 57 }
1fccbbe0 58
9ac91a91 59 //
60 // Set External decayer
61 TVirtualMCDecayer *decayer = new AliDecayerPythia();
7354fb71 62
9ac91a91 63 decayer->SetForceDecay(kAll);
64 decayer->Init();
65 gMC->SetExternalDecayer(decayer);
66
67 //=======================================================================
68 // ************* STEERING parameters FOR ALICE SIMULATION **************
69 // --- Specify event type to be tracked through the ALICE setup
70 // --- All positions are in cm, angles in degrees, and P and E in GeV
1fccbbe0 71
9ac91a91 72 gMC->SetProcess("DCAY",1);
73 gMC->SetProcess("PAIR",1);
74 gMC->SetProcess("COMP",1);
75 gMC->SetProcess("PHOT",1);
76 gMC->SetProcess("PFIS",0);
77 gMC->SetProcess("DRAY",0);
78 gMC->SetProcess("ANNI",1);
79 gMC->SetProcess("BREM",1);
80 gMC->SetProcess("MUNU",1);
81 gMC->SetProcess("CKOV",1);
82 gMC->SetProcess("HADR",1);
83 gMC->SetProcess("LOSS",2);
84 gMC->SetProcess("MULS",1);
85 //gMC->SetProcess("RAYL",1);
1fccbbe0 86
9ac91a91 87 Float_t cut = 1.e-3; // 1MeV cut by default
88 Float_t tofmax = 1.e10;
89
90 gMC->SetCut("CUTGAM", cut);
91 gMC->SetCut("CUTELE", cut);
92 gMC->SetCut("CUTNEU", cut);
93 gMC->SetCut("CUTHAD", cut);
94 gMC->SetCut("CUTMUO", cut);
95 gMC->SetCut("BCUTE", cut);
96 gMC->SetCut("BCUTM", cut);
97 gMC->SetCut("DCUTE", cut);
98 gMC->SetCut("DCUTM", cut);
99 gMC->SetCut("PPCUTM", cut);
100 gMC->SetCut("TOFMAX", tofmax);
101
102 // Set apply cuts
103 geant4->ProcessGeantCommand("/run/particle/applyCuts");
e14b4d5a 104 // geant4->ProcessGeantCommand("/mcVerbose/geometryManager 2");
105 geant4->ProcessGeantCommand("/mcVerbose/composedPhysicsList 2");
9ac91a91 106 geant4->ProcessGeantCommand("/mcDet/volNameSeparator !");
107 geant4->ProcessGeantCommand("/mcControl/g3Defaults");
108 geant4->ProcessGeantCommand("/mcPhysics/setStackPopperSelection e+ e- pi+ pi- kaon+ kaon- gamma");
e14b4d5a 109 // geant4->ProcessGeantCommand("/tracking/verbose 1");
110
111 cout << "Running g4Config.C finished ... " << endl;
1fccbbe0 112}