Пример #1
0
def my_configure_pgun(self, seq):
    from GaudiKernel.SystemOfUnits import GeV, rad
    from Configurables import ParticleGun
    pgun = ParticleGun("ParticleGun")
    pgun.EventType = 53210205
    from Configurables import MomentumRange
    pgun.addTool(MomentumRange, name="MomentumRange")
    pgun.ParticleGunTool = "MomentumRange"
    from Configurables import FlatNParticles
    pgun.addTool(FlatNParticles, name="FlatNParticles")
    pgun.NumberOfParticlesTool = "FlatNParticles"
    pgun.FlatNParticles.MinNParticles = 1
    pgun.FlatNParticles.MaxNParticles = 1
    pgun.MomentumRange.PdgCodes = [-11]
    pgun.MomentumRange.MomentumMin = 2.0 * GeV
    pgun.MomentumRange.MomentumMax = 100.0 * GeV
    pgun.MomentumRange.ThetaMin = 0.015 * rad
    pgun.MomentumRange.ThetaMax = 0.300 * rad
    seq += [pgun]
Пример #2
0
eventType = '13142411'  #[B_s0 -> (J/psi(1S) -> mu+ mu- ) (pi0 -> gamma gamma) ]cc

#eventType="11102013"
#use PGun sim or pythia?
importOptions('$DECFILESOPTS/%s.py' % eventType)
#get PDG
pGun = True

if True == pGun:
    importOptions("$LBPGUNSROOT/options/PGuns.py")
    from Configurables import ToolSvc
    from Configurables import EvtGenDecay
    from Configurables import ParticleGun

    #if the dec file already has a particle gun configuration, pass it here, else, configure a flat momentum spectrum
    if hasattr(ParticleGun(), 'SignalPdgCode'):
        print 'has attribute!'
        #no configuration necessary
        pass
    elif hasattr(ParticleGun(), 'MomentumRange'):
        if hasattr(ParticleGun().MomentumRange, "PdgCodes"):
            print 'got PDGCodes. Should be Configured'
            pass
        else:
            print 'problem with configuration!'
            import sys
            sys.exit()
    else:
        print 'using flat momentum spectrum!'
        from Configurables import MomentumRange
        ParticleGun().addTool(MomentumRange)
Пример #3
0
particlePropertySvc = Gaudi__ParticlePropertySvc(
    "ParticlePropertySvc",
    ParticlePropertiesFile=DATAPATH + '/ParticleTable.txt')

### Example of pythia configuration file to generate events
#pythiafile="Test/TestGeneration/data/ee_ZH_Zmumu_Hbb.txt"

#### Data service
podioevent = FCCDataSvc("EventDataSvc")

### PYTHIA algorithm
#pythia8gentool = PythiaInterface("Pythia8Interface", Filename=pythiafile)
#pythia8gen = GenAlg("Pythia8", SignalProvider=pythia8gentool)
#pythia8gen.hepmc.Path = "hepmcevent"
# guntool = ParticleGun("SignalProvider", PdgCodes=[211, 22, 11, -13, 2112, 2212])
guntool = ParticleGun("SignalProvider", PdgCodes=[11])
gun = GenAlg('ParticleGunAlg', SignalProvider=guntool)
gun.hepmc.Path = "hepmcevent"

### Reads an HepMC::GenEvent from the data service and writes a collection of EDM Particles
hepmc_converter = HepMCToEDMConverter("Converter")
hepmc_converter.hepmc.Path = "hepmcevent"
hepmc_converter.genparticles.Path = "GenParticle"
hepmc_converter.genvertices.Path = "Genvertex"

# from CMS_detector_cfg import detservice
from SCTau_detector_cfg import detservice
from papas_cfg import papasalg

