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
def configure_DATA(datafiles, catalogs, castor, params): logger.info('Configure DATA') the_year = params['Year'] from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) from Configurables import DaVinci dv = DaVinci(Lumi=True, # HistogramFile='B_Histos.root', TupleFile='B.root' ) from Configurables import TrackScaleState state_scale = TrackScaleState('StateScale') dv.UserAlgorithms = [state_scale] logger.info('Momentum scaling is applied!') return configure_COMMON(datafiles, catalogs, castor, params)
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'
def configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ ## needed for job configuration from Configurables import DaVinci the_year = "2011" from BenderTools.Parser import hasInFile if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Collision13'): the_year = '2013' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) rootInTES = '/Event/PSIX' # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( VOID_Code=""" 0.5 < CONTAINS('/Event/PSIX/Phys/SelB&B/Particles' ) """ ) dv = DaVinci( DataType=the_year, InputType='MDST', RootInTES=rootInTES, Simulation=False, PrintFreq=1000, EvtMax=-1, # HistogramFile='BB_Histos.root', TupleFile='BB.root', # Lumi=True, # ) dv.UserAlgorithms = ['BB'] from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) from BenderTools.Utils import silence silence() # # come back to Bender # setData(datafiles, catalogs, castor) # # start Gaudi # gaudi = appMgr() alg = BB( 'BB', RootInTES=rootInTES, Inputs=['Phys/SelB&B/Particles'] ) return SUCCESS
the_year = "2011" ## the_year = "2012" from Configurables import EventNodeKiller killer = EventNodeKiller("KillpRec") killer.Nodes += ['/Event/pRec'] from Configurables import DaVinci dv = DaVinci( EventPreFilters=fltrs.filters('Filters'), InputType='MDST', DataType=the_year, EvtMax=-1, Lumi=True, HistogramFile="DVHistos.root", # dbase # DDDBtag = "head-20120413" , # CondDBtag = "head-20120724" , # PrintFreq=1000 ) # from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) dv.appendToMainSequence([killer] + [udstWriter.sequence()]) # ============================================================================= if '__main__' == __name__:
mct.ToolList=mctl #mctB.ToolList=mctl printMC = PrintMCTree() printMC.ParticleNames = ["Lambda_c+","Lambda_c~-"] printMC.ParticleNames = ["D0","D~0"] printMC.ParticleNames = ["Xi_cc++","Xi_cc~--"] printMC.ParticleNames = ["B0","B~0"] printMC.ParticleNames = ["B+","B-"] ######################################################################## from Configurables import DaVinci DaVinci().EvtMax = -1 #DaVinci().PrintFreq = 1 #DaVinci().SkipEvents = 4 # Events to skip DaVinci().DataType = "2018" DaVinci().Simulation = True #DaVinci().DDDBtag ="dddb-20150703" #DaVinci().CondDBtag = "sim-20150703-vc-md100" #name = "B2KstGamma" DaVinci().TupleFile = "/eos/experiment/spacal/users/zhangy/GeneratorPhoton_B2KstGammaRun1000Evt1000.root" DaVinci().TupleFile = "/eos/experiment/spacal/users/zhangy/GeneratorPhoton_B2KPiPi0Run1000Evt1000.root" #DaVinci().UserAlgorithms = [printMC] DaVinci().UserAlgorithms = [mct] #DaVinci().Input=["Gauss-26166050-100ev-20170208.xgen"] #DaVinci().Input=["Lc.xgen"] DaVinci().Input=["/eos/experiment/spacal/users/zhangy/B2KstGammaGenerator_Run1000FirstEvent1000.sim"] DaVinci().Input=["/eos/experiment/spacal/users/zhangy/B2KPiPi0.sim"]
} d0_comb = "(AMAXDOCA('') < 0.2*mm) & (ADAMASS('D0') < 100*MeV)" # We can split long selections across multiple lines d0_vertex = ('(VFASPF(VCHI2/VDOF)< 9)' '& (BPVDIRA > 0.9997)' "& (ADMASS('D0') < 70*MeV)") d0 = CombineParticles('Combine_D0', DecayDescriptor='([D0 -> pi- K+]CC)', DaughtersCuts=d0_decay_products, CombinationCut=d0_comb, MotherCut=d0_vertex) d0_sel = Selection('Sel_D0', Algorithm=d0, RequiredSelections=[Pions, Kaons]) dstar_decay_products = {'pi+': '(TRCHI2DOF < 3) & (PT > 100*MeV)'} dstar_comb = "(ADAMASS('D*(2010)+') < 400*MeV)" dstar_vertex = ("(abs(M-MAXTREE('D0'==ABSID,M)-145.42) < 10*MeV)" '& (VFASPF(VCHI2/VDOF)< 9)') dstar_sel = SimpleSelection('Sel_Dstar', ConfigurableGenerators.CombineParticles, [d0_sel, Pions], DecayDescriptor='[D*(2010)+ -> D0 pi+]cc', DaughtersCuts=dstar_decay_products, CombinationCut=dstar_comb, MotherCut=dstar_vertex) dstar_seq = SelectionSequence('Dstar_Seq', TopSelection=dstar_sel) DaVinci().UserAlgorithms += [dstar_seq.sequence()]
tistostool.TriggerList = triggerlist striptool = tup.addTupleTool("TupleToolStripping") striptool.TriggerList = ["Stripping{0}Decision".format(line1)] # add custom variables with functors hybridtool = tup.addTupleTool('LoKi::Hybrid::TupleTool') hybridtool.Variables = { 'ETA': '0.5 * log( (P+PZ)/(P-PZ) )', 'PHI': 'atan2(PY,PX)' } # refit PVs with exclusion of our tracks of interest tup.ReFitPVs = True # add ntuple to the list of running algorithms DaVinci().UserAlgorithms += [tup] # Filter events for faster processing from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code="HLT_PASS_RE('Stripping{0}Decision')".format(line1)) DaVinci().EventPreFilters = fltrs.filters('Filters') stream = "AllStreams" #DaVinci().RootInTES = "/Event/{0}".format(stream) DaVinci().InputType = "DST" DaVinci().DataType = "MC{0}".format(year[2:]) DaVinci().Simulation = True DaVinci().Lumi = False DaVinci().PrintFreq = 1000 DaVinci().EvtMax = -1
for l in lines: for f in l.filterMembers(): if not hasattr(f, 'Output'): continue # Remove the last item so we get everything (Particle, relations, # decayVertices, etc... o = '/'.join(f.Output.split('/')[:-1]) outputs.append(o) mykiller = EventNodeKiller("killStripping") #Some default nodes which we will want to kill in all cases nodestokill = outputs + ['Strip', '/Event/Rec/Vertex/Primary'] mykiller.Nodes = nodestokill deathstar = GaudiSequencer("killStrippingSeq") deathstar.Members = [mykiller] # Configure DaVinci DaVinci().InputType = 'DST' DaVinci().DataType = options.datatype DaVinci().Simulation = options.forMC DaVinci().DDDBtag = options.dddb DaVinci().CondDBtag = options.conddb # The sequence for the swimming has to be configured # by hand inserting the node killer before it DaVinci().appendToMainSequence([deathstar]) DaVinci().appendToMainSequence([sc.sequence()]) #uDST writer from DSTWriters.__dev__.Configuration import MicroDSTWriter, microDSTStreamConf from DSTWriters.__dev__.microdstelements import * SwimmingConf = microDSTStreamConf() streamConf = {'default': SwimmingConf} SwimmingElements = [ CloneRecHeader(),
'Hlt2TopoMu3BodyBBDT', 'Hlt2TopoMu4BodyBBDT', 'Hlt2TopoE2BodyBBDT', 'Hlt2TopoE3BodyBBDT', 'Hlt2TopoE4BodyBBDT', 'Hlt2TopoRad2BodyBBDT', 'Hlt2TopoRad2plus1BodyBBDT', 'Hlt2IncPhi', 'Hlt2IncPhiSidebands'])) args = argparser.parse_args() linename = stripping_line_name('Pi', args.baryon) strippingList = [stripping_line_name(bachelor, baryon) for bachelor in 'Pi', 'K' for baryon in 'Lc', 'Xic'] dv = DaVinci() dv.TupleFile = 'DVTuples.root' dv.HistogramFile = 'DVHistos.root' dv.Lumi = True dv.configure_data_opts(get_data_opts(args.datafile)) # Substitute PID of the head if it's Xib -> Xic as it's labelled as # Lb -> Xic in the stripping. aliases = ['X_b0', 'X_c', 'p', 'K', 'pi', 'bachelorPi'] linesettings, lineseq = \ dv.add_line_tuple_sequence(get_line_settings(linename, args.version), L0List = args.L0List.split(), HLT1List = args.HLT1List.split(), HLT2List = args.HLT2List.split(), strippingList = strippingList, aliases = aliases,
reports = evt[loc + "/DecReports"] 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 configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ ## needed for job configuration from Configurables import DaVinci from BenderTools.Parser import hasInFile the_year = "2011" if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) rootInTES = '/Event/Charm' from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code=""" HLT_PASS_RE ( 'Stripping.*Xicc.*ForPromptCharm.*' ) """ ) davinci = DaVinci( DataType=the_year, EventPreFilters=fltrs.filters('Filters'), InputType='MDST', RootInTES=rootInTES, Simulation=False, PrintFreq=1000, EvtMax=-1, # HistogramFile='Xic_Histos.root', TupleFile='Xic.root', # Lumi=True, # ) from BenderTools.Utils import silence silence() from Configurables import TrackScaleState state_scale = TrackScaleState( 'StateScale', ) davinci.UserAlgorithms = [state_scale, 'Xi1', 'Xi2'] from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) # # come back to Bender # setData(datafiles, catalogs, castor) # # start Gaudi # gaudi = appMgr() # alg1 = Xicc( 'Xi1', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/Xicc+ForPromptCharm/Particles'] ) alg2 = Xicc( 'Xi2', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/Xicc++ForPromptCharm/Particles'] ) alg2.mode = " [ Xi_cc++ -> Lambda_c+ (K-|K+) (pi+|pi-) (pi+|pi-)]CC" return SUCCESS
#'/lhcb/LHCb/Collision12/DIMUON.DST/00020198/0001/00020198_00016402_1.dimuon.dst', #'/lhcb/LHCb/Collision12/DIMUON.DST/00020198/0001/00020198_00014253_1.dimuon.dst', #'/lhcb/LHCb/Collision12/DIMUON.DST/00020198/0001/00020198_00014185_1.dimuon.dst' ] input = s20 # ## Input data from GaudiConf import IOHelper PFN = 'PFN:root://eoslhcb.cern.ch//eos/lhcb/grid/prod' ioh = IOHelper() ioh.inputFiles ( [ PFN + i for i in input ] ) from Configurables import DaVinci davinci = DaVinci() ##davinci.EvtMax = 100000 davinci.PrintFreq = 100 davinci.EvtMax = 10000 ## davinci.EvtMax = 1000 # davinci.PrintFreq = 1 # davinci.SkipEvents = 37890 # davinci.EvtMax = 20 # davinci.PrintFreq = 100 # davinci.SkipEvents = 1
def configure(datafiles, catalogs=[], castor=False): """ Job configuration """ # ======================================================================= # J/psi # ======================================================================= from PhysSelPython.Wrappers import AutomaticData jpsi_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles' jpsi = AutomaticData(Location=jpsi_location) from StrippingSelections.StrippingPromptCharm import StrippingPromptCharmConf as PC # ====================================== # REMOVED !!! + # ( TRGHOSTPROB < 0.5 ) & + # ====================================== pc = PC('PromptCharm', { 'TrackCuts' : """ ( TRCHI2DOF < 5 ) & ( PT > 250 * MeV ) & in_range ( 2 , ETA , 5 ) """ , 'KaonCuts': ' & ( 0 < PIDK - PIDpi ) ', 'PionCuts': ' & ( 0 < PIDpi - PIDK ) ', } ) pions = pc.pions() kaons = pc.kaons() Preambulo = [ # shortcut for chi2 of vertex fit 'chi2vx = VFASPF(VCHI2) ', # shortcut for the c*tau "from GaudiKernel.PhysicalConstants import c_light", # use the embedded cut for chi2(LifetimeFit)<25 "ctau = BPVLTIME ( 25 ) * c_light " ] from GaudiConfUtils.ConfigurableGenerators import CombineParticles # ======================================================================== # prepare Ds+ # ======================================================================== Ds_alg = CombineParticles( # the decays to be reconstructed DecayDescriptor="[D_s+ -> K- K+ pi+]cc ", # Preambulo=Preambulo, # combination cut : wide mass-cut & PT-cut CombinationCut=""" ( AM12 < 1050 * MeV ) & ( ( ADAMASS('D+') < 60 * MeV ) | ( ADAMASS('D_s+') < 60 * MeV ) ) & ( APT > 900 * MeV ) """ , # mother cut MotherCut=""" ( chi2vx < 25 ) & ( PT > 1 * GeV ) & ( ( ADMASS('D+') < 50 * MeV ) | ( ADMASS('D_s+') < 50 * MeV ) ) """ , # ParticleCombiners={'': 'LoKi::VertexFitter'} ) from PhysSelPython.Wrappers import Selection # make selection Ds_sel = Selection( 'DsForPsiC', Algorithm=Ds_alg, RequiredSelections=[kaons, pions] ) # ======================================================================== BDs_alg = CombineParticles( # the decays to be reconstructed DecayDescriptor="[ B_c+ -> J/psi(1S) D_s+ ]cc ", # Preambulo=Preambulo, # combination cut : CombinationCut=""" in_range ( 5 * GeV , AM , 7 * GeV ) """ , # mother cut MotherCut=""" ( chi2vx < 16 ) & ( ctau > -10 * micrometer ) """ , # ParticleCombiners={'': 'LoKi::VertexFitter'}, ReFitPVs=True ) # make the selection BDs_sel = Selection( 'PsiDs', Algorithm=BDs_alg, RequiredSelections=[jpsi, Ds_sel] ) # ======================================================================== # Bc -> J/psi + 3pi # ======================================================================== from GaudiConfUtils.ConfigurableGenerators import CombineParticles bc_3pi = CombineParticles( DecayDescriptor='[B_c+ -> J/psi(1S) pi+ pi+ pi-]cc', # Preambulo=Preambulo, DaughtersCuts={ "J/psi(1S)": " M < 4.0 * GeV " }, # CombinationCut=""" in_range ( 5.9 * GeV , AM , 6.6 * GeV ) """ , # MotherCut=""" ( chi2vx < 49 ) & ( ctau > 50 * micrometer ) """ , # ParticleCombiners={'': 'LoKi::VertexFitter'}, ReFitPVs=True ) # Bc_3p = Selection( 'Psi3pi', Algorithm=bc_3pi, RequiredSelections=[jpsi, pions] ) # ======================================================================== # Bc -> J/psi + pi # ======================================================================== from GaudiConfUtils.ConfigurableGenerators import CombineParticles bc_pi = CombineParticles( DecayDescriptor='[B_c+ -> J/psi(1S) pi+ ]cc', # Preambulo=Preambulo, DaughtersCuts={ "J/psi(1S)": " M < 4.0 * GeV " }, # CombinationCut=""" in_range ( 5.9 * GeV , AM , 6.6 * GeV ) """ , # MotherCut=""" ( chi2vx < 16 ) & ( ctau > 50 * micrometer ) """ , ParticleCombiners={'': 'LoKi::VertexFitter'}, ReFitPVs=True ) # Bc_1p = Selection( 'Psi1Pi', Algorithm=bc_pi, RequiredSelections=[jpsi, pions] ) from PhysSelPython.Wrappers import SelectionSequence Bc_1PI = SelectionSequence("PSIPi", TopSelection=Bc_1p) Bc_3PI = SelectionSequence("PSI3Pi", TopSelection=Bc_3p) Bc_Ds = SelectionSequence("PSIDs", TopSelection=BDs_sel) # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code="HLT_PASS_RE('Stripping.*DiMuonJpsi2MuMuDeta.*')", VOID_Code=""" 0.5 < CONTAINS('%s') """ % jpsi_location ) # ===================================================================== from Configurables import DaVinci # needed for job configuration the_year = '2011' davinci = DaVinci( EventPreFilters=fltrs.filters('FilterMC'), DataType=the_year, InputType='DST', Simulation=True, PrintFreq=1000, EvtMax=-1, # HistogramFile='BcMC_Histos.root', TupleFile='BcMC.root', ## HistogramFile = 'BcMC1pi_Histos.root' , ## TupleFile = 'BcMC1pi.root' , # # for Ds #DDDBtag = 'MC2011-20120727' , #CondDBtag = 'MC2011-20120727-vc-mu100' , # # for pi # DDDBtag = 'MC11-20111102' , # CondDBtag = 'sim-20111111-vc-md100' , # ## Lumi = True , # ) from Configurables import GaudiSequencer seqDs = GaudiSequencer( 'DS', Members=[Bc_Ds . sequence(), "MCBc2Ds"] ) from Configurables import GaudiSequencer seq1pi = GaudiSequencer( 'Pi1', Members=[Bc_1PI . sequence(), "MCBc1Pi"] ) from Configurables import TrackSmearState state_smear = TrackSmearState( 'StateSmear', ## RootInTES = rootInTES , ) davinci.UserAlgorithms = [state_smear, seqDs] ## davinci.UserAlgorithms = [ seq1pi ] # from Configurables import CondDB # CondDB ( LatestGlobalTagByDataType = the_year ) # ------- decoding set-up start ---------- # from BenderTools.MicroDST import uDstConf # uDstConf ( rootInTES ) # ------- decoding set-up end ----------- # come back to Bender setData(datafiles, catalogs, castor) # # start Gaudi # gaudi = appMgr() alg1 = MCBc( 'MCBc2Ds', # Algorithm name , Inputs=[Bc_Ds.outputLocation()], PP2MCs=['Relations/Rec/ProtoP/Charged'] ) alg2 = MCBc1Pi( 'MCBc1Pi', # Algorithm name , Inputs=[Bc_1PI.outputLocation()], PP2MCs=['Relations/Rec/ProtoP/Charged'] ) return SUCCESS
number of events by which we advanced""" n = 0 while True: appMgr.run(1) if not evt['/Event']: n = 0 break n += 1 dec = evt['/Event/Strip/Phys/DecReports'] if dec.hasDecisionName('Stripping{0}Decision'.format(decision)): break return n dv = DaVinci() dv.DataType = '2012' # Pass file to open as first command line argument inputFiles = [sys.argv[-1]] IOHelper('ROOT').inputFiles(inputFiles) appMgr = GP.AppMgr() evt = appMgr.evtsvc() print_decay = appMgr.toolsvc().create('PrintDecayTreeTool', interface='IPrintDecayTreeTool') decay_finder = appMgr.toolsvc().create('LoKi::Decay', interface='Decays::IDecay')
def configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ ## needed for job configuration from Configurables import DaVinci from BenderTools.Parser import hasInFile the_year = "2011" if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) rootInTES = '/Event/PSIX' # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( VOID_Code=""" ( CONTAINS('/Event/PSIX/Phys/SelPsiKForPsiX/Particles' ) > 0.5 ) | ( CONTAINS('/Event/PSIX/Phys/SelPsiPiForPsiX/Particles' ) > 0.5 ) """ ) davinci = DaVinci( EventPreFilters=fltrs.filters('Filters'), DataType=the_year, InputType='MDST', RootInTES=rootInTES, Simulation=False, PrintFreq=1000, EvtMax=-1, # HistogramFile='Bc_Histos.root', TupleFile='Bc.root', # Lumi=True, # ) from BenderTools.Utils import silence silence() from Configurables import TrackScaleState state_scale = TrackScaleState('StateScale') davinci.UserAlgorithms = [ state_scale, 'B2K', 'B2P' ] from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) # # come back to Bender # setData(datafiles, catalogs, castor) # # start Gaudi # gaudi = appMgr() # alg1 = B2PsiH( 'B2K', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/SelPsiKForPsiX/Particles'] ) # Phys/SelPsiKForPsiX/Particles alg2 = B2PsiH( 'B2P', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/SelPsiPiForPsiX/Particles'] ) return SUCCESS
from Configurables import DaVinci from Configurables import CondDB from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters(STRIP_Code=""" HLT_PASS_RE ( 'StrippingZ02MuMu.*|StrippingLowMultLMR2HHLineDecision' ) """) dv = DaVinci( DataType='2015', InputType='DST', TupleFile='Tuples.root', ## IMPORTANT HistogramFile='Histos.root', ## IMPORTANT Simulation=False, Lumi=True, EventPreFilters=fltrs.filters('Filters'), CondDBtag='cond-20180625-1', DDDBtag='dddb-20180726-3', DQFLAGStag='dq-20170627', EvtMax=-1 ##TODO #EvtMax = 1000, ##TODO #SkipEvents = 340000 ##TODO ) db = CondDB(LatestGlobalTagByDataType='2015') db.LocalTags["DQFLAGS"] = ["herschel-20161018"] from StandardParticles import StdAllNoPIDsKaons as loosekaons from StandardParticles import StdAllLooseMuons as loosemuons from PhysSelPython.Wrappers import SimpleSelection, MergedSelection, DataOnDemand, Selection from GaudiConfUtils.ConfigurableGenerators import FilterDesktop, CombineParticles
def __init__(self, fname, version, linename, datafile, explicitTags = False, useTrackScaleState = True, toolList = ["TupleToolPropertime", "TupleToolKinematic", "TupleToolGeometry", "TupleToolEventInfo", "TupleToolPrimaries", "TupleToolPid", "TupleToolANNPID", "TupleToolTrackInfo", "TupleToolRecoStats",], mcToolList = ['TupleToolMCTruth', 'TupleToolMCBackgroundInfo', 'MCTupleToolPrompt'], L0List = [], HLT1List = [], HLT2List = [], strippingList = [], aliases = {}, labXAliases = False, substitutions = {}, optssuffix = 'settings', extraopts = '', extraoptsfile = '', datatype = None, diracversion = None, force = False) : from Configurables import GaudiSequencer, DaVinci, TupleToolStripping, \ TupleToolTrigger # Defines Simulation, CondDBtag, DDDBtag, InputType, DataType dv = DaVinci() dataopts = get_data_opts(datafile, explicitTags, optssuffix, datatype, diracversion, force) dv.configure_data_opts(dataopts) dv.TupleFile = 'DVTuples.root' dv.HistogramFile = 'DVHistos.root' dv.Lumi = True # Can't use TrackScaleState for 2015 data yet as it's not been calibrated. if useTrackScaleState : dv.add_TrackScaleState() # Defines rootInTES, inputLocation, and decayDescs lineopts = get_line_settings(linename, version, os.path.split(fname)[0], optssuffix, force) lineopts, lineseq = dv.add_line_tuple_sequence(lineopts, toolList, mcToolList, L0List, HLT1List, HLT2List, strippingList, aliases, labXAliases, substitutions) dtt = lineseq.Members[-1] if dataopts['Simulation'] : mcunbseqs = [] for desc in lineopts['decayDescs'] : mcunbseq = dv.add_mc_unbiased_sequence(desc) mcunbseqs.append(mcunbseq) localns = dict(locals()) localns.update(globals()) if extraopts : exec extraopts in localns if extraoptsfile : execfile(os.path.expandvars(extraoptsfile)) in localns objsdict = {'dv' : dv} Script.__init__(self, fname, dv.extraobjs, objsdict)
from Configurables import DaVinci DaVinci().CondDBtag = 'sim-20170721-2-vc-mu100' DaVinci().DDDBtag = 'dddb-20170721-3' DaVinci().InputType = 'DST' DaVinci().DataType = '2016' DaVinci().Simulation = True
def configure(datafiles, catalogs=[], params={}, castor=False): """ Configure the job """ from Configurables import DaVinci ## needed for job configuration from Configurables import EventSelector ## needed for job configuration from Configurables import MessageSvc msg = MessageSvc() msg.setError += [ 'HcalDet.Quality' , 'EcalDet.Quality' , 'MagneticFieldSvc' , 'PropertyConfigSvc' ] from PhysSelPython.Wrappers import AutomaticData jpsi_location = 'FullDSTDiMuonJpsi2MuMuDetachedLine' jpsi = AutomaticData( Location='/Event/AllStreams/Phys/%s/Particles' % jpsi_location) # ============================================================================= from StrippingSelections.StrippingPsiXForBandQ import PsiX_BQ_Conf as PsiX ## 1) redefine stripping configurations def _psi_(self): """ psi(') -> mu+ mu- """ return jpsi PsiX.psi = _psi_ logger.warning("Redefine PsiX .psi") ## 2) unify the pion& kaon selections # ============================================================================= _PionCut_ = """ ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 4 ) & ( TRGHOSTPROB < 0.4 ) & ( PT > 200 * MeV ) & in_range ( 2 , ETA , 4.9 ) & in_range ( 3.2 * GeV , P , 150 * GeV ) & HASRICH & ( PROBNNpi > 0.15 ) & ( MIPCHI2DV() > 9. ) """ _KaonCut_ = """ ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 4 ) & ( TRGHOSTPROB < 0.4 ) & ( PT > 200 * MeV ) & in_range ( 2 , ETA , 4.9 ) & in_range ( 3.2 * GeV , P , 150 * GeV ) & HASRICH & ( PROBNNk > 0.15 ) & ( MIPCHI2DV() > 9. ) """ from GaudiConfUtils.ConfigurableGenerators import FilterDesktop _alg_pi = FilterDesktop( ## Code=_PionCut_, ## ) from PhysSelPython.Wrappers import Selection from StandardParticles import StdAllNoPIDsPions as input_pions pions = Selection( "SelPiForBQ", Algorithm=_alg_pi, RequiredSelections=[input_pions] ) from GaudiConfUtils.ConfigurableGenerators import FilterDesktop _alg_k = FilterDesktop( ## Code=_KaonCut_, ## ) from PhysSelPython.Wrappers import Selection from StandardParticles import StdAllNoPIDsKaons as input_kaons kaons = Selection( "SelKForBQ", Algorithm=_alg_k, RequiredSelections=[input_kaons] ) def _kaons_(self): return kaons def _pions_(self): return pions # ## get the selections # for s in [PsiX]: s.pions = _pions_ s.kaons = _kaons_ logger.warning("Redefine PsiX.kaons ") logger.warning("Redefine PsiX.kaons ") psix = PsiX('PsiX', {}) for s in [psix.psi_3Kpi()]: a = s.algorithm() a.ParticleCombiners = {'': 'LoKi::VertexFitter:PUBLIC'} from PhysSelPython.Wrappers import SelectionSequence sel_seq = SelectionSequence('B2Psi3Kpi', psix . psi_3Kpi()) davinci = DaVinci( InputType = 'DST' , Simulation = True , PrintFreq = 1000 , EvtMax = -1 , Lumi = True , DataType = params['Year'], DDDBtag = params['DDDB'], CondDBtag = params['SIMCOND'], # HistogramFile = 'DVHistos.root' , TupleFile = 'DVNtuples.root' , ) my_name = "Bplus" from Configurables import GaudiSequencer davinci.UserAlgorithms = [ sel_seq.sequence() , my_name ] setData ( datafiles , catalogs , castor ) gaudi = appMgr() print 'seq.outputLocation()= ', sel_seq.outputLocation() # Phys/SelPsi3KPiForPsiX/Particles # create local algorithm: alg = MCAnalysisAlgorithm( my_name, Inputs = [ sel_seq.outputLocation() ] , PP2MCs = [ 'Relations/Rec/ProtoP/Charged' ] ) return SUCCESS
################################################################## from DSTWriters.microdstelements import * from DSTWriters.Configuration import (SelDSTWriter, stripDSTStreamConf, stripDSTElements) SelDSTWriterElements = {'default': stripDSTElements()} SelDSTWriterConf = {'default': stripDSTStreamConf()} if MODE == 'MC': dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='MC', SelectionSequences=sc.activeStreams()) ###################### DAVINCI SETTINGS ############################################ DaVinci().SkipEvents = 0 #1945 DaVinci().PrintFreq = 10000 DaVinci().EvtMax = EVTMAX DaVinci().TupleFile = "DVTuples1.root" DaVinci().HistogramFile = 'DVHistos.root' DaVinci().RootInTES = rootInTES DaVinci().InputType = "MDST" DaVinci().Simulation = False DaVinci().Lumi = True DaVinci().DataType = "2012" CondDB(LatestGlobalTagByDataType='2012') if False: # Add the DST writing algorithms DaVinci().appendToMainSequence([dstWriter.sequence(), printTree]) if True: # Add the ntuple writing algorithms
def configure(datafiles, catalogs=[], castor=True, params={}): """ Configure the job """ from Configurables import DaVinci # needed for job configuration from Configurables import EventSelector # needed for job configuration from Configurables import NTupleSvc from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code=""" HLT_PASS_RE ( 'Stripping.*DiMuonHighMass.*Decision' ) """, VOID_Code=""" 0 < CONTAINS ( '/Event/Dimuon/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles') """ ) filters = fltrs.filters('Filters') filters.reverse() the_year = params["year"] davinci = DaVinci( # noqa DataType=the_year, InputType='MDST', HistogramFile="chib_histos.root", TupleFile="chib_tuples.root", PrintFreq=1000, Lumi=True, EvtMax=-1 ) from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) #========================================================================= # RootInTES = '/Event/ChiB' # RootInTES = '/Event/Bottomonia' RootInTES = '/Event/BOTTOM' #========================================================================= from BenderTools.MicroDST import uDstConf uDstConf(RootInTES) # ========================================================================= from Configurables import Gaudi__IODataManager as IODataManager IODataManager().AgeLimit = 2 # ========================================================================= from Configurables import TrackScaleState state_scale = TrackScaleState('StateScale', RootInTES='/Event/BOTTOM') # ========================================================================= davinci.UserAlgorithms = [ state_scale, "ChibAlg", "UpsilonAlg" ] # ========================================================================= # come back to Bender setData(datafiles, catalogs, castor) gaudi = appMgr() alg_chib = Chib( 'ChibAlg', # Algorithm name , # input particles RootInTES=RootInTES, Inputs=[ # 'Phys/Chi_b/Particles' 'Phys/ChiB/Particles' ], # take care about the proper particle combiner ParticleCombiners={'': 'LoKi::VertexFitter'} ) alg_upsilon = Upsilon( 'UpsilonAlg', # Algorithm name , # input particles RootInTES=RootInTES, Inputs=[ 'Phys/Upsilon/Particles' ], # take care about the proper particle combiner ParticleCombiners={'': 'LoKi::VertexFitter'} ) # ========================================================================= # mainSeq = gaudi.algorithm('GaudiSequencer/DaVinciUserSequence', True) # mainSeq.Members += [state_scale, alg_chib.name(), alg_upsilon.name()] # ========================================================================= return SUCCESS
from Configurables import DaVinci DaVinci().DataType = '2016' DaVinci().Simulation = True DaVinci().TupleFile = 'mc.root' # DaVinci().HistogramFile = 'mc-histo.root' # Additional global flags DaVinci().MoniSequence += ['TRACKER_ONLY'] from Configurables import LHCbApp LHCbApp().CondDBtag = "sim-20170721-2-vc-mu100" LHCbApp().DDDBtag = "dddb-20170721-3"
"""Advance until stripping decision is true, returns number of events by which we advanced""" n = 0 while True: appMgr.run(1) if not evt['/Event']: n = 0 break n += 1 dec = evt['/Event/Strip/Phys/DecReports'] if dec.hasDecisionName('Stripping{0}Decision'.format(decision)): break return n dv = DaVinci() dv.DataType = '2012' # Pass file to open as first command line argument inputFiles = [sys.argv[-1]] IOHelper('ROOT').inputFiles(inputFiles) appMgr = GP.AppMgr() evt = appMgr.evtsvc() print_decay = appMgr.toolsvc().create( 'PrintDecayTreeTool', interface='IPrintDecayTreeTool' ) decay_finder = appMgr.toolsvc().create( 'LoKi::Decay', interface='Decays::IDecay'
#-- Processing Pass Step-133315 #-- StepId : 133315 #-- StepName : Stripping29r2-Merging-DV-v42r7p2-AppConfig-v3r353-LZMA4-Compression #-- ApplicationName : DaVinci #-- ApplicationVersion : v42r7p2 #-- OptionFiles : $APPCONFIGOPTS/Merging/DV-Stripping-Merging.py;$APPCONFIGOPTS/Persistency/Compression-LZMA-4.py #-- DDDB : dddb-20170721-3 #-- CONDDB : cond-20170724 #-- ExtraPackages : AppConfig.v3r353;SQLDDDB.v7r10 #-- Visible : N from Configurables import DaVinci, CondDB DaVinci().DataType = '2017' DaVinci().InputType = 'DST' CondDB().Tags['DDDB'] = 'dddb-20170721-3' from Gaudi.Configuration import * from GaudiConf import IOHelper IOHelper('ROOT').inputFiles([ 'PFN:root://f01-081-129-e.gridka.de:1094/pnfs/gridka.de/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00000361_1.bhadroncompleteevent.dst', 'PFN:root://f01-081-129-e.gridka.de:1094/pnfs/gridka.de/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00000377_1.bhadroncompleteevent.dst', 'PFN:root://f01-080-123-e.gridka.de:1094/pnfs/gridka.de/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00000390_1.bhadroncompleteevent.dst', 'PFN:root://f01-080-123-e.gridka.de:1094/pnfs/gridka.de/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00000401_1.bhadroncompleteevent.dst', 'PFN:root://f01-081-129-e.gridka.de:1094/pnfs/gridka.de/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00003360_1.bhadroncompleteevent.dst', 'PFN:root://ccdcacli265.in2p3.fr:1094/pnfs/in2p3.fr/data/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00001724_1.bhadroncompleteevent.dst', 'PFN:root://ccdcacli264.in2p3.fr:1094/pnfs/in2p3.fr/data/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00001850_1.bhadroncompleteevent.dst', 'PFN:root://ccdcacli265.in2p3.fr:1094/pnfs/in2p3.fr/data/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071671/0000/00071671_00003360_1.bhadroncompleteevent.dst',
def configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ ## needed for job configuration from Configurables import DaVinci from BenderTools.Parser import hasInFile the_year = "2011" if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) rootInTES = '/Event/B2PSIC' davinci = DaVinci( DataType=the_year, InputType='MDST', RootInTES=rootInTES, Simulation=False, PrintFreq=1000, EvtMax=-1, # HistogramFile='Bc_Histos.root', TupleFile='Bc.root', # Lumi=True, # ) from Configurables import MessageSvc msg = MessageSvc() msg.setError += ['HcalDet.Quality', 'EcalDet.Quality', 'MagneticFieldSvc', 'PropertyConfigSvc'] from Configurables import TrackScaleState state_scale = TrackScaleState( 'StateScale', ## RootInTES = rootInTES , ) ##from Configurables import TrackSmearState # state_smear = TrackSmearState ( ## 'StateSmear' , # RootInTES = rootInTES , # ) davinci.UserAlgorithms = [state_scale, ## state_smear , 'BDs', #'B3pi' , #'B1pi' , #'BD0' , #'BDp' ] from Configurables import CondDB #CondDB ( LatestGlobalTagByDataType = the_year ) ## CondDB ( LatestLocalTagsByDataType = [ the_year ] ) from Configurables import CondDBAccessSvc CondDB(). addLayer(CondDBAccessSvc( "myCond", ## ConnectionString = "sqlite_file:SCALE%s.db/LHCBCOND" % the_year, ConnectionString="sqlite_file:$HOME/tmp/SCALE.db/LHCBCOND", DefaultTAG="HEAD")) # ------- decoding set-up start ---------- #from BenderTools.MicroDST import uDstConf #uDstConf ( rootInTES ) # ------- decoding set-up end ----------- # # come back to Bender # setData(datafiles, catalogs, castor) # # start Gaudi # gaudi = appMgr() # alg1 = B2Ds( 'BDs', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/PsiDs/Particles'] ) alg2 = Bc23pi( 'B3pi', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/Psi3pi/Particles'] ) # alg3 = Bc2pi( 'B1pi', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/Psi1Pi/Particles'] ) # alg4 = B2D0( 'BD0', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/PsiD0/Particles'] ) alg5 = B2Dp( 'BDp', # Algorithm name , RootInTES=rootInTES, Inputs=['Phys/PsiDp/Particles'] ) ## mainSeq = gaudi.algorithm ('GaudiSequencer/DaVinciUserSequence', True ) # mainSeq.Members += [ alg1 . name () , ## alg2 . name () , ## alg3 . name () , ## alg4 . name () , # alg5 . name () ] return SUCCESS
#tuple.TupleToolTrigger.Verbose = True 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
#,'Hlt2B2HHLTUnbiasedDecision' ] #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
def configure(datafiles, catalogs=[], params={}, castor=False): """ Configure the job """ from Configurables import DaVinci ## needed for job configuration ## get the builder from StrippingSelections.StrippingPsiXForBandQ import PsiX_BQ_Conf as PSIX ## for MC it is better to exclude PID/DLL/PROBNN cuts builder_configuration = { # 'PionCut' : """ # ( PT > 200 * MeV ) & 'PionCut' : """ ( CLONEDIST > 5000 ) & """ # ( TRGHOSTPROB < 0.5 ) & # ( TRCHI2DOF < 4 ) & # in_range ( 2 , ETA , 5 ) & # in_range ( 3.2 * GeV , P , 150 * GeV ) & # HASRICH & # ( PROBNNpi > 0.1 ) #( MIPCHI2DV() > 4 ) , # ( PT > 200 * MeV ) & 'KaonCut' : """ ( CLONEDIST > 5000 ) & ( TRGHOSTPROB < 0.5 ) & ( TRCHI2DOF < 4 ) & in_range ( 2 , ETA , 5 ) & in_range ( 3.2 * GeV , P , 150 * GeV ) & HASRICH & ( PROBNNk > 0.1 ) """ # ( MIPCHI2DV() > 4 ) } def _kaons_ ( self ) : """ Kaons for B -> psi X lines """ from GaudiConfUtils.ConfigurableGenerators import FilterDesktop ## from StandardParticles import StdAllLooseKaons as inpts from StandardParticles import StdNoPIDsKaons as inpts ## return self.make_selection ( 'Kaon' , FilterDesktop , [ inpts ] , Code = self['KaonCut'] , ) def _pions_ ( self ) : """ Pions for B -> psi X lines """ from GaudiConfUtils.ConfigurableGenerators import FilterDesktop ## from StandardParticles import StdAllLoosePions as inpts from StandardParticles import StdNoPIDsPions as inpts ## return self.make_selection ( 'Pion' , FilterDesktop , [ inpts ] , Code = self['PionCut'] , ) jpsi_name = 'FullDSTDiMuonJpsi2MuMuDetachedLine' psi2_name = 'FullDSTDiMuonPsi2MuMuDetachedLine' from PhysSelPython.Wrappers import AutomaticData jpsi = AutomaticData ( '/Event/AllStreams/Phys/%s/Particles' % jpsi_name ) psi2s = AutomaticData ( '/Event/AllStreams/Phys/%s/Particles' % psi2_name ) # ## merged selectoon for J/psi & psi' # from PhysSelPython.Wrappers import MergedSelection psis = MergedSelection ( 'SelDetachedPsisForBandQ' , RequiredSelections = [ jpsi ] ) def _psi_ ( self ) : """ psi(') -> mu+ mu- """ return psis PSIX.pions = _pions_ PSIX.kaons = _kaons_ PSIX.psi = _psi_ ## use builder builder = PSIX ( 'PsiX' , builder_configuration ) from PhysSelPython.Wrappers import SelectionSequence psi3k = SelectionSequence ( 'Psi3K' , builder.psi_3K () ) psi3kpi = SelectionSequence ( 'Psi3Kpi' , builder.psi_3Kpi () ) from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters ( STRIP_Code = """ HLT_PASS_RE('Stripping.*FullDSTDiMuonJpsi2MuMuDetachedLine.*') """ ) davinci = DaVinci( EventPreFilters = fltrs.filters('WG'), InputType = 'DST' , Simulation = True , PrintFreq = 1000 , EvtMax = -1 , Lumi = True , DataType = params['Year'], DDDBtag = params['DDDB'], CondDBtag = params['SIMCOND'], # HistogramFile = 'DVHistos.root' , TupleFile = 'output_kpipi.root' , ) from Configurables import GaudiSequencer # seq = GaudiSequencer('SEQ1', Members=[psi3k.sequence()]) seq = GaudiSequencer('SEQ2', Members=[psi3kpi.sequence()]) my_name = "Bplus" davinci.UserAlgorithms = [ my_name ] setData ( datafiles , catalogs , castor ) gaudi = appMgr() from StandardParticles import StdAllNoPIDsPions, StdAllNoPIDsKaons # create local algorithm: alg = MCAnalysisAlgorithm( my_name, Inputs = [ StdAllNoPIDsPions.outputLocation(), StdAllNoPIDsKaons.outputLocation(), '/Event/AllStreams/Phys/%s/Particles' % jpsi_name ] , PP2MCs = [ 'Relations/Rec/ProtoP/Charged' ], ReFitPVs = True ) return SUCCESS
streams = get_streams(strippingVersion) dtt = DecayTreeTuple('Dst2010ToD0ToKpipiTuple', Inputs = ['/Event/AllStreams/Phys/D2hhPromptDst2D2RSLine/Particles'], Decay = '[D*(2010)+ -> (D0 -> K- pi+) pi+]CC') ttmc = dtt.addTupleTool('TupleToolMCTruth') ttmc.ToolList += ['MCTupleToolPrompt'] ttmc.ToolList += ['MCTupleToolHierarchy'] dtt.ToolList += ['TupleToolMCTruth', #'TupleToolGeneration' 'TupleToolMCBackgroundInfo' ] dtfVars = { # Index 0 for CHILDFUN meas the particle itself, so 1 is the D0. "DTF_M_D0_BPVIPCHI2" : "DTF_FUN(CHILDFUN(BPVIPCHI2(), 1), False, 'D0')" } decayDesc = dtt.Decay.replace('^', '') dtt.addBranches({'Dst' : decayDesc}) dstLoKiTuple = LoKi__Hybrid__TupleTool('DstLoKiTuple') dstLoKiTuple.Variables = dtfVars dtt.Dst.ToolList += [ "LoKi::Hybrid::TupleTool/DstLoKiTuple" ] dtt.Dst.addTool(dstLoKiTuple) dtt.Dst.InheritTools = True dv = DaVinci('DaVinci', DataType = '2011', TupleFile = 'DVTuples.root', HistogramFile = 'DVHistos.root', UserAlgorithms = [dtt], Lumi = True, DDDBtag = 'Sim08-20130503', CondDBtag = 'Sim08-20130503-vc-md100', Simulation = True) FileCatalog().Catalogs = ["xmlcatalog_file:/afs/cern.ch/work/m/malexand//charm/2011/data/mc/pool_xml_catalog.xml"] dv.EvtMax = 1000
######################################################################\ ## # Flavour tagging Checker: tagcheck = BTaggingChecker("BTaggingChecker") tagcheck.InputLocations = [ location ] tagcheck.TagsLocation = location+"/FlavourTags" tagcheck.OutputLevel = 4 ######################################################################## # # Standard configuration # MessageSvc().Format = "% F%30W%S%7W%R%T %0W%M" DaVinci().EvtMax = 200 # Number of events DaVinci().SkipEvents = 0 # Events to skip DaVinci().PrintFreq = 1 DaVinci().DataType = "2010" DaVinci().Simulation = True DaVinci().DDDBtag = "head-20100119" DaVinci().CondDBtag = "sim-20100222-vc-md100" ######################################################################## DaVinci().MoniSequence = [ cheatsel, tag, # tagcheck ] # The algorithms
def configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ ## needed for job configuration from Configurables import DaVinci the_year = "2011" from BenderTools.Parser import hasInFile if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' elif hasInFile(datafiles, 'Stripping20'): the_year = '2012' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) # Jpsi_location = '/Event/Dimuon/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles' # # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code="HLT_PASS_RE('Stripping.*DiMuonJpsi2MuMuDeta.*')", VOID_Code=""" 0.5 < CONTAINS('%s') """ % Jpsi_location ) # # protection agains ``corrupted'' Stripping 17b DIMUON.DST fltrs_0 = LoKi_Filters( VOID_Code=""" ( EXISTS ( '/Event/DAQ/RawEvent') | EXISTS('/Event/Trigger/RawEvent' ) ) & EXISTS ( '/Event/Strip/Phys/DecReports') """ ) davinci = DaVinci( EventPreFilters=fltrs_0.filters( 'Filters0') + fltrs.filters('Filters'), DataType=the_year, InputType='DST', Simulation=False, PrintFreq=1000, EvtMax=-1, # HistogramFile='Bcc1_Histos.root', TupleFile='Bcc1.root', # Lumi=True, # ) from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) # ------- decoding set-up start ---------- ## from BenderTools.MicroDST import uDstConf ## uDstConf ( rootInTES ) # ------- decoding set-up end ----------- # # dimuon locations in DIMUON.DST # from PhysSelPython.Wrappers import AutomaticData jpsi = AutomaticData(Location=Jpsi_location) # # get the prompt charm # from StrippingSelections.StrippingPromptCharm import StrippingPromptCharmConf as PC # # ====================================== pc = PC('PromptCharm', { 'TrackCuts' : """ ( TRCHI2DOF < 4 ) & ( TRGHOSTPROB < 0.5 ) & ( PT > 250 * MeV ) & in_range ( 2 , ETA , 5 ) """ , 'KaonCuts': ' & in_range ( 3.2 * GeV , P , 100 * GeV ) & ( 2 < PIDK - PIDpi ) ', 'PionCuts': ' & in_range ( 3.2 * GeV , P , 100 * GeV ) & ( 0 < PIDpi - PIDK ) ', } ) pions = pc.pions() kaons = pc.kaons() Preambulo = [ # shortcut for chi2 of vertex fit 'chi2vx = VFASPF(VCHI2) ', # shortcut for the c*tau "from GaudiKernel.PhysicalConstants import c_light", # use the embedded cut for chi2(LifetimeFit)<9 !!! "ctau = BPVLTIME ( 9 ) * c_light " # ATTENTION, 9 is here! ] from GaudiConfUtils.ConfigurableGenerators import CombineParticles # ======================================================================== # B -> J/psi + K pi pi # ======================================================================== from GaudiConfUtils.ConfigurableGenerators import CombineParticles bc_Kpp = CombineParticles( DecayDescriptor='[B+ -> J/psi(1S) K+ pi+ pi-]cc', # Preambulo=Preambulo, DaughtersCuts={ "J/psi(1S)": " in_range( 3.096 * GeV - 45 * MeV , M , 3.096 * GeV + 45 * MeV ) " }, # CombinationCut=""" in_range ( 5.0 * GeV , AM , 5.6 * GeV ) """ , # MotherCut=""" in_range ( 5.1 * GeV , M , 5.5 * GeV ) & ( PT > 1 * GeV ) & ( chi2vx < 49 ) & in_range ( 150 * micrometer , ctau , 1000 * micrometer ) """ , # ParticleCombiners={'': 'LoKi::VertexFitter'}, ReFitPVs=True ) # from PhysSelPython.Wrappers import Selection Bc_Kpp = Selection( 'PsiKpp', Algorithm=bc_Kpp, RequiredSelections=[jpsi, pions, kaons] ) # ======================================================================== # B -> J/psi + K # ======================================================================== from GaudiConfUtils.ConfigurableGenerators import CombineParticles bc_K = CombineParticles( DecayDescriptor='[ B+ -> J/psi(1S) K+ ]cc', # Preambulo=Preambulo, DaughtersCuts={ "J/psi(1S)": " in_range( 3.096 * GeV - 45 * MeV , M , 3.096 * GeV + 45 * MeV ) " }, # CombinationCut=""" in_range ( 5.0 * GeV , AM , 5.6 * GeV ) """ , # MotherCut=""" in_range ( 5.1 * GeV , M , 5.5 * GeV ) & ( PT > 1 * GeV ) & ( chi2vx < 16 ) & in_range ( 150 * micrometer , ctau , 1000 * micrometer ) """ , ParticleCombiners={'': 'LoKi::VertexFitter'}, ReFitPVs=True ) # Bc_K = Selection( 'PsiK', Algorithm=bc_K, RequiredSelections=[jpsi, kaons] ) from PhysSelPython.Wrappers import SelectionSequence Seq_Kpp = SelectionSequence("PSIKPP", TopSelection=Bc_Kpp) Seq_K = SelectionSequence("PSIK", TopSelection=Bc_K) from Configurables import GaudiSequencer davinci.UserAlgorithms = [ GaudiSequencer( 'K', Members=[Seq_K .sequence(), 'B2PsiK']), GaudiSequencer('KPP', Members=[Seq_Kpp.sequence(), 'B2PsiKpp']) ] # # come back to Bender # setData(datafiles, catalogs, castor) # # start Gaudi # gaudi = appMgr() # algKpp = B2Kpp( 'B2PsiKpp', # Algorithm name , Inputs=[Seq_Kpp.outputLocation()] ) algK = B2K( 'B2PsiK', # Algorithm name , Inputs=[Seq_K .outputLocation()] ) return SUCCESS
from Configurables import DaVinci DaVinci().DataType = '2012' DaVinci().Simulation = False DaVinci().TupleFile = 'mu_misid.root' # Additional global flags DaVinci().MoniSequence += ['MU_MISID'] from GaudiConf import IOHelper IOHelper().inputFiles( [ './data/data-2012-md/00041836_00006100_1.semileptonic.dst', # 95 MB './data/data-2012-md/00041836_00011435_1.semileptonic.dst', # 1.3 GB './data/data-2012-md/00041836_00013110_1.semileptonic.dst', # 2.9 GB ], clear=True)
STRIP_Code=" HLT_PASS_RE('Stripping.*(D0|Dh|D2|Ds|Lc|Lambdac)*.*') " # , VOID_Code = " SKIP ( 50 ) " ) the_year = "2011" ## the_year = "2012" fltrs = fltrs.filters('Filters') fltrs.reverse() from Configurables import DaVinci dv = DaVinci( EventPreFilters=fltrs, InputType='DST', DataType=the_year, EvtMax=-1, Lumi=True, HistogramFile="DVHistos.root", # PrintFreq=50000 ) # from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) # dv.appendToMainSequence([udstWriter.sequence()]) # ============================================================================= if '__main__' == __name__: print 80 * '*'
#stck = StrippingTCK(HDRLocation = '/Event/Strip/Phys/DecReports', TCK=0x36112100) # #Configure DaVinci # # Change the column size of Timing table from Configurables import TimingAuditor, SequencerTimerTool TimingAuditor().addTool(SequencerTimerTool,name="TIMER") TimingAuditor().TIMER.NameSize = 60 from Configurables import AuditorSvc, ChronoAuditor AuditorSvc().Auditors.append( ChronoAuditor("Chrono") ) pFreq = 1000 DaVinci().EvtMax = -1 DaVinci().PrintFreq = pFreq from Configurables import StrippingReport sr = StrippingReport(Selections = sc.selections(), ReportFrequency = pFreq) from Configurables import AlgorithmCorrelationsAlg ac = AlgorithmCorrelationsAlg(Algorithms = sc.selections()) DaVinci().HistogramFile = 'DV_stripping_histos.root' DaVinci().appendToMainSequence( [ sc.sequence() ] ) DaVinci().appendToMainSequence( [ sr ] ) #DaVinci().appendToMainSequence( [ ac ] ) DaVinci().appendToMainSequence( [ dstWriter.sequence() ] ) DaVinci().ProductionType = "Stripping"
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]
ApplicationVersion : v42r7p2 OptionFiles : $APPCONFIGOPTS/DaVinci/DV-Stripping29r2-Stripping.py;$APPCONFIGOPTS/DaVinci/DataType-2017.py;$APPCONFIGOPTS/DaVinci/InputType-RDST.py;$APPCONFIGOPTS/DaVinci/DV-RawEventJuggler-0_3-to-4_2.py;$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py DDB : dddb-20170721-3 CONDDB : cond-20170724 ExtraPackages : AppConfig.v3r353;SQLDDDB.v7r10;TMVAWeights.v1r9 Visible : Y ----------------------- Number of Steps 87522 Total number of files: 787698 BHADRON.MDST:87522 BHADRONCOMPLETEEVENT.DST:87522 EW.DST:87522 LEPTONIC.MDST:87522 LOG:87522 CHARM.MDST:87522 CHARMCOMPLETEEVENT.DST:87522 DIMUON.DST:87522 SEMILEPTONIC.DST:87522 Number of events 0 Path: /LHCb/Collision17/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco17/Stripping29r2 ''' from Configurables import DaVinci from Gaudi.Configuration import importOptions importOptions('$APPCONFIGOPTS/DaVinci/DataType-2017.py') DaVinci().InputType = 'MDST' DaVinci().CondDBtag = 'cond-20170724' DaVinci().DDDBtag = 'dddb-20170721-3'
def configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ ## needed for job configuration from Configurables import DaVinci the_year = "2011" from BenderTools.Parser import hasInFile if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Collision13'): the_year = '2013' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' elif hasInFile(datafiles, 'Stripping20r1'): the_year = '2011' elif hasInFile(datafiles, 'Stripping20r1p1'): the_year = '2011' elif hasInFile(datafiles, 'Stripping20r0p1'): the_year = '2012' elif hasInFile(datafiles, 'MC11'): the_year = '2011' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) W_Location = '/Event/AllStreams/Phys/WMuLine/Particles' from PhysSelPython.Wrappers import AutomaticData W_Strip = AutomaticData(Location=W_Location) EW_preambulo = [ "pion_cuts = in_range ( 300 * MeV , PT , 10 * GeV ) & ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 5 ) & ( TRGHOSTPROB < 0.5 ) & ( PERR2/P2 < 0.05**2 ) ", "ptCone_ = SUMCONE ( 0.25 , PT , '/Event/Phys/StdAllLoosePions/Particles' )", "ptCone_2 = SUMCONE ( 0.25 , PT , '/Event/Phys/StdAllLoosePions/Particles' , pion_cuts )", "etCone_ = SUMCONE ( 0.25 , PT , '/Event/Phys/StdLooseAllPhotons/Particles' )", "ptCone = SINFO ( 55001 , ptCone_ , True ) ", "ptCone2 = SINFO ( 55003 , ptCone_2 , True ) ", "etCone = SINFO ( 55002 , etCone_ , True ) ", ] # ======================================================================== # good W # ======================================================================== from GaudiConfUtils.ConfigurableGenerators import FilterDesktop gW = FilterDesktop( Preambulo=EW_preambulo, Code=""" in_range ( 15 * GeV , PT , 100 * GeV ) & ( -1e+10 * GeV < ptCone ) & ( -1e+10 * GeV < ptCone2 ) & ( -1e+10 * GeV < etCone ) """ ) from PhysSelPython.Wrappers import Selection W_Data = Selection( 'W', Algorithm=gW, RequiredSelections=[W_Strip] ) from PhysSelPython.Wrappers import SelectionSequence seq = SelectionSequence("Wseq", TopSelection=W_Data) # counters from Configurables import LoKi__CounterAlg as CounterAlg cnt = CounterAlg( 'CharmEWCounters', Location="Counters/CharmEW", Preambulo=[ "from LoKiPhys.decorators import *", "from LoKiCore.functions import *", "pion_cuts = in_range ( 300 * MeV , PT , 120 * GeV ) & ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 5 ) ", "gamma_cuts = in_range ( 300 * MeV , PT , 10 * GeV ) ", "pions = SOURCE ( '/Event/Phys/StdAllNoPIDsPions/Particles' , pion_cuts ) ", "gammas = SOURCE ( '/Event/Phys/StdLooseAllPhotons/Particles' , gamma_cuts ) ", ], Variables={ "px_c": " pions >> sum ( PX ) ", "py_c": " pions >> sum ( PY ) ", "px_g": " gammas >> sum ( PX ) ", "py_g": " gammas >> sum ( PY ) ", "n_c": " pions >> SIZE ", "g_c": " gammas >> SIZE ", } ) from Configurables import DataOnDemandSvc dod = DataOnDemandSvc() dod.AlgMap['/Event/Counters/CharmEW'] = cnt # ======================================================================== # prefilters for drastical speedup in the reading of input data # ======================================================================== from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code=" HLT_PASS_RE ( 'Stripping.*WMuLine.*Decision' ) " ) davinci = DaVinci( EventPreFilters=fltrs.filters('Filters'), # PREFILTERS DataType=the_year, InputType='DST', Simulation=True, PrintFreq=10000, EvtMax=-1, # HistogramFile='MCW_Histos.root', TupleFile='MCW.root', # ) # connect to DaVinci from Configurables import GaudiSequencer davinci.UserAlgorithms = [ GaudiSequencer('MySeq', Members=[seq.sequence(), 'MCW']) ] # # take care abotu DB-tags: # # try to get the tags from Rec/Header from BenderTools.GetDBtags import getDBTags tags = getDBTags( datafiles[0], castor ) logger.info('Extract tags from DATA : %s' % tags) if tags.has_key('DDDB') and tags['DDDB']: davinci.DDDBtag = tags['DDDB'] logger.info('Set DDDB %s ' % davinci.DDDBtag) if tags.has_key('CONDDB') and tags['CONDDB']: davinci.CondDBtag = tags['CONDDB'] logger.info('Set CONDDB %s ' % davinci.CondDBtag) if tags.has_key('SIMCOND') and tags['SIMCOND']: davinci.CondDBtag = tags['SIMCOND'] logger.info('Set SIMCOND %s ' % davinci.CondDBtag) # # remove excessive printout # from Configurables import MessageSvc msg = MessageSvc() msg.setError += ['HcalDet.Quality', 'EcalDet.Quality', 'MagneticFieldSvc', 'PropertyConfigSvc', 'ToolSvc.L0DUConfig', 'ToolSvc.L0CondDBProvider', 'L0MuonFromRaw', 'IntegrateBeamCrossing'] # # come back to Bender # setData(datafiles, catalogs, castor) # # start Gaudi # gaudi = appMgr() # # more silence # _a = gaudi.tool('ToolSvc.L0DUConfig') _a.OutputLevel = 4 alg = MCW( 'MCW', Inputs=[seq.outputLocation()], PP2MCs=['Relations/Rec/ProtoP/Charged'] ) return SUCCESS
dtt.Inputs = ['/Event/{0}/Phys/{1}/Particles'.format(stream, line)] dtt.Decay = '[D*(2010)+ -> ^(D0 -> ^K- ^K+) ^pi+]CC' # add a kinematic fitter dtt.addBranches({ 'Dstar': '[D*(2010)+ -> (D0 -> K- K+) pi+]CC', }) dtt.Dstar.addTupleTool('TupleToolDecayTreeFitter/ConsD') dtt.Dstar.ConsD.constrainToOriginVertex = True dtt.Dstar.ConsD.Verbose = True dtt.Dstar.ConsD.daughtersToConstrain = ['D0'] # add another fitter, this time we will change a mass hypothesis dtt.Dstar.addTupleTool('TupleToolDecayTreeFitter/ConsDKpi') dtt.Dstar.ConsDKpi.constrainToOriginVertex = True dtt.Dstar.ConsDKpi.Verbose = True dtt.Dstar.ConsDKpi.daughtersToConstrain = ['D0'] # make the hypothesis that actually we had the decay D0->pi+pi- # note that you have to explicitely give both charges # CC does not work here! dtt.Dstar.ConsDKpi.Substitutions = { 'Charm -> (D0 -> ^K- K+) Meson': 'pi-', 'Charm -> (D~0 -> ^K+ K-) Meson': 'pi+', 'Charm -> (D0 -> K- ^K+) Meson': 'pi+', 'Charm -> (D~0 -> K+ ^K-) Meson': 'pi-' } # Configure DaVinci DaVinci().UserAlgorithms += [dtt]
def configure ( datafiles , catalogs = [] , castor = False ) : """ Job configuration """ from Configurables import DaVinci ## needed for job configuration from Configurables import EventSelector ## needed for job configuration from Configurables import MessageSvc msg = MessageSvc() msg.setError += [ 'HcalDet.Quality' , 'EcalDet.Quality' , 'MagneticFieldSvc' , 'PropertyConfigSvc' ] ## # ========================================================================= ## ## 0) Rerun stripping if MC is nt MC/2011 or MC/2012 ## # ========================================================================= ## if '2012' == the_year : ## import StrippingArchive.Stripping20.StrippingDiMuonNew as DiMuon ## import StrippingSettings.Stripping20.LineConfigDictionaries_BandQ as LineSettings ## elif '2011' == the_year : ## import StrippingArchive.Stripping20r1.StrippingDiMuonNew as DiMuon ## import StrippingSettings.Stripping20r1.LineConfigDictionaries_BandQ as LineSettings ## config = LineSettings.FullDSTDiMuon['CONFIG'] ## name = 'FullDST' ## builder = DiMuon.DiMuonConf ( name , config ) ## ## selection ## jpsi = builder.SelJpsi2MuMuDetached # ========================================================================= ## 0) Otherwise use existing stripping ilne # ========================================================================= from PhysSelPython.Wrappers import AutomaticData jpsi_location = 'FullDSTDiMuonJpsi2MuMuDetachedLine' jpsi = AutomaticData ( Location = '/Event/AllStreams/Phys/%s/Particles' % jpsi_location ) # ============================================================================= from StrippingSelections.StrippingPsiXForBandQ import PsiX_BQ_Conf as PsiX # ============================================================================= ## 1) redefine stripping configurations # ============================================================================= # ## redefine psi(') -> mu+ mu- # def _psi_ ( self ) : """ psi(') -> mu+ mu- """ return jpsi PsiX . psi = _psi_ logger.warning ( "Redefine PsiX .psi" ) # ============================================================================= ## 2) unify the pion& kaon selections # ============================================================================= _PionCut_ = """ ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 4 ) & ( TRGHOSTPROB < 0.4 ) & ( PT > 200 * MeV ) & in_range ( 2 , ETA , 4.9 ) & in_range ( 3.2 * GeV , P , 150 * GeV ) & HASRICH & ( PROBNNpi > 0.15 ) & ( MIPCHI2DV() > 9. ) """ _KaonCut_ = """ ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 4 ) & ( TRGHOSTPROB < 0.4 ) & ( PT > 200 * MeV ) & in_range ( 2 , ETA , 4.9 ) & in_range ( 3.2 * GeV , P , 150 * GeV ) & HASRICH & ( PROBNNk > 0.15 ) & ( MIPCHI2DV() > 9. ) """ from GaudiConfUtils.ConfigurableGenerators import FilterDesktop _alg_pi = FilterDesktop ( ## Code = _PionCut_ , ## ) from PhysSelPython.Wrappers import Selection from StandardParticles import StdAllNoPIDsPions as input_pions pions = Selection ( "SelPiForBQ" , Algorithm = _alg_pi , RequiredSelections = [ input_pions ] ) from GaudiConfUtils.ConfigurableGenerators import FilterDesktop _alg_k = FilterDesktop ( ## Code = _KaonCut_ , ## ) from PhysSelPython.Wrappers import Selection from StandardParticles import StdAllNoPIDsKaons as input_kaons kaons = Selection ( "SelKForBQ" , Algorithm = _alg_k , RequiredSelections = [ input_kaons ] ) def _kaons_ ( self ) : return kaons def _pions_ ( self ) : return pions # ## get the selections # for s in [ PsiX ] : s.pions = _pions_ s.kaons = _kaons_ logger.warning ( "Redefine PsiX.kaons " ) logger.warning ( "Redefine PsiX.kaons " ) psix = PsiX ( 'PsiX' , {} ) for s in [ psix.psi_pi() ] : a = s.algorithm () a.ParticleCombiners = { '' : 'LoKi::VertexFitter:PUBLIC' } from PhysSelPython.Wrappers import SelectionSequence sel_seq = SelectionSequence ( 'B2PsiPi' , psix . psi_pi () ) the_year = '2012' davinci = DaVinci ( DataType = the_year , InputType = 'DST' , Simulation = True , PrintFreq = 1000 , EvtMax = -1 , HistogramFile = 'DVHistos.root' , TupleFile = 'DVNtuples.root' , Lumi = True , ## # MC : ## SIMCOND : 'Sim08-20130503-1', 'Sim08-20130503-1-vc-md100' # DDDBtag = "Sim08-20130503-1" , CondDBtag = "Sim08-20130503-1-vc-md100" ) my_name = "Bplus" from Configurables import GaudiSequencer davinci.UserAlgorithms = [ sel_seq.sequence() , my_name ] setData ( datafiles , catalogs , castor ) gaudi = appMgr() print 'seq.outputLocation()= ', sel_seq.outputLocation() # Phys/SelPsi3KPiForPsiX/Particles alg = Jpsi_mu( my_name , ## Algorithm name Inputs = [ sel_seq.outputLocation() ] , PP2MCs = [ 'Relations/Rec/ProtoP/Charged' ] ) return SUCCESS
# Change the column size of Timing table from Configurables import TimingAuditor, SequencerTimerTool TimingAuditor().addTool(SequencerTimerTool, name="TIMER") TimingAuditor().TIMER.NameSize = 60 from Configurables import AuditorSvc, ChronoAuditor AuditorSvc().Auditors.append(ChronoAuditor("Chrono")) from Configurables import StrippingReport sr = StrippingReport(Selections=sc.selections()) sr.OnlyPositive = False from Configurables import AlgorithmCorrelationsAlg ac = AlgorithmCorrelationsAlg(Algorithms=sc.selections()) DaVinci().HistogramFile = 'StrippingHistos.root' DaVinci().TupleFile = 'StrippingTuples.root' DaVinci().EvtMax = -1 DaVinci().Lumi = True DaVinci().PrintFreq = 10000 DaVinci().appendToMainSequence([sc.sequence()]) DaVinci().appendToMainSequence([sr]) DaVinci().appendToMainSequence([ac]) DaVinci().appendToMainSequence([dstWriter.sequence()]) if (len(mdstDstLines) > 0): DaVinci().appendToMainSequence([mdstDstSeq]) DaVinci().ProductionType = "Stripping" DaVinci().DataType = "2012" DaVinci().InputType = "DST" # change the column size of timing table from Configurables import TimingAuditor, SequencerTimerTool
ApplicationName : DaVinci ApplicationVersion : v42r7p2 OptionFiles : $APPCONFIGOPTS/DaVinci/DV-Stripping29r2-Stripping.py;$APPCONFIGOPTS/DaVinci/DataType-2017.py;$APPCONFIGOPTS/DaVinci/InputType-RDST.py;$APPCONFIGOPTS/DaVinci/DV-RawEventJuggler-0_3-to-4_2.py;$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py DDB : dddb-20170721-3 CONDDB : cond-20170724 ExtraPackages : AppConfig.v3r353;Det/SQLDDDB.v7r10;TMVAWeights.v1r9 Visible : Y ----------------------- Number of Steps 87522 Total number of files: 787698 BHADRON.MDST:87522 BHADRONCOMPLETEEVENT.DST:87522 LOG:87522 EW.DST:87522 LEPTONIC.MDST:87522 CHARM.MDST:87522 CHARMCOMPLETEEVENT.DST:87522 DIMUON.DST:87522 SEMILEPTONIC.DST:87522 Number of events 0 Path: /LHCb/Collision17/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco17/Stripping29r2 ''' from Configurables import DaVinci DaVinci().InputType = 'MDST' DaVinci().DataType = '2017' from Configurables import CondDB CondDB().LatestGlobalTagByDataType = DaVinci().getProp('DataType')
from Gaudi.Configuration import * from Configurables import DaVinci,GaudiSequencer DaVinci().DataType = "2012" DaVinci().EvtMax = -1 DaVinci().TupleFile = "bs2st2buk_jpsik.root" DaVinci().Simulation=True from bs2st_bu2kmutau.options.jpsikkselection import * from bs2st_bu2kmutau.options.jpsikktuples import * tuple.Inputs = [ SeqBss2BuK.outputLocation() ] tupleSS.Inputs = [ SeqBss2BuKSS.outputLocation() ] SequenceOS = GaudiSequencer('SequenceOS') SequenceSS = GaudiSequencer('SequenceSS') SequenceOS.Members = [ strippingfilter, SeqBss2BuK.sequence(), tuple ] SequenceSS.Members = [ strippingfilter, SeqBss2BuKSS.sequence(), tupleSS ] DaVinci().UserAlgorithms = [ SequenceOS, SequenceSS ]
D2PimumuSSTuple = tuple.clone("D2PimumuSSTuple") #updated D2PimumuSSTuple.Inputs = [ PiMuMuSSlocation ] #updated D2PimumuSSTuple.Decay = "[D- -> ^pi+ ^mu- ^mu-]CC" #updated D2PimumuSSTuple.Branches = { "D" : "[D- -> pi+ mu- mu-]CC"} #updated D2PimumuSSTuple.addTool(TupleToolDecay, name="D-") #updated D2PimumuSSTuple.P2PVInputLocations = ["Phys/D2XMuMu_PiSSLine/Particle2VertexRelations"] #---------------------------------------- # 2) Run within DaVinci #---------------------------------------- magPol = "Down" year = "12" DaVinci().RootInTES = rootInTes DaVinci().TupleFile = "Stripping21_D2HMuMu"+year+"_Mag"+magPol+"_NTuples.root" DaVinci().EvtMax = -1 DaVinci().DataType = "20"+year DaVinci().Simulation = False DaVinci().UserAlgorithms = [ D2KmumuOSTuple, D2KmumuSSTuple, D2PimumuOSTuple, D2PimumuSSTuple ] # All OK bellow this point DaVinci().InputType = "MDST" # Database tags if year == "12": DaVinci().DDDBtag = 'dddb-20130929-1' #12 Mag Down Strip 21 dddb-20130929-1
# Make sure they are present on full DST streams SelDSTWriterConf['default'].extraItems += caloProtoReprocessLocs dstWriter = SelDSTWriter("MyDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='Filtered', SelectionSequences=sc.activeStreams()) # Add stripping TCK from Configurables import StrippingTCK stck = StrippingTCK(HDRLocation='/Event/Strip/Phys/DecReports', TCK=0x36132110) # # DaVinci Configuration # from Configurables import DaVinci DaVinci().Simulation = True DaVinci().EvtMax = -1 # Number of events DaVinci().HistogramFile = "DVHistos.root" DaVinci().appendToMainSequence([sc.sequence()]) DaVinci().appendToMainSequence([stck]) DaVinci().appendToMainSequence([dstWriter.sequence()]) DaVinci().ProductionType = "Stripping" # Change the column size of Timing table from Configurables import TimingAuditor, SequencerTimerTool TimingAuditor().addTool(SequencerTimerTool, name="TIMER") TimingAuditor().TIMER.NameSize = 60
NTuple=tup_file, # NTuple name Histograms=False, # do not produce Histograms FemtoDST="", ## Calibration KaliDB={ 'name': lambdas, 'ecal': 'ecal' }, ## general DataType='2015', EvtMax=-1, OutputLevel=ERROR) ## ======== input data type - 'SDST' ============ from Configurables import DaVinci DaVinci().InputType = 'DST' # use SDSTs as an input DaVinci().CondDBtag = 'cond-20150828' if '__main__' == __name__: """ Messages in the online get redirected. Setup here the FMC message service @author M.Frank """ #Online = importOnline() #from Gaudi.Configuration import * #from Configurables import CondDB #cdb = CondDB()
contributions and advices from G.Raven, J.van Tilburg, A.Golutvin, P.Koppenburg have been used in the design. By usage of this code one clearly states the disagreement with the campain of Dr.O.Callot et al.: \"No Vanya's lines are allowed in LHCb/Gaudi software.\" """ # ============================================================================= __author__ = " Vanya BELYAEV [email protected] " __version__ = " CVS Tag $Name: not supported by cvs2svn $, version $Revision: 1.2 $ " # ============================================================================= import LoKiExample.LoKi_Decay ## configure our own algorithm: from Configurables import LoKi__GenDecayDescriptor as GenDecay alg = GenDecay ( 'GenDecay' , PP2MCs = [] , InputLocations = [] ) from Configurables import DaVinci DaVinci( UserAlgorithms = [ alg ] ) # ============================================================================= # The END # =============================================================================
tuple.B.addTupleTool(LoKi_constrain) # Fit with B0 mass constraint B0Const = tuple.B.addTupleTool('TupleToolDecayTreeFitter/ConstB0Fit') B0Const.UpdateDaughters = True B0Const.daughtersToConstrain += ['D0', 'B0'] # Fit with B_s0 mass constraint BsConst = tuple.B.addTupleTool('TupleToolDecayTreeFitter/ConstBsFit') BsConst.UpdateDaughters = True BsConst.Substitutions = {'B0': 'B_s0'} BsConst.daughtersToConstrain += ['D0', 'B_s0'] #configure differently depending on which data you use #DaVinci().DataType="2012" #DaVinci().DDDBtag="dddb-20120831" #DaVinci().CondDBtag="cond-20121025" ###################################################### DaVinci().DataType = "2012" #DaVinci().DDDBtag="dddb-20130111" #DaVinci().CondDBtag="cond-20130114" ###################################################### DaVinci().EvtMax = -1 DaVinci().PrintFreq = 100 DaVinci().Simulation = False #changed to false for data #DaVinci().RedoMCLinks = True DaVinci().TupleFile = "B_Data_nTuples.root" #DaVinci().UserAlgorithms = [ NodeKiller, scaler, BMassseq, tuple ] DaVinci().appendToMainSequence([NodeKiller, scaler, BMassseq, tuple]) DaVinci().InputType = 'MDST'
# Create the selection algorithms convLLAlg = AllMuMuGms.x2MuMuGmConvAlg(nameLL, 'Long') convDDAlg = AllMuMuGms.x2MuMuGmConvAlg(nameDD, 'Downstream') caloAlg = AllMuMuGms.x2MuMuGmCaloAlg(nameCalo) dimuAlg = AllMuMuGms.x2MuMuAlg(nameMuMu) # Create the selection sequences convLLSeq = SelectionSequence('RecoLL', TopSelection=convLLAlg) convDDSeq = SelectionSequence('RecoDD', TopSelection=convDDAlg) caloSeq = SelectionSequence('RecoCalo', TopSelection=caloAlg) dimuSeq = SelectionSequence('RecoMuMu', TopSelection=dimuAlg) #=============== # Setup DaVinci DaVinci().EvtMax = -1 DaVinci().PrintFreq = 1000 DaVinci().Simulation = False #if jobType.startswith('MC'): DaVinci().Simulation = True #elif jobType.startswith('Data'): DaVinci().Simulation = False DaVinci().Lumi = False DaVinci().DataType = '2016' DaVinci().UserAlgorithms = [convLLSeq, convDDSeq, caloSeq, dimuSeq] #================ # Setup Turbo from Configurables import DstConf, TurboConf from PhysConf.Filters import LoKi_Filters hltFilter = LoKi_Filters( HLT2_Code="HLT_PASS_RE('.*ExoticaPrmptDiMuonTurboDecision.*')") DstConf().Turbo = True
from Configurables import DaVinci, IoHelper DaVinci().InputType = 'DST' DaVinci().TupleFile = 'DVntuple.root' DaVinci().PrintFreq = 1000 DaVinci().DataType = '2012' DaVinci().Simulation = True # Only ask for luminosity information when not using simulated data DaVinci().Lumi = not DaVinci().Simulation DaVinci().EvtMax = 1000 # Use the local input data IOHelper().inputFiles([('root://eoslhcb.cern.ch//eos/lhcb/user/a/apearce/' 'Starterkit/Nov2015/' '00035742_00000001_1.allstreams.dst')], clear=True)
from PhysSelPython.Wrappers import SelectionSequence recSVs_seq = SelectionSequence('recSVs_Seq', TopSelection=recSVs) recMus_seq = SelectionSequence('recMus_Seq', TopSelection=recMus) Jpsi_seq = SelectionSequence('Jpsi_Seq', TopSelection=recJpsi) D0_seq = SelectionSequence('D0_Seq', TopSelection=recD0) Dp_seq = SelectionSequence('Dp_Seq', TopSelection=recDp) Ds_seq = SelectionSequence('Ds_Seq', TopSelection=recDs) Lc_seq = SelectionSequence('Lc_Seq', TopSelection=recLc) D02K3pi_seq = SelectionSequence('D2K3pi0_Seq', TopSelection=recD02K3pi) ########################## # Turbo/DaVinci configuration. from Configurables import DstConf, TurboConf, DaVinci DaVinci().Simulation = False DaVinci().Lumi = True DaVinci().TupleFile = "LumiTuple.root" #DaVinci().appendToMainSequence([genPF, genJB, recPF, recJB]) DaVinci().appendToMainSequence([recPF, recJB]) DaVinci().appendToMainSequence([recSVs_seq.sequence(), recMus_seq.sequence()]) DaVinci().appendToMainSequence([Jpsi_seq.sequence(),D0_seq.sequence(), Dp_seq.sequence(), Ds_seq.sequence(), Lc_seq.sequence(), D02K3pi_seq.sequence()]) ##TODO adding recSVs and recMus changes the daughters of jet objects from smart poniters to Particles DaVinci().DataType = '2017' DaVinci().EventPreFilters = fltrs.filters ('Filters') from Configurables import LumiIntegrateFSR, LumiIntegratorConf LumiIntegrateFSR('IntegrateBeamCrossing').SubtractBXTypes = ['None'] # Configure the BDT tagger. from Configurables import LoKi__BDTTag
The package has been designed with the kind help from Galina PAKHLOVA and Sergey BARSUK. Many bright ideas, contributions and advices from G.Raven, J.van Tilburg, A.Golutvin, P.Koppenburg have been used in the design. By usage of this code one clearly states the disagreement with the campain of Dr.O.Callot et al.: \"No Vanya's lines are allowed in LHCb/Gaudi software.\" """ # ============================================================================= __author__ = " Vanya BELYAEV [email protected] " __version__ = " CVS Tag $Name: not supported by cvs2svn $, version $Revision: 1.2 $ " # ============================================================================= from Gaudi.Configuration import * import LoKiExample.LoKi_Bs2PsiPhi ## configure our own algorithm: from Configurables import LoKi__DecayDescriptor as Decay alg = Decay('Decay', InputLocations=["PsiPhi"]) from Configurables import DaVinci davinci = DaVinci(EvtMax=20) davinci.UserAlgorithms += [alg] # ============================================================================= # The END # =============================================================================
def configure(datafiles, catalogs=[], castor=False, params={}): """ Job configuration """ logger.info("start: params: %s " % params) from BenderTools.Parser import hasInFile the_year = "2011" if params: the_year = params['Year'] logger.info('Year is set from params to be %s ' % the_year) else: if hasInFile(datafiles, 'Collision11'): the_year = '2011' elif hasInFile(datafiles, 'Collision12'): the_year = '2012' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping13'): the_year = '2011' elif hasInFile(datafiles, 'Stripping15'): the_year = '2011' elif hasInFile(datafiles, 'Stripping17'): the_year = '2011' elif hasInFile(datafiles, 'Stripping19'): the_year = '2012' logger.info('Year is set from files to be %s ' % the_year) # # check # if '2011' == the_year and hasInFile(datafiles, 'Collision12'): raise AttributeError, 'Invalid Year %s ' % the_year if '2012' == the_year and hasInFile(datafiles, 'Collision11'): raise AttributeError, 'Invalid Year %s ' % the_year logger.info('Use the Year = %s ' % the_year) # # dimuon locations in DIMUON.DST # Jpsi_det_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles' Jpsi_unb_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuTOSLine/Particles' if hasInFile(datafiles, '/MC/MC11a/'): Jpsi_unb_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuLine/Particles' logger.warning('Rename ``unbised line'' to be %s ' % Jpsi_unb_location) from PhysSelPython.Wrappers import AutomaticData jpsi_det = AutomaticData(Location=Jpsi_det_location) jpsi_unb = AutomaticData(Location=Jpsi_unb_location) # pions : from GaudiConfUtils.ConfigurableGenerators import FilterDesktop alg_pions = FilterDesktop( # Preambulo=["from LoKiPhysMC.decorators import mcMatch"], Code=""" ( PT > 500 * MeV ) & ( CLONEDIST > 5000 ) & ( TRGHOSTPROB < 0.5 ) & ( TRCHI2DOF < 4 ) & in_range ( 2 , ETA , 5 ) & HASRICH & mcMatch( '[B_c+ => ( J/psi(1S) => mu+ mu- ) ^pi+ ]CC' , 1 ) """ , ) ## ( PROBNNpi > 0.10 ) from PhysSelPython.Wrappers import Selection from StandardParticles import StdAllLoosePions pions = Selection( "ThePions", Algorithm=alg_pions, RequiredSelections=[StdAllLoosePions] ) alg_kaons = FilterDesktop( # Preambulo=["from LoKiPhysMC.decorators import mcMatch"], Code=""" ( PT > 500 * MeV ) & ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 4 ) & ( TRGHOSTPROB < 0.5 ) & in_range ( 2 , ETA , 5 ) & HASRICH & mcMatch( '[B+ => ( J/psi(1S) => mu+ mu- ) ^K+ ]CC' , 1 ) """ ) ## ( PROBNNk > 0.10 ) from StandardParticles import StdAllLooseKaons kaons = Selection( "TheKaons", Algorithm=alg_kaons, RequiredSelections=[StdAllLooseKaons] ) # Preambulo = [ # shortcut for chi2 of vertex fit "chi2vx = VFASPF(VCHI2)", # shortcut for the c*tau "from GaudiKernel.PhysicalConstants import c_light", # use the embedded cut for chi2(LifetimeFit)<16 "ctau_25 = BPVLTIME ( 25 ) * c_light ", "mbc_acut = in_range ( 6.050 * GeV , AM , 6.550 * GeV ) ", "mbp_acut = in_range ( 5.100 * GeV , AM , 5.550 * GeV ) ", # mass-cut for beauty particles "mbc_cut = in_range ( 6.100 * GeV , M , 6.500 * GeV ) ", "mbp_cut = in_range ( 5.150 * GeV , M , 5.500 * GeV ) ", # "from LoKiPhysMC.decorators import mcMatch" ] # Bc : from GaudiConfUtils.ConfigurableGenerators import CombineParticles alg_bc = CombineParticles( DecayDescriptor="[B_c+ -> J/psi(1S) pi+ ]cc", DaughtersCuts={ "J/psi(1S)": "mcMatch( '[ B_c+ => ^( J/psi(1S) => mu+ mu- ) pi+ ]CC' , 1 )" }, Preambulo=Preambulo, CombinationCut=" mbc_acut ", MotherCut=""" ( chi2vx < 25 ) & mbc_cut & ( ctau_25 > %s ) & mcMatch( '[ B_c+ => ( J/psi(1S) => mu+ mu- ) pi+ ]CC' , 1 ) """ % ( 40 * micrometer ) ) # B+ : alg_bu = CombineParticles( DecayDescriptor="[B+ -> J/psi(1S) K+ ]cc", DaughtersCuts={ "J/psi(1S)": "mcMatch( '[ B+ => ^( J/psi(1S) => mu+ mu- ) K+ ]CC' , 1 )" }, Preambulo=Preambulo, CombinationCut=" mbp_acut ", MotherCut=""" ( chi2vx < 25 ) & mbp_cut & ( ctau_25 > %s ) & mcMatch( '[ B+ => ( J/psi(1S) => mu+ mu- ) K+ ]CC' , 1 ) """ % ( 40 * micrometer ) ) sel_bc_det = Selection( "TheBc_det", Algorithm=alg_bc, RequiredSelections=[jpsi_det, pions] ) sel_bc_unb = Selection( "TheBc_unb", Algorithm=alg_bc, RequiredSelections=[jpsi_unb, pions] ) sel_bu_det = Selection( "TheB_det", Algorithm=alg_bu, RequiredSelections=[jpsi_det, kaons] ) sel_bu_unb = Selection( "TheB_unb", Algorithm=alg_bu, RequiredSelections=[jpsi_unb, kaons] ) from PhysSelPython.Wrappers import SelectionSequence Bc_det_seq = SelectionSequence("Bc_det", TopSelection=sel_bc_det) Bu_det_seq = SelectionSequence("Bu_det", TopSelection=sel_bu_det) Bc_unb_seq = SelectionSequence("Bc_unb", TopSelection=sel_bc_unb) Bu_unb_seq = SelectionSequence("Bu_unb", TopSelection=sel_bu_unb) # # selection sequence # mode = params['Mode'] mode = mode.upper() if 0 <= mode.find('BC') or 0 <= mode.find('PI'): seqs = [Bc_det_seq, Bc_unb_seq] # seqs = [ Bc_det_seq ] elif 0 <= mode.find('B+') or 0 <= mode.find('K+'): seqs = [Bu_det_seq, Bu_unb_seq] # seqs = [ Bu_det_seq ] else: raise from PhysSelPython.Wrappers import MultiSelectionSequence B_SEQ = MultiSelectionSequence( "B2PSI", Sequences=seqs, ) from DSTWriters.Configuration import (SelDSTWriter, stripMicroDSTStreamConf, stripMicroDSTElements) # Configuration of SelDSTWriter SelDSTWriterConf = { 'default': stripMicroDSTStreamConf(pack=False)} SelDSTWriterElements = { 'default': stripMicroDSTElements(pack=False)} udstWriter = SelDSTWriter( "MyMicroDSTWriter", StreamConf=SelDSTWriterConf, MicroDSTElements=SelDSTWriterElements, OutputFileSuffix='MCBSEQ', SelectionSequences=[B_SEQ] ) # Read only fired events to speed up from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code="HLT_PASS_RE('Stripping.*DiMuonJpsi2MuMu.*')", VOID_Code=""" ( 0.5 < CONTAINS('%s') ) | ( 0.5 < CONTAINS('%s') ) """ % ( Jpsi_det_location , Jpsi_unb_location ) ) # fltrs_0 = LoKi_Filters( VOID_Code=""" ( EXISTS ( '/Event/DAQ/RawEvent') | EXISTS('/Event/Trigger/RawEvent' ) ) & EXISTS ( '/Event/Strip/Phys/DecReports') & ( RECSUMMARY ( 0 , -1 ) > 0.5 ) """ ) # # finally: DaVinci # ## needed for job configuration from Configurables import DaVinci davinci = DaVinci( EventPreFilters=fltrs_0.filters( 'Filters0') + fltrs.filters('Filters1'), DataType=the_year, InputType='MDST', Simulation=True, PrintFreq=1000, EvtMax=-1, # HistogramFile='MCBc_Histos.root', TupleFile='MCBc.root', # DDDBtag=params['DDDB'], CondDBtag=params['SIMCOND'], # Lumi=False # True , # ) davinci.appendToMainSequence([udstWriter.sequence()]) # # come back to Bender # setData(datafiles, catalogs, castor) from BenderTools.Utils import silence silence() # gaudi = appMgr() # logger.info("end: params: %s " % params) return SUCCESS
#! /usr/:bin/env python # CONFIGURE DAVINCI (GENERAL CONFIGURATION OF THE JOB) from Configurables import DaVinci import GaudiPython import os.path import ROOT import numpy as np import os import sys DaVinci().EvtMax = 0 DaVinci().DataType = "2012" DaVinci().Simulation = True ## These are for data tags (magnet up or down?) DaVinci().DDDBtag = "dddb-20130929-1" DaVinci().CondDBtag = "sim-20130522-1-vc-md100" ## INPUT DSTS, POTENTIALLY ADD MORE (estan todas incorporadas agora) dst_file = [] for i in xrange(1,34): i = str(i) if int(i)<10: dst_file_name = '/scratch13/MC2012MB/00040748_0000000'+i+'_2.AllStreams.dst' else: dst_file_name = '/scratch13/MC2012MB/00040748_000000'+i+'_2.AllStreams.dst' if os.path.isfile(dst_file_name): dst_file.append(dst_file_name) DaVinci().Input = dst_file gaudi = GaudiPython.AppMgr()
""" % ups_name ) # ======================================================================== # The last step: DaVinci & DB # ======================================================================== ##the_year = '2012' the_year = '2011' from Configurables import DaVinci davinci = DaVinci( # DataType=the_year, # ATTENTION !! # EventPreFilters=fltrs.filters('Filters'), InputType="DST", EvtMax=-1, PrintFreq=10000, Lumi=True, ) davinci.appendToMainSequence([uDstWriter.sequence()]) from Configurables import CondDB CondDB(LatestGlobalTagByDataType=the_year) # ATTENTION !! # TEST data sample # input = [ # '/lhcb/LHCb/Collision12/DIMUON.DST/00020198/0001/00020198_00012742_1.dimuon.dst',
from PhysSelPython.Wrappers import SelectionSequence #recSVs_seq = SelectionSequence('recSVs_Seq', TopSelection=recSVs) #recMus_seq = SelectionSequence('recMus_Seq', TopSelection=recMus) Jpsi_seq = SelectionSequence('Jpsi_Seq', TopSelection=recJpsi) D0_seq = SelectionSequence('D0_Seq', TopSelection=recD0) Dp_seq = SelectionSequence('Dp_Seq', TopSelection=recDp) Ds_seq = SelectionSequence('Ds_Seq', TopSelection=recDs) Lc_seq = SelectionSequence('Lc_Seq', TopSelection=recLc) D02K3pi_seq = SelectionSequence('D2K3pi0_Seq', TopSelection=recD02K3pi) ########################## # Turbo/DaVinci configuration. from Configurables import DstConf, TurboConf, DaVinci DaVinci().Simulation = True DaVinci().Lumi = True DaVinci().TupleFile = "LumiTuple.root" #DaVinci().appendToMainSequence([genPF, genJB, recPF, recJB]) DaVinci().appendToMainSequence([recPF, recJB]) #DaVinci().appendToMainSequence([recSVs_seq.sequence(), recMus_seq.sequence()]) DaVinci().appendToMainSequence([Jpsi_seq.sequence(), D0_seq.sequence(), Dp_seq.sequence(), Ds_seq.sequence(), Lc_seq.sequence(), D02K3pi_seq.sequence()]) ##TODO adding recSVs and recMus changes the daughters of jet objects from smart poniters to Particles DaVinci().DataType = '2016' #DaVinci().EventPreFilters = fltrs.filters ('Filters') from Configurables import LumiIntegrateFSR, LumiIntegratorConf LumiIntegrateFSR('IntegrateBeamCrossing').SubtractBXTypes = ['None'] # Configure the BDT tagger. from Configurables import LoKi__BDTTag
def configure(datafiles, catalogs=[], params={}, castor=False): from Configurables import DaVinci from Configurables import EventSelector from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( VOID_Code=""" 0 < CONTAINS ('/Event/PSIX/Phys/SelPsi3KForPsiX/Particles') """ ) filters = fltrs.filters('Filters') the_year = '2011' daVinci = DaVinci( # EventPreFilters = filters , # DataType = params['year'] , InputType = 'MDST' , RootInTES = 'PSIX' , # PrintFreq = 1000 , EvtMax = -1 , # TupleFile='Bu2JpsiKKK.root', # Lumi=True # ) daVinci.UserAlgorithms = [ 'JpsiKKK' ] from Configurables import CondDB CondDB ( LatestGlobalTagByDataType = the_year ) # ## define input data # setData(datafiles, catalogs, castor) # ## suppress some extra printput # from BenderTools.Utils import silence silence() # ## get the actual application manager (create if needed) # gaudi = appMgr() # ## create local algorithm: # alg = Bu2JpsiKKK ( 'JpsiKKK', # input particles : RootInTES='/Event/PSIX', Inputs=['Phys/SelPsi3KForPsiX/Particles'] ) return SUCCESS
def configure ( inputdata , ## the list of input files catalogs = [] , ## xml-catalogs (filled by GRID) castor = False , ## use the direct access to castor/EOS ? params = {} ) : from PhysSelPython.Wrappers import AutomaticData jpsi_name = 'FullDSTDiMuonJpsi2MuMuDetachedLine' psi2_name = 'FullDSTDiMuonPsi2MuMuDetachedLine' jpsi = AutomaticData ( '/Event/AllStreams/Phys/%s/Particles' % jpsi_name ) psi2s = AutomaticData ( '/Event/AllStreams/Phys/%s/Particles' % psi2_name ) from PhysSelPython.Wrappers import MergedSelection psis = MergedSelection ( 'SelDetachedPsisForBandQ' , RequiredSelections = [ jpsi , psi2s ] ) from StrippingSelections.StrippingPsiXForBandQ import PsiX_BQ_Conf as PsiX from StrippingSelections.StrippingPsiX0 import PsiX0Conf as PsiX0 def _psi_ ( self ) : """ psi(') -> mu+ mu- """ return psis PsiX0 . psi = _psi_ PsiX . psi = _psi_ logger.warning ( "Redefine PsiX .psi" ) psix = PsiX ( 'PsiX' , {} ) psix0 = PsiX0 ( 'PsiX0' , {} ) for s in ( psix.psi_pi () , psix.psi_K () , # psix.psi_2pi () , psix.psi_2K () , psix.psi_2Kpi () , ## psix.psi_3pi () , psix.psi_3K () , psix.psi_3Kpi () , ## psix.psi_4pi () , psix.psi_4Kpi () , psix.psi_4K () , ## psix.psi_5pi () , psix.psi_5K () , psix.psi_5Kpi () , ## psix.psi_6pi () , psix.psi_6Kpi () , ## psix.psi_7pi () , psix.psi_7Kpi () , ## # Lb psix.psi_pK () , psix.psi_ppi () , psix.psi_pKpipi () , ## # 2protons psix.psi_pp () , psix.psi_pppi () , psix.psi_ppK () , psix.psi_pppipi () , psix.psi_ppKpipi () , psix.psi_pppipipi () , ## ) : a = s.algorithm () a.ParticleCombiners = { '' : 'LoKi::VertexFitter:PUBLIC' } # a.MaxCandidates = 2000 a.StopAtMaxCandidates = True a.StopIncidentType = 'ExceedsCombinatoricsLimit' # from PhysSelPython.Wrappers import MultiSelectionSequence from PhysSelPython.Wrappers import SelectionSequence psi_x = MultiSelectionSequence ( "PSIX" , Sequences = [ ## channels with chic # SelectionSequence ( 'B2CHICK' , psix0 . b2chicK () ) , SelectionSequence ( 'B2CHICKK' , psix0 . b2chicKK () ) , SelectionSequence ( 'B2CHICKPi' , psix0 . b2chicKpi () ) , SelectionSequence ( 'B2CHICKPiPi' , psix0 . b2chicKpipi () ) , SelectionSequence ( 'B2CHICPiPi' , psix0 . b2chicpipi () ) , # SelectionSequence ( 'BC2CHICPi' , psix0 . bc2chicpi () ) , SelectionSequence ( 'Lb2CHICPi' , psix0 . lb2chicpK () ) , ] ) ## import DaVinci from Configurables import DaVinci ## delegate the actual configuration to DaVinci dv = DaVinci ( DataType = '2012' , InputType = 'DST' , Simulation = True , Lumi = False , TupleFile = 'Tuples.root' ## IMPORTANT ) ## add the name of Bender algorithm into User sequence sequence alg_name = 'HistosAndTuples' dv.UserAlgorithms += [ psi_x.sequence(), 'TrackScaleState', alg_name ] ## define the input data setData ( inputdata , catalogs , castor ) ## get/create application manager gaudi = appMgr() ## (1) create the algorithm with given name alg = HistosAndTuples ( alg_name , Inputs = [ 'Phys/SelB2ChicPiPiForPsiX0/Particles' ] ) return SUCCESS
def configure(datafiles, catalogs=[], castor=True, params=None): """ Configure the job """ from Configurables import DaVinci # needed for job configuration # from Configurables import EventSelector # needed for job configuration # from Configurables import NTupleSvc from PhysConf.Filters import LoKi_Filters fltrs = LoKi_Filters( STRIP_Code=""" HLT_PASS_RE ( 'Stripping.*DiMuonHighMass.*Decision' ) """, VOID_Code=""" 0 < CONTAINS ( '/Event/AllStreams/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles') """ ) filters = fltrs.filters('Filters') filters.reverse() from PhysSelPython.Wrappers import AutomaticData, Selection, SelectionSequence # # defimuon in stripping DST # # DiMuLocation = # '/Event/Dimuon/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles' DiMuLocation = '/Event/AllStreams/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles' from PhysSelPython.Wrappers import AutomaticData DiMuData = AutomaticData(Location=DiMuLocation) # ========================================================================= # Upsilon -> mumu, cuts by Giulia Manca # ======================================================================== from GaudiConfUtils.ConfigurableGenerators import FilterDesktop UpsAlg = FilterDesktop( Code=""" ( M > 7 * GeV ) & DECTREE ('Meson -> mu+ mu-' ) & CHILDCUT( 1 , HASMUON & ISMUON ) & CHILDCUT( 2 , HASMUON & ISMUON ) & ( MINTREE ( 'mu+' == ABSID , PT ) > 1 * GeV ) & ( MAXTREE ( ISBASIC & HASTRACK , TRCHI2DOF ) < 4 ) & ( MINTREE ( ISBASIC & HASTRACK , CLONEDIST ) > 5000 ) & ( VFASPF ( VPCHI2 ) > 0.5/100 ) & ( abs ( BPV ( VZ ) ) < 0.5 * meter ) & ( BPV ( vrho2 ) < ( 10 * mm ) ** 2 ) """, Preambulo=[ "vrho2 = VX**2 + VY**2" ], ReFitPVs=True ) UpsSel = Selection( 'UpsSel', Algorithm=UpsAlg, RequiredSelections=[DiMuData] ) # ========================================================================= # chi_b -> Upsilon gamma # ======================================================================== from GaudiConfUtils.ConfigurableGenerators import CombineParticles ChibCombine = CombineParticles( DecayDescriptor="chi_b1(1P) -> J/psi(1S) gamma", DaughtersCuts={ "gamma": " ( 350 * MeV < PT ) & ( CL > 0.01 ) " }, CombinationCut=""" ( AM - AM1 ) < 3 * GeV """, MotherCut=" PALL", # # we are dealing with photons! # ParticleCombiners={ '': 'LoKi::VertexFitter' } ) from StandardParticles import StdLooseAllPhotons # needed for chi_b ChibSel1 = Selection( 'PreSelChib', Algorithm=ChibCombine, RequiredSelections=[UpsSel, StdLooseAllPhotons] ) from GaudiConfUtils.ConfigurableGenerators import Pi0Veto__Tagger TagAlg = Pi0Veto__Tagger( ExtraInfoIndex=25001, # should be unique! MassWindow=20 * MeV, # cut on delta-mass MassChi2=-1, # no cut for chi2(mass) ) ChibSel2 = Selection( 'Chi_b', Algorithm=TagAlg, RequiredSelections=[ChibSel1] ) Chib = SelectionSequence("ChiB", TopSelection=ChibSel2) # print 'OUTPUT!!!' , output_loc # ========================================================================= # Upsilons # ======================================================================== Ups = SelectionSequence("UpsSelSeq", TopSelection=UpsSel) # ======================================================================== from Configurables import GaudiSequencer myChibSeq = GaudiSequencer('MyChibSeq') myChibSeq.Members = [Chib.sequence()] + ["ChibAlg"] myUpsSeq = GaudiSequencer('MyUpsSeq') myUpsSeq.Members = [Ups.sequence()] + ["UpsilonAlg"] davinci = DaVinci( EventPreFilters=filters, DataType='2011', Simulation=True, InputType='DST', HistogramFile="chib_histos.root", TupleFile="chib_tuples.root", PrintFreq=1000, Lumi=True, EvtMax=-1 ) davinci.UserAlgorithms = [myChibSeq, myUpsSeq] # ========================================================================= from Configurables import Gaudi__IODataManager as IODataManager IODataManager().AgeLimit = 2 # ========================================================================= # come back to Bender setData(datafiles, catalogs, castor) gaudi = appMgr() alg_chib = ChibMC( 'ChibAlg', # Algorithm name , # input particles Inputs=[ Chib.outputLocation() ], # take care about the proper particle combiner ParticleCombiners={'': 'LoKi::VertexFitter'} ) alg_ups = UpsilonMC( 'UpsilonAlg', # Algorithm name , # input particles Inputs=[ Ups.outputLocation() ], # take care about the proper particle combiner ParticleCombiners={'': 'LoKi::VertexFitter'} ) alg_chib.nb = alg_ups.nb = params['nb'] alg_chib.np = alg_ups.np = params['np'] # ========================================================================= return SUCCESS
tt_strip, #"TupleToolTISTOS", #"TupleToolTrigger", "TupleToolPropertime", "TupleToolKinematic", "TupleToolGeometry", "TupleToolEventInfo", "TupleToolPrimaries", "TupleToolPid", "TupleToolTrackInfo", "TupleToolRecoStats", #"TupleToolGeneration" ] dv = DaVinci() dv.Lumi = True dv.HistogramFile = "DVHistos.root" # Histogram file dv.TupleFile = "DVNtuples.root" # Ntuple bachelors = 'K', 'Pi' charmBaryons = 'Lc', 'Xic' baryonSymbols = {'Lc' : 'Lambda_cplus', 'Xic' : 'Xi_cplus'} baryonDescriptors = {'Lc' : 'Lambda_c+', 'Xic' : 'Xi_c+'} bachelorDescriptors = {'Pi' : 'pi-', 'K' : 'K-'} oppositeBachelors = {'Pi' : 'K-', 'K' : 'pi-'}