def test_selection_with_name_overlap_doesnt_raise(): sel02 = AutomaticData(Location='Phys/Sel02/Particles') sel03 = AutomaticData(Location='Phys/Sel03/Particles') alg0 = MockConfGenerator() sel0 = Selection('Sel005', Algorithm=alg0) sel1 = Selection('Sel005Loose', Algorithm=alg0) assert sel0.outputLocation() == 'Phys/Sel005/Particles' assert sel1.outputLocation() == 'Phys/Sel005Loose/Particles'
def test_outputLocation(): sel00 = AutomaticData(Location='Phys/Sel00/Particles') assert sel00.outputLocation() == 'Phys/Sel00/Particles' alg0 = MockConfGenerator() sel0 = Selection('SomeName001', Algorithm=alg0) assert sel0.outputLocation() == 'Phys/SomeName001/Particles' sel1 = Selection('SomeName002', OutputBranch='HLT2', Algorithm=alg0, Extension='HltParticles') assert sel1.outputLocation() == 'HLT2/SomeName002/HltParticles'
"pi-" : "ALL" } KsPiPi.MotherCut = "(M > 400) & (M < 600) & (BPVVDCHI2 > 100.) & (VFASPF(VCHI2/VDOF) < 10)" from PhysSelPython.Wrappers import Selection from StandardParticles import StdNoPIDsDownPions, StdLoosePions LooseKsPiPi = Selection("SelLooseKsPiPi", Algorithm = KsPiPi, RequiredSelections = [StdNoPIDsDownPions ]) #RequiredSelections = [StdLoosePions]) from PhysSelPython.Wrappers import SelectionSequence SeqKsPiPi = SelectionSequence('SeqKsPiPi', TopSelection = LooseKsPiPi) KsPiPiTuple = DecayTreeTuple("KsPiPiTuple") # input locations KsPiPiTuple.Inputs = [ LooseKsPiPi.outputLocation() ] # decay descriptors KsPiPiTuple.Decay = "KS0 -> ^pi+ ^pi-" # define the tools and configure them KsPiPiTuple.ToolList = [ "TupleToolKinematic" ,"TupleToolGeometry" ,"TupleToolPid" ,"TupleToolANNPID" #,"TupleToolTrackInfo" ,"TupleToolRecoStats" ,"TupleToolTrigger" ,"TupleToolPrimaries" ] KsPiPiTuple.addTupleTool("TupleToolTrackInfo/TupleToolTrackInfo")
class StrippingHyperCPXConf(LineBuilder) : """ Helper class to construct stirppinglines for search Sigma+ -> p mu+ mu- """ __configuration_keys__ = tuple ( _default_configuration_.keys() ) ## get the default configuration @staticmethod def defaultConfiguration( key = None ) : """ Get the defualt configurtaion >>> conf = StrippingHyperCPXConf.defaultConfiguration() Get the elements of default configurtaion: >>> SigmaPrescale = StrippingHyperCPXConf.defaultConfiguration( 'SigmaPrescale' ) """ from copy import deepcopy _config_ = deepcopy ( _default_configuration_ ) if key : return _config_[ key ] return _config_ ## constructor def __init__( self , name , config ) : """ Constructor """ ## if isinstance ( config , dict ) : from copy import deepcopy _config_ = deepcopy ( _default_configuration_ ) _config_ . update ( config ) else : _config_ = config ## base class LineBuilder.__init__( self , name , _config_ ) for line in self._lines_private() : self.registerLine(line) ## define ``main'' selection for Sigma+ -> p mu+ mu- def sigma ( self ) : """ define ``main'' selection for Sigma+ -> p mu+ mu- """ if hasattr ( self , 'Sigma' ) : return self.Sigma _SigmaAlg = CombineParticles ( # DecayDescriptors = [ " [ Sigma+ -> p+ mu+ mu- ]cc " , # signal " [ Sigma~+ -> p~- mu+ mu+ ]cc " # background ] , # DaughtersCuts = { 'p+' : self._config['ProtonCuts'] } , # Preambulo = self._config [ 'Preambulo' ] , # CombinationCut = """ ADAMASS('Sigma+') < %s """ % self._config[ 'SigmaMass' ] , # MotherCut = """ ( chi2vx < 25 ) & ( ctau > %s ) """ % self._config['SigmaCTau'] ) self.Sigma = Selection ( 'SelSigma2pMuMuFor' + self.name() , Algorithm = _SigmaAlg , RequiredSelections = [ self.twoMuons () , StdLooseProtons ] ) return self.Sigma ## define ``normalization'' selection for Ds+ -> ( phi -> mu+ mu- ) pi+ def ds2PhiPi ( self ) : """ Define ``normalization'' selection for Ds+ -> ( phi -> mu+ mu- ) pi+ """ if hasattr ( self , 'PhiPi' ) : return self.PhiPi _PhiPiAlg = CombineParticles ( # DecayDescriptors = [ " [ D_s+ -> pi+ mu+ mu- ]cc " , # signal " [ D_s+ -> pi- mu+ mu+ ]cc " # backghround ] , # DaughtersCuts = { 'pi+' : self._config['PionCuts'] } , # Preambulo = self._config [ 'Preambulo' ] , # CombinationCut = """ ( APT > 2 * GeV ) & ( ADAMASS ( 'D_s+' ) < %s ) & phi """ % self._config[ 'DsMass' ] , # MotherCut = """ ( chi2vx < 25 ) & ( ctau > %s ) """ % self._config['DplusCTau'] ) self.PhiPi = Selection ( 'SelDs2PhiPiFor' + self.name() , Algorithm = _PhiPiAlg , RequiredSelections = [ self.twoMuons () , StdLoosePions ] ) return self.PhiPi ## define ``normalization'' selection for Ds+ -> pi+ pi- pi+ def ds2PiPiPi ( self ) : """ Define ``normalization'' selection for Ds+ -> pi+ pi- pi+ """ def makeTISTOS( name, _input, _trigger ) : from Configurables import TisTosParticleTagger _tisTosFilter = TisTosParticleTagger( name + "Tagger" ) _tisTosFilter.TisTosSpecs = { _trigger : 0 } #_tisTosFilter.ProjectTracksToCalo = False #_tisTosFilter.CaloClustForCharged = False #_tisTosFilter.CaloClustForNeutral = False #_tisTosFilter.TOSFrac = { 4:0.0, 5:0.0 } return Selection( name , Algorithm = _tisTosFilter , RequiredSelections = [ _input ] ) _PiPiPiAlg = CombineParticles ( # DecayDescriptors = [" [ D_s+ -> pi+ pi+ pi- ]cc " ] , # DaughtersCuts = { 'pi+' : self._config['PionCuts'] } , # Preambulo = self._config [ 'Preambulo' ] , # CombinationCut = """ ( APT > 2 * GeV ) & ( ADAMASS ( 'D_s+' ) < %s ) & phi """ % self._config[ 'DsMass' ] , # MotherCut = """ ( chi2vx < 25 ) & ( ctau > %s ) """ % self._config['DplusCTau'] ) self.combPiPiPi = Selection ( 'SelDs2PiPiPiFor' + self.name() , Algorithm = _PiPiPiAlg , RequiredSelections = [ StdLoosePions ] ) self.selDs23PiHlt1TIS = makeTISTOS( self.name() + "Ds23PiHlt1TIS" , self.combPiPiPi , "Hlt1.*Decision%TIS" ) self.selDs23PiHlt2TIS = makeTISTOS( self.name() + "Ds23PiHlt2TIS" , self.selDs23PiHlt1TIS , "Hlt2.*Decision%TIS" ) return self.selDs23PiHlt2TIS ## define selection for D+ -> pi mu+ mu- def d2PiMuMu ( self ) : """ Define selection for D+ -> pi mu+ mu- """ if hasattr ( self , 'PiMuMu' ) : return self.PiMuMu _PiMuMuAlg = CombineParticles ( # DecayDescriptors = [ " [ D+ -> pi+ mu+ mu- ]cc " , # signal " [ D+ -> pi- mu+ mu+ ]cc " # backghround ] , # DaughtersCuts = { 'pi+' : self._config['PionCuts'] } , # Preambulo = self._config [ 'Preambulo' ] , # CombinationCut = """ ( APT > 2 * GeV ) & ( ADAMASS ( 'D+' ) < %s ) """ % self._config[ 'DplusMass' ] , # MotherCut = """ ( chi2vx < 25 ) & ( ctau > %s ) """ % self._config['DplusCTau'] ) self.PiMuMu = Selection ( 'SelDplus2PiMuMuFor' + self.name() , Algorithm = _PiMuMuAlg , RequiredSelections = [ self.twoMuons () , StdLoosePions ] ) return self.PhiPi ## get the muon selection def twoMuons ( self ) : """ Get the proton selection """ if hasattr ( self , 'TwoMuons' ) : return self.TwoMuons _MuonFilter = FilterDesktop ( Code = " ( 'mu+' == ABSID ) & " + self._config['MuonCuts'] ) self.Muons = Selection ( 'SelMuonsFor' + self.name () , Algorithm = _MuonFilter , RequiredSelections = [ StdLooseMuons ] ) ## require at least 2 muons self.TwoMuons = VoidEventSelection ( "TwoMuonsFor" + self.name() , Code = """ CONTAINS('%s') > 1.5 """ % self.Muons.outputLocation() , RequiredSelection = self.Muons ) # return self.TwoMuons ## get all stripping lines def _lines_private ( self ) : if hasattr ( self , '_Lines' ) : return self._Lines self._Lines = [ ## StrippingLine ( "Sigma2PMuMuFor" + self.name() , prescale = self._config['SigmaPrescale' ] , ## ATTENTION! Prescale here !! checkPV = self._config['PrimaryVertices'] , algos = [ self.sigma() ] ) , ## StrippingLine ( "Ds2PhiPiFor" + self.name () , prescale = self._config['DsPrescale' ] , ## ATTENTION! Prescale here !! checkPV = self._config['PrimaryVertices'] , algos = [ self.ds2PhiPi () ] ) , ## StrippingLine ( "Ds2PiPiPiFor" + self.name () , prescale = self._config['Ds3PiPrescale' ] , ## ATTENTION! Prescale here !! checkPV = self._config['PrimaryVertices'] , algos = [ self.ds2PiPiPi () ] ) , ## StrippingLine ( "Dplus2PiMuMuFor" + self.name () , prescale = self._config['DplusPrescale' ] , ## ATTENTION! Prescale here !! checkPV = self._config['PrimaryVertices'] , algos = [ self.d2PiMuMu () ] ) ] # return self._Lines
def patchBrunel(): """ Instantiate the options to run Brunel with raw data @author M.Frank """ import GaudiConf.DstConf import Brunel.Configuration import OnlineEnv brunel = Brunel.Configuration.Brunel() brunel.OnlineMode = True try: brunel.DDDBtag = OnlineEnv.DDDBTag except: print "DDDBTag not found, use default" try: brunel.CondDBtag = OnlineEnv.CondDBTag except: print "CondDBTag not found, use default" ##print '[ERROR]', OnlineEnv.DDDBTag, OnlineEnv.CondDBTag conddb = CondDB() conddb.IgnoreHeartBeat = True # # Adjust to pickup the proper online conditions # import ConditionsMap conddb.setProp('RunChangeHandlerConditions', ConditionsMap.RunChangeHandlerConditions) conddb.setProp('EnableRunChangeHandler', True) brunel.DataType = "2015" brunel.UseDBSnapshot = True # Try it brunel.WriteFSR = False # This crashes Jaap's stuff conddb = CondDB() conddb.Online = True # # Adjust to pickup the proper online conditions from ConditionsMap # conddb.RunChangeHandlerConditions = ConditionsMap.RunChangeHandlerConditions conddb.setProp('EnableRunChangeHandler', True) # Enabled data-on-demand Gaudi.ApplicationMgr().ExtSvc += ["DataOnDemandSvc"] ################################################################################ # # # Set up PID monitoring sequence # # # ################################################################################ # The sequencer to run all the monitoring in seq = GaudiSequencer("PIDMoniSeq") pidSeq = GaudiSequencer("RichPIDSelections") brunel.setOtherProps(RichPIDQCConf(), ['OutputLevel', 'Context']) RichPIDQCConf().setProp("CalibSequencer", pidSeq) seq.Members += [pidSeq] ################################################################################ # # # Configure the muon efficiency monitor # # # ################################################################################ muEffMoni = MuEffMonitor("MuEffMonitor") muEffMoni.addTool(TrackMasterExtrapolator, name="MuEffExtrap") muEffMoni.Extrapolator = muEffMoni.MuEffExtrap muEffMoni.MuEffExtrap.ApplyMultScattCorr = True muEffMoni.MuEffExtrap.ApplyEnergyLossCorr = True muEffMoni.MuEffExtrap.MaterialLocator = "SimplifiedMaterialLocator" muEffMoni.MuEffExtrap.OutputLevel = 6 muEffMoni.nSigma1X = [11., 8., 7., 7.] muEffMoni.nSigma1Y = [6., 5., 5., 5.] muEffMoni.nSigmaX = [5., 5., 5., 5.] muEffMoni.nSigmaY = [5., 5., 5., 5.] muEffMoni.RequiredStations = 4 muEffMoni.MomentumCut = 3000.0 muEffMoni.nSigmaFidVol = 3.0 muEffMoni.UseCalo = True muEffMoni.EecalMax = 1500.0 muEffMoni.EhcalMax = 5000.0 muEffMoni.EhcalMin = 1000.0 muEffMoni.Chi2ProbTrMin = 0.01 muEffMoni.Chi2MuMin = 10.0 muEffMoni.nSigmaXother = 2.0 muEffMoni.nSigmaYother = 2.0 muEffMoni.HistoLevel = "OfflineFull" seq.Members += [muEffMoni] ################################################################################ # # # Configure the muon pid monitor # # # ################################################################################ from Configurables import MuIDMonitor, CombineParticles from Configurables import FilterDesktop from StandardParticles import StdNoPIDsPions, StdNoPIDsProtons, StdNoPIDsMuons from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand MuPidMoniSeq_Lambda = GaudiSequencer("MuPidMoniSeq_Lambda") MuPidMoniSeq_Jpsi = GaudiSequencer("MuPidMoniSeq_Jpsi") # # Make pions and protons # PionsFilter = FilterDesktop("PionsFilter") PionsFilter.Code = "(P>3000*MeV) & (PT>100*MeV) & (TRCHI2DOF<2) & (ISLONG) & (MIPCHI2DV(PRIMARY)>9)" PionsFilterSel = Selection("PionsFilterSel", Algorithm=PionsFilter, RequiredSelections=[StdNoPIDsPions]) ProtonsFilter = FilterDesktop("ProtonsFilter") ProtonsFilter.Code = "(P>3000*MeV) & (PT>100*MeV) & (TRCHI2DOF<2) & (ISLONG) & (MIPCHI2DV(PRIMARY)>9)" ProtonsFilterSel = Selection("ProtonsFilterSel", Algorithm=ProtonsFilter, RequiredSelections=[StdNoPIDsProtons]) # # Make Lambda_0 # LambdaMonitor = CombineParticles("LambdaMonitor") LambdaMonitor.DecayDescriptor = "[Lambda0 -> p+ pi-]cc" LambdaMonitor.CombinationCut = "(ADAMASS('Lambda0')<10*MeV)" LambdaMonitor.MotherCut = "(50<BPVVDZ) & (600>BPVVDZ) & (BPVDIRA>0.9999995) & (CHILDCUT((PT>0.2*GeV),1) | CHILDCUT((PT>0.2*GeV),2)) & (ADWM('KS0', WM('pi+', 'pi-')) > 20*MeV)" LambdaMonitorSel = Selection( "LambdaMonitorSel", Algorithm=LambdaMonitor, RequiredSelections=[PionsFilterSel, ProtonsFilterSel]) LambdaMonitorSeq = SelectionSequence("LambdaMonitorSeq", TopSelection=LambdaMonitorSel) MuPidMoniSeq_Lambda.Members += [LambdaMonitorSeq.sequence()] # # Make muons and J/psi # mucocut = '(0.5<PPINFO(LHCb.ProtoParticle.InAccMuon,-1)) & (P>3*GeV) & (PT>800*MeV) & (TRCHI2DOF<3) & (ISLONG)' tag1cuts = " (CHILDCUT(ISMUON,1)) & (CHILDCUT((P>6*GeV),1)) & (CHILDCUT((PT>1.5*GeV),1)) " tag2cuts = " (CHILDCUT(ISMUON,2)) & (CHILDCUT((P>6*GeV),2)) & (CHILDCUT((PT>1.5*GeV),2)) " probe2cuts = " ( (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)<1000*MeV),2)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)<4000*MeV),2)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)>-10*MeV),2)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)>1000*MeV),2)) ) " probe1cuts = " ( (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)<1000*MeV),1)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)<4000*MeV),1)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)>-10*MeV),1)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)>1000*MeV),1)) ) " child1cuts = tag1cuts + " & " + probe2cuts child2cuts = tag2cuts + " & " + probe1cuts MuonsFilter = FilterDesktop("MuonsFilter") MuonsFilter.Code = mucocut MuonsFilterSel = Selection("MuonsFilterSel", Algorithm=MuonsFilter, RequiredSelections=[StdNoPIDsMuons]) JpsiMonitor = CombineParticles("JpsiMonitor") JpsiMonitor.DecayDescriptor = "J/psi(1S) -> mu+ mu-" JpsiMonitor.CombinationCut = "(ADAMASS('J/psi(1S)')<300*MeV)" JpsiMonitor.MotherCut = "(VFASPF(VCHI2/VDOF)<20) & ( " + child1cuts + " | " + child2cuts + " ) " JpsiMonitor.OutputLevel = 6 JpsiMonitorSel = Selection("JpsiMonitorSel", Algorithm=JpsiMonitor, RequiredSelections=[MuonsFilterSel]) JpsiMonitorSeq = SelectionSequence("JpsiMonitorSeq", TopSelection=JpsiMonitorSel) MuPidMoniSeq_Jpsi.Members += [JpsiMonitorSeq.sequence()] # # Monitoring muon mis-id with Lambda_0 # MuIDLambdaPlot = MuIDMonitor("MuIDLambdaPlot") MuIDLambdaPlot.Inputs = [LambdaMonitorSel.outputLocation()] MuIDLambdaPlot.OutputLevel = 6 MuIDLambdaPlot.MassMean = 1115.68 MuIDLambdaPlot.MassWindow = 20. MuIDLambdaPlot.EffMassWin = 2. MuIDLambdaPlot.JpsiAnalysis = 0 MuIDLambdaPlot.LambdaAnalysis = 1 MuIDLambdaPlot.HitInFoi = 1 MuIDLambdaPlot.PreSelMomentum = 3000. # MuonID preselection momentum (MeV/c) MuIDLambdaPlot.MomentumCuts = [6000., 10000. ] # MuonID momentum cut ranges (MeV/c) # MuonID FOI parameters MuIDLambdaPlot.FOIfactor = 1. MuIDLambdaPlot.XFOIParameter1 = [ 5.5, 4.0, 3.3, 2.8, 5.2, 3.6, 2.4, 2.4, 5.7, 4.4, 2.8, 2.3, 5.1, 3.1, 2.3, 2.1, 5.8, 3.4, 2.6, 2.8 ] MuIDLambdaPlot.XFOIParameter2 = [ 11., 3., 1., 1., 31., 28., 21., 17., 30., 31., 27., 22., 28., 33., 35., 47., 31., 39., 56., 151. ] MuIDLambdaPlot.XFOIParameter3 = [ 0.20, 0.08, 0.03, 0.1, 0.06, 0.08, 0.10, 0.15, 0.04, 0.06, 0.09, 0.12, 0.08, 0.15, 0.23, 0.36, 0.07, 0.14, 0.24, 0.49 ] MuIDLambdaPlot.YFOIParameter1 = [ 2.8, 1.7, -153., 1.9, 3.3, 2.1, 1.7, 1.6, 3.6, 2.8, 1.9, 1.8, 4.4, 3.3, 2.2, 2.2, 4.8, 3.9, 2.6, 2.3 ] MuIDLambdaPlot.YFOIParameter2 = [ 3., 2., 156., 0., 17., 15., 9., 5., 26., 25., 16., 15., 30., 49., 57., 92., 32., 55., 96., 166. ] MuIDLambdaPlot.YFOIParameter3 = [ 0.03, 0.02, 0.00, 0.09, 0.13, 0.19, 0.19, 0.24, 0.11, 0.19, 0.21, 0.32, 0.10, 0.22, 0.30, 0.52, 0.08, 0.20, 0.34, 0.52 ] # # Parameters of the Landau functions # MuIDLambdaPlot.distMuon = [ 0.311, 1.349, 0.524, 0.0020, 17., 10.6, 0.04, 4.1, 1.64 ] MuIDLambdaPlot.distPion = [ 11., -12., 0.2029, -0.026, 0.06, 0.59, 0.008, -29., 41. ] MuPidMoniSeq_Lambda.Members += [MuIDLambdaPlot] # # Monitoring muon id with J/psi # MuIDJpsiPlot = MuIDMonitor("MuIDJpsiPlot") MuIDJpsiPlot.Inputs = [JpsiMonitorSel.outputLocation()] MuIDJpsiPlot.OutputLevel = 6 MuIDJpsiPlot.MassMean = 3096.91 MuIDJpsiPlot.MassWindow = 300. MuIDJpsiPlot.EffMassWin = 20. MuIDJpsiPlot.JpsiAnalysis = 1 MuIDJpsiPlot.LambdaAnalysis = 0 MuIDJpsiPlot.HitInFoi = 1 MuIDJpsiPlot.PreSelMomentum = MuIDLambdaPlot.PreSelMomentum MuIDJpsiPlot.MomentumCuts = MuIDLambdaPlot.MomentumCuts # MuonID FOI parameters MuIDJpsiPlot.FOIfactor = MuIDLambdaPlot.FOIfactor MuIDJpsiPlot.XFOIParameter1 = MuIDLambdaPlot.XFOIParameter1 MuIDJpsiPlot.XFOIParameter2 = MuIDLambdaPlot.XFOIParameter2 MuIDJpsiPlot.XFOIParameter3 = MuIDLambdaPlot.XFOIParameter3 MuIDJpsiPlot.YFOIParameter1 = MuIDLambdaPlot.YFOIParameter1 MuIDJpsiPlot.YFOIParameter2 = MuIDLambdaPlot.YFOIParameter2 MuIDJpsiPlot.YFOIParameter3 = MuIDLambdaPlot.YFOIParameter3 # # Parameters of the Landau functions # MuIDJpsiPlot.distMuon = MuIDLambdaPlot.distMuon MuIDJpsiPlot.distPion = MuIDLambdaPlot.distPion MuPidMoniSeq_Jpsi.Members += [MuIDJpsiPlot] MuPidMoniSeq_Jpsi.IgnoreFilterPassed = True MuPidMoniSeq_Lambda.IgnoreFilterPassed = True seq.Members += [MuPidMoniSeq_Lambda, MuPidMoniSeq_Jpsi] # set the options class __MonAdd: def __init__(self, s): self.seq = s def addMonitors(self): # Append to processing GaudiSequencer("PhysicsSeq").Members += [self.seq] mon = __MonAdd(seq) Gaudi.appendPostConfigAction(mon.addMonitors) EventLoopMgr().OutputLevel = MSG_DEBUG #ERROR EventLoopMgr().Warnings = False brunel.UseDBSnapshot = True # try it Brunel.Configuration.Brunel.configureOutput = dummy HistogramPersistencySvc().OutputFile = "" HistogramPersistencySvc().OutputLevel = MSG_ERROR print brunel return brunel
# vertex_filter_seq = GaudiSequencer( # '{0}VertexFilterSequencer'.format(t['name']), # Members=[vertex_filter, t['tuple']] # ) if 'sel' in t: sel = t['sel'] # dstp = DataOnDemand(t['line']) cutter = FilterDesktop(t['name'] + 'selector', Code=sel) selection = Selection(t['name'] + 'selection', Algorithm=cutter, RequiredSelections=[dstp]) selseq = SelectionSequence(t['name'] + 'selectionsequence', TopSelection=selection) t['tuple'].Inputs = [selection.outputLocation()] sequencer = GaudiSequencer('{0}SelectionSequencer'.format(t['name']), Members=[selseq.sequence(), t['tuple']]) tuple_members.append(sequencer) else: tuple_members.append(t['tuple']) if is_mc(): gen_members.append(t['gen']) # Run the ntuple creation as a sequence, but don't worry about whether each # ntuple gets filled tuple_seq = GaudiSequencer('TupleSequencer', Members=tuple_members, IgnoreFilterPassed=True)
def test_multi_sequencer_sequences(): _sel00 = AutomaticData(Location='Phys/Sel00') _sel01 = AutomaticData(Location='Phys/Sel01') _sel02 = AutomaticData(Location='Phys/Sel02') _sel03 = AutomaticData(Location='Phys/Sel03') sel00_01 = Selection('0000110', Algorithm=MockConfGenerator(), RequiredSelections=[_sel00, _sel01]) sel02_03 = Selection('0000111', Algorithm=MockConfGenerator(), RequiredSelections=[_sel02, _sel03]) selA = Selection('000112A', Algorithm=MockConfGenerator(), RequiredSelections=[sel00_01, sel02_03]) _sel04 = AutomaticData(Location='Phys/Sel04') _sel05 = AutomaticData(Location='Phys/Sel05') _sel06 = AutomaticData(Location='Phys/Sel06') _sel07 = AutomaticData(Location='Phys/Sel07') sel04_05 = Selection('0000112', Algorithm=MockConfGenerator(), RequiredSelections=[_sel04, _sel05]) sel06_07 = Selection('0000113', Algorithm=MockConfGenerator(), RequiredSelections=[_sel06, _sel07]) selB = Selection('000112B', Algorithm=MockConfGenerator(), RequiredSelections=[sel04_05, sel06_07]) presel0 = MockConfGenerator() presel1 = MockConfGenerator() presel2 = MockConfGenerator() presel3 = MockConfGenerator() postsel0 = MockConfGenerator() postsel1 = MockConfGenerator() postsel2 = MockConfGenerator() postsel3 = MockConfGenerator() preselsA = [presel0, presel1] postselsA = [postsel0, postsel1] preselsB = [presel2, presel3] postselsB = [postsel2, postsel3] seqA = SelectionSequence('Seq0002A', TopSelection=selA, EventPreSelector=preselsA, PostSelectionAlgs=postselsA) seqB = SelectionSequence('Seq0002B', TopSelection=selB, EventPreSelector=preselsB, PostSelectionAlgs=postselsB) multiSeq = MultiSelectionSequence('MultiSeqAB', Sequences=[seqA, seqB], sequencerType=DummySequencer) assert multiSeq.outputLocations() == [ selA.outputLocation(), selB.outputLocation() ] print 'algos in seqA', len(seqA.algorithms()) print 'algos in seqB', len(seqB.algorithms()) seqAlgos = multiSeq.sequence().Members seqAlgosA = seqAlgos[0].Members seqAlgosB = seqAlgos[1].Members assert len(seqAlgos) == len(multiSeq._sequences) assert len(multiSeq.algorithms()) == len(seqAlgosA) + len(seqAlgosB) ref_algosA = [ presel0, presel1, _sel00.algorithm(), _sel01.algorithm(), _sel02.algorithm(), _sel03.algorithm(), sel02_03.algorithm(), sel00_01.algorithm(), selA.algorithm(), postsel0, postsel1 ] ref_algosB = [ presel2, presel3, _sel04.algorithm(), _sel05.algorithm(), _sel06.algorithm(), _sel07.algorithm(), sel06_07.algorithm(), sel04_05.algorithm(), selB.algorithm(), postsel2, postsel3 ] assert len(seqAlgos) == 2 assert preselsA == seqAlgosA[:len(preselsA)] assert preselsB == seqAlgosB[:len(preselsB)] # selA must be just before postsels assert selA.algorithm() == ref_algosA[len(ref_algosA) - (len(postselsA) + 1)] assert postselsA == seqAlgosA[len(ref_algosA) - len(postselsA):] assert postselsB == seqAlgosB[len(ref_algosB) - len(postselsB):] # selB must be just before postsels assert selB.algorithm() == ref_algosB[len(ref_algosB) - (len(postselsB) + 1)] # order doesn't matter for sel in [sel04_05, sel06_07]: assert sel.algorithm() in ref_algosB[len(preselsB):len(ref_algosB) - len(postselsB)] for sel in [sel00_01, sel02_03]: assert sel.algorithm() in ref_algosA[len(preselsA):len(ref_algosA) - len(postselsA)]
ln = str(lm) hn = str(hm) name = ln+"_"+hn # define the prescale to have a constant (assumed flat) level of background prescale = DeterministicPrescaler("Prescale_"+name, AcceptFraction = 100./(hm-lm)) filter = FilterDesktop("Jpsi_"+name, Code = "(MM>"+ln+") & (MM<"+hn+") & (MIPCHI2DV(PRIMARY) > 2)") SelJpsi = Selection('SelJpsi_'+name, Algorithm = filter, RequiredSelections = [ MyLooseJpsi ]) printer = PrintDecayTree("Print_"+name, Inputs = [SelJpsi.outputLocation()]) SeqJpsi = SelectionSequence('SeqJpsi_'+name , TopSelection = SelJpsi , EventPreSelector = [ prescale ] , PostSelectionAlgs = [ printer ]) selections += [SeqJpsi] dstWriter = SelDSTWriter("JpsiDSTWriter_"+name, SelectionSequences = selections) dstWriter.MicroDSTElements['default'] += [CloneParticleMCInfo()] seq = dstWriter.sequence()