#output fcc particles to root
# out = PodioOutput("out", OutputLevel=INFO)
Пример #4
0
# number of steps it is necessary to have "ApplicationMgr.EvtMax = 8792;",
# for the whole x-y grid "ApplicationMgr.ExtMax = 8320;"
#
# Include this file instead of the EVENTTYPE.opts after all you other
# options.
#
#  @author : G.Corti
#  @date   : last modified on 2009-11-04
##############################################################################

#from Gaudi.Configuration import *
from Configurables import ParticleGun
from GaudiKernel.SystemOfUnits import *

# Set up ParticleGun
ParticleGun = ParticleGun("ParticleGun")

# Control of the ParticleGun
# Event type is set as described in LHCb-2005-034 : G=5! (Def = 0)
ParticleGun.EventType = 53210205

# Pick the type of particle gun generator
from Configurables import MaterialEval
ParticleGun.addTool(MaterialEval, name="MaterialEval")
ParticleGun.ParticleGunTool = "MaterialEval"

# Set fixed number of particles to produce in an event (default = 10) and
# their PDG code (default = 2221111)
from Configurables import FlatNParticles
ParticleGun.addTool(FlatNParticles, name="FlatNParticles")
ParticleGun.NumberOfParticlesTool = "FlatNParticles"
Пример #5
0
# Set up particle gun
from Gaudi.Configuration import *
from Configurables import ParticleGun
from GaudiKernel.SystemOfUnits import *

partgun = ParticleGun("ParticleGun")

# Event type is set as described in LHCb-2005-034 : G=5! (Def = 0)
partgun.EventType = 53210205;

# Add the beamshape gun
from Configurables import BeamShape
partgun.addTool(BeamShape, name="BeamShape")
partgun.ParticleGunTool = "BeamShape"
guntool = partgun.BeamShape

# Beam centroid
guntool.xCenter = 0*mm          # Beam position
guntool.yCenter = 0*mm          # Beam position
guntool.zCenter = -1000*mm      # Generation point
guntool.BeamDirection = 1       # Beam 1: 1, Beam 2: -1 
guntool.ThetaCenter = 0*rad     # Inclination angle (angle to z)
guntool.PhiCenter = 0*rad       # Azimuth angle 

# Beam parameters
guntool.Momentum = 450*GeV      # Beam particle momentum
guntool.PdgCode = 2212          # Particle PDG ID
guntool.xEmmitance = 7.82e-9*m  # Transverse emmitance
guntool.yEmmitance = 7.82e-9*m  # Transverse emmitance
guntool.xBeta = 10.0*m          # Optical beta function
guntool.yBeta = 10.0*m          # Optical beta function
Пример #6
0
#
# ASCII decay Descriptor: [B+ -> K+ e+ e-]cc
#
#from Configurables import Generation
#Generation().EventType = 12123002
#Generation().SampleGenerationTool = "SignalRepeatedHadronization"
#from Configurables import SignalRepeatedHadronization
#Generation().addTool( SignalRepeatedHadronization )
#Generation().SignalRepeatedHadronization.ProductionTool = "PythiaProduction"
#Generation().SignalRepeatedHadronization.CutTool = "DaughtersInLHCb"
#Generation().SignalRepeatedHadronization.SignalPIDList = [ 521,-521 ]

# Ad-hoc particle gun code

from Configurables import ParticleGun
pgun = ParticleGun("ParticleGun")
pgun.SignalPdgCode = 521

from Configurables import ToolSvc
from Configurables import EvtGenDecay
ToolSvc().addTool(EvtGenDecay)
ToolSvc(
).EvtGenDecay.UserDecayFile = "$DECFILESROOT/dkfiles/Bu_Kee=MS,DecProdCut.dec"

pgun.DecayTool = "EvtGenDecay"
pgun.GenCutTool = "DaughtersInLHCb"

