示例#1
0
def configure(year, mc):
    """General configuration of DaVinci options.

    Keyword arguments:
    year -- One of lc2pxx.config.years
    mc -- True if booking MC ntuples, else false
    """
    dv = DaVinci()
    # Output ntuple name
    dv.TupleFile = "DVntuple.root"
    # Process all events
    dv.EvtMax = -1
    # Print status every 1000 events
    dv.PrintFreq = 1000
    # Number of events to skip at the beginning of each file
    dv.SkipEvents = 0
    dv.DataType = str(year)
    dv.Simulation = mc
    # Collision streams for Charm are on microDST, and  in MC
    if not mc:
        dv.InputType = "MDST"
        # See "Question about microDST and RootInTES" in lhcb-davinci
        dv.RootInTES = "/Event/Charm"
    # Add a GetIntegratedLuminosity/LumiTuple TTree to output, but not in MC
    dv.Lumi = not mc
示例#2
0
def configure(year, mc, input_type, n_events, root=None, tfn=None):
    """General configuration of DaVinci object.

    Keyword arguments:
    year -- One of (2011, 2012)
    mc -- True if creating Monte Carlo ntuples, else False
    """
    dv = DaVinci()
    # Stripping output on CHARMCOMPLETEEVENT.DST, MC on ALLSTREAMS.DST
    dv.InputType = input_type
    # Output ntuple name
    dv.TupleFile = 'DVntuple.root'
    # Print status every 1000 events
    dv.PrintFreq = 1000
    dv.EvtMax = n_events
    # Year of data taking
    dv.DataType = str(year)
    # Is the data from simulation
    dv.Simulation = mc
    # Add a GetIntegratedLuminosity/LumiTuple TTree to output if appropriate
    dv.Lumi = not mc
    if root is not None:
        dv.RootInTES = root
    if tfn is not None:
        dv.TupleFile = tfn
ttsis.ReportsLocation = selectionPath + '/P2TPRelations'
ttsis.ReportStage = "Stripping"

tttt = dtt.B.addTupleTool('TupleToolTISTOS')
tttt.TriggerList = [
    'Hlt1TrackAllL0Decision', 'Hlt1TrackMuonDecision',
    'Hlt1DiMuonHighMassDecision', 'Hlt2DiMuonDetachedJpsiDecision',
    'Hlt2DiMuonJpsiDecision'
]
tttt.VerboseHlt1 = True
tttt.VerboseHlt2 = True

dv = DaVinci()
dv.DDDBtag = 'head-20110914'
dv.CondDBtag = 'head-20110914'
dv.DataType = '2011'
dv.Lumi = False
dv.InputType = "MDST" if mDST else "DST"
dv.UserAlgorithms = [dtt]
dv.EvtMax = -1

ApplicationMgr().HistogramPersistency = "ROOT"
from Configurables import HistogramPersistencySvc
HistogramPersistencySvc(OutputFile='histos.root')

from Configurables import NTupleSvc
NTupleSvc().Output += ["DTT DATAFILE='tuples.root' TYPE='ROOT' OPT='NEW'"]
NTupleSvc().OutputLevel = 1

## Point the EventClockSvc to the RootInTES
## from Configurables import EventClockSvc, OdinTimeDecoder, TimeDecoderList
  tuple.addTool( TupleToolTISTOS() )
  tuple.TupleToolTISTOS.VerboseL0 = True
  tuple.TupleToolTISTOS.VerboseHlt1 = True
  tuple.TupleToolTISTOS.VerboseHlt2 = True
  tuple.TupleToolTISTOS.Verbose = True
  tuple.TupleToolTISTOS.TriggerList = triggerList
  return tuple

################
# Configure DaVinci
################
from Configurables import DaVinci, L0Conf

dv = DaVinci()

dv.DataType = '2012'
dv.EvtMax = -1
for line_info in line_infos:
  print line_info
  tuple = makeDecayTreeTuple( line_info[0], line_info[1], line_info[2], line_info[3] )
  dv.UserAlgorithms += [ tuple ]
dv.Simulation   = False
#from Configurables import CondDB
#CondDB(UseOracle = True)
DaVinci().DDDBtag = "dddb-20120831"
DaVinci().CondDBtag = "cond-20121211"
DaVinci().EnableUnpack = ['Stripping','Reconstruction']

dv.Lumi = True
dv.HistogramFile = "DVHistos.root"    # Histogram file
dv.TupleFile = "DVNtuples.root"       # Ntuple
示例#5
0
            n = 0
            break
        n += 1
        dec = evt['/Event/Strip/Phys/DecReports']
        if dec.hasDecisionName('Stripping{0}Decision'.format(decision)):
            break

    return n


# Configure all the unpacking, algorithms, tags and input files
appConf = ApplicationMgr()
appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

dv = DaVinci()
dv.DataType = '2012'

# disable for older versions of DV
# generally it seems in older versions of DV
# this whole script 'breaks' at places
# raising exceptions and yet works ...
dre = DecodeRawEvent()
dre.DataOnDemand = True

lhcbApp = LHCbApp()
lhcbApp.Simulation = True
CondDB().Upgrade = False
# don't really need tags for looking around
# LHCbApp().DDDBtag = ...
# LHCbApp().CondDBtag  = ...
    "P/1000": ('momentum', 0, 150),
    "PT/1000": ('pt_%1%', 0, 5, 750),
    "M": ('mass in MeV_%1%_%2%_%3%', 2.8 * Units.GeV, 3.2 * Units.GeV)
}
#

JpsiFilterSel = Selection(name='JpsiFilterSel',
                          Algorithm=_jpsiFilter,
                          RequiredSelections=[JpsiSel])

JpsiSeq = SelectionSequence('SeqJpsi', TopSelection=JpsiFilterSel)
seq = JpsiSeq.sequence()

dv = DaVinci()
dv.PrintFreq = 10
dv.HistogramFile = "DVHistos_Strip.root"
dv.EvtMax = -1
dv.DataType = "MC09"
dv.Simulation = True
dv.RedoMCLinks = False
dv.UserAlgorithms = [seq]
dv.InputType = 'DST'
# MC09
#dv.Input = ["   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000001_1.dst' TYP='POOL_ROOTTREE' OPT='READ'"]
dv.Input = [
    "DATAFILE='PFN:/castor/cern.ch/user/j/jpalac/StripDST/MC09/DaVinci_v24r3p1/Sel.Jpsi.dst'  TYP='POOL_ROOTTREE' OPT='READ'"
]

ApplicationMgr().ExtSvc += ["NTupleSvc"]
ApplicationMgr().HistogramPersistency = "ROOT"
示例#7
0
def execute(inputdata=None,
            simulation=True,
            decay_descriptor="J/psi(1S) -> mu- mu+"):
    # Configure all the unpacking, algorithms, tags and input files
    appConf = ApplicationMgr()
    appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

    dv = DaVinci()
    dv.DataType = "2012"

    lhcbApp = LHCbApp()
    lhcbApp.Simulation = simulation
    CondDB().Upgrade = False
    # don't really need tags for looking around
    #LHCbApp().DDDBtag = t['DDDB']
    #LHCbApp().CondDBtag  = t['CondDB']

    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)
    filter_jpsi = FilterDesktop("MyFilterJPsi",
                                Code=code,
                                Preambulo=["vrho2 = VX**2 + VY**2"],
                                ReFitPVs=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 = DecayTreeTuple("Early2015")
    dtt.Inputs = [jpsi_seq.outputLocation()]
    # Overwriting default list of TupleTools
    # XXX need to add TisTosTool with sensible lines
    dtt.ToolList = [
        "TupleToolKinematic",
        "TupleToolPid",
        "TupleToolMCBackgroundInfo",
    ]
    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
    loki_mum = dtt.muminus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuMinus")
    loki_mum.Variables = muon_vars

    dv.UserAlgorithms = [jpsi_seq.sequence(), dtt]
    dv.TupleFile = "DVNtuples.root"

    if isinstance(inputdata, list):
        IOHelper('ROOT').inputFiles(inputdata)
vtxCut.ZExclusionRangeUp = 265.
vtxCut.OutputLevel = DEBUG
#HltAlgorithm related
vtxCut.MinCandidates = 1  #Should be > 0 and <= MaxBinValueCut+1 (by default = 1)
print vtxCut

mySeqBGTrig = GaudiSequencer('mySeqBGTrig')
mySeqBGTrig.Members = [clustCut]
#mySeqBGTrig.Members += [ extrCl ] # What will change if we do this; change LiteClusterLocation too !!!
mySeqBGTrig.Members += [rzTracking2]
mySeqBGTrig.Members += [vtxCut]

#########################################################################################
from Configurables import DaVinci
DV = DaVinci()
DV.DataType = 'DC06'
#DaVinci().DDDBtag   = 'head-20090112'
#DaVinci().CondDBtag = 'sim-20090112'
DV.UserAlgorithms = [mySeqRZTr, mySeqBGTrig]
DV.InputType = 'DST'
print DV

#########################################################################################
####################  GaudiPython; Other Imports; Type Shortcuts  #######################
#########################################################################################
import GaudiPython
appMgr = GaudiPython.AppMgr()
#appMgr.DLLs = [ 'GaudiAlg', 'RootHistCnv' ]

from GaudiPython import PyAlgorithm
from ROOT import TH1F, TH1D, TCanvas, gStyle
示例#9
0
                                         ]

#evttuple.TupleToolTrigger.CollateTriggerList = True



evttuple.addTool(LoKiTool)

evttuple.TupleName = "EventInfo"



dv = DaVinci()

dv.DataType = "2010"

dv.Simulation = False

dv.EvtMax     = -1

dv.TupleFile  = 'b2hh_stripped.root'

dv.PrintFreq  = 100

condDB = CondDB()

condDB.UseOracle = True


示例#10
0
Usage: SetupBender; ipython checkFT.py streamname dst_file
(Example: ipython checkFT.py Dimuon 00047192_00000021_1.dimuon.dst)
"""

import sys
import GaudiPython as GP
from GaudiConf import IOHelper
from Configurables import (LHCbApp, ApplicationMgr, DataOnDemandSvc,
                           DecodeRawEvent, CondDB, DaVinci)

## Copypasted from LHCb Starterkit:
## (http://lhcb.github.io/first-analysis-steps/05-interactive-dst.html)

appConf = ApplicationMgr()
dv = DaVinci()
dv.DataType = '2015'
dre = DecodeRawEvent()
dre.DataOnDemand = True
lhcbApp = LHCbApp()
dv.PrintFreq = 1000000  # Only results from FT checking loop.
lhcbApp.Simulation = False
CondDB().Upgrade = True
dv.IgnoreDQFlags = True

inputFiles = [sys.argv[-1]]
stream = str(sys.argv[-2])
IOHelper('ROOT').inputFiles(inputFiles)

appMgr = GP.AppMgr()
evt = appMgr.evtsvc()
appMgr.run(1)
示例#11
0
            dec = "%sDecision" % decision
            rep = reports.decReport(dec)
            if rep and rep.decision():
                found = True
                break
        if found:
            break
    return n


# Configure all the unpacking, algorithms, tags and input files
appConf = ApplicationMgr()
appConf.ExtSvc += ["ToolSvc", "DataOnDemandSvc", LoKiSvc()]

dv = DaVinci()
dv.DataType = "2012"

# disable for older versions of DV
# generally it seems in older versions of DV
# this whole script 'breaks' at places
# raising exceptions and yet works ...
dre = DecodeRawEvent()
dre.DataOnDemand = True

lhcbApp = LHCbApp()
lhcbApp.Simulation = True
CondDB().Upgrade = False
# don't really need tags for looking around
# LHCbApp().DDDBtag = ...
# LHCbApp().CondDBtag  = ...
示例#12
0
            dec = "%sDecision" % decision
            rep = reports.decReport(dec)
            if rep and rep.decision():
                found = True
                break
        if found:
            break
    return n


# Configure all the unpacking, algorithms, tags and input files
appConf = ApplicationMgr()
appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

dv = DaVinci()
dv.DataType = "2016"

# disable for older versions of DV
# generally it seems in older versions of DV
# this whole script 'breaks' at places
# raising exceptions and yet works ...
dre = DecodeRawEvent()
dre.DataOnDemand = True

lhcbApp = LHCbApp()
lhcbApp.Simulation = True
CondDB().Upgrade = False
# don't really need tags for looking around
# LHCbApp().DDDBtag = ...
# LHCbApp().CondDBtag  = ...
示例#13
0
from Configurables import DaVinci
from Configurables import Velo__VeloIPResolutionMonitorNT as IPMoni

dv = DaVinci()
dv.DataType = '2015'
dv.DDDBtag = 'dddb-20150526'
dv.CondDBtag = 'cond-20150625'
#dv.EvtMax = 100

ipMoni = IPMoni('VeloIPResolutionMonitor')
ipMoni.CheckIDs = True
dv.UserAlgorithms = [ipMoni]
dv.TupleFile = 'IPTuple.root'
示例#14
0
import sys

import GaudiPython as GP
from GaudiConf import IOHelper
from Configurables import DaVinci

dv = DaVinci()
dv.DataType = 'Upgrade'
dv.Simulation = True

# Pass file to open as first command line argument
inputFiles = [sys.argv[-1]]
IOHelper('ROOT').inputFiles(inputFiles)

appMgr = GP.AppMgr()
evt = appMgr.evtsvc()

appMgr.run(2)
evt.dump()

hs = evt["/Event/MC/VP/Hits"]
hits = [(h.X(), h.Y(), h.Z()) for h in [e.entry() for e in hs]]

import json
with open("hits.json", "w") as f:
    json.dump(hits, f)
示例#15
0
            dec = "%sDecision" % decision
            rep = reports.decReport(dec)
            if rep and rep.decision():
                found = True
                break
        if found:
            break
    return n


# Configure all the unpacking, algorithms, tags and input files
appConf = ApplicationMgr()
appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

dv = DaVinci()
dv.DataType = "2012"

# disable for older versions of DV
# generally it seems in older versions of DV
# this whole script 'breaks' at places
# raising exceptions and yet works ...
dre = DecodeRawEvent()
dre.DataOnDemand = True

lhcbApp = LHCbApp()
lhcbApp.Simulation = True
CondDB().Upgrade = False
# don't really need tags for looking around
# LHCbApp().DDDBtag = ...
# LHCbApp().CondDBtag  = ...
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]
dstExtras = MicroDSTExtras(branch=_tesBranch, callables=microDSTElements)

microDSTWriterConf.filePrefix = 'Test3'

dstWriter = DSTWriterSelectionSequence(
    selSequence=selSequence,
    outputStreamConfiguration=microDSTWriterConf,
    extras=dstExtras)

microDST0Seq = dstWriter.sequence()

#

dv = DaVinci()
dv.DataType = 'MC09'
dv.Simulation = True
dv.EvtMax = 100
dv.UserAlgorithms = [microDST0Seq]
dv.Input = [
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000001_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000002_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000003_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000004_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000005_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000006_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000007_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000008_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000009_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000010_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
    "   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000011_1.dst' TYP='POOL_ROOTTREE' OPT='READ'",
示例#18
0
        appMgr.run(1)

        if not evt['/Event/Rec/Header']:
            print 'Reached end of input files'
            break

        n += 1
        dec = evt['/Event/Strip/Phys/DecReports']
        if dec.hasDecisionName('Stripping{0}Decision'.format(decision)):
            break

    return n


dv = DaVinci()
dv.DataType = '2016'  # need to change depending on file?
dv.Simulation = True

# Pass file to open as first command line argument
inputFiles = [sys.argv[-1]]
IOHelper('ROOT').inputFiles(inputFiles)

appMgr = GP.AppMgr()
evt = appMgr.evtsvc()

appMgr.run(1)
evt.dump()

from LoKiPhys.decorators import PX, PY, PZ, PT, M, E, GeV

示例#19
0
]

streamConf = {'default': stripDSTStreamConf(), charm: microDSTStreamConf()}

elements = {
    'default': stripDSTElements(),
    charm: microDSTElements() + extraMicroElements
}

conf = SelDSTWriter("StripDST",
                    StreamConf=streamConf,
                    MicroDSTElements=elements,
                    OutputFileSuffix="01234567",
                    SelectionSequences=sc.activeStreams())

conf.StreamConf[charm] = microDSTStreamConf()

selDST0Seq = conf.sequence()

#

dv = DaVinci()
dv.DataType = '2010'
dv.InputType = 'SDST'
dv.EvtMax = 2000
#dv.UserAlgorithms = [multiSeqA.sequence(), multiSeqB.sequence(), selDST0Seq]
dv.UserAlgorithms = [conf.sequence()]
importOptions("Reco05-Stripping09_SDSTs.py")
#EventSelector().Input = ["DATAFILE='PFN:castor:/castor/cern.ch/user/c/cattanem/testFiles/Brunel-v37r1-069857_0000000006-1000ev.sdst' TYP='POOL_ROOTTREE' OPT='READ'"]
#FileCatalog().Catalogs =['xmlcatalog_file:TestSDSTCatalog.xml']
示例#20
0
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]