ATLAS Offline Software
Functions | Variables
RHadronMasses Namespace Reference

Functions

def charge (c)
 
def get_quarks (y)
 
def is_baryon (x)
 
def anti_name (x)
 
def get_gluino_Rhadron_masses (input_file, mass_spectrum=1)
 
def update_PDG_table (input_file, pdg_table, mass_spectrum=1)
 
def update_particle_table (input_file, particle_table='particles.txt', mass_spectrum=1)
 
def get_Pythia8_commands (input_file, mass_spectrum=1)
 
def get_interaction_list (input_file, interaction_file='ProcessList.txt', mass_spectrum=1)
 
def print_masses (spectrum=-1)
 

Variables

int first_mass_set = 4
 
dictionary offset_options
 
dictionary gb_offset = offset_options[1009113][first_mass_set+5]-offset_options[1009113][first_mass_set+1]
 

Function Documentation

◆ anti_name()

def RHadronMasses.anti_name (   x)
Function to turn a particle name into an anti-particle name (mostly charge issues)

Definition at line 175 of file RHadronMasses.py.

175 def anti_name( x ):
176  """ Function to turn a particle name into an anti-particle name (mostly charge issues)
177  """
178  # These look a little funny to get both + and ++
179  if '*+' in x: return x.replace('*','bar*').replace('+','-')
180  if '*-' in x: return x.replace('*','bar*').replace('-','+')
181  if '++' in x: return x.replace('++','bar--')
182  if '--' in x: return x.replace('--','bar++')
183  if '+' in x: return x.replace('+','bar-')
184  if '-' in x: return x.replace('-','bar+')
185  if '*0' in x: return x.replace('*0','bar*0')
186  return x.replace('0','bar0')
187 
188 

◆ charge()

def RHadronMasses.charge (   c)
Function to return a PDG table formatted charge given an integer charge
    Input is the charge either as a string or number

Definition at line 135 of file RHadronMasses.py.

135 def charge( c ):
136  """ Function to return a PDG table formatted charge given an integer charge
137  Input is the charge either as a string or number
138  """
139  n = int(c)
140  if n==0: return ' 0'
141  if n==1: return ' +'
142  if n==2: return '++'
143  if n==-1: return ' -'
144  if n==-2: return '--'
145  raise RuntimeError('Unexpected charge: '+str(n))
146 
147 

◆ get_gluino_Rhadron_masses()

def RHadronMasses.get_gluino_Rhadron_masses (   input_file,
  mass_spectrum = 1 
)
Function to return a dictionary of PDG IDs and masses based on an input param/SLHA/LHE file
    First parameter: input file (string or file handle)
    Second parameter: mass spectrum (enumeration value)

Definition at line 189 of file RHadronMasses.py.

