Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-13 03:23:09

0001 import os
0002 
0003 import FWCore.ParameterSet.Config as cms
0004 
0005 
0006 
0007 
0008 ##
0009 ## Setup command line options
0010 ##
0011 import FWCore.ParameterSet.VarParsing as VarParsing
0012 import sys
0013 options = VarParsing.VarParsing ('standard')
0014 options.register('workingArea', None, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Working area")
0015 options.register('globalTag', "None", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Custom global tag")
0016 options.register('measName', None, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Folder in which to store results")
0017 options.register('fileNumber', 1, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Input file number")
0018 options.register('iteration', 0, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "Iteration number")
0019 options.register('lastIter', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.bool, "Last iteration")
0020 options.register('isCosmics', False, VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.bool, "Cosmic data set")
0021 # get and parse the command line arguments
0022 options.parseArguments()   
0023 
0024 ##
0025 ## Process definition
0026 ##
0027 process = cms.Process("ApeEstimator")
0028 
0029 
0030 process.load("Configuration.Geometry.GeometryRecoDB_cff")
0031 process.load("Configuration.StandardSequences.Services_cff")
0032 process.load("Configuration.StandardSequences.MagneticField_cff")
0033 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
0034 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0035 from Configuration.AlCa.GlobalTag import GlobalTag
0036 from CondCore.CondDB.CondDB_cfi import *
0037 
0038 ##
0039 ## Message Logger
0040 ##
0041 process.load("FWCore.MessageService.MessageLogger_cfi")
0042 process.MessageLogger.SectorBuilder=dict()
0043 process.MessageLogger.ResidualErrorBinning=dict()
0044 process.MessageLogger.HitSelector=dict()
0045 process.MessageLogger.CalculateAPE=dict()
0046 process.MessageLogger.ApeEstimator=dict()
0047 process.MessageLogger.TrackRefitter=dict()
0048 process.MessageLogger.AlignmentTrackSelector=dict()
0049 process.MessageLogger.cerr.threshold = 'WARNING'
0050 process.MessageLogger.cerr.INFO.limit = 0
0051 process.MessageLogger.cerr.default.limit = -1
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 ## Process options
0062 ##
0063 process.options = cms.untracked.PSet(
0064     wantSummary = cms.untracked.bool(True),
0065 )
0066 
0067 
0068 ##
0069 ## Input Files
0070 ##
0071 readFiles = cms.untracked.vstring()
0072 process.source = cms.Source ("PoolSource",
0073     fileNames = readFiles
0074 )
0075 readFiles.extend( [
0076     'file:reco.root',
0077 ] )
0078 
0079 
0080 
0081 ##
0082 ## Number of Events (should be after input file)
0083 ##
0084 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(options.maxEvents) ) # maxEvents is included in options by default
0085 
0086 
0087 
0088 ##
0089 ## Check run and event numbers for Dublicates --- only for real data
0090 ##
0091 process.source.duplicateCheckMode = cms.untracked.string("checkEachRealDataFile")
0092 #process.source.duplicateCheckMode = cms.untracked.string("checkAllFilesOpened")   # default value
0093 
0094 
0095 ##
0096 ## Whole Refitter Sequence
0097 ##
0098 process.load("Alignment.APEEstimation.TrackRefitter_38T_cff")
0099 process.GlobalTag = GlobalTag(process.GlobalTag, options.globalTag, '')
0100 
0101 
0102 
0103 import importlib
0104 mod = importlib.import_module("Alignment.APEEstimation.conditions.measurement_{}_cff".format(options.measName))
0105 mod.applyConditions(process)
0106 
0107 
0108 ## APE
0109 if options.iteration!=0:
0110     CondDBAlignmentError = CondDB.clone(connect = cms.string('sqlite_file:'+os.path.join(options.workingArea,options.measName)+'/apeObjects/apeIter'+str(options.iteration-1)+'.db'))
0111     process.myTrackerAlignmentErr = cms.ESSource("PoolDBESSource",
0112         CondDBAlignmentError,
0113         timetype = cms.string("runnumber"),
0114         toGet = cms.VPSet(
0115             cms.PSet(
0116                 record = cms.string('TrackerAlignmentErrorExtendedRcd'),
0117                 tag = cms.string('APEs')
0118             )
0119         )
0120     )
0121     process.es_prefer_trackerAlignmentErr = cms.ESPrefer("PoolDBESSource","myTrackerAlignmentErr")
0122 
0123 
0124 ##
0125 ## ApeEstimator
0126 ##
0127 from Alignment.APEEstimation.ApeEstimator_cff import *
0128 process.ApeEstimator1 = ApeEstimator.clone(
0129     tjTkAssociationMapTag = "TrackRefitterForApeEstimator",
0130     applyTrackCuts = False,
0131     analyzerMode = False,
0132     calculateApe = True,
0133     Sectors = RecentSectors,
0134 )
0135 
0136 process.ApeEstimator2 = process.ApeEstimator1.clone(
0137   Sectors = ValidationSectors,
0138   analyzerMode = True,
0139   calculateApe = False,
0140 )
0141 process.ApeEstimator3 = process.ApeEstimator2.clone(
0142     zoomHists = False,
0143 )
0144 
0145 process.ApeEstimatorSequence = cms.Sequence(process.ApeEstimator1)
0146 if options.iteration==0:
0147   process.ApeEstimatorSequence *= process.ApeEstimator2
0148   process.ApeEstimatorSequence *= process.ApeEstimator3
0149 elif options.lastIter == True:
0150   process.ApeEstimatorSequence *= process.ApeEstimator2
0151 
0152 
0153 
0154 ##
0155 ## Output File Configuration
0156 ##
0157 process.TFileService = cms.Service("TFileService",
0158     fileName = cms.string(os.path.join(options.workingArea,options.measName,"out"+str(options.fileNumber)+".root")),
0159     closeFileFast = cms.untracked.bool(True)
0160 )
0161 
0162 
0163 
0164 ##
0165 ## Path
0166 ##
0167 
0168 if not options.isCosmics:
0169     process.p = cms.Path(
0170         process.RefitterHighPuritySequence*
0171         process.ApeEstimatorSequence
0172     )
0173 else:
0174     process.p = cms.Path(
0175         process.RefitterNoPuritySequence* # this sequence doesn't include high purity track criteria
0176         process.ApeEstimatorSequence
0177     )
0178 
0179 
0180