ATLAS Offline Software
ReweightUtils.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 # sanitize shell output
4 try:
5  from os import environ
6  if environ.get('TERM','') == 'xterm':
7  environ['TERM'] = 'vt100'
8 except ImportError:
9  pass
10 except KeyError:
11  pass
12 
13 # filter out annoying warnings regarding missing converters
14 import warnings
15 warnings.filterwarnings( action='ignore', category=RuntimeWarning, message='creating converter.*' )
16 
17 # import basics
18 from os import getenv
19 from distutils.version import StrictVersion
20 from platform import python_version
21 
22 try:
23  import ROOT
24  # check if the python version is compatible
25  if StrictVersion(python_version()) < StrictVersion('2.7.0'):
26  raise ImportError("\033[1;31mFATAL\033[0m: unsupported python version, please use at least version 2.7.0")
27 
28  # we will need this library later
29  ROOT.gSystem.Load("libTreePlayer")
30 
31  # retrieve the root core dir environment variable
32  RootCoreDir = getenv ("ROOTCOREDIR")
33  try:
34  t = ROOT.McEventWeight()
35  except Exception:
36  if RootCoreDir:
37  ROOT.gROOT.ProcessLine(".x $ROOTCOREDIR/scripts/load_packages.C")
38  else:
39  print ("Nothing foreseen in this case, complain to Olivier...")
40 
41 except ImportError as err:
42  print(err)
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70