Exemplo n.º 1
0
def main(args):
    '''Run the Qt application.'''
    a = Qt.QApplication(sys.argv)
    a.setApplicationVersion("%s (%s)" % (versionNumber, versionDate))
    a.setOrganizationName("LHCb")
    a.setOrganizationDomain("lhcb.cern.ch")

    if len(args) > 1:
        # the first argument can be the name of a partition
        if args[1] in _allowed_partitions or re.match(r"ONLINE_[0-9]{6}",
                                                      args[1]):
            from Gaudi.Configuration import importOptions, allConfigurables
            importOptions("$SQLDDDBROOT/options/SQLDDDB.py")
            if args[1] in allConfigurables \
               and hasattr(allConfigurables[args[1]],"ConnectionString"):
                args[1] = allConfigurables[args[1]].ConnectionString
                print "Opening %s" % args[1]
        if len(args) > 2:
            rw = args[2].upper() == "RW"
        else:
            rw = False
        bridge = CondDBUI.CondDB(args[1], readOnly=not rw)
    else:
        bridge = None

    mw = guiwin.myWindow(bridge=bridge)
    mw.setGeometry(10, 10, 800, 600)
    mw.splitter.setSizes([150, 650])
    mw.dbTable.setSizes([450, 200])

    a.setMainWidget(mw)
    mw.show()

    return a.exec_()
def guessConnectionString(partition, options):
    import re
    known_partitions = ["DDDB", "LHCBCOND", "SIMCOND", "ONLINE"]
    if partition in known_partitions or re.match(r"ONLINE_[0-9]{6}",
                                                 partition):
        # Try to extract the connection string from the default configuration
        from Gaudi.Configuration import importOptions, allConfigurables
        _fixLogger()
        for opt in options:
            importOptions(opt)
        if partition in allConfigurables \
            and hasattr(allConfigurables[partition],"ConnectionString"):
            return allConfigurables[partition].ConnectionString
    # No configurable found
    if isSQLiteFile(partition):
        # it is an SQLite file, let's try to guess the partition name
        exp = re.compile(r"([A-Z][A-Z0-9_]{0,7})\.db")
        filename = os.path.basename(partition)
        m = exp.match(filename)
        if m:
            # the filename is of type LHCBCOND.db, let's try with:
            # sqlite_file:/path/to/FILE.db/FILE
            return "sqlite_file:%s/%s" % (partition, m.group(1))
        else:
            # let's see if filename contains the name of a know partition
            for p in known_partitions:
                if p in filename:
                    # so if the file is something like "DDDB_changes.db" use DDDB
                    return "sqlite_file:%s/%s" % (partition, p)
    # No further guessing, let's assume that we are dealing with a connection string
    return partition
Exemplo n.º 3
0
def getStandardConnectionStrings(optionFiles):
    from Gaudi.Configuration import importOptions, allConfigurables
    from GaudiKernel.ProcessJobOptions import ParserError
    # output dictionary
    data = {}
    for o in optionFiles:
        try:
            importOptions(o)
        except ParserError, x:
            # Ignore errors from the parser (e.g. file not found)
            logging.info("Problems importing %s: %s", o, x)
from Gaudi.Configuration import importOptions
eventType = 21113001
importOptions('$APPCONFIGOPTS/Gauss/Sim08-Beam3500GeV-md100-2011-nu2.py')
importOptions('$DECFILESROOT/options/21113001.py')
importOptions('$LBPYTHIA8ROOT/options/Pythia8.py')
importOptions('$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py')
importOptions('$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py')

from ProdConf import ProdConf

ProdConf(NOfEvents=1,
         DDDBTag='Sim08-20130503',
         AppVersion='v45r3',
         XMLSummaryFile='summaryGaussv45r3.xml',
         Application='Gauss',
         OutputFilePrefix='00012345_00006789_1',
         RunNumber=5678,
         XMLFileCatalog='pool_xml_catalogGaussv45r3.xml',
         FirstEventNumber=1234,
         CondDBTag='Sim08-20130503-vc-md100',
         OutputFileTypes=['sim'])
Exemplo n.º 5
0
# Create an ntuple to capture D*+ decays from the StrippingLine line
dtt = DecayTreeTuple('TupleDstToD0pi_D0ToKK')
dtt.Inputs = ['/Event/{0}/Phys/{1}/Particles'.format(stream, line)]
dtt.Decay = '[D*(2010)+ -> (D0 -> K- K+) pi+]CC'

