def execute(simulation=True, turbo=True, decay_descriptor="J/psi(1S) -> mu- mu+"): # Configure all the unpacking, algorithms, tags and input files appConf = ApplicationMgr() appConf.ExtSvc+= ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()] ConfigTarFileAccessSvc().File = 'config.tar' dv = DaVinci() dv.DataType = "2012" lhcbApp = LHCbApp() lhcbApp.Simulation = simulation CondDB().Upgrade = False dtt = DecayTreeTuple("Early2015") if turbo: tesla_prefix = "Hlt2DiMuonJPsi" dtt.Inputs = ["/Event/"+tesla_prefix+"/Particles"] dtt.InputPrimaryVertices = "/Event/"+tesla_prefix+"/Primary" dtt.WriteP2PVRelations = False else: LHCbApp().DDDBtag = "dddb-20140729" polarity = "u" LHCbApp().CondDBtag = "sim-20140730-vc-m%s100"%polarity muons = AutomaticData(Location="Phys/StdAllLooseMuons/Particles") jpsi = CombineParticles('MyJPsi') jpsi.DecayDescriptors = [decay_descriptor] jpsi.CombinationCut = "(AM < 7100.0 *GeV)" jpsi.DaughtersCuts = {"": "ALL", "mu+": "ALL", "mu-": "ALL"} jpsi.MotherCut = "(VFASPF(VCHI2/VDOF) < 999999.0)" code = """ ('J/psi(1S)' == ID) & in_range(2.990*GeV, M, 3.210*GeV) & DECTREE('%s') & CHILDCUT(1, HASMUON & ISMUON) & CHILDCUT(2, HASMUON & ISMUON) & (MINTREE('mu+' == ABSID, PT) > 700*MeV) & (MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF) < 5) & (MINTREE(ISBASIC & HASTRACK, CLONEDIST) > 5000) & (VFASPF(VPCHI2) > 0.5/100) & (abs(BPV(VZ)) < 0.5*meter) & (BPV(vrho2) < (10*mm)**2) """%(decay_descriptor) # similar to the HLT2 line code = """ (ADMASS('J/psi(1S)')< 120*MeV) & DECTREE('%s') & (PT>0*MeV) & (MAXTREE('mu-'==ABSID,TRCHI2DOF) < 4) & (MINTREE('mu-'==ABSID,PT)> 0*MeV) & (VFASPF(VCHI2PDOF)< 25) """%(decay_descriptor) filter_jpsi = FilterDesktop("MyFilterJPsi", Code=code, Preambulo=["vrho2 = VX**2 + VY**2"], ReFitPVs=True, #IgnoreP2PVFromInputLocations=True, #WriteP2PVRelations=True ) jpsi_sel = Selection("SelMyJPsi", Algorithm=jpsi, RequiredSelections=[muons]) filter_jpsi_sel = Selection("SelFilterMyJPsi", Algorithm=filter_jpsi, RequiredSelections=[jpsi_sel]) jpsi_seq = SelectionSequence("SeqMyJPsi", TopSelection=filter_jpsi_sel) dtt.Inputs = [jpsi_seq.outputLocation()] # Overwriting default list of TupleTools dtt.ToolList = ["TupleToolKinematic", "TupleToolPid", "TupleToolEventInfo", "TupleToolMCBackgroundInfo", "TupleToolMCTruth", #"MCTupleToolHierarchy", #"MCTupleToolPID", "TupleToolGeometry", "TupleToolTISTOS", # with turbo this crashes #"TupleToolTrackInfo", "TupleToolTrigger", ] tlist = ["L0HadronDecision", "L0MuonDecision", "L0DiMuonDecision", "L0ElectronDecision", "L0PhotonDecision", "Hlt1DiMuonHighMassDecision", "Hlt1DiMuonLowMassDecision", "Hlt1TrackMuonDecision", "Hlt1TrackAllL0Decision", "Hlt2DiMuonJPsiDecision", "Hlt2SingleMuonDecision", ] dtt.addTool(TupleToolTrigger, name="TupleToolTrigger") dtt.addTool(TupleToolTISTOS, name="TupleToolTISTOS") # Get trigger info dtt.TupleToolTrigger.Verbose = True dtt.TupleToolTrigger.TriggerList = tlist dtt.TupleToolTISTOS.Verbose = True dtt.TupleToolTISTOS.TriggerList = tlist from Configurables import TupleToolMCTruth, MCTupleToolHierarchy dtt.addTool(TupleToolMCBackgroundInfo, name="TupleToolMCBackgroundInfo") dtt.TupleToolMCBackgroundInfo.Verbose = True dtt.addTool(MCTupleToolHierarchy, name="MCTupleToolHierarchy") dtt.MCTupleToolHierarchy.Verbose = True dtt.addTool(TupleToolMCTruth, name="TupleToolMCTruth") dtt.TupleToolMCTruth.Verbose = True if turbo: assoc_seq = TeslaTruthUtils.associateSequence(tesla_prefix, False) ChargedPP2MC(tesla_prefix+"ProtoAssocPP").OutputLevel = 1 assoc_seq.Members.insert(0, PatLHCbID2MCParticle()) from Configurables import MuonCoord2MCParticleLink muon_coords = MuonCoord2MCParticleLink("TeslaMuonCoordLinker") assoc_seq.Members.insert(1, muon_coords) TrackAssociator("TeslaAssocTr").DecideUsingMuons = True relations = TeslaTruthUtils.getRelLoc(tesla_prefix) else: relations = "Relations/Rec/ProtoP/Charged" TeslaTruthUtils.makeTruth(dtt, relations, ["MCTupleToolKinematic", "MCTupleToolHierarchy", "MCTupleToolPID", ] ) dtt.Decay = mark(2, mark(3, decay_descriptor)) #"J/psi(1S) -> ^mu- ^mu+" dtt.addBranches({"X": "^(%s)"%(decay_descriptor), "muplus": mark(3, decay_descriptor),#"J/psi(1S) -> mu- ^mu+", "muminus": mark(2, decay_descriptor),#"J/psi(1S) -> ^mu- mu+", }) x_preamble = ["DZ = VFASPF(VZ) - BPV(VZ)", ] x_vars = {"ETA": "ETA", "Y": "Y", "PHI": "PHI", "VPCHI2": "VFASPF(VPCHI2)", "DELTAZ": "DZ", # DZ * M / PZ / c with c in units of mm/s # XXX should this be the PDG mass or measured mass? #"TZ": "DZ*M / PZ / 299792458000.0", #seconds "TZ": "DZ*3096.916 / PZ/299792458000.0*(10**12)", #ps "minpt": "MINTREE('mu+' == ABSID, PT)", "minclonedist": "MINTREE(ISBASIC & HASTRACK, CLONEDIST)", "maxtrchi2dof": "MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF)", } muon_vars = {"ETA": "ETA", "Y": "Y", "PHI": "PHI", "CHARGE": "Q", "CLONEDIST": "CLONEDIST", "TRCHI2DOF": "TRCHI2DOF", } loki_X = dtt.X.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_X") loki_X.Variables = x_vars loki_X.Preambulo = x_preamble loki_mup = dtt.muplus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuPlus") loki_mup.Variables = muon_vars #dtt.muplus.addTupleTool("TupleToolGeometry") loki_mum = dtt.muminus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuMinus") loki_mum.Variables = muon_vars #dtt.muminus.addTupleTool("TupleToolGeometry") dv.TupleFile = "DVNtuples.root" if turbo: dv.UserAlgorithms = [assoc_seq, dtt] else: assocpp = ChargedPP2MC("TimsChargedPP2MC") assocpp.OutputLevel = 1 dv.UserAlgorithms = [jpsi_seq.sequence(), assocpp, dtt]
#tlist = ["L0HadronDecision","L0MuonDecision","L0DiMuonDecision","L0ElectronDecision","L0PhotonDecision","Hlt1DiMuonHighMassDecision","Hlt1DiMuonLowMassDecision","Hlt1TrackMuonDecision","Hlt1TrackAllL0Decision","Hlt2DiMuonJPsi","Hlt2IncPhiDecision","Hlt2Topo4BodySimpleDecision","Hlt2Topo3BodySimpleDecision","Hlt2Topo3BodyBBDTDecision","Hlt2Topo2BodySimpleDecision","Hlt2Topo2BodyBBDTDecision","Hlt2Topo4BodyBBDTDecision","Hlt2TopoMu4BodyBBDTDecision","Hlt2IncPhiSidebandsDecision","Hlt2B2HHDecision","Hlt2DiPhiDecision"] tlist = ["Hlt2DiMuonJPsi"] tuple.Decay = "J/psi(1S) -> ^mu+ ^mu-" #tuple.Decay = "[D*(2010)+ -> ^(K*(892)0 -> ^K+ ^pi-) ^pi+]CC" tuple.addTool(TupleToolTrigger, name="TupleToolTrigger") tuple.addTool(TupleToolTISTOS, name="TupleToolTISTOS") # Get trigger info tuple.TupleToolTrigger.Verbose = True tuple.TupleToolTrigger.TriggerList = tlist tuple.TupleToolTISTOS.Verbose = True tuple.TupleToolTISTOS.TriggerList = tlist from TeslaTools import TeslaTruthUtils seq = TeslaTruthUtils.associateSequence("Tesla",False) relations = TeslaTruthUtils.getRelLoc("Tesla") TeslaTruthUtils.makeTruth(tuple, relations, [ "MCTupleToolKinematic" , "MCTupleToolHierarchy" , "MCTupleToolPID" ]) tuple2 = MCDecayTreeTuple("MCTeslaTuple") tuple2.Inputs = ['/Event/Tesla/Particles'] tuple2.Decay = tuple.Decay from Configurables import DataOnDemandSvc, L0SelReportsMaker, L0DecReportsMaker DataOnDemandSvc().AlgMap["HltLikeL0/DecReports"] = L0DecReportsMaker() DataOnDemandSvc().AlgMap["HltLikeL0/SelReports"] = L0SelReportsMaker() from Configurables import L0Conf L0Conf().FullL0MuonDecoding = True L0Conf().EnableL0DecodingOnDemand = True L0Conf().EnsureKnownTCK=False
#tlist = ["L0HadronDecision","L0MuonDecision","L0DiMuonDecision","L0ElectronDecision","L0PhotonDecision","Hlt1DiMuonHighMassDecision","Hlt1DiMuonLowMassDecision","Hlt1TrackMuonDecision","Hlt1TrackAllL0Decision","Hlt2DiMuonJPsi","Hlt2IncPhiDecision","Hlt2Topo4BodySimpleDecision","Hlt2Topo3BodySimpleDecision","Hlt2Topo3BodyBBDTDecision","Hlt2Topo2BodySimpleDecision","Hlt2Topo2BodyBBDTDecision","Hlt2Topo4BodyBBDTDecision","Hlt2TopoMu4BodyBBDTDecision","Hlt2IncPhiSidebandsDecision","Hlt2B2HHDecision","Hlt2DiPhiDecision"] tlist = ["Hlt2DiMuonJPsi"] tuple.Decay = "J/psi(1S) -> ^mu+ ^mu-" #tuple.Decay = "[D*(2010)+ -> ^(K*(892)0 -> ^K+ ^pi-) ^pi+]CC" tuple.addTool(TupleToolTrigger, name="TupleToolTrigger") tuple.addTool(TupleToolTISTOS, name="TupleToolTISTOS") # Get trigger info tuple.TupleToolTrigger.Verbose = True tuple.TupleToolTrigger.TriggerList = tlist tuple.TupleToolTISTOS.Verbose = True tuple.TupleToolTISTOS.TriggerList = tlist from TeslaTools import TeslaTruthUtils seq = TeslaTruthUtils.associateSequence("Tesla", False) relations = TeslaTruthUtils.getRelLoc("Tesla") TeslaTruthUtils.makeTruth( tuple, relations, ["MCTupleToolKinematic", "MCTupleToolHierarchy", "MCTupleToolPID"]) tuple2 = MCDecayTreeTuple("MCTeslaTuple") tuple2.Inputs = ['/Event/Tesla/Particles'] tuple2.Decay = tuple.Decay from Configurables import DataOnDemandSvc, L0SelReportsMaker, L0DecReportsMaker DataOnDemandSvc().AlgMap["HltLikeL0/DecReports"] = L0DecReportsMaker() DataOnDemandSvc().AlgMap["HltLikeL0/SelReports"] = L0SelReportsMaker() from Configurables import L0Conf L0Conf().FullL0MuonDecoding = True L0Conf().EnableL0DecodingOnDemand = True
def execute(simulation=True, turbo=True, decay_descriptor="J/psi(1S) -> mu- mu+"): # Configure all the unpacking, algorithms, tags and input files appConf = ApplicationMgr() appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()] ConfigTarFileAccessSvc().File = 'config.tar' dv = DaVinci() dv.DataType = "2012" lhcbApp = LHCbApp() lhcbApp.Simulation = simulation CondDB().Upgrade = False dtt = DecayTreeTuple("Early2015") if turbo: tesla_prefix = "Hlt2DiMuonJPsi" dtt.Inputs = ["/Event/" + tesla_prefix + "/Particles"] dtt.InputPrimaryVertices = "/Event/" + tesla_prefix + "/Primary" dtt.WriteP2PVRelations = False else: LHCbApp().DDDBtag = "dddb-20140729" polarity = "u" LHCbApp().CondDBtag = "sim-20140730-vc-m%s100" % polarity muons = AutomaticData(Location="Phys/StdAllLooseMuons/Particles") jpsi = CombineParticles('MyJPsi') jpsi.DecayDescriptors = [decay_descriptor] jpsi.CombinationCut = "(AM < 7100.0 *GeV)" jpsi.DaughtersCuts = {"": "ALL", "mu+": "ALL", "mu-": "ALL"} jpsi.MotherCut = "(VFASPF(VCHI2/VDOF) < 999999.0)" code = """ ('J/psi(1S)' == ID) & in_range(2.990*GeV, M, 3.210*GeV) & DECTREE('%s') & CHILDCUT(1, HASMUON & ISMUON) & CHILDCUT(2, HASMUON & ISMUON) & (MINTREE('mu+' == ABSID, PT) > 700*MeV) & (MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF) < 5) & (MINTREE(ISBASIC & HASTRACK, CLONEDIST) > 5000) & (VFASPF(VPCHI2) > 0.5/100) & (abs(BPV(VZ)) < 0.5*meter) & (BPV(vrho2) < (10*mm)**2) """ % (decay_descriptor) # similar to the HLT2 line code = """ (ADMASS('J/psi(1S)')< 120*MeV) & DECTREE('%s') & (PT>0*MeV) & (MAXTREE('mu-'==ABSID,TRCHI2DOF) < 4) & (MINTREE('mu-'==ABSID,PT)> 0*MeV) & (VFASPF(VCHI2PDOF)< 25) """ % (decay_descriptor) filter_jpsi = FilterDesktop( "MyFilterJPsi", Code=code, Preambulo=["vrho2 = VX**2 + VY**2"], ReFitPVs=True, #IgnoreP2PVFromInputLocations=True, #WriteP2PVRelations=True ) jpsi_sel = Selection("SelMyJPsi", Algorithm=jpsi, RequiredSelections=[muons]) filter_jpsi_sel = Selection("SelFilterMyJPsi", Algorithm=filter_jpsi, RequiredSelections=[jpsi_sel]) jpsi_seq = SelectionSequence("SeqMyJPsi", TopSelection=filter_jpsi_sel) dtt.Inputs = [jpsi_seq.outputLocation()] # Overwriting default list of TupleTools dtt.ToolList = [ "TupleToolKinematic", "TupleToolPid", "TupleToolEventInfo", "TupleToolMCBackgroundInfo", "TupleToolMCTruth", #"MCTupleToolHierarchy", #"MCTupleToolPID", "TupleToolGeometry", "TupleToolTISTOS", # with turbo this crashes #"TupleToolTrackInfo", "TupleToolTrigger", ] tlist = [ "L0HadronDecision", "L0MuonDecision", "L0DiMuonDecision", "L0ElectronDecision", "L0PhotonDecision", "Hlt1DiMuonHighMassDecision", "Hlt1DiMuonLowMassDecision", "Hlt1TrackMuonDecision", "Hlt1TrackAllL0Decision", "Hlt2DiMuonJPsiDecision", "Hlt2SingleMuonDecision", ] dtt.addTool(TupleToolTrigger, name="TupleToolTrigger") dtt.addTool(TupleToolTISTOS, name="TupleToolTISTOS") # Get trigger info dtt.TupleToolTrigger.Verbose = True dtt.TupleToolTrigger.TriggerList = tlist dtt.TupleToolTISTOS.Verbose = True dtt.TupleToolTISTOS.TriggerList = tlist from Configurables import TupleToolMCTruth, MCTupleToolHierarchy dtt.addTool(TupleToolMCBackgroundInfo, name="TupleToolMCBackgroundInfo") dtt.TupleToolMCBackgroundInfo.Verbose = True dtt.addTool(MCTupleToolHierarchy, name="MCTupleToolHierarchy") dtt.MCTupleToolHierarchy.Verbose = True dtt.addTool(TupleToolMCTruth, name="TupleToolMCTruth") dtt.TupleToolMCTruth.Verbose = True if turbo: assoc_seq = TeslaTruthUtils.associateSequence(tesla_prefix, False) ChargedPP2MC(tesla_prefix + "ProtoAssocPP").OutputLevel = 1 assoc_seq.Members.insert(0, PatLHCbID2MCParticle()) from Configurables import MuonCoord2MCParticleLink muon_coords = MuonCoord2MCParticleLink("TeslaMuonCoordLinker") assoc_seq.Members.insert(1, muon_coords) TrackAssociator("TeslaAssocTr").DecideUsingMuons = True relations = TeslaTruthUtils.getRelLoc(tesla_prefix) else: relations = "Relations/Rec/ProtoP/Charged" TeslaTruthUtils.makeTruth(dtt, relations, [ "MCTupleToolKinematic", "MCTupleToolHierarchy", "MCTupleToolPID", ]) dtt.Decay = mark(2, mark(3, decay_descriptor)) #"J/psi(1S) -> ^mu- ^mu+" dtt.addBranches({ "X": "^(%s)" % (decay_descriptor), "muplus": mark(3, decay_descriptor), #"J/psi(1S) -> mu- ^mu+", "muminus": mark(2, decay_descriptor), #"J/psi(1S) -> ^mu- mu+", }) x_preamble = [ "DZ = VFASPF(VZ) - BPV(VZ)", ] x_vars = { "ETA": "ETA", "Y": "Y", "PHI": "PHI", "VPCHI2": "VFASPF(VPCHI2)", "DELTAZ": "DZ", # DZ * M / PZ / c with c in units of mm/s # XXX should this be the PDG mass or measured mass? #"TZ": "DZ*M / PZ / 299792458000.0", #seconds "TZ": "DZ*3096.916 / PZ/299792458000.0*(10**12)", #ps "minpt": "MINTREE('mu+' == ABSID, PT)", "minclonedist": "MINTREE(ISBASIC & HASTRACK, CLONEDIST)", "maxtrchi2dof": "MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF)", } muon_vars = { "ETA": "ETA", "Y": "Y", "PHI": "PHI", "CHARGE": "Q", "CLONEDIST": "CLONEDIST", "TRCHI2DOF": "TRCHI2DOF", } loki_X = dtt.X.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_X") loki_X.Variables = x_vars loki_X.Preambulo = x_preamble loki_mup = dtt.muplus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuPlus") loki_mup.Variables = muon_vars #dtt.muplus.addTupleTool("TupleToolGeometry") loki_mum = dtt.muminus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuMinus") loki_mum.Variables = muon_vars #dtt.muminus.addTupleTool("TupleToolGeometry") dv.TupleFile = "DVNtuples.root" if turbo: dv.UserAlgorithms = [assoc_seq, dtt] else: assocpp = ChargedPP2MC("TimsChargedPP2MC") assocpp.OutputLevel = 1 dv.UserAlgorithms = [jpsi_seq.sequence(), assocpp, dtt]