CMS 3D CMS Logo

Functions
eGammaCorrection Namespace Reference

Functions

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

Function Documentation

◆ eGammaCorrection()

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

Definition at line 20 of file eGammaCorrection.py.

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

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