189 def get_gluino_Rhadron_masses(input_file, mass_spectrum=1):
190  """ Function to return a dictionary of PDG IDs and masses based on an input param/SLHA/LHE file
191  First parameter: input file (string or file handle)
192  Second parameter: mass spectrum (enumeration value)
193  """
194  # Expect a string file name or file handle
195  if isinstance(input_file, str):
196  in_file = open(input_file,'r')
197  else:
198  in_file = input_file
199 
200  # Expect SLHA file format. Read for mass block, then look for relevant masses, then exit
201  masses = {}
202  mass_block = False
203  for l in in_file.readlines():
204  # Are we entering the mass block?
205  if 'BLOCK' in l.upper().split('#')[0].split() and 'MASS' in l.upper().split('#')[0].split():
206  mass_block = True
207  continue
208  # Otherwise, if we've not yet entered the mass block, keep reading
209  elif not mass_block: continue
210  # If we're past the mass block, then stop reading
211  if 'BLOCK' in l.upper().split('#')[0].split(): break
212  # Skip empty lines, comments, etc
213  if len(l.split('#')[0].split())<2: continue
214  pdg_id = int(l.split('#')[0].split()[0])
215  # Set the input masses
216  if pdg_id in offset_options:
217  mass = float(l.split('#')[0].split()[1])
218  # If we have decoupled the thing, don't include it!
219  if mass > 7e3: continue
220  # Otherwise, it goes in the list
221  masses[pdg_id] = mass
222  # Not an ID we care about otherwise! Skip!
223  # Done reading file; close if it's our responsibility
224  if isinstance(input_file, str):
225  in_file.close()
226 
227  # Set the remainder of the masses
228  had_rhadron=False
229  for pid in offset_options:
230  # Skip fundamental particles - they should be read from the input file!
231  if offset_options[pid][0] == 0: continue
232  # Check if the constituent is in there (e.g. skip stop R-hadrons for gluino production)
233  if offset_options[pid][0] not in masses: continue
234  # Check if the mass spectrum is available
235  if mass_spectrum<0 or first_mass_set+mass_spectrum>len(offset_options[pid]):
236  raise RuntimeError("Unknown mass set requested: "+str(mass_spectrum)+" > number of options ("+str(len(offset_options[pid])-first_mass_set+1)+") for PID "+str(pid))
237  # Add 'normal' R-hadron
238  masses[pid] = masses[ offset_options[pid][0] ] + offset_options[pid][first_mass_set+mass_spectrum]
239  # If needed, add anti-R-hadron
240  if offset_options[pid][1]:
241  masses[-pid] = masses[ offset_options[pid][0] ] + offset_options[pid][first_mass_set+mass_spectrum]
242  had_rhadron = True
243 
244  # Make sure we generated some R-hadrons
245  if not had_rhadron:
246  raise RuntimeError('No R-hadrons generated!')
247 
248  # Return the dictionary
249  return masses
250 
251 

◆ get_interaction_list()

def RHadronMasses.get_interaction_list (   input_file,
  interaction_file = 'ProcessList.txt',
  mass_spectrum = 1 
)
Function to write all possible interactiosn that we need
    First input parameter: input file (string or file handle)
    Second input parameter: output PDG table (string or file handle)
    Third input parameter: mass spectrum (enumeration value)
    Gets R-hadron masses based on get_gluino_Rhadron_masses()

Definition at line 366 of file RHadronMasses.py.

