4 import FWCore.ParameterSet.Config as cms
6 process = cms.Process("OfflineValidator")
8 # process.load("Alignment.OfflineValidation..oO[dataset]Oo._cff")
9 .oO[datasetDefinition]Oo.
11 process.options = cms.untracked.PSet(
12 wantSummary = cms.untracked.bool(False),
13 Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal
14 fileMode = cms.untracked.string('NOMERGE') # no ordering needed, but calls endRun/beginRun etc. at file boundaries
18 # ## Maximum number of Events
20 # process.maxEvents = cms.untracked.PSet(
21 # input = cms.untracked.int32(.oO[nEvents]Oo.)
25 ## Messages & Convenience
27 process.load("FWCore.MessageLogger.MessageLogger_cfi")
28 process.MessageLogger.cerr = cms.untracked.PSet(placeholder = cms.untracked.bool(True))
29 process.MessageLogger.cout = cms.untracked.PSet(INFO = cms.untracked.PSet(
30 reportEvery = cms.untracked.int32(1000) # every 1000th only
31 # limit = cms.untracked.int32(10) # or limit to 10 printouts...
33 process.MessageLogger.statistics.append('cout')
35 #############################################################
36 ##select trigger bits 40 OR 41
37 ##AND NOT (36 OR 37 OR 38 OR 39)
38 ##trigger bit 0 is selecting crossing bunches (not in MC)
39 ##########################################################
40 process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskTechTrigConfig_cff')
41 process.load('HLTrigger/HLTfilters/hltLevel1GTSeed_cfi')
44 process.bptxAnd = process.hltLevel1GTSeed.clone(L1TechTriggerSeeding = cms.bool(True), L1SeedsLogicalExpression = cms.string('0'))
46 #process.bit40 = process.hltLevel1GTSeed.clone(L1TechTriggerSeeding = cms.bool(True), L1SeedsLogicalExpression = cms.string('(40 OR 41) AND NOT (36 OR 37 OR 38 OR 39) AND NOT ((42 AND NOT 43) OR (43 AND NOT 42))'))
49 process.load('HLTrigger.special.hltPhysicsDeclared_cfi')
50 process.hltPhysicsDeclared.L1GtReadoutRecordTag = 'gtDigis'
53 #############################################################
54 ##select only high purity tracks
55 ##has to run first as necessary information
56 ##is only available in initial track selection
57 ##(Quality information is thrown away by the tracker refitters)
58 ##########################################################
59 import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
60 process.HighPuritySelector = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone(
61 applyBasicCuts = True,
63 src = '.oO[TrackCollection]Oo.',
64 trackQualities = ["highPurity"]
67 ###############################################################
68 ## Quality filters on the event (REAL DATA - FIRST COLLISIONS DEC09 ONLY!)
69 ## see https://twiki.cern.ch/twiki/bin/viewauth/CMS/TRKPromptFeedBack#Event_and_track_selection_recipe
70 ##NOT in PATH yet, to be commented in, if necessay
72 #########################################################
73 ############################################################################
74 ##Produce Primary Vertex Collection needed for later analysis
75 ############################################################################
76 #process.load('TrackingTools/TransientTrack/TransientTrackBuilder_cfi')
77 #process.load("RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi")
78 #process.offlinePrimaryVertices.TrackLabel = 'ALCARECOTkAlMinBias'
80 process.oneGoodVertexFilter = cms.EDFilter("VertexSelector",
81 src = cms.InputTag("offlinePrimaryVertices"),
82 cut = cms.string("!isFake && ndof > 4 && abs(z) <= 15 && position.Rho <= 2"), # tracksSize() > 3 for the older cut
83 filter = cms.bool(True), # otherwise it won't filter the events, just produce an empty vertex collection.
88 process.FilterGoodEvents=cms.Sequence(#process.HighPuritySelector*
89 process.oneGoodVertexFilter)
92 process.noScraping= cms.EDFilter("FilterOutScraping",
93 src=cms.InputTag("ALCARECOTkAlMinBias"),
94 applyfilter = cms.untracked.bool(True),
95 debugOn = cms.untracked.bool(False), ## Or 'True' to get some per-event info
96 numtrack = cms.untracked.uint32(10),
97 thresh = cms.untracked.double(0.25)
99 ####################################
106 # TrackerTrackHitFilter takes as input the tracks/trajectories coming out from TrackRefitter1
107 process.load("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff")
108 process.TrackerTrackHitFilter.src = 'TrackRefitter1'
110 #-- Alignment Track Selection
111 process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi")
112 process.AlignmentTrackSelector.src = 'HitFilteredTracks'
113 process.AlignmentTrackSelector.filter = True
115 .oO[TrackSelectionTemplate]Oo.
117 #now we give the TrackCandidate coming out of the TrackerTrackHitFilter to the track producer
118 import RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff
119 process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff.ctfWithMaterialTracks.clone(
120 src = 'TrackerTrackHitFilter',
121 NavigationSchool = "",
123 ### TrajectoryInEvent = True,
124 TTRHBuilder = "WithAngleAndTemplate"
128 ## Load and Configure TrackRefitter1
131 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
134 # parameters for TrackRefitter
135 #process.load("RecoTracker.TrackProducer.RefitterWithMaterial_cff")
136 import RecoTracker.TrackProducer.TrackRefitters_cff
137 process.TrackRefitter1 = process.TrackRefitter.clone(
138 src = 'HighPuritySelector',
139 TrajectoryInEvent = True,
140 TTRHBuilder = "WithAngleAndTemplate",
141 NavigationSchool = ""
143 process.TrackRefitter2 = process.TrackRefitter1.clone(
144 # src = 'HitFilteredTracks')
145 src = 'AlignmentTrackSelector'
152 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
155 ## GlobalTag Conditions (if needed)
157 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
158 process.GlobalTag.globaltag = ".oO[GlobalTag]Oo."
161 .oO[LorentzAngleTemplate]Oo.
166 process.load("Configuration.Geometry.GeometryDB_cff")
172 process.load("Configuration/StandardSequences/MagneticField_38T_cff")
176 ## to apply misalignments
177 #TrackerDigiGeometryESModule.applyAlignment = True
180 ## Load and Configure OfflineValidation and Output File
182 process.load("Alignment.OfflineValidation.TrackerOfflineValidation_.oO[offlineValidationMode]Oo._cff")
183 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2'
184 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2'
185 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = .oO[offlineModuleLevelHistsTransient]Oo.
186 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = .oO[offlineModuleLevelProfiles]Oo.
187 .oO[offlineValidationFileOutput]Oo.
192 process.p = cms.Path(
193 #process.triggerSelection*
194 process.offlineBeamSpot*process.HighPuritySelector*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks
195 *process.AlignmentTrackSelector*process.TrackRefitter2*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.)
202 offlineParallelTemplate =
"""
203 import FWCore.ParameterSet.Config as cms
205 process = cms.Process("OfflineValidator")
207 process.load("Alignment.OfflineValidation..oO[dataset]Oo._cff")
209 process.options = cms.untracked.PSet(
210 wantSummary = cms.untracked.bool(False),
211 Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal
212 fileMode = cms.untracked.string('NOMERGE') # no ordering needed, but calls endRun/beginRun etc. at file boundaries
216 ## Maximum number of Events
217 ## and number of events to be skipped
218 ## in case of parallel job nIndex
219 ## .oO[nIndex]Oo * .oO[nEvents]Oo/.oO[nJobs]Oo
221 process.maxEvents = cms.untracked.PSet(
222 input = cms.untracked.int32(.oO[nEvents]Oo./.oO[nJobs]Oo.)
224 process.source.skipEvents=cms.untracked.uint32(.oO[nIndex]Oo.*.oO[nEvents]Oo./.oO[nJobs]Oo.)
227 ## Messages & Convenience
229 process.load("FWCore.MessageLogger.MessageLogger_cfi")
230 process.MessageLogger.cerr = cms.untracked.PSet(placeholder = cms.untracked.bool(True))
231 process.MessageLogger.cout = cms.untracked.PSet(INFO = cms.untracked.PSet(
232 reportEvery = cms.untracked.int32(1000) # every 1000th only
233 # limit = cms.untracked.int32(10) # or limit to 10 printouts...
235 process.MessageLogger.statistics.append('cout')
237 #############################################################
238 ##select trigger bits 40 OR 41
239 ##AND NOT (36 OR 37 OR 38 OR 39)
240 ##trigger bit 0 is selecting crossing bunches (not in MC)
241 ##########################################################
242 process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskTechTrigConfig_cff')
243 process.load('HLTrigger/HLTfilters/hltLevel1GTSeed_cfi')
245 #Good Bunch Crossings
246 process.bptxAnd = process.hltLevel1GTSeed.clone(L1TechTriggerSeeding = cms.bool(True), L1SeedsLogicalExpression = cms.string('0'))
248 #process.bit40 = process.hltLevel1GTSeed.clone(L1TechTriggerSeeding = cms.bool(True), L1SeedsLogicalExpression = cms.string('(40 OR 41) AND NOT (36 OR 37 OR 38 OR 39) AND NOT ((42 AND NOT 43) OR (43 AND NOT 42))'))
251 process.load('HLTrigger.special.hltPhysicsDeclared_cfi')
252 process.hltPhysicsDeclared.L1GtReadoutRecordTag = 'gtDigis'
255 #############################################################
256 ##select only high purity tracks
257 ##has to run first as necessary information
258 ##is only available in initial track selection
259 ##(Quality information is thrown away by the tracker refitters)
260 ##########################################################
261 import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
262 process.HighPuritySelector = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone(
263 applyBasicCuts = True,
265 src = '.oO[TrackCollection]Oo.',
266 trackQualities = ["highPurity"]
269 ###############################################################
270 ## Quality filters on the event (REAL DATA - FIRST COLLISIONS DEC09 ONLY!)
271 ## see https://twiki.cern.ch/twiki/bin/viewauth/CMS/TRKPromptFeedBack#Event_and_track_selection_recipe
272 ##NOT in PATH yet, to be commented in, if necessay
274 #########################################################
275 ############################################################################
276 ##Produce Primary Vertex Collection needed for later analysis
277 ############################################################################
278 #process.load('TrackingTools/TransientTrack/TransientTrackBuilder_cfi')
279 #process.load("RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi")
280 #process.offlinePrimaryVertices.TrackLabel = 'ALCARECOTkAlMinBias'
282 process.oneGoodVertexFilter = cms.EDFilter("VertexSelector",
283 src = cms.InputTag("offlinePrimaryVertices"),
284 cut = cms.string("!isFake && ndof > 4 && abs(z) <= 15 && position.Rho <= 2"), # tracksSize() > 3 for the older cut
285 filter = cms.bool(True), # otherwise it won't filter the events, just produce an empty vertex collection.
290 process.FilterGoodEvents=cms.Sequence(#process.HighPuritySelector*
291 process.oneGoodVertexFilter)
294 process.noScraping= cms.EDFilter("FilterOutScraping",
295 src=cms.InputTag("ALCARECOTkAlMinBias"),
296 applyfilter = cms.untracked.bool(True),
297 debugOn = cms.untracked.bool(False), ## Or 'True' to get some per-event info
298 numtrack = cms.untracked.uint32(10),
299 thresh = cms.untracked.double(0.25)
301 ####################################
308 # TrackerTrackHitFilter takes as input the tracks/trajectories coming out from TrackRefitter1
309 process.load("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff")
310 process.TrackerTrackHitFilter.src = 'TrackRefitter1'
312 #-- Alignment Track Selection
313 process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi")
314 process.AlignmentTrackSelector.src = 'HitFilteredTracks'
315 process.AlignmentTrackSelector.filter = True
317 .oO[TrackSelectionTemplate]Oo.
319 #now we give the TrackCandidate coming out of the TrackerTrackHitFilter to the track producer
320 import RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff
321 process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff.ctfWithMaterialTracks.clone(
322 src = 'TrackerTrackHitFilter',
323 NavigationSchool = "",
325 ### TrajectoryInEvent = True,
326 TTRHBuilder = "WithAngleAndTemplate"
330 ## Load and Configure TrackRefitter1
333 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
336 # parameters for TrackRefitter
337 #process.load("RecoTracker.TrackProducer.RefitterWithMaterial_cff")
338 import RecoTracker.TrackProducer.TrackRefitters_cff
339 process.TrackRefitter1 = process.TrackRefitter.clone(
340 src = 'HighPuritySelector',
341 TrajectoryInEvent = True,
342 TTRHBuilder = "WithAngleAndTemplate",
343 NavigationSchool = ""
345 process.TrackRefitter2 = process.TrackRefitter1.clone(
346 # src = 'HitFilteredTracks')
347 src = 'AlignmentTrackSelector'
354 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
357 ## GlobalTag Conditions (if needed)
359 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
360 process.GlobalTag.globaltag = ".oO[GlobalTag]Oo."
363 .oO[LorentzAngleTemplate]Oo.
368 process.load("Configuration.Geometry.GeometryDB_cff")
373 process.load("Configuration/StandardSequences/MagneticField_38T_cff")
377 ## to apply misalignments
378 #TrackerDigiGeometryESModule.applyAlignment = True
381 ## Load and Configure OfflineValidation and Output File
383 process.load("Alignment.OfflineValidation.TrackerOfflineValidation_.oO[offlineValidationMode]Oo._cff")
384 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2'
385 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2'
386 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = .oO[offlineModuleLevelHistsTransient]Oo.
387 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = .oO[offlineModuleLevelProfiles]Oo.
388 .oO[offlineValidationFileOutput]Oo.
393 process.p = cms.Path(
394 #process.triggerSelection*
395 process.offlineBeamSpot*process.HighPuritySelector*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks
396 *process.AlignmentTrackSelector*process.TrackRefitter2*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.)
403 mergeOfflineParallelResults=
"""
405 # Merging works also if there is only one file to merge
406 # if merged file already exists it will be moved to a backup file (~)
408 # run TkAlOfflinejobs.C
409 echo -e "\n\nMerging results from parallel jobs with TkAlOfflineJobsMerge.C"
410 #set directory to which TkAlOfflineJobsMerge.C saves the merged file
411 # export OUTPUTDIR=.oO[datadir]Oo.
413 cp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/merge_TrackerOfflineValidation.C .
417 # ls -al .oO[datadir]Oo./AlignmentValidation*.root > .oO[datadir]Oo./log_rootfilelist.txt
418 ls -al AlignmentValidation*.root > .oO[datadir]Oo./log_rootfilelist.txt
420 # Remove parallel job files
427 mergeOfflineParJobsTemplate=
"""
428 int TkAlOfflineJobsMerge(TString pars, TString outFile)
430 // load framework lite just to find the CMSSW libs...
431 gSystem->Load("libFWCoreFWLite");
432 AutoLibraryLoader::enable();
434 gROOT->ProcessLine(".L merge_TrackerOfflineValidation.C++");
436 return hadd(pars, outFile);
443 offlineStandaloneFileOutputTemplate =
"""
444 process.TFileService.fileName = '.oO[outputFile]Oo.'
449 offlineParallelFileOutputTemplate =
"""
450 process.TFileService.fileName = '.oO[outputFile]Oo.'
455 offlineDqmFileOutputTemplate =
"""
456 process.TrackerOfflineValidationSummary.oO[offlineValidationMode]Oo..removeModuleLevelHists = .oO[offlineModuleLevelHistsTransient]Oo.
457 process.DqmSaverTkAl.workflow = '.oO[workflow]Oo.'
458 process.DqmSaverTkAl.dirName = '.oO[workdir]Oo./.'
459 process.DqmSaverTkAl.forceRunNumber = .oO[firstRunNumber]Oo.
470 LorentzAngleTemplate =
"#use lorentz angle from global tag"
475 TrackSelectionTemplate =
"""
476 #####default for MC tracks with now further corrections etc.
478 process.AlignmentTrackSelector.applyBasicCuts = True
479 # Note that pMin is overridden and set to zero in
480 # the offlineTemplate0T
481 process.AlignmentTrackSelector.pMin = 3
482 process.AlignmentTrackSelector.pMax = 9999.
483 process.AlignmentTrackSelector.ptMin = 0.65
484 process.AlignmentTrackSelector.ptMax = 9999.
485 process.AlignmentTrackSelector.etaMin = -999.
486 process.AlignmentTrackSelector.etaMax = 999.
487 process.AlignmentTrackSelector.nHitMin = 8
488 process.AlignmentTrackSelector.nHitMin2D = 2
489 process.AlignmentTrackSelector.chi2nMax = 999.
490 process.AlignmentTrackSelector.applyMultiplicityFilter = False
491 process.AlignmentTrackSelector.maxMultiplicity = 1
492 process.AlignmentTrackSelector.applyNHighestPt = False
493 process.AlignmentTrackSelector.nHighestPt = 1
494 process.AlignmentTrackSelector.seedOnlyFrom = 0
495 process.AlignmentTrackSelector.applyIsolationCut = False
496 process.AlignmentTrackSelector.minHitIsolation = 0.8
497 process.AlignmentTrackSelector.applyChargeCheck = False
498 process.AlignmentTrackSelector.minHitChargeStrip = 50.
499 #process.AlignmentTrackSelector.trackQualities = ["highPurity"]
500 #process.AlignmentTrackSelector.iterativeTrackingSteps = ["iter1","iter2"]
503 process.TrackerTrackHitFilter.useTrajectories= True # this is needed only if you require some selections; but it will work even if you don't ask for them
504 process.TrackerTrackHitFilter.minimumHits = 8
505 process.TrackerTrackHitFilter.commands = cms.vstring("keep PXB","keep PXE","keep TIB","keep TID","keep TOB","keep TEC")
506 process.TrackerTrackHitFilter.detsToIgnore = [
507 # see https://hypernews.cern.ch/HyperNews/CMS/get/tracker-performance/484.html
509 #369136710, 369136714, 402668822,
511 #436310989, 436310990, 436299301, 436299302,
513 #470340521, 470063045, 470063046, 470114669, 470114670, 470161093, 470161094, 470164333, 470164334, 470312005, 470312006, 470312009, 470067405, 470067406, 470128813
515 process.TrackerTrackHitFilter.replaceWithInactiveHits = True
516 process.TrackerTrackHitFilter.stripAllInvalidHits = False
517 process.TrackerTrackHitFilter.rejectBadStoNHits = True
518 process.TrackerTrackHitFilter.StoNcommands = cms.vstring("ALL 12.0")
519 process.TrackerTrackHitFilter.rejectLowAngleHits= True
520 process.TrackerTrackHitFilter.TrackAngleCut= 0.17 # in rads, starting from the module surface
521 process.TrackerTrackHitFilter.usePixelQualityFlag= True
526 #for MC only trigger bit 40 is simulated
527 #no triger on bunch crossing bit 0
530 # process.triggerSelection=cms.Sequence(process.bit40)