CMS 3D CMS Logo

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

Functions

def customizeGSFixForPAT
 
def miniAOD_addOrginalEGamma
 
def replace_input_tag_module_label
 
def replace_input_tags
 

Function Documentation

def egammaGainSwitchFixToolsForPAT_cff.customizeGSFixForPAT (   process)

Definition at line 87 of file egammaGainSwitchFixToolsForPAT_cff.py.

References helpers.addKeepStatement(), and miniAOD_addOrginalEGamma().

Referenced by customizeMiniAOD_MuEGFixMoriond2017.customizeAll().

87 
88 def customizeGSFixForPAT(process):
89  process.load("RecoEgamma.EgammaTools.egammaGainSwitchFixForPAT_cff")
90  process.load("RecoParticleFlow.PFProducer.pfGSFixLinkerForPAT_cff")
91  process.load("RecoEgamma.EgammaIsolationAlgos.pfClusterIsolationRemapForPAT_cff")
92  process.load("RecoEgamma.ElectronIdentification.idExternalRemapForPAT_cff")
93  process.load("RecoEgamma.EgammaTools.egammaGainSwitchFlag_cff")
94 
95  #this clones all the modules before they were modified to run on the orginal collections
96  miniAOD_addOrginalEGamma(process,"BeforeGSFix")
97  from PhysicsTools.PatAlgos.tools.helpers import addKeepStatement
98  addKeepStatement(process,'keep *_slimmedElectrons_*_*',
99  ['keep *_reducedEgammaBeforeGSFix_*_*',
100  'keep *_slimmedElectronsBeforeGSFix_*_*',
101  'keep *_slimmedPhotonsBeforeGSFix_*_*',
102  'keep EBDigiCollection_selectDigi_*_*',
103  'keep EEDigiCollection_selectDigi_*_*',
104  'drop *_reducedEgammaBeforeGSFix_reducedGedGsfElectrons_*',
105  'drop *_reducedEgammaBeforeGSFix_reducedGedPhotons_*',
106  'keep *_ecalMultiAndGSGlobalRecHitEB_hitsNotReplaced_*',
107  'keep *_particleFlowEGammaGSFixed_dupECALClusters_*',
108  'keep *_particleFlowEGammaGSFixed_dupESClusters_*',
109  ])
110  process.reducedEgamma.gsfElectrons = cms.InputTag("gedGsfElectronsGSFixed")
111  process.reducedEgamma.gsfElectronsPFValMap = cms.InputTag("particleBasedIsolationGSFixed","gedGsfElectrons")
112  process.reducedEgamma.gsfElectronPFClusterIsoSources = cms.VInputTag(
113  cms.InputTag("electronEcalPFClusterIsolationProducerGSFixed"),
114  cms.InputTag("electronHcalPFClusterIsolationProducerGSFixed"),
115  )
116  process.reducedEgamma.gsfElectronIDSources = cms.VInputTag(
117  cms.InputTag("eidLooseGSFixed"),
118  cms.InputTag("eidRobustHighEnergyGSFixed"),
119  cms.InputTag("eidRobustLooseGSFixed"),
120  cms.InputTag("eidRobustTightGSFixed"),
121  cms.InputTag("eidTightGSFixed"),
122  )
123  process.reducedEgamma.photons = cms.InputTag("gedPhotonsGSFixed")
124  process.reducedEgamma.conversions = cms.InputTag("allConversions", processName=cms.InputTag.skipCurrentProcess())
125  process.reducedEgamma.singleConversions = cms.InputTag("particleFlowEGamma", processName=cms.InputTag.skipCurrentProcess())
126  process.reducedEgamma.photonsPFValMap = cms.InputTag("particleBasedIsolationGSFixed","gedPhotons")
127  process.reducedEgamma.photonPFClusterIsoSources = cms.VInputTag(
128  cms.InputTag("photonEcalPFClusterIsolationProducerGSFixed"),
129  cms.InputTag("photonHcalPFClusterIsolationProducerGSFixed"),
130  )
131  process.reducedEgamma.photonIDSources = cms.VInputTag(
132  cms.InputTag("PhotonCutBasedIDLooseGSFixed"),
133  cms.InputTag("PhotonCutBasedIDLooseEMGSFixed"),
134  cms.InputTag("PhotonCutBasedIDTightGSFixed")
135  )
136  process.reducedEgamma.barrelEcalHits = cms.InputTag("ecalMultiAndGSGlobalRecHitEB")
137  process.reducedEgamma.endcapEcalHits = cms.InputTag("reducedEcalRecHitsEE")
138  process.reducedEgamma.preshowerEcalHits = cms.InputTag("reducedEcalRecHitsES")
139 
140  for modification in process.slimmedPhotons.modifierConfig.modifications:
141  if modification.modifierName != 'EGExtraInfoModifierFromIntValueMaps': continue
142  modification.photon_config.hasGainSwitchFlag = cms.InputTag('PhotonGainSwitchFlagProducer:hasGainSwitchFlag')
143  for modification in process.slimmedElectrons.modifierConfig.modifications:
144  if modification.modifierName != 'EGExtraInfoModifierFromIntValueMaps': continue
145  modification.electron_config.hasGainSwitchFlag = cms.InputTag('ElectronGainSwitchFlagProducer:hasGainSwitchFlag')
146 
147 
148  return process
def addKeepStatement
Definition: helpers.py:427
def egammaGainSwitchFixToolsForPAT_cff.miniAOD_addOrginalEGamma (   process,
  suffix 
)

Definition at line 29 of file egammaGainSwitchFixToolsForPAT_cff.py.

References clone(), and replace_input_tags().

Referenced by customizeGSFixForPAT().

29 
30 def miniAOD_addOrginalEGamma(process,suffix):
31  modules_to_clone=["slimmedElectrons",
32  "selectedPatElectrons",
33  "patElectrons",
34  "slimmedPhotons",
35  "selectedPatPhotons",
36  "patPhotons",
37  "reducedEgamma",
38  "egmGsfElectronIDs",
39  "electronMVAValueMapProducer",
40  "electronRegressionValueMapProducer",
41  "egmPhotonIDs",
42  "photonIDValueMapProducer",
43  "photonRegressionValueMapProducer",
44  "photonMVAValueMapProducer",
45  "phPFIsoDepositChargedPAT",
46  "phPFIsoDepositChargedAllPAT",
47  "phPFIsoDepositPUPAT",
48  "phPFIsoDepositNeutralPAT",
49  "phPFIsoDepositGammaPAT",
50  "phPFIsoValueCharged04PFIdPAT",
51  "phPFIsoValueChargedAll04PFIdPAT",
52  "phPFIsoValuePU04PFIdPAT",
53  "phPFIsoValueNeutral04PFIdPAT",
54  "phPFIsoValueGamma04PFIdPAT",
55  "elPFIsoDepositChargedPAT",
56  "elPFIsoDepositChargedAllPAT",
57  "elPFIsoDepositPUPAT",
58  "elPFIsoDepositNeutralPAT",
59  "elPFIsoDepositGammaPAT",
60  "elPFIsoValueCharged04PFIdPAT",
61  "elPFIsoValueChargedAll04PFIdPAT",
62  "elPFIsoValuePU04PFIdPAT",
63  "elPFIsoValueNeutral04PFIdPAT",
64  "elPFIsoValueGamma04PFIdPAT",
65  "elPFIsoValueCharged04NoPFIdPAT",
66  "elPFIsoValueChargedAll04NoPFIdPAT",
67  "elPFIsoValuePU04NoPFIdPAT",
68  "elPFIsoValueNeutral04NoPFIdPAT",
69  "elPFIsoValueGamma04NoPFIdPAT"]
70 
71 
72  for name in modules_to_clone:
73  new_name = name+suffix
74  setattr(process,new_name,getattr(process,name).clone())
75  replace_input_tags(process,new_name,getattr(process,new_name),modules_to_clone,suffix)
76 
77  process.reducedEgammaBeforeGSFix.gsfElectronIDSources = cms.VInputTag(
78  cms.InputTag("eidLoose", processName=cms.InputTag.skipCurrentProcess()),
79  cms.InputTag("eidRobustHighEnergy", processName=cms.InputTag.skipCurrentProcess()),
80  cms.InputTag("eidRobustLoose", processName=cms.InputTag.skipCurrentProcess()),
81  cms.InputTag("eidRobustTight", processName=cms.InputTag.skipCurrentProcess()),
82  cms.InputTag("eidTight", processName=cms.InputTag.skipCurrentProcess()),
83  )
84 
85 
86 
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def egammaGainSwitchFixToolsForPAT_cff.replace_input_tag_module_label (   tag,
  names_to_replace,
  suffix 
)

Definition at line 3 of file egammaGainSwitchFixToolsForPAT_cff.py.

Referenced by replace_input_tags().

3 
4 def replace_input_tag_module_label(tag,names_to_replace,suffix):
5  if type(tag)==str: #having some problems with things appearing as strings....
6  if tag in names_to_replace:
7  tag = tag+suffix
8  else:
9  if tag.getModuleLabel() in names_to_replace:
10  tag.setModuleLabel(tag.getModuleLabel()+suffix)
11 
#replaces all input tags in the module which match modules to replace with that module name + suffix
def egammaGainSwitchFixToolsForPAT_cff.replace_input_tags (   process,
  modname,
  pset,
  modules_to_replace,
  suffix 
)

Definition at line 12 of file egammaGainSwitchFixToolsForPAT_cff.py.

References replace_input_tag_module_label().

Referenced by miniAOD_addOrginalEGamma().

12 
13 def replace_input_tags(process,modname,pset,modules_to_replace,suffix):
14  for paraname in pset.parameterNames_():
15  para = pset.getParameter(paraname)
16  if para.pythonTypeName()=="cms.PSet":
17  replace_input_tags(process,modname,para,modules_to_replace,suffix)
18  elif para.pythonTypeName()=="cms.VPSet":
19  for newpset in para:
20  replace_input_tags(process,modname,newpset,modules_to_replace,suffix)
21  elif para.pythonTypeName()=="cms.InputTag":
22  replace_input_tag_module_label(para,modules_to_replace,suffix)
23  elif para.pythonTypeName()=="cms.VInputTag":
24  for tag in para:
25  replace_input_tag_module_label(tag,modules_to_replace,suffix)
26 
27 
28 #clones all these egamma pat modules and then updates the tags of these modules
#to point to the other cloned modules