test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
runGlobalFakeInputProducer.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 import sys
3 
4 """
5 The parameters can be changed by adding commandline arguments of the form
6 ::
7 
8  runGlobalFakeInputProducer.py nevents=-1
9 
10 The latter can be used to change parameters in crab.
11 """
12 
13 job = 0 #job number
14 njob = 1 #number of jobs
15 nevents = 3564 #number of events
16 rootout = False #whether to produce root file
17 dump = False #dump python
18 
19 # Argument parsing
20 # vvv
21 
22 if len(sys.argv) > 1 and sys.argv[1].endswith('.py'):
23  sys.argv.pop(0)
24 if len(sys.argv) == 2 and ':' in sys.argv[1]:
25  argv = sys.argv[1].split(':')
26 else:
27  argv = sys.argv[1:]
28 
29 for arg in argv:
30  (k, v) = map(str.strip, arg.split('='))
31  if k not in globals():
32  raise "Unknown argument '%s'!" % (k,)
33  if type(globals()[k]) == bool:
34  globals()[k] = v.lower() in ('y', 'yes', 'true', 't', '1')
35  elif type(globals()[k]) == int:
36  globals()[k] = int(v)
37  else:
38  globals()[k] = v
39 
40 neventsPerJob = nevents/njob
41 skip = job * neventsPerJob
42 
43 if skip>4:
44  skip = skip-4
45  neventsPerJob = neventsPerJob+4
46 
47 import FWCore.ParameterSet.Config as cms
48 
49 process = cms.Process('L1TEMULATION')
50 
51 process.load('Configuration.StandardSequences.Services_cff')
52 process.load('FWCore.MessageService.MessageLogger_cfi')
53 process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff')
54 
55 
56 
57 # Select the Message Logger output you would like to see:
58 #
59 process.load('FWCore.MessageService.MessageLogger_cfi')
60 #process.load('L1Trigger/L1TYellow/l1t_debug_messages_cfi')
61 #process.load('L1Trigger/L1TYellow/l1t_info_messages_cfi')
62 
63 process.load('L1Trigger/L1TGlobal/debug_messages_cfi')
64 process.MessageLogger.l1t_debug.l1t.limit = cms.untracked.int32(100000)
65 
66 process.maxEvents = cms.untracked.PSet(
67  input = cms.untracked.int32(neventsPerJob)
68  )
69 
70 # Input source
71 process.source = cms.Source("PoolSource",
72  secondaryFileNames = cms.untracked.vstring(),
73  fileNames = cms.untracked.vstring(
74  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/06801062-95EA-E411-BAA4-002618943832.root",
75  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/069BD085-9BEA-E411-B063-002618943985.root",
76  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/0EABD22E-97EA-E411-9187-0025905A6068.root",
77  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/10E5C59E-9DEA-E411-B378-00261894385D.root",
78  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/14C238D9-96EA-E411-B343-00261894387E.root",
79  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/2634383A-94EA-E411-B274-002590596486.root",
80  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/36F53C7D-99EA-E411-995F-0026189437EB.root",
81  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/3EC53EC3-A1EA-E411-A30F-002618943826.root",
82  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/42B2E0FF-95EA-E411-9743-0025905B860C.root",
83  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/444664B9-95EA-E411-844B-00261894391B.root",
84  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/48D2AF08-98EA-E411-B556-002618943869.root",
85  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/4A5FFFC2-95EA-E411-B62F-0025905B858C.root",
86  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/5419CE7B-9AEA-E411-AE7C-002618943923.root",
87  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/583FA9B9-98EA-E411-B867-0025905A7786.root",
88  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/60CD47B5-95EA-E411-9469-00261894382D.root",
89  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/647E2B80-A0EA-E411-80CB-002618943950.root",
90  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/78A02D9A-94EA-E411-8625-0025905A6082.root",
91  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/88637A5A-A0EA-E411-916B-0025905A6094.root",
92  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/8E93F5C6-A0EA-E411-A4ED-0025905A6126.root",
93  "root://cmsxrootd-site.fnal.gov//store/relval/CMSSW_7_5_0_pre1/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_MCRUN2_74_V6-v1/00000/908AF505-96EA-E411-9C1D-003048FFD756.root",
94  ),
95  skipEvents = cms.untracked.uint32(skip)
96  )
97 
98 process.output =cms.OutputModule("PoolOutputModule",
99  outputCommands = cms.untracked.vstring('keep *'),
100  fileName = cms.untracked.string('testGlobalMCInputProducer_'+`job`+'.root')
101  )
102 
103 process.options = cms.untracked.PSet()
104 
105 # Other statements
106 from Configuration.AlCa.GlobalTag import GlobalTag
107 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS1', '')
108 
109 # Flag to switch between using MC particles and injecting individual particles
110 useMCtoGT = True
111 
112 process.dumpGT = cms.EDAnalyzer("l1t::GtInputDump",
113  egInputTag = cms.InputTag("gtInput"),
114  muInputTag = cms.InputTag("gtInput"),
115  tauInputTag = cms.InputTag("gtInput"),
116  jetInputTag = cms.InputTag("gtInput"),
117  etsumInputTag = cms.InputTag("gtInput"),
118  minBx = cms.int32(0),
119  maxBx = cms.int32(0)
120  )
121 process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
122 process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
123 
124 process.mcL1GTinput = cms.EDProducer("l1t::GenToInputProducer",
125  bxFirst = cms.int32(-2),
126  bxLast = cms.int32(2),
127  maxMuCand = cms.int32(8),
128  maxJetCand = cms.int32(12),
129  maxEGCand = cms.int32(12),
130  maxTauCand = cms.int32(8),
131  jetEtThreshold = cms.double(1),
132  tauEtThreshold = cms.double(1),
133  egEtThreshold = cms.double(1),
134  muEtThreshold = cms.double(1),
135  emptyBxTrailer = cms.int32(5),
136  emptyBxEvt = cms.int32(neventsPerJob)
137  )
138 
139 process.mcL1GTinput.maxMuCand = cms.int32(8)
140 process.mcL1GTinput.maxJetCand = cms.int32(12)
141 process.mcL1GTinput.maxEGCand = cms.int32(12)
142 process.mcL1GTinput.maxTauCand = cms.int32(8)
143 
144 # Fake the input
145 process.fakeL1GTinput = cms.EDProducer("l1t::FakeInputProducer",
146 
147 # Note: There is no error checking on these parameters...you are responsible.
148  egParams = cms.untracked.PSet(
149  egBx = cms.untracked.vint32(-2, -1, 0, 0, 1, 2),
150  egHwPt = cms.untracked.vint32(10, 20, 30, 61, 40, 50),
151  egHwPhi = cms.untracked.vint32(11, 21, 31, 61, 41, 51),
152  egHwEta = cms.untracked.vint32(12, 22, 32, 62, 42, 52),
153  egIso = cms.untracked.vint32( 0, 0, 1, 1, 0, 0)
154  ),
155 
156  muParams = cms.untracked.PSet(
157  muBx = cms.untracked.vint32(0, -1, 0, 0, 1, 2),
158  muHwPt = cms.untracked.vint32(5, 20, 30, 61, 40, 50),
159  muHwPhi = cms.untracked.vint32(11, 21, 31, 61, 41, 51),
160  muHwEta = cms.untracked.vint32(12, 22, 32, 62, 42, 52),
161  muIso = cms.untracked.vint32( 0, 0, 1, 1, 0, 0)
162  ),
163 
164  tauParams = cms.untracked.PSet(
165  tauBx = cms.untracked.vint32(),
166  tauHwPt = cms.untracked.vint32(),
167  tauHwPhi = cms.untracked.vint32(),
168  tauHwEta = cms.untracked.vint32(),
169  tauIso = cms.untracked.vint32()
170  ),
171 
172  jetParams = cms.untracked.PSet(
173  jetBx = cms.untracked.vint32( 0, 0, 2, 1, 1, 2),
174  jetHwPt = cms.untracked.vint32(100, 200, 130, 170, 85, 145),
175  jetHwPhi = cms.untracked.vint32( 2, 67, 10, 3, 78, 10),
176  jetHwEta = cms.untracked.vint32( 1, 19, 11, 0, 17, 11)
177  ),
178 
179  etsumParams = cms.untracked.PSet(
180  etsumBx = cms.untracked.vint32( -2, -1, 0, 1, 2),
181  etsumHwPt = cms.untracked.vint32( 2, 1, 204, 3, 4),
182  etsumHwPhi = cms.untracked.vint32( 2, 1, 20, 3, 4)
183  )
184  )
185 
186 ## Load our L1 menu
187 process.load('L1Trigger.L1TGlobal.StableParametersConfig_cff')
188 
189 process.load('L1Trigger.L1TGlobal.TriggerMenuXml_cfi')
190 process.TriggerMenuXml.TriggerMenuLuminosity = 'startup'
191 #process.TriggerMenuXml.DefXmlFile = 'L1_Example_Menu_2013.xml'
192 process.TriggerMenuXml.DefXmlFile = 'L1Menu_Reference_2014.xml'
193 
194 process.load('L1Trigger.L1TGlobal.TriggerMenuConfig_cff')
195 process.es_prefer_l1GtParameters = cms.ESPrefer('l1t::TriggerMenuXmlProducer','TriggerMenuXml')
196 
197 
198 process.simL1uGtDigis = cms.EDProducer("l1t::GtProducer",
199  #TechnicalTriggersUnprescaled = cms.bool(False),
200  ProduceL1GtObjectMapRecord = cms.bool(True),
201  AlgorithmTriggersUnmasked = cms.bool(False),
202  EmulateBxInEvent = cms.int32(1),
203  L1DataBxInEvent = cms.int32(5),
204  AlgorithmTriggersUnprescaled = cms.bool(False),
205  ProduceL1GtDaqRecord = cms.bool(True),
206  GmtInputTag = cms.InputTag("gtInput"),
207  caloInputTag = cms.InputTag("gtInput"),
208  AlternativeNrBxBoardDaq = cms.uint32(0),
209  #WritePsbL1GtDaqRecord = cms.bool(True),
210  BstLengthBytes = cms.int32(-1),
211  Verbosity = cms.untracked.int32(0)
212 )
213 
214 process.dumpGTRecord = cms.EDAnalyzer("l1t::GtRecordDump",
215  egInputTag = cms.InputTag("gtInput"),
216  muInputTag = cms.InputTag("gtInput"),
217  tauInputTag = cms.InputTag("gtInput"),
218  jetInputTag = cms.InputTag("gtInput"),
219  etsumInputTag = cms.InputTag("gtInput"),
220  uGtRecInputTag = cms.InputTag("simL1uGtDigis"),
221  uGtAlgInputTag = cms.InputTag("simL1uGtDigis"),
222  uGtExtInputTag = cms.InputTag("simL1uGtDigis"),
223  bxOffset = cms.int32(skip),
224  minBx = cms.int32(-2),
225  maxBx = cms.int32(2),
226  minBxVec = cms.int32(0),
227  maxBxVec = cms.int32(0),
228  dumpGTRecord = cms.bool(False),
229  dumpVectors = cms.bool(True),
230  tvFileName = cms.string( ("TestVector_%03d.txt") % job )
231  )
232 
233 
234 
235 process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi")
236 process.l1GtTrigReport.L1GtRecordInputTag = "simL1uGtDigis"
237 process.l1GtTrigReport.PrintVerbosity = 2
238 process.report = cms.Path(process.l1GtTrigReport)
239 
240 process.MessageLogger.categories.append("MuConditon")
241 
242 if useMCtoGT:
243  process.gtInput = process.mcL1GTinput.clone()
244 else:
245  process.gtInput = process.fakeL1GTinput.clone()
246 
247 process.p1 = cms.Path(
248  process.gtInput
249 # *process.dumpGT
250  *process.simL1uGtDigis
251  *process.dumpGTRecord
252 # * process.debug
253 # *process.dumpED
254 # *process.dumpES
255  )
256 
257 process.schedule = cms.Schedule(
258  process.p1
259  )
260 #process.schedule.append(process.report)
261 if rootout:
262  process.outpath = cms.EndPath(process.output)
263  process.schedule.append(process.outpath)
264 
265 # Spit out filter efficiency at the end.
266 process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(True))
267 
268 if dump:
269  outfile = open('dump_runGlobalFakeInputProducer_'+`job`+'.py','w')
270  print >> outfile,process.dumpPython()
271  outfile.close()
double split
Definition: MVATrainer.cc:139