Skip to content
Snippets Groups Projects
tut_detsim_pan_matrix.py 7.09 KiB
Newer Older
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
#!/usr/bin/env python

import os
print(os.environ["DD4HEP_LIBRARY_PATH"])
import sys

from Gaudi.Configuration import *

##############################################################################
# Random Number Svc
##############################################################################
from Configurables import RndmGenSvc, HepRndm__Engine_CLHEP__RanluxEngine_

seed = [42]

rndmengine = HepRndm__Engine_CLHEP__HepJamesRandom_("RndmGenSvc.Engine") # The default engine in Geant4
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
rndmengine.SetSingleton = True
rndmengine.Seeds = seed

rndmgensvc = RndmGenSvc("RndmGenSvc")
rndmgensvc.Engine = rndmengine.name()
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed

##############################################################################
# Event Data Svc
##############################################################################
from Configurables import k4DataSvc
dsvc = k4DataSvc("EventDataSvc")
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed


##############################################################################
# Geometry Svc
##############################################################################

geometry_option = "CepC_v4-onlyVXD.xml"

if not os.getenv("DETCEPCV4ROOT"):
    print("Can't find the geometry. Please setup envvar DETCEPCV4ROOT." )
    sys.exit(-1)

geometry_path = os.path.join(os.getenv("DETCEPCV4ROOT"), "compact", geometry_option)
if not os.path.exists(geometry_path):
    print("Can't find the compact geometry file: %s"%geometry_path)
    sys.exit(-1)

from Configurables import GeomSvc
geosvc = GeomSvc("GeomSvc")
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
#geosvc.compact = geometry_path
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
geosvc.compact = "./Detector/DetEcalMatrix/compact/det.xml"
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed

##############################################################################
# Physics Generator
##############################################################################
from Configurables import GenAlgo
from Configurables import GtGunTool
from Configurables import StdHepRdr
from Configurables import SLCIORdr
from Configurables import HepMCRdr
from Configurables import GenPrinter

gun = GtGunTool("GtGunTool")
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
gun.Particles = ["gamma","gamma"]
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
gun.EnergyMins= [5 , 10] # GeV
gun.EnergyMaxs= [5 , 10] # GeV
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
gun.ThetaMins = [90, 90] # degree
gun.ThetaMaxs = [90, 90] # degree
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
gun.PhiMins   = [0,  4 ] # degree
gun.PhiMaxs   = [0,  4 ] # degree
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
#stdheprdr = StdHepRdr("StdHepRdr")
#stdheprdr.Input = "/cefs/data/stdhep/CEPC250/higgs/E250.Pbbh.whizard195/E250.Pbbh_X.e0.p0.whizard195/Pbbh_X.e0.p0.00001.stdhep"
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed

# lciordr = SLCIORdr("SLCIORdr")
# lciordr.Input = "/cefs/data/stdhep/lcio250/signal/Higgs/E250.Pbbh.whizard195/E250.Pbbh_X.e0.p0.whizard195/Pbbh_X.e0.p0.00001.slcio"

# hepmcrdr = HepMCRdr("HepMCRdr")
# hepmcrdr.Input = "example_UsingIterators.txt"

genprinter = GenPrinter("GenPrinter")

genalg = GenAlgo("GenAlgo")
genalg.GenTools = ["GtGunTool"]
#genalg.GenTools = ["StdHepRdr"]
# genalg.GenTools = ["StdHepRdr", "GenPrinter"]
# genalg.GenTools = ["SLCIORdr", "GenPrinter"]
# genalg.GenTools = ["HepMCRdr", "GenPrinter"]

##############################################################################
# Detector Simulation
##############################################################################
from Configurables import DetSimSvc
detsimsvc = DetSimSvc("DetSimSvc")
from Configurables import DetSimAlg
detsimalg = DetSimAlg("DetSimAlg")
detsimalg.RandomSeeds = seed

