1 import FWCore.ParameterSet.Config
as cms
4 _oldToNewProds = {
'CaloJetCorrectionProducer':
'CorrectedCaloJetProducer',
'PFJetCorrectionProducer':
'CorrectedPFJetProducer'}
7 """Based on the type, find the labels for modules we need to change
10 for label,mod
in producers.iteritems():
11 if mod.type_()
in prodsToFind:
12 modulesToChange.append(label)
13 return modulesToChange
16 """Starting from a EDProducer, find which old jet correctors are used
19 for x
in producer.correctors:
24 """Find all Correctors used by the corrector 'name'
26 m=getattr(process,name)
27 if m.type_() ==
'JetCorrectionESChain':
28 for n
in m.correctors:
31 correctors.append(name)
34 """Based on the label from the old correct, determine what label to use for the new corrector
36 post1 =
"CorrectionESProducer"
37 if oldName[-1*len(post1):] == post1:
38 return oldName[:-1*len(post1)]+
"Corrector"
40 if oldName[-1*len(post2):] == post2:
41 return oldName[:-1*len(post2)]+
"Corrector"
45 """Appropriately transform the parameters from the old module to the new module.
46 This includes changing 'correctors' from a vstring to a VInputTag
48 for n
in dir(oldModule):
49 p = getattr(oldModule,n)
50 if isinstance(p,cms._ParameterTypeBase):
51 if n ==
'appendToDataLabel':
53 if n ==
"correctors" and isinstance(p,cms.vstring):
55 setattr(newModule,n,p)
60 """Based on the old ESProducer corrector, create the equivalent EDProducer
62 oldToNewCorrectors_ = {
'JetCorrectionESChain':
'ChainedJetCorrectorProducer',
'LXXXCorrectionESProducer':
'LXXXCorrectorProducer',
'L1FastjetCorrectionESProducer':
'L1FastjetCorrectorProducer'}
63 type = oldToNewCorrectors_[oldCorrector.type_()]
64 corrector = cms.EDProducer(type)
68 """Based on the old EDProducer which used a corrector from the EventSetup, create the appropriate EDProducer which gets the corrector from the Event.
70 type = _oldToNewProds[oldProducer.type_()]
71 newProd = cms.EDProducer(type)
75 """Using the dependencies between correctors, construct the appropriate cms.Sequence.
78 for n
in correctorNames:
79 mod = getattr(process,n)
82 setattr(process,newLabel,newMod)
87 return cms.Sequence(modSequence)
90 modulesToChange =
_findModulesToChange(process.producers, [x
for x
in _oldToNewProds.iterkeys()])
93 oldCorrectorsSequence = set()
95 oldCorrectorsToNewSequence = {}
96 for m
in modulesToChange:
98 oldCorrectors.update( correctors )
99 stringOfOldCorrectorNames =
",".
join(correctors)
100 if stringOfOldCorrectorNames
not in oldCorrectorsSequence:
104 oldCorrectorsSequence.add(stringOfOldCorrectorNames)
105 oldCorrectorsToNewSequence[stringOfOldCorrectorNames] = seq
108 oldModule = getattr(process,m)
110 setattr(process,m,newModule)
113 seq = oldCorrectorsToNewSequence[stringOfOldCorrectorNames]
114 for p
in process.paths.itervalues():
115 if m
in p.moduleNames():
116 if not p.replace(newModule,seq+newModule):
117 print "failed to replace ",m,
"in path ", p.label_(), p
120 for m
in oldCorrectors:
def _makeNewCorrectorFromOld
def _findCorrectorsUsedByProducer
def customizeHLTforNewJetCorrectors
def _correctorNameChanger
def _makeNewProducerFroOld
def _findCorrectorsRecursive
def _buildSequenceOfCorrectors
static std::string join(char **cmd)