366 def get_interaction_list(input_file, interaction_file='ProcessList.txt', mass_spectrum=1):
367  """ Function to write all possible interactiosn that we need
368  First input parameter: input file (string or file handle)
369  Second input parameter: output PDG table (string or file handle)
370  Third input parameter: mass spectrum (enumeration value)
371  Gets R-hadron masses based on get_gluino_Rhadron_masses()
372  """
373  # Get the masses that we need. Note that we don't really need masses, just PDG IDs
374  masses = get_gluino_Rhadron_masses(input_file,mass_spectrum)
375  # Get the output file ready
376  # Open for appending (assume that's what was done if given a file handle)
377  if isinstance (interaction_file, str):
378  out_file = open(interaction_file,'a')
379  else:
380  out_file = interaction_file
381 
382  # Helpful lists to move us along
383  sm_particles = {
384  # Name : Charge , Baryon # , Strangeness
385  'pi0' : [ 0 , 0 , 0 ],
386  'pi+' : [ 1 , 0 , 0 ],
387  'pi-' : [ -1 , 0 , 0 ],
388  'neutron' : [ 0 , 1 , 0 ],
389  'proton' : [ 1 , 1 , 0 ],
390  'kaon0' : [ 0 , 0 , 1 ],
391  'anti_kaon0' : [ 0 , 0 , -1 ],
392  'kaon+' : [ 1 , 0 , 1 ],
393  'kaon-' : [ -1 , 0 , -1 ]
394  }
395  targets = [ 'proton' , 'neutron' ]
396 
397  incoming_rhadrons = {}
398  outgoing_rhadrons = {}
399  for pid in masses:
400  # Only for bound states
401  if offset_options[abs(pid)][0]==0: continue
402  # All of them are on the list of incoming RHadrons
403  # Deal with strangeness
404  # Approximation! Bottom number -> -Charm number -> Strangeness
405  # Approximation needed because outgoing SM charms are not treated in G4 at the moment
406  s_number = 0
407  my_q = get_quarks(pid)
408  if '3' in my_q or '4' in my_q or '5' in my_q:
409  if len(my_q)>2:
410  # Gluino R-baryons
411  s_number = -(my_q.count('3')-my_q.count('4')+my_q.count('5')) if pid>0 else my_q.count('3')-my_q.count('4')+my_q.count('5')
412  elif len(my_q)>1 and '9' in str(pid):
413  # Gluino R-mesons
414  if my_q in ['33','44','55','35']: s_number=0 # 33, 44, 55, 35 - one is anti-quark, so they cancel
415  # By convention both 43 and 53 have charge +1, which means c-sbar or c-bbar
416  elif my_q in ['43','53']: s_number = 2 if pid>0 else -2
417  # Only one of bottom / charm / strange. Deal with neutral convention first
418  elif offset_options[abs(pid)][3]==0 and ('3' in my_q or '5' in my_q): s_number=1 if pid>0 else -1
419  elif offset_options[abs(pid)][3]==0 and '4' in my_q: s_number=1 if pid<0 else -1
420  # Now charged convention
421  elif '3' in my_q or '5' in my_q: s_number=offset_options[abs(pid)][3]
422  elif '4' in my_q: s_number=-offset_options[abs(pid)][3]
423  elif len(my_q)>1:
424  # Squark R-baryons
425  s_number = -(my_q.count('3')-my_q.count('4')+my_q.count('5')) if pid>0 else my_q.count('3')-my_q.count('4')+my_q.count('5')
426  else:
427  # Squark R-mesons
428  s_number = my_q.count('3') - my_q.count('4') + my_q.count('5')
429  s_number = s_number if pid>0 else -s_number
430  else: s_number=0
431  # Build the dictionary
432  pid_name = offset_options[pid][2].strip() if pid>0 else anti_name(offset_options[abs(pid)][2]).strip()
433  charge = offset_options[abs(pid)][3] if pid>0 else -offset_options[abs(pid)][3]
434  incoming_rhadrons[pid_name] = [ charge , is_baryon(pid) , s_number ]
435  # Smaller list of outgoing rhadrons.
436  # No charm or bottom
437  if '4' in my_q or '5' in my_q: continue
438  outgoing_rhadrons[pid_name] = [ charge , is_baryon(pid) , s_number ]
439 
440  # Add all our R-hadrons to the table
441  for proj in incoming_rhadrons:
442  # Loop over targets
443  for t in targets:
444  # Loop over possible outgoing R-hadrons
445  for orhad in outgoing_rhadrons:
446  # Possible 2>2 reactions
447  for osm1 in sm_particles:
448  # Check for charge conservation
449  total_charge = incoming_rhadrons[proj][0]+sm_particles[t][0]-outgoing_rhadrons[orhad][0]-sm_particles[osm1][0]
450  # Check for baryon number conservation
451  total_bnumber = incoming_rhadrons[proj][1]+sm_particles[t][1]-outgoing_rhadrons[orhad][1]-sm_particles[osm1][1]
452  # Check for strangeness conservation
453  total_snumber = incoming_rhadrons[proj][2]+sm_particles[t][2]-outgoing_rhadrons[orhad][2]-sm_particles[osm1][2]
454  # Check if it's an allowed reaction
455  if total_charge==0 and total_bnumber==0 and total_snumber==0:
456  out_file.write( ' # '.join([str(proj),str(t),str(orhad),str(osm1)])+'\n' )
457  # Now loop over possible 2>3 reactions
458  for osm2 in sm_particles:
459  # Check for charge conservation
460  total_charge = incoming_rhadrons[proj][0]+sm_particles[t][0]-outgoing_rhadrons[orhad][0]-sm_particles[osm1][0]-sm_particles[osm2][0]
461  # Check for baryon number conservation
462  total_bnumber = incoming_rhadrons[proj][1]+sm_particles[t][1]-outgoing_rhadrons[orhad][1]-sm_particles[osm1][1]-sm_particles[osm2][1]
463  # Check for strangeness conservation
464  total_snumber = incoming_rhadrons[proj][2]+sm_particles[t][2]-outgoing_rhadrons[orhad][2]-sm_particles[osm1][2]-sm_particles[osm2][2]
465  # Check if it's an allowed reaction
466  if total_charge==0 and total_bnumber==0 and total_snumber==0:
467  out_file.write( ' # '.join([str(proj),str(t),str(orhad),str(osm1),str(osm2)])+'\n' )
468  # Wrote out the reaction
469  # Loop over 2>3
470  # Loop over 2>2
471  # Loop over outgoing RHadrons
472  # Loop over targets
473  # Loop over projectiles
474 
475  # Done writing all the lines! Clean up if necessary
476  if isinstance(interaction_file, str):
477  out_file.close()
478 
479  # Nothing to return
480 
481 

