Beispiel #1
0
    def _do_persistency(cls):
        """ Place to handle the persistency.
        """
        from G4AtlasApps.SimFlags import simFlags
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        if cls.will_write_output_files():
            ## Write hits in POOL
            AtlasG4Eng.G4Eng.log.verbose(
                'SimSkeleton._do_persistency :: starting')

            ## The following used to be in G4AtlasApps/HitAthenaPoolWriteOptions
            from AthenaCommon.DetFlags import DetFlags
            from AthenaCommon.Configurable import Configurable
            from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream

            ## Default setting for one output stream
            from AthenaCommon.AppMgr import ServiceMgr as svcMgr
            svcMgr.AthenaPoolCnvSvc.PoolAttributes += [
                "TREE_BRANCH_OFFSETTAB_LEN = '100'"
            ]
            # Recommendations from Peter vG 16.08.25
            svcMgr.AthenaPoolCnvSvc.PoolAttributes += [
                "DatabaseName = '" + athenaCommonFlags.PoolHitsOutput() +
                "'; ContainerName = 'TTree=CollectionTree'; TREE_AUTO_FLUSH = '1'"
            ]

            ## Write geometry tag info
            import EventInfoMgt.EventInfoMgtInit

            ## Instantiate StreamHITS
            if athenaCommonFlags.PoolHitsOutput.statusOn:
                cls.hits_persistency()

            ## StreamEVGEN: needed for cosmic simulations and cavern BG
            ## Separate stream of track record (TR) info -- it does not apply to the CTB simulations.
            # TODO: Can this be merged into the cosmics sec above, or do the AthenaPool includes *need* to be in-between?
            if "tb" not in simFlags.SimLayout.get_Value():
                cls.evgen_persistency()

            AtlasG4Eng.G4Eng.log.verbose('SimSkeleton._do_persistency :: done')
        else:
            AtlasG4Eng.G4Eng.log.info(
                'SimSkeleton._do_persistency :: nothing done')

        # Check on run numbers and update them if necessary
        cls.do_run_number_modifications()
