CMS 3D CMS Logo

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

Functions

def digitizersFull2Fast
 
def get_PileUpSimulatorPSet_PileUpProducer
 
def get_VertexGeneratorPSet_PileUpProducer
 
def prepareDigiRecoMixing
 
def prepareGenMixing
 

Function Documentation

def MixingModule_Full2Fast.digitizersFull2Fast (   digitizers)

Definition at line 77 of file MixingModule_Full2Fast.py.

Referenced by prepareDigiRecoMixing().

77 
78 def digitizersFull2Fast(digitizers):
79 
80  # fastsim does not simulate castor
81  if hasattr(digitizers,"castor"):
82  delattr(digitizers,"castor")
83  else:
84  print "WARNING: digitizers has no attribute 'castor'"
85 
86  # fastsim does not digitize pixel and strip hits, it mixes tracks
87  if hasattr(digitizers,"pixel") and hasattr(digitizers,"strip"):
88  delattr(digitizers,"pixel")
89  delattr(digitizers,"strip")
90  import FastSimulation.Tracking.recoTrackAccumulator_cfi
91  digitizers.tracker = cms.PSet(FastSimulation.Tracking.recoTrackAccumulator_cfi.recoTrackAccumulator)
92  else:
93  print "WARNING: digitizers has no attribute 'pixel' and/or 'strip'"
94  print " : => not mixing tracks"
95 
96  # fastsim has its own names for simhit collections
97  for element in ["ecal","hcal"]:
98  if hasattr(digitizers,element):
99  getattr(digitizers,element).hitsProducer = "famosSimHits"
100  else:
101  print "WARNING: digitizers has no attribute '{0}'".format(element)
102 
103  # fastsim has different input for merged truth
104  if hasattr(digitizers,"mergedtruth"):
105  digitizers.mergedtruth.allowDifferentSimHitProcesses = True
106  digitizers.mergedtruth.simHitCollections = cms.PSet(
107  muon = cms.VInputTag( cms.InputTag('MuonSimHits','MuonDTHits'),
108  cms.InputTag('MuonSimHits','MuonCSCHits'),
109  cms.InputTag('MuonSimHits','MuonRPCHits') ),
110  trackerAndPixel = cms.VInputTag( cms.InputTag('famosSimHits','TrackerHits') )
111  )
112  digitizers.mergedtruth.simTrackCollection = cms.InputTag('famosSimHits')
113  digitizers.mergedtruth.simVertexCollection = cms.InputTag('famosSimHits')
114 
115  return digitizers
116 
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 204 of file MixingModule_Full2Fast.py.

References digitizersFull2Fast().

Referenced by prepareGenMixing().

205 def prepareDigiRecoMixing(process):
206 
207  # switch to FastSim digitizers
208  process.mix.digitizers = digitizersFull2Fast(process.mix.digitizers)
209 
210  # switch to FastSim mixObjects
211  import FastSimulation.Configuration.mixObjects_cfi
212  process.mix.mixObjects = FastSimulation.Configuration.mixObjects_cfi.theMixObjects
213 
214  # fastsim does not simulate castor
215  # fastsim does not digitize pixel and strip hits
216  for element in ["simCastorDigis","simSiPixelDigis","simSiStripDigis"]:
217  if hasattr(process,element):
218  delattr(process,element)
219 
220  # get rid of some FullSim specific psets that work confusing when dumping FastSim cfgs
221  # (this is optional)
222  del process.theDigitizers
223  del process.theDigitizersValid
224  del process.trackingParticles
225  del process.stripDigitizer
226  del process.SiStripSimBlock
227  del process.castorDigitizer
228  del process.pixelDigitizer
229  del process.ecalDigitizer
230 
231  # get rid of FullSim specific services that work confusing when dumping FastSim cfgs
232  # (this is optional)
233  del process.siStripGainSimESProducer
234 
235  return process
def MixingModule_Full2Fast.prepareGenMixing (   process)

Definition at line 117 of file MixingModule_Full2Fast.py.

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

118 def prepareGenMixing(process):
119 
120  # prepare digitizers and mixObjects for Gen-mixing
121  process = prepareDigiRecoMixing(process)
122 
123  # OOT PU not supported for Gen-mixing: disable it
124  process.mix.maxBunch = cms.int32(0)
125  process.mix.minBunch = cms.int32(0)
126 
127  # set the bunch spacing
128  # bunch spacing matters for calorimeter calibration
129  # setting the bunch spacing here, will have actually no effect,
130  # but leads to consistency with the bunch spacing as hard coded in
131  # FastSimulation/PileUpProducer/plugins/PileUpProducer.cc
132  # where it is propagated to the pileUpInfo, from which calorimeter calibration reads the bunch spacing
133  process.mix.bunchspace = 450
134 
135  # define the PileUpProducer module
136  process.famosPileUp = cms.EDProducer(
137  "PileUpProducer",
138  PileUpSimulator = cms.PSet(),
139  VertexGenerator = cms.PSet()
140  )
141 
142  # get the pu vertex distribution
143  process.famosPileUp.VertexGenerator = get_VertexGeneratorPSet_PileUpProducer(process)
144 
145 
146  # get pu distribution from MixingModule
147  process.famosPileUp.PileUpSimulator = get_PileUpSimulatorPSet_PileUpProducer(process.mix.input)
148 
149  # MixingModule only used for digitization, no need for input
150  del process.mix.input
151 
152  # Insert the PileUpProducer in the simulation sequence
153  pos = process.psim.index(process.famosSimHits)
154  process.psim.insert(pos,process.famosPileUp)
155 
156  # No track mixing when Gen-mixing
157  del process.mix.digitizers.tracker
158  del process.mix.mixObjects.mixRecoTracks
159  del process.generalTracks
160  process.generalTracks = process.generalTracksBeforeMixing.clone()
161  process.iterTracking.replace(process.generalTracksBeforeMixing,process.generalTracks)
162  del process.generalTracksBeforeMixing
163 
164  # Use generalTracks where DIGI-RECO mixing requires preMixTracks
165  process.generalConversionTrackProducer.TrackProducer = cms.string('generalTracks')
166  process.generalConversionTrackProducerTmp.TrackProducer = cms.string('generalTracks')
167  process.trackerDrivenElectronSeedsTmp.TkColList = cms.VInputTag(cms.InputTag("generalTracks"))
168  process.trackerDrivenElectronSeeds.oldTrackCollection = "generalTracks"
169 
170  # take care of the track aliases for HLT
171 
172  _parameters = {
173  "generalTracks":cms.VPSet( cms.PSet(type=cms.string('recoTracks')),
174  cms.PSet(type=cms.string('recoTrackExtras')),
175  cms.PSet(type=cms.string('TrackingRecHitsOwned')),
176  cms.PSet(type=cms.string('floatedmValueMap')))
177  }
178  process.hltIter4HighPtMerged = cms.EDAlias(**_parameters)
179  process.hltIter2HighPtMerged = cms.EDAlias(**_parameters)
180  process.hltIter4Merged = cms.EDAlias(**_parameters)
181  process.hltIter2Merged = cms.EDAlias(**_parameters)
182  process.hltIter4Tau3MuMerged = cms.EDAlias(**_parameters)
183  process.hltIter4MergedReg = cms.EDAlias(**_parameters)
184  process.hltIter2MergedForElectrons = cms.EDAlias(**_parameters)
185  process.hltIter2MergedForPhotons = cms.EDAlias(**_parameters)
186  process.hltIter2L3MuonMerged = cms.EDAlias(**_parameters)
187  process.hltIter2L3MuonMergedReg = cms.EDAlias(**_parameters)
188  process.hltIter2MergedForBTag = cms.EDAlias(**_parameters)
189  process.hltIter2MergedForTau = cms.EDAlias(**_parameters)
190  process.hltIter4MergedForTau = cms.EDAlias(**_parameters)
191  process.hltIter2GlbTrkMuonMerged = cms.EDAlias(**_parameters)
192  process.hltIter2HighPtTkMuMerged = cms.EDAlias(**_parameters)
193  process.hltIter2HighPtTkMuIsoMerged = cms.EDAlias(**_parameters)
194  process.hltIter2DisplacedJpsiMerged = cms.EDAlias(**_parameters)
195  process.hltIter2DisplacedPsiPrimeMerged = cms.EDAlias(**_parameters)
196  process.hltIter2DisplacedNRMuMuMerged = cms.EDAlias(**_parameters)
197  process.hltIter0PFlowTrackSelectionHighPurityForBTag = cms.EDAlias(**_parameters)
198  process.hltIter4MergedWithIter012DisplacedJets = cms.EDAlias(**_parameters)
199 
200  # PileUp info must be read from PileUpProducer, rather than from MixingModule
201  process.addPileupInfo.PileupMixingLabel = cms.InputTag("famosPileUp")
202 
203  return process