コード例 #1
0
    def addGroup(self, group):

        from Gaugi import ToolSvc
        emulator = ToolSvc.retrieve("Emulator")
        if not emulator.isValid(group.chain().name()):
            emulator += group.chain()
        self.__groups.append(group)
コード例 #2
0
def configure(l1item):

    # Get the emulator tool
    from Gaugi import ToolSvc
    emulator = ToolSvc.retrieve("Emulator")

    name = 'Hypo__' + l1item

    # Check if this hypo is in cache
    if not emulator.isValid(name):
        # We need to create the hypo tool

        # L1 configuration parameters
        hypo = TrigEgammaL1CaloHypoTool(
            name,
            WPNames=['Tight', 'Medium', 'Loose'
                     ],  # must be: ["T","M","L"] (Tight,Medium and Loose)
            HadCoreCutMin=[
                1.0, 1.0, 1.0, 1.0
            ],  # must be a list with for values: (default,tight,medium and loose)
            HadCoreCutOff=[-0.2, -0, 2, -0.2, -0.2],
            HadCoreSlope=[1 / 23., 1 / 23., 1 / 23., 1 / 23.],
            EmIsolCutMin=[2.0, 1.0, 1.0, 1.5],
            EmIsolCutOff=[-1.8, -2.6, -2.0, -1.8],
            EmIsolSlope=[1 / 8., 1 / 8., 1 / 8., 1 / 8.],
            IsolCutMax=50,
            L1Item=l1item)

        emulator += hypo

    return name
コード例 #3
0
def attach( hypos ):
  from Gaugi import ToolSvc
  emulator = ToolSvc.retrieve( "Emulator" )
  names = []
  for hypo in hypos:
    names.append( hypo.name() )
    if not emulator.isValid( hypo.name() ):
      emulator+=hypo
  return names
コード例 #4
0
ファイル: Menu.py プロジェクト: ringer-atlas/prometheus
    def accept(self, key):

        # is in cache?
        if key in self.decorations():
            # decision in cache
            return self.getDecor(key)

        # get the accept decision from the TDT metadata
        elif (self._dataframe is DataframeEnum.Electron_v1
              or DataframeEnum.Photon_v1) and key.startswith('TDT__'):

            #  TDT__HLT__e28_lhtight_nod0_ivarloose
            #  TDT__EFCalo__e28_lhtight_nod0_ivarloose
            tdt = self.getContext().getHandler("HLT__TDT")
            trigInfo = key.split('__')
            tdt.core(DecisionCore.TriggerDecisionTool)  # athena core
            # TDT__AcceptType__trigItem
            passed = tdt.ancestorPassed('HLT_' + trigInfo[-1],
                                        AcceptType.fromstring(trigInfo[1]))
            accept = Accept(key)
            accept.setCutResult('pass', passed)
            self.setDecor(key, accept)
            return accept
        # get the accept decision from the Emulation metadata
        elif (self._dataframe is DataframeEnum.Electron_v1
              or DataframeEnum.Photon_v1) and key.startswith('EMU__'):
            #  EMU__HLT__e28_lhtight_nod0_ivarloose

            tdt = self.getContext().getHandler("HLT__TDT")
            trigInfo = key.split('__')
            tdt.core(DecisionCore.TrigEgammaEmulationTool
                     )  # athena emulation e/g core
            # EMU__AcceptType__trigItem
            passed = tdt.ancestorPassed('HLT_' + trigInfo[-1],
                                        AcceptType.fromstring(trigInfo[1]))
            accept = Accept(key)
            accept.setCutResult('pass', passed)
            self.setDecor(key, accept)
            return accept

        # This name is not in metadata and not in cache, let's access the emulation svc and run it!
        else:
            emulator = ToolSvc.retrieve("Emulator")

            if emulator.isValid(key):
                accept = emulator.accept(self.getContext(), key)
                self.setDecor(key, accept)
                return accept
            else:
                MSG_FATAL(self,
                          "It's is not possble to interpreter the key: %s.",
                          key)