Beispiel #2
0
    def hits_persistency():
        """ HITS POOL file persistency
        """
        from G4AtlasApps.SimFlags import simFlags
        from AthenaCommon.DetFlags import DetFlags
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream

        ## Not yet understood, but need to treat StreamHITS as alg in Hive.
        ## Seems to also work fine outside of Hive, but to be extra safe I'm
        ## only changing it in Hive.
        from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps
        if concurrencyProps.ConcurrencyFlags.NumThreads() > 0:
            as_alg = True
        else:
            as_alg = False
        ## NB. Two-arg constructor is needed, since otherwise metadata writing fails!
        stream1 = AthenaPoolOutputStream("StreamHITS",
                                         athenaCommonFlags.PoolHitsOutput(),
                                         asAlg=as_alg)

        ## Write geometry tag info - move to main method
        #import EventInfoMgt.EventInfoMgtInit

        ## EventInfo & TruthEvent always written by default
        stream1.ForceRead = True
        stream1.ItemList = [
            "EventInfo#*", "McEventCollection#TruthEvent", "JetCollection#*"
        ]

        ## If we are running quasi-stable particle simulation, include the original event record
        if hasattr(
                simFlags, 'IncludeParentsInG4Event'
        ) and simFlags.IncludeParentsInG4Event.statusOn and simFlags.IncludeParentsInG4Event(
        ):
            stream1.ItemList += ["McEventCollection#GEN_EVENT"]

        stream1.ItemList += ["xAOD::JetContainer#*", "xAOD::JetAuxContainer#*"]

        ## Make stream aware of aborted events
        stream1.AcceptAlgs = ["G4AtlasAlg"]

        ## Detectors

        ## Inner Detector
        if DetFlags.ID_on():
            stream1.ItemList += [
                "SiHitCollection#*", "TRTUncompressedHitCollection#*",
                "TrackRecordCollection#CaloEntryLayer"
            ]
        ## Calo
        if DetFlags.Calo_on():
            stream1.ItemList += [
                "CaloCalibrationHitContainer#*",
                "LArHitContainer#*",
                "TileHitVector#*",
                #"SimpleScintillatorHitCollection#*",
                "TrackRecordCollection#MuonEntryLayer"
            ]
        ## Muon
        if DetFlags.Muon_on():
            stream1.ItemList += [
                "RPCSimHitCollection#*", "TGCSimHitCollection#*",
                "CSCSimHitCollection#*", "MDTSimHitCollection#*",
                "TrackRecordCollection#MuonExitLayer"
            ]
            if hasattr(simFlags, 'SimulateNewSmallWheel'):
                if simFlags.SimulateNewSmallWheel():
                    stream1.ItemList += ["GenericMuonSimHitCollection#*"]
        ## Lucid
        if DetFlags.Lucid_on():
            stream1.ItemList += ["LUCID_SimHitCollection#*"]

        ## FwdRegion
        if DetFlags.FwdRegion_on():
            stream1.ItemList += ["SimulationHitCollection#*"]

        ## ZDC
        if DetFlags.ZDC_on():
            stream1.ItemList += [
                "ZDC_SimPixelHit_Collection#*", "ZDC_SimStripHit_Collection#*"
            ]
        ## ALFA
        if DetFlags.ALFA_on():
            stream1.ItemList += [
                "ALFA_HitCollection#*", "ALFA_ODHitCollection#*"
            ]

        ## AFP
        if DetFlags.AFP_on():
            stream1.ItemList += [
                "AFP_TDSimHitCollection#*", "AFP_SIDSimHitCollection#*"
            ]

        ### Ancillary scintillators
        #stream1.ItemList += ["ScintillatorHitCollection#*"]

        ## TimingAlg
        stream1.ItemList += ["RecoTimingObj#EVNTtoHITS_timings"]

        ## Add cosmics and test beam configuration hit persistency if required cf. geom tag
        layout = simFlags.SimLayout.get_Value()
        if "tb" not in layout:
            from AthenaCommon.BeamFlags import jobproperties
            if jobproperties.Beam.beamType() == 'cosmics' or \
                    (hasattr(simFlags, "WriteTR") and simFlags.WriteTR.statusOn) or \
                    (hasattr(simFlags, "ReadTR") and simFlags.ReadTR.statusOn):
                stream1.ItemList += [
                    "TrackRecordCollection#CosmicRecord",
                    "TrackRecordCollection#CosmicPerigee"
                ]
        else:
            ## CTB-specific
            if layout.startswith("ctb"):
                if simFlags.LArFarUpstreamMaterial.statusOn and simFlags.LArFarUpstreamMaterial.get_Value(
                ):
                    stream1.ItemList.append(
                        "TrackRecordCollection#LArFarUpstreamMaterialExitLayer"
                    )
            ## Persistency of test-beam layout
            if layout.startswith('ctb') or layout.startswith('tb_Tile2000_'):
                stream1.ItemList += ["TBElementContainer#*"]
Beispiel #3
0
    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
    if will_write_output_files():
        ## Write hits in POOL
        ## The following used to be in G4AtlasApps/HitAthenaPoolWriteOptions
        from AthenaCommon.DetFlags import DetFlags
        from AthenaCommon.Configurable import Configurable
        from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream

        ## Default setting for one output stream
        from AthenaCommon.AppMgr import ServiceMgr as svcMgr
        svcMgr.AthenaPoolCnvSvc.PoolAttributes += [
            "TREE_BRANCH_OFFSETTAB_LEN = '100'"
        ]
        # Recommendations from Peter vG 16.08.25
        svcMgr.AthenaPoolCnvSvc.PoolAttributes += [
            "DatabaseName = '" + athenaCommonFlags.PoolHitsOutput() +
            "'; ContainerName = 'TTree=CollectionTree'; TREE_AUTO_FLUSH = '1'"
        ]

        ## Write geometry tag info
        import EventInfoMgt.EventInfoMgtInit

        ## Patch metadata if required
        from G4AtlasApps.G4Atlas_Metadata import patch_mc_channel_numberMetadata
        patch_mc_channel_numberMetadata()

        ## Instantiate StreamHITS
        if athenaCommonFlags.PoolHitsOutput.statusOn:
            hits_persistency()

        ## StreamEVGEN: needed for cosmic simulations and cavern BG
