CMS 3D CMS Logo

align_cfg.py
Go to the documentation of this file.
1 import os
2 import FWCore.ParameterSet.Config as cms
3 
4 alignmenttmp = os.environ["ALIGNMENT_ALIGNMENTTMP"].split("\n")
5 iteration = int(os.environ["ALIGNMENT_ITERATION"])
6 
7 globaltag = os.environ["ALIGNMENT_GLOBALTAG"]
8 inputdb = os.environ["ALIGNMENT_INPUTDB"]
9 trackerconnect = os.environ["ALIGNMENT_TRACKERCONNECT"]
10 trackeralignment = os.environ["ALIGNMENT_TRACKERALIGNMENT"]
11 trackerAPEconnect = os.environ["ALIGNMENT_TRACKERAPECONNECT"]
12 trackerAPE = os.environ["ALIGNMENT_TRACKERAPE"]
13 trackerBowsconnect = os.environ["ALIGNMENT_TRACKERBOWSCONNECT"]
14 trackerBows = os.environ["ALIGNMENT_TRACKERBOWS"]
15 gprcdconnect = os.environ["ALIGNMENT_GPRCDCONNECT"]
16 gprcd = os.environ["ALIGNMENT_GPRCD"]
17 
18 iscosmics = (os.environ["ALIGNMENT_ISCOSMICS"] == "True")
19 station123params = os.environ["ALIGNMENT_STATION123PARAMS"]
20 station4params = os.environ["ALIGNMENT_STATION4PARAMS"]
21 cscparams = os.environ["ALIGNMENT_CSCPARAMS"]
22 minTrackPt = float(os.environ["ALIGNMENT_MINTRACKPT"])
23 maxTrackPt = float(os.environ["ALIGNMENT_MAXTRACKPT"])
24 minTrackP = float(os.environ["ALIGNMENT_MINTRACKP"])
25 maxTrackP = float(os.environ["ALIGNMENT_MAXTRACKP"])
26 minTrackerHits = int(os.environ["ALIGNMENT_MINTRACKERHITS"])
27 maxTrackerRedChi2 = float(os.environ["ALIGNMENT_MAXTRACKERREDCHI2"])
28 allowTIDTEC = (os.environ["ALIGNMENT_ALLOWTIDTEC"] == "True")
29 twoBin = (os.environ["ALIGNMENT_TWOBIN"] == "True")
30 weightAlignment = (os.environ["ALIGNMENT_WEIGHTALIGNMENT"] == "True")
31 minAlignmentHits = int(os.environ["ALIGNMENT_MINALIGNMENTHITS"])
32 combineME11 = (os.environ["ALIGNMENT_COMBINEME11"] == "True")
33 maxResSlopeY = float(os.environ["ALIGNMENT_MAXRESSLOPEY"])
34 residualsModel = os.environ["ALIGNMENT_RESIDUALSMODEL"]
35 peakNSigma = float(os.environ["ALIGNMENT_PEAKNSIGMA"])
36 useResiduals = os.environ["ALIGNMENT_USERESIDUALS"]
37 
38 # optionally do selective DT or CSC alignment
39 doDT = True
40 doCSC = True
41 envDT = os.getenv("ALIGNMENT_DO_DT")
42 envCSC = os.getenv("ALIGNMENT_DO_CSC")
43 if envDT is not None and envCSC is not None:
44  if envDT=='True' and envCSC=='False':
45  doDT = True
46  doCSC = False
47  if envDT=='False' and envCSC=='True':
48  doDT = False
49  doCSC = True
50 
51 # optionally: create ntuples along with tmp files
52 createAlignNtuple = False
53 envNtuple = os.getenv("ALIGNMENT_CREATEALIGNNTUPLE")
54 if envNtuple is not None:
55  if envNtuple=='True': createAlignNtuple = True
56 
57 
58 process = cms.Process("ALIGN")
59 process.source = cms.Source("EmptySource")
60 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))
61 
62 process.load("Configuration.StandardSequences.Reconstruction_cff")
63 
64 process.MuonNumberingInitialization = cms.ESProducer("MuonNumberingInitialization")
65 process.MuonNumberingRecord = cms.ESSource( "EmptyESSource",
66  recordName = cms.string( "MuonNumberingRecord" ),
67  iovIsRunNotTime = cms.bool( True ),
68  firstValid = cms.vuint32( 1 )
69 )
70 
71 process.load("Configuration.Geometry.GeometryIdeal_cff")
72 process.load("Configuration.StandardSequences.MagneticField_cff")
73 
74 process.load("Alignment.MuonAlignmentAlgorithms.MuonAlignmentFromReference_cff")
75 process.looper.algoConfig.readTemporaryFiles = cms.vstring(*alignmenttmp)
76 process.looper.algoConfig.reportFileName = cms.string("MuonAlignmentFromReference_report.py")
77 
78 process.looper.ParameterBuilder.Selector.alignParams = cms.vstring("MuonDTChambers,%s,stations123" % station123params, "MuonDTChambers,%s,station4" % station4params, "MuonCSCChambers,%s" % cscparams)
79 process.looper.algoConfig.minTrackPt = minTrackPt
80 process.looper.algoConfig.maxTrackPt = maxTrackPt
81 process.looper.algoConfig.minTrackP = minTrackP
82 process.looper.algoConfig.maxTrackP = maxTrackP
83 process.looper.algoConfig.minTrackerHits = minTrackerHits
84 process.looper.algoConfig.maxTrackerRedChi2 = maxTrackerRedChi2
85 process.looper.algoConfig.allowTIDTEC = allowTIDTEC
86 process.looper.algoConfig.twoBin = twoBin
87 process.looper.algoConfig.weightAlignment = weightAlignment
88 process.looper.algoConfig.minAlignmentHits = minAlignmentHits
89 process.looper.algoConfig.combineME11 = combineME11
90 process.looper.algoConfig.maxResSlopeY = maxResSlopeY
91 process.looper.algoConfig.residualsModel = cms.string(residualsModel)
92 process.looper.algoConfig.peakNSigma = peakNSigma
93 process.looper.algoConfig.createNtuple = createAlignNtuple
94 process.looper.algoConfig.doDT = doDT
95 process.looper.algoConfig.doCSC = doCSC
96 process.looper.algoConfig.useResiduals = cms.string(useResiduals)
97 
98 
99 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
100 process.GlobalTag.globaltag = cms.string(globaltag)
101 process.looper.applyDbAlignment = True
102 
103 process.MuonAlignmentFromReferenceInputDB.connect = cms.string("sqlite_file:%s" % inputdb)
104 process.MuonAlignmentFromReferenceInputDB.toGet = cms.VPSet(cms.PSet(record = cms.string("DTAlignmentRcd"), tag = cms.string("DTAlignmentRcd")),
105  cms.PSet(record = cms.string("CSCAlignmentRcd"), tag = cms.string("CSCAlignmentRcd")))
106 
107 if trackerconnect != "":
109  process.TrackerAlignmentInputDB = cms.ESSource("PoolDBESSource",
110  CondDBSetup,
111  connect = cms.string(trackerconnect),
112  toGet = cms.VPSet(cms.PSet(record = cms.string("TrackerAlignmentRcd"), tag = cms.string(trackeralignment))))
113  process.es_prefer_TrackerAlignmentInputDB = cms.ESPrefer("PoolDBESSource", "TrackerAlignmentInputDB")
114 
115 if trackerAPEconnect != "":
117  process.TrackerAlignmentErrorInputDB = cms.ESSource("PoolDBESSource",
118  CondDBSetup,
119  connect = cms.string(trackerAPEconnect),
120  toGet = cms.VPSet(cms.PSet(cms.PSet(record = cms.string("TrackerAlignmentErrorExtendedRcd"), tag = cms.string(trackerAPE)))))
121  process.es_prefer_TrackerAlignmentErrorInputDB = cms.ESPrefer("PoolDBESSource", "TrackerAlignmentErrorInputDB")
122 
123 if trackerBowsconnect != "":
125  process.TrackerSurfaceDeformationInputDB = cms.ESSource("PoolDBESSource",
126  CondDBSetup,
127  connect = cms.string(trackerBowsconnect),
128  toGet = cms.VPSet(cms.PSet(cms.PSet(record = cms.string("TrackerSurfaceDeformationRcd"), tag = cms.string(trackerBows)))))
129  process.es_prefer_TrackerSurfaceDeformationInputDB = cms.ESPrefer("PoolDBESSource", "TrackerSurfaceDeformationInputDB")
130 
131 if gprcdconnect != "":
133  process.GlobalPositionInputDB = cms.ESSource("PoolDBESSource",
134  CondDBSetup,
135  connect = cms.string(gprcdconnect),
136  toGet = cms.VPSet(cms.PSet(record = cms.string("GlobalPositionRcd"), tag = cms.string(gprcd))))
137  process.es_prefer_GlobalPositionInputDB = cms.ESPrefer("PoolDBESSource", "GlobalPositionInputDB")
138 
139 process.looper.saveToDB = True
140 process.looper.saveApeToDB = True
141 process.PoolDBOutputService.connect = cms.string("sqlite_file:MuonAlignmentFromReference_outputdb.db")
142 
143 process.TFileService = cms.Service("TFileService", fileName = cms.string("MuonAlignmentFromReference_plotting.root"))