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