ATLAS Offline Software
Functions
python.MadGraphUtilsHelpers Namespace Reference

Functions

def getDictFromCard (card_loc, lowercase=False)
 
def settingIsTrue (setting)
 
def totallyStripped (x)
 
def checkSetting (key_, value_, mydict_)
 
def checkSettingIsTrue (key_, mydict_)
 
def checkSettingExists (key_, mydict_)
 
def is_version_or_newer (args)
 
def isNLO_from_run_card (run_card)
 
def get_runArgs_info (runArgs)
 

Function Documentation

◆ checkSetting()

def python.MadGraphUtilsHelpers.checkSetting (   key_,
  value_,
  mydict_ 
)

Definition at line 37 of file MadGraphUtilsHelpers.py.

37 def checkSetting(key_,value_,mydict_):
38  key=totallyStripped(key_)
39  value=totallyStripped(value_)
40  mydict={}
41  for k in mydict_:
42  mydict[totallyStripped(k)]=totallyStripped(mydict_[k])
43  return key in mydict and mydict[key]==value
44 

◆ checkSettingExists()

def python.MadGraphUtilsHelpers.checkSettingExists (   key_,
  mydict_ 
)

Definition at line 52 of file MadGraphUtilsHelpers.py.

52 def checkSettingExists(key_,mydict_):
53  key=totallyStripped(key_)
54  keys=[]
55  for k in mydict_:
56  keys+=[totallyStripped(k)]
57  return key in keys
58 

◆ checkSettingIsTrue()

def python.MadGraphUtilsHelpers.checkSettingIsTrue (   key_,
  mydict_ 
)

Definition at line 45 of file MadGraphUtilsHelpers.py.

45 def checkSettingIsTrue(key_,mydict_):
46  key=totallyStripped(key_)
47  mydict={}
48  for k in mydict_:
49  mydict[totallyStripped(k)]=totallyStripped(mydict_[k])
50  return key in mydict and mydict[key] in ['t','true']
51 

◆ get_runArgs_info()

def python.MadGraphUtilsHelpers.get_runArgs_info (   runArgs)

Definition at line 98 of file MadGraphUtilsHelpers.py.

98 def get_runArgs_info(runArgs):
99  if runArgs is None:
100  raise RuntimeError('runArgs must be provided!')
101  if hasattr(runArgs,'ecmEnergy'):
102  beamEnergy = runArgs.ecmEnergy / 2.
103  else:
104  raise RuntimeError("No center of mass energy found in runArgs.")
105  if hasattr(runArgs,'randomSeed'):
106  random_seed = runArgs.randomSeed
107  else:
108  raise RuntimeError("No random seed found in runArgs.")
109  return beamEnergy,random_seed
110 
111 

◆ getDictFromCard()

def python.MadGraphUtilsHelpers.getDictFromCard (   card_loc,
  lowercase = False 
)

Definition at line 7 of file MadGraphUtilsHelpers.py.

7 def getDictFromCard(card_loc,lowercase=False):
8  card=open(card_loc)
9  mydict={}
10  for line in iter(card):
11  if not line.strip().startswith('#'): # line commented out
12  command = line.split('!', 1)[0]
13  if '=' in command:
14  setting = command.split('=')[-1].strip()
15  value = '='.join(command.split('=')[:-1]).strip()
16  if lowercase:
17  value=value.lower()
18  setting=setting.lower()
19  mydict[setting]=value
20  card.close()
21  return mydict
22 

◆ is_version_or_newer()

def python.MadGraphUtilsHelpers.is_version_or_newer (   args)

Definition at line 59 of file MadGraphUtilsHelpers.py.

59 def is_version_or_newer(args):
60  # also need to find out the version (copied from generate)
61  import os
62  version=None
63  version_file = open(os.environ['MADPATH']+'/VERSION','r')
64 
65  for line in version_file:
66  if 'version' in line:
67  version=line.split('=')[1].strip()
68  version_file.close()
69 
70  if not version:
71  raise RuntimeError('Failed to find MadGraph/MadGraph5_aMC@NLO version in '+version_file)
72 
73  vs=[int(v) for v in version.split('.')]
74 
75  # this is lazy, let's hope there wont be a subversion > 100...
76  y=int(100**max(len(vs),len(args)))
77  testnumber=0
78  for x in args:
79  testnumber+=x*y
80  y/=100
81 
82  y=int(100**max(len(vs),len(args)))
83  versionnumber=0
84  for x in vs:
85  versionnumber+=x*y
86  y/=100
87  return versionnumber>=testnumber
88 

◆ isNLO_from_run_card()

def python.MadGraphUtilsHelpers.isNLO_from_run_card (   run_card)

Definition at line 89 of file MadGraphUtilsHelpers.py.

89 def isNLO_from_run_card(run_card):
90  f = open(run_card,'r')
91  if "parton_shower" in f.read().lower():
92  f.close()
93  return True
94  else:
95  f.close()
96  return False
97 

◆ settingIsTrue()

def python.MadGraphUtilsHelpers.settingIsTrue (   setting)

Definition at line 23 of file MadGraphUtilsHelpers.py.

23 def settingIsTrue(setting):
24  if setting.replace("'",'').replace('"','').replace('.','').lower() in ['t','true']:
25  return True
26  return False
27 

◆ totallyStripped()

def python.MadGraphUtilsHelpers.totallyStripped (   x)

Definition at line 28 of file MadGraphUtilsHelpers.py.

28 def totallyStripped(x):
29  y=str(x).lower().strip()
30  # remove leading and trailing "/'
31  while len(y)>0 and (y[0]=='"' or y[0]=="'"):
32  y=y[1:]
33  while len(y)>0 and (y[-1]=='"' or y[-1]=="'"):
34  y=y[:-1]
35  return y
36 
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.MadGraphUtilsHelpers.isNLO_from_run_card
def isNLO_from_run_card(run_card)
Definition: MadGraphUtilsHelpers.py:89
python.MadGraphUtilsHelpers.settingIsTrue
def settingIsTrue(setting)
Definition: MadGraphUtilsHelpers.py:23
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.MadGraphUtilsHelpers.checkSettingIsTrue
def checkSettingIsTrue(key_, mydict_)
Definition: MadGraphUtilsHelpers.py:45
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
python.MadGraphUtilsHelpers.get_runArgs_info
def get_runArgs_info(runArgs)
Definition: MadGraphUtilsHelpers.py:98
python.MadGraphUtilsHelpers.checkSetting
def checkSetting(key_, value_, mydict_)
Definition: MadGraphUtilsHelpers.py:37
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.MadGraphUtilsHelpers.checkSettingExists
def checkSettingExists(key_, mydict_)
Definition: MadGraphUtilsHelpers.py:52
Trk::open
@ open
Definition: BinningType.h:40
str
Definition: BTagTrackIpAccessor.cxx:11
python.MadGraphUtilsHelpers.totallyStripped
def totallyStripped(x)
Definition: MadGraphUtilsHelpers.py:28
python.MadGraphUtilsHelpers.getDictFromCard
def getDictFromCard(card_loc, lowercase=False)
Definition: MadGraphUtilsHelpers.py:7
python.MadGraphUtilsHelpers.is_version_or_newer
def is_version_or_newer(args)
Definition: MadGraphUtilsHelpers.py:59