Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:40:36

0001 import glob
0002 import FWCore.ParameterSet.Config as cms
0003 from Alignment.OfflineValidation.TkAlAllInOneTool.defaultInputFiles_cff import filesDefaultData_Comissioning2022_Cosmics_string
0004 
0005 ###################################################################
0006 # Setup 'standard' options
0007 ###################################################################
0008 import FWCore.ParameterSet.VarParsing as VarParsing
0009 options = VarParsing.VarParsing()
0010 options.register('outFileName',
0011                  "test.root", # default value
0012                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0013                  VarParsing.VarParsing.varType.string, # string, int, or float
0014                  "name of the output file (test.root is default)")
0015 
0016 options.register('trackCollection',
0017                  "ctfWithMaterialTracksP5", #ALCARECOTkAlCosmicsCTF0T
0018                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0019                  VarParsing.VarParsing.varType.string, # string, int, or float
0020                  "name of the input track collection")
0021 
0022 options.register('globalTag',
0023                  "auto:run3_data_prompt", # default value
0024                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0025                  VarParsing.VarParsing.varType.string, # string, int, or float
0026                  "name of the input Global Tag")
0027 
0028 options.register('unitTest',
0029                  False, # default value
0030                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0031                  VarParsing.VarParsing.varType.bool, # string, int, or float
0032                  "is it a unit test?")
0033 
0034 options.register('inputData',
0035                  "/eos/cms/store/express/Commissioning2022/ExpressCosmics/FEVT/Express-v1/000/350/010/00000/*",
0036                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list
0037                  VarParsing.VarParsing.varType.string, # string, int, or float
0038                  "eos directory to read from")
0039 
0040 options.register('maxEvents',
0041                  -1,
0042                  VarParsing.VarParsing.multiplicity.singleton, # singleton or list                 
0043                  VarParsing.VarParsing.varType.int, # string, int, or float
0044                  "num. events to run")
0045 
0046 options.parseArguments()
0047 
0048 process = cms.Process("AlCaRECOAnalysis")
0049 
0050 ###################################################################
0051 # Message logger service
0052 ###################################################################
0053 process.load("FWCore.MessageLogger.MessageLogger_cfi")
0054 process.MessageLogger.cerr.enable = False
0055 process.MessageLogger.DMRChecker=dict()  
0056 process.MessageLogger.GeneralPurposeTrackAnalyzer=dict()
0057 process.MessageLogger.cout = cms.untracked.PSet(
0058     enable = cms.untracked.bool(True),
0059     threshold = cms.untracked.string("INFO"),
0060     default   = cms.untracked.PSet(limit = cms.untracked.int32(0)),                       
0061     FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
0062                                    reportEvery = cms.untracked.int32(1000)
0063                                    ),                                                      
0064     DMRChecker = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
0065     GeneralPurposeTrackAnalyzer = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
0066     #enableStatistics = cms.untracked.bool(True)
0067     )
0068 
0069 ###################################################################
0070 # Geometry producer and standard includes
0071 ###################################################################
0072 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
0073 process.load("Configuration.StandardSequences.Services_cff")
0074 process.load("Configuration.StandardSequences.GeometryRecoDB_cff")
0075 process.load('Configuration.StandardSequences.MagneticField_cff')
0076 #process.load("Configuration.StandardSequences.MagneticField_0T_cff")
0077 process.load("CondCore.CondDB.CondDB_cfi")
0078 
0079 ####################################################################
0080 # Get the GlogalTag
0081 ####################################################################
0082 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0083 from Configuration.AlCa.GlobalTag import GlobalTag
0084 process.GlobalTag = GlobalTag(process.GlobalTag,options.globalTag, '')
0085 
0086 ###################################################################
0087 # Source
0088 ###################################################################
0089 readFiles = cms.untracked.vstring()
0090 process.source = cms.Source("PoolSource",fileNames = readFiles)
0091 the_files=[]
0092 if(options.unitTest):
0093     ## fixed input for the unit test
0094     readFiles.extend([filesDefaultData_Comissioning2022_Cosmics_string]) 
0095 else:
0096     file_list = glob.glob(options.inputData)
0097     for f in file_list:
0098         the_files.append(f.replace("/eos/cms",""))
0099     print(the_files)
0100     readFiles.extend(the_files)
0101 
0102 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32((10 if (options.unitTest) else options.maxEvents)))
0103 
0104 ###################################################################
0105 # momentum constraint for 0T
0106 ###################################################################
0107 process.load("RecoTracker.TrackProducer.MomentumConstraintProducer_cff")
0108 import RecoTracker.TrackProducer.MomentumConstraintProducer_cff
0109 process.AliMomConstraint = RecoTracker.TrackProducer.MomentumConstraintProducer_cff.MyMomConstraint.clone()
0110 process.AliMomConstraint.src = options.trackCollection
0111 process.AliMomConstraint.fixedMomentum = 5.0
0112 process.AliMomConstraint.fixedMomentumError = 0.005
0113 
0114 ###################################################################
0115 # Alignment Track Selector
0116 ###################################################################
0117 import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
0118 process.MuSkimSelector = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone(
0119     applyBasicCuts = True,                                                                            
0120     filter = True,
0121     src = options.trackCollection,
0122     ptMin = 17.,
0123     pMin = 17.,
0124     etaMin = -2.5,
0125     etaMax = 2.5,
0126     d0Min = -2.,
0127     d0Max = 2.,
0128     dzMin = -25.,
0129     dzMax = 25.,
0130     nHitMin = 6,
0131     nHitMin2D = 0)
0132 
0133 ###################################################################
0134 # The TrackRefitter
0135 ###################################################################
0136 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
0137 import RecoTracker.TrackProducer.TrackRefitters_cff
0138 process.TrackRefitter1 = process.TrackRefitterP5.clone(
0139     src =  options.trackCollection, #'AliMomConstraint',
0140     TrajectoryInEvent = True,
0141     TTRHBuilder = "WithAngleAndTemplate", #"WithTrackAngle"
0142     NavigationSchool = "",
0143     #constraint = 'momentum', ### SPECIFIC FOR CRUZET
0144     #srcConstr='AliMomConstraint' ### SPECIFIC FOR CRUZET$works only with tag V02-10-02 TrackingTools/PatternTools / or CMSSW >=31X
0145     )
0146 
0147 ###################################################################
0148 # the pT filter
0149 ###################################################################
0150 from CommonTools.RecoAlgos.ptMaxTrackCountFilter_cfi import ptMaxTrackCountFilter
0151 process.myfilter = ptMaxTrackCountFilter.clone(src = cms.InputTag(options.trackCollection),
0152                                                ptMax = cms.double(10.))
0153 
0154 process.preAnaSeq = cms.Sequence()
0155 if(options.unitTest):
0156     print("adding the max pT filter")
0157     process.preAnaSeq = cms.Sequence(process.myfilter)
0158 
0159 ###################################################################
0160 # The analysis module
0161 ###################################################################
0162 process.myanalysis = cms.EDAnalyzer("GeneralPurposeTrackAnalyzer",
0163                                     TkTag  = cms.InputTag('TrackRefitter1'),
0164                                     isCosmics = cms.bool(True))
0165 
0166 process.fastdmr = cms.EDAnalyzer("DMRChecker",
0167                                  TkTag  = cms.InputTag('TrackRefitter1'),
0168                                  isCosmics = cms.bool(True))
0169 
0170 ###################################################################
0171 # Output name
0172 ###################################################################
0173 process.TFileService = cms.Service("TFileService",
0174                                    fileName = cms.string(options.outFileName))
0175 
0176 ###################################################################
0177 # Path
0178 ###################################################################
0179 process.p1 = cms.Path(process.offlineBeamSpot
0180                       #*process.AliMomConstraint  # for 0T
0181                       *process.TrackRefitter1
0182                       *process.myanalysis
0183                       *process.fastdmr)
0184 
0185 ###################################################################
0186 # preprend the filter
0187 ###################################################################
0188 if(options.unitTest):
0189     process.p1.insert(0, process.preAnaSeq)