CMS 3D CMS Logo

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

Functions

def eGammaCorrection (process, electronCollection, photonCollection, corElectronCollection, corPhotonCollection, metCollections, pfCandMatching=False, pfCandidateCollection="", corMetName="corEGSlimmedMET", postfix="")
 

Function Documentation

def eGammaCorrection.eGammaCorrection (   process,
  electronCollection,
  photonCollection,
  corElectronCollection,
  corPhotonCollection,
  metCollections,
  pfCandMatching = False,
  pfCandidateCollection = "",
  corMetName = "corEGSlimmedMET",
  postfix = "" 
)

Definition at line 19 of file eGammaCorrection.py.

References helpers.addToProcessAndTask(), clone(), and helpers.getPatAlgosToolsTask().

19  ):
20 
21  task = getPatAlgosToolsTask(process)
22 
23  process.load("PhysicsTools.PatAlgos.cleaningLayer1.photonCleaner_cfi")
24  task.add(process.cleanPatPhotons)
25  #cleaning the bad collections
26  cleanedPhotonCollection="cleanedPhotons"+postfix
27  cleanPhotonProducer = getattr(process, "cleanPatPhotons").clone(
28  src = photonCollection,
29 
30  )
31  cleanPhotonProducer.checkOverlaps.electrons.src = electronCollection
32  cleanPhotonProducer.checkOverlaps.electrons.requireNoOverlaps=cms.bool(True)
33 
34  #cleaning the good collections
35  cleanedCorPhotonCollection="cleanedCorPhotons"+postfix
36  cleanCorPhotonProducer = getattr(process, "cleanPatPhotons").clone(
37  src = corPhotonCollection
38  )
39  cleanCorPhotonProducer.checkOverlaps.electrons.src = corElectronCollection
40  cleanCorPhotonProducer.checkOverlaps.electrons.requireNoOverlaps=cms.bool(True)
41 
42 
43  #matching between objects
44  matchPhotonCollection="matchedPhotons"+postfix
45  matchPhotonProducer=cms.EDProducer("PFMatchedCandidateRefExtractor",
46  col1=cms.InputTag(cleanedPhotonCollection),
47  col2=cms.InputTag(cleanedCorPhotonCollection),
48  pfCandCollection=cms.InputTag(pfCandidateCollection),
49  extractPFCandidates=cms.bool(pfCandMatching) )
50 
51  matchElectronCollection="matchedElectrons"+postfix
52  matchElectronProducer=cms.EDProducer("PFMatchedCandidateRefExtractor",
53  col1=cms.InputTag(electronCollection),
54  col2=cms.InputTag(corElectronCollection),
55  pfCandCollection=cms.InputTag(pfCandidateCollection),
56  extractPFCandidates=cms.bool(pfCandMatching) )
57 
58 
59  #removal of old objects, and replace by the new
60  tag1= "pfCandCol1" if pfCandMatching else "col1"
61  tag2= "pfCandCol2" if pfCandMatching else "col2"
62  correctionPhoton="corMETPhoton"+postfix
63  corMETPhoton = cms.EDProducer("ShiftedParticleMETcorrInputProducer",
64  srcOriginal = cms.InputTag(matchPhotonCollection,tag1),
65  srcShifted = cms.InputTag(matchPhotonCollection,tag2),
66  )
67  correctionElectron="corMETElectron"+postfix
68  corMETElectron=cms.EDProducer("ShiftedParticleMETcorrInputProducer",
69  srcOriginal=cms.InputTag(matchElectronCollection,tag1),
70  srcShifted=cms.InputTag(matchElectronCollection,tag2),
71  )
72 
73 
74  addToProcessAndTask(cleanedPhotonCollection,cleanPhotonProducer, process, task)
75  addToProcessAndTask(cleanedCorPhotonCollection,cleanCorPhotonProducer, process, task)
76  addToProcessAndTask(matchPhotonCollection,matchPhotonProducer, process, task)
77  addToProcessAndTask(matchElectronCollection,matchElectronProducer, process, task)
78  addToProcessAndTask(correctionPhoton,corMETPhoton, process, task)
79  addToProcessAndTask(correctionElectron,corMETElectron, process, task)
80 
81  sequence=cms.Sequence()
82  sequence+=getattr(process,cleanedPhotonCollection)
83  sequence+=getattr(process,cleanedCorPhotonCollection)
84  sequence+=getattr(process,correctionPhoton)
85  sequence+=getattr(process,correctionElectron)
86 
87 
88 
89  #MET corrector
90  for metCollection in metCollections:
91  #print "---------->>>> ",metCollection, postfix
92  if not hasattr(process, metCollection+postfix):
93  #print " ==>> aqui"
94  #raw met is the only one that does not have already a valid input collection
95  inputMetCollection=metCollection.replace("Raw","",1)
96  corMETModuleName=corMetName+postfix
97  corMETModule = cms.EDProducer("CorrectedPATMETProducer",
98  src = cms.InputTag( inputMetCollection ),
99  #"patPFMet" if ("Raw" in metCollection )else metCollection
100  srcCorrections = cms.VInputTag( cms.InputTag(correctionPhoton),
101  cms.InputTag(correctionElectron),
102  )
103  )
104  addToProcessAndTask(metCollection+postfix, corMETModule, process, task) #corMETModuleName
105  sequence+=getattr(process,metCollection+postfix) #corMETModuleName
106  else:
107  print metCollection
108  getattr(process,metCollection).srcCorrections.append(cms.InputTag(correctionPhoton))
109  getattr(process,metCollection).srcCorrections.append(cms.InputTag(correctionElectron))
110 
111  return sequence
112 
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:27
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def getPatAlgosToolsTask(process)
Definition: helpers.py:12