Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:23

0001 from __future__ import print_function
0002 import os
0003 
0004 import FWCore.ParameterSet.Config as cms
0005 
0006 
0007 
0008 
0009 ##
0010 ## Setup command line options
0011 ##
0012 import FWCore.ParameterSet.VarParsing as VarParsing
0013 import sys
0014 options = VarParsing.VarParsing ('standard')
0015 options.register('sample', 'wlnu', VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Input sample")
0016 options.register('isTest', True, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.bool, "Test run")
0017 
0018 # get and parse the command line arguments
0019 if( hasattr(sys, "argv") ):
0020     for args in sys.argv :
0021         arg = args.split(',')
0022         for val in arg:
0023             val = val.split('=')
0024             if(len(val)==2):
0025                 setattr(options,val[0], val[1])
0026 
0027 print("Input sample: ", options.sample)
0028 print("Test run: ", options.isTest)
0029 
0030 
0031 
0032 ##
0033 ## Process definition
0034 ##
0035 process = cms.Process("ApeEstimator")
0036 
0037 
0038 
0039 ##
0040 ## Message Logger
0041 ##
0042 process.load("FWCore.MessageService.MessageLogger_cfi")
0043 process.MessageLogger.SectorBuilder=dict()
0044 process.MessageLogger.ResidualErrorBinning=dict()
0045 process.MessageLogger.HitSelector=dict()
0046 process.MessageLogger.CalculateAPE=dict()
0047 process.MessageLogger.ApeEstimator=dict()
0048 #process.MessageLogger.TrackRefitter=dict()
0049 process.MessageLogger.AlignmentTrackSelector=dict()
0050 process.MessageLogger.cerr.INFO.limit = 0
0051 process.MessageLogger.cerr.default.limit = -1  # Do not use =0, else all error messages (except those listed below) are supressed
0052 process.MessageLogger.cerr.SectorBuilder = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0053 process.MessageLogger.cerr.HitSelector = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0054 process.MessageLogger.cerr.CalculateAPE = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0055 process.MessageLogger.cerr.ApeEstimator = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0056 process.MessageLogger.cerr.AlignmentTrackSelector = cms.untracked.PSet(limit = cms.untracked.int32(-1))
0057 process.MessageLogger.cerr.FwkReport.reportEvery = 1000 ## really show only every 1000th
0058 
0059 
0060 
0061 ##
0062 ## Process options
0063 ##
0064 process.options = cms.untracked.PSet(
0065     wantSummary = cms.untracked.bool(True),
0066 )
0067 
0068 
0069 
0070 ##
0071 ## Input sample definition
0072 ##
0073 isData1 = isData2 = False
0074 isData = False
0075 isQcd = isWlnu = isZmumu = isZtautau = isZmumu10 = isZmumu20 = False
0076 isMc = False
0077 if options.sample == 'data1':
0078     isData1 = True
0079     isData = True
0080 elif options.sample == 'data2':
0081     isData2 = True
0082     isData = True
0083 elif options.sample == 'qcd':
0084     isQcd = True
0085     isMc = True
0086 elif options.sample == 'wlnu':
0087     isWlnu = True
0088     isMc = True
0089 elif options.sample == 'zmumu':
0090     isZmumu = True
0091     isMc = True
0092 elif options.sample == 'ztautau':
0093     isZtautau = True
0094     isMc = True
0095 elif options.sample == 'zmumu10':
0096     isZmumu10 = True
0097     isMc = True
0098 elif options.sample == 'zmumu20':
0099     isZmumu20 = True
0100     isMc = True
0101 else:
0102     print('ERROR --- incorrect data sammple: ', options.sample)
0103     exit(8888)
0104 
0105 
0106 
0107 ##
0108 ## Input Files
0109 ##
0110 if isData1:
0111     process.load("Alignment.APEEstimation.samples.Data_TkAlMuonIsolated_Run2011A_May10ReReco_ApeSkim_cff")
0112 elif isData2:
0113     process.load("Alignment.APEEstimationsamples.Data_TkAlMuonIsolated_Run2011A_PromptV4_ApeSkim_cff")
0114 elif isQcd:
0115     process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_Summer11_qcd_ApeSkim_cff")
0116 elif isWlnu:
0117     process.load("Alignment.APEEstimation.samples.Mc_WJetsToLNu_74XTest_ApeSkim_cff")
0118 elif isZmumu10:
0119     process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_Summer11_zmumu10_ApeSkim_cff")
0120 elif isZmumu20:
0121     process.load("Alignment.APEEstimation.samples.Mc_TkAlMuonIsolated_Summer11_zmumu20_ApeSkim_cff")
0122     
0123 
0124 
0125 ##
0126 ## Number of Events (should be after input file)
0127 ##
0128 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
0129 if options.isTest: process.maxEvents.input = 10001
0130 
0131 
0132 ##
0133 ## Check run and event numbers for Dublicates --- only for real data
0134 ##
0135 #process.source.duplicateCheckMode = cms.untracked.string("noDuplicateCheck")
0136 #process.source.duplicateCheckMode = cms.untracked.string("checkEachFile")
0137 process.source.duplicateCheckMode = cms.untracked.string("checkEachRealDataFile")
0138 #process.source.duplicateCheckMode = cms.untracked.string("checkAllFilesOpened")   # default value
0139 
0140 
0141 
0142 ##
0143 ## Whole Refitter Sequence
0144 ##
0145 process.load("Alignment.APEEstimation.TrackRefitter_38T_cff")
0146 
0147 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0148 from Configuration.AlCa.GlobalTag import GlobalTag
0149 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_design', '')
0150 
0151 
0152 ##### To be used when running on Phys14MC with a CMSSW version > 72X
0153 #process.GlobalTag.toGet = cms.VPSet(
0154 #    cms.PSet(
0155 #        record = cms.string("BeamSpotObjectsRcd"),
0156 #        tag = cms.string("Realistic8TeVCollisions_START50_V13_v1_mc"),
0157 #        connect = cms.untracked.string("frontier://FrontierProd/CMS_CONDITIONS"),
0158 #    )
0159 #) 
0160 print("Using global tag "+process.GlobalTag.globaltag._value)
0161 
0162 
0163 
0164 ##
0165 ## New pixel templates
0166 ##
0167 process.GlobalTag.toGet = cms.VPSet(
0168     cms.PSet(
0169         record = cms.string("SiPixelTemplateDBObjectRcd"),
0170         tag = cms.string("SiPixelTemplateDBObject_38T_v3_mc"),
0171         connect = cms.untracked.string("frontier://FrontierProd/CMS_CONDITIONS"),
0172     )
0173 ) 
0174 
0175 
0176 
0177 ##
0178 ## Alignment and APE
0179 ##
0180 import CalibTracker.Configuration.Common.PoolDBESSource_cfi
0181 ## Choose Alignment (w/o touching APE)
0182 if isMc:
0183   process.myTrackerAlignment = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
0184     connect = 'frontier://FrontierProd/CMS_CONDITIONS', # or your sqlite file
0185     toGet = [
0186       cms.PSet(
0187         record = cms.string('TrackerAlignmentRcd'),
0188         tag = cms.string('TrackerIdealGeometry210_mc') # 'TrackerAlignment_2009_v2_offline'
0189       ),
0190     ],
0191   )
0192   process.es_prefer_trackerAlignment = cms.ESPrefer("PoolDBESSource","myTrackerAlignment")
0193 
0194 process.es_prefer_trackerAlignment = cms.ESPrefer("PoolDBESSource","myTrackerAlignment")
0195 if isData:
0196   # Recent geometry
0197   process.myTrackerAlignment = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
0198     connect = 'frontier://FrontierProd/CMS_CONDITIONS',
0199     toGet = [
0200       cms.PSet(
0201         record = cms.string('TrackerAlignmentRcd'),
0202         tag = cms.string('TrackerAlignment_GR10_v6_offline'),
0203       ),
0204     ],
0205   )
0206   process.es_prefer_trackerAlignment = cms.ESPrefer("PoolDBESSource","myTrackerAlignment")
0207   # Kinks and bows
0208   process.myTrackerAlignmentKinksAndBows = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
0209     connect = 'frontier://FrontierProd/CMS_CONDITIONS',
0210     toGet = [
0211       cms.PSet(
0212         record = cms.string('TrackerSurfaceDeformationRcd'),
0213         tag = cms.string('TrackerSurfaceDeformations_v1_offline'),
0214       ),
0215     ],
0216   )
0217   process.es_prefer_trackerAlignmentKinksAndBows = cms.ESPrefer("PoolDBESSource","myTrackerAlignmentKinksAndBows")
0218 
0219 ## APE (set to zero)
0220 process.myTrackerAlignmentErr = CalibTracker.Configuration.Common.PoolDBESSource_cfi.poolDBESSource.clone(
0221     connect = 'frontier://FrontierProd/CMS_CONDITIONS',
0222     toGet = [
0223       cms.PSet(
0224         record = cms.string('TrackerAlignmentErrorExtendedRcd'),
0225         tag = cms.string('TrackerIdealGeometryErrorsExtended210_mc')
0226       ),
0227     ],
0228 )
0229 process.es_prefer_trackerAlignmentErr = cms.ESPrefer("PoolDBESSource","myTrackerAlignmentErr")
0230 
0231 
0232 
0233 ##
0234 ## Trigger Selection
0235 ##
0236 process.load("Alignment.APEEstimation.TriggerSelection_cff")
0237 
0238 
0239 
0240 ##
0241 ## ApeEstimator
0242 ##
0243 from Alignment.APEEstimation.ApeEstimator_cff import *
0244 process.ApeEstimator1 = ApeEstimator.clone(
0245     #~ tjTkAssociationMapTag = "TrackRefitterHighPurityForApeEstimator",
0246     tjTkAssociationMapTag = "TrackRefitterForApeEstimator",
0247     maxTracksPerEvent = 0,
0248     applyTrackCuts = False,
0249     Sectors = RecentSectors,
0250     analyzerMode = False,
0251     calculateApe = True
0252 )
0253 process.ApeEstimator1.HitSelector.width = []
0254 process.ApeEstimator1.HitSelector.maxIndex = []
0255 process.ApeEstimator1.HitSelector.widthProj = []
0256 process.ApeEstimator1.HitSelector.widthDiff = []
0257 process.ApeEstimator1.HitSelector.edgeStrips = []
0258 process.ApeEstimator1.HitSelector.sOverN = []
0259 process.ApeEstimator1.HitSelector.maxCharge = []
0260 process.ApeEstimator1.HitSelector.chargeOnEdges = []
0261 process.ApeEstimator1.HitSelector.probX = []
0262 process.ApeEstimator1.HitSelector.phiSensX = []
0263 process.ApeEstimator1.HitSelector.phiSensY = []
0264 process.ApeEstimator1.HitSelector.errXHit = []
0265 process.ApeEstimator1.HitSelector.chargePixel = []
0266 process.ApeEstimator1.HitSelector.widthX = []
0267 process.ApeEstimator1.HitSelector.widthY = []
0268 process.ApeEstimator1.HitSelector.logClusterProbability = []
0269 process.ApeEstimator1.HitSelector.isOnEdge = []
0270 process.ApeEstimator1.HitSelector.qBin = []
0271 
0272 
0273 process.ApeEstimator2 = process.ApeEstimator1.clone(
0274     Sectors = ValidationSectors,
0275     analyzerMode = True,
0276     calculateApe = False,
0277 )
0278 
0279 process.ApeEstimator3 = process.ApeEstimator2.clone(
0280     zoomHists = False,
0281 )
0282 
0283 
0284 
0285 ##
0286 ## Output File Configuration
0287 ##
0288 outputName = os.environ['CMSSW_BASE'] + '/src/Alignment/APEEstimation/hists/'
0289 if options.isTest:
0290     outputName = outputName + 'test_'
0291 outputName = outputName + options.sample + '.root'
0292 
0293 process.TFileService = cms.Service("TFileService",
0294     fileName = cms.string(outputName),
0295     closeFileFast = cms.untracked.bool(True)
0296 )
0297 
0298 
0299 
0300 ##
0301 ## Path
0302 ##
0303 process.p = cms.Path(
0304     process.TriggerSelectionSequence*
0305     process.RefitterHighPuritySequence*
0306     (process.ApeEstimator1+
0307      process.ApeEstimator2+
0308      process.ApeEstimator3
0309     )
0310 )
0311 
0312 
0313