def main(argv): parser = OptionParser() parser.add_option("-o", "--out", dest="outfile_name", default=None, help='Name of output file.') parser.add_option("-l", "--html", dest="html_labels", action="store_true", default=True, help="Use Dot 2.x's fancy HTML labels to render parameters in output.") parser.add_option("-n", "--no-html", dest="html_labels", action="store_false", help="Don't use Dot 2.x's fancy HTML labels to render parameters in output.") parser.add_option("--format", dest="output_format", default='png', help='File extension of the output format (must be one of the output formats supported by Dot).' + 'The filename will be corrected if necessary to include this extension.' + 'The default format is png.') (options, args) = parser.parse_args(argv) infile_name = args[1] g = graphphys.get_parser().parseFile(infile_name) converter = PydotVisualizer(options.html_labels) if options.outfile_name != None: converter.convert_to_file(g, options.outfile_name, options.output_format) else: diagram = converter.convert(g) print diagram.__getattribute__('create_' + options.output_format)()
def convert(self, obj): if isinstance(obj, DecayElement): return obj elif isinstance(obj, str): return graphphys.get_parser().parseString(obj) elif isinstance(obj, file): return graphphys.get_parser().parseFile(obj) # FIXME: should try importing, in case it hasn't been imported yet elif hasattr(PARTICLE_TYPE_IMPL.__module__, "converters") and hasattr( PARTICLE_TYPE_IMPL.__module__.converters, "PyDecayConverter" ): return PARTICLE_TYPE_IMPL.__module__.converters.PyDecayConverter().convert(obj) else: raise InvalidTypeError("Cannot convert %s object to %s" % (type(obj).__name__, self.output_type))
def main(argv): infile_name = argv[1] g = graphphys.get_parser().parseFile(infile_name) bad_decays = [] for root in g.root_particles: bad_decays += find_bad_decays(root) if len(bad_decays) == 0: print 'All decays specified are kinematically possible.' else: for decay in bad_decays: message = 'Impossible decay specified: %s ->' % decay.parent.type for p in decay.products: message = ' '.join([message, p.type]) print message
def main(argv): #### Command line variables #### parser = OptionParser() parser.add_option("--outfile", dest="outfile_name", default=None, help='Name of output file.') (options, args) = parser.parse_args() infile_name = args[0] g = graphphys.get_parser().parseFile(infile_name) if options.outfile_name != None: BtmTclConverter().convert_to_file(g, options.outfile_name) else: print BtmTclConverter().convert(g)
if __name__ == '__main__': ################################################################################ # Parse the command line options ################################################################################ input_file = sys.argv[1] max_events = int(sys.argv[2]) # print input_file # print max_events ################################################################################ # Read the input file ################################################################################ try: [root_particle] = graphphys.get_parser().parseFile( input_file ) except ValueError: # Occurs if there are too many list elements in the return value raise Exception('Multiple root nodes not allowed in a simulation') rnd = TRandom3() ################################################################################ # Walk the particle tree and check that the decays are all valid ################################################################################ get_end_masses = lambda products: array('d', [ get_mass(x) for x in products ]) # print get_end_masses # print get_mass(root_particle) initial_vector = TLorentzVector( 0.0, 0.0, 0.0, get_mass(root_particle) )