packages feed

hepevt 0.2 → 0.3

raw patch · 2 files changed

+54/−7 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.HEPEVT: instance Eq Particle
+ Data.HEPEVT: instance Show Particle
- Data.HEPEVT: type Event = ([Double], [[Double]])
+ Data.HEPEVT: type Event = ([Double], [Particle])

Files

Data/HEPEVT.hs view
@@ -1,7 +1,10 @@ {-| -This modules provides a pure haskell implementation of a reader and writer for-the ASCII HEPEVT file format.+This module provides a pure haskell implementation of a reader and writer for+the ASCII HEPEVT file format, rougly as described at+http://cepa.fnal.gov/psm/simulation/mcgen/lund/pythia_manual/pythia6.3/pythia6301/node39.html.+Compatibility with the extended format used by HepMC+(http://lcgapp.cern.ch/project/simu/HepMC/) is given priority.  -} module Data.HEPEVT (@@ -13,13 +16,57 @@  import qualified Data.ByteString.Char8 as S -type Event = ([Double], [[Double]])+{-+int: barcode+int: PDG id+double: px+double: py+double: pz+double: energy+double: generated mass+int: status code+double: Polarization theta+double: Polarization phi+int: barcode for vertex that has this particle as an incoming particle+int: number of entries in flow list (may be zero)+int, int: optional code index and code for each entry in the flow list+-}+data Particle = Particle+  { barcode :: Int+  , pid     :: Int+  , px      :: Double+  , py      :: Double+  , pz      :: Double+  , energy  :: Double+  , mass    :: Double+  , stat    :: Int+  , ptheta  :: Double+  , pphi    :: Double+  }+  deriving (Eq, Show) +mkParticle :: [String] -> Particle+mkParticle (barcode:pid:px:py:pz:energy:mass:stat:ptheta:pphi:_) =+  Particle+    { barcode = read barcode+    , pid     = read pid+    , px      = parseDouble px+    , py      = parseDouble py+    , pz      = parseDouble pz+    , energy  = parseDouble energy+    , mass    = parseDouble mass+    , stat    = read stat+    , ptheta  = parseDouble ptheta+    , pphi    = parseDouble pphi+    }++type Event = ([Double], [Particle])+ parseEventFile :: String -> IO [Event] parseEventFile fname = do   S.readFile fname >>= return . parseEvents -data Line = Meta String | E [Double] | P [Double] | V [Double] | Blank+data Line = Meta String | E [Double] | P Particle | V [Double] | Blank   deriving (Show, Eq)  parseLine :: S.ByteString -> Line@@ -28,7 +75,7 @@     parseLine' (map S.unpack ws) line   where     parseLine' ("E":xs) _ = E $ map parseDouble xs-    parseLine' ("P":xs) _ = P $ map parseDouble xs+    parseLine' ("P":xs) _ = P $ mkParticle xs     parseLine' ("V":xs) _ = V $ map parseDouble xs     parseLine' _ line = if S.length line > 1 then Meta (S.unpack line) else Blank @@ -43,7 +90,7 @@     reverse $ foldl process [] $ getLines ls   where     process events (E ds) = (ds, []):events-    process ((el, vl):events) (V ds) = (el, ds:vl):events+    process ((el, pl):events) (P p) = (el, p:pl):events     process events _ = events  parseDouble :: String -> Double
hepevt.cabal view
@@ -7,7 +7,7 @@ -- 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.2+Version:             0.3  -- A short (one-line) description of the package. Synopsis:            HEPEVT parser and writer