コード例 #5
0
def configure( trigger ):

  from TrigEgammaEmulationTool import TriggerInfo
  info = TriggerInfo( trigger )
  etthr = info.etthr()

  from Gaugi import ToolSvc
  emulator = ToolSvc.retrieve("Emulator")
  pidname = info.pidname()
  name = 'Hypo__HLT__' + info.signature()[0]+str(int(etthr)) + '_' + info.pidname()

  if not emulator.isValid(name):
    hypo  = TrigEgammaElectronHypoTool(name, Branch = 'trig_EF_el_'+info.pidname() )
    emulator+=hypo

  return name
コード例 #6
0
def configure( trigger ):

  from TrigEgammaEmulationTool import TriggerInfo
  info = TriggerInfo( trigger )
  etthr = info.etthr()

  from Gaugi import ToolSvc
  emulator = ToolSvc.retrieve("Emulator")

  name = 'Hypo__L2Photon__' + info.signature()[0]+str(int(etthr)) + '_' + info.pidname()

  if not emulator.isValid(name):

    hypo = TrigEgammaL2PhotonHypoTool(name, EtCut = (etthr - 3)*GeV)
    emulator+=hypo

  return name
コード例 #7
0
def configure( trigger ):

  from TrigEgammaEmulationTool import TriggerInfo
  info = TriggerInfo( trigger )
  etthr = info.etthr()

  from Gaugi import ToolSvc
  emulator = ToolSvc.retrieve("Emulator")
  
  name = 'Hypo__HLT__' + info.signature()[0]+str(int(etthr)) + '_' + info.isolationType()


  # Taken from: https://gitlab.cern.ch/atlas/athena/-/blob/master/Trigger/TrigHypothesis/TrigEgammaHypo/python/TrigEFElectronHypoConfig.py
  isolation_dict = {
                    'ivarloose'   : [-1, -1, -1,0.100,-1,-1],
                    'ivarmedium'  : [-1, -1, -1,0.065,-1,-1],
                    'ivartight'   : [-1, -1, -1,0.05,-1,-1],
                    'iloose'      : [0.100, -1, -1,-1,-1,-1],
                   }
  
  caloisolation_dict = {
                        'icaloloose'  : [-1, -1, -1,0.2,-1,-1],
                        'icalomedium' : [-1, -1, -1,0.15,-1,-1],
                        'icalotight'  : [-1, -1, -1,0.1,-1,-1],
                       }


  pidname = info.isolationType()
  relEtConeCuts = caloisolation_dict[pidname] if 'icalo' in pidname else [-1, -1, -1,-1, -1, -1]
  relPtConeCuts = isolation_dict[pidname] if not 'icalo' in pidname else [-1, -1, -1,-1, -1, -1]

  if not emulator.isValid(name):
    hypo  = TrigEgammaElectronIsolationHypoTool(name,
                                                UseClusETforCaloIso   = True,
                                                UseClusETforTrackIso  = True,
                                                PtConeCut             = [-1, -1, -1,-1,-1,-1],
                                                EtConeCut             = [-1, -1, -1,-1, -1, -1],
                                                RelPtConeCut          = relPtConeCuts,
                                                RelEtConeCut          = relEtConeCuts,
                                                )
    emulator+=hypo

  return name
コード例 #8
0
def configure(trigger):

    from TrigEgammaEmulationTool import TriggerInfo
    info = TriggerInfo(trigger)
    etthr = info.etthr()

    from Gaugi import ToolSvc
    emulator = ToolSvc.retrieve("Emulator")
    pidname = info.pidname()
    name = 'Hypo__L2Calo__' + info.signature()[0] + str(
        int(etthr)) + '_' + info.pidname()

    if not emulator.isValid(name):

        def same(value):
            return [value] * 9

        if info.signature() == 'electron':
            from .TrigEgammaL2CaloHypoCuts import L2CaloCutMaps
            cuts = L2CaloCutMaps(etthr)
        elif info.signature() == 'photon':
            from .TrigEgammaL2CaloHypoCuts import L2CaloPhotonCutMaps
            cuts = L2CaloPhotonCutMaps(etthr)
        hypo = TrigEgammaL2CaloHypoTool(
            name,
            dETACLUSTERthr=0.1,
            dPHICLUSTERthr=0.1,
            EtaBins=[0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47],
            F1thr=same(0.005),
            ETthr=same(0),
            ET2thr=same(90.0 * GeV),
            HADET2thr=same(999.0),
            WETA2thr=same(99999.),
            WSTOTthr=same(99999.),
            F3thr=same(99999.),
            HADETthr=cuts.MapsHADETthr[pidname],
            CARCOREthr=cuts.MapsCARCOREthr[pidname],
            CAERATIOthr=cuts.MapsCAERATIOthr[pidname],
        )
        emulator += hypo

    return name