from Configurables import FlatNParticles
pgun.NumberOfParticlesTool = "FlatNParticles"
pgun.addTool(FlatNParticles, name="FlatNParticles")
Пример #7
0
def setup_Targets_pguns(projID, projEng, targMat, targThick):

    from Configurables import ParticleGun
    from GaudiKernel.SystemOfUnits import mm, GeV, rad

    # Set up ParticleGun
    ParticleGun = ParticleGun("ParticleGun")

    # Control of the ParticleGun
    # Event type is set as described in LHCb-2005-034 : G=5! (Def = 0)
    ParticleGun.EventType = 53210205

    # Pick the type of particle gun generator
    from Configurables import MaterialEval
    ParticleGun.addTool(MaterialEval, name="MaterialEval")
    ParticleGun.ParticleGunTool = "MaterialEval"

    # Set fixed number of particles to produce in an event (default = 10) and
    # their PDG code (default = 2221111)
    from Configurables import FlatNParticles
    ParticleGun.addTool(FlatNParticles, name="FlatNParticles")
    ParticleGun.NumberOfParticlesTool = "FlatNParticles"
    ParticleGun.FlatNParticles.MinNParticles = 1
    ParticleGun.FlatNParticles.MaxNParticles = 1
    ParticleGun.MaterialEval.PdgCode = particles[projID]

    # The vertex of each particle gun is produced in a single point of given
    # coordinates. Default is 0.0*mm for all.
    # distribution within the given limits, when min=max the vertex is in the
    # given point.
    #ParticleGun.MaterialEval.Xorig = 0*mm
    #ParticleGun.MaterialEval.Yorig = 0*mm
    ParticleGun.MaterialEval.Zorig = Zorig[targMat][targThick] * mm

    # The abs(P) of the particle if fixed at the given value (default = 500 GeV)
    ParticleGun.MaterialEval.ModP = projEng * GeV

    # The particle can be generated uniformly (randomly or in a grid) in eta-phi
    # rather than x-y (default is false, i.e. x-y)
    ParticleGun.MaterialEval.EtaPhi = True

    # The boundary limits of the x-y or eta-phi planes have to given.
    #
    # The following options are for the x-y plane, to specify the position
    # and size of the "target rectangle". The default plane is at z = 10*m,
    # with -3.2*m < x < 3.2*m and -2.6*m < y < -2.6*m, i.e. a little more
    # than the LHCb acceptance
    ParticleGun.MaterialEval.ZPlane = Zplane[targMat][targThick] * mm
    #ParticleGun.MaterialEval.Xmin   = -15*m
    #ParticleGun.MaterialEval.Ymin   = -15*m
    #ParticleGun.MaterialEval.Xmax   =  15*m
    #ParticleGun.MaterialEval.Ymax   =  15*m

    # The follwing control the parameters for the generation in eta-phi.
    # The defaults are 2.1 < eta < 4.9 and phi over 2pi, i.e. a little more
    # than scanning the LHCb acceptance
    ParticleGun.MaterialEval.MinEta = 10.
    ParticleGun.MaterialEval.MaxEta = 10.
    ParticleGun.MaterialEval.MinPhi = 0.0 * rad
    ParticleGun.MaterialEval.MaxPhi = 0.0 * rad

    # A regular grid of given steps can be used instead of a randomly uniform
    # distribution (default = false)
    ParticleGun.MaterialEval.UseGrid = False
Пример #8
0
LHCbApp().DDDBtag = "Sim08-20130503-1"
LHCbApp().CondDBtag = "Sim08-20130503-1-vc-md100"

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

from Gauss.Configuration import *
Gauss().Production = 'PGUN'
Gauss().DatasetName = "test"

Gauss().Phases = ["Generator","GenToMCTree"] 

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

from Configurables import ParticleGun, FlatNParticles, MomentumSpectrum

pgun = ParticleGun()

pgun.ParticleGunTool = "MomentumSpectrum"
pgun.addTool( MomentumSpectrum , name = "MomentumSpectrum" )

pgun.MomentumSpectrum.PdgCodes = [ 511 , -511 ]
pgun.MomentumSpectrum.InputFile = "BSpectrum.root"
pgun.MomentumSpectrum.HistogramPath = "BSpectrum"
pgun.MomentumSpectrum.OutputLevel = 3