# Configure DaVinci
DaVinci().UserAlgorithms += [dtt]
DaVinci().InputType = 'DST'
DaVinci().TupleFile = 'DVntuple.root'
DaVinci().PrintFreq = 1000
DaVinci().DataType = '2016'
DaVinci().Simulation = True
# Only ask for luminosity information when not using simulated data
DaVinci().Lumi = not DaVinci().Simulation
DaVinci().EvtMax = -1
DaVinci().CondDBtag = 'sim-20161124-2-vc-md100'
DaVinci().DDDBtag = 'dddb-20150724'

# Use input data from the bookkeeping query with XML catalog
importOptions("MC_2016_27163002_"
              "Beam6500GeV2016MagDownNu1.625nsPythia8_Sim09b_"
              "Trig0x6138160F_Reco16_Turbo03_"
              "Stripping28NoPrescalingFlagged_ALLSTREAMS.DST.py")
FileCatalog().Catalogs = [
    "xmlcatalog_file:MC_2016_27163002_"
    "Beam6500GeV2016MagDownNu1.625nsPythia8_Sim09b_"
    "Trig0x6138160F_Reco16_Turbo03_"
    "Stripping28NoPrescalingFlagged_ALLSTREAMS.DST.xml"
]
Exemplo n.º 6
0
def main():
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-c", "--connect-string",
                      dest="connectString", type="string",
                      help="cool::DatabaseId to use for the connection [default: %default]",
                      default="sqlite_file:LocalDDDB.db/DDDB")
    parser.add_option("-T", "--tag",
                      dest="tag", type="string",
                      help="tag to extract from the DB [default: %default]",
                      default="HEAD")
    parser.add_option("-t", "--event-time",
                      dest="time", type="string",
                      help="event time to be used to select the IOV [default: %default]",
                      default="0")
    parser.add_option("-s", "--source",
                      dest="source", type="string",
                      help="directory, in the database, where the files to copy to the DB are [default: %default]",
                      default="/",
                      metavar="SRCDIR")
    parser.add_option("--options",
                      dest="options", type="string", action="append",
                      help="Option file from which to get the needed informations",
                      default=[],
                      metavar="JOBOPTS")
    parser.add_option("-d", "--dest",
                      dest="dest", type="string",
                      help="directory where to copy the files [default: %default]",
                      default="DDDB",
                      metavar="DESTPATH")
    parser.add_option("-f", "--force",
                      dest="force", action="store_true",
                      help="overwrite files during copy",
                      default=False)
    parser.add_option("-v", "--verbose",
                      dest="verbosity", action="count",
                      help="increase verbosity")
    #parser.add_option("-X", "--ext",
    #                  action="store_true", dest="extension",
    #                  help="add filename extension when copying a COOL Folder",
    #                  default=False)
    parser.add_option("", "--from-file",
                      dest="filelist", type="string",
                      metavar="FILELIST",
                      help="copy only the files specified in the file FILELIST (override -s)")
    
    
    (options, args) = parser.parse_args()
 
    if len(args) != 0 or not (options.source or options.options) or not options.dest:
        parser.error("Bad arguments, use -h for help.")

    if options.verbosity == 1:
        logging.getLogger().setLevel(logging.INFO)
    elif options.verbosity > 1:
        logging.getLogger().setLevel(logging.DEBUG)

    if options.options:
        from Gaudi.Configuration import importOptions, configurationDict
        for o in options.options:
            importOptions(o)
        conf = configurationDict()
        if "DDDB" not in conf or "LHCBCOND" not in conf:
            raise RuntimeError("Bad configuration file")
        t = int(options.time)
        log = logging.getLogger("copy_to_files")
        db = conf["DDDB"]
        l = log.getEffectiveLevel()
        log.setLevel(logging.INFO)
        log.info("Copying DDDB from %s with tag %s"%(db["ConnectionString"],db.get("DefaultTAG","HEAD")))
        log.setLevel(l)
        DumpToFiles(db["ConnectionString"],t,db.get("DefaultTAG","HEAD"),
                    ["/"],options.dest,options.force)
        db = conf["LHCBCOND"]
        l = log.getEffectiveLevel()
        log.setLevel(logging.INFO)
        log.info("Copying LHCBCOND from %s with tag %s"%(db["ConnectionString"],db.get("DefaultTAG","HEAD")))
        log.setLevel(l)
        DumpToFiles(db["ConnectionString"],t,db.get("DefaultTAG","HEAD"),
                    ["/"],options.dest,options.force)
    else:
        srcs = [ options.source ]
        if options.filelist:
            srcs = [ f.strip() for f in open(options.filelist).readlines() ]
        
        t = int(options.time)
            
        DumpToFiles(options.connectString,t,options.tag,srcs,
                    options.dest,options.force)
