analysis fpath = do
    liftIO $ putStrLn $ "analyzing " ++ fpath 
    bstr <- liftIO $ LB.readFile fpath
    let unzipped = decompress bstr
        unmergedevts = parsestr unzipped
        taumergedevts = map mkPhyEventNoTau unmergedevts
        -- totnum = length evts 
        -- evt = head mergedevts :: PhyEventNoTau
        --- evt' = mergeBJetFromNoTauEv evt
        fullmergedevts = map mergeBJetFromNoTauEv taumergedevts

        etarangeevts = map filterEtaRange fullmergedevts

        test = (,,) <$> checkj <*> checkl <*> checkj2
        pass1 x = view (_1._1) x
        pass2 x = pass1 x && view (_1._2) x
        pass3 x = pass1 x && pass2 x && view (_1._3) x
        pass4 x = pass1 x && pass2 x && pass3 x && view _2 x
        -- pass5 x = pass1 x && pass2 x && pass3 x && pass4 x && view (_3._1) x
        -- pass6 x = pass1 x && pass2 x && pass3 x && pass4 x && pass5 x && view (_3._2) x

        pass1evts = filter (pass1.test) etarangeevts -- fullmergedevts
        pass2evts = filter (pass2.test) etarangeevts -- fullmergedevts
        pass3evts = filter (pass3.test) etarangeevts -- fullmergedevts
        pass4evts = filter (pass4.test) etarangeevts -- fullmergedevts
        -- pass5evts = filter (pass5.test) etarangeevts -- fullmergedevts
        -- pass6evts = filter (pass6.test) etarangeevts -- fullmergedevts

        assoclist = map (\x -> (x, (length . filter (ptlcut x)) pass4evts)) [10,20..300] 
    -- liftIO $ print assoclist
    return (fpath, length fullmergedevts, length pass1evts, length pass2evts, length pass3evts, length pass4evts, assoclist)

    {- liftIO $ IO.hPutStrLn h 
      (fpath ++ ": " ++ show (length fullmergedevts, length pass1evts, length pass2evts, length pass3evts, length pass4evts)
                     ++ show assoclist
      ) -}

       -- show (length fullmergedevts, length pass1evts,length pass2evts,length pass3evts,length pass4evts,length pass5evts,length pass6evts)) 


-- countFiltered p lst = length (filter p lst)
analysis fpath = do
    liftIO $ putStrLn $ "analyzing " ++ fpath 
    bstr <- liftIO $ LB.readFile fpath
    let unzipped = decompress bstr
        unmergedevts = parsestr unzipped
        taumergedevts = map mkPhyEventNoTau unmergedevts
        -- totnum = length evts 
        -- evt = head mergedevts :: PhyEventNoTau
        --- evt' = mergeBJetFromNoTauEv evt
        fullmergedevts = map mergeBJetFromNoTauEv taumergedevts

        etarangeevts = map filterEtaRange fullmergedevts

        test = (,,) <$> checkj <*> checkl <*> checkj2
        pass1 x = view (_1._1) x
        pass2 x = pass1 x && view (_1._2) x
        pass3 x = pass1 x && pass2 x && view (_1._3) x
        pass4 x = pass1 x && pass2 x && pass3 x && view _2 x
        -- pass5 x = pass1 x && pass2 x && pass3 x && pass4 x && view (_3._1) x
        -- pass6 x = pass1 x && pass2 x && pass3 x && pass4 x && pass5 x && view (_3._2) x

        pass1evts = filter (pass1.test) etarangeevts -- fullmergedevts
        pass2evts = filter (pass2.test) etarangeevts -- fullmergedevts
        pass3evts = filter (pass3.test) etarangeevts -- fullmergedevts
        pass4evts = filter (pass4.test) etarangeevts -- fullmergedevts
        -- pass5evts = filter (pass5.test) etarangeevts -- fullmergedevts
        -- pass6evts = filter (pass6.test) etarangeevts -- fullmergedevts

        assoclist = map (\x -> (x, (length . filter (ptlcut x)) pass4evts)) [10,20..300] 
    -- liftIO $ print assoclist
    return (fpath, length fullmergedevts, length pass1evts, length pass2evts, length pass3evts, length pass4evts, assoclist)

    {- liftIO $ IO.hPutStrLn h 
      (fpath ++ ": " ++ show (length fullmergedevts, length pass1evts, length pass2evts, length pass3evts, length pass4evts)
                     ++ show assoclist
      ) -}

       -- show (length fullmergedevts, length pass1evts,length pass2evts,length pass3evts,length pass4evts,length pass5evts,length pass6evts)) 


-- countFiltered p lst = length (filter p lst)
analysis fpath = do
    liftIO $ putStrLn $ "analyzing " ++ fpath 
    bstr <- liftIO $ LB.readFile fpath
    let unzipped = decompress bstr
        unmergedevts = parsestr unzipped
        taumergedevts = map mkPhyEventNoTau unmergedevts
        -- totnum = length evts 
        -- evt = head mergedevts :: PhyEventNoTau
        --- evt' = mergeBJetFromNoTauEv evt
        fullmergedevts = map mergeBJetFromNoTauEv taumergedevts

        etarangeevts = map filterEtaRange fullmergedevts

        test = (,,) <$> checkj <*> checkl <*> checkj2
        pass1 x = view (_1._1) x
        pass2 x = pass1 x && view (_1._2) x
        pass3 x = pass1 x && pass2 x && view (_1._3) x
        pass4 x = pass1 x && pass2 x && pass3 x && view _2 x
        -- pass5 x = pass1 x && pass2 x && pass3 x && pass4 x && view (_3._1) x
        -- pass6 x = pass1 x && pass2 x && pass3 x && pass4 x && pass5 x && view (_3._2) x

        pass1evts = filter (pass1.test) etarangeevts -- fullmergedevts
        pass2evts = filter (pass2.test) etarangeevts -- fullmergedevts
        pass3evts = filter (pass3.test) etarangeevts -- fullmergedevts
        pass4evts = filter (pass4.test) etarangeevts -- fullmergedevts
        -- pass5evts = filter (pass5.test) etarangeevts -- fullmergedevts
        -- pass6evts = filter (pass6.test) etarangeevts -- fullmergedevts

        assoclist = map (\x -> (x, (length . filter (ptlcut x)) pass4evts)) [10,20..300] 
    -- liftIO $ print assoclist
    return (fpath, length fullmergedevts, length pass1evts, length pass2evts, length pass3evts, length pass4evts, assoclist)

    {- liftIO $ IO.hPutStrLn h 
      (fpath ++ ": " ++ show (length fullmergedevts, length pass1evts, length pass2evts, length pass3evts, length pass4evts)
                     ++ show assoclist
      ) -}

       -- show (length fullmergedevts, length pass1evts,length pass2evts,length pass3evts,length pass4evts,length pass5evts,length pass6evts)) 


-- countFiltered p lst = length (filter p lst)