pgun.NumberOfParticlesTool = "FlatNParticles"
pgun.addTool( FlatNParticles , name = "FlatNParticles" )



Пример #9
0
GaussGen = GenInit("GaussGen")
#
# Set the random numbers - these fix the random seed.
#
GaussGen.FirstEventNumber = FIRST_EVENT_NUMBER
GaussGen.RunNumber = RUN_NUMBER

# The output is managed below, so we disable the standard Gauss output.
Gauss().OutputType = 'NONE'
Gauss().Histograms = 'NONE'

############################################################################
## Set properties of particles to be generated

## momentum properties
ParticleGun().addTool(MomentumRange)
ParticleGun().ParticleGunTool = "MomentumRange"

## number of particles (default=1)
ParticleGun().addTool(FlatNParticles)
ParticleGun().NumberOfParticlesTool = "FlatNParticles"
ParticleGun().EventType = 52210001

############################################################################
## Add event decay tool (not clear if needed)
ToolSvc().addTool(EvtGenDecay)
ToolSvc(
).EvtGenDecay.UserDecayFile = "$DECFILESROOT/dkfiles/mu+mu-,fixP=TrkAcc.dec"

## Commented out TrackerAcceptance script as it restricts theta-phi range to LHCb
#from Gaudi.Configuration import *
def execute(pos="c", angle=0):
    importOptions(
        "$APPCONFIGOPTS/Gauss/Beam7000GeV-md100-nu7.6-HorExtAngle.py")

    importOptions("$LBPYTHIA8ROOT/options/Pythia8.py")
    importOptions("$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py")
    importOptions("$APPCONFIGOPTS/Conditions/Upgrade.py")
    importOptions("$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py")

    #importOptions("$APPCONFIGOPTS/Gauss/Gauss-Upgrade-Baseline-20131029.py")
    # FTv5
    importOptions('$APPCONFIGOPTS/Gauss/Gauss-Upgrade-Baseline-20150522.py')

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

    Gauss().DataType = "Upgrade"

    #LHCbApp().DDDBtag = "dddb-20150424"
    #LHCbApp().CondDBtag = "sim-20140204-vc-md100"

    #LHCbApp().DDDBtag = "dddb-20150424"
    #LHCbApp().CondDBtag = "sim-20140204-vc-md100"

    # FTv5 from Luigi
    LHCbApp().DDDBtag = "dddb-20150424"
    LHCbApp().CondDBtag = "sim-20140204-vc-md100"
    #DDDBConf().DbRoot = "/home/ttekampe/SciFi/FTv5/DDDB_FTv5_20150424_s20140204_lhcbv38r6/lhcb.xml"

    #work around for bug in DB
    CondDB().LoadCALIBDB = 'HLT1'
    CondDB().addLayer(dbFile="DDDB_FTv5_20150424_s20140204_lhcbv38r6.db",
                      dbName="DDDB")

    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

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

    OutputStream(
        "GaussTape"
    ).Output = "DATAFILE='PFN:%s.sim' TYP='POOL_ROOTTREE' OPT='RECREATE'" % outpath