コード例 #9
0
def configure(trigger):

    from TrigEgammaEmulationTool import TriggerInfo
    info = TriggerInfo(trigger)
    etthr = info.etthr()

    from Gaugi import ToolSvc
    emulator = ToolSvc.retrieve("Emulator")

    name = 'Hypo__L2Electron__' + info.signature()[0] + str(
        int(etthr)) + '_' + info.pidname()

    if not emulator.isValid(name):

        hypo = TrigEgammaL2ElectronHypoTool(name,
                                            EtCut=(etthr - 3) * GeV,
                                            TrackPt=1 * GeV,
                                            CaloTrackdETA=0.2,
                                            CaloTrackdPHI=0.3,
                                            CaloTrackdEoverPLow=0,
                                            CaloTrackdEoverPHigh=999,
                                            TRTRatio=-999)

        if etthr < 15:
            hypo.TrackPt = 1 * GeV
        elif etthr >= 15 and etthr < 20:
            hypo.TrackPt = 2 * GeV
        elif etthr >= 20 and etthr < 50:
            hypo.TrackPt = 3 * GeV
        else:
            hypo.TrackPt = 5 * GeV
            hypo.CaloTrackdETA = 999
            hypo.CaloTrackdPHI = 999

        emulator += hypo

    return name
コード例 #10
0
ファイル: Menu.py プロジェクト: ringer-atlas/prometheus
    def initialize(self):

        if not ToolSvc.retrieve("Emulator"):
            MSG_FATAL(self, "The emulator tool is not in the ToolSvc")

        return StatusCode.SUCCESS