Beispiel #4
0
class ISF_HITSStream:
    """
     Place to handle the persistency.
    """

    isfoplog.info("in ISF_HITSStream")

    from G4AtlasApps.SimFlags import simFlags
    from ISF_Config.ISF_jobProperties import ISF_Flags
    from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
    if athenaCommonFlags.PoolHitsOutput.statusOn or (hasattr(simFlags, "WriteTR") and simFlags.WriteTR.statusOn) or (hasattr(simFlags,'StoppedParticleFile') and simFlags.StoppedParticleFile.statusOn):
        ## Write hits in POOL
        isfoplog.info("ISF_HITSStream starting")

        ## The following used to be in G4AtlasApps/HitAthenaPoolWriteOptions
        from AthenaCommon.Configurable import Configurable
        from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream

        ## Default setting for one output stream
        from AthenaCommon.AppMgr import ServiceMgr
        ServiceMgr.AthenaPoolCnvSvc.PoolAttributes += ["TREE_BRANCH_OFFSETTAB_LEN = '100'"]
        ServiceMgr.AthenaPoolCnvSvc.PoolAttributes += ["DEFAULT_BUFFERSIZE = '2048'"]

        ## Write geometry tag info
        import EventInfoMgt.EventInfoMgtInit

        ## Patch metadata if required
        from ISF_Example.ISF_Metadata import patch_mc_channel_numberMetadata
        patch_mc_channel_numberMetadata()

        ## Instantiate StreamHITS
        ## NB. Two-arg constructor is needed, since otherwise metadata writing fails!
        stream1 = None
        if athenaCommonFlags.PoolHitsOutput.statusOn:
            stream1 = AthenaPoolOutputStream("StreamHITS", athenaCommonFlags.PoolHitsOutput())
            stream1.ForceRead = True
            stream1.ItemList = getHITSStreamItemList()
            ## Make stream aware of aborted events
            stream1.AcceptAlgs = [ISF_Flags.Simulator.KernelName()]

        ## StreamEVGEN: needed for cosmic simulations and cavern BG
        ## Separate stream of track record (TR) info -- it does not apply to the CTB simulations.
        # TODO: Can this be merged into the cosmics sec above, or do the AthenaPool includes *need* to be in-between?
        layout = simFlags.SimLayout.get_Value()
        if "tb" not in layout:
            if hasattr(simFlags, "WriteTR") and simFlags.WriteTR.statusOn or\
               hasattr(simFlags,'StoppedParticleFile') and simFlags.StoppedParticleFile.statusOn:
                streamName = simFlags.WriteTR.get_Value() if simFlags.WriteTR.statusOn else simFlags.StoppedParticleFile.get_Value()
                stream2 = AthenaPoolOutputStream("StreamEVGEN", streamName)
                stream2.ItemList = getEVNTStreamItemList()
                ## Make stream aware of aborted events
                stream2.AcceptAlgs = [ISF_Flags.Simulator.KernelName()]
        #
        #  Setup and add metadata to the HITS file.
        #  ( heavily based on G4AtlasApps/python/SimAtlasKernel.py )
        #
        #  causes problems with cosmics currently:
        #    "IOVDbSvc ERROR Duplicate request for folder /Simulation/Parameters associated to already"
        from AthenaServices.AthenaServicesConf import AthenaOutputStream
        stream1_SimMetaData = AthenaOutputStream("StreamHITS_SimMetaData")
        stream1_SimMetaData.ItemList += [ "IOVMetaDataContainer#*" ]

        isfoplog.info("ISF_HITSStream done")
    else:
        isfoplog.info("ISF_HITSStream nothing done")