Skip to content

Commit

Permalink
use ScriptSetup and MGRunSetup for evchainGen parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
wavewave committed Feb 28, 2013
1 parent 658a5ec commit 6def004
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 33 deletions.
16 changes: 9 additions & 7 deletions lib/HEP/Automation/EventChain/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import HEP.Parser.LHEParser.Parser.Conduit
import HEP.Parser.LHEParser.Type
import HEP.Storage.WebDAV
import HEP.Automation.MadGraph.Model
import HEP.Automation.MadGraph.Model.ADMXUDD
-- import HEP.Automation.MadGraph.Model.ADMXUDD
import HEP.Automation.MadGraph.SetupType
--
import HEP.Automation.EventChain.LHEConn
import HEP.Automation.EventChain.FileDriver
Expand Down Expand Up @@ -86,20 +87,21 @@ getheader fp = do
-- |
evchainGen :: (Model model) =>
model
-> (FilePath,FilePath,FilePath)
-- -> (FilePath,FilePath,FilePath)
-> ScriptSetup
-> (String,String)
-> ModelParam model
-> ProcSpecMap
-> DCross
-> Int
-> MGRunSetup
-> IO ()
evchainGen mdl path (basename,procname) pset pmap cross n = do
evchainGen mdl path (basename,procname) pset pmap cross mgrs = do
let idxcross = (mkCrossIDIdx . mkDICross) cross
print idxcross
rm <- createProcessX
(generateX mdl path (basename,procname) pset pmap)
(generateD mdl path (basename,procname) pset pmap)
lheCntX lheCntD idxcross n
lheCntX lheCntD idxcross (mgrs_numevent mgrs)
let fp = fromJust (HM.lookup [] rm)
(_,fn) = splitFileName fp
(fb,_) = splitExtension fn
Expand All @@ -111,14 +113,14 @@ evchainGen mdl path (basename,procname) pset pmap cross n = do
lhev <- accumTotalEvent <$> matchFullCross idxcross
let output = lheFormatOutput lhev ++ endl
return (acc . (output++))
let lst = replicate n ()
let lst = replicate (mgrs_numevent mgrs) ()
let r = runState (runErrorT (foldM action id lst)) rm2
case fst r of
Left err -> putStrLn err
Right builder -> do
let builder' = ((C8.unpack bstr)++) . builder
(dir,file,wsetup) <-
combineX mdl path (basename,procname) pset n
combineX mdl path (basename,procname) pset (mgrs_numevent mgrs)
b <- doesDirectoryExist dir
when (not b) (createDirectory dir)
(LC8.writeFile (dir</>file) . GZ.compress . LC8.pack . builder') []
Expand Down
62 changes: 36 additions & 26 deletions lib/HEP/Automation/EventChain/Process/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import System.FilePath
import System.IO
-- from hep-platform packages
import HEP.Automation.MadGraph.Model
import HEP.Automation.MadGraph.Model.ADMXUDD
-- import HEP.Automation.MadGraph.Model.ADMXUDD
import HEP.Automation.MadGraph.Machine
import HEP.Automation.MadGraph.SetupType
import HEP.Automation.MadGraph.UserCut
Expand Down Expand Up @@ -128,31 +128,43 @@ runSetupPart pset n =

-- |
getWorkSetupPart :: model
-> (FilePath,FilePath,FilePath)
-- -> (FilePath,FilePath,FilePath)
-> ScriptSetup
-> ModelParam model
-> String
-> String
-> Int
-> IO (WorkSetup model)
getWorkSetupPart mdl (dir_sb,dir_mg5,dir_mc) pset str wname n =
WS <$> getScriptSetup dir_sb dir_mg5 dir_mc
-> WorkSetup model
getWorkSetupPart mdl ssetup pset str wname n =
WS ssetup
(processSetupPart mdl str wname)
(runSetupPart pset n)
(WebDAVRemoteDir "")

{- <$> getScriptSetup dir_sb dir_mg5 dir_mc
<*> pure (processSetupPart mdl str wname)
<*> pure (runSetupPart pset n)
<*> pure (WebDAVRemoteDir "")

<*> pure (WebDAVRemoteDir "") -}
-- |
getWorkSetupCombined :: model
-> (FilePath,FilePath,FilePath)
-- -> (FilePath,FilePath,FilePath)
-> ScriptSetup
-> ModelParam model
-> String -- ^ process name
-> String -- ^ directory name
-> Int
-> IO (WorkSetup model)
getWorkSetupCombined mdl (dir_sb,dir_mg5,dir_mc) pset str wname n =
WS <$> getScriptSetup dir_sb dir_mg5 dir_mc
-> WorkSetup model
getWorkSetupCombined mdl ssetup pset str wname n =
WS ssetup
(processSetupCombined mdl str wname)
(runSetupPart pset n)
(WebDAVRemoteDir "")

{- WS <$> getScriptSetup dir_sb dir_mg5 dir_mc
<*> pure (processSetupCombined mdl str wname)
<*> pure (runSetupPart pset n) -- for the time being
<*> pure (WebDAVRemoteDir "")
<*> pure (WebDAVRemoteDir "") -}



Expand Down Expand Up @@ -222,34 +234,34 @@ cnt1EvtD i decay (Counter incomingm outgoingm) ev@LHEvent {..} = do
-- |
generateX :: (Model model) =>
model
-> (FilePath,FilePath,FilePath) -- ^ directories
{- -> (FilePath,FilePath,FilePath) -- ^ directories -}
-> ScriptSetup
-> (String,String) -- ^ (base madgraph dir name, resultant process name)
-> ModelParam model -- ^ model parameters
-> ProcSpecMap -- ^
-> CrossID ProcSmplIdx
-> Int
-> IO FilePath
generateX mdl (dir_sb,dir_mg5,dir_mc) (basename,procname) pset pm MkC {..} n = do
generateX mdl ssetup (basename,procname) pset pm MkC {..} n = do
case HM.lookup Nothing pm of
Nothing -> fail "what? no root process in map?"
Just str -> do
let nwname = basename
print nwname
work =<< getWorkSetupPart mdl (dir_sb,dir_mg5,dir_mc) pset str nwname n
-- r <- work mdl (dir_sb,dir_mg5,dir_mc) pset str nwname n
-- return r
work (getWorkSetupPart mdl ssetup pset str nwname n)


-- | Single PDGID in dnode is assumed.
generateD :: (Model model) =>
model
-> (FilePath,FilePath,FilePath)
-> ScriptSetup
-> (String,String) -- ^ (base madgraph dir name, resultant process name)
-> ModelParam model -- ^ model parameter
-> ProcSpecMap
-> DecayID ProcSmplIdx
-> Int
-> IO FilePath
generateD mdl (dir_sb,dir_mg5,dir_mc) (basename,procname) pset pm MkD {..} n = do
generateD mdl ssetup (basename,procname) pset pm MkD {..} n = do
let psidx = (proc_procid . head . ptl_procs) dnode
pdgid' = (proc_pdgid . head . ptl_procs ) dnode
pmidx = mkPMIdx psidx pdgid'
Expand All @@ -258,23 +270,21 @@ generateD mdl (dir_sb,dir_mg5,dir_mc) (basename,procname) pset pm MkD {..} n = d
Just str -> do
let nwname = (((basename++"_") ++).show.md5.B.pack.(str ++).show) pmidx
print nwname
work =<< getWorkSetupPart mdl (dir_sb,dir_mg5,dir_mc) pset str nwname n
work (getWorkSetupPart mdl ssetup pset str nwname n)

-- r <- work mdl (dir_sb,dir_mg5,dir_mc) pset str nwname n
-- return r

combineX :: (Model model) =>
model
-> (FilePath,FilePath,FilePath) -- ^ directories
-> ScriptSetup
-> (String,String) -- ^ (base madgraph dir name, resultant process name)
-> ModelParam model -- ^ model parameters
-> Int
-> IO (FilePath,FilePath,WorkSetup model)
combineX mdl (dir_sb,dir_mg5,dir_mc) (basename,procname) pset n = do
combineX mdl ssetup (basename,procname) pset n = do
let nwname = basename
print nwname
wsetup <- getWorkSetupCombined
mdl (dir_sb,dir_mg5,dir_mc) pset procname basename n
let wsetup = getWorkSetupCombined
mdl ssetup pset procname basename n
r <- flip runReaderT wsetup . runErrorT $ do
WS _ psetup rsetup _ <- ask
let taskname = makeRunName psetup rsetup
Expand Down

0 comments on commit 6def004

Please sign in to comment.