コード例 #11
0
    def initialize(self):

        self.__signature = self.__trigInfo.signature()

        # Configure the L2Calo hypo step
        from TrigEgammaEmulationTool.TrigEgammaL1CaloHypoTool import configure
        self.__l1caloItem = configure(self.__l1item)

        if self.__trigInfo.signature() == 'electron':

            # Configure L2Calo step
            if self.__trigInfo.ringer():
                if self.__trigInfo.etthr() > 15:  #GeV
                    from TrigEgammaEmulationTool import installElectronRingerZeeFromVersion as configure
                else:
                    from TrigEgammaEmulationTool import installElectronRingerJpsieeFromVersion as configure
                version = self.__trigInfo.ringerVersion()
                names = configure(version)
                # define like tight, medium, loose and vloose
                self.__l2caloItem = names[self.__trigInfo.pidnameIdx()]

                version = self.__trigInfo.ringerVersion("fast_el")
                if version is not None:
                    names = configure(version, step="fast_el")
                    self.__l2Item = names[self.__trigInfo.pidnameIdx()]
                else:
                    from TrigEgammaEmulationTool.TrigEgammaL2ElectronHypoTool import configure
                    self.__l2Item = configure(self.__trigger)

            else:
                # Configure the L2Calo hypo step
                from TrigEgammaEmulationTool.TrigEgammaL2CaloHypoTool import configure
                self.__l2caloItem = configure(self.__trigger)

                # Configure the L2 hypo step
                from TrigEgammaEmulationTool.TrigEgammaL2ElectronHypoTool import configure
                self.__l2Item = configure(self.__trigger)

            # Configure the HLT hypo step
            from TrigEgammaEmulationTool.TrigEgammaElectronHypoTool import configure
            self.__hltItem = configure(self.__trigger)

            if self.__trigInfo.isolated():
                self.__applyIsolation = True
                from TrigEgammaEmulationTool.TrigEgammaElectronIsolationHypoTool import configure
                self.__hltIsoItem = configure(self.__trigger)
            else:
                self.__applyIsolation = False

        elif self.__trigInfo.signature() == 'photon':

            # Configure L2Calo step
            if self.__trigInfo.ringer():
                from TrigEgammaEmulationTool import installPhotonRingerZradFromVersion as configure
                version = self.__trigInfo.ringerVersion()
                names = configure(version)
                # define like tight, medium, loose and vloose
                self.__l2caloItem = names[self.__trigInfo.pidnameIdx()]

            else:
                # Configure the L2Calo hypo step
                from TrigEgammaEmulationTool.TrigEgammaL2CaloHypoTool import configure
                self.__l2caloItem = configure(self.__trigger)

            # Configure the EFCalo hypo step
            from TrigEgammaEmulationTool.TrigEgammaL2PhotonHypoTool import configure
            self.__l2Item = configure(self.__trigger)

            # Configure the HLT hypo step
            from TrigEgammaEmulationTool.TrigEgammaPhotonHypoTool import configure
            self.__hltItem = configure(self.__trigger)

            if self.__trigInfo.isolated():
                self.__applyIsolation = True
                from TrigEgammaEmulationTool.TrigEgammaPhotonIsolationHypoTool import configure
                self.__hltIsoItem = configure(self.__trigger)
            else:
                self.__applyIsolation = False

        else:
            MSG_FATAL(self, "Signature not found")

        # configure et cuts
        self.__l2caloEtCut = (self.__trigInfo.etthr() - 3) * GeV
        self.__efcaloEtCut = (self.__trigInfo.etthr()) * GeV
        self.__hltEtCut = (self.__trigInfo.etthr()) * GeV

        from Gaugi import ToolSvc
        emulator = ToolSvc.retrieve("Emulator")
        if emulator.retrieve(self.__l1caloItem).initialize().isFailure():
            MSG_FATAL(self,
                      "It's not possible to initialize the tool with name %s",
                      self.__l1caloItem)
        if emulator.retrieve(self.__l2caloItem).initialize().isFailure():
            MSG_FATAL(self,
                      "It's not possible to initialize the tool with name %s",
                      self.__l2caloItem)
        if emulator.retrieve(self.__l2Item).initialize().isFailure():
            MSG_FATAL(self,
                      "It's not possible to initialize the tool with name %s",
                      self.__l2Item)
        if emulator.retrieve(self.__hltItem).initialize().isFailure():
            MSG_FATAL(self,
                      "It's not possible to initialize the tool with name %s",
                      self.__hltItem)

        if self.__applyIsolation:
            if emulator.retrieve(self.__hltIsoItem).initialize().isFailure():
                MSG_FATAL(
                    self,
                    "It's not possible to initialize the tool with name %s",
                    self.__hltItem)

        # Print chain info steps
        MSG_INFO(self, "")
        MSG_INFO(self, "+ Chain with name   : %s", self.name())
        MSG_INFO(self, "|--> L1Calo       : %s", self.__l1caloItem)
        MSG_INFO(self, "|--> L2Calo EtCut : %d", self.__l2caloEtCut)
        MSG_INFO(self, "|--> L2Calo       : %s", self.__l2caloItem)
        MSG_INFO(self, "|--> L2           : %s", self.__l2Item)
        MSG_INFO(self, "|--> EFCalo EtCut : %d", self.__efcaloEtCut)
        MSG_INFO(self, "|--> HLT EtCut    : %d", self.__hltEtCut)
        MSG_INFO(self, "|--> HLT          : %s", self.__hltItem)
        if self.__applyIsolation:
            MSG_INFO(self, "|--> HLTIso       : %s", self.__hltIsoItem)

        self.init_lock()
        return StatusCode.SUCCESS
