FairShip
Loading...
Searching...
No Matches
shipRoot_conf.py
Go to the documentation of this file.
1# SPDX-License-Identifier: LGPL-3.0-or-later
2# SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration
3
4import atexit
5import os
6import sys
7
8import ROOT
9from pythia8_conf_utils import addHNLtoROOT
10from pythia8darkphoton_conf import addDPtoROOT
11
12if os.environ.get("FAIRSHIP_ROOT", "") == "":
13 print("FairShip environment not found, quitting.")
14 quit()
15
16ROOT.gSystem.Load("libPythia6")
17ROOT.gSystem.Load("libpythia8")
18ROOT.gSystem.Load("libG4clhep")
19
20# GenFit 02-03-00 no longer ships rootmap or unified PCM files, so ROOT's
21# autoloading cannot discover genfit classes. Load the library, point Cling
22# at the headers, and explicitly parse those used at runtime.
23genfit_root = os.environ.get("GENFIT_ROOT", os.environ.get("GENFIT", ""))
24if genfit_root:
25 ROOT.gSystem.Load("libgenfit2")
26 ROOT.gInterpreter.AddIncludePath(os.path.join(genfit_root, "include"))
27 ROOT.gInterpreter.Declare(
28 """
29#include "DAF.h"
30#include "DetPlane.h"
31#include "Exception.h"
32#include "FieldManager.h"
33#include "MaterialEffects.h"
34#include "MeasuredStateOnPlane.h"
35#include "RKTrackRep.h"
36#include "SharedPlanePtr.h"
37#include "StateOnPlane.h"
38#include "TGeoMaterialInterface.h"
39#include "Tools.h"
40#include "Track.h"
41#include "TrackPoint.h"
42#include "WireMeasurement.h"
43"""
44 )
45
46
47def forReadingOldFile() -> None:
48 ROOT.gInterpreter.ProcessLine("typedef double Double32_t")
49
50
51# -----prepare python exit-----------------------------------------------
52
53
54def pyExit() -> None:
55 for module in sys.modules:
56 if "ROOT.genfit" in module:
57 x = sys.modules["__main__"]
58 if hasattr(x, "run"):
59 del x.run
60 print("make suicid, until better solution found to ROOT/genfit interference")
61 for f in ROOT.gROOT.GetListOfFiles():
62 if f.IsWritable() and f.IsOpen():
63 f.Close()
64 os.system("kill " + str(os.getpid()))
65 if hasattr(x, "fMan"):
66 del x.fMan
67 if hasattr(x, "fRun"):
68 del x.fRun
69 return
70 print("Exit normally")
71
72
73def configure(darkphoton=None) -> None:
74 ROOT.gROOT.ProcessLine('#include "' + os.environ["FAIRSHIP"] + '/shipdata/ShipGlobals.h"')
75 pdg = ROOT.TDatabasePDG.Instance()
76 # pythia stuff not known to ROOT
77 pdg.AddParticle("system", "system", 0.0, False, 0.0, 0.0, "XXX", 90)
78 pdg.AddParticle("Pomeron", "Pomeron", 0.0, False, 0.0, 0.0, "Pomeron", 990)
79 pdg.AddParticle("p_diffr+", "p_diffr+", 0.0, False, 0.0, 0.0, "XXX", 9902210)
80 pdg.AddParticle("n_diffr0", "n_diffr0", 0.0, False, 0.0, 0.0, "XXX", 9902110)
81 pdg.AddParticle("C12", "Carbon-12", 12.0, True, 0, 6.0, "nucleus", 1000060120)
82 pdg.AddParticle("C13", "Carbon-13", 13.003355, True, 0, 6.0, "nucleus", 1000060130)
83 pdg.AddParticle("J/psi[3PJ(8)]", "J/psi[3PJ(8)]", 3.29692, False, 0.0, 0.0, "Meson", 9942003)
84 pdg.AddParticle("J/psi[1S0(8)]", "J/psi[1S0(8)]", 3.29692, False, 0.0, 0.0, "Meson", 9941003)
85 pdg.AddParticle("f0(980)", "f0(980)", 1.0, False, 0.0, 0.0, "Meson", 9010221)
86 pdg.AddParticle("psi(3770)", "psi(3770)", 3.77315, False, 0.02720, 0, "Meson", 30443)
87 pdg.AddParticle("psi(3770)[3PJ(8)]", "psi(3770)[3PJ(8)]", 3.97315, False, 0.0, 0, "Meson", 9942033)
88 pdg.AddParticle("J/psi[3S1(8)]", "J/psi[3S1(8)]", 3.29692, False, 0.0, 0, "Meson", 9940003)
89 pdg.AddParticle("chi_0c[3S1(8)]", "chi_0c[3S1(8)]", 3.61475, False, 0.0, 0, "Meson", 9940011)
90 pdg.AddParticle("psi(2S)[1S0(8)]", "psi(2S)[1S0(8)]", 3.88611, False, 0.0, 0, "Meson", 9941103)
91 pdg.AddParticle("psi(2S)[3S1(8)]", "psi(2S)[3S1(8)]", 3.88611, False, 0.0, 0, "Meson", 9940103)
92 pdg.AddParticle("psi(2S)[3PJ(8)]", "psi(2S)[3PJ(8)]", 3.88611, False, 0.0, 0, "Meson", 9942103)
93 pdg.AddParticle("chi_1c[3S1(8)]", "chi_1c[3S1(8)]", 3.71066, False, 0.0, 0, "Meson", 9940023)
94 pdg.AddParticle("chi_2c[3S1(8)]", "chi_2c[3S1(8)]", 3.75620, False, 0.0, 0, "Meson", 9940005)
95 pdg.AddParticle("Upsilon[3S1(8)]", "Upsilon[3S1(8)]", 9.66030, False, 0.0, 0, "Meson", 9950003)
96
97 atexit.register(pyExit)
98 if darkphoton == 0:
99 return # will be added by pythia8_conf
100 if darkphoton:
101 addDPtoROOT()
102 else:
103 addHNLtoROOT()
None configure(darkphoton=None)
None forReadingOldFile()