Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:43

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