1 from __future__
import print_function
3 import FWCore.ParameterSet.Config
as cms
10 import simplejson
as json
12 print(
"Please use lxplus or set an environment (for example crab) with json lib available")
15 inputfiles = os.environ[
"ALIGNMENT_INPUTFILES"].
split(
" ")
16 iteration =
int(os.environ[
"ALIGNMENT_ITERATION"])
17 jobnumber =
int(os.environ[
"ALIGNMENT_JOBNUMBER"])
18 mapplots = (os.environ[
"ALIGNMENT_MAPPLOTS"] ==
"True")
19 segdiffplots = (os.environ[
"ALIGNMENT_SEGDIFFPLOTS"] ==
"True")
20 curvatureplots = (os.environ[
"ALIGNMENT_CURVATUREPLOTS"] ==
"True")
22 globaltag = os.environ[
"ALIGNMENT_GLOBALTAG"]
23 inputdb = os.environ[
"ALIGNMENT_INPUTDB"]
24 trackerconnect = os.environ[
"ALIGNMENT_TRACKERCONNECT"]
25 trackeralignment = os.environ[
"ALIGNMENT_TRACKERALIGNMENT"]
26 trackerAPEconnect = os.environ[
"ALIGNMENT_TRACKERAPECONNECT"]
27 trackerAPE = os.environ[
"ALIGNMENT_TRACKERAPE"]
28 trackerBowsconnect = os.environ[
"ALIGNMENT_TRACKERBOWSCONNECT"]
29 trackerBows = os.environ[
"ALIGNMENT_TRACKERBOWS"]
30 gprcdconnect = os.environ[
"ALIGNMENT_GPRCDCONNECT"]
31 gprcd = os.environ[
"ALIGNMENT_GPRCD"]
33 iscosmics = (os.environ[
"ALIGNMENT_ISCOSMICS"] ==
"True")
34 station123params = os.environ[
"ALIGNMENT_STATION123PARAMS"]
35 station4params = os.environ[
"ALIGNMENT_STATION4PARAMS"]
36 cscparams = os.environ[
"ALIGNMENT_CSCPARAMS"]
37 minTrackPt =
float(os.environ[
"ALIGNMENT_MINTRACKPT"])
38 maxTrackPt =
float(os.environ[
"ALIGNMENT_MAXTRACKPT"])
39 minTrackP =
float(os.environ[
"ALIGNMENT_MINTRACKP"])
40 maxTrackP =
float(os.environ[
"ALIGNMENT_MAXTRACKP"])
41 minTrackerHits =
int(os.environ[
"ALIGNMENT_MINTRACKERHITS"])
42 maxTrackerRedChi2 =
float(os.environ[
"ALIGNMENT_MAXTRACKERREDCHI2"])
43 allowTIDTEC = (os.environ[
"ALIGNMENT_ALLOWTIDTEC"] ==
"True")
44 twoBin = (os.environ[
"ALIGNMENT_TWOBIN"] ==
"True")
45 weightAlignment = (os.environ[
"ALIGNMENT_WEIGHTALIGNMENT"] ==
"True")
46 minAlignmentHits =
int(os.environ[
"ALIGNMENT_MINALIGNMENTHITS"])
47 combineME11 = (os.environ[
"ALIGNMENT_COMBINEME11"] ==
"True")
48 maxEvents =
int(os.environ[
"ALIGNMENT_MAXEVENTS"])
49 skipEvents =
int(os.environ[
"ALIGNMENT_SKIPEVENTS"])
50 maxResSlopeY =
float(os.environ[
"ALIGNMENT_MAXRESSLOPEY"])
51 preFilter = (os.environ[
"ALIGNMENT_PREFILTER"] ==
"True")
52 muonCollectionTag = os.environ[
"ALIGNMENT_MUONCOLLECTIONTAG"]
53 maxDxy =
float(os.environ[
"ALIGNMENT_MAXDXY"])
54 minNCrossedChambers =
int(os.environ[
"ALIGNMENT_MINNCROSSEDCHAMBERS"])
57 createAlignNtuple =
False 58 envNtuple = os.getenv(
"ALIGNMENT_CREATEALIGNNTUPLE")
59 if envNtuple
is not None:
60 if envNtuple==
'True': createAlignNtuple =
True 63 createMapNtuple =
False 64 envNtuple = os.getenv(
"ALIGNMENT_CREATEMAPNTUPLE")
65 if envNtuple
is not None:
66 if envNtuple==
'True': createMapNtuple =
True 71 envDT = os.getenv(
"ALIGNMENT_DO_DT")
72 envCSC = os.getenv(
"ALIGNMENT_DO_CSC")
73 if envDT
is not None and envCSC
is not None:
74 if envDT==
'True' and envCSC==
'False':
77 if envDT==
'False' and envCSC==
'True':
83 json_file = os.getenv(
"ALIGNMENT_JSON")
85 if json_file
is not None and json_file !=
'':
86 jsonfile=
file(json_file,
'r') 87 jsondict = json.load(jsonfile) 88 runs = sorted(jsondict.keys()) 90 blocks = sorted(jsondict[run])
92 for lsrange
in blocks:
93 if lsrange[0] == prevblock[1]+1:
95 prevblock[1] = lsrange[1]
96 good_lumis[-1] =
str(
"%s:%s-%s:%s" % (run, prevblock[0], run, prevblock[1]))
98 good_lumis.append(
str(
"%s:%s-%s:%s" % (run, lsrange[0], run, lsrange[1])))
102 process = cms.Process(
"GATHER")
104 process.load(
"Geometry.MuonNumbering.muonNumberingInitialization_cfi")
105 process.load(
"Geometry.DTGeometry.dtGeometry_cfi")
106 process.load(
"Geometry.RPCGeometry.rpcGeometry_cfi")
107 process.load(
"Geometry.CSCGeometry.cscGeometry_cfi")
108 process.load(
"Geometry.CommonDetUnit.bareGlobalTrackingGeometry_cfi")
111 process.load(
"TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
116 process.load(
"Configuration.StandardSequences.Reconstruction_cff")
118 process.MuonNumberingInitialization = cms.ESProducer(
"MuonNumberingInitialization")
119 process.MuonNumberingRecord = cms.ESSource(
"EmptyESSource",
120 recordName = cms.string(
"MuonNumberingRecord" ),
121 iovIsRunNotTime = cms.bool(
True ),
122 firstValid = cms.vuint32( 1 )
125 process.load(
"Configuration.StandardSequences.GeometryDB_cff")
126 process.load(
'Configuration.StandardSequences.MagneticField_cff')
128 if len(good_lumis)>0:
129 process.source = cms.Source(
"PoolSource",
130 fileNames = cms.untracked.vstring(*inputfiles),
131 skipEvents = cms.untracked.uint32(skipEvents),
132 lumisToProcess = cms.untracked.VLuminosityBlockRange(*good_lumis))
134 process.source = cms.Source(
"PoolSource",
135 fileNames = cms.untracked.vstring(*inputfiles),
136 skipEvents = cms.untracked.uint32(skipEvents))
138 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(maxEvents))
142 process.MessageLogger = cms.Service(
"MessageLogger",
143 destinations = cms.untracked.vstring(
"cout"),
144 cout = cms.untracked.PSet(threshold = cms.untracked.string(
"ERROR"),
145 ERROR = cms.untracked.PSet(limit = cms.untracked.int32(10))))
147 process.load(
"Alignment.MuonAlignmentAlgorithms.MuonAlignmentFromReference_cff")
148 process.looper.ParameterBuilder.Selector.alignParams = cms.vstring(
"MuonDTChambers,%s,stations123" % station123params,
"MuonDTChambers,%s,station4" % station4params,
"MuonCSCChambers,%s" % cscparams)
151 process.looper.algoConfig.writeTemporaryFile =
"alignment%04d.tmp" % jobnumber
152 process.looper.algoConfig.doAlignment =
False 153 process.looper.algoConfig.muonCollectionTag = cms.InputTag(muonCollectionTag)
154 process.looper.algoConfig.minTrackPt = minTrackPt
155 process.looper.algoConfig.maxTrackPt = maxTrackPt
156 process.looper.algoConfig.minTrackP = minTrackP
157 process.looper.algoConfig.maxTrackP = maxTrackP
158 process.looper.algoConfig.maxDxy = maxDxy
159 process.looper.algoConfig.minTrackerHits = minTrackerHits
160 process.looper.algoConfig.maxTrackerRedChi2 = maxTrackerRedChi2
161 process.looper.algoConfig.allowTIDTEC = allowTIDTEC
162 process.looper.algoConfig.minNCrossedChambers = minNCrossedChambers
163 process.looper.algoConfig.twoBin = twoBin
164 process.looper.algoConfig.weightAlignment = weightAlignment
165 process.looper.algoConfig.minAlignmentHits = minAlignmentHits
166 process.looper.algoConfig.combineME11 = combineME11
167 process.looper.algoConfig.maxResSlopeY = maxResSlopeY
169 process.looper.algoConfig.minDT13Hits = 7
170 process.looper.algoConfig.doDT = doDT
171 process.looper.algoConfig.doCSC = doCSC
173 process.looper.monitorConfig = cms.PSet(monitors = cms.untracked.vstring())
176 process.load(
"Alignment.CommonAlignmentMonitor.AlignmentMonitorMuonSystemMap1D_cfi")
177 process.looper.monitorConfig.monitors.append(
"AlignmentMonitorMuonSystemMap1D")
178 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D = process.AlignmentMonitorMuonSystemMap1D
179 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.muonCollectionTag = cms.InputTag(muonCollectionTag)
180 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minTrackPt = minTrackPt
181 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxTrackPt = maxTrackPt
182 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minTrackP = minTrackP
183 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxTrackP = maxTrackP
184 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxDxy = maxDxy
185 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minTrackerHits = minTrackerHits
186 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxTrackerRedChi2 = maxTrackerRedChi2
187 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.allowTIDTEC = allowTIDTEC
188 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minNCrossedChambers = process.looper.algoConfig.minNCrossedChambers
189 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minDT13Hits = process.looper.algoConfig.minDT13Hits
190 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minDT2Hits = process.looper.algoConfig.minDT2Hits
191 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minCSCHits = process.looper.algoConfig.minCSCHits
192 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.doDT = doDT
193 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.doCSC = doCSC
194 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.createNtuple = createMapNtuple
197 process.load(
"Alignment.CommonAlignmentMonitor.AlignmentMonitorSegmentDifferences_cfi")
198 process.looper.monitorConfig.monitors.append(
"AlignmentMonitorSegmentDifferences")
199 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences = process.AlignmentMonitorSegmentDifferences
200 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.muonCollectionTag = cms.InputTag(muonCollectionTag)
201 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minTrackPt = minTrackPt
202 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minTrackP = minTrackP
203 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.maxDxy = maxDxy
204 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minTrackerHits = minTrackerHits
205 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.maxTrackerRedChi2 = maxTrackerRedChi2
206 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.allowTIDTEC = allowTIDTEC
207 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minNCrossedChambers = process.looper.algoConfig.minNCrossedChambers
208 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minDT13Hits = process.looper.algoConfig.minDT13Hits
209 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minDT2Hits = process.looper.algoConfig.minDT2Hits
210 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minCSCHits = process.looper.algoConfig.minCSCHits
211 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.doDT = doDT
212 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.doCSC = doCSC
215 process.load(
"Alignment.CommonAlignmentMonitor.AlignmentMonitorMuonVsCurvature_cfi")
216 process.looper.monitorConfig.monitors.append(
"AlignmentMonitorMuonVsCurvature")
217 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature = process.AlignmentMonitorMuonVsCurvature
218 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.muonCollectionTag = cms.InputTag(muonCollectionTag)
219 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minTrackPt = minTrackPt
221 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.maxDxy = maxDxy
222 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minTrackerHits = minTrackerHits
223 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.maxTrackerRedChi2 = maxTrackerRedChi2
224 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.allowTIDTEC = allowTIDTEC
225 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minNCrossedChambers = process.looper.algoConfig.minNCrossedChambers
226 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minDT13Hits = process.looper.algoConfig.minDT13Hits
227 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minDT2Hits = process.looper.algoConfig.minDT2Hits
228 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minCSCHits = process.looper.algoConfig.minCSCHits
229 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.doDT = doDT
230 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.doCSC = doCSC
232 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
233 process.GlobalTag.globaltag = cms.string(globaltag)
234 process.looper.applyDbAlignment =
True 235 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cfi")
237 process.load(
"Alignment.MuonAlignmentAlgorithms.MuonAlignmentPreFilter_cfi")
238 process.MuonAlignmentPreFilter.minTrackPt = minTrackPt
239 process.MuonAlignmentPreFilter.minTrackP = minTrackP
240 process.MuonAlignmentPreFilter.minTrackerHits = minTrackerHits
241 process.MuonAlignmentPreFilter.allowTIDTEC = allowTIDTEC
244 process.MuonAlignmentPreFilter.tracksTag = cms.InputTag(
"ALCARECOMuAlGlobalCosmics:GlobalMuon")
245 if preFilter: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentPreFilter * process.MuonAlignmentFromReferenceGlobalCosmicRefit)
246 else: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentFromReferenceGlobalCosmicRefit)
247 process.looper.tjTkAssociationMapTag = cms.InputTag(
"MuonAlignmentFromReferenceGlobalCosmicRefit:Refitted")
250 process.MuonAlignmentPreFilter.tracksTag = cms.InputTag(
"globalMuons")
251 process.MuonAlignmentFromReferenceGlobalMuonRefit.Tracks = cms.InputTag(
"globalMuons")
252 if preFilter: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentPreFilter * process.MuonAlignmentFromReferenceGlobalMuonRefit)
253 else: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentFromReferenceGlobalMuonRefit)
254 process.looper.tjTkAssociationMapTag = cms.InputTag(
"MuonAlignmentFromReferenceGlobalMuonRefit:Refitted")
257 if len(muonCollectionTag) > 0:
258 process.Path = cms.Path(process.offlineBeamSpot * process.newmuons)
261 process.MuonAlignmentFromReferenceInputDB.connect = cms.string(
"sqlite_file:%s" % inputdb)
262 process.MuonAlignmentFromReferenceInputDB.toGet = cms.VPSet(cms.PSet(record = cms.string(
"DTAlignmentRcd"), tag = cms.string(
"DTAlignmentRcd")),
263 cms.PSet(record = cms.string(
"CSCAlignmentRcd"), tag = cms.string(
"CSCAlignmentRcd")))
265 if trackerconnect !=
"":
267 process.TrackerAlignmentInputDB = cms.ESSource(
"PoolDBESSource",
269 connect = cms.string(trackerconnect),
270 toGet = cms.VPSet(cms.PSet(record = cms.string(
"TrackerAlignmentRcd"), tag = cms.string(trackeralignment))))
271 process.es_prefer_TrackerAlignmentInputDB = cms.ESPrefer(
"PoolDBESSource",
"TrackerAlignmentInputDB")
273 if trackerAPEconnect !=
"":
275 process.TrackerAlignmentErrorInputDB = cms.ESSource(
"PoolDBESSource",
277 connect = cms.string(trackerAPEconnect),
278 toGet = cms.VPSet(cms.PSet(cms.PSet(record = cms.string(
"TrackerAlignmentErrorExtendedRcd"), tag = cms.string(trackerAPE)))))
279 process.es_prefer_TrackerAlignmentErrorInputDB = cms.ESPrefer(
"PoolDBESSource",
"TrackerAlignmentErrorInputDB")
281 if trackerBowsconnect !=
"":
283 process.TrackerSurfaceDeformationInputDB = cms.ESSource(
"PoolDBESSource",
285 connect = cms.string(trackerBowsconnect),
286 toGet = cms.VPSet(cms.PSet(cms.PSet(record = cms.string(
"TrackerSurfaceDeformationRcd"), tag = cms.string(trackerBows)))))
287 process.es_prefer_TrackerSurfaceDeformationInputDB = cms.ESPrefer(
"PoolDBESSource",
"TrackerSurfaceDeformationInputDB")
289 if gprcdconnect !=
"":
291 process.GlobalPositionInputDB = cms.ESSource(
"PoolDBESSource",
293 connect = cms.string(gprcdconnect),
294 toGet = cms.VPSet(cms.PSet(record = cms.string(
"GlobalPositionRcd"), tag = cms.string(gprcd))))
295 process.es_prefer_GlobalPositionInputDB = cms.ESPrefer(
"PoolDBESSource",
"GlobalPositionInputDB")
334 process.looper.saveToDB =
False 335 process.looper.saveApeToDB =
False 336 del process.PoolDBOutputService
338 process.TFileService = cms.Service(
"TFileService", fileName = cms.string(
"plotting%03d.root" % jobnumber))
S & print(S &os, JobReport::InputFile const &f)