Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-16 03:23:29

0001 from __future__ import print_function
0002 import FWCore.ParameterSet.Config as cms
0003 from FWCore.ParameterSet.VarParsing import VarParsing
0004 
0005 ###################################################################
0006 # Setup 'standard' options
0007 ###################################################################
0008 options = VarParsing()
0009 
0010 options.register('conditionGT',
0011                  "auto:run2_data",
0012                  VarParsing.multiplicity.singleton,
0013                  VarParsing.varType.string,
0014                  "condition global tag for the job (\"auto:run2_data\" is default)")
0015 
0016 options.register('conditionOverwrite',
0017                  "",
0018                  VarParsing.multiplicity.singleton,
0019                  VarParsing.varType.string,
0020                  "configuration to overwrite the condition into the GT (\"\" is default)")
0021 
0022 options.register('inputCollection',
0023                  "ALCARECOSiStripCalMinBias",
0024                  VarParsing.multiplicity.singleton,
0025                  VarParsing.varType.string,
0026                  "collections to be used for input (\"ALCARECOSiStripCalMinBias\" is default, use 'generalTracks' for prompt reco and 'ctfWithMaterialTracksP5' for cosmic reco)")
0027 
0028 options.register('outputFile',
0029                  "calibTreeTest.root",
0030                  VarParsing.multiplicity.singleton,
0031                  VarParsing.varType.string,
0032                  "name for the output root file (\"calibTreeTest.root\" is default)")
0033 
0034 options.register('inputFiles',
0035                  '/store/data/Run2018D/Cosmics/ALCARECO/SiStripCalCosmics-UL18-v1/40000/0346DCE4-0C70-1344-A7EB-D488B627208C.root',
0036                  VarParsing.multiplicity.list,
0037                  VarParsing.varType.string,
0038                  "file to process")
0039 
0040 options.register('maxEvents',
0041                  -1,
0042                  VarParsing.multiplicity.singleton,
0043                  VarParsing.varType.int,
0044                  "number of events to process (\"-1\" for all)")
0045 
0046 options.register('runNumber',
0047                  -1,
0048                  VarParsing.multiplicity.singleton,
0049                  VarParsing.varType.int,
0050                  "run number to process (\"-1\" for all)")
0051 
0052 options.register('cosmicTriggers', '',
0053                  VarParsing.multiplicity.list,
0054                  VarParsing.varType.string,
0055                  'cosmic triggers')
0056 
0057 options.parseArguments()
0058 ###################################################################
0059 # To use the prompt reco dataset please use 'generalTracks' as inputCollection
0060 # To use the cosmic reco dataset please use 'ctfWithMaterialTracksP5' as inputCollection
0061 
0062 
0063 process = cms.Process('CALIB')
0064 process.load('Configuration/StandardSequences/MagneticField_cff')
0065 process.load('Configuration.Geometry.GeometryRecoDB_cff')
0066 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0067 
0068 from Configuration.AlCa.GlobalTag import GlobalTag
0069 process.GlobalTag = GlobalTag(process.GlobalTag, options.conditionGT, options.conditionOverwrite)
0070 
0071 process.load('FWCore.MessageService.MessageLogger_cfi')
0072 process.load('Configuration.StandardSequences.Services_cff')
0073 
0074 process.maxEvents = cms.untracked.PSet(input=cms.untracked.int32(options.maxEvents))
0075 
0076 process.source = cms.Source("PoolSource", fileNames=cms.untracked.vstring(options.inputFiles))
0077 if options.runNumber != -1:
0078    if 'Cosmics' not in options.inputCollection:
0079       print("Restricting to the following events :")
0080       print('%s:1-%s:MAX'%(options.runNumber,options.runNumber))
0081       process.source.eventsToProcess = cms.untracked.VEventRange('%s:1-%s:MAX'%(options.runNumber,options.runNumber))
0082    else:
0083       print("Restricting to the following lumis for Cosmic runs only:")
0084       print('%s:1-%s:MAX'%(options.runNumber,options.runNumber))
0085       process.source.lumisToProcess = cms.untracked.VLuminosityBlockRange('%s:1-%s:MAX'%(options.runNumber,options.runNumber))
0086 
0087 process.options = cms.untracked.PSet(
0088         wantSummary = cms.untracked.bool(True)
0089         )
0090 process.MessageLogger.cerr.FwkReport.reportEvery = 10000
0091 
0092 inTracks = cms.InputTag(options.inputCollection)
0093 
0094 process.load('CalibTracker.SiStripCommon.prescaleEvent_cfi')
0095 process.load('CalibTracker.Configuration.Filter_Refit_cff')
0096 ## use CalibrationTracks (for clusters) and CalibrationTracksRefit (for tracks)
0097 process.CalibrationTracks.src = inTracks
0098 tracksForCalib = cms.InputTag("CalibrationTracksRefit")
0099 
0100 process.prescaleEvent.prescale = 1
0101 process.load("CalibTracker.SiStripCommon.SiStripBFieldFilter_cfi")
0102 
0103 from HLTrigger.HLTfilters.triggerResultsFilter_cfi import triggerResultsFilter
0104 
0105 process.IsolatedMuonFilter = triggerResultsFilter.clone(
0106         triggerConditions = cms.vstring("HLT_IsoMu20_*"),
0107         hltResults = cms.InputTag("TriggerResults", "", "HLT"),
0108         l1tResults = cms.InputTag(""),
0109         throw = cms.bool(False)
0110         )
0111 if len(options.cosmicTriggers) > 0:
0112     print("Cosmic triggers: {0}".format(", ".join(options.cosmicTriggers)))
0113     process.IsolatedMuonFilter.triggerConditions = cms.vstring(options.cosmicTriggers)
0114 else:
0115     print("Cosmic triggers: {0} (default)".format(", ".join(process.IsolatedMuonFilter.triggerConditions)))
0116     print("Argument passed: {0}".format(options.cosmicTriggers))
0117 
0118 process.TkCalSeq = cms.Sequence(
0119         process.prescaleEvent*
0120         process.IsolatedMuonFilter*
0121         process.siStripBFieldOnFilter*
0122         process.CalibrationTracks,
0123         cms.Task(process.MeasurementTrackerEvent),
0124         cms.Task(process.offlineBeamSpot),
0125         cms.Task(process.CalibrationTracksRefit)
0126         )
0127 
0128 process.load("PhysicsTools.NanoAOD.nano_cff")
0129 process.load("PhysicsTools.NanoAOD.NanoAODEDMEventContent_cff")
0130 
0131 ## as a test: it should be possible to add tracks fully at configuration level (+ declaring the plugin)
0132 from PhysicsTools.NanoAOD.common_cff import *
0133 ## this is equivalent to ShallowTrackProducer as configured for the gain calibration
0134 process.tracksTable = cms.EDProducer("SimpleTrackFlatTableProducer",
0135         src=tracksForCalib,
0136         cut=cms.string(""),
0137         name=cms.string("track"),
0138         doc=cms.string("SiStripCalMinBias ALCARECO tracks"),
0139         singleton=cms.bool(False),
0140         extension=cms.bool(False),
0141         variables=cms.PSet(
0142             chi2ndof=Var("chi2()/ndof", float),
0143             pt=Var("pt()", float),
0144             hitsvalid=Var("numberOfValidHits()", int), ## unsigned?
0145             phi=Var("phi()", float),
0146             eta=Var("eta()", float),
0147             )
0148         )
0149 process.load("CalibTracker.SiStripCommon.siStripPositionCorrectionsTable_cfi")
0150 process.siStripPositionCorrectionsTable.Tracks = tracksForCalib
0151 process.load("CalibTracker.SiStripCommon.siStripLorentzAngleRunInfoTable_cfi")
0152 
0153 siStripCalCosmicsNanoTables = cms.Task(
0154         process.nanoMetadata,
0155         process.tracksTable,
0156         process.siStripPositionCorrectionsTable,
0157         process.siStripLorentzAngleRunInfoTable
0158         )
0159 
0160 process.nanoCTPath = cms.Path(process.TkCalSeq, siStripCalCosmicsNanoTables)
0161 
0162 process.out = cms.OutputModule("NanoAODOutputModule",
0163         fileName=cms.untracked.string(options.outputFile),
0164         outputCommands=process.NANOAODEventContent.outputCommands+[
0165             "drop edmTriggerResults_*_*_*"
0166             ],
0167         SelectEvents=cms.untracked.PSet(
0168             SelectEvents=cms.vstring("nanoCTPath")
0169             )
0170         )
0171 process.end = cms.EndPath(process.out)
0172 
0173 process.schedule = cms.Schedule(process.nanoCTPath, process.end)