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