CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MixingModule_Full2Fast.py
Go to the documentation of this file.
1 #####################################
2 # customisation functions that allow to convert a FullSim PU cfg into a FastSim one
3 # main functions: prepareGenMixing and prepareDigiRecoMixing
4 # author: Lukas Vanelderen
5 # date: Jan 21 2015
6 #####################################
7 
8 import FWCore.ParameterSet.Config as cms
9 
10 
11 def digitizersFull2Fast(digitizers):
12 
13  # fastsim does not simulate castor
14  if hasattr(digitizers,"castor"):
15  delattr(digitizers,"castor")
16  else:
17  print "WARNING: digitizers has no attribute 'castor'"
18 
19  # fastsim does not digitize pixel and strip hits, it mixes tracks
20  if hasattr(digitizers,"pixel") and hasattr(digitizers,"strip"):
21  delattr(digitizers,"pixel")
22  delattr(digitizers,"strip")
23  import FastSimulation.Tracking.recoTrackAccumulator_cfi
24  digitizers.tracker = cms.PSet(FastSimulation.Tracking.recoTrackAccumulator_cfi.recoTrackAccumulator)
25  else:
26  print "WARNING: digitizers has no attribute 'pixel' and/or 'strip'"
27  print " : => not mixing tracks"
28 
29  # fastsim has its own names for simhit collections
30  for element in ["ecal","hcal"]:
31  if hasattr(digitizers,element):
32  getattr(digitizers,element).hitsProducer = "famosSimHits"
33  else:
34  print "WARNING: digitizers has no attribute '{0}'".format(element)
35 
36  # fastsim has different input for merged truth
37  if hasattr(digitizers,"mergedtruth"):
38  digitizers.mergedtruth.allowDifferentSimHitProcesses = True
39  digitizers.mergedtruth.simHitCollections = cms.PSet(
40  muon = cms.VInputTag( cms.InputTag('MuonSimHits','MuonDTHits'),
41  cms.InputTag('MuonSimHits','MuonCSCHits'),
42  cms.InputTag('MuonSimHits','MuonRPCHits') ),
43  trackerAndPixel = cms.VInputTag( cms.InputTag('famosSimHits','TrackerHits') )
44  )
45  digitizers.mergedtruth.simTrackCollection = cms.InputTag('famosSimHits')
46  digitizers.mergedtruth.simVertexCollection = cms.InputTag('famosSimHits')
47 
48  return digitizers
49 
50 
51 def prepareDigiRecoMixing(process):
52 
53  # switch to FastSim digitizers
54  process.mix.digitizers = digitizersFull2Fast(process.mix.digitizers)
55 
56  # switch to FastSim mixObjects
57  import FastSimulation.Configuration.mixObjects_cfi
58  process.mix.mixObjects = FastSimulation.Configuration.mixObjects_cfi.theMixObjects
59 
60  # fastsim does not simulate castor
61  # fastsim does not digitize pixel and strip hits
62  for element in ["simCastorDigis","simSiPixelDigis","simSiStripDigis"]:
63  if hasattr(process,element):
64  delattr(process,element)
65 
66  # get rid of some FullSim specific psets that work confusing when dumping FastSim cfgs
67  # (this is optional)
68  del process.theDigitizers
69  del process.theDigitizersValid
70  del process.trackingParticles
71  del process.stripDigitizer
72  del process.SiStripSimBlock
73  del process.castorDigitizer
74  del process.pixelDigitizer
75  del process.ecalDigitizer
76 
77  # get rid of FullSim specific services that work confusing when dumping FastSim cfgs
78  # (this is optional)
79  del process.siStripGainSimESProducer
80 
81  return process