Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-14 01:44:16

0001 ############################################################
0002 # define basic process
0003 ############################################################
0004 
0005 import FWCore.ParameterSet.Config as cms
0006 import FWCore.Utilities.FileUtils as FileUtils
0007 import os
0008 process = cms.Process("L1TrackNtuple")
0009 
0010 ############################################################
0011 # edit options here
0012 ############################################################
0013 
0014 GEOMETRY = "D76"
0015 # Set L1 tracking algorithm:
0016 # 'HYBRID' (baseline, 4par fit) or 'HYBRID_DISPLACED' (extended, 5par fit).
0017 # 'HYBRID_NEWKF' (baseline, 4par fit, with bit-accurate KF emulation),
0018 # 'HYBRID_REDUCED' to use the "Summer Chain" configuration with reduced inputs.
0019 # (Or legacy algos 'TMTT' or 'TRACKLET').
0020 L1TRKALGO = 'HYBRID'
0021 
0022 WRITE_DATA = False
0023 
0024 ############################################################
0025 # import standard configurations
0026 ############################################################
0027 
0028 process.load('Configuration.StandardSequences.Services_cff')
0029 process.load('Configuration.EventContent.EventContent_cff')
0030 process.load('Configuration.StandardSequences.MagneticField_cff')
0031 
0032 process.load('FWCore.MessageService.MessageLogger_cfi')
0033 process.MessageLogger.L1track = dict(limit = -1)
0034 process.MessageLogger.Tracklet = dict(limit = -1)
0035 process.MessageLogger.TrackTriggerHPH = dict(limit = -1)
0036 
0037 if GEOMETRY == "D49":
0038     print("using geometry " + GEOMETRY + " (tilted)")
0039     process.load('Configuration.Geometry.GeometryExtended2026D49Reco_cff')
0040     process.load('Configuration.Geometry.GeometryExtended2026D49_cff')
0041 elif GEOMETRY == "D76":
0042     print("using geometry " + GEOMETRY + " (tilted)")
0043     process.load('Configuration.Geometry.GeometryExtended2026D76Reco_cff')
0044     process.load('Configuration.Geometry.GeometryExtended2026D76_cff')
0045 else:
0046     print("this is not a valid geometry!!!")
0047 
0048 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0049 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0050 
0051 from Configuration.AlCa.GlobalTag import GlobalTag
0052 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '')
0053 
0054 
0055 ############################################################
0056 # input and output
0057 ############################################################
0058 
0059 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10))
0060 
0061 #--- To use MCsamples scripts, defining functions get*data*() for easy MC access,
0062 #--- follow instructions in https://github.com/cms-L1TK/MCsamples
0063 
0064 #from MCsamples.Scripts.getCMSdata_cfi import *
0065 #from MCsamples.Scripts.getCMSlocaldata_cfi import *
0066 
0067 if GEOMETRY == "D49":
0068   inputMC = ["/store/relval/CMSSW_11_3_0_pre3/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v3_2026D49PU200_rsb-v1/00000/00260a30-734a-4a3a-a4b0-f836ce5502c6.root"]
0069 
0070 elif GEOMETRY == "D76":
0071   # Read data from card files (defines getCMSdataFromCards()):
0072   #from MCsamples.RelVal_1130_D76.PU200_TTbar_14TeV_cfi import *
0073   #inputMC = getCMSdataFromCards()
0074 
0075   # Or read .root files from directory on local computer:
0076   #dirName = "$myDir/whatever/"
0077   #inputMC=getCMSlocaldata(dirName)
0078 
0079   # Or read specified dataset (accesses CMS DB, so use this method only occasionally):
0080   #dataName="/RelValTTbar_14TeV/CMSSW_11_3_0_pre6-PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/GEN-SIM-DIGI-RAW"
0081   #inputMC=getCMSdata(dataName)
0082 
0083   # Or read specified .root file:
0084   inputMC = ["/store/relval/CMSSW_11_3_0_pre6/RelValTTbar_14TeV/GEN-SIM-DIGI-RAW/PU_113X_mcRun4_realistic_v6_2026D76PU200-v1/00000/00026541-6200-4eed-b6f8-d3a1fd720e9c.root"]
0085 
0086 else:
0087 
0088   print("this is not a valid geometry!!!")
0089 
0090 process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(*inputMC))
0091 # Use skipEvents to select particular single events for test vectors
0092 #process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring(*inputMC), skipEvents = cms.untracked.uint32(11))
0093 
0094 process.TFileService = cms.Service("TFileService", fileName = cms.string('TTbar_PU200_'+GEOMETRY+'.root'), closeFileFast = cms.untracked.bool(True))
0095 process.Timing = cms.Service("Timing", summaryOnly = cms.untracked.bool(True))
0096 
0097 
0098 ############################################################
0099 # L1 tracking: stubs / DTC emulation
0100 ############################################################
0101 
0102 process.load('L1Trigger.TrackTrigger.TrackTrigger_cff')
0103 
0104 # remake stubs?
0105 #from L1Trigger.TrackTrigger.TTStubAlgorithmRegister_cfi import *
0106 #process.load("SimTracker.TrackTriggerAssociation.TrackTriggerAssociator_cff")
0107 
0108 #from SimTracker.TrackTriggerAssociation.TTClusterAssociation_cfi import *
0109 #TTClusterAssociatorFromPixelDigis.digiSimLinks = cms.InputTag("simSiPixelDigis","Tracker")
0110 
0111 #process.TTClusterStub = cms.Path(process.TrackTriggerClustersStubs)
0112 #process.TTClusterStubTruth = cms.Path(process.TrackTriggerAssociatorClustersStubs)
0113 
0114 
0115 # DTC emulation
0116 process.load('L1Trigger.TrackerDTC.ProducerED_cff')
0117 
0118 # load code that analyzes DTCStubs
0119 #process.load('L1Trigger.TrackerDTC.Analyzer_cff')
0120 
0121 # modify default cuts
0122 #process.TrackTriggerSetup.FrontEnd.BendCut = 5.0
0123 #process.TrackTriggerSetup.Hybrid.MinPt = 1.0
0124 
0125 process.dtc = cms.Path(process.TrackerDTCProducer)#*process.TrackerDTCAnalyzer)
0126 
0127 
0128 ############################################################
0129 # L1 tracking
0130 ############################################################
0131 
0132 process.load("L1Trigger.TrackFindingTracklet.L1HybridEmulationTracks_cff")
0133 
0134 # HYBRID: prompt tracking
0135 if (L1TRKALGO == 'HYBRID'):
0136     process.TTTracksEmulation = cms.Path(process.L1THybridTracks)
0137     process.TTTracksEmulationWithTruth = cms.Path(process.L1THybridTracksWithAssociators)
0138     NHELIXPAR = 4
0139     L1TRK_NAME  = "l1tTTTracksFromTrackletEmulation"
0140     L1TRK_LABEL = "Level1TTTracks"
0141     L1TRUTH_NAME = "TTTrackAssociatorFromPixelDigis"
0142 
0143 # HYBRID: extended tracking
0144 elif (L1TRKALGO == 'HYBRID_DISPLACED'):
0145     process.TTTracksEmulation = cms.Path(process.L1TExtendedHybridTracks)
0146     process.TTTracksEmulationWithTruth = cms.Path(process.L1TExtendedHybridTracksWithAssociators)
0147     NHELIXPAR = 5
0148     L1TRK_NAME  = "l1tTTTracksFromExtendedTrackletEmulation"
0149     L1TRK_LABEL = "Level1TTTracks"
0150     L1TRUTH_NAME = "TTTrackAssociatorFromPixelDigisExtended"
0151 
0152 # HYBRID_NEWKF: prompt tracking or reduced
0153 elif (L1TRKALGO == 'HYBRID_NEWKF' or L1TRKALGO == 'HYBRID_REDUCED'):
0154     process.load( 'L1Trigger.TrackFindingTracklet.Producer_cff' )
0155     NHELIXPAR = 4
0156     L1TRK_NAME  = process.TrackFindingTrackletProducer_params.LabelTT.value()
0157     L1TRK_LABEL = process.TrackFindingTrackletProducer_params.BranchAcceptedTracks.value()
0158     L1TRUTH_NAME = "TTTrackAssociatorFromPixelDigis"
0159     process.TTTrackAssociatorFromPixelDigis.TTTracks = cms.VInputTag( cms.InputTag(L1TRK_NAME, L1TRK_LABEL) )
0160     process.HybridNewKF = cms.Sequence(process.L1HybridTracks + process.TrackFindingTrackletProducerTBout + process.TrackFindingTrackletProducerKFin + process.TrackFindingTrackletProducerKF + process.TrackFindingTrackletProducerTT + process.TrackFindingTrackletProducerAS + process.TrackFindingTrackletProducerKFout)
0161     process.TTTracksEmulation = cms.Path(process.HybridNewKF)
0162     #process.TTTracksEmulationWithTruth = cms.Path(process.HybridNewKF +  process.TrackTriggerAssociatorTracks)
0163     # Optionally include code producing performance plots & end-of-job summary.
0164     process.load( 'SimTracker.TrackTriggerAssociation.StubAssociator_cff' )
0165     process.load( 'L1Trigger.TrackFindingTracklet.Analyzer_cff' )
0166     process.TTTracksEmulationWithTruth = cms.Path(process.HybridNewKF +  process.TrackTriggerAssociatorTracks + process.StubAssociator +  process.TrackFindingTrackletAnalyzerTracklet + process.TrackFindingTrackletAnalyzerTBout + process.TrackFindingTrackletAnalyzerKFin + process.TrackFindingTrackletAnalyzerKF + process.TrackFindingTrackletAnalyzerKFout)
0167     from L1Trigger.TrackFindingTracklet.Customize_cff import *
0168     if (L1TRKALGO == 'HYBRID_NEWKF'):
0169         fwConfig( process )
0170     if (L1TRKALGO == 'HYBRID_REDUCED'):
0171         reducedConfig( process )
0172 
0173 # LEGACY ALGORITHM (EXPERTS ONLY): TRACKLET
0174 elif (L1TRKALGO == 'TRACKLET'):
0175     print "\n WARNING: This is not the baseline algorithm! Prefer HYBRID or HYBRID_DISPLACED!"
0176     print "\n To run the Tracklet-only algorithm, ensure you have commented out 'CXXFLAGS=-DUSEHYBRID' in BuildFile.xml & recompiled! \n"
0177     process.TTTracksEmulation = cms.Path(process.L1THybridTracks)
0178     process.TTTracksEmulationWithTruth = cms.Path(process.L1THybridTracksWithAssociators)
0179     NHELIXPAR = 4
0180     L1TRK_NAME  = "l1tTTTracksFromTrackletEmulation"
0181     L1TRK_LABEL = "Level1TTTracks"
0182     L1TRUTH_NAME = "TTTrackAssociatorFromPixelDigis"
0183 
0184 # LEGACY ALGORITHM (EXPERTS ONLY): TMTT
0185 elif (L1TRKALGO == 'TMTT'):
0186     print("\n WARNING: This is not the baseline algorithm! Prefer HYBRID or HYBRID_DISPLACED! \n")
0187     process.load("L1Trigger.TrackFindingTMTT.TMTrackProducer_Ultimate_cff")
0188     L1TRK_PROC  =  process.TMTrackProducer
0189     L1TRK_NAME  = "TMTrackProducer"
0190     L1TRK_LABEL = "TML1TracksKF4ParamsComb"
0191     L1TRUTH_NAME = "TTTrackAssociatorFromPixelDigis"
0192     NHELIXPAR = 4
0193     L1TRK_PROC.EnableMCtruth = cms.bool(False) # Reduce CPU use by disabling internal histos.
0194     L1TRK_PROC.EnableHistos  = cms.bool(False)
0195     process.load("RecoVertex.BeamSpotProducer.BeamSpot_cfi")
0196     process.load("SimTracker.TrackTriggerAssociation.TrackTriggerAssociator_cff")
0197     process.TTTrackAssociatorFromPixelDigis.TTTracks = cms.VInputTag( cms.InputTag(L1TRK_NAME, L1TRK_LABEL) )
0198     process.TTTracksEmulation = cms.Path(process.offlineBeamSpot*L1TRK_PROC)
0199     process.TTTracksEmulationWithTruth = cms.Path(process.offlineBeamSpot*L1TRK_PROC*process.TrackTriggerAssociatorTracks)
0200 
0201 else:
0202     print("ERROR: Unknown L1TRKALGO option")
0203     exit(1)
0204 
0205 ############################################################
0206 # Define the track ntuple process, MyProcess is the (unsigned) PDGID corresponding to the process which is run
0207 # e.g. single electron/positron = 11
0208 #      single pion+/pion- = 211
0209 #      single muon+/muon- = 13
0210 #      pions in jets = 6
0211 #      taus = 15
0212 #      all TPs = 1
0213 ############################################################
0214 
0215 process.L1TrackNtuple = cms.EDAnalyzer('L1TrackNtupleMaker',
0216                                        MyProcess = cms.int32(1),
0217                                        DebugMode = cms.bool(False),      # printout lots of debug statements
0218                                        SaveAllTracks = cms.bool(True),   # save *all* L1 tracks, not just truth matched to primary particle
0219                                        SaveStubs = cms.bool(False),      # save some info for *all* stubs
0220                                        L1Tk_nPar = cms.int32(NHELIXPAR), # use 4 or 5-parameter L1 tracking?
0221                                        L1Tk_minNStub = cms.int32(4),     # L1 tracks with >= 4 stubs
0222                                        TP_minNStub = cms.int32(4),       # require TP to have >= X number of stubs associated with it
0223                                        TP_minNStubLayer = cms.int32(4),  # require TP to have stubs in >= X layers/disks
0224                                        TP_minPt = cms.double(1.9),       # only save TPs with pt > X GeV
0225                                        TP_maxEta = cms.double(2.5),      # only save TPs with |eta| < X
0226                                        TP_maxZ0 = cms.double(30.0),      # only save TPs with |z0| < X cm
0227                                        L1TrackInputTag = cms.InputTag(L1TRK_NAME, L1TRK_LABEL),         # TTTrack input
0228                                        MCTruthTrackInputTag = cms.InputTag(L1TRUTH_NAME, L1TRK_LABEL),  # MCTruth input
0229                                        # other input collections
0230                                        L1StubInputTag = cms.InputTag("TTStubsFromPhase2TrackerDigis","StubAccepted"),
0231                                        MCTruthClusterInputTag = cms.InputTag("TTClusterAssociatorFromPixelDigis", "ClusterAccepted"),
0232                                        MCTruthStubInputTag = cms.InputTag("TTStubAssociatorFromPixelDigis", "StubAccepted"),
0233                                        TrackingParticleInputTag = cms.InputTag("mix", "MergedTrackTruth"),
0234                                        TrackingVertexInputTag = cms.InputTag("mix", "MergedTrackTruth"),
0235                                        # tracking in jets (--> requires AK4 genjet collection present!)
0236                                        TrackingInJets = cms.bool(False),
0237                                        GenJetInputTag = cms.InputTag("ak4GenJets", "")
0238                                        )
0239 
0240 process.ana = cms.Path(process.L1TrackNtuple)
0241 
0242 
0243 ############################################################
0244 # final schedule of what is to be run
0245 ############################################################
0246 
0247 # use this if you want to re-run the stub making
0248 # process.schedule = cms.Schedule(process.TTClusterStub,process.TTClusterStubTruth,process.dtc,process.TTTracksEmulationWithTruth,process.ana)
0249 
0250 # use this if cluster/stub associators not available
0251 # process.schedule = cms.Schedule(process.TTClusterStubTruth,process.dtc,process.TTTracksEmulationWithTruth,process.ana)
0252 
0253 # use this to only run tracking + track associator
0254 process.schedule = cms.Schedule(process.dtc,process.TTTracksEmulationWithTruth,process.ana)
0255 
0256 
0257 ############################################################
0258 # write output dataset?
0259 ############################################################
0260 
0261 if (WRITE_DATA):
0262   process.writeDataset = cms.OutputModule("PoolOutputModule",
0263       splitLevel = cms.untracked.int32(0),
0264       eventAutoFlushCompressedSize = cms.untracked.int32(5242880),
0265       outputCommands = process.RAWSIMEventContent.outputCommands,
0266       fileName = cms.untracked.string('output_dataset.root'), ## ADAPT IT ##
0267       dataset = cms.untracked.PSet(
0268           filterName = cms.untracked.string(''),
0269           dataTier = cms.untracked.string('GEN-SIM')
0270       )
0271   )
0272   process.writeDataset.outputCommands.append('keep  *TTTrack*_*_*_*')
0273   process.writeDataset.outputCommands.append('keep  *TTStub*_*_*_*')
0274 
0275   process.pd = cms.EndPath(process.writeDataset)
0276   process.schedule.append(process.pd)