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  ### Neutrino Gun Sample - PU50
74  #fileNames = cms.untracked.vstring("file:/home/puigh/work/L1Upgrade/CMSSW_6_2_0/src/Neutrino_Pt2to20_gun_UpgradeL1TDR-PU50_POSTLS161_V12-v1_001D5CFF-2839-E211-9777-0030487FA483.root"),
75  ### RelValSingleElectronPt10
76  #fileNames = cms.untracked.vstring("root://xrootd.unl.edu//store/relval/CMSSW_7_0_0_pre8/RelValSingleElectronPt10/GEN-SIM-DIGI-RAW-HLTDEBUG/START70_V2_amend-v4/00000/52DE2A7D-E651-E311-8E12-003048FFCBFC.root"),
77  ### RelValTTBar
78  #fileNames = cms.untracked.vstring("root://xrootd.unl.edu//store/relval/CMSSW_7_0_0_pre8/RelValTTbar/GEN-SIM-DIGI-RAW-HLTDEBUG/START70_V2_amend-v4/00000/1A20137C-E651-E311-A9C6-00304867BFAA.root"),
79  ### Local RelValTTBar
80  #fileNames = cms.untracked.vstring("/store/relval/CMSSW_7_1_0_pre6/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_PRE_LS171_V6-v1/00000/02ACFBFD-B0CB-E311-862A-002618FDA248.root"),
81  fileNames = cms.untracked.vstring(
82  "/store/relval/CMSSW_7_1_0/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V16-v1/00000/0EF13A80-F2FE-E311-9565-003048FFD7D4.root",
83  "/store/relval/CMSSW_7_1_0/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V16-v1/00000/389E0C8A-EFFE-E311-86EA-0025905A6088.root",
84  "/store/relval/CMSSW_7_1_0/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V16-v1/00000/52F1C37C-F1FE-E311-89EA-00261894394D.root",
85  "/store/relval/CMSSW_7_1_0/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V16-v1/00000/545B93FA-F1FE-E311-8414-0025905A497A.root",
86  "/store/relval/CMSSW_7_1_0/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V16-v1/00000/5C8B9784-EFFE-E311-A37A-0025905A60B0.root",
87  "/store/relval/CMSSW_7_1_0/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V16-v1/00000/5E835FAA-F3FE-E311-8D88-0025905B8596.root",
88  "/store/relval/CMSSW_7_1_0/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V16-v1/00000/6C2B9503-F0FE-E311-858F-0025905A612A.root",
89  ),
90 
91  #fileNames = cms.untracked.vstring("/store/relval/CMSSW_7_1_0_pre5/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU50ns_POSTLS171_V2-v2/00000/0E8CA3E5-94BC-E311-866D-02163E00EB85.root"),
92  #fileNames = cms.untracked.vstring(
93  #"/store/user/puigh/RelValTTbar_GEN-SIM-DIGI-RAW-HLTDEBUG_START70_V2_amend-v4_00000_3A11157B-ED51-E311-BA75-003048679080.root",
94  #"/store/user/puigh/RelValTTbar_GEN-SIM-DIGI-RAW-HLTDEBUG_START70_V2_amend-v4_00000_1A20137C-E651-E311-A9C6-00304867BFAA.root",
95  #"/store/user/puigh/RelValTTbar_GEN-SIM-DIGI-RAW-HLTDEBUG_START70_V2_amend-v4_00000_2EFD8C7A-E651-E311-8C92-002354EF3BE3.root",
96  #"file:/home/winer/RelValTTbar_GEN-SIM-DIGI-RAW-HLTDEBUG_START70_V2_amend-v4_00000_7854097B-E651-E311-96D3-002618B27F8A.root",
97  #),
98  skipEvents = cms.untracked.uint32(skip)
99  )
100 
101 process.output =cms.OutputModule("PoolOutputModule",
102  outputCommands = cms.untracked.vstring('keep *'),
103  fileName = cms.untracked.string('testGlobalMCInputProducer_'+`job`+'.root')
104  )
105 
106 process.options = cms.untracked.PSet()
107 
108 # Other statements
109 from Configuration.AlCa.GlobalTag import GlobalTag
110 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:upgradePLS1', '')
111 
112 # Flag to switch between using MC particles and injecting individual particles
113 useMCtoGT = True
114 
115 process.dumpGT = cms.EDAnalyzer("l1t::GtInputDump",
116  egInputTag = cms.InputTag("gtInput"),
117  muInputTag = cms.InputTag("gtInput"),
118  tauInputTag = cms.InputTag("gtInput"),
119  jetInputTag = cms.InputTag("gtInput"),
120  etsumInputTag = cms.InputTag("gtInput"),
121  minBx = cms.int32(0),
122  maxBx = cms.int32(0)
123  )
124 process.dumpED = cms.EDAnalyzer("EventContentAnalyzer")
125 process.dumpES = cms.EDAnalyzer("PrintEventSetupContent")
126 
127 process.mcL1GTinput = cms.EDProducer("l1t::GenToInputProducer",
128  bxFirst = cms.int32(-2),
129  bxLast = cms.int32(2),
130  maxMuCand = cms.int32(8),
131  maxJetCand = cms.int32(12),
132  maxEGCand = cms.int32(12),
133  maxTauCand = cms.int32(8),
134  jetEtThreshold = cms.double(1),
135  tauEtThreshold = cms.double(1),
136  egEtThreshold = cms.double(1),
137  muEtThreshold = cms.double(1),
138  emptyBxTrailer = cms.int32(5),
139  emptyBxEvt = cms.int32(neventsPerJob)
140  )
141 
142 process.mcL1GTinput.maxMuCand = cms.int32(8)
143 process.mcL1GTinput.maxJetCand = cms.int32(12)
144 process.mcL1GTinput.maxEGCand = cms.int32(12)
145 process.mcL1GTinput.maxTauCand = cms.int32(8)
146 
147 # Fake the input
148 process.fakeL1GTinput = cms.EDProducer("l1t::FakeInputProducer",
149 
150 # Note: There is no error checking on these parameters...you are responsible.
151  egParams = cms.untracked.PSet(
152  egBx = cms.untracked.vint32(-2, -1, 0, 0, 1, 2),
153  egHwPt = cms.untracked.vint32(10, 20, 30, 61, 40, 50),
154  egHwPhi = cms.untracked.vint32(11, 21, 31, 61, 41, 51),
155  egHwEta = cms.untracked.vint32(12, 22, 32, 62, 42, 52),
156  egIso = cms.untracked.vint32( 0, 0, 1, 1, 0, 0)
157  ),
158 
159  muParams = cms.untracked.PSet(
160  muBx = cms.untracked.vint32(0, -1, 0, 0, 1, 2),
161  muHwPt = cms.untracked.vint32(5, 20, 30, 61, 40, 50),
162  muHwPhi = cms.untracked.vint32(11, 21, 31, 61, 41, 51),
163  muHwEta = cms.untracked.vint32(12, 22, 32, 62, 42, 52),
164  muIso = cms.untracked.vint32( 0, 0, 1, 1, 0, 0)
165  ),
166 
167  tauParams = cms.untracked.PSet(
168  tauBx = cms.untracked.vint32(),
169  tauHwPt = cms.untracked.vint32(),
170  tauHwPhi = cms.untracked.vint32(),
171  tauHwEta = cms.untracked.vint32(),
172  tauIso = cms.untracked.vint32()
173  ),
174 
175  jetParams = cms.untracked.PSet(
176  jetBx = cms.untracked.vint32( 0, 0, 2, 1, 1, 2),
177  jetHwPt = cms.untracked.vint32(100, 200, 130, 170, 85, 145),
178  jetHwPhi = cms.untracked.vint32( 2, 67, 10, 3, 78, 10),
179  jetHwEta = cms.untracked.vint32( 1, 19, 11, 0, 17, 11)
180  ),
181 
182  etsumParams = cms.untracked.PSet(
183  etsumBx = cms.untracked.vint32( -2, -1, 0, 1, 2),
184  etsumHwPt = cms.untracked.vint32( 2, 1, 204, 3, 4),
185  etsumHwPhi = cms.untracked.vint32( 2, 1, 20, 3, 4)
186  )
187  )
188 
189 ## Load our L1 menu
190 process.load('L1Trigger.L1TGlobal.StableParametersConfig_cff')
191 
192 process.load('L1Trigger.L1TGlobal.TriggerMenuXml_cfi')
193 process.TriggerMenuXml.TriggerMenuLuminosity = 'startup'
194 #process.TriggerMenuXml.DefXmlFile = 'L1_Example_Menu_2013.xml'
195 process.TriggerMenuXml.DefXmlFile = 'L1Menu_Reference_2014.xml'
196 
197 process.load('L1Trigger.L1TGlobal.TriggerMenuConfig_cff')
198 process.es_prefer_l1GtParameters = cms.ESPrefer('l1t::TriggerMenuXmlProducer','TriggerMenuXml')
199 
200 
201 process.simL1uGtDigis = cms.EDProducer("l1t::GtProducer",
202  #TechnicalTriggersUnprescaled = cms.bool(False),
203  ProduceL1GtObjectMapRecord = cms.bool(True),
204  AlgorithmTriggersUnmasked = cms.bool(False),
205  EmulateBxInEvent = cms.int32(1),
206  L1DataBxInEvent = cms.int32(5),
207  AlgorithmTriggersUnprescaled = cms.bool(False),
208  ProduceL1GtDaqRecord = cms.bool(True),
209  GmtInputTag = cms.InputTag("gtInput"),
210  caloInputTag = cms.InputTag("gtInput"),
211  AlternativeNrBxBoardDaq = cms.uint32(0),
212  #WritePsbL1GtDaqRecord = cms.bool(True),
213  BstLengthBytes = cms.int32(-1),
214  Verbosity = cms.untracked.int32(0)
215 )
216 
217 process.dumpGTRecord = cms.EDAnalyzer("l1t::GtRecordDump",
218  egInputTag = cms.InputTag("gtInput"),
219  muInputTag = cms.InputTag("gtInput"),
220  tauInputTag = cms.InputTag("gtInput"),
221  jetInputTag = cms.InputTag("gtInput"),
222  etsumInputTag = cms.InputTag("gtInput"),
223  uGtRecInputTag = cms.InputTag("simL1uGtDigis"),
224  uGtAlgInputTag = cms.InputTag("simL1uGtDigis"),
225  uGtExtInputTag = cms.InputTag("simL1uGtDigis"),
226  bxOffset = cms.int32(skip),
227  minBx = cms.int32(-2),
228  maxBx = cms.int32(2),
229  minBxVec = cms.int32(0),
230  maxBxVec = cms.int32(0),
231  dumpGTRecord = cms.bool(False),
232  dumpVectors = cms.bool(True),
233  tvFileName = cms.string( ("TestVector_%03d.txt") % job )
234  )
235 
236 
237 
238 process.load("L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi")
239 process.l1GtTrigReport.L1GtRecordInputTag = "simL1uGtDigis"
240 process.l1GtTrigReport.PrintVerbosity = 2
241 process.report = cms.Path(process.l1GtTrigReport)
242 
243 process.MessageLogger.categories.append("MuConditon")
244 
245 if useMCtoGT:
246  process.gtInput = process.mcL1GTinput.clone()
247 else:
248  process.gtInput = process.fakeL1GTinput.clone()
249 
250 process.p1 = cms.Path(
251  process.gtInput
252 # *process.dumpGT
253  *process.simL1uGtDigis
254  *process.dumpGTRecord
255 # * process.debug
256 # *process.dumpED
257 # *process.dumpES
258  )
259 
260 process.schedule = cms.Schedule(
261  process.p1
262  )
263 #process.schedule.append(process.report)
264 if rootout:
265  process.outpath = cms.EndPath(process.output)
266  process.schedule.append(process.outpath)
267 
268 # Spit out filter efficiency at the end.
269 process.options = cms.untracked.PSet(wantSummary = cms.untracked.bool(True))
270 
271 if dump:
272  outfile = open('dump_runGlobalFakeInputProducer_'+`job`+'.py','w')
273  print >> outfile,process.dumpPython()
274  outfile.close()
double split
Definition: MVATrainer.cc:139