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(year, mc, input_type, n_events, root=None, tfn=None): """General configuration of DaVinci object. Keyword arguments: year -- One of (2011, 2012) mc -- True if creating Monte Carlo ntuples, else False """ dv = DaVinci() # Stripping output on CHARMCOMPLETEEVENT.DST, MC on ALLSTREAMS.DST dv.InputType = input_type # Output ntuple name dv.TupleFile = 'DVntuple.root' # Print status every 1000 events dv.PrintFreq = 1000 dv.EvtMax = n_events # Year of data taking dv.DataType = str(year) # Is the data from simulation dv.Simulation = mc # Add a GetIntegratedLuminosity/LumiTuple TTree to output if appropriate dv.Lumi = not mc if root is not None: dv.RootInTES = root if tfn is not None: dv.TupleFile = tfn
] streamConf = {'default': stripDSTStreamConf(), charm: microDSTStreamConf()} elements = { 'default': stripDSTElements(), charm: microDSTElements() + extraMicroElements } conf = SelDSTWriter("StripDST", StreamConf=streamConf, MicroDSTElements=elements, OutputFileSuffix="01234567", SelectionSequences=sc.activeStreams()) conf.StreamConf[charm] = microDSTStreamConf() selDST0Seq = conf.sequence() # dv = DaVinci() dv.DataType = '2010' dv.InputType = 'SDST' dv.EvtMax = 2000 #dv.UserAlgorithms = [multiSeqA.sequence(), multiSeqB.sequence(), selDST0Seq] dv.UserAlgorithms = [conf.sequence()] importOptions("Reco05-Stripping09_SDSTs.py") #EventSelector().Input = ["DATAFILE='PFN:castor:/castor/cern.ch/user/c/cattanem/testFiles/Brunel-v37r1-069857_0000000006-1000ev.sdst' TYP='POOL_ROOTTREE' OPT='READ'"] #FileCatalog().Catalogs =['xmlcatalog_file:TestSDSTCatalog.xml']
print vtxCut mySeqBGTrig = GaudiSequencer('mySeqBGTrig') mySeqBGTrig.Members = [clustCut] #mySeqBGTrig.Members += [ extrCl ] # What will change if we do this; change LiteClusterLocation too !!! mySeqBGTrig.Members += [rzTracking2] mySeqBGTrig.Members += [vtxCut] ######################################################################################### from Configurables import DaVinci DV = DaVinci() DV.DataType = 'DC06' #DaVinci().DDDBtag = 'head-20090112' #DaVinci().CondDBtag = 'sim-20090112' DV.UserAlgorithms = [mySeqRZTr, mySeqBGTrig] DV.InputType = 'DST' print DV ######################################################################################### #################### GaudiPython; Other Imports; Type Shortcuts ####################### ######################################################################################### import GaudiPython appMgr = GaudiPython.AppMgr() #appMgr.DLLs = [ 'GaudiAlg', 'RootHistCnv' ] from GaudiPython import PyAlgorithm from ROOT import TH1F, TH1D, TCanvas, gStyle from LinkerInstances.eventassoc import * import math SUCCESS = GaudiPython.SUCCESS
tttt = dtt.B.addTupleTool('TupleToolTISTOS') tttt.TriggerList = [ 'Hlt1TrackAllL0Decision', 'Hlt1TrackMuonDecision', 'Hlt1DiMuonHighMassDecision', 'Hlt2DiMuonDetachedJpsiDecision', 'Hlt2DiMuonJpsiDecision' ] tttt.VerboseHlt1 = True tttt.VerboseHlt2 = True dv = DaVinci() dv.DDDBtag = 'head-20110914' dv.CondDBtag = 'head-20110914' dv.DataType = '2011' dv.Lumi = False dv.InputType = "MDST" if mDST else "DST" dv.UserAlgorithms = [dtt] dv.EvtMax = -1 ApplicationMgr().HistogramPersistency = "ROOT" from Configurables import HistogramPersistencySvc HistogramPersistencySvc(OutputFile='histos.root') from Configurables import NTupleSvc NTupleSvc().Output += ["DTT DATAFILE='tuples.root' TYPE='ROOT' OPT='NEW'"] NTupleSvc().OutputLevel = 1 ## Point the EventClockSvc to the RootInTES ## from Configurables import EventClockSvc, OdinTimeDecoder, TimeDecoderList ## EventClockSvc().addTool( TimeDecoderList, name = "EventTimeDecoder" ) ## EventClockSvc().EventTimeDecoder.RootInTES = locationRoot
"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"
ttsis = dtt.D.addTupleTool('TupleToolSwimmingInfo/StrippingInfo') ttsi.ReportsLocation = '/Event/SwimStrippingD2hhMDST_v14r8/CharmToBeSwum/Phys/D2hhPromptD2KPiLine/P2TPRelations' ttsis.ReportsLocation = '/Event/SwimStrippingD2hhMDST_v14r8/CharmToBeSwum/Phys/D2hhPromptD2KPiLine/P2TPRelations' 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
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
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"