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.StandardSequences.Geometry_cff")
171 process.load("Configuration/StandardSequences/MagneticField_38T_cff")
175 ## to apply misalignments
176 #TrackerDigiGeometryESModule.applyAlignment = True
179 ## Load and Configure OfflineValidation and Output File
181 process.load("Alignment.OfflineValidation.TrackerOfflineValidation_.oO[offlineValidationMode]Oo._cff")
182 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2'
183 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2'
184 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = .oO[offlineModuleLevelHistsTransient]Oo.
185 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = .oO[offlineModuleLevelProfiles]Oo.
186 .oO[offlineValidationFileOutput]Oo.
191 process.p = cms.Path(
192 #process.triggerSelection*
193 process.offlineBeamSpot*process.HighPuritySelector*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks
194 *process.AlignmentTrackSelector*process.TrackRefitter2*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.)
201 offlineParallelTemplate =
"""
202 import FWCore.ParameterSet.Config as cms
204 process = cms.Process("OfflineValidator")
206 process.load("Alignment.OfflineValidation..oO[dataset]Oo._cff")
208 process.options = cms.untracked.PSet(
209 wantSummary = cms.untracked.bool(False),
210 Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal
211 fileMode = cms.untracked.string('NOMERGE') # no ordering needed, but calls endRun/beginRun etc. at file boundaries
215 ## Maximum number of Events
216 ## and number of events to be skipped
217 ## in case of parallel job nIndex
218 ## .oO[nIndex]Oo * .oO[nEvents]Oo/.oO[nJobs]Oo
220 process.maxEvents = cms.untracked.PSet(
221 input = cms.untracked.int32(.oO[nEvents]Oo./.oO[nJobs]Oo.)
223 process.source.skipEvents=cms.untracked.uint32(.oO[nIndex]Oo.*.oO[nEvents]Oo./.oO[nJobs]Oo.)
226 ## Messages & Convenience
228 process.load("FWCore.MessageLogger.MessageLogger_cfi")
229 process.MessageLogger.cerr = cms.untracked.PSet(placeholder = cms.untracked.bool(True))
230 process.MessageLogger.cout = cms.untracked.PSet(INFO = cms.untracked.PSet(
231 reportEvery = cms.untracked.int32(1000) # every 1000th only
232 # limit = cms.untracked.int32(10) # or limit to 10 printouts...
234 process.MessageLogger.statistics.append('cout')
236 #############################################################
237 ##select trigger bits 40 OR 41
238 ##AND NOT (36 OR 37 OR 38 OR 39)
239 ##trigger bit 0 is selecting crossing bunches (not in MC)
240 ##########################################################
241 process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskTechTrigConfig_cff')
242 process.load('HLTrigger/HLTfilters/hltLevel1GTSeed_cfi')
244 #Good Bunch Crossings
245 process.bptxAnd = process.hltLevel1GTSeed.clone(L1TechTriggerSeeding = cms.bool(True), L1SeedsLogicalExpression = cms.string('0'))
247 #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))'))
250 process.load('HLTrigger.special.hltPhysicsDeclared_cfi')
251 process.hltPhysicsDeclared.L1GtReadoutRecordTag = 'gtDigis'
254 #############################################################
255 ##select only high purity tracks
256 ##has to run first as necessary information
257 ##is only available in initial track selection
258 ##(Quality information is thrown away by the tracker refitters)
259 ##########################################################
260 import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
261 process.HighPuritySelector = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone(
262 applyBasicCuts = True,
264 src = '.oO[TrackCollection]Oo.',
265 trackQualities = ["highPurity"]
268 ###############################################################
269 ## Quality filters on the event (REAL DATA - FIRST COLLISIONS DEC09 ONLY!)
270 ## see https://twiki.cern.ch/twiki/bin/viewauth/CMS/TRKPromptFeedBack#Event_and_track_selection_recipe
271 ##NOT in PATH yet, to be commented in, if necessay
273 #########################################################
274 ############################################################################
275 ##Produce Primary Vertex Collection needed for later analysis
276 ############################################################################
277 #process.load('TrackingTools/TransientTrack/TransientTrackBuilder_cfi')
278 #process.load("RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi")
279 #process.offlinePrimaryVertices.TrackLabel = 'ALCARECOTkAlMinBias'
281 process.oneGoodVertexFilter = cms.EDFilter("VertexSelector",
282 src = cms.InputTag("offlinePrimaryVertices"),
283 cut = cms.string("!isFake && ndof > 4 && abs(z) <= 15 && position.Rho <= 2"), # tracksSize() > 3 for the older cut
284 filter = cms.bool(True), # otherwise it won't filter the events, just produce an empty vertex collection.
289 process.FilterGoodEvents=cms.Sequence(#process.HighPuritySelector*
290 process.oneGoodVertexFilter)
293 process.noScraping= cms.EDFilter("FilterOutScraping",
294 src=cms.InputTag("ALCARECOTkAlMinBias"),
295 applyfilter = cms.untracked.bool(True),
296 debugOn = cms.untracked.bool(False), ## Or 'True' to get some per-event info
297 numtrack = cms.untracked.uint32(10),
298 thresh = cms.untracked.double(0.25)
300 ####################################
307 # TrackerTrackHitFilter takes as input the tracks/trajectories coming out from TrackRefitter1
308 process.load("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff")
309 process.TrackerTrackHitFilter.src = 'TrackRefitter1'
311 #-- Alignment Track Selection
312 process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi")
313 process.AlignmentTrackSelector.src = 'HitFilteredTracks'
314 process.AlignmentTrackSelector.filter = True
316 .oO[TrackSelectionTemplate]Oo.
318 #now we give the TrackCandidate coming out of the TrackerTrackHitFilter to the track producer
319 import RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff
320 process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff.ctfWithMaterialTracks.clone(
321 src = 'TrackerTrackHitFilter',
322 NavigationSchool = "",
324 ### TrajectoryInEvent = True,
325 TTRHBuilder = "WithAngleAndTemplate"
329 ## Load and Configure TrackRefitter1
332 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
335 # parameters for TrackRefitter
336 #process.load("RecoTracker.TrackProducer.RefitterWithMaterial_cff")
337 import RecoTracker.TrackProducer.TrackRefitters_cff
338 process.TrackRefitter1 = process.TrackRefitter.clone(
339 src = 'HighPuritySelector',
340 TrajectoryInEvent = True,
341 TTRHBuilder = "WithAngleAndTemplate",
342 NavigationSchool = ""
344 process.TrackRefitter2 = process.TrackRefitter1.clone(
345 # src = 'HitFilteredTracks')
346 src = 'AlignmentTrackSelector'
353 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
356 ## GlobalTag Conditions (if needed)
358 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
359 process.GlobalTag.globaltag = ".oO[GlobalTag]Oo."
362 .oO[LorentzAngleTemplate]Oo.
367 process.load("Configuration.StandardSequences.Geometry_cff")
372 process.load("Configuration/StandardSequences/MagneticField_38T_cff")
376 ## to apply misalignments
377 #TrackerDigiGeometryESModule.applyAlignment = True
380 ## Load and Configure OfflineValidation and Output File
382 process.load("Alignment.OfflineValidation.TrackerOfflineValidation_.oO[offlineValidationMode]Oo._cff")
383 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2'
384 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2'
385 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = .oO[offlineModuleLevelHistsTransient]Oo.
386 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = .oO[offlineModuleLevelProfiles]Oo.
387 .oO[offlineValidationFileOutput]Oo.
392 process.p = cms.Path(
393 #process.triggerSelection*
394 process.offlineBeamSpot*process.HighPuritySelector*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks
395 *process.AlignmentTrackSelector*process.TrackRefitter2*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.)
402 mergeOfflineParallelResults=
"""
404 # Merging works also if there is only one file to merge
405 # if merged file already exists it will be moved to a backup file (~)
407 # run TkAlOfflinejobs.C
408 echo "Merging results from parallel jobs with TkAlOfflineJobsMerge.C"
409 #set directory to which TkAlOfflineJobsMerge.C saves the merged file
410 # export OUTPUTDIR=.oO[datadir]Oo.
412 cp .oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/merge_TrackerOfflineValidation.C .
416 # ls -al .oO[datadir]Oo./AlignmentValidation*.root > .oO[datadir]Oo./log_rootfilelist.txt
417 ls -al AlignmentValidation*.root > .oO[datadir]Oo./log_rootfilelist.txt
419 # Remove parallel job files if merged file exists
420 for file in $(cmsLs -l /store/caf/user/$USER/.oO[eosdir]Oo. |awk '{print $5}')
422 if [[ ${file} = /store/caf/user/$USER/.oO[eosdir]Oo./AlignmentValidation*_[0-9].root ]]
433 mergeOfflineParJobsTemplate=
"""
434 void TkAlOfflineJobsMerge(TString pars, TString outFile)
436 // load framework lite just to find the CMSSW libs...
437 gSystem->Load("libFWCoreFWLite");
438 AutoLibraryLoader::enable();
440 gROOT->ProcessLine(".L merge_TrackerOfflineValidation.C++");
449 offlineStandaloneFileOutputTemplate =
"""
450 process.TFileService.fileName = '.oO[outputFile]Oo.'
455 offlineParallelFileOutputTemplate =
"""
456 process.TFileService.fileName = '.oO[outputFile]Oo.'
461 offlineDqmFileOutputTemplate =
"""
462 process.TrackerOfflineValidationSummary.oO[offlineValidationMode]Oo..removeModuleLevelHists = .oO[offlineModuleLevelHistsTransient]Oo.
463 process.DqmSaverTkAl.workflow = '.oO[workflow]Oo.'
464 process.DqmSaverTkAl.dirName = '.oO[workdir]Oo./.'
465 process.DqmSaverTkAl.forceRunNumber = .oO[firstRunNumber]Oo.
476 LorentzAngleTemplate =
"#use lorentz angle from global tag"
481 TrackSelectionTemplate =
"""
482 #####default for MC tracks with now further corrections etc.
484 process.AlignmentTrackSelector.applyBasicCuts = True
485 # Note that pMin is overridden and set to zero in
486 # the offlineTemplate0T
487 process.AlignmentTrackSelector.pMin = 3
488 process.AlignmentTrackSelector.pMax = 9999.
489 process.AlignmentTrackSelector.ptMin = 0.65
490 process.AlignmentTrackSelector.ptMax = 9999.
491 process.AlignmentTrackSelector.etaMin = -999.
492 process.AlignmentTrackSelector.etaMax = 999.
493 process.AlignmentTrackSelector.nHitMin = 8
494 process.AlignmentTrackSelector.nHitMin2D = 2
495 process.AlignmentTrackSelector.chi2nMax = 999.
496 process.AlignmentTrackSelector.applyMultiplicityFilter = False
497 process.AlignmentTrackSelector.maxMultiplicity = 1
498 process.AlignmentTrackSelector.applyNHighestPt = False
499 process.AlignmentTrackSelector.nHighestPt = 1
500 process.AlignmentTrackSelector.seedOnlyFrom = 0
501 process.AlignmentTrackSelector.applyIsolationCut = False
502 process.AlignmentTrackSelector.minHitIsolation = 0.8
503 process.AlignmentTrackSelector.applyChargeCheck = False
504 process.AlignmentTrackSelector.minHitChargeStrip = 50.
505 #process.AlignmentTrackSelector.trackQualities = ["highPurity"]
506 #process.AlignmentTrackSelector.iterativeTrackingSteps = ["iter1","iter2"]
509 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
510 process.TrackerTrackHitFilter.minimumHits = 8
511 process.TrackerTrackHitFilter.commands = cms.vstring("keep PXB","keep PXE","keep TIB","keep TID","keep TOB","keep TEC")
512 process.TrackerTrackHitFilter.detsToIgnore = [
513 # see https://hypernews.cern.ch/HyperNews/CMS/get/tracker-performance/484.html
515 #369136710, 369136714, 402668822,
517 #436310989, 436310990, 436299301, 436299302,
519 #470340521, 470063045, 470063046, 470114669, 470114670, 470161093, 470161094, 470164333, 470164334, 470312005, 470312006, 470312009, 470067405, 470067406, 470128813
521 process.TrackerTrackHitFilter.replaceWithInactiveHits = True
522 process.TrackerTrackHitFilter.stripAllInvalidHits = False
523 process.TrackerTrackHitFilter.rejectBadStoNHits = True
524 process.TrackerTrackHitFilter.StoNcommands = cms.vstring("ALL 12.0")
525 process.TrackerTrackHitFilter.rejectLowAngleHits= True
526 process.TrackerTrackHitFilter.TrackAngleCut= 0.17 # in rads, starting from the module surface
527 process.TrackerTrackHitFilter.usePixelQualityFlag= True
532 #for MC only trigger bit 40 is simulated
533 #no triger on bunch crossing bit 0
536 # process.triggerSelection=cms.Sequence(process.bit40)