6 from Configuration.PyReleaseValidation.autoCond
import autoCond
10 from subprocess
import *
18 , l1MenuTag =
'L1GtTriggerMenu_L1Menu_Commissioning2010_v4_mc'
24 process.l1GtTriggerMenu = cms.ESSource(
"PoolDBESSource"
25 , CondCore.DBCommon.CondDBCommon_cfi.CondDBCommon
28 connect = cms.untracked.string(
'frontier://FrontierProd/CMS_COND_31X_L1T' )
29 , record = cms.string(
'L1GtTriggerMenuRcd' )
30 , tag = cms.string( l1MenuTag )
34 process.preferL1GtTriggerMenu = cms.ESPrefer(
"PoolDBESSource",
"l1GtTriggerMenu" )
45 ------------------------------------------------------------------
46 Reconfigure the PATJetProducer to be able to run the 36X version
47 of PAT on 35X input samples.
50 ------------------------------------------------------------------
52 print "*********************************************************************"
53 print "NOTE TO USER: when running on 35X sample with 36X s/w versions you "
54 print " need to adapt for different event contents. The "
55 print " adaptations need to be made: "
57 print " - re-configuration of secondary vertex tag discrimi- "
58 print " nator information. "
60 print "*********************************************************************"
62 process.patJets.discriminatorSources = cms.VInputTag(
63 cms.InputTag(
"combinedSecondaryVertexBJetTags"),
64 cms.InputTag(
"combinedSecondaryVertexMVABJetTags"),
65 cms.InputTag(
"jetBProbabilityBJetTags"),
66 cms.InputTag(
"jetProbabilityBJetTags"),
67 cms.InputTag(
"simpleSecondaryVertexBJetTags"),
68 cms.InputTag(
"softElectronByPtBJetTags"),
69 cms.InputTag(
"softElectronByIP3dBJetTags"),
70 cms.InputTag(
"softMuonBJetTags"),
71 cms.InputTag(
"softMuonByPtBJetTags"),
72 cms.InputTag(
"softMuonByIP3dBJetTags"),
73 cms.InputTag(
"trackCountingHighEffBJetTags"),
74 cms.InputTag(
"trackCountingHighPurBJetTags"),
77 print "*********************************************************************"
78 print "NOTE TO USER: when running on 31X samples re-recoed in 3.5.x "
79 print " with this CMSSW version of PAT "
80 print " it is required to re-run the GenJet production for "
81 print " anti-kT since that is not part of the re-reco "
82 print "*********************************************************************"
83 process.load(
"RecoJets.Configuration.GenJetParticles_cff")
84 process.load(
"RecoJets.JetProducers." + genJets +
"_cfi")
85 process.patDefaultSequence.replace( getattr(process,
"patCandidates"+postfix), process.genParticlesForJets+getattr(process,genJets)+getattr(process,
"patCandidates"+postfix))
96 ------------------------------------------------------------------
97 Define sequence to run b tagging on AOD input for a given jet
98 collection including a JetTracksAssociatorAtVertex module with
99 name 'jetTracksAssociatorAtVertex' + 'label'.
101 Return value is a pair of (sequence, labels) where 'sequence'
102 is the cms.Sequence, and 'labels' is a vector with the follow-
105 * labels['jta'] = the name of the JetTrackAssociator module
106 * labels['tagInfos'] = a list of names of the TagInfo modules
107 * labels['jetTags '] = a list of names of the JetTag modules
109 This is a re-implementation to run the 36X version of PAT on 35X
111 ------------------------------------------------------------------
113 _label=
'runBTagging35X'
114 _defaultParameters=dicttypes.SortedKeysDict()
116 ConfigToolBase.__init__(self)
117 self.addParameter(self.
_defaultParameters,
'jetCollection',self._defaultValue,
'input jet collection',Type=cms.InputTag)
118 self.addParameter(self.
_defaultParameters,
'label',self._defaultValue,
'postfix label to identify new sequence/modules', Type=str)
119 self.addParameter(self.
_defaultParameters,
'postfix',
"",
"postfix of default sequence (do not confuse with 'label')")
127 jetCollection =
None,
130 if jetCollection
is None:
136 self.setParameter(
'jetCollection',jetCollection)
137 self.setParameter(
'label',label)
138 self.setParameter(
'postfix',postfix)
140 return self.
apply(process)
143 jetCollection=self.
_parameters[
'jetCollection'].value
147 if hasattr(process,
"addAction"):
148 process.disableRecording()
151 comment=inspect.stack(2)[2][4][0].rstrip(
"\n")
152 if comment.startswith(
"#"):
153 self.setComment(comment.lstrip(
"#"))
160 print "*********************************************************************"
161 print "NOTE TO USER: when running on 35X sample with 36X s/w versions you "
162 print " need to adapt for different event contents. The "
163 print " adaptations need to be made: "
165 print " - re-configuration of secondary vertex tag discrimi- "
166 print " nator information. "
168 print " - take out soft electron tagger information, which "
169 print " is not available on 35X. "
170 print "*********************************************************************"
174 raise ValueError,
"label for re-running b tagging is not allowed to be empty"
177 process.load(
"RecoJets.JetAssociationProducers.ak5JTA_cff")
179 process.load(
"RecoBTag.Configuration.RecoBTag_cff")
190 jtaLabel =
'jetTracksAssociatorAtVertex'+postfix
192 if (
not label ==
'AOD'):
195 ipTILabel =
'impactParameterTagInfos' + label
196 svTILabel =
'secondaryVertexTagInfos' + label
197 smTILabel =
'softMuonTagInfos' + label
200 setattr( process, ipTILabel, btag.impactParameterTagInfos.clone(jetTracks = cms.InputTag(jtaLabel)) )
201 setattr( process, svTILabel, btag.secondaryVertexTagInfos.clone(trackIPTagInfos = cms.InputTag(ipTILabel)) )
202 setattr( process, smTILabel, btag.softMuonTagInfos.clone(jets = jetCollection) )
205 def vit(*args) :
return cms.VInputTag( *[ cms.InputTag(x)
for x
in args ] )
208 setattr( process,
'jetBProbabilityBJetTags'+label, btag.jetBProbabilityBJetTags.clone(tagInfos = vit(ipTILabel)) )
209 setattr( process,
'jetProbabilityBJetTags' +label, btag.jetProbabilityBJetTags.clone (tagInfos = vit(ipTILabel)) )
210 setattr( process,
'trackCountingHighPurBJetTags'+label, btag.trackCountingHighPurBJetTags.clone(tagInfos = vit(ipTILabel)) )
211 setattr( process,
'trackCountingHighEffBJetTags'+label, btag.trackCountingHighEffBJetTags.clone(tagInfos = vit(ipTILabel)) )
212 setattr( process,
'simpleSecondaryVertexBJetTags'+label, btag.simpleSecondaryVertexBJetTags.clone(tagInfos = vit(svTILabel)) )
213 setattr( process,
'combinedSecondaryVertexBJetTags'+label, btag.combinedSecondaryVertexBJetTags.clone(tagInfos = vit(ipTILabel, svTILabel)) )
214 setattr( process,
'combinedSecondaryVertexMVABJetTags'+label, btag.combinedSecondaryVertexMVABJetTags.clone(tagInfos = vit(ipTILabel, svTILabel)) )
215 setattr( process,
'softMuonBJetTags'+label, btag.softMuonBJetTags.clone(tagInfos = vit(smTILabel)) )
216 setattr( process,
'softMuonByPtBJetTags'+label, btag.softMuonByPtBJetTags.clone(tagInfos = vit(smTILabel)) )
217 setattr( process,
'softMuonByIP3dBJetTags'+label, btag.softMuonByIP3dBJetTags.clone(tagInfos = vit(smTILabel)) )
220 labels = {
'jta' : jtaLabel,
221 'tagInfos' : (ipTILabel,svTILabel,smTILabel),
222 'jetTags' : [ (x + label)
for x
in (
'jetBProbabilityBJetTags',
223 'jetProbabilityBJetTags',
224 'trackCountingHighPurBJetTags',
225 'trackCountingHighEffBJetTags',
226 'simpleSecondaryVertexBJetTags',
227 'combinedSecondaryVertexBJetTags',
228 'combinedSecondaryVertexMVABJetTags',
230 'softMuonByPtBJetTags',
231 'softMuonByIP3dBJetTags'
237 def mkseq(process, firstlabel, *otherlabels):
238 seq = getattr(process, firstlabel)
239 for x
in otherlabels: seq += getattr(process, x)
240 return cms.Sequence(seq)
243 setattr( process,
'btaggingTagInfos'+label, mkseq(process, *(labels[
'tagInfos']) ) )
245 setattr( process,
'btaggingJetTags'+label, mkseq(process, *(labels[
'jetTags']) ) )
247 seq = mkseq(process,
'btaggingTagInfos'+label,
'btaggingJetTags' + label)
248 setattr( process,
'btagging'+label, seq )
251 if hasattr(process,
"addAction"):
252 process.enableRecording()
253 action=self.__copy__()
254 process.addAction(action)
264 ------------------------------------------------------------------
265 Add a new collection of jets. Takes the configuration from the
266 already configured standard jet collection as starting point;
267 replaces before calling addJetCollection will also affect the
268 new jet collections. This is a re-implementation to run the
269 36X version of PAT on 35X input samples.
270 ------------------------------------------------------------------
272 _label=
'addJetCollection35X'
273 _defaultParameters=dicttypes.SortedKeysDict()
275 ConfigToolBase.__init__(self)
276 self.addParameter(self.
_defaultParameters,
'jetCollection',self._defaultValue,
'Input jet collection', cms.InputTag)
277 self.addParameter(self.
_defaultParameters,
'algoLabel',self._defaultValue,
"label to indicate the jet algorithm (e.g.'AK5')",str)
278 self.addParameter(self.
_defaultParameters,
'typeLabel',self._defaultValue,
"label to indicate the type of constituents (e.g. 'Calo', 'Pflow', 'Jpt', ...)",str)
279 self.addParameter(self.
_defaultParameters,
'doJTA',
True,
"run b tagging sequence for new jet collection and add it to the new pat jet collection")
280 self.addParameter(self.
_defaultParameters,
'doBTagging',
True,
'run JetTracksAssociation and JetCharge and add it to the new pat jet collection (will autom. be true if doBTagging is set to true)')
281 self.addParameter(self.
_defaultParameters,
'jetCorrLabel',
None,
"algorithm and type of JEC; use 'None' for no JEC; examples are ('AK5','Calo'), ('SC7','Calo'), ('KT4','PF')", tuple,acceptNoneValue=
True)
282 self.addParameter(self.
_defaultParameters,
'doType1MET',
True,
"if jetCorrLabel is not 'None', set this to 'True' to redo the Type1 MET correction for the new jet colllection; at the moment it must be 'False' for non CaloJets otherwise the JetMET POG module crashes. ")
283 self.addParameter(self.
_defaultParameters,
'doL1Cleaning',
True,
"copy also the producer modules for cleanLayer1 will be set to 'True' automatically when doL1Counters is 'True'")
284 self.addParameter(self.
_defaultParameters,
'doL1Counters',
False,
"copy also the filter modules that accept/reject the event looking at the number of jets")
285 self.addParameter(self.
_defaultParameters,
'genJetCollection',cms.InputTag(
"ak5GenJets"),
"GenJet collection to match to")
286 self.addParameter(self.
_defaultParameters,
'doJetID',
True,
"add jetId variables to the added jet collection?")
287 self.addParameter(self.
_defaultParameters,
'jetIdLabel',
"ak5",
" specify the label prefix of the xxxJetID object; in general it is the jet collection tag like ak5, kt4 sc5, aso. For more information have a look to SWGuidePATTools#add_JetCollection")
288 self.addParameter(self.
_defaultParameters,
'standardAlgo',
"AK5",
"standard algorithm label of the collection from which the clones for the new jet collection will be taken from (note that this jet collection has to be available in the event before hand)")
289 self.addParameter(self.
_defaultParameters,
'standardType',
"Calo",
"standard constituent type label of the collection from which the clones for the new jet collection will be taken from (note that this jet collection has to be available in the event before hand)")
298 jetCollection =
None,
307 genJetCollection =
None,
311 standardType =
None):
313 if jetCollection
is None:
315 if algoLabel
is None:
317 if typeLabel
is None:
321 if doBTagging
is None:
323 if jetCorrLabel
is None:
325 if doType1MET
is None:
327 if doL1Cleaning
is None:
329 if doL1Counters
is None:
331 if genJetCollection
is None:
335 if jetIdLabel
is None:
337 if standardAlgo
is None:
339 if standardType
is None:
342 self.setParameter(
'jetCollection',jetCollection)
343 self.setParameter(
'algoLabel',algoLabel)
344 self.setParameter(
'typeLabel',typeLabel)
345 self.setParameter(
'doJTA',doJTA)
346 self.setParameter(
'doBTagging',doBTagging)
347 self.setParameter(
'jetCorrLabel',jetCorrLabel)
348 self.setParameter(
'doType1MET',doType1MET)
349 self.setParameter(
'doL1Cleaning',doL1Cleaning)
350 self.setParameter(
'doL1Counters',doL1Counters)
351 self.setParameter(
'genJetCollection',genJetCollection)
352 self.setParameter(
'doJetID',doJetID)
353 self.setParameter(
'jetIdLabel',jetIdLabel)
354 self.setParameter(
'standardAlgo',standardAlgo)
355 self.setParameter(
'standardType',standardType)
360 jetCollection=self.
_parameters[
'jetCollection'].value
365 jetCorrLabel=self.
_parameters[
'jetCorrLabel'].value
367 doL1Cleaning=self.
_parameters[
'doL1Cleaning'].value
368 doL1Counters=self.
_parameters[
'doL1Counters'].value
369 genJetCollection=self.
_parameters[
'genJetCollection'].value
372 standardAlgo=self.
_parameters[
'standardAlgo'].value
373 standardType=self.
_parameters[
'standardType'].value
381 def oldLabel(prefix=''):
386 def newLabel(oldLabel):
388 if(oldLabel.find(standardAlgo)>=0
and oldLabel.find(standardType)>=0):
389 oldLabel=oldLabel.replace(standardAlgo, algoLabel).
replace(standardType, typeLabel)
391 oldLabel=oldLabel+algoLabel+typeLabel
395 def addClone(hook, **replaceStatements):
398 newModule = getattr(process, hook).
clone(**replaceStatements)
400 addModuleToSequence(hook, newModule)
403 def addModuleToSequence(hook, newModule):
404 hookModule = getattr(process, hook)
407 setattr( process, newLabel(hook), newModule)
410 process.patDefaultSequence.replace( hookModule, hookModule*newModule )
412 print "*********************************************************************"
413 print "NOTE TO USER: when running on 35X sample with 36X s/w versions you "
414 print " need to adapt for different event contents. The "
415 print " adaptations need to be made: "
417 print " - re-configuration of secondary vertex tag discrimi- "
418 print " nator information. "
420 print " - take out soft electron tagger information, which "
421 print " is not available on 35X. "
422 print "*********************************************************************"
425 addClone(oldLabel(), jetSource = jetCollection)
427 addClone(oldLabel(
'selected'), src=cms.InputTag(newLabel(oldLabel())))
430 addClone(oldLabel(
'clean'), src=cms.InputTag(newLabel(oldLabel(
'selected'))))
434 addClone(oldLabel(
'count'), src=cms.InputTag(newLabel(oldLabel(
'clean'))))
436 addClone(oldLabel(
'count'), src=cms.InputTag(newLabel(oldLabel(
'selected'))))
439 l1Jets = getattr(process, newLabel(oldLabel()))
442 addClone(
'patJetPartonMatch', src = jetCollection)
443 addClone(
'patJetGenJetMatch', src = jetCollection, matched = genJetCollection)
446 addClone(
'patJetPartonAssociation', jets = jetCollection)
447 addClone(
'patJetFlavourAssociation', srcByReference = cms.InputTag(newLabel(
'patJetPartonAssociation')))
450 def fixInputTag(x): x.setModuleLabel(newLabel(x.moduleLabel))
452 def fixVInputTag(x): x[0].setModuleLabel(newLabel(x[0].moduleLabel))
455 fixInputTag(l1Jets.genJetMatch)
456 fixInputTag(l1Jets.genPartonMatch)
457 fixInputTag(l1Jets.JetPartonMapSource)
460 def vit(*args) :
return cms.VInputTag( *[ cms.InputTag(x)
for x
in args ] )
462 if (doJTA
or doBTagging):
464 process.load(
"RecoJets.JetAssociationProducers.ak5JTA_cff")
467 jtaLabel =
'jetTracksAssociatorAtVertex'+algoLabel+typeLabel
468 setattr( process, jtaLabel, ak5JetTracksAssociatorAtVertex.clone(jets = jetCollection) )
469 process.makePatJets.replace(process.patJetCharge, getattr(process,jtaLabel)+process.patJetCharge)
470 l1Jets.trackAssociationSource = cms.InputTag(jtaLabel)
471 addClone(
'patJetCharge', src=cms.InputTag(jtaLabel)),
472 fixInputTag(l1Jets.jetChargeSource)
476 l1Jets.addAssociatedTracks =
False
477 l1Jets.addJetCharge =
False
481 postfixLabel=algoLabel+typeLabel
483 (btagSeq, btagLabels) = runBTagging35X(process, jetCollection, postfixLabel)
485 process.makePatJets.replace(getattr(process,jtaLabel), getattr(process,jtaLabel)+btagSeq)
487 l1Jets.trackAssociationSource = cms.InputTag(btagLabels[
'jta'])
488 l1Jets.tagInfoSources = cms.VInputTag( *[ cms.InputTag(x)
for x
in btagLabels[
'tagInfos'] ] )
489 l1Jets.discriminatorSources = cms.VInputTag( *[ cms.InputTag(x)
for x
in btagLabels[
'jetTags'] ] )
492 l1Jets.addBTagInfo =
False
495 l1Jets.addJetID = cms.bool(
True)
496 jetIdLabelNew = jetIdLabel +
'JetID'
497 l1Jets.jetIDMap = cms.InputTag( jetIdLabelNew )
499 l1Jets.addJetID = cms.bool(
False)
501 if (jetCorrLabel !=
None):
504 if (jetCorrLabel ==
False ):
505 raise ValueError,
"In addJetCollection 'jetCorrLabel' must be set to 'None', not 'False'"
506 if (jetCorrLabel ==
"None"):
507 raise ValueError,
"In addJetCollection 'jetCorrLabel' must be set to 'None' (without quotes)"
509 if type(jetCorrLabel) != type((
'AK5',
'Calo')):
510 raise ValueError,
"In addJetCollection 'jetCorrLabel' must be 'None', or of type ('Algo','Type')"
513 addClone(
'patJetCorrFactors', jetSource = jetCollection)
514 switchJECParameters( getattr(process,newLabel(
'patJetCorrFactors')), jetCorrLabel[0], jetCorrLabel[1], oldAlgo=
'AK5',oldType=
'Calo' )
515 fixVInputTag(l1Jets.jetCorrFactorsSource)
518 if( jetCollection.__str__().
find(
'PFJets')>=0 ):
519 print '================================================='
520 print 'Type1MET corrections are switched off for PFJets.'
521 print 'of type %s%s.' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
522 print 'Users are recommened to use pfMET together with '
524 print '================================================='
531 if not hasattr( process,
'%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) ):
532 setattr( process,
'%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
533 cms.ESSource(
"JetCorrectionServiceChain",
534 correctors = cms.vstring(
'%s%sL2Relative' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
535 '%s%sL3Absolute' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
541 addClone(
'metJESCorAK5CaloJet', inputUncorJetsLabel = jetCollection.value(),
542 corrector = cms.string(
'%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]))
544 addClone(
'metJESCorAK5CaloJetMuons', uncorMETInputTag = cms.InputTag(newLabel(
'metJESCorAK5CaloJet')))
545 addClone(
'patMETs', metSource = cms.InputTag(newLabel(
'metJESCorAK5CaloJetMuons')))
546 l1MET = getattr(process, newLabel(
'patMETs'))
548 process.patCandidateSummary.candidates += [ cms.InputTag(newLabel(
'patMETs')) ]
551 l1Jets.addJetCorrFactors =
False
561 ------------------------------------------------------------------
562 Switch the collection of jets in PAT from the default value to a
563 new jet collection. This is a re-implementation to run the 36X
564 version of PAT on 35X input samples.
565 ------------------------------------------------------------------
567 _label=
'switchJetCollection35X'
568 _defaultParameters=dicttypes.SortedKeysDict()
570 ConfigToolBase.__init__(self)
571 self.addParameter(self.
_defaultParameters,
'jetCollection',self._defaultValue,
'Input jet collection', cms.InputTag)
572 self.addParameter(self.
_defaultParameters,
'doJTA',
True,
"run b tagging sequence for new jet collection and add it to the new pat jet collection")
573 self.addParameter(self.
_defaultParameters,
'doBTagging',
True,
'run JetTracksAssociation and JetCharge and add it to the new pat jet collection (will autom. be true if doBTagging is set to true)')
574 self.addParameter(self.
_defaultParameters,
'jetCorrLabel',
None,
"algorithm and type of JEC; use 'None' for no JEC; examples are ('AK5','Calo'), ('SC7','Calo'), ('KT4','PF')", tuple,acceptNoneValue=
True)
575 self.addParameter(self.
_defaultParameters,
'doType1MET',
True,
"if jetCorrLabel is not 'None', set this to 'True' to redo the Type1 MET correction for the new jet colleection; at the moment it must be 'False' for non CaloJets otherwise the JetMET POG module crashes. ")
576 self.addParameter(self.
_defaultParameters,
'genJetCollection',cms.InputTag(
"ak5GenJets"),
"GenJet collection to match to")
577 self.addParameter(self.
_defaultParameters,
'doJetID',
True,
"add jetId variables to the added jet collection")
578 self.addParameter(self.
_defaultParameters,
'jetIdLabel',
"ak5",
" specify the label prefix of the xxxJetID object; in general it is the jet collection tag like ak5, kt4 sc5, aso. For more information have a look to SWGuidePATTools#add_JetCollection")
579 self.addParameter(self.
_defaultParameters,
'postfix',
"",
"postfix of default sequence")
588 jetCollection =
None,
593 genJetCollection =
None,
598 if jetCollection
is None:
602 if doBTagging
is None:
604 if jetCorrLabel
is None:
606 if doType1MET
is None:
608 if genJetCollection
is None:
612 if jetIdLabel
is None:
617 self.setParameter(
'jetCollection',jetCollection)
618 self.setParameter(
'doJTA',doJTA)
619 self.setParameter(
'doBTagging',doBTagging)
620 self.setParameter(
'jetCorrLabel',jetCorrLabel)
621 self.setParameter(
'doType1MET',doType1MET)
622 self.setParameter(
'genJetCollection',genJetCollection)
623 self.setParameter(
'doJetID',doJetID)
624 self.setParameter(
'jetIdLabel',jetIdLabel)
625 self.setParameter(
'postfix',postfix)
630 jetCollection=self.
_parameters[
'jetCollection'].value
633 jetCorrLabel=self.
_parameters[
'jetCorrLabel'].value
635 genJetCollection=self.
_parameters[
'genJetCollection'].value
642 oldLabel =
applyPostfix(process,
"patJets", postfix).jetSource;
645 applyPostfix(process,
"patJetPartonMatch", postfix).src = jetCollection
646 applyPostfix(process,
"patJetGenJetMatch", postfix).src = jetCollection
647 applyPostfix(process,
"patJetGenJetMatch", postfix).matched = genJetCollection
648 applyPostfix(process,
"patJetPartonAssociation", postfix).jets = jetCollection
650 applyPostfix(process,
"patJets", postfix).jetSource = jetCollection
653 def vit(*args) :
return cms.VInputTag( *[ cms.InputTag(x)
for x
in args ] )
655 if (doJTA
or doBTagging):
657 process.load(
"RecoJets.JetAssociationProducers.ak5JTA_cff")
659 setattr(process,
"jetTracksAssociatorAtVertex"+postfix, ak5JetTracksAssociatorAtVertex.clone(jets = jetCollection))
660 getattr(process,
"patDefaultSequence"+postfix).
replace(
662 getattr(process,
"jetTracksAssociatorAtVertex" + postfix)
666 applyPostfix(process,
"patJetCharge", postfix).src =
'jetTracksAssociatorAtVertex'+postfix
667 applyPostfix(process,
"patJets", postfix).trackAssociationSource =
'jetTracksAssociatorAtVertex'+postfix
674 applyPostfix(process,
"patJets", postfix).addAssociatedTracks =
False
675 applyPostfix(process,
"patJets", postfix).addJetCharge =
False
680 (btagSeq, btagLabels) = runBTagging35X(process, jetCollection,
'AOD',postfix)
682 getattr(process,
"patDefaultSequence"+postfix).
replace(
683 getattr( process,
"jetTracksAssociatorAtVertex"+postfix),
684 getattr( process,
"jetTracksAssociatorAtVertex"+postfix) + btagSeq
688 applyPostfix(process,
"patJets", postfix).trackAssociationSource = btagLabels[
'jta']
689 applyPostfix(process,
"patJets", postfix).tagInfoSources = cms.VInputTag( *[ cms.InputTag(x)
for x
in btagLabels[
'tagInfos'] ] )
690 applyPostfix(process,
"patJets", postfix).discriminatorSources = cms.VInputTag( *[ cms.InputTag(x)
for x
in btagLabels[
'jetTags'] ] )
693 removeIfInSequence(process,
"secondaryVertexNegativeTagInfos",
"patDefaultSequence", postfix)
694 removeIfInSequence(process,
"simpleSecondaryVertexNegativeBJetTags",
"patDefaultSequence", postfix)
698 applyPostfix(process,
"patJets", postfix).addBTagInfo =
False
701 jetIdLabelNew = jetIdLabel +
'JetID'
702 applyPostfix(process,
"patJets", postfix).jetIDMap = cms.InputTag( jetIdLabelNew )
704 applyPostfix(process,
"patJets", postfix).addJetID = cms.bool(
False)
707 if (jetCorrLabel!=
None):
710 if (jetCorrLabel ==
False ):
711 raise ValueError,
"In switchJetCollection 'jetCorrLabel' must be set to 'None', not 'False'"
712 if (jetCorrLabel ==
"None"):
713 raise ValueError,
"In switchJetCollection 'jetCorrLabel' must be set to 'None' (without quotes)"
715 if (type(jetCorrLabel)!=type((
'AK5',
'Calo'))):
716 raise ValueError,
"In switchJetCollection 'jetCorrLabel' must be 'None', or of type ('Algo','Type')"
719 applyPostfix(process,
"patJetCorrFactors", postfix).jetSource = jetCollection
720 switchJECParameters(
applyPostfix(process,
"patJetCorrFactors", postfix), jetCorrLabel[0], jetCorrLabel[1], oldAlgo=
'AK5',oldType=
'Calo')
723 if( jetCollection.__str__().
find(
'PFJets')>=0 ):
724 print '================================================='
725 print 'Type1MET corrections are switched off for PFJets.'
726 print 'of type %s%s.' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
727 print 'Users are recommened to use pfMET together with '
729 print '================================================='
736 if not hasattr( process,
'%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]) ):
737 setattr( process,
'%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
738 cms.ESSource(
"JetCorrectionServiceChain",
739 correctors = cms.vstring(
'%s%sL2Relative' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1]),
740 '%s%sL3Absolute' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
747 applyPostfix(process,
"metJESCorAK5CaloJet", postfix).inputUncorJetsLabel = jetCollection.value()
748 applyPostfix(process,
"metJESCorAK5CaloJet", postfix).corrector =
'%s%sL2L3' % (jetCorrLabel[0].swapcase(), jetCorrLabel[1])
751 process.patJetMETCorrections.remove(process.patJetCorrFactors)
754 applyPostfix(process,
"patJets", postfix).addJetCorrFactors =
False
765 """ Picks up RelVal input files automatically and
766 returns a vector of strings with the paths to be used in [PoolSource].fileNames
767 PickRelValInputFiles( cmsswVersion, relVal, dataTier, condition, globalTag, maxVersions, skipFiles, numberOfFiles, debug )
768 - cmsswVersion : CMSSW release to pick up the RelVal files from
769 optional; default: the current release (determined automatically from environment)
770 - formerVersion: use the last before the last valid CMSSW release to pick up the RelVal files from
771 applies also, if 'cmsswVersion' is set explicitly
772 optional; default: False
773 - relVal : RelVal sample to be used
774 optional; default: 'RelValTTbar'
775 - dataTier : data tier to be used
776 optional; default: 'GEN-SIM-RECO'
777 - condition : identifier of GlobalTag as defined in Configurations/PyReleaseValidation/python/autoCond.py
778 possibly overwritten, if 'globalTag' is set explicitly
779 optional; default: 'startup'
780 - globalTag : name of GlobalTag as it is used in the data path of the RelVals
781 optional; default: determined automatically as defined by 'condition' in Configurations/PyReleaseValidation/python/autoCond.py
782 !!! Determination is done for the release one runs in, not for the release the RelVals have been produced in.
783 !!! Example of deviation: data RelVals (CMSSW_4_1_X) might not only have the pure name of the GlobalTag 'GR_R_311_V2' in the full path,
784 but also an extension identifying the data: 'GR_R_311_V2_RelVal_wzMu2010B'
785 - maxVersions : max. versioning number of RelVal to check
787 - skipFiles : number of files to skip for a found RelVal sample
789 - numberOfFiles: number of files to pick up
790 setting it to 0, returns all found ('skipFiles' remains active though)
792 - debug : switch to enable enhanced messages in 'stdout'
793 optional; default: False
796 _label =
'pickRelValInputFiles'
797 _defaultParameters = dicttypes.SortedKeysDict()
803 ConfigToolBase.__init__( self )
804 self.addParameter( self.
_defaultParameters,
'cmsswVersion' , os.getenv(
"CMSSW_VERSION" ) ,
'auto from environment' )
818 , cmsswVersion =
None
819 , formerVersion =
None
826 , numberOfFiles =
None
829 if cmsswVersion
is None:
831 if formerVersion
is None:
837 if condition
is None:
839 if globalTag
is None:
840 globalTag = autoCond[ condition ][ : -5 ]
841 if maxVersions
is None:
843 if skipFiles
is None:
845 if numberOfFiles
is None:
849 self.setParameter(
'cmsswVersion' , cmsswVersion )
850 self.setParameter(
'formerVersion', formerVersion )
851 self.setParameter(
'relVal' , relVal )
852 self.setParameter(
'dataTier' , dataTier )
853 self.setParameter(
'condition' , condition )
854 self.setParameter(
'globalTag' , globalTag )
855 self.setParameter(
'maxVersions' , maxVersions )
856 self.setParameter(
'skipFiles' , skipFiles )
857 self.setParameter(
'numberOfFiles', numberOfFiles )
858 self.setParameter(
'debug' , debug )
862 print '%s DEBUG: Empty file list returned'%( self.
_label )
863 print ' This might be overwritten by providing input files explicitly to the source module in the main configuration file.'
866 cmsswVersion = self.
_parameters[
'cmsswVersion' ].value
867 formerVersion = self.
_parameters[
'formerVersion' ].value
872 maxVersions = self.
_parameters[
'maxVersions' ].value
874 numberOfFiles = self.
_parameters[
'numberOfFiles' ].value
881 if patchId
in cmsswVersion:
882 cmsswVersion = cmsswVersion.split( patchId )[ 0 ]
883 elif ibId
in cmsswVersion
or formerVersion:
884 outputTuple = Popen( [
'scram',
'l -c CMSSW' ], stdout = PIPE, stderr = PIPE ).
communicate()
885 if len( outputTuple[ 1 ] ) != 0:
886 print '%s INFO : SCRAM error'%( self.
_label )
888 print ' from trying to determine last valid releases before \'%s\''%( cmsswVersion )
890 print outputTuple[ 1 ]
894 versions = {
'last' :
''
897 for line
in outputTuple[ 0 ].splitlines():
898 version = line.split()[ 1 ]
899 if cmsswVersion.split( ibId )[ 0 ]
in version
or cmsswVersion.rpartition(
'_' )[ 0 ]
in version:
900 if not ( patchId
in version
or ibId
in version ):
901 versions[
'lastToLast' ] = versions[
'last' ]
902 versions[
'last' ] = version
903 if version == cmsswVersion:
906 cmsswVersion = versions[
'lastToLast' ]
908 cmsswVersion = versions[
'last' ]
911 print '%s DEBUG: Called with...'%( self.
_label )
912 for key
in self._parameters.keys():
913 print ' %s:\t'%( key ),
919 if key ==
'cmsswVersion' and cmsswVersion != self.
_parameters[ key ].value:
921 print ' ==> modified to last to last valid release %s (s. \'formerVersion\' parameter)'%( cmsswVersion )
923 print ' ==> modified to last valid release %s'%( cmsswVersion )
927 domain = socket.getfqdn().
split(
'.' )
928 if len( domain ) == 0:
929 print '%s INFO : Cannot determine domain of this computer'%( self.
_label )
933 elif len( domain ) == 1:
934 print '%s INFO : Running on local host \'%s\' without direct access to RelVal files'%( self.
_label, domain[ 0 ] )
938 if domain[ -2 ] ==
'cern' and domain[ -1 ] ==
'ch':
940 storage =
'/castor/cern.ch/cms'
941 elif domain[ -2 ] ==
'fnal' and domain[ -1 ] ==
'gov':
943 storage =
'/pnfs/cms/WAX/11'
945 print '%s INFO : Running on site \'%s.%s\' without direct access to RelVal files'%( self.
_label, domain[ -2 ], domain[ -1 ] )
950 print '%s DEBUG: Running at site \'%s.%s\''%( self.
_label, domain[ -2 ], domain[ -1 ] )
951 print ' using command \'%s\''%( command )
952 print ' on storage path %s'%( storage )
953 rfdirPath =
'/store/relval/%s/%s/%s/%s-v'%( cmsswVersion, relVal, dataTier, globalTag )
954 argument =
'%s%s'%( storage, rfdirPath )
957 for version
in range( maxVersions, 0, -1 ):
961 print '%s DEBUG: Checking directory \'%s%i\''%( self.
_label, argument, version )
962 directories = Popen( [ command,
'%s%i'%( argument, version ) ], stdout = PIPE, stderr = PIPE ).
communicate()[0]
963 for directory
in directories.splitlines():
964 files = Popen( [ command,
'%s%i/%s'%( argument, version, directory ) ], stdout = PIPE, stderr = PIPE ).
communicate()[0]
965 for file
in files.splitlines():
968 print '%s DEBUG: File \'%s\' found'%( self.
_label, file )
970 validVersion = version
971 if fileCount > skipFiles:
972 filePath =
'%s%i/%s/%s'%( rfdirPath, version, directory, file )
973 filePaths.append( filePath )
974 if numberOfFiles != 0
and len( filePaths ) >= numberOfFiles:
977 print '%s DEBUG: %i file(s) found'%( self.
_label, fileCount )
978 if numberOfFiles != 0
and len( filePaths ) >= numberOfFiles:
980 if numberOfFiles != 0:
981 if len( filePaths ) >= numberOfFiles:
983 elif validVersion > 0:
986 if validVersion == 0:
987 print '%s INFO : No RelVal file(s) found at all in \'%s*\''%( self.
_label, argument )
990 elif len( filePaths ) == 0:
991 print '%s INFO : No RelVal file(s) picked up in \'%s%i\''%( self.
_label, argument, validVersion )
994 elif len( filePaths ) < numberOfFiles:
995 print '%s INFO : Only %i RelVal files picked up in \'%s%i\''%( self.
_label, len( filePaths ), argument, validVersion )
998 print '%s DEBUG: returning %i file(s)\n%s'%( self.
_label, len( filePaths ), filePaths )
static void * communicate(void *obj)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
def applyPostfix
Helpers to perform some technically boring tasks like looking for all modules with a given parameter ...
perl if(1 lt scalar(@::datatypes))