ATLAS Offline Software
Loading...
Searching...
No Matches
RHadronMasses Namespace Reference

Functions

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

Variables

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

Detailed Description

The offset options.  Dictionary of PDG IDs with offsets.
Anti-particles by definition have the same mass as standard particles.
Columns are:
   PDG ID
   PDG ID of SUSY constituent
   Has an anti-particle (i.e. need to define a particle with an opposite-signed PDG ID)
   Name (for PDG table)
   Charge (for PDG table)

   Mass Offset in the Pythia6 simulation configuration
   8 mass options documented in the INT note of the stopped particle analysis:
   https://cds.cern.ch/record/2665511
   First 3 are the meson fits; 4th is the first specrum shifted to make the gluino R-glueball heaver
    than the lightest R-mesons, but with the same relative splitting otherwise.
   Second set of four follow the same pattern, but for the baryon fits.

The list of possible R-hadrons comes from the Pythia8 code, in src/RHadrons.cc (at the top)

Function Documentation

◆ anti_name()

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

Definition at line 174 of file RHadronMasses.py.

174def anti_name( x ):
175 """ Function to turn a particle name into an anti-particle name (mostly charge issues)
176 """
177 # These look a little funny to get both + and ++
178 if '*+' in x: return x.replace('*','bar*').replace('+','-')
179 if '*-' in x: return x.replace('*','bar*').replace('-','+')
180 if '++' in x: return x.replace('++','bar--')
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 '*0' in x: return x.replace('*0','bar*0')
185 return x.replace('0','bar0')
186
187
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ charge()

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 134 of file RHadronMasses.py.

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

◆ get_gluino_Rhadron_masses()

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 188 of file RHadronMasses.py.

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

◆ get_interaction_list()

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 365 of file RHadronMasses.py.

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

◆ get_Pythia8_commands()

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 344 of file RHadronMasses.py.

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

◆ get_quarks()

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

Definition at line 147 of file RHadronMasses.py.

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

◆ is_baryon()

RHadronMasses.is_baryon ( x)

Definition at line 159 of file RHadronMasses.py.

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

◆ print_masses()

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

Definition at line 481 of file RHadronMasses.py.

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

◆ update_particle_table()

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 289 of file RHadronMasses.py.

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

◆ update_PDG_table()

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 251 of file RHadronMasses.py.

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

Variable Documentation

◆ first_mass_set

int RHadronMasses.first_mass_set = 4

Definition at line 27 of file RHadronMasses.py.

◆ gb_offset

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

Definition at line 123 of file RHadronMasses.py.

◆ offset_options

dict RHadronMasses.offset_options

Definition at line 28 of file RHadronMasses.py.