lhe 0.3 → 0.4
raw patch · 3 files changed
+39/−62 lines, 3 filesdep +lhaPVP ok
version bump matches the API change (PVP)
Dependencies added: lha
API changes (from Hackage documentation)
- Data.LHE: Event :: [Double] -> [[Double]] -> Event
- Data.LHE: RawEvent :: [Double] -> [[Double]] -> RawEvent
- Data.LHE: data Event
- Data.LHE: data RawEvent
- Data.LHE: instance Eq Event
- Data.LHE: instance Eq Init
- Data.LHE: instance Read Event
- Data.LHE: instance Read Init
- Data.LHE: instance Read RawEvent
- Data.LHE: instance Show Event
- Data.LHE: instance Show Init
- Data.LHE: parseRawEventFile :: String -> IO [RawEvent]
- Data.LHE: parseRawEvents :: String -> ByteString -> [RawEvent]
Files
- Data/LHE.hs +34/−18
- LICENSE +1/−1
- lhe.cabal +4/−43
Data/LHE.hs view
@@ -1,34 +1,24 @@ {-| This module provides a pure haskell implementation of a parser and writer for-the Les-Houches event file format. (Note that the writer doesn't actually exist-yet.)+the Les-Houches event file format, as described in hep-ph/0609017. (Note that+the writer doesn't actually exist yet.) -} module Data.LHE ( parseEventFile, parseEvents,-- parseRawEventFile,- parseRawEvents,-- Event(..),- RawEvent(..), ) where import qualified Data.ByteString.Char8 as S -import Text.XML.HaXml.Parse (xmlParse)+import Text.XML.HaXml.ParseLazy (xmlParse) import Text.XML.HaXml.Types (Document(..), Element(..), Content(..), QName(..)) -data Init = Init- deriving (Eq, Show, Read)--data Event = Event [Double] [[Double]]- deriving (Eq, Show, Read)+import Data.LHA -data RawEvent = RawEvent [Double] [[Double]]- deriving (Eq, Show, Read)+data RawEvent = RawEvent [String] [[String]]+ deriving (Eq, Show) parseEventFile :: String -> IO [Event] parseEventFile fname = do@@ -37,8 +27,34 @@ parseEvents :: String -> S.ByteString -> [Event] parseEvents fname dat = let re = parseRawEvents fname dat in- []+ map makeEvent re +makeEvent :: RawEvent -> Event+makeEvent (RawEvent (n:idpr:xwgt:scal:aqed:aqcd:[]) rps) = Event+ { nPart = read n+ , evProcId = read idpr+ , evWeight = parseDouble xwgt+ , scale = parseDouble scal+ , aQED = parseDouble aqed+ , aQCD = parseDouble aqcd+ , parts = map makeParticle rps+ }++makeParticle :: [String] -> Particle+makeParticle (pdg:stat:m1:m2:c1:c2:px:py:pz:e:m:lt:spin:[]) = Particle+ { partPDG = read pdg+ , status = statusFromInt $ read stat+ , mothers = PBoth (read m1, read m2)+ , iColor = (read c1, read c2)+ , partPx = parseDouble px+ , partPy = parseDouble py+ , partPz = parseDouble pz+ , partE = parseDouble e+ , partM = parseDouble m+ , lifetime = parseDouble lt+ , spin = parseDouble spin+ }+ parseRawEventFile :: String -> IO [RawEvent] parseRawEventFile fname = do S.readFile fname >>= return . parseRawEvents fname@@ -52,7 +68,7 @@ isEvent _ = False isCString (CString _ _ _) = True isCString _ = False- parseLine = map parseDouble . words+ parseLine = words getElem (CElem (Elem _ _ c) _) = head $ filter isCString c getRawEvent (CString _ eStr _) = let eLines = filter (\x -> length x > 2) $ lines eStr in
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2011 Scott Lawrence <bytbox@gmail.com>+Copyright (c) 2011, 2012 Scott Lawrence <bytbox@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
lhe.cabal view
@@ -1,59 +1,20 @@--- LHE.cabal auto-generated by cabal init. For additional options, see--- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.--- The name of the package. Name: lhe---- The package version. See the Haskell package versioning policy--- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for--- standards guiding when and how versions should be incremented.-Version: 0.3---- A short (one-line) description of the package.+Version: 0.4 Synopsis: Parser and writer for Les-Houches event files---- A longer description of the package. Description: This package implements a parser and writer for the Les-Houches event file format as described in hep-ph/0609017---- The license under which the package is released. License: MIT---- The file containing the license text. License-file: LICENSE---- The package author(s). Author: Scott Lawrence---- An email address to which users can send suggestions, bug reports,--- and patches. Maintainer: bytbox@gmail.com---- A copyright notice.--- Copyright: - Category: Data, Physics- Build-type: Simple---- Extra files to be distributed with the package, such as examples or--- a README.--- Extra-source-files: ---- Constraint on the version of Cabal needed to build this package.-Cabal-version: >=1.6-+Cabal-version: >=1.10 Library- -- Modules exported by the library. Exposed-modules: Data.LHE- - -- Packages needed in order to build this package.- Build-depends: haskell2010 >= 1.0 , HaXml >= 1.22, bytestring >= 0.9- - -- Modules not exported by this package.+ Default-language: Haskell2010+ Build-depends: haskell2010 >= 1.0 , HaXml >= 1.22, bytestring >= 0.9, lha >= 0.1.2 -- Other-modules: - - -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.- -- Build-tools: source-repository head type: git