Exemplo n.º 7
0
##############################################################################
# File for running Boole with default MC10 settings (full Digi output)
#
# Syntax is:
# gaudirun.py Boole-MC10.py <someDataFiles>.py
##############################################################################

from Gaudi.Configuration import importOptions
from Boole.Configuration import *
Boole().SiG4EnergyDeposit = False

importOptions("$APPCONFIGOPTS/Boole/DataType-2010.py")
Exemplo n.º 8
0
from   Gaudi.Configuration import importOptions

## loop over command line arguments 
for a in sys.argv[1:] :
    
    fname = str(a)
    fname = os.path.expandvars ( fname )
    fname = os.path.expandvars ( fname )
    fname = os.path.expandvars ( fname )
    fname = os.path.expanduser ( fname )
    
    if not os.path.exists ( fname ) : continue 
    if not os.path.isfile ( fname ) : continue 

    ## import options from configuration files 
    try : 
        importOptions( fname )
    except : pass

## 
from Configurables import EventSelector

evtsel = EventSelector()
flist  = evtsel.Input 
print '##  number of Input files %s' % len(flist)
print flist  

# =============================================================================
# The END 
# =============================================================================
Exemplo n.º 9
0
    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'

# Stream and stripping line we want to use
stream = 'AllStreams'
line = 'D2hhCompleteEventPromptDst2D2RSLine'

# Create an ntuple to capture D*+ decays from the StrippingLine line
dtt = DecayTreeTuple('TupleDstToD0pi_D0ToKpi')
dtt.Inputs = ['/Event/{0}/Phys/{1}/Particles'.format(stream, line)]
dtt.Decay = '[D*(2010)+ -> (D0 -> K- pi+) pi+]CC'

# Configure DaVinci
DaVinci().UserAlgorithms += [dtt]
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 = -1

# Use input data from the bookkeeping query with XML catalog
importOptions(
    "MC_2012_27163003_Beam4000GeV2012MagDownNu2.5Pythia8_Sim08e_Digi13_"
    "Trig0x409f0045_Reco14a_Stripping20NoPrescalingFlagged_ALLSTREAMS"
    ".DST.py")
FileCatalog().Catalogs = [
    "xmlcatalog_file:MC_2012_27163003_"
    "Beam4000GeV2012MagDownNu2.5Pythia8_Sim08e_Digi13_Trig0x409f0045_Reco14a_"
    "Stripping20NoPrescalingFlagged_ALLSTREAMS.DST.xml"]
from Gaudi.Configuration import importOptions
importOptions('$APPCONFIGOPTS/Moore/MooreSimProductionWithL0Emulation.py')
importOptions('$APPCONFIGOPTS/Conditions/TCK-0x40760037.py')
importOptions('$APPCONFIGOPTS/Moore/DataType-2011.py')
importOptions('$APPCONFIGOPTS/L0/L0TCK-0x0037.py')

from ProdConf import ProdConf

ProdConf(
    NOfEvents=1,
    DDDBTag='Sim08-20130503',
    AppVersion='v12r8g3',
    InputFiles=['00012345_00006789_2.digi'],
    XMLSummaryFile='summaryMoorev12r8g3.xml',
    Application='Moore',
    OutputFilePrefix='00012345_00006789_3',
    XMLFileCatalog='pool_xml_catalogMoorev12r8g3.xml',
    CondDBTag='Sim08-20130503-vc-md100',
    OutputFileTypes=['digi']
)
Exemplo n.º 12
0
# $Id: DataType.py 184170 2015-02-22 11:45:31Z ibelyaev $
# Test your line(s) of the stripping
#
# NOTE: Please make a copy of this file for your testing, and do NOT change this one!
#

from Configurables import DaVinci

