CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CustomConfigs.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 def ProcessName(process):
4 # processname modifications
5 
6  if 'hltTrigReport' in process.__dict__:
7  process.hltTrigReport.HLTriggerResults = cms.InputTag( 'TriggerResults','',process.name_() )
8 
9  if 'hltDQMHLTScalers' in process.__dict__:
10  process.hltDQMHLTScalers.triggerResults = cms.InputTag( 'TriggerResults','',process.name_() )
11 
12  if 'hltDQML1SeedLogicScalers' in process.__dict__:
13  process.hltDQML1SeedLogicScalers.processname = process.name_()
14 
15  return(process)
16 
17 
18 def Base(process):
19 # default modifications
20 
21  process.options.wantSummary = cms.untracked.bool(True)
22 
23  process.MessageLogger.categories.append('TriggerSummaryProducerAOD')
24  process.MessageLogger.categories.append('L1GtTrigReport')
25  process.MessageLogger.categories.append('L1TGlobalSummary')
26  process.MessageLogger.categories.append('HLTrigReport')
27 
28 # No longer override - instead use GT config as provided via cmsDriver
29 ## override the GlobalTag, connection string and pfnPrefix
30 # if 'GlobalTag' in process.__dict__:
31 # process.GlobalTag.connect = 'frontier://FrontierProd/CMS_CONDITIONS'
32 # process.GlobalTag.pfnPrefix = cms.untracked.string('frontier://Frontie#rProd/')
33 #
34 # process.GlobalTag.snapshotTime = cms.string("9999-12-31 23:59:59.000")
35 
36  process=ProcessName(process)
37 
38  return(process)
39 
40 
41 def L1T(process):
42 # modifications when running L1T only
43 
44  labels = ['gtDigis','simGtDigis','newGtDigis','hltGtDigis']
45  for label in labels:
46  if label in process.__dict__:
47  process.load('L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi')
48  process.l1GtTrigReport.L1GtRecordInputTag = cms.InputTag( label )
49  process.L1AnalyzerEndpath = cms.EndPath( process.l1GtTrigReport )
50  process.schedule.append(process.L1AnalyzerEndpath)
51 
52  labels = ['gtStage2Digis','simGtStage2Digis','newGtStage2Digis','hltGtStage2Digis']
53  for label in labels:
54  if label in process.__dict__:
55  process.load('L1Trigger.L1TGlobal.L1TGlobalSummary_cfi')
56  process.L1TGlobalSummary.AlgInputTag = cms.InputTag( label )
57  process.L1TGlobalSummary.ExtInputTag = cms.InputTag( label )
58  process.L1TAnalyzerEndpath = cms.EndPath(process.L1TGlobalSummary )
59  process.schedule.append(process.L1TAnalyzerEndpath)
60 
61  if hasattr(process,'TriggerMenu'):
62  delattr(process,'TriggerMenu')
63 
64  process=Base(process)
65 
66  return(process)
67 
68 
69 def L1THLT(process):
70 # modifications when running L1T+HLT
71 
72  if not ('HLTAnalyzerEndpath' in process.__dict__) :
73  if 'hltGtDigis' in process.__dict__:
74  from HLTrigger.Configuration.HLT_Fake_cff import fragment
75  process.hltL1GtTrigReport = fragment.hltL1GtTrigReport
76  process.hltTrigReport = fragment.hltTrigReport
77  process.HLTAnalyzerEndpath = cms.EndPath(process.hltGtDigis + process.hltL1GtTrigReport + process.hltTrigReport)
78  process.schedule.append(process.HLTAnalyzerEndpath)
79 
80  if 'hltGtStage2ObjectMap' in process.__dict__:
81  from HLTrigger.Configuration.HLT_FULL_cff import fragment
82  process.hltL1TGlobalSummary = fragment.hltL1TGlobalSummary
83  process.hltTrigReport = fragment.hltTrigReport
84  process.HLTAnalyzerEndpath = cms.EndPath(process.hltGtStage2Digis + process.hltL1TGlobalSummary + process.hltTrigReport)
85  process.schedule.append(process.HLTAnalyzerEndpath)
86 
87  if hasattr(process,'TriggerMenu'):
88  delattr(process,'TriggerMenu')
89 
90  process=Base(process)
91 
92  return(process)
93 
94 
95 def HLTDropPrevious(process):
96 # drop on input the previous HLT results
97  process.source.inputCommands = cms.untracked.vstring (
98  'keep *',
99  'drop *_hltL1GtObjectMap_*_*',
100  'drop *_TriggerResults_*_*',
101  'drop *_hltTriggerSummaryAOD_*_*',
102  )
103 
104  process=Base(process)
105 
106  return(process)
107 
108 
109 def MassReplaceInputTag(process,old="rawDataCollector",new="rawDataRepacker",verbose=False,moduleLabelOnly=False,skipLabelTest=False):
110 # replace InputTag values (adapted from Configuration/Applications/python/ConfigBuilder.py)
111  from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceAnyInputTag
112  for s in process.paths_().keys():
113  massSearchReplaceAnyInputTag(getattr(process,s),old,new,verbose,moduleLabelOnly,skipLabelTest)
114  for s in process.endpaths_().keys():
115  massSearchReplaceAnyInputTag(getattr(process,s),old,new,verbose,moduleLabelOnly,skipLabelTest)
116  return(process)
117 
118 def MassReplaceParameter(process,name="label",old="rawDataCollector",new="rawDataRepacker",verbose=False):
119 # replace values of named parameters
120  from PhysicsTools.PatAlgos.tools.helpers import massSearchReplaceParam
121  for s in process.paths_().keys():
122  massSearchReplaceParam(getattr(process,s),name,old,new,verbose)
123  for s in process.endpaths_().keys():
124  massSearchReplaceParam(getattr(process,s),name,old,new,verbose)
125  return(process)
126 
127 def L1REPACK(process,sequence="Full"):
128 
129  from Configuration.StandardSequences.Eras import eras
130 
131  l1repack = cms.Process('L1REPACK',eras.Run2_2016)
132  l1repack.load('Configuration.StandardSequences.SimL1EmulatorRepack_'+sequence+'_cff')
133 
134  for module in l1repack.es_sources_():
135  if (not hasattr(process,module)):
136  setattr(process,module,getattr(l1repack,module))
137  for module in l1repack.es_producers_():
138  if (not hasattr(process,module)):
139  setattr(process,module,getattr(l1repack,module))
140 
141  for module in l1repack.SimL1Emulator.expandAndClone().moduleNames():
142  setattr(process,module,getattr(l1repack,module))
143  process.SimL1Emulator = l1repack.SimL1Emulator
144 
145  for path in process.paths_():
146  getattr(process,path).insert(0,process.SimL1Emulator)
147  for path in process.endpaths_():
148  getattr(process,path).insert(0,process.SimL1Emulator)
149 
150  return process
151 
152 def L1XML(process,xmlFile=None):
153 
154 # xmlFile="L1Menu_Collisions2016_dev_v3.xml"
155 
156  if ((xmlFile is None) or (xmlFile=="")):
157  return process
158 
159  process.L1TriggerMenu= cms.ESProducer("L1TUtmTriggerMenuESProducer",
160  L1TriggerMenuFile= cms.string(xmlFile)
161  )
162  process.ESPreferL1TXML = cms.ESPrefer("L1TUtmTriggerMenuESProducer","L1TriggerMenu")
163 
164  return process
def massSearchReplaceAnyInputTag
Definition: helpers.py:262
def massSearchReplaceParam
Definition: helpers.py:249
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
return(e1-e2)*(e1-e2)+dp *dp
def MassReplaceParameter