# detsimalg.VisMacs = ["Examples/options/vis.mac"]
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
detsimalg.RunCmds = [
#    "/tracking/verbose 1",
]
detsimalg.AnaElems = [
    "Edm4hepWriterAnaElemTool"
]
detsimalg.RootDetElem = "WorldDetElemTool"
from Configurables import AnExampleDetElemTool
example_dettool = AnExampleDetElemTool("AnExampleDetElemTool")
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
##############################################################################
# Detector digitization
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
##############################################################################
from Configurables import CaloDigiAlg
example_CaloDigiAlg = CaloDigiAlg("CaloDigiAlg")
example_CaloDigiAlg.Scale = 1
example_CaloDigiAlg.SimCaloHitCollection = "SimCalorimeterCol"
example_CaloDigiAlg.CaloHitCollection    = "ECALBarrel"
example_CaloDigiAlg.CaloAssociationCollection    = "RecoCaloAssociation_ECALBarrel"
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
##############################################################################
from Configurables import GearSvc
gearSvc  = GearSvc("GearSvc")
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
gearSvc.GearXMLFile = "./Detector/DetCEPCv4/compact/FullDetGear.xml"
##############################################################################
# Pandora 
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
##############################################################################
from Configurables import PandoraMatrixAlg

pandoralg = PandoraMatrixAlg("PandoraMatrixAlg")
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.collections = [
        "MCParticle:MCParticle",
        "CalorimeterHit:ECALBarrel",
        "MCRecoCaloAssociation:RecoCaloAssociation_ECALBarrel" 
        ]
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.WriteClusterCollection               = "PandoraClusters"              
pandoralg.WriteReconstructedParticleCollection = "PandoraPFOs" 
pandoralg.WriteVertexCollection                = "PandoraPFANewStartVertices"               
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.AnaOutput = "AnaMatrix.root"
pandoralg.PandoraSettingsDefault_xml = "./Reconstruction/PFA/Pandora/PandoraSettingsDefault.xml"
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.TrackCollections      =  ["MarlinTrkTracks"]
pandoralg.ECalCaloHitCollections=  ["ECALBarrel", "ECALEndcap", "ECALOther"]
pandoralg.HCalCaloHitCollections=  ["HCALBarrel", "HCALEndcap", "HCALOther"]
pandoralg.LCalCaloHitCollections=  ["LCAL"]
pandoralg.LHCalCaloHitCollections= ["LHCAL"]
pandoralg.MuonCaloHitCollections=  ["MUON"]
pandoralg.MCParticleCollections =  ["MCParticle"]
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.RelCaloHitCollections =  ["RecoCaloAssociation_ECALBarrel"]
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.RelTrackCollections   =  ["MarlinTrkTracksMCTruthLink"]
pandoralg.KinkVertexCollections =  ["KinkVertices"]
pandoralg.ProngVertexCollections=  ["ProngVertices"]
pandoralg.SplitVertexCollections=  ["SplitVertices"]
pandoralg.V0VertexCollections   =  ["V0Vertices"]
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.ECalToMipCalibration  = 112 #1000MeV/8.918
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.HCalToMipCalibration  = 34.8 
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.ECalMipThreshold      = 0.225# 8.918*0.225=2.00655
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.HCalMipThreshold      = 0.3 
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.ECalToEMGeVCalibration= 1.# BGO, to be tuned
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.HCalToEMGeVCalibration= 1.007 
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.ECalToHadGeVCalibrationBarrel= 1.12
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.ECalToHadGeVCalibrationEndCap= 1.12 
pandoralg.HCalToHadGeVCalibration= 1.07
pandoralg.MuonToMipCalibration= 10.0 
pandoralg.DigitalMuonHits= 0 
pandoralg.MaxHCalHitHadronicEnergy   = 1.0 
pandoralg.UseOldTrackStateCalculation= 0 
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.AbsorberRadLengthECal= 0.08945 #BG0: 1/11.18 mm 
pandoralg.AbsorberIntLengthECal= 0.00448 #BG0: 1/223.2 mm 
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
pandoralg.AbsorberRadLengthHCal= 0.0569 
pandoralg.AbsorberIntLengthHCal= 0.006  
pandoralg.AbsorberRadLengthOther= 0.0569
pandoralg.AbsorberIntLengthOther= 0.006 
##############################################################################

# write PODIO file
from Configurables import PodioOutput
write = PodioOutput("write")
write.filename = "test.root"
write.outputCommands = ["keep *"]

# ApplicationMgr
from Configurables import ApplicationMgr
ApplicationMgr(
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
        TopAlg = [genalg, detsimalg],
        #TopAlg = [genalg, detsimalg, example_CaloDigiAlg, pandoralg],
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
        EvtSel = 'NONE',
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
        EvtMax = 50,
        ExtSvc = [rndmengine, rndmgensvc, dsvc, geosvc, gearSvc,detsimsvc],
fangwx@ihep.ac.cn's avatar
fangwx@ihep.ac.cn committed
        OutputLevel=INFO
)