DaVinci().HistogramFile = 'DV_stripping_histos.root'
DaVinci().EvtMax = 10000
DaVinci().PrintFreq = 2000
DaVinci().DataType = "2012"
DaVinci().InputType = "DST"

# database
DaVinci().DDDBtag = "dddb-20120831"
DaVinci().CondDBtag = "cond-20121008"

# input file
from Gaudi.Configuration import importOptions
importOptions("$STRIPPINGSELECTIONSROOT/tests/data/Reco14_Run125113.py")

DaVinci().EvtMax = 100
def execute(pos="c", angle=0):
  ################
  #user options
  sub_id = 0

  #number of events to generate
  LHCbApp().EvtMax = 1000

  #geometry options
  GeoV5 = True

  ################


  #parser options
  #import argparse

  #parser = argparse.ArgumentParser()
  #parser.add_argument('--nevt', type = int,
  #                    help = 'Set the number of event.')
  #args = parser.parse_args()
  #print "args.nevt", args.nevt, "\n"

  ################

  #to enable spillover and 25 ns bunch crossing
  #EnableSpillover = True

  #if EnableSpillover :
  #    importOptions('$APPCONFIGOPTS/Gauss/EnableSpillover-25ns.py')
  #else :
  #    #without spillover, I manually specify the bunch crossing
  #    from GaudiKernel import SystemOfUnits
  #    GenInit("GaussGen").BunchSpacing = 25 * SystemOfUnits.ns

  ################


  #generation seeds are controlled by the event number and the run number
  #GaussGen = GenInit("GaussGen")
  #GaussGen.FirstEventNumber = (sub_id * LHCbApp().EvtMax) + 1
  #GaussGen.RunNumber        = (sub_id * 1000) 


        
    #detector conditions

  from Configurables import DDDBConf

  if GeoV5 :
    #customized geometry
    from Configurables import Gauss, CondDB
        
    #CondDB().Upgrade = True
    #Gauss().DetectorGeo  = { "Detectors": ['VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Ecal', 'Hcal', 'Muon', 'Magnet' ] }
    #Gauss().DetectorSim  = { "Detectors": ['VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Ecal', 'Hcal', 'Muon', 'Magnet' ] }
    #Gauss().DetectorMoni = { "Detectors": ['VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Ecal', 'Hcal', 'Muon', 'Magnet' ] }
    #Gauss().DataType = "Upgrade"
        
     
    # V5 geo based on dddb-20150424, June 2015
    importOptions('$APPCONFIGOPTS/Gauss/Gauss-Upgrade-Baseline-20150522.py')
        
    LHCbApp().DDDBtag    = "dddb-20150424"
    LHCbApp().CondDBtag  = "sim-20140204-vc-md100"
        
    #xml files
    #local interactive DB root file
    #DDDBConf().DbRoot = "/afs/cern.ch/user/d/delbuono/cmtuser/DDDB_FTv5_20150424_s20140204_lhcbv38r6/lhcb.xml"

    #ganga (sandbox) non local db file
    CondDB().addLayer(dbFile = "DDDB_FTv5_20150424_s20140204_lhcbv38r6.db", dbName="DDDB" )
        

    #########################################################################

    # This is usually not needed, but right now there is a bug
    # which tries to search caliboff.db and fails
  from Configurables import CondDB
  CondDB().LoadCALIBDB = 'HLT1'

  importOptions('$LBPGUNSROOT/options/PGuns.py')
  from Configurables import ParticleGun
    #ParticleGun().EventType = 52210010

  # Set momentum
  from Configurables import MaterialEval
  ParticleGun().addTool(MaterialEval, name="MaterialEval")
  ParticleGun().ParticleGunTool = "MaterialEval"

  # test beam position jargon
  #position a: 225.5 cm (near mirror) ~5 cm distance from mirror
  #position b: 125.5 cm
  #position c: 30.5 cm (near sipm) ~ 5 cm distance from sipm
  #default y table position: 72.4 cm


  moduleWidth = 552.4 + 3 # 3 = modul gap
  z_orig = 7834. # 7620
  z_target = 9439.
  x_orig = 4. * moduleWidth + 65.3 # centre of the innermost fibre mat of the second module from left when looking into beam direction (neglected half a gap)
  #y_orig = 2417.5
  if pos == "a":
    y_orig = 50 # 5 cm from mirror
  elif pos == "c":
    y_orig = 2417.5 - 50. # 5 cm from SiPM
  elif pos.isdigit():
    y_orig = float(pos)
  else:
    exit()

  ParticleGun().MaterialEval.Xorig = x_orig
  ParticleGun().MaterialEval.Yorig = y_orig
  #ParticleGun().MaterialEval.Zorig = 7620
  ParticleGun().MaterialEval.Zorig = z_orig
  ParticleGun().MaterialEval.ModP = 150000 #150GeV

  ParticleGun().MaterialEval.ZPlane = z_target
  ParticleGun().MaterialEval.Xmin = x_orig - 1.7 + (z_target - z_orig) / tan( radians(90 - angle) )
  ParticleGun().MaterialEval.Xmax = x_orig + 1.7 + (z_target - z_orig) / tan( radians(90 - angle) )
  ParticleGun().MaterialEval.Ymin = y_orig - 1.7
  ParticleGun().MaterialEval.Ymax = y_orig + 1.7
  ParticleGun().MaterialEval.PdgCode = 211

  # Set min and max number of particles to produce in an event
  from Configurables import FlatNParticles
  ParticleGun().addTool(FlatNParticles, name="FlatNParticles")
  ParticleGun().NumberOfParticlesTool = "FlatNParticles"
  ParticleGun().FlatNParticles.MinNParticles = 1
  ParticleGun().FlatNParticles.MaxNParticles = 1

  GaussGen = GenInit("GaussGen")
  GaussGen.FirstEventNumber = 1
  GaussGen.RunNumber = 1082

  LHCbApp().EvtMax = 10

  outpath = "testbeam_simulation_position_" + pos  + '_at_' + str(angle) + 'deg'

  HistogramPersistencySvc().OutputFile = outpath+'-GaussHistos.root'

  OutputStream("GaussTape").Output = "DATAFILE='PFN:%s.sim' TYP='POOL_ROOTTREE' OPT='RECREATE'"%outpath
