CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
MixingModule_Full2Fast Namespace Reference

Functions

def get_PileUpSimulatorPSet_PileUpProducer
 
def get_VertexGeneratorPSet_PileUpProducer
 
def prepareDigiRecoMixing
 
def prepareGenMixing
 

Function Documentation

def MixingModule_Full2Fast.get_PileUpSimulatorPSet_PileUpProducer (   _input)

Definition at line 35 of file MixingModule_Full2Fast.py.

Referenced by prepareGenMixing().

35 
37 
38  # container for PileUpSimulator parameters
39  PileUpSimulator = cms.PSet()
40 
41  # Extract the type of pu distribution
42  _type = "none"
43  if hasattr(_input,"type"):
44  _type = _input.type
45 
46  if _type == "poisson":
47  if not hasattr(_input.nbPileupEvents,"averageNumber"):
48  print " ERROR while reading PU distribution for FastSim PileUpProducer:"
49  print " when process.mix.input.type is set to 'poisson', process.mix.input.nbPileupEvents.averageNumber must be specified."
50  raise
51  PileUpSimulator.averageNumber = _input.nbPileupEvents.averageNumber
52  PileUpSimulator.usePoisson = cms.bool(True)
53 
54  elif _type == "probFunction":
55  if not hasattr(_input.nbPileupEvents,"probFunctionVariable") or not hasattr(_input.nbPileupEvents,"probValue"):
56  print " ERROR while reading PU distribution for FastSim PileUpProducer:"
57  print " when process.mix.input.type is set to 'probFunction', process.mix.nbPileupEvents.probFunctionVariable and process.mix.nbPileupEvents.probValue must be specified"
58  raise
59  PileUpSimulator.usePoisson = cms.bool(False)
60  PileUpSimulator.probFunctionVariable = _input.nbPileupEvents.probFunctionVariable
61  PileUpSimulator.probValue = _input.nbPileupEvents.probValue
62 
63  elif _type != "none":
64  print " ERROR while reading PU distribution for FastSim PileUpProducer:"
65  print " value {0} for process.mix.input.type not supported by FastSim GEN-level PU mixing".format(_type)
66  raise
67 
68  # minbias files
69  from FastSimulation.PileUpProducer.PileUpFiles_cff import puFileNames
70  PileUpSimulator.fileNames = puFileNames.fileNames
71 
72  # a purely technical, but required, setting
73  PileUpSimulator.inputFile = cms.untracked.string('PileUpInputFile.txt')
74 
75  return PileUpSimulator
76 
def MixingModule_Full2Fast.get_VertexGeneratorPSet_PileUpProducer (   process)

Definition at line 10 of file MixingModule_Full2Fast.py.

References ConfigBuilder.dumpPython(), and python.rootplot.root2matplotlib.replace().

Referenced by prepareGenMixing().

10 
12 
13  # container for vertex parameters
14  vertexParameters = cms.PSet()
15 
16  # find the standard vertex generator
17  if not hasattr(process,"VtxSmeared"):
18  "WARNING: no vtx smearing applied (ok for steps other than SIM)"
19  return vertexParameters
20  vertexGenerator = process.VtxSmeared
21 
22  # check the type of the standard vertex generator
23  vertexGeneratorType = vertexGenerator.type_().replace("EvtVtxGenerator","")
24  vtxGenMap = {"Betafunc":"BetaFunc","Flat":"Flat","Gauss":"Gaussian"}
25  if not vertexGeneratorType in vtxGenMap.keys():
26  raise Error("WARNING: given vertex generator type for vertex smearing is not supported")
27  vertexParameters.type = cms.string(vtxGenMap[vertexGeneratorType])
28 
29  # set vertex generator parameters in PileUpProducer
30  vertexGeneratorParameterNames = vertexGenerator.parameterNames_()
31  for name in vertexGeneratorParameterNames:
32  exec("vertexParameters.{0} = {1}".format(name,getattr(vertexGenerator,name).dumpPython()))
33 
34  return vertexParameters
def MixingModule_Full2Fast.prepareDigiRecoMixing (   process)

Definition at line 137 of file MixingModule_Full2Fast.py.

Referenced by prepareGenMixing().

138 def prepareDigiRecoMixing(process):
139 
140  # switch to FastSim digitizers
141  if hasattr(process,"theDigitizersValid"):
142  del process.theDigitizersValid
143  from FastSimulation.Configuration.digitizers_cfi import theDigitizersValid
144  process.mix.digitizers = theDigitizersValid
145 
146  # switch to FastSim mixObjects
147  if hasattr(process,"theMixObjects"):
148  del process.theMixObjects
149  from FastSimulation.Configuration.mixObjects_cfi import theMixObjects
150  process.mix.mixObjects = theMixObjects
151 
152  # get rid of FullSim specific EDAliases for collections from MixingModule
153  del process.simCastorDigis
154  del process.simSiPixelDigis
155  del process.simSiStripDigis
156 
157  # import the FastSim specific EDAliases for collections from MixingModule
158  from FastSimulation.Configuration.digitizers_cfi import generalTracks
159  process.generalTracks = generalTracks
160 
161  # get rid of some FullSim specific psets that work confusing when dumping FastSim cfgs
162  # (this is optional)
163  del process.trackingParticles
164  del process.stripDigitizer
165  del process.SiStripSimBlock
166  del process.castorDigitizer
167  del process.pixelDigitizer
168  del process.ecalDigitizer
169 
170 
171  # get rid of FullSim specific services that work confusing when dumping FastSim cfgs
172  # (this is optional)
173  del process.siStripGainSimESProducer
174 
175  return process
def MixingModule_Full2Fast.prepareGenMixing (   process)

Definition at line 77 of file MixingModule_Full2Fast.py.

References get_PileUpSimulatorPSet_PileUpProducer(), get_VertexGeneratorPSet_PileUpProducer(), and prepareDigiRecoMixing().

77 
78 def prepareGenMixing(process):
79 
80  # prepare digitizers and mixObjects for Gen-mixing
81  process = prepareDigiRecoMixing(process)
82 
83  # for reasons of simplicity track mixing is not switched off,
84  # although it has no effect in case of Gen-mixing
85 
86  # OOT PU not supported for Gen-mixing: disable it
87  process.mix.maxBunch = cms.int32(0)
88  process.mix.minBunch = cms.int32(0)
89 
90  # set the bunch spacing
91  # bunch spacing matters for calorimeter calibration
92  # setting the bunch spacing here, will have actually no effect,
93  # but leads to consistency with the bunch spacing as hard coded in
94  # FastSimulation/PileUpProducer/plugins/PileUpProducer.cc
95  # where it is propagated to the pileUpInfo, from which calorimeter calibration reads the bunch spacing
96  process.mix.bunchspace = 450
97 
98  # define the PileUpProducer module
99  process.famosPileUp = cms.EDProducer(
100  "PileUpProducer",
101  PileUpSimulator = cms.PSet(),
102  VertexGenerator = cms.PSet()
103  )
104 
105  # get the pu vertex distribution
106  process.famosPileUp.VertexGenerator = get_VertexGeneratorPSet_PileUpProducer(process)
107 
108 
109  # get pu distribution from MixingModule
110  process.famosPileUp.PileUpSimulator = get_PileUpSimulatorPSet_PileUpProducer(process.mix.input)
111 
112  # MixingModule only used for digitization, no need for input
113  del process.mix.input
114 
115  # Insert the PileUpProducer in the simulation sequence
116  pos = process.simulationSequence.index(process.famosSimHits)
117  process.simulationSequence.insert(pos,process.famosPileUp)
118 
119  # No track mixing when Gen-mixing
120  del process.mix.digitizers.tracker
121  del process.mix.mixObjects.mixRecoTracks
122  del process.generalTracks
123  process.generalTracks = process.generalTracksBeforeMixing.clone()
124  process.iterTracking.replace(process.generalTracksBeforeMixing,process.generalTracks)
125  del process.generalTracksBeforeMixing
126 
127  # Use generalTracks where DIGI-RECO mixing requires preMixTracks
128  process.generalConversionTrackProducer.TrackProducer = cms.string('generalTracks')
129  # it's not nice but gen-mixing will be depricated anyhow
130  process.trackerDrivenElectronSeedsTmp.TkColList = cms.VInputTag(cms.InputTag("generalTracks"))
131  process.trackerDrivenElectronSeeds.oldTrackCollection = cms.InputTag('generalTracks')
132 
133  # PileUp info must be read from PileUpProducer, rather than from MixingModule
134  process.addPileupInfo.PileupMixingLabel = cms.InputTag("famosPileUp")
135 
136  return process