コード例 #12
0
    def initialize(self):

        MSG_INFO(self, 'Initializing EventSimulator...')

        if super(EventReader, self).initialize().isFailure():
            MSG_FATAL(self,
                      "Impossible to initialize the TEventLoop services.")

        # RingerPhysVal hold the address of required branches
        if self._dataframe is DataframeEnum.Lorenzetti_v1:
            #self._t.SetBranchStatus("*", False)
            from CaloCell import CaloCellCollection
            from CaloRings import CaloRings
            from CaloCluster import CaloCluster
            from EventInfo import EventInfo
            from GaugiKernel.schema import Lorenzetti_v1
            self._event = Lorenzetti_v1()
            self._t.GetEntry(0)
        else:
            return StatusCode.FATAL

        MSG_INFO(self, "Creating containers...")

        self._containersSvc['EventInfoContainer'] = EventInfo()
        self._containersSvc['CaloCellsContainer'] = CaloCellCollection()
        self._containersSvc['CaloRingsContainer'] = CaloRings()
        self._containersSvc['CaloClusterContainer'] = CaloCluster()

        # configure all EDMs needed
        for key, edm in self._containersSvc.items():

            # attach the EDM pointer into the context list
            self.getContext().setHandler(key, edm)
            # add properties
            edm.dataframe = self._dataframe
            edm.tree = self._t
            edm.level = self._level
            edm.event = self._event
            edm.setContext(self.getContext())
            # If initializations is failed, we must remove this from the container
            # service
            if (edm.initialize().isFailure()):
                MSG_WARNING(self, 'Impossible to create the EDM: %s', key)

        self.getContext().initialize()

        MSG_INFO(self, 'Initializing all tools...')
        from Gaugi import ToolSvc as toolSvc
        self._alg_tools = toolSvc.getTools()
        for alg in self._alg_tools:
            if alg.status is StatusTool.DISABLE:
                continue
            # Retrieve all services
            alg.level = self._level
            alg.setContext(self.getContext())
            alg.setStoreGateSvc(self.getStoreGateSvc())
            alg.dataframe = self._dataframe
            if alg.isInitialized():
                continue
            if alg.initialize().isFailure():
                MSG_FATAL(self, "Impossible to initialize the tool name: %s",
                          alg.name)

        return StatusCode.SUCCESS
コード例 #13
0
    #pidname = 'MediumLLH_DataDriven_Rel21_Run2_2018'
    pidname = 'ph_tight'

evt.setCutValue(SelectionType.SelectionPID, pidname)
evt.setCutValue(EtCutType.L2CaloAbove, 15)
ToolSvc += evt

from TrigEgammaEmulationTool import Chain

triggerList = [
    Chain("EMU_g10_tight_noringer", "L1_EM3", "HLT_g10_tight_noringer"),
    Chain("EMU_g10_tight_ringer_v1", "L1_EM3", "HLT_g10_tight_ringer_v1"),
]

# Add all chains into the emulator
emulator = ToolSvc.retrieve("Emulator")
for chain in triggerList:
    print(chain.name())
    if not emulator.isValid(chain.name()):
        emulator += chain

from QuadrantTools import QuadrantTool
alg = QuadrantTool("Quadrant")
alg.add_quadrant(
    'HLT_g10_tight_noringer',
    "EMU_g10_tight_noringer",  # T2Calo
    'HLT_g10_tight_ringer_v1',
    "EMU_g10_tight_ringer_v1")  # Ringer v1