from Gaudi.Configuration import importOptions
from Configurables import LHCbApp
from Gauss.Configuration import *

import sys
import inspect
import os
from math import tan, radians

local_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
sys.path.append(local_dir)

#information on colliding beams: momenta, crossing angles
importOptions('$APPCONFIGOPTS/Gauss/Beam7000GeV-md100-nu7.6-HorExtAngle.py')

#event type
#importOptions('$DECFILESROOT/options/13104012.py')    #Bs phi phi 
#importOptions('$DECFILESROOT/options/13104013.py')   #Bs phi phi with Pt>400MeV

#MC generator to use - all upgrade studies are done with PYTHIA 8
importOptions('$LBPYTHIA8ROOT/options/Pythia8.py')

#to enable hadronic physics in GEANT4
importOptions('$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py')

#Upgrade conditions
importOptions('$APPCONFIGOPTS/Conditions/Upgrade.py')

def execute(pos="c", angle=0):
  ################
  #user options
def execute(pos="c", angle=0):

    #MC generator to use - all upgrade studies are done with PYTHIA 8
    importOptions('$LBPYTHIA8ROOT/options/Pythia8.py')

    #to enable hadronic physics in GEANT4
    importOptions('$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py')

    #Upgrade conditions
    importOptions('$APPCONFIGOPTS/Conditions/Upgrade.py')

    importOptions("$APPCONFIGOPTS/Gauss/Beam7000GeV-md100-nu7.6-HorExtAngle.py")
    importOptions("$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py")


    ################
    #user options
    sub_id = 0

    #number of events to generate
    LHCbApp().EvtMax = 10000

    #geometry options
    GeoV5 = True

    ################

    #to enable spillover and 25 ns bunch crossing
    #EnableSpillover = True

    #if EnableSpillover :
    #    importOptions('$APPCONFIGOPTS/Gauss/EnableSpillover-25ns.py')
    #else :
    #    #without spillover, I manually specify the bunch crossing
    #    from GaudiKernel import SystemOfUnits
    #    GenInit("GaussGen").BunchSpacing = 25 * SystemOfUnits.ns

    ################


    #generation seeds are controlled by the event number and the run number
    GaussGen = GenInit("GaussGen")
    GaussGen.FirstEventNumber = (sub_id * LHCbApp().EvtMax) + 1
    GaussGen.RunNumber        = (sub_id * 1000) 

        
    #detector conditions

    from Configurables import DDDBConf

    if GeoV5 :
        #customized geometry
        from Configurables import Gauss, CondDB
        
     
        # V5 geo based on dddb-20150424, June 2015
        importOptions('$APPCONFIGOPTS/Gauss/Gauss-Upgrade-Baseline-20150522.py')
        
        #from Configurables import Gauss, CondDB
        #CondDB().Upgrade = True
        #Gauss().DetectorGeo  = { "Detectors": ['VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Ecal', 'Hcal', 'Muon', 'Magnet' ] }
        #Gauss().DetectorSim  = { "Detectors": ['VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Ecal', 'Hcal', 'Muon', 'Magnet' ] }
        #Gauss().DetectorMoni = { "Detectors": ['VP', 'UT', 'FT', 'Rich1Pmt', 'Rich2Pmt', 'Ecal', 'Hcal', 'Muon', 'Magnet' ] }

        #Gauss().DetectorGeo  = { "Detectors": ['FT'] }
        #Gauss().DetectorSim  = { "Detectors": ['FT'] }
        #Gauss().DetectorMoni = { "Detectors": ['FT'] }

        #Gauss().DataType = "Upgrade"


        LHCbApp().DDDBtag    = "dddb-20150424"
        LHCbApp().CondDBtag  = "sim-20140204-vc-md100"
        
        #xml files
        #local interactive DB root file
        #DDDBConf().DbRoot = "/afs/cern.ch/user/d/delbuono/cmtuser/DDDB_FTv5_20150424_s20140204_lhcbv38r6/lhcb.xml"
        #ganga (sandbox) non local db file
        CondDB().addLayer(dbFile = "DDDB_FTv5_20150424_s20140204_lhcbv38r6.db", dbName="DDDB" ) #if loaded in the ganga script it will be automatically loaded by Gauss
           
    #########################################################################

    # This is usually not needed, but right now there is a bug
    # which tries to search caliboff.db and fails
    from Configurables import CondDB
    CondDB().LoadCALIBDB = 'HLT1'

    #########################################################################
    #Options = "Gauss_"


    #Options = "BsPhiPhi"+"_V5_"+"Spillover"
    #OutputStream("GaussTape").Output = "DATAFILE='PFN:"+Options+".sim' TYP='POOL_ROOTTREE' OPT='RECREATE'"
    outpath = "testbeam_simulation_position_" + pos  + '_at_' + str(angle) + 'deg'
    importOptions('$LBPGUNSROOT/options/PGuns.py')
    from Configurables import ParticleGun
    #ParticleGun().EventType = 52210010

    # Set momentum
    from Configurables import MaterialEval
    ParticleGun().addTool(MaterialEval, name="MaterialEval")
    ParticleGun().ParticleGunTool = "MaterialEval"

    # test beam position jargon
    #position a: 225.5 cm (near mirror) ~5 cm distance from mirror
    #position b: 125.5 cm
    #position c: 30.5 cm (near sipm) ~ 5 cm distance from sipm
    #default y table position: 72.4 cm


    #moduleWidth = 552.4 + 3 # 3 = modul gap
    moduleWidth = 529.0 + 3 # 3 = modul gap
    z_orig = 7820. # 7620
    z_target = 9439.
    x_orig = 4. * moduleWidth + 65.3 # centre of the innermost fibre mat of the second module from left when looking into beam direction (neglected half a gap)
    #y_orig = 2417.5
    if pos == "a":
        y_orig = 50 # 5 cm from mirror
    elif pos == "c":
        y_orig = 2417.5 - 50. # 5 cm from SiPM
    elif pos.isdigit():
        y_orig = float(pos)
    else:
        exit()

    ParticleGun().MaterialEval.Xorig = x_orig
    ParticleGun().MaterialEval.Yorig = y_orig
    #ParticleGun().MaterialEval.Zorig = 7620
    ParticleGun().MaterialEval.Zorig = z_orig
    ParticleGun().MaterialEval.ModP = 150000 #150GeV

    ParticleGun().MaterialEval.ZPlane = z_target
    ParticleGun().MaterialEval.Xmin = x_orig - 1.7 + (z_target - z_orig) / tan( radians(90 - angle) )
    ParticleGun().MaterialEval.Xmax = x_orig + 1.7 + (z_target - z_orig) / tan( radians(90 - angle) )
    ParticleGun().MaterialEval.Ymin = y_orig - 1.7
    ParticleGun().MaterialEval.Ymax = y_orig + 1.7
    ParticleGun().MaterialEval.PdgCode = 211

    # Set min and max number of particles to produce in an event
    from Configurables import FlatNParticles
    ParticleGun().addTool(FlatNParticles, name="FlatNParticles")
    ParticleGun().NumberOfParticlesTool = "FlatNParticles"
    ParticleGun().FlatNParticles.MinNParticles = 1
    ParticleGun().FlatNParticles.MaxNParticles = 1


    LHCbApp().EvtMax = 10

    HistogramPersistencySvc().OutputFile = outpath+'-GaussHistos.root'

    OutputStream("GaussTape").Output = "DATAFILE='PFN:%s.sim' TYP='POOL_ROOTTREE' OPT='RECREATE'"%outpath
