2 import FWCore.ParameterSet.Config
as cms
9 import simplejson
as json
11 print "Please use lxplus or set an environment (for example crab) with json lib available" 14 inputfiles = os.environ[
"ALIGNMENT_INPUTFILES"].
split(
" ")
15 iteration =
int(os.environ[
"ALIGNMENT_ITERATION"])
16 jobnumber =
int(os.environ[
"ALIGNMENT_JOBNUMBER"])
17 mapplots = (os.environ[
"ALIGNMENT_MAPPLOTS"] ==
"True")
18 segdiffplots = (os.environ[
"ALIGNMENT_SEGDIFFPLOTS"] ==
"True")
19 curvatureplots = (os.environ[
"ALIGNMENT_CURVATUREPLOTS"] ==
"True")
21 globaltag = os.environ[
"ALIGNMENT_GLOBALTAG"]
22 inputdb = os.environ[
"ALIGNMENT_INPUTDB"]
23 trackerconnect = os.environ[
"ALIGNMENT_TRACKERCONNECT"]
24 trackeralignment = os.environ[
"ALIGNMENT_TRACKERALIGNMENT"]
25 trackerAPEconnect = os.environ[
"ALIGNMENT_TRACKERAPECONNECT"]
26 trackerAPE = os.environ[
"ALIGNMENT_TRACKERAPE"]
27 trackerBowsconnect = os.environ[
"ALIGNMENT_TRACKERBOWSCONNECT"]
28 trackerBows = os.environ[
"ALIGNMENT_TRACKERBOWS"]
29 gprcdconnect = os.environ[
"ALIGNMENT_GPRCDCONNECT"]
30 gprcd = os.environ[
"ALIGNMENT_GPRCD"]
32 iscosmics = (os.environ[
"ALIGNMENT_ISCOSMICS"] ==
"True")
33 station123params = os.environ[
"ALIGNMENT_STATION123PARAMS"]
34 station4params = os.environ[
"ALIGNMENT_STATION4PARAMS"]
35 cscparams = os.environ[
"ALIGNMENT_CSCPARAMS"]
36 minTrackPt =
float(os.environ[
"ALIGNMENT_MINTRACKPT"])
37 maxTrackPt =
float(os.environ[
"ALIGNMENT_MAXTRACKPT"])
38 minTrackP =
float(os.environ[
"ALIGNMENT_MINTRACKP"])
39 maxTrackP =
float(os.environ[
"ALIGNMENT_MAXTRACKP"])
40 minTrackerHits =
int(os.environ[
"ALIGNMENT_MINTRACKERHITS"])
41 maxTrackerRedChi2 =
float(os.environ[
"ALIGNMENT_MAXTRACKERREDCHI2"])
42 allowTIDTEC = (os.environ[
"ALIGNMENT_ALLOWTIDTEC"] ==
"True")
43 twoBin = (os.environ[
"ALIGNMENT_TWOBIN"] ==
"True")
44 weightAlignment = (os.environ[
"ALIGNMENT_WEIGHTALIGNMENT"] ==
"True")
45 minAlignmentHits =
int(os.environ[
"ALIGNMENT_MINALIGNMENTHITS"])
46 combineME11 = (os.environ[
"ALIGNMENT_COMBINEME11"] ==
"True")
47 maxEvents =
int(os.environ[
"ALIGNMENT_MAXEVENTS"])
48 skipEvents =
int(os.environ[
"ALIGNMENT_SKIPEVENTS"])
49 maxResSlopeY =
float(os.environ[
"ALIGNMENT_MAXRESSLOPEY"])
50 preFilter = (os.environ[
"ALIGNMENT_PREFILTER"] ==
"True")
51 muonCollectionTag = os.environ[
"ALIGNMENT_MUONCOLLECTIONTAG"]
52 maxDxy =
float(os.environ[
"ALIGNMENT_MAXDXY"])
53 minNCrossedChambers =
int(os.environ[
"ALIGNMENT_MINNCROSSEDCHAMBERS"])
56 createAlignNtuple =
False 57 envNtuple = os.getenv(
"ALIGNMENT_CREATEALIGNNTUPLE")
58 if envNtuple
is not None:
59 if envNtuple==
'True': createAlignNtuple =
True 62 createMapNtuple =
False 63 envNtuple = os.getenv(
"ALIGNMENT_CREATEMAPNTUPLE")
64 if envNtuple
is not None:
65 if envNtuple==
'True': createMapNtuple =
True 70 envDT = os.getenv(
"ALIGNMENT_DO_DT")
71 envCSC = os.getenv(
"ALIGNMENT_DO_CSC")
72 if envDT
is not None and envCSC
is not None:
73 if envDT==
'True' and envCSC==
'False':
76 if envDT==
'False' and envCSC==
'True':
82 json_file = os.getenv(
"ALIGNMENT_JSON")
84 if json_file
is not None and json_file !=
'':
85 jsonfile=
file(json_file,
'r') 86 jsondict = json.load(jsonfile) 87 runs = sorted(jsondict.keys()) 89 blocks = sorted(jsondict[run])
91 for lsrange
in blocks:
92 if lsrange[0] == prevblock[1]+1:
94 prevblock[1] = lsrange[1]
95 good_lumis[-1] =
str(
"%s:%s-%s:%s" % (run, prevblock[0], run, prevblock[1]))
97 good_lumis.append(
str(
"%s:%s-%s:%s" % (run, lsrange[0], run, lsrange[1])))
101 process = cms.Process(
"GATHER")
103 process.load(
"Geometry.MuonNumbering.muonNumberingInitialization_cfi")
104 process.load(
"Geometry.DTGeometry.dtGeometry_cfi")
105 process.load(
"Geometry.RPCGeometry.rpcGeometry_cfi")
106 process.load(
"Geometry.CSCGeometry.cscGeometry_cfi")
107 process.load(
"Geometry.CommonDetUnit.bareGlobalTrackingGeometry_cfi")
110 process.load(
"TrackingTools.TrackAssociator.DetIdAssociatorESProducer_cff")
115 process.load(
"Configuration.StandardSequences.Reconstruction_cff")
117 process.MuonNumberingInitialization = cms.ESProducer(
"MuonNumberingInitialization")
118 process.MuonNumberingRecord = cms.ESSource(
"EmptyESSource",
119 recordName = cms.string(
"MuonNumberingRecord" ),
120 iovIsRunNotTime = cms.bool(
True ),
121 firstValid = cms.vuint32( 1 )
124 process.load(
"Configuration.StandardSequences.GeometryDB_cff")
125 process.load(
'Configuration.StandardSequences.MagneticField_cff')
127 if len(good_lumis)>0:
128 process.source = cms.Source(
"PoolSource",
129 fileNames = cms.untracked.vstring(*inputfiles),
130 skipEvents = cms.untracked.uint32(skipEvents),
131 lumisToProcess = cms.untracked.VLuminosityBlockRange(*good_lumis))
133 process.source = cms.Source(
"PoolSource",
134 fileNames = cms.untracked.vstring(*inputfiles),
135 skipEvents = cms.untracked.uint32(skipEvents))
137 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(maxEvents))
141 process.MessageLogger = cms.Service(
"MessageLogger",
142 destinations = cms.untracked.vstring(
"cout"),
143 cout = cms.untracked.PSet(threshold = cms.untracked.string(
"ERROR"),
144 ERROR = cms.untracked.PSet(limit = cms.untracked.int32(10))))
146 process.load(
"Alignment.MuonAlignmentAlgorithms.MuonAlignmentFromReference_cff")
147 process.looper.ParameterBuilder.Selector.alignParams = cms.vstring(
"MuonDTChambers,%s,stations123" % station123params,
"MuonDTChambers,%s,station4" % station4params,
"MuonCSCChambers,%s" % cscparams)
150 process.looper.algoConfig.writeTemporaryFile =
"alignment%04d.tmp" % jobnumber
151 process.looper.algoConfig.doAlignment =
False 152 process.looper.algoConfig.muonCollectionTag = cms.InputTag(muonCollectionTag)
153 process.looper.algoConfig.minTrackPt = minTrackPt
154 process.looper.algoConfig.maxTrackPt = maxTrackPt
155 process.looper.algoConfig.minTrackP = minTrackP
156 process.looper.algoConfig.maxTrackP = maxTrackP
157 process.looper.algoConfig.maxDxy = maxDxy
158 process.looper.algoConfig.minTrackerHits = minTrackerHits
159 process.looper.algoConfig.maxTrackerRedChi2 = maxTrackerRedChi2
160 process.looper.algoConfig.allowTIDTEC = allowTIDTEC
161 process.looper.algoConfig.minNCrossedChambers = minNCrossedChambers
162 process.looper.algoConfig.twoBin = twoBin
163 process.looper.algoConfig.weightAlignment = weightAlignment
164 process.looper.algoConfig.minAlignmentHits = minAlignmentHits
165 process.looper.algoConfig.combineME11 = combineME11
166 process.looper.algoConfig.maxResSlopeY = maxResSlopeY
168 process.looper.algoConfig.minDT13Hits = 7
169 process.looper.algoConfig.doDT = doDT
170 process.looper.algoConfig.doCSC = doCSC
172 process.looper.monitorConfig = cms.PSet(monitors = cms.untracked.vstring())
175 process.load(
"Alignment.CommonAlignmentMonitor.AlignmentMonitorMuonSystemMap1D_cfi")
176 process.looper.monitorConfig.monitors.append(
"AlignmentMonitorMuonSystemMap1D")
177 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D = process.AlignmentMonitorMuonSystemMap1D
178 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.muonCollectionTag = cms.InputTag(muonCollectionTag)
179 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minTrackPt = minTrackPt
180 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxTrackPt = maxTrackPt
181 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minTrackP = minTrackP
182 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxTrackP = maxTrackP
183 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxDxy = maxDxy
184 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minTrackerHits = minTrackerHits
185 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.maxTrackerRedChi2 = maxTrackerRedChi2
186 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.allowTIDTEC = allowTIDTEC
187 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minNCrossedChambers = process.looper.algoConfig.minNCrossedChambers
188 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minDT13Hits = process.looper.algoConfig.minDT13Hits
189 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minDT2Hits = process.looper.algoConfig.minDT2Hits
190 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.minCSCHits = process.looper.algoConfig.minCSCHits
191 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.doDT = doDT
192 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.doCSC = doCSC
193 process.looper.monitorConfig.AlignmentMonitorMuonSystemMap1D.createNtuple = createMapNtuple
196 process.load(
"Alignment.CommonAlignmentMonitor.AlignmentMonitorSegmentDifferences_cfi")
197 process.looper.monitorConfig.monitors.append(
"AlignmentMonitorSegmentDifferences")
198 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences = process.AlignmentMonitorSegmentDifferences
199 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.muonCollectionTag = cms.InputTag(muonCollectionTag)
200 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minTrackPt = minTrackPt
201 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minTrackP = minTrackP
202 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.maxDxy = maxDxy
203 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minTrackerHits = minTrackerHits
204 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.maxTrackerRedChi2 = maxTrackerRedChi2
205 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.allowTIDTEC = allowTIDTEC
206 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minNCrossedChambers = process.looper.algoConfig.minNCrossedChambers
207 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minDT13Hits = process.looper.algoConfig.minDT13Hits
208 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minDT2Hits = process.looper.algoConfig.minDT2Hits
209 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.minCSCHits = process.looper.algoConfig.minCSCHits
210 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.doDT = doDT
211 process.looper.monitorConfig.AlignmentMonitorSegmentDifferences.doCSC = doCSC
214 process.load(
"Alignment.CommonAlignmentMonitor.AlignmentMonitorMuonVsCurvature_cfi")
215 process.looper.monitorConfig.monitors.append(
"AlignmentMonitorMuonVsCurvature")
216 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature = process.AlignmentMonitorMuonVsCurvature
217 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.muonCollectionTag = cms.InputTag(muonCollectionTag)
218 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minTrackPt = minTrackPt
220 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.maxDxy = maxDxy
221 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minTrackerHits = minTrackerHits
222 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.maxTrackerRedChi2 = maxTrackerRedChi2
223 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.allowTIDTEC = allowTIDTEC
224 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minNCrossedChambers = process.looper.algoConfig.minNCrossedChambers
225 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minDT13Hits = process.looper.algoConfig.minDT13Hits
226 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minDT2Hits = process.looper.algoConfig.minDT2Hits
227 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.minCSCHits = process.looper.algoConfig.minCSCHits
228 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.doDT = doDT
229 process.looper.monitorConfig.AlignmentMonitorMuonVsCurvature.doCSC = doCSC
231 process.load(
"Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
232 process.GlobalTag.globaltag = cms.string(globaltag)
233 process.looper.applyDbAlignment =
True 234 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cfi")
236 process.load(
"Alignment.MuonAlignmentAlgorithms.MuonAlignmentPreFilter_cfi")
237 process.MuonAlignmentPreFilter.minTrackPt = minTrackPt
238 process.MuonAlignmentPreFilter.minTrackP = minTrackP
239 process.MuonAlignmentPreFilter.minTrackerHits = minTrackerHits
240 process.MuonAlignmentPreFilter.allowTIDTEC = allowTIDTEC
243 process.MuonAlignmentPreFilter.tracksTag = cms.InputTag(
"ALCARECOMuAlGlobalCosmics:GlobalMuon")
244 if preFilter: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentPreFilter * process.MuonAlignmentFromReferenceGlobalCosmicRefit)
245 else: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentFromReferenceGlobalCosmicRefit)
246 process.looper.tjTkAssociationMapTag = cms.InputTag(
"MuonAlignmentFromReferenceGlobalCosmicRefit:Refitted")
249 process.MuonAlignmentPreFilter.tracksTag = cms.InputTag(
"globalMuons")
250 process.MuonAlignmentFromReferenceGlobalMuonRefit.Tracks = cms.InputTag(
"globalMuons")
251 if preFilter: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentPreFilter * process.MuonAlignmentFromReferenceGlobalMuonRefit)
252 else: process.Path = cms.Path(process.offlineBeamSpot * process.MuonAlignmentFromReferenceGlobalMuonRefit)
253 process.looper.tjTkAssociationMapTag = cms.InputTag(
"MuonAlignmentFromReferenceGlobalMuonRefit:Refitted")
256 if len(muonCollectionTag) > 0:
257 process.Path = cms.Path(process.offlineBeamSpot * process.newmuons)
260 process.MuonAlignmentFromReferenceInputDB.connect = cms.string(
"sqlite_file:%s" % inputdb)
261 process.MuonAlignmentFromReferenceInputDB.toGet = cms.VPSet(cms.PSet(record = cms.string(
"DTAlignmentRcd"), tag = cms.string(
"DTAlignmentRcd")),
262 cms.PSet(record = cms.string(
"CSCAlignmentRcd"), tag = cms.string(
"CSCAlignmentRcd")))
264 if trackerconnect !=
"":
266 process.TrackerAlignmentInputDB = cms.ESSource(
"PoolDBESSource",
268 connect = cms.string(trackerconnect),
269 toGet = cms.VPSet(cms.PSet(record = cms.string(
"TrackerAlignmentRcd"), tag = cms.string(trackeralignment))))
270 process.es_prefer_TrackerAlignmentInputDB = cms.ESPrefer(
"PoolDBESSource",
"TrackerAlignmentInputDB")
272 if trackerAPEconnect !=
"":
274 process.TrackerAlignmentErrorInputDB = cms.ESSource(
"PoolDBESSource",
276 connect = cms.string(trackerAPEconnect),
277 toGet = cms.VPSet(cms.PSet(cms.PSet(record = cms.string(
"TrackerAlignmentErrorExtendedRcd"), tag = cms.string(trackerAPE)))))
278 process.es_prefer_TrackerAlignmentErrorInputDB = cms.ESPrefer(
"PoolDBESSource",
"TrackerAlignmentErrorInputDB")
280 if trackerBowsconnect !=
"":
282 process.TrackerSurfaceDeformationInputDB = cms.ESSource(
"PoolDBESSource",
284 connect = cms.string(trackerBowsconnect),
285 toGet = cms.VPSet(cms.PSet(cms.PSet(record = cms.string(
"TrackerSurfaceDeformationRcd"), tag = cms.string(trackerBows)))))
286 process.es_prefer_TrackerSurfaceDeformationInputDB = cms.ESPrefer(
"PoolDBESSource",
"TrackerSurfaceDeformationInputDB")
288 if gprcdconnect !=
"":
290 process.GlobalPositionInputDB = cms.ESSource(
"PoolDBESSource",
292 connect = cms.string(gprcdconnect),
293 toGet = cms.VPSet(cms.PSet(record = cms.string(
"GlobalPositionRcd"), tag = cms.string(gprcd))))
294 process.es_prefer_GlobalPositionInputDB = cms.ESPrefer(
"PoolDBESSource",
"GlobalPositionInputDB")
333 process.looper.saveToDB =
False 334 process.looper.saveApeToDB =
False 335 del process.PoolDBOutputService
337 process.TFileService = cms.Service(
"TFileService", fileName = cms.string(
"plotting%03d.root" % jobnumber))