etlist = [15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 50000.0]
etalist = [0.0, 0.6, 0.8, 1.15, 1.37, 1.52, 1.81, 2.01, 2.37, 2.47]
コード例 #14
0
ファイル: EventATLAS.py プロジェクト: jlieberm/prometheus
    def initialize(self):

        MSG_INFO(self, 'Initializing EventATLAS...')
        if super(EventATLAS, self).initialize().isFailure():
            MSG_FATAL(self,
                      "Impossible to initialize the TEventLoop services.")

        if self._dataframe is DataframeEnum.Electron_v1:
            from EventAtlas import Electron_v1
            self._event = Electron_v1()
        elif self._dataframe is DataframeEnum.ElectronForward_v1:
            from EventAtlas import ElectronForward_v1
            self._event = ElectronForward_v1()
        elif self._dataframe is DataframeEnum.Photon_v1:
            from EventAtlas import Photon_v1
            self._event = Photon_v1()
        else:
            return StatusCode.FATAL

        MSG_INFO(self, "Creating containers...")
        # Allocating containers
        from EventAtlas import Electron
        from EventAtlas import ElectronForward
        from EventAtlas import Photon
        from EventAtlas import TrigEMCluster
        from EventAtlas import TrigElectron
        from EventAtlas import CaloCluster
        from EventAtlas import TrackParticle
        from EventAtlas import EmTauRoI
        from EventAtlas import EventInfo
        from EventAtlas import MonteCarlo
        from EventAtlas import TDT
        from EventAtlas import Menu

        # Initialize the base of this container.
        # Do not change this key names!
        self._containersSvc = {
            # event dataframe containers
            'EventInfoContainer': EventInfo(),
            'MonteCarloContainer': MonteCarlo(),
            'CaloClusterContainer': CaloCluster(),
            'MenuContainer': Menu(),
        }

        if self._dataframe is DataframeEnum.Electron_v1:
            self._containersSvc.update({
                'ElectronContainer':
                Electron(),
                'TrackParticleContainer':
                TrackParticle(),
                'HLT__TrigElectronContainer':
                TrigElectron(),
                'HLT__ElectronContainer':
                Electron(),
                'HLT__TrackParticleContainer':
                TrackParticle(),
            })
            self._containersSvc.update({
                'HLT__TrigEMClusterContainer':
                TrigEMCluster(),
                'HLT__CaloClusterContainer':
                CaloCluster(),
                'HLT__EmTauRoIContainer':
                EmTauRoI(),
            })
        elif self._dataframe is DataframeEnum.ElectronForward_v1:
            self._containersSvc.update(
                {'ElectronForwardContainer': ElectronForward()})
        elif self._dataframe is DataframeEnum.Photon_v1:
            self._containersSvc.update({
                'PhotonContainer': Photon(),
                'HLT__PhotonContainer': Photon(),
            })
            self._containersSvc.update({
                'HLT__TrigEMClusterContainer':
                TrigEMCluster(),
                'HLT__CaloClusterContainer':
                CaloCluster(),
                'HLT__EmTauRoIContainer':
                EmTauRoI(),
            })
        else:
            return StatusCode.FATAL

        if self._dataframe is DataframeEnum.Electron_v1 or DataframeEnum.Photon_v1:
            self._containersSvc.update({
                # metadata containers
                'HLT__TDT': TDT(),
            })

        # force the event id number for this event looper
        #self._containersSvc['EventInfoContainer'].setId( self.id() )
        # Add decoration for ATLAS event information
        self._containersSvc['EventInfoContainer'].setDecor(
            "is_fakes", True if 'fakes' in self._treePath else False)

        # configure all EDMs needed
        for key, edm in self._containersSvc.items():
            self.getContext().setHandler(key, edm)
            # add properties
            edm.dataframe = self._dataframe
            edm.tree = self._t
            edm.level = self._level
            edm.event = self._event
            edm.setContext(self.getContext())

            # enable hlt property by the container key name
            if 'HLT' in key:
                edm.is_hlt = True

            # set basepath into the root file
            if edm.useMetadataParams():
                edm.setMetadataParams({
                    'basepath':
                    self._metadataInputFile[1].rsplit('/', 1)[0],
                    'file':
                    self._metadataInputFile[0]
                })  # remove the last name after '/' (tree name)
            # If initializations is failed, we must remove this from the container
            # service
            MSG_INFO(self, "Initialize the dataframe with name: %s", key)
            if (edm.initialize().isFailure()):
                MSG_WARNING(self, 'Impossible to create the EDM: %s', key)

        self.getContext().initialize()

        MSG_INFO(self, 'Initializing all tools...')
        from Gaugi import ToolSvc as toolSvc
        self._alg_tools = toolSvc.getTools()
        for alg in self._alg_tools:
            if alg.status is StatusTool.DISABLE:
                continue
            # Retrieve all services
            alg.level = self._level
            alg.setContext(self.getContext())
            alg.setStoreGateSvc(self.getStoreGateSvc())
            alg.dataframe = self._dataframe
            if alg.isInitialized():
                continue
            if alg.initialize().isFailure():
                MSG_FATAL(self, "Impossible to initialize the tool name: %s",
                          alg.name)

        return StatusCode.SUCCESS