示例#1
0
def configure(inputdata, catalogs=[], castor=False, params={}):

    from Configurables import DaVinci

    daVinci = DaVinci(DataType='2012', InputType='DST', Simulation=True)

    daVinci.TupleFile = 'B2JPsiK-TagInfo.root'

    setData(inputdata, catalogs,
            castor)  ## inform bender about input files and access to data

    from BenderTools.GetDBtags import getDBTags
    tags = getDBTags(inputdata[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)

    gaudi = appMgr()

    alg = TagInfo(
        'TagInfo',
        Inputs=[
            '/Event/AllStreams/Phys/BetaSBu2JpsiKDetachedLine/Particles',
            '/Event/AllStreams/Phys/BetaSBu2JpsiKPrescaledLine/Particles'
        ])

    gaudi.setAlgorithms([alg])

    return SUCCESS
示例#2
0
def useDBTagsFromData (
    files             ,   ## the file name 
    castor     = True ,   ## use castor/EOS ? 
    grid       = ''   ,   ## use grid?
    daVinci    = None ,   ## davinci instance 
    importOpts = []   ,   ## import options (if any) 
    catalogs   = []   ) : ## XMl  catalogs to use 
    """ Extract the tags from data file  and configure DaVinci
    >>> dv        = DaVinci ( ... )
    >>> datatiles = ...
    >>> from BenderTools.GetDBtags import useDBtagsFromDATA
    >>> useDBtagsFromDATA ( datafiles , castor , grid )    
    """
    
    if isinstance ( files , str ) :  files = [ filenames ]  

    if importOpts :
        from Bender.DataUtils import evtSelInput
        ifiles = evtSelInput ( importOpts )
        files  = files + ifiles

    if not files :
        logger.error('No input files are specified') 
        return {}
    
    tags  = {}
    ifile = 0
    nfile = len(files)
    for f  in files :
        ifile += 1 
        logger.debug ( "Try the file %s   [%d/%d]" %  ( f , ifile , nfile ) ) 
        tags = getDBTags  ( f                       ,
                            castor     = castor     ,
                            grid       = grid       ,
                            importOpts = importOpts ,
                            catalogs   = catalogs   ,
                            debug      = False      )
        if tags : break  
        if   0 == ifile % 100 : 
            logger.error   (" No success in %d/%d trials" % ( ifile , nfile ) )
        elif 0 == ifile %  10 :
            logger.warning (" No success in %d/%d trials" % ( ifile , nfile ) )  

    if not tags : 
        logger.warning ( 'No tags are extracted from %d files ' % nfile )
        return tags  
    #
    logger.info    ( 'Extracted tags from DATA are : %s' % tags         )
    
    if not daVinci :
        from Configurables import DaVinci
        daVinci = DaVinci ()
        
    if tags.has_key ( 'DDDB'    ) and tags ['DDDB'   ] :

        daVinci.DDDBtag   = dddb_tag ( tags ['DDDB'  ] )
        logger.info ( ' DaVinci/DDDBtag   : %s ' % daVinci.DDDBtag    )

        if isinstance ( tags['DDDB'] , list ) and  1 < len ( tags['DDDB'] ) :
            from Configurables import CondDB  
            db = CondDB()
            db.LocalTags['DDDB'] = tags['DDDB']
            logger.info ( " ConDB/LocalTags['DDDB'] : %s " % db.LocalTags['DDDB'] )
            
    if tags.has_key ( 'CONDDB'  ) and tags ['CONDDB' ] :

        if isinstance ( tags ['CONDDB'] , str ) :
            daVinci.CondDBtag = tags ['CONDDB']
        else :
            daVinci.CondDBtag = tags ['CONDDB'][0]
            from Configurables import CondDB  
            db = CondDB()
            db.LocalTags['CONDDB'] = tags['CONDDB']
            logger.info ( " ConDB/LocalTags['CONDDB'] : %s " % db.LocalTags['CONDDB'] )

        logger.info ( ' DaVinci/CondDBtag : %s ' % daVinci.CondDBtag  )
        
    if tags.has_key ( 'SIMCOND' ) and tags ['SIMCOND'] :
        
        if isinstance ( tags ['SIMCOND'] , str ) :
            daVinci.CondDBtag = tags ['SIMCOND']
        else :
            daVinci.CondDBtag = tags ['SIMCOND'][0]
            from Configurables import CondDB  
            db = CondDB()
            db.LocalTags['CONDDB'] = tags['SIMCOND']
            logger.info ( " CondDB/LocalTags['CONDDB'/'SIMCOND'] : %s " % db.LocalTags['CONDDB'] )
        
        logger.info ( ' DaVinci/CondDBtag : %s ' % daVinci.CondDBtag  )

    return tags
ttsi.ReportsLocation = selectionPath + '/P2TPRelations'
ttsis.ReportsLocation = selectionPath + '/P2TPRelations'
ttsis.ReportStage = "Stripping"

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

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

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

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

## Point the EventClockSvc to the RootInTES
示例#4
0
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
示例#5
0
dtt.D.addTupleTool('TupleToolPropertime')
ttsi = dtt.D.addTupleTool('TupleToolSwimmingInfo/TriggerInfo')
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
示例#6
0
dv = DaVinci()

dv.DataType = "2010"

dv.Simulation = False

dv.EvtMax     = -1

dv.TupleFile  = 'b2hh_stripped.root'

dv.PrintFreq  = 100

condDB = CondDB()

condDB.UseOracle = True



dv.DDDBtag = "head-20100518"

dv.CondDBtag = "head-20100715"

dv.Lumi = True

dv.WriteFSR = True

dv.UserAlgorithms = [ evttuple, preseltuple ]



示例#7
0
from Configurables import DaVinci
from Configurables import Velo__VeloIPResolutionMonitorNT as IPMoni

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

ipMoni = IPMoni('VeloIPResolutionMonitor')
ipMoni.CheckIDs = True
dv.UserAlgorithms = [ipMoni]
dv.TupleFile = 'IPTuple.root'