from Gaudi.Configuration import importOptions
importOptions('$APPCONFIGOPTS/Brunel/DataType-2011.py')
importOptions('$APPCONFIGOPTS/Brunel/MC-WithTruth.py')
importOptions('$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py')

from ProdConf import ProdConf

ProdConf(
    NOfEvents=1,
    DDDBTag='Sim08-20130503',
    AppVersion='v43r2p7',
    InputFiles=['00012345_00006789_3.digi'],
    XMLSummaryFile='summaryBrunelv43r2p7.xml',
    Application='Brunel',
    OutputFilePrefix='00012345_00006789_4',
    XMLFileCatalog='pool_xml_catalogBrunelv43r2p7.xml',
    CondDBTag='Sim08-20130503-vc-md100',
    OutputFileTypes=['dst']
)
Exemplo n.º 17
0
from Gaudi.Configuration import importOptions
from Configurables import LHCbApp

LHCbApp().DDDBtag = "dddb-20170721-3"
LHCbApp().CondDBtag = "sim-20170721-2-vc-md100"

# from production request 48724
importOptions(
    "$APPCONFIGOPTS/DaVinci/DV-Stripping28r1p1-Stripping-MC-NoPrescaling-DST.py"
)
importOptions("$APPCONFIGOPTS/DaVinci/DataType-2016.py")
importOptions("$APPCONFIGOPTS/DaVinci/InputType-DST.py")
# Stream and stripping line we want to use
stream = 'AllStreams'
line = 'D2hhCompleteEventPromptDst2D2RSLine'

# Create an ntuple to capture D*+ decays from the StrippingLine line
dtt = DecayTreeTuple('TupleDstToD0pi_D0ToKpi')
dtt.Inputs = ['/Event/{0}/Phys/{1}/Particles'.format(stream, line)]
dtt.Decay = '[D*(2010)+ -> (D0 -> K- pi+) pi+]CC'

# Configure DaVinci
DaVinci().UserAlgorithms += [dtt]
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 = -1

# Use input data from the bookkeeping query with XML catalog
importOptions(
    "MC_2012_27163003_Beam4000GeV2012MagDownNu2.5Pythia8_Sim08e_Digi13_"
    "Trig0x409f0045_Reco14a_Stripping20NoPrescalingFlagged_ALLSTREAMS"
    ".DST.py")
FileCatalog().Catalogs = [
    "xmlcatalog_file:MC_2012_27163003_"
    "Beam4000GeV2012MagDownNu2.5Pythia8_Sim08e_Digi13_Trig0x409f0045_Reco14a_"
    "Stripping20NoPrescalingFlagged_ALLSTREAMS.DST.xml"
]
Exemplo n.º 19
0
##
## put some algorithms into "user" list
##
from StandardParticles      import StdLooseKaons 
from PhysSelPython.Wrappers import SelectionSequence
seq = SelectionSequence( 'KAONS' , StdLooseKaons )
dv.UserAlgorithms += [  seq.sequence() ] 

## produde a lot of prints 
## msg = MessageSvc ( OutputLevel = 2 )


## get some input data 
from Gaudi.Configuration import importOptions
importOptions('$STRIPPINGSELECTIONSROOT/tests/data/Reco15a_Run164668.py')


##
## GaudiPython 
##

from GaudiPython.Bindings import AppMgr

gaudi = AppMgr()


alg   = gaudi.algorithm('KAONS')

mainseq = 'DaVinciEventSeq'
Exemplo n.º 20
0
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
Exemplo n.º 21
0
from Gaudi.Configuration import importOptions
from Gaussino.Generation import GenPhase

from Configurables import Generation

# Beam options as in Beam6500GeV-md100-2016-nu1.6.py
importOptions("$APPCONFIGOPTS/Gauss/Beam7000GeV-mu100-nu7.6-HorExtAngle.py")

from Configurables import Gauss, CondDB

CondDB().Upgrade = True

# Add also the DDDB tag for now
from Configurables import LHCbApp
LHCbApp().DDDBtag = "dddb-20190223"
LHCbApp().CondDBtag = "sim-20180530-vc-mu100"
LHCbApp().DataType = "Upgrade"

# Configure the generation phase as usual
Generation().EventType = 30000000
GenPhase().SampleGenerationTool = "MinimumBias"
GenPhase().ProductionTool = "Pythia8ProductionMT"
GenPhase().DecayTool = "EvtGenDecay"

from Configurables import ToolSvc
from Configurables import EvtGenDecay
ToolSvc().addTool(EvtGenDecay)
ToolSvc(
).EvtGenDecay.UserDecayFile = "$DECFILESROOT/dkfiles/Dsst_ppbarpi=TightCut.dec"
ToolSvc().EvtGenDecay.DecayFile = "$DECFILESROOT/dkfiles/DECAY.DEC"
Exemplo n.º 22
0
from Gaudi.Configuration import importOptions
importOptions('$APPCONFIGOPTS/Boole/Default.py')
importOptions('$APPCONFIGOPTS/Boole/DataType-2011.py')
importOptions('$APPCONFIGOPTS/Boole/Boole-SiG4EnergyDeposit.py')
importOptions('$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py')

from ProdConf import ProdConf

ProdConf(NOfEvents=1,
         DDDBTag='Sim08-20130503',
         AppVersion='v26r3',
         InputFiles=['00012345_00006789_1.sim'],
         XMLSummaryFile='summaryBoolev26r3.xml',
         Application='Boole',
         OutputFilePrefix='00012345_00006789_2',
         XMLFileCatalog='pool_xml_catalogBoolev26r3.xml',
         CondDBTag='Sim08-20130503-vc-md100',
         OutputFileTypes=['digi'])
from Gaudi.Configuration import importOptions

importOptions('$APPCONFIGOPTS/DaVinci/DV-Stripping20-Stripping-MC-NoPrescaling.py')
importOptions('$APPCONFIGOPTS/DaVinci/DataType-2012.py')
importOptions('$APPCONFIGOPTS/DaVinci/InputType-DST.py')
importOptions('$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py') 

from ProdConf import ProdConf

ProdConf(
    NOfEvents=1,
    DDDBTag='dddb-20130929-1',
    InputFiles=['00012345_00006789_2.dst'],
    AppVersion='v32r2p1',
    XMLSummaryFile='summaryBrunel.xml',
    Application='DaVinci',
    OutputFilePrefix='ALLSTREAMS',
    XMLFileCatalog='pool_xml_catalogBrunel.xml',
    CondDBTag='sim-20130522-1-vc-mu100',
    OutputFileTypes=['dst']
)
from Gaudi.Configuration import importOptions
from Configurables import LHCbApp
from Gauss.Configuration import *

import sys
import inspect
import os
from math import tan, radians

local_dir = os.path.dirname(
    os.path.abspath(inspect.getfile(inspect.currentframe())))
sys.path.append(local_dir)

#information on colliding beams: momenta, crossing angles
importOptions('$APPCONFIGOPTS/Gauss/Beam7000GeV-md100-nu7.6-HorExtAngle.py')

#event type
#importOptions('$DECFILESROOT/options/13104012.py')    #Bs phi phi
#importOptions('$DECFILESROOT/options/13104013.py')   #Bs phi phi with Pt>400MeV

#MC generator to use - all upgrade studies are done with PYTHIA 8
importOptions('$LBPYTHIA8ROOT/options/Pythia8.py')

#to enable hadronic physics in GEANT4
importOptions('$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py')

#Upgrade conditions
importOptions('$APPCONFIGOPTS/Conditions/Upgrade.py')


def execute(pos="c", angle=0):