Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:28

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 import os
0004 
0005 mySample = "g4"
0006 mySection = "0"
0007 myEvent = "100"
0008 mySeed = "32789"
0009 myEnergy = "20"
0010 
0011 # condor_output_vtx50 -------------------------------------
0012 # vertex sigma 5.0 : not much different at this time.
0013 myParList = cms.vdouble(1.006, 1.0, 0.0, 1.82790e+00, 3.66237e+00, 0.965, 1.0)
0014 myNameTag = mySample + "_" + myEnergy + "_" + mySection
0015 
0016 process = cms.Process("TBSim")
0017 
0018 
0019 
0020 
0021 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0022 
0023     
0024 process.load("SimGeneral.HepPDTESSource.pythiapdt_cfi")
0025 
0026 process.RandomNumberGeneratorService = cms.Service("RandomNumberGeneratorService",
0027     saveFileName = cms.untracked.string(''),
0028     theSource = cms.PSet(
0029         initialSeed = cms.untracked.uint32(7824367),      
0030         engineName = cms.untracked.string('HepJamesRandom') 
0031     ),                                                      
0032     generator = cms.PSet(
0033         initialSeed = cms.untracked.uint32(int(mySeed)),      
0034         engineName = cms.untracked.string('HepJamesRandom') 
0035     ),                                                      
0036     VtxSmeared = cms.PSet(
0037         initialSeed = cms.untracked.uint32(98765432),
0038         engineName = cms.untracked.string('HepJamesRandom')
0039     ),
0040     g4SimHits = cms.PSet(
0041         initialSeed = cms.untracked.uint32(11),
0042         engineName = cms.untracked.string('HepJamesRandom')
0043     ),
0044     SimEcalTBG4Object = cms.PSet(
0045         initialSeed = cms.untracked.uint32(12),
0046         engineName = cms.untracked.string('HepJamesRandom')
0047     ),
0048     mix = cms.PSet(
0049         initialSeed = cms.untracked.uint32(12345),
0050         engineName = cms.untracked.string('HepJamesRandom')
0051     ),
0052 )
0053 
0054 process.randomEngineStateProducer = cms.EDProducer("RandomEngineStateProducer")
0055 
0056 
0057 process.maxEvents = cms.untracked.PSet(
0058     input = cms.untracked.int32(int(myEvent)*10)
0059 )
0060 
0061 #Geometry
0062 
0063 #process.load("SimG4CMS.EcalTestBeam.crystal248_cff")
0064 process.common_beam_direction_parameters = cms.PSet(
0065     BeamMeanY = cms.double(0.0),
0066     BeamMeanX = cms.double(0.0),
0067     MinEta = cms.double(0.221605),
0068     MaxEta = cms.double(0.221605),
0069     MinPhi = cms.double(0.0467487),
0070     MaxPhi = cms.double(0.0467487),
0071 #    Psi    = cms.double(999.9),
0072     BeamPosition = cms.double(-26733.5)
0073 )
0074 
0075 
0076 
0077 #process.load("Geometry.EcalTestBeam.TBH4GeometryXML_cfi")
0078 process.MuonNumberingInitialization = cms.ESProducer("MuonNumberingInitialization")
0079 process.XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource",
0080     geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/materials.xml', 
0081         'Geometry/CMSCommonData/data/rotations.xml', 
0082         'Geometry/EcalTestBeam/data/ebcon.xml', 
0083         'Geometry/EcalCommonData/data/ebrot.xml', 
0084         'Geometry/EcalTestBeam/data/eregalgo.xml', 
0085         'Geometry/EcalCommonData/data/ebalgo.xml', 
0086         'Geometry/EcalTestBeam/data/tbrot.xml',
0087         'Geometry/EcalTestBeam/data/TBH4.xml', 
0088         'Geometry/EcalTestBeam/data/TBH4ecalsens.xml', 
0089         'Geometry/HcalSimData/data/CaloUtil.xml', 
0090         #'Geometry/EcalSimData/data/EcalProdCuts.xml', 
0091         #'Geometry/EcalTestBeam/data/TBH4ProdCuts.xml',
0092         'SimG4Core/GFlash/TB/gflashTBH4ProdCuts.xml',
0093         'Geometry/CMSCommonData/data/FieldParameters.xml'),
0094     rootNodeName = cms.string('TBH4:OCMS')
0095 )
0096 
0097 
0098 process.load("Geometry.CaloEventSetup.CaloGeometry_cff")
0099 process.load("Geometry.CaloEventSetup.CaloTopology_cfi")
0100 process.load("Geometry.EcalMapping.EcalMapping_cfi")
0101 process.load("Geometry.CaloEventSetup.EcalTrigTowerConstituents_cfi")
0102 process.CaloGeometryBuilder.SelectedCalos = ['EcalBarrel']
0103 #, 'EcalEndcap']
0104 
0105 
0106 # No magnetic field
0107 
0108 process.load("MagneticField.Engine.uniformMagneticField_cfi")
0109 
0110 process.source = cms.Source("EmptySource")
0111 
0112 process.generator = cms.EDProducer("FlatRandomEGunProducer",
0113     PGunParameters = cms.PSet(
0114         process.common_beam_direction_parameters,
0115         PartID = cms.vint32(11),
0116         MinE = cms.double(float(myEnergy)),
0117         MaxE = cms.double(float(myEnergy))
0118     ),
0119     Verbosity = cms.untracked.int32(0), ## set to 1 (or greater)  for printouts
0120 
0121     psethack = cms.string('single electron'),
0122     AddAntiParticle = cms.bool(False),
0123 )
0124 
0125 process.ProductionFilterSequence = cms.Sequence(process.generator)
0126 
0127 from IOMC.EventVertexGenerators.VtxSmearedParameters_cfi import *
0128 
0129 #
0130 # this module takes input in the units of *cm* and *radian*!!!
0131 #
0132 
0133 process.VtxSmeared = cms.EDProducer("BeamProfileVtxGenerator",
0134     process.common_beam_direction_parameters,
0135     VtxSmearedCommon,
0136 #    BeamSigmaX = cms.double(2.4),
0137 #    BeamSigmaY = cms.double(2.4),
0138 #    GaussianProfile = cms.bool(False),
0139     BeamSigmaX = cms.double(5.0),
0140     BeamSigmaY = cms.double(5.0),
0141     Psi             = cms.double(999.9),
0142     GaussianProfile = cms.bool(True),
0143     BinX = cms.int32(50),
0144     BinY = cms.int32(50),
0145     File       = cms.string('beam.profile'),
0146     UseFile    = cms.bool(False),
0147     TimeOffset = cms.double(0.)                      
0148 )
0149 
0150 # Geant4, ECAL test beam specific OscarProducer configuration
0151 
0152 process.load("SimG4Core.Application.g4SimHits_cfi")
0153 
0154 process.g4SimHits.UseMagneticField = cms.bool(False)
0155 process.g4SimHits.Physics.DefaultCutValue = 1.
0156 process.g4SimHits.NonBeamEvent = cms.bool(True)
0157 process.g4SimHits.Generator.HepMCProductLabel = cms.string('generatorSmeared')
0158 process.g4SimHits.Generator.ApplyPCuts = cms.bool(False)
0159 process.g4SimHits.Generator.ApplyEtaCuts = cms.bool(True)
0160 process.g4SimHits.Generator.ApplyPhiCuts = cms.bool(False)
0161 process.g4SimHits.Generator.MaxEtaCut = cms.double(1.5)
0162 process.g4SimHits.Generator.MinEtaCut = cms.double(0.0)
0163 process.g4SimHits.CaloSD.CorrectTOFBeam = cms.bool(True)
0164 process.g4SimHits.CaloSD.BeamPosition = cms.double(-26733.5)
0165 process.g4SimHits.CaloTrkProcessing.TestBeam = cms.bool(True)
0166 process.g4SimHits.StackingAction.MaxTrackTime = cms.double(10000.)
0167 process.g4SimHits.SteppingAction.MaxTrackTime = cms.double(10000.)
0168 process.g4SimHits.CaloSD.TmaxHit = cms.double(10000.)
0169 process.g4SimHits.CaloSD.TmaxHits = cms.vdouble(10000.,10000.,10000.,10000.,10000.)
0170 process.g4SimHits.Watchers = cms.VPSet(cms.PSet(
0171     type = cms.string('EcalTBH4Trigger'),
0172     verbose = cms.untracked.bool(False),
0173     #IMPORTANT    #    #    #    #    #    #    #    # NUMBER OF EVENTS TO BE TRIGGERED 
0174     trigEvents = cms.untracked.int32(int(myEvent))
0175 ))
0176 
0177 
0178 # Test Beam ECAL specific MC info
0179 
0180 process.SimEcalTBG4Object = cms.EDProducer("EcalTBMCInfoProducer",
0181     process.common_beam_direction_parameters,
0182     CrystalMapFile = cms.FileInPath('Geometry/EcalTestBeam/data/BarrelSM1CrystalCenterElectron120GeV.dat'),
0183     moduleLabelVtx = cms.untracked.string('generatorSmeared')
0184 )
0185 
0186 # Test Beam ECAL hodoscope raw data simulation
0187 
0188 process.SimEcalTBHodoscope = cms.EDProducer("TBHodoActiveVolumeRawInfoProducer")
0189 
0190 # Test Beam ECAL Event header filling
0191 
0192 process.SimEcalEventHeader = cms.EDProducer("FakeTBEventHeaderProducer",
0193     EcalTBInfoLabel = cms.untracked.string('SimEcalTBG4Object')
0194 )
0195 
0196 # Digitization
0197 
0198 # no pileup
0199 
0200 process.load("SimGeneral.MixingModule.mixNoPU_cfi")
0201 
0202 # fake TB conditions
0203 
0204 process.load("CalibCalorimetry.EcalTrivialCondModules.EcalTrivialCondRetrieverTB_cfi")
0205 
0206 process.load("CalibCalorimetry.EcalTrivialCondModules.ESTrivialCondRetriever_cfi")
0207 
0208 # Test beam unsuppressed digis
0209 
0210 process.load("SimCalorimetry.EcalTestBeam.ecaldigi_testbeam_cfi")
0211 
0212 # local reco
0213 process.load("Configuration.EcalTB.localReco_tbsim_cff")
0214  
0215 # ntuplizer for TB data format
0216 #process.treeProducerCalibSimul = cms.EDFilter("TreeProducerCalibSimul",
0217 #    rootfile = cms.untracked.string("treeTB_"+myNameTag+".root"),
0218 #    eventHeaderCollection = cms.string(''),
0219 #    eventHeaderProducer = cms.string('SimEcalEventHeader'),
0220 #    txtfile = cms.untracked.string("treeTB_"+myNameTag+".txt"),
0221 #    EBRecHitCollection = cms.string('EcalRecHitsEB'),
0222 #    tdcRecInfoCollection = cms.string('EcalTBTDCRecInfo'),
0223 #    xtalInBeam = cms.untracked.int32(248),
0224 #    hodoRecInfoProducer = cms.string('ecalTBSimHodoscopeReconstructor'),
0225 #    hodoRecInfoCollection = cms.string('EcalTBHodoscopeRecInfo'),
0226 #    RecHitProducer = cms.string('ecalTBSimRecHit'),
0227 #    tdcRecInfoProducer = cms.string('ecalTBSimTDCReconstructor')
0228 #)
0229 
0230 # turning on/off Gflash
0231 if mySample == "gf":
0232     process.ecal_notCont_sim.EBs25notContainment = 1.0
0233     process.ecal_notCont_sim.EEs25notContainment = 1.0
0234     process.g4SimHits.Physics.type = 'SimG4Core/Physics/GFlash'
0235     process.g4SimHits.Physics.GFlash = cms.PSet(
0236         bField = cms.double(0.0),
0237         GflashEMShowerModel = cms.bool(True),
0238         GflashHadronShowerModel = cms.bool(True),
0239         GflashHistogram = cms.bool(True),
0240         GflashHistogramName = cms.string("gflash_histogram_"+myNameTag+".root"),
0241         GflashHadronPhysics = cms.string('QGSP_BERT'),
0242         GflashHcalOuter = cms.bool(True),
0243         GflashExportToFastSim = cms.bool(False),
0244         watcherOn = cms.bool(False),
0245         Verbosity = cms.untracked.int32(0),
0246         tuning_pList = myParList
0247     )
0248 
0249 print("physics type : ", process.g4SimHits.Physics.type)
0250 
0251 # sequences
0252 process.doSimHits = cms.Sequence(process.ProductionFilterSequence*process.VtxSmeared*process.g4SimHits)
0253 process.doSimTB = cms.Sequence(process.SimEcalTBG4Object*process.SimEcalTBHodoscope*process.SimEcalEventHeader)
0254 process.doEcalDigis = cms.Sequence(process.mix)
0255 #process.p1 = cms.Path(process.doSimHits*process.doSimTB*process.doEcalDigis*process.localReco_tbsim*process.treeProducerCalibSimul)
0256 process.p1 = cms.Path(process.doSimHits*process.doSimTB*process.doEcalDigis*process.localReco_tbsim)
0257 
0258 
0259 
0260 # modify the default behavior of the MessageLogger
0261     
0262 #process.MessageLogger.debugModule = cms.untracked.vstring('g4SimHits','generatorSmeared')
0263 
0264 #Configuring the G4msg.log output
0265 process.MessageLogger.files = dict(G4msg =  cms.untracked.PSet(
0266     noTimeStamps = cms.untracked.bool(True)
0267     #First eliminate unneeded output
0268     ,threshold = cms.untracked.string('INFO')
0269     #,DEBUG = cms.untracked.PSet(limit = cms.untracked.int32(0))
0270     ,INFO = cms.untracked.PSet(limit = cms.untracked.int32(0))
0271     ,FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(0))
0272     ,FwkSummary = cms.untracked.PSet(limit = cms.untracked.int32(0))
0273     ,Root_NoDictionary = cms.untracked.PSet(limit = cms.untracked.int32(0))
0274     ,FwkJob = cms.untracked.PSet(limit = cms.untracked.int32(0))
0275     ,TimeReport = cms.untracked.PSet(limit = cms.untracked.int32(0))
0276     ,TimeModule = cms.untracked.PSet(limit = cms.untracked.int32(0))
0277     ,TimeEvent = cms.untracked.PSet(limit = cms.untracked.int32(0))
0278     ,MemoryCheck = cms.untracked.PSet(limit = cms.untracked.int32(0))
0279     #TimeModule, TimeEvent, TimeReport are written to LogAsbolute instead of LogInfo with a category
0280     #so they cannot be eliminated from any destination (!) unless one uses the summaryOnly option
0281     #in the Timing Service... at the price of silencing the output needed for the TimingReport profiling
0282     #
0283     #Then add the wanted ones:
0284     ,PhysicsList = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0285     ,G4cout = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0286     ,G4cerr = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0287     ,BeamProfileVtxGenerator = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0288     )
0289 )
0290 
0291 #Add these 3 lines to put back the summary for timing information at the end of the logfile
0292 #(needed for TimeReport report)
0293 process.options = cms.untracked.PSet(
0294     wantSummary = cms.untracked.bool(True)
0295 )
0296 
0297 
0298 #if not hasattr(process,"options") :
0299 process.options = cms.untracked.PSet()
0300 process.options.SkipEvent = cms.untracked.vstring('EventCorruption')
0301 
0302