Пример #11
0
# file /build/jenkins-tests/workspace/nightly-builds/checkout/tmp/checkout/DBASE/Gen/DecFiles/v31r0/options/51000034.py generated: Fri, 05 Oct 2018 16:18:46
#
# Event Type: 51000000
#
# ASCII decay Descriptor: e- => ?
#
from Configurables import ParticleGun
from Configurables import MomentumRange
ParticleGun().addTool( MomentumRange )
from GaudiKernel import SystemOfUnits
ParticleGun().MomentumRange.MomentumMin = 33.8*SystemOfUnits.GeV
from GaudiKernel import SystemOfUnits
ParticleGun().MomentumRange.MomentumMax = 33.8*SystemOfUnits.GeV
ParticleGun().EventType = 51000034
ParticleGun().ParticleGunTool = "MomentumRange"
ParticleGun().NumberOfParticlesTool = "FlatNParticles"
ParticleGun().MomentumRange.PdgCodes = [ 11 ]
from Configurables import ToolSvc
from Configurables import EvtGenDecay
ToolSvc().addTool( EvtGenDecay )
ToolSvc().EvtGenDecay.UserDecayFile = "$DECFILESROOT/dkfiles/e-,fixP=CaloAcc.dec"
from Gaudi.Configuration import *
importOptions( "$DECFILESROOT/options/CaloAcceptance.py" )
Пример #12
0
#  (0,0,0) in the LHCb reference system, with 1 GeV < abs(P) < 100 GeV,
#  0.15 mrad < theta < 0.300 mrad and 0 < phi < 2pi
#
#  Include this file instead of the EVENTTYPE.opts after all you other
#  options.
#
#  @author : G.Corti
#  @date   : last modified on 2009-11-04
##############################################################################

from Gaudi.Configuration import *
from Configurables import ParticleGun
from GaudiKernel.SystemOfUnits import *

# Set up ParticleGun
ParticleGun = ParticleGun("ParticleGun")

# Control of the ParticleGun
# Event type is set as described in LHCb-2005-034 : G=5! (Def = 0)
ParticleGun.EventType = 53210205

# GunMode flag:
#   if = MomentumRange uses parameters below within random values generated
#   if = FixedMomentum need to set fix values of px, py, pz via specific properties
from Configurables import MomentumRange
ParticleGun.addTool(MomentumRange, name="MomentumRange")
ParticleGun.ParticleGunTool = "MomentumRange"

#from Configurables import FixedMomentum
#ParticleGun.addTool(FixedMomentum, name="FixedMomentum")
#ParticleGun.ParticleGunTool = "FixedMomentum"
def execute(evt_type=13104021, stereo=5):
    importOptions(
        "$APPCONFIGOPTS/Gauss/Beam7000GeV-md100-nu7.6-HorExtAngle.py")

    importOptions("$LBPYTHIA8ROOT/options/Pythia8.py")
    importOptions("$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py")
    importOptions("$APPCONFIGOPTS/Conditions/Upgrade.py")
    importOptions("$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py")
    importOptions("$APPCONFIGOPTS/Gauss/Gauss-Upgrade-Baseline-20131029.py")

    outpath = "%s_%s" % ("Gun", evt_type)
    Gauss().DataType = "Upgrade"

    set_tags(stereo)

    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"
    x_orig = 480
    y_orig = 500
    ParticleGun().MaterialEval.Xorig = x_orig
    ParticleGun().MaterialEval.Yorig = y_orig
    ParticleGun().MaterialEval.Zorig = 7620
    ParticleGun().MaterialEval.ModP = 150000  #150GeV

    ParticleGun().MaterialEval.ZPlane = 9439
    ParticleGun().MaterialEval.Xmin = x_orig - 20
    ParticleGun().MaterialEval.Xmax = x_orig + 20
    ParticleGun().MaterialEval.Ymin = y_orig - 5
    ParticleGun().MaterialEval.Ymax = y_orig + 5
    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 = 2
    ParticleGun().FlatNParticles.MaxNParticles = 2

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

    LHCbApp().EvtMax = 10

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

    OutputStream(
        "GaussTape"
    ).Output = "DATAFILE='PFN:%s.sim' TYP='POOL_ROOTTREE' OPT='RECREATE'" % outpath
def execute(pos="c", angle=0, eng=180, part=211):
    importOptions(
        "$APPCONFIGOPTS/Gauss/Beam7000GeV-md100-nu7.6-HorExtAngle.py")

    importOptions("$LBPYTHIA8ROOT/options/Pythia8.py")
    importOptions("$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmNoCuts.py")
    importOptions("$APPCONFIGOPTS/Conditions/Upgrade.py")
    importOptions("$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py")

    # FTv5
    importOptions('$APPCONFIGOPTS/Gauss/Gauss-Upgrade-Baseline-20150522.py')

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

    Gauss().DataType = "Upgrade"

    LHCbApp().DDDBtag = "dddb-20160304"
    LHCbApp().CondDBtag = "sim-20150716-vc-md100"
    CondDB().addLayer(
        dbFile=
        "/eos/lhcb/wg/SciFi/Custom_Geoms_Upgrade/databases/DDDB_FT61_noEndplug.db",
        dbName="DDDB")
    CondDB.LocalTags = {"SIMCOND": ["magnet-off"]}

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

    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

    posA = {
        #"x": 2600.55,  ## Far from beam
        "x": 138.8,  ## Close to the beam: importan when using irradiated mats
        "y": 63.378,
        "z": 7783.228
    }
    posC = {
        #"x" : 2600.55, ## Far from beam
        "x": 138.8,  ## Close to the beam: importan when using irradiated mats
        "y": 2363.363,
        "z": 7791.510
    }

    hit_pos = {}
    if pos == "a":
        hit_pos = posA
    elif pos == "c":
        hit_pos = posC
    else:
        exit()

    # origin point
    orig_delta_z = 7000.
    orig_x = hit_pos["x"] + orig_delta_z * tan(radians(angle))
    orig_y = hit_pos["y"]
    orig_z = hit_pos["z"] - orig_delta_z

    # beam spread parameter
    # see http://cds.cern.ch/record/2108337/files/LHCb-PUB-2015-025.pdf, Fig. 1.8
    beam_width_x = 13.
    beam_width_y = 5.

    ParticleGun().MaterialEval.Xorig = orig_x
    ParticleGun().MaterialEval.Yorig = orig_y
    ParticleGun().MaterialEval.Zorig = orig_z

    # target point
    target_delta_z = 300.
    target_x = hit_pos["x"] - target_delta_z * tan(radians(angle))
    target_y = hit_pos["y"]
    target_z = hit_pos["z"] + target_delta_z

    ParticleGun().MaterialEval.ZPlane = target_z
    ParticleGun().MaterialEval.Xmin = target_x - beam_width_x / 2.
    ParticleGun().MaterialEval.Xmax = target_x + beam_width_x / 2.
    ParticleGun().MaterialEval.Ymin = target_y - beam_width_y / 2.
    ParticleGun().MaterialEval.Ymax = target_y + beam_width_y / 2.

    # particle options
    ParticleGun().MaterialEval.PdgCode = part
    ParticleGun().MaterialEval.ModP = eng * units.GeV

    # 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 = 10000

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

    OutputStream(
        "GaussTape"
    ).Output = "DATAFILE='PFN:%s.sim' TYP='POOL_ROOTTREE' OPT='RECREATE'" % outpath
Пример #15
0
# This example will generate one mu+ or mu- per event passing
# through the RICH1 scintillator trigger
#   
# Include this file instead of the EVENTTYPE.opts after all you other 
# options.
#
# @author : C.Jones
# @date   : 15/07/2009
##############################################################################

from Gaudi.Configuration import *
from Configurables import ParticleGun
from GaudiKernel.SystemOfUnits import *

# Set up ParticleGun
ParticleGun = ParticleGun("ParticleGun")

# Event type is set as described in LHCb-2005-034 : G=5! (Def = 0)
# gsdctnxu:
# g=type of process (5=particle gun)
# s=which particles are present and pass 400mrad w.r.t.beam cut; 2=mu
# d=decay; particle or antipart; 2=several particles (??)
# c=eta and p distribution : 2 (0=fix p, 1=flat eta, 2=flat xy, 3=mom range)
# tnxu = track parameters; if c=2 or 3, tn=00;
ParticleGun.EventType = 52220000

# Pick the type of particle gun generator
from Configurables import Cosmics
ParticleGun.addTool(Cosmics, name="Cosmics")
ParticleGun.ParticleGunTool = "Cosmics"
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