◆ get_Pythia8_commands()

def RHadronMasses.get_Pythia8_commands (   input_file,
  mass_spectrum = 1 
)
Function to return a list of Pythia8 commands to set up an R-hadron mass spectrum.
    First input parameter: input file (string or file handle)
    Second input parameter: mass spectrum (enumeration value)

Definition at line 345 of file RHadronMasses.py.

345 def get_Pythia8_commands(input_file, mass_spectrum=1):
346  """ Function to return a list of Pythia8 commands to set up an R-hadron mass spectrum.
347  First input parameter: input file (string or file handle)
348  Second input parameter: mass spectrum (enumeration value)
349  """
350  # Get the masses for this configuration
351  masses = get_gluino_Rhadron_masses(input_file,mass_spectrum)
352  # Tell Pythia8 we are going to use our own masses
353  commands = ['RHadrons:setMasses = off']
354 
355  # Add commands to set all the masses
356  for pid in masses:
357  # Only set masses for particles (not anti-particles)
358  if pid<0: continue
359  # Actual command takes the form PDGID:m0 = somemass
360  commands += [ str(pid)+':m0 = '+str(masses[pid]) ]
361 
362  # All done!
363  return commands
364 
365 

◆ get_quarks()

def RHadronMasses.get_quarks (   y)
Function to return a list of quarks in a hadron

Definition at line 148 of file RHadronMasses.py.

148 def get_quarks( y ):
149  """ Function to return a list of quarks in a hadron
150  """
151  x = abs(y)
152  # For stop/sbottom mesons, just the last quark!
153  if '000' in str(x): return str(x)[5:6]
154  # For mesons, just two quarks
155  if '00' in str(x): return str(x)[4:6]
156  # For baryons, three quarks
157  return str(x)[3:6]
158 
159 

◆ is_baryon()

def RHadronMasses.is_baryon (   x)

Definition at line 160 of file RHadronMasses.py.

160 def is_baryon( x ):
161  # 1000993, gluinoball, is also not a baryon
162  b_n = 0
163  if '009' in str(x): b_n=0 # gluino meson
164  elif '09' in str(x): b_n=1 # gluino baryon
165  elif '0006' in str(x): b_n=0 # stop meson
166  elif '0005' in str(x): b_n=0 # sbottom meson
167  elif '006' in str(x): b_n=1 # stop baryon
168  elif '005' in str(x): b_n=1 # sbottom baryon
169  else: # Otherwise, what on earth was this??
170  raise RuntimeError('is_baryon ERROR Unknown PDG ID: '+str(x))
171  if int(x)<0: return -b_n
172  return b_n
173 
174 

◆ print_masses()

def RHadronMasses.print_masses (   spectrum = -1)
Print the mass spectra.
Input parameter: spectrum number.  If -1, print all spectra.

Definition at line 482 of file RHadronMasses.py.

482 def print_masses(spectrum=-1):
483  """ Print the mass spectra.
484  Input parameter: spectrum number. If -1, print all spectra.
485  """
486  for i in sorted(offset_options.keys()):
487  s= str(offset_options[i][2])+' '+str(i)
488  if spectrum<0:
489  from past.builtins import range # Temporary workaround for python3 compatibility use range in CA-based config
490  for j in range(first_mass_set,len(offset_options[i])): s+=' '+str(offset_options[i][j])
491  else:
492  if first_mass_set+spectrum>len(offset_options[i]):
493  raise RuntimeError('Spectrum #'+str(spectrum)+' not known for PID '+str(i))
494  else:
495  s+=' '+str(offset_options[i][spectrum+first_mass_set])
496  print (s)
497  # Done!

◆ update_particle_table()

def RHadronMasses.update_particle_table (   input_file,
  particle_table = 'particles.txt',
  mass_spectrum = 1 
)
Function to update a particle table with R-hadron masses
    First input parameter: input file (string or file handle)
    Second input parameter: output particle table (string or file handle)
    Third input parameter: mass spectrum (enumeration value)
    Gets R-hadron masses based on get_gluino_Rhadron_masses()

Definition at line 290 of file RHadronMasses.py.

290 def update_particle_table(input_file, particle_table='particles.txt', mass_spectrum=1):
291  """ Function to update a particle table with R-hadron masses
292  First input parameter: input file (string or file handle)
293  Second input parameter: output particle table (string or file handle)
294  Third input parameter: mass spectrum (enumeration value)
295  Gets R-hadron masses based on get_gluino_Rhadron_masses()
296  """
297  # Get the masses that we need
298  masses = get_gluino_Rhadron_masses(input_file,mass_spectrum)
299  # Get the output file ready
300  # Open for appending (assume that's what was done if given a file handle)
301  if isinstance (particle_table, str):
302  out_file = open(particle_table,'a')
303  else:
304  out_file = particle_table
305  # Add all our R-hadrons to the table!
306  # Note that we MUST write the primary first, followed by the compound particles
307  primaries = []
308  extras = []
309  for pid in masses:
310  if offset_options[abs(pid)][0]==0: extras += [pid]
311  elif not offset_options[abs(pid)][0] in primaries: primaries += [ offset_options[abs(pid)][0] ]
312 
313  # Rounds per primary
314  for p in primaries:
315  # Note that we follow the old convention of *including* fundamental SUSY particles
316  # The format is VERY specific; needs mass and width (we always set the width to 0)
317  # Mass is in MeV here, rather than GeV as in the dictionary
318  if p>0: out_file.write(' %i %04.3f # %s\n'%(p,masses[p],offset_options[abs(p)][2]))
319  # For the anti-particle, also need the anti-name
320  else: out_file.write(' %i %04.3f # %s\n'%(p,masses[p],anti_name(offset_options[abs(p)][2])))
321  # Now include the secondaries
322  for pid in masses:
323  if offset_options[abs(pid)][0]!=p: continue
324  # Note that we follow the old convention of *including* fundamental SUSY particles
325  # The format is VERY specific; needs mass and width (we always set the width to 0)
326  # Mass is in MeV here, rather than GeV as in the dictionary
327  if pid>0: out_file.write(' %i %04.3f # %s\n'%(pid,masses[pid],offset_options[abs(pid)][2]))
328  # For the anti-particle, also need the anti-name
329  else: out_file.write(' %i %04.3f # %s\n'%(pid,masses[pid],anti_name(offset_options[abs(pid)][2])))
330  # Done with secondaries for this primary
331 
332  for p in extras:
333  if p in primaries: continue
334  if p>0: out_file.write(' %i %04.3f # %s\n'%(p,masses[p],offset_options[abs(p)][2]))
335  # For the anti-particle, also need the anti-name
336  else: out_file.write(' %i %04.3f # %s\n'%(p,masses[p],anti_name(offset_options[abs(p)][2])))
337 
338  # Done writing all the lines! Clean up if necessary
339  if isinstance(particle_table, str):
340  out_file.close()
341 
342  # Nothing to return
343 
344 

◆ update_PDG_table()

def RHadronMasses.update_PDG_table (   input_file,
  pdg_table,
  mass_spectrum = 1 
)
Function to update a PDG table with R-hadron masses
    First input parameter: input file (string or file handle)
    Second input parameter: output PDG table (string or file handle)
    Third input parameter: mass spectrum (enumeration value)
    Gets R-hadron masses based on get_gluino_Rhadron_masses()

Definition at line 252 of file RHadronMasses.py.

252 def update_PDG_table(input_file, pdg_table, mass_spectrum=1):
253  """ Function to update a PDG table with R-hadron masses
254  First input parameter: input file (string or file handle)
255  Second input parameter: output PDG table (string or file handle)
256  Third input parameter: mass spectrum (enumeration value)
257  Gets R-hadron masses based on get_gluino_Rhadron_masses()
258  """
259  # Check that we had the right output file type
260  # Get the masses that we need
261  masses = get_gluino_Rhadron_masses(input_file,mass_spectrum)
262  # Get the output file ready
263  # Open for appending (assume that's what was done if given a file handle)
264  lines = None
265  if isinstance(pdg_table, str):
266  lines = open(pdg_table).readlines()
267  else:
268  lines = pdg_table.readlines()
269  # Add all our R-hadrons to the table!
270  pdgcodes = []
271  for pid in masses:
272  pdgcodes += [pid]
273  # For the PDG table, we only write positive-signed PDG ID particles
274  if pid<0: continue
275  # Note that we follow the Pythia6 convention of *including* fundamental SUSY particles
276  # The format is VERY specific; needs mass and width (we always set the width to 0)
277  # Mass is in MeV here, rather than GeV as in the dictionary
278  lines.append('M %i %11.7E +0.0E+00 -0.0E+00 %s %s'%(pid,masses[pid]*1000.,offset_options[pid][2],charge(offset_options[pid][3])) + '\n')
279  lines.append('W %i %11.7E +0.0E+00 -0.0E+00 %s %s'%(pid,0.E+00,offset_options[pid][2],charge(offset_options[pid][3])) + '\n')
280 
281  update = open('PDGTABLE.MeV', 'w')
282  update.write(''.join(lines))
283  update.close()
284 
285  from ExtraParticles.PDGHelpers import updateExtraParticleAcceptList
286  updateExtraParticleAcceptList('G4particle_acceptlist_ExtraParticles.txt', pdgcodes)
287  # Nothing to return
288 
289 

Variable Documentation

◆ first_mass_set

int RHadronMasses.first_mass_set = 4

Definition at line 28 of file RHadronMasses.py.

◆ gb_offset

dictionary RHadronMasses.gb_offset = offset_options[1009113][first_mass_set+5]-offset_options[1009113][first_mass_set+1]

Definition at line 124 of file RHadronMasses.py.

◆ offset_options

dictionary RHadronMasses.offset_options

Definition at line 29 of file RHadronMasses.py.

replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
PDGHelpers.updateExtraParticleAcceptList
def updateExtraParticleAcceptList(listName='G4particle_acceptlist_ExtraParticles.txt', pdgcodes=[])
Definition: PDGHelpers.py:57
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
RHadronMasses.update_particle_table
def update_particle_table(input_file, particle_table='particles.txt', mass_spectrum=1)
Definition: RHadronMasses.py:290
RHadronMasses.get_gluino_Rhadron_masses
def get_gluino_Rhadron_masses(input_file, mass_spectrum=1)
Definition: RHadronMasses.py:189
RHadronMasses.get_interaction_list
def get_interaction_list(input_file, interaction_file='ProcessList.txt', mass_spectrum=1)
Definition: RHadronMasses.py:366
RHadronMasses.anti_name
def anti_name(x)
Definition: RHadronMasses.py:175
RHadronMasses.is_baryon
def is_baryon(x)
Definition: RHadronMasses.py:160
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
RHadronMasses.get_quarks
def get_quarks(y)
Definition: RHadronMasses.py:148
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
charge
double charge(const T &p)
Definition: AtlasPID.h:501
Trk::open
@ open
Definition: BinningType.h:40
RHadronMasses.get_Pythia8_commands
def get_Pythia8_commands(input_file, mass_spectrum=1)
Definition: RHadronMasses.py:345
RHadronMasses.print_masses
def print_masses(spectrum=-1)
Definition: RHadronMasses.py:482
RHadronMasses.update_PDG_table
def update_PDG_table(input_file, pdg_table, mass_spectrum=1)
Definition: RHadronMasses.py:252
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38