CMS 3D CMS Logo

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

Functions

def eGammaCorrection
 

Function Documentation

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