"P/1000": ('momentum', 0, 150), "PT/1000": ('pt_%1%', 0, 5, 750), "M": ('mass in MeV_%1%_%2%_%3%', 2.8 * Units.GeV, 3.2 * Units.GeV) } # JpsiFilterSel = Selection(name='JpsiFilterSel', Algorithm=_jpsiFilter, RequiredSelections=[JpsiSel]) JpsiSeq = SelectionSequence('SeqJpsi', TopSelection=JpsiFilterSel) seq = JpsiSeq.sequence() dv = DaVinci() dv.PrintFreq = 10 dv.HistogramFile = "DVHistos_Strip.root" dv.EvtMax = -1 dv.DataType = "MC09" dv.Simulation = True dv.RedoMCLinks = False dv.UserAlgorithms = [seq] dv.InputType = 'DST' # MC09 #dv.Input = [" DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000001_1.dst' TYP='POOL_ROOTTREE' OPT='READ'"] dv.Input = [ "DATAFILE='PFN:/castor/cern.ch/user/j/jpalac/StripDST/MC09/DaVinci_v24r3p1/Sel.Jpsi.dst' TYP='POOL_ROOTTREE' OPT='READ'" ] ApplicationMgr().ExtSvc += ["NTupleSvc"] ApplicationMgr().HistogramPersistency = "ROOT"
################ from Configurables import DaVinci, L0Conf dv = DaVinci() dv.DataType = '2012' dv.EvtMax = -1 for line_info in line_infos: print line_info tuple = makeDecayTreeTuple( line_info[0], line_info[1], line_info[2], line_info[3] ) dv.UserAlgorithms += [ tuple ] dv.Simulation = False #from Configurables import CondDB #CondDB(UseOracle = True) DaVinci().DDDBtag = "dddb-20120831" DaVinci().CondDBtag = "cond-20121211" DaVinci().EnableUnpack = ['Stripping','Reconstruction'] dv.Lumi = True dv.HistogramFile = "DVHistos.root" # Histogram file dv.TupleFile = "DVNtuples.root" # Ntuple # to test rejecting hot CALO cells #from Gaudi.Configuration import * #def recomputeL0Calo(): # from Configurables import L0CaloAlg # DataOnDemandSvc().AlgMap[ 'Trig/L0/FullCalo' ] = L0CaloAlg( WriteOnTES = True , WriteBanks = False ) # DataOnDemandSvc().AlgMap[ 'Trig/L0/Calo' ] = L0CaloAlg( WriteOnTES = True , WriteBanks = False ) # #appendPostConfigAction(recomputeL0Calo)
def configure(config, colors=False): """Configure the application from parser data """ # if config.OutputLevel <= 3 and not config.Quiet: _vars = vars(config) _keys = _vars.keys() _keys.sort() logger.info('Configuration:') for _k in _keys: logger.info(' %15s : %-s ' % (_k, _vars[_k])) ## redefine output level for 'quiet'-mode if config.OutputLevel > 5: config.OutputLevel = 5 logger.info('set OutputLevel to be %s ' % config.OutputLevel) if config.OutputLevel < 0: config.OutputLevel = 0 logger.info('set OutputLevel to be %s ' % config.OutputLevel) if config.Quiet and 4 > config.OutputLevel: config.OutputLevel = 4 logger.info('set OutputLevel to be %s ' % config.OutputLevel) from BenderTools.Utils import silence silence() # ## use coherent C++/Python logging levels setLogging(config.OutputLevel) # # some sanity actions: # config.RootInTES = config.RootInTES.strip() config.files = [i.strip() for i in config.files if i.strip()] # ## start the actual action: # from Configurables import DaVinci # ## get the file type for the file extension # from BenderTools.Parser import dataType pyfiles = [i for i in config.files if len(i) == 3 + i.rfind('.py')] files = [i for i in config.files if i not in pyfiles] from BenderTools.Parser import fileList for f in config.FileList: files += fileList(f) if not files and not config.ImportOptions: raise AttributeError('No data files are specified!') ## get some info from file names/extensision dtype, simu, ext = None, None, None if files: dtype, simu, ext = dataType(files) logger.debug('DataType,Simu&extension:"%s",%s,"%s" (from files)' % (dtype, simu, ext)) elif config.ImportOptions: from Bender.DataUtils import evtSelInput ifiles = evtSelInput(config.ImportOptions) dtype, simu, ext = dataType(ifiles) logger.debug( 'DataType,Simu&extension:"%s",%s&"%s" (from EventSelector)' % (dtype, simu, ext)) if '2013' == dtype: logger.info('Data type 2013 is redefined to be 2012') dtype = '2012' # if ext in ('gen', 'xgen', 'GEN', 'XGEN', 'ldst', 'LDST') and not simu: simu = True if dtype and dtype != config.DataType: logger.info('Redefine DataType from %s to %s ' % (config.DataType, dtype)) config.DataType = dtype if simu and not config.Simulation: logger.info('Redefine Simulation from %s to %s ' % (config.Simulation, simu)) config.Simulation = simu if config.Simulation and config.Lumi: logger.info('suppress Lumi for Simulated data') config.Lumi = False ## summary information (when available) from Configurables import LHCbApp LHCbApp().XMLSummary = 'summary.xml' daVinci = DaVinci( DataType=config.DataType, Simulation=config.Simulation, Lumi=config.Lumi, ) if hasattr(config, 'TupleFile') and config.TupleFile: logger.info('Define TupleFile to be %s' % config.TupleFile) daVinci.TupleFile = config.TupleFile if hasattr(config, 'HistoFile') and config.HistoFile: logger.info('Define HistogramFile to be %s' % config.HistoFile) daVinci.HistogramFile = config.HistoFile if config.MicroDST or 'mdst' == ext or 'MDST' == ext or 'uDST' == ext: logger.info('Define input type as micro-DST') daVinci.InputType = 'MDST' # ## try to guess RootInTES # from BenderTools.Parser import hasInFile if hasInFile(files, 'CHARM.MDST') and not config.RootInTES: config.RootInTES = '/Event/Charm' logger.info('RootInTES is set according to CHARM.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'LEPTONIC.MDST') and not config.RootInTES: config.RootInTES = '/Event/Leptonic' logger.info('RootInTES is set according to LEPTONIC.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'BHADRON.MDST') and not config.RootInTES: config.RootInTES = '/Event/Bhadron' logger.info('RootInTES is set according to BHADRON.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'PID.MDST') and not config.RootInTES: config.RootInTES = '/Event/PID' logger.info('RootInTES is set according to PID.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'PSIX.MDST') and not config.RootInTES: config.RootInTES = '/Event/PSIX' logger.info('RootInTES is set according to PSIX.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'PSIX0.MDST') and not config.RootInTES: config.RootInTES = '/Event/PSIX0' logger.info('RootInTES is set according to PSIX0.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'BOTTOM.MDST') and not config.RootInTES: config.RootInTES = '/Event/BOTTOM' logger.info('RootInTES is set according to BOTTOM.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'TURBO.MDST') and not config.RootInTES: config.RootInTES = '/Event/Turbo' logger.info('RootInTES is set according to TURBO.MDST') daVinci.InputType = 'MDST' elif hasInFile(files, 'ALLSTREAMS.MDST') and not config.RootInTES: config.RootInTES = '/Event/AllStreams' logger.info('RootInTES is set according to ALLSTREAMS.MDST') daVinci.InputType = 'MDST' if config.RootInTES and 0 != config.RootInTES.find('/Event'): config.RootInTES = '/Event/' + config.RootInTES if config.RootInTES and '/' == config.RootInTES[-1]: config.RootInTES = config.RootInTES[:-1] if config.RootInTES and '/Event' != config.RootInTES: daVinci.RootInTES = config.RootInTES # ## check for Grid-access # if config.Grid: from Bender.DataUtils import hasGridProxy if not hasGridProxy(): logger.warning( 'GRID proxy is not available, switch off GRID-lookup') config.Grid = '' ## SWITCH OFF Grid-lookup if not config.Simulation and config.DataType in ('2010', '2011', '2012', '2013', '2015'): # ## try to use the latest available tags: # from Configurables import CondDB ## CondDB ( UseLatestTags = [ options.DataType ] ) ## logger.info('Use latest tags for %s' % options.DataType ) CondDB(LatestGlobalTagByDataType=config.DataType) logger.info('Use latest global tag for data type %s' % config.DataType) if config.Simulation: # ## try to get the tags from Rec/Header from BenderTools.GetDBtags import useDBTagsFromData tags = useDBTagsFromData(files, castor=config.Castor, grid=config.Grid, daVinci=daVinci, importOpts=config.ImportOptions, catalogs=config.XmlCatalogs) if config.IgnoreDQFlags: logger.info('DataQuality flags will be ignored') daVinci.IgnoreDQFlags = config.IgnoreDQFlags ## specific action for (x)gen files if ext in ('gen', 'xgen', 'GEN', 'XGEN'): from BenderTools.GenFiles import genAction genAction(ext) ## prepare to copy good/marked/tagged evenst if hasattr(config, 'OutputFile') and config.OutputFile: from BenderTools.GoodEvents import copyGoodEvents if 0 <= config.OutputFile.find('.'): copyGoodEvents(config.OutputFile) else: copyGoodEvents("%s.%s" % (config.OutputFile, ext)) ## OutptuLevel from Configurables import MessageSvc msgSvc = MessageSvc(OutputLevel=config.OutputLevel) ## import options (if specified) for i in config.ImportOptions: logger.info("Import options from file %s'" % i) from Gaudi.Configuration import importOptions importOptions(i) if colors: logger.debug('Add colorization to MessageSvc') from Configurables import MessageSvc msgsvc = MessageSvc( useColors=True, errorColorCode=['yellow', 'red'], warningColorCode=['red'], fatalColorCode=['blue', 'red'], ) def _color_pre_start_action_(): logger.debug('Add colorization to MessageSvc') from GaudiPython.Bindings import AppMgr _g = AppMgr() if not _g: return _s = _g.service('MessageSvc') if not _s: return _s.useColors = True _s.errorColorCode = ['yellow', 'red'] _s.warningColorCode = ['red'] _s.fatalColorCode = ['blue', 'red'] ##_s.alwaysColorCode = [ 'blue' ] ##_s.infoColorCode = [ 'green' ] del _g, _s from Bender.Utils import addPreInitAction addPreInitAction(_color_pre_start_action_) ## set input data from Bender.Utils import setData setData( files, config.XmlCatalogs, ## XML-catalogues config.Castor, ## use Castor/EOS lookup config.Grid) ## Use GRID to locate files return pyfiles
ttsis.ReportStage = "Stripping" tttt = dtt.D.addTupleTool('TupleToolTISTOS') tttt.TriggerList = ['Hlt1TrackAllL0Decision', 'Hlt2CharmHadD02HH_D02KPiDecision'] tttt.VerboseHlt1 = True tttt.VerboseHlt2 = True dv = DaVinci() dv.DDDBtag = 'dddb-20120831' dv.CondDBtag = 'cond-20120831' dv.DataType = '2012' dv.Lumi = False dv.InputType = "MDST" dv.UserAlgorithms = [ killer,dtt ] dv.EvtMax = -1 dv.EnableUnpack = ['Stripping','Reconstruction'] # Where to save the output: dv.HistogramFile = "histos.root" dv.Simulation = False from Configurables import NTupleSvc NTupleSvc().Output += [ "DTT DATAFILE='SwimD2hhTuple_v14r8.root' TYPE='ROOT' OPT='NEW'"] NTupleSvc().OutputLevel = 1 from GaudiConf import IOHelper IOHelper().inputFiles(['Swimming.SwimStrippingD2hhMDST_v14r8.mdst']) # Use the CondDB to get the right database tags from Configurables import CondDB CondDB(UseOracle = False, DisableLFC = True)
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)
'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, substitutions = ({} if args.baryon == 'Lc' else ['Xi_b0'])) lineseq.Members.insert(0, CheckPV(MinPVs = 1))
BsFilterSel = Selection('HelloWorld', Algorithm = _bsFilter, RequiredSelections = [BsSel] ) from Configurables import CheckPV BsSeq = SelectionSequence('Bs', TopSelection = BsFilterSel, EventPreSelector = [CheckPV()]) seq = BsSeq.sequence() seq.RootInTES = "/Event/MicroDST/" seq.OutputLevel=4 dv=DaVinci() dv.EvtMax=-1 dv.DataType="MC09" dv.HistogramFile = "DVHistos_MDST.root" dv.Simulation=True dv.RedoMCLinks=False dv.UserAlgorithms = [seq] dv.InputType='MDST' # some necessary framework stuff #ecs = EventClockSvc() #ecs.addTool(OdinTimeDecoder) #ecs.OdinTimeDecoder.RootInTES = "/Event/MicroDST/" #ecs.OdinTimeDecoder.RootInTES = "/Event/" dv.Input = ["DATAFILE='PFN:/afs/cern.ch/user/j/jpalac/w0/nightlies/lhcb3/DaVinci_HEAD/Ex/MicroDSTExample/cmt/TestODIN_.SeqBs2Jpsi2MuMuPhi2KK.mdst' TYP='POOL_ROOTTREE' OPT='READ'" ] ApplicationMgr().ExtSvc += [ "NTupleSvc" ] ApplicationMgr().HistogramPersistency = "ROOT"
# need to configure TupleMCTruth's MC association tool from Configurables import TupleToolMCTruth tuple.addTool(TupleToolMCTruth) from Configurables import MCMatchObjP2MCRelator tuple.TupleToolMCTruth.IP2MCPAssociatorType = 'MCMatchObjP2MCRelator' tuple.TupleToolMCTruth.addTool(MCMatchObjP2MCRelator, name="IP2MCPAssociatorType") tuple.TupleToolMCTruth.IP2MCPAssociatorType.RelTableLocations = [ location + '/P2MCPRelations' ] seq = GaudiSequencer("TupleSeq", Members=[tuple], RootInTES="/Event/MicroDST/") seq.OutputLevel = 1 dv = DaVinci() dv.EvtMax = -1 dv.DataType = "MC09" dv.HistogramFile = "DVHistos_DTT.root" DaVinci().TupleFile = "DVNtuples.root" dv.Simulation = True dv.RedoMCLinks = False dv.UserAlgorithms = [seq] dv.InputType = 'MDST' dv.Input = [ "DATAFILE='PFN:/afs/cern.ch/user/j/jpalac/w0/nightlies/lhcb3/DaVinci_HEAD/Ex/MicroDSTExample/cmt/Test.SeqBs2Jpsi2MuMuPhi2KK.mdst' TYP='POOL_ROOTTREE' OPT='READ'" ] ApplicationMgr().ExtSvc += ["NTupleSvc"] ApplicationMgr().HistogramPersistency = "ROOT"
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 = 'prod', force = False, mooreversion = 'latest') : 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, mooreversion) 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, toolList = toolList, mcToolList = mcToolList, L0List = L0List, HLT1List = HLT1List, HLT2List = HLT2List, strippingList = strippingList) mcunbseqs.append(mcunbseq) localns = dict(locals()) localns.update(globals()) if extraopts : exec extraopts in localns if extraoptsfile : if isinstance(extraoptsfile, (tuple, list)) : for fextraopts in extraoptsfile : execfile(os.path.expandvars(fextraopts)) in localns else : execfile(os.path.expandvars(extraoptsfile)) in localns objsdict = {'dv' : dv} Script.__init__(self, fname, dv.extraobjs, objsdict)