1
1
import FWCore .ParameterSet .Config as cms
2
2
from PhysicsTools .NanoAOD .run3scouting_cff import *
3
- from L1Trigger .Configuration .L1TRawToDigi_cff import *
4
3
from EventFilter .L1TRawToDigi .gtStage2Digis_cfi import gtStage2Digis
5
4
from PhysicsTools .NanoAOD .triggerObjects_cff import l1bits
6
5
from PhysicsTools .NanoAOD .globals_cff import puTable
@@ -123,7 +122,7 @@ def prepareScoutingNanoTaskMC():
123
122
124
123
# Specific tasks which will be added to sequence during customization
125
124
scoutingTriggerTask = prepareScoutingTriggerTask ()
126
- scoutingTriggerSequence = cms .Sequence (L1TRawToDigi + cms . Sequence ( scoutingTriggerTask ) )
125
+ scoutingTriggerSequence = cms .Sequence (scoutingTriggerTask )
127
126
scoutingNanoTaskMC = prepareScoutingNanoTaskMC ()
128
127
129
128
def customiseScoutingNano (process ):
@@ -147,17 +146,53 @@ def customiseScoutingNano(process):
147
146
# these function are designed to be used with --customise flag in cmsDriver.py
148
147
# e.g. --customise PhysicsTools/NanoAOD/python/custom_run3scouting_cff.addScoutingPFCandidate
149
148
150
- # reconfigure for running with ScoutingPFMonitor/MiniAOD inputs alone
149
+ # additional customisation for running with ScoutingPFMonitor/RAW inputs
151
150
# should be used with default customiseScoutingNano
151
+ # this is suitable when ScoutingPFMonitor/RAW is involved, e.g. RAW, RAW-MiniAOD two-file solution, full chain RAW-MiniAOD-NanoAOD
152
+ # when running full chain RAW-MiniAOD-NanoAOD, this ensures that gtStage2Digis, gmtStage2Digis, and caloStage2Digis are run
153
+ def customiseScoutingNanoForScoutingPFMonitor (process ):
154
+ process = skipEventsWithoutScouting (process )
155
+
156
+ # replace gtStage2DigisScouting with standard gtStage2Digis
157
+ process .scoutingTriggerTask .remove (process .gtStage2DigisScouting )
158
+ process .scoutingTriggerTask .add (process .gtStage2Digis )
159
+
160
+ # add gmtStage2Digis
161
+ process .load ("EventFilter.L1TRawToDigi.gmtStage2Digis_cfi" )
162
+ process .scoutingTriggerTask .add (process .gmtStage2Digis )
163
+
164
+ # add caloStage2Digis
165
+ process .load ("EventFilter.L1TRawToDigi.caloStage2Digis_cfi" )
166
+ process .scoutingTriggerTask .add (process .caloStage2Digis )
167
+
168
+ # replace l1bitsScouting with standard l1bits
169
+ process .scoutingTriggerTask .remove (process .l1bitsScouting )
170
+ process .scoutingTriggerTask .add (process .l1bits )
171
+
172
+ # change src for l1 objects
173
+ process .l1MuScoutingTable .src = cms .InputTag ("gmtStage2Digis" , "Muon" )
174
+ process .l1EGScoutingTable .src = cms .InputTag ("caloStage2Digis" , "EGamma" )
175
+ process .l1TauScoutingTable .src = cms .InputTag ("caloStage2Digis" , "Tau" )
176
+ process .l1JetScoutingTable .src = cms .InputTag ("caloStage2Digis" , "Jet" )
177
+ process .l1EtSumScoutingTable .src = cms .InputTag ("caloStage2Digis" , "EtSum" )
178
+
179
+ return process
180
+
181
+ # additional customisation for running with ScoutingPFMonitor/MiniAOD inputs alone
182
+ # can also be used on MC input
183
+ # should be used with default customiseScoutingNano and NOT with customiseScoutingNanoForScoutingPFMonitor
152
184
def customiseScoutingNanoFromMini (process ):
153
- # remove L1TRawToDigi
154
- process .scoutingTriggerSequence .remove (process .L1TRawToDigi )
185
+ # when running on data, assume ScoutingPFMonitor/MiniAOD dataset as inputs
186
+ runOnData = hasattr (process ,"NANOAODSIMoutput" ) or hasattr (process ,"NANOAODoutput" )
187
+ if runOnData :
188
+ process = skipEventsWithoutScouting (process )
155
189
156
190
# remove gtStage2Digis since they are already run for Mini
157
191
process .scoutingTriggerTask .remove (process .gtStage2DigisScouting )
158
192
159
- # change src for l1 bits
160
- process .l1bitsScouting .src = cms .InputTag ("gtStage2Digis" )
193
+ # replace l1bitsScouting with standard l1bits
194
+ process .scoutingTriggerTask .remove (process .l1bitsScouting )
195
+ process .scoutingTriggerTask .add (process .l1bits )
161
196
162
197
# change src for l1 objects
163
198
process .l1MuScoutingTable .src = cms .InputTag ("gmtStage2Digis" , "Muon" )
@@ -168,6 +203,32 @@ def customiseScoutingNanoFromMini(process):
168
203
169
204
return process
170
205
206
+ # skip events without scouting object products
207
+ # this may be needed since for there are some events which do not contain scouting object products in 2022-24
208
+ # this is fixed for 2025: https://its.cern.ch/jira/browse/CMSHLT-3331
209
+ def skipEventsWithoutScouting (process ):
210
+ # if scouting paths are triggered, scouting objects will be reconstructed
211
+ # so we select events passing scouting paths
212
+ import HLTrigger .HLTfilters .hltHighLevel_cfi
213
+
214
+ process .scoutingTriggerPathFilter = HLTrigger .HLTfilters .hltHighLevel_cfi .hltHighLevel .clone (
215
+ HLTPaths = cms .vstring ("Dataset_ScoutingPFRun3" )
216
+ )
217
+
218
+ process .nanoSkim_step = cms .Path (process .scoutingTriggerPathFilter )
219
+ process .schedule .extend ([process .nanoSkim_step ])
220
+
221
+ if hasattr (process , "NANOAODoutput" ):
222
+ process .NANOAODoutput .SelectEvents = cms .untracked .PSet (SelectEvents = cms .vstring ("nanoSkim_step" ))
223
+
224
+ if hasattr (process , "NANOAODEDMoutput" ):
225
+ process .NANOEDMAODoutput .SelectEvents = cms .untracked .PSet (SelectEvents = cms .vstring ("nanoSkim_step" ))
226
+
227
+ if hasattr (process , "write_NANOAOD" ): # PromptReco
228
+ process .write_NANOAOD .SelectEvents = cms .untracked .PSet (SelectEvents = cms .vstring ("nanoSkim_step" ))
229
+
230
+ return process
231
+
171
232
def addScoutingTrack (process ):
172
233
process .scoutingNanoSequence .associate (cms .Task (scoutingTrackTable ))
173
234
return process
0 commit comments