Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-12 22:40:00

0001 REFIT = True
0002 MISALIGN = False
0003 
0004 if not REFIT and not MISALIGN:
0005     print( "Normal mode")
0006 elif REFIT and not MISALIGN:
0007     print( "REFIT only MODE")
0008 elif REFIT and MISALIGN:
0009     print( "REFIT + MISALIGN")
0010 else :
0011     print( "ERROR! STOP!")
0012     exit
0013     
0014 import FWCore.ParameterSet.VarParsing as VarParsing
0015 options = VarParsing.VarParsing("analysis")
0016 
0017 options.register ('outputRootFile',
0018                   "test_EopTreeElectron.root",
0019                   VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0020                   VarParsing.VarParsing.varType.string,         # string, int, or float
0021                   "output root file")
0022 
0023 options.register ('GlobalTag',
0024                   'auto:phase1_2022_realistic',
0025                   VarParsing.VarParsing.multiplicity.singleton,  # singleton or list
0026                   VarParsing.VarParsing.varType.string,          # string, int, or float
0027                   "Global Tag to be used")
0028 
0029 options.parseArguments()
0030 
0031 print( "conditionGT       : ", options.GlobalTag)
0032 print( "outputFile        : ", options.outputRootFile)
0033 print( "maxEvents         : ", options.maxEvents)
0034 
0035 import FWCore.ParameterSet.Config as cms
0036 from Configuration.Eras.Era_Run3_cff import Run3
0037 process = cms.Process("EnergyOverMomentumTree",Run3)
0038     
0039 #process.Tracer = cms.Service("Tracer")
0040 
0041 # initialize MessageLogger and output report
0042 process.load("FWCore.MessageService.MessageLogger_cfi")
0043 process.MessageLogger.cerr.FwkReport.reportEvery = 1000
0044 process.MessageLogger.TrackRefitter=dict()
0045 process.MessageLogger.EopElecTreeWriter=dict()
0046     
0047 process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False))
0048     
0049 # define input files
0050 process.source = cms.Source("PoolSource",
0051                             fileNames = cms.untracked.vstring(
0052                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/4a1ae43b-f4b3-4ad9-b86e-a7d9f6fc5c40.root',
0053                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/33565608-3cac-47fe-a1fc-aef60f866b3a.root',
0054                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/87fa96e1-925f-4cd3-878d-98a735737e55.root',
0055                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/ea3a1cc8-720f-4392-9f0b-bd04d7f236a8.root',
0056                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/3b3e7330-6174-43f3-8a49-c12eeae4d7f2.root',
0057                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/ddc48c68-781c-485b-887e-4fcd6f0e0772.root',
0058                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/a366a7ca-b71c-457a-8b64-09040f5b5819.root',
0059                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/4758604c-b0c1-4e09-a0d4-38dd0da16789.root',
0060                                 '/store/relval/CMSSW_12_4_0_pre4/RelValZEE_14/GEN-SIM-RECO/PU_124X_mcRun3_2021_realistic_v1-v1/2580000/48985150-6f47-4a7f-b09f-b6301b7ec6ff.root'))
0061                         
0062 process.maxEvents = cms.untracked.PSet(
0063     input = cms.untracked.int32(options.maxEvents)
0064 )
0065 
0066 ####################################################################
0067 # Load  electron configuration files
0068 ####################################################################
0069 process.load("TrackingTools.GsfTracking.GsfElectronFit_cff")
0070 
0071 ####################################################################
0072 # Get the Magnetic Field
0073 ####################################################################
0074 process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
0075 
0076 ###################################################################
0077 # Standard loads
0078 ###################################################################
0079 from Configuration.Geometry.GeometryRecoDB_cff import *
0080 process.load("Configuration.Geometry.GeometryRecoDB_cff")
0081 
0082 ####################################################################
0083 # Get the BeamSpot
0084 ####################################################################
0085 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
0086 
0087 ####################################################################
0088 # Get the GlogalTag
0089 ####################################################################
0090 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0091 from Configuration.AlCa.GlobalTag import GlobalTag
0092 process.GlobalTag = GlobalTag(process.GlobalTag, options.GlobalTag, '')
0093 
0094 # choose geometry
0095 if MISALIGN:
0096     print( "MISALIGN")
0097     from CondCore.CondDB.CondDB_cfi import CondDB
0098     CondDB.connect = cms.string("frontier://FrontierProd/CMS_CONDITIONS")
0099     process.trackerAlignment = cms.ESSource("PoolDBESSource",
0100                                             CondDB,
0101                                             toGet = cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentRcd"),
0102                                                                        tag = cms.string("TrackerAlignment_2017_ultralegacymc_v2")
0103                                                                        )
0104                                                           )
0105     )
0106     process.es_prefer_trackerAlignment = cms.ESPrefer("PoolDBESSource", "trackerAlignment")
0107 
0108     process.trackerAPE = cms.ESSource("PoolDBESSource",
0109                                       CondDB,
0110                                       toGet = cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentErrorRcd"),
0111                                                                  tag = cms.string("TrackerAlignmentExtendedErrors_2017_ultralegacymc_v2")
0112                                                                  )
0113                                                         )
0114     )
0115     process.es_prefer_TrackerAPE = cms.ESPrefer("PoolDBESSource", "trackerAPE")
0116     
0117 else:
0118     print( "NO MISALIGN")
0119     
0120 # configure Gsf track refitter
0121 if REFIT:
0122     print( "REFIT")
0123     process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0124     import RecoTracker.TrackProducer.TrackRefitters_cff
0125     process.load("TrackingTools.TransientTrack.TransientTrackBuilder_cfi")
0126     process.load("TrackingTools.GsfTracking.fwdGsfElectronPropagator_cff")
0127     process.load("RecoTracker.TrackProducer.GsfTrackRefitter_cff")
0128     process.GsfTrackRefitter.src = cms.InputTag('electronGsfTracks')  
0129     process.GsfTrackRefitter.TrajectoryInEvent = True
0130     process.GsfTrackRefitter.AlgorithmName = cms.string('gsf')
0131 else:
0132     print( "NO REFIT")
0133 
0134 process.load("Alignment.OfflineValidation.eopElecTreeWriter_cfi")
0135 
0136 if REFIT:
0137     print( "REFIT")
0138     process.energyOverMomentumTree.src = cms.InputTag('GsfTrackRefitter')
0139 else:
0140     print( "NO REFIT")
0141     process.energyOverMomentumTree.src = cms.InputTag('electronGsfTracks')
0142      
0143 process.TFileService = cms.Service("TFileService",
0144                                    fileName = cms.string(options.outputRootFile)
0145                                    )
0146  
0147 if REFIT:
0148     print( "REFIT")
0149     process.p = cms.Path(process.offlineBeamSpot
0150                          *process.GsfTrackRefitter
0151                          *process.energyOverMomentumTree)
0152 else:
0153     print( "NO REFIT")
0154     process.p = cms.Path(process.offlineBeamSpot
0155                          *process.energyOverMomentumTree)