CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 18 of file eGammaCorrection.py.

References clone().

18 
19  ):
20 
21  process.load("PhysicsTools.PatAlgos.cleaningLayer1.photonCleaner_cfi")
22  #cleaning the bad collections
23  cleanedPhotonCollection="cleanedPhotons"+postfix
24  cleanPhotonProducer = getattr(process, "cleanPatPhotons").clone(
25  src = photonCollection,
26 
27  )
28  cleanPhotonProducer.checkOverlaps.electrons.src = electronCollection
29  cleanPhotonProducer.checkOverlaps.electrons.requireNoOverlaps=cms.bool(True)
30 
31  #cleaning the good collections
32  cleanedCorPhotonCollection="cleanedCorPhotons"+postfix
33  cleanCorPhotonProducer = getattr(process, "cleanPatPhotons").clone(
34  src = corPhotonCollection
35  )
36  cleanCorPhotonProducer.checkOverlaps.electrons.src = corElectronCollection
37  cleanCorPhotonProducer.checkOverlaps.electrons.requireNoOverlaps=cms.bool(True)
38  #cleanCorPhotonProducer = cms.EDProducer("CandPtrProjector",
39  #src = cms.InputTag(corPhotonCollection),
40  #veto = cms.InputTag(corElectronCollection)
41  #)
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  )
68  correctionElectron="corMETElectron"+postfix
69  corMETElectron=cms.EDProducer("ShiftedParticleMETcorrInputProducer",
70  srcOriginal=cms.InputTag(matchElectronCollection,tag1),
71  srcShifted=cms.InputTag(matchElectronCollection,tag2),
72  )
73 
74 
75  setattr(process,cleanedPhotonCollection,cleanPhotonProducer)
76  setattr(process,cleanedCorPhotonCollection,cleanCorPhotonProducer)
77  setattr(process,matchPhotonCollection,matchPhotonProducer)
78  setattr(process,matchElectronCollection,matchElectronProducer)
79  setattr(process,correctionPhoton,corMETPhoton)
80  setattr(process,correctionElectron,corMETElectron)
81 
82  sequence=cms.Sequence()
83  sequence+=getattr(process,cleanedPhotonCollection)
84  sequence+=getattr(process,cleanedCorPhotonCollection)
85  sequence+=getattr(process,correctionPhoton)
86  sequence+=getattr(process,correctionElectron)
87 
88 
89 
90  #MET corrector
91  for metCollection in metCollections:
92  #print "---------->>>> ",metCollection, postfix
93  if not hasattr(process, metCollection+postfix):
94  #print " ==>> aqui"
95  #raw met is the only one that does not have already a valid input collection
96  inputMetCollection=metCollection.replace("Raw","",1)
97  corMETModuleName=corMetName+postfix
98  corMETModule = cms.EDProducer("CorrectedPATMETProducer",
99  src = cms.InputTag( inputMetCollection ),
100  #"patPFMet" if ("Raw" in metCollection )else metCollection
101  srcCorrections = cms.VInputTag( cms.InputTag(correctionPhoton),
102  cms.InputTag(correctionElectron),
103  )
104  )
105  setattr(process,metCollection+postfix,corMETModule) #corMETModuleName
106  sequence+=getattr(process,metCollection+postfix) #corMETModuleName
107  else:
108  print metCollection
109  getattr(process,metCollection).srcCorrections.append(cms.InputTag(correctionPhoton))
110  getattr(process,metCollection).srcCorrections.append(cms.InputTag(correctionElectron))
111 
112  return sequence
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135