CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
offlineValidationTemplates.py
Go to the documentation of this file.
1 ######################################################################
2 ######################################################################
3 offlineTemplate = """
4 import FWCore.ParameterSet.Config as cms
5 
6 process = cms.Process("OfflineValidator")
7 
8 .oO[datasetDefinition]Oo.
9 
10 process.options = cms.untracked.PSet(
11  wantSummary = cms.untracked.bool(False),
12  Rethrow = cms.untracked.vstring("ProductNotFound"), # make this exception fatal
13  fileMode = cms.untracked.string('NOMERGE') # no ordering needed, but calls endRun/beginRun etc. at file boundaries
14 )
15 
16  ##
17  ## Messages & Convenience
18  ##
19 process.load("FWCore.MessageLogger.MessageLogger_cfi")
20 process.MessageLogger.cerr = cms.untracked.PSet(placeholder = cms.untracked.bool(True))
21 process.MessageLogger.cout = cms.untracked.PSet(INFO = cms.untracked.PSet(
22 reportEvery = cms.untracked.int32(1000) # every 1000th only
23 # limit = cms.untracked.int32(10) # or limit to 10 printouts...
24 ))
25 process.MessageLogger.statistics.append('cout')
26 
27 #############################################################
28 ##select trigger bits 40 OR 41
29 ##AND NOT (36 OR 37 OR 38 OR 39)
30 ##trigger bit 0 is selecting crossing bunches (not in MC)
31 ##########################################################
32 process.load('L1TriggerConfig.L1GtConfigProducers.L1GtTriggerMaskTechTrigConfig_cff')
33 process.load('HLTrigger/HLTfilters/hltLevel1GTSeed_cfi')
34 
35 #Good Bunch Crossings
36 process.bptxAnd = process.hltLevel1GTSeed.clone(L1TechTriggerSeeding = cms.bool(True), L1SeedsLogicalExpression = cms.string('0'))
37 #BSCNOBEAMHALO
38 #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))'))
39 
40 #Physics declared
41 process.load('HLTrigger.special.hltPhysicsDeclared_cfi')
42 process.hltPhysicsDeclared.L1GtReadoutRecordTag = 'gtDigis'
43 
44 
45 #############################################################
46 ##select only high purity tracks
47 ##has to run first as necessary information
48 ##is only available in initial track selection
49 ##(Quality information is thrown away by the tracker refitters)
50 ##########################################################
51 import Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi
52 process.HighPuritySelector = Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi.AlignmentTrackSelector.clone(
53  applyBasicCuts = True,
54  filter = True,
55  src = '.oO[TrackCollection]Oo.',
56  trackQualities = ["highPurity"]
57  )
58 
59 ###############################################################
60 ## Quality filters on the event (REAL DATA - FIRST COLLISIONS DEC09 ONLY!)
61 ## see https://twiki.cern.ch/twiki/bin/viewauth/CMS/TRKPromptFeedBack#Event_and_track_selection_recipe
62 ##NOT in PATH yet, to be commented in, if necessay
63 ##
64 #########################################################
65 ############################################################################
66 ##Produce Primary Vertex Collection needed for later analysis
67 ############################################################################
68 #process.load('TrackingTools/TransientTrack/TransientTrackBuilder_cfi')
69 #process.load("RecoVertex.PrimaryVertexProducer.OfflinePrimaryVertices_cfi")
70 #process.offlinePrimaryVertices.TrackLabel = 'ALCARECOTkAlMinBias'
71 
72 process.oneGoodVertexFilter = cms.EDFilter("VertexSelector",
73  src = cms.InputTag("offlinePrimaryVertices"),
74  cut = cms.string("!isFake && ndof > 4 && abs(z) <= 15 && position.Rho <= 2"), # tracksSize() > 3 for the older cut
75  filter = cms.bool(True), # otherwise it won't filter the events, just produce an empty vertex collection.
76  )
77 
78 
79 
80 process.FilterGoodEvents=cms.Sequence(#process.HighPuritySelector*
81 process.oneGoodVertexFilter)
82 
83 
84 process.noScraping= cms.EDFilter("FilterOutScraping",
85  src=cms.InputTag("ALCARECOTkAlMinBias"),
86  applyfilter = cms.untracked.bool(True),
87  debugOn = cms.untracked.bool(False), ## Or 'True' to get some per-event info
88  numtrack = cms.untracked.uint32(10),
89  thresh = cms.untracked.double(0.25)
90  )
91 ####################################
92 
93 
94 
95 
96 
97 #-- Track hit filter
98 # TrackerTrackHitFilter takes as input the tracks/trajectories coming out from TrackRefitter1
99 process.load("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff")
100 process.TrackerTrackHitFilter.src = 'TrackRefitter1'
101 
102 #-- Alignment Track Selection
103 process.load("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi")
104 process.AlignmentTrackSelector.src = 'HitFilteredTracks'
105 process.AlignmentTrackSelector.filter = True
106 
107 .oO[TrackSelectionTemplate]Oo.
108 
109 #now we give the TrackCandidate coming out of the TrackerTrackHitFilter to the track producer
110 import RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff
111 process.HitFilteredTracks = RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff.ctfWithMaterialTracks.clone(
112  src = 'TrackerTrackHitFilter',
113  NavigationSchool = "",
114 
115 ### TrajectoryInEvent = True,
116  TTRHBuilder = "WithAngleAndTemplate"
117 )
118 
119  ##
120  ## Load and Configure TrackRefitter1
121  ##
122 
123 process.load("RecoTracker.TrackProducer.TrackRefitters_cff")
124 
125 #############
126 # parameters for TrackRefitter
127 #process.load("RecoTracker.TrackProducer.RefitterWithMaterial_cff")
128 import RecoTracker.TrackProducer.TrackRefitters_cff
129 process.TrackRefitter1 = process.TrackRefitter.clone(
130  src = 'HighPuritySelector',
131  TrajectoryInEvent = True,
132  TTRHBuilder = "WithAngleAndTemplate",
133  NavigationSchool = ""
134 )
135 process.TrackRefitter2 = process.TrackRefitter1.clone(
136 # src = 'HitFilteredTracks')
137  src = 'AlignmentTrackSelector'
138 )
139 
140 
141  ##
142  ## Get the BeamSpot
143  ##
144 process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
145 
146  ##
147  ## GlobalTag Conditions (if needed)
148  ##
149 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
150 process.GlobalTag.globaltag = ".oO[GlobalTag]Oo."
151 
152 
153 .oO[LorentzAngleTemplate]Oo.
154 
155  ##
156  ## Geometry
157  ##
158 process.load("Configuration.Geometry.GeometryDB_cff")
159 
160  ##
161  ## Magnetic Field
162  ##
163 process.load("Configuration/StandardSequences/.oO[magneticField]Oo._cff")
164 
165 .oO[condLoad]Oo.
166 
167 ## to apply misalignments
168 #TrackerDigiGeometryESModule.applyAlignment = True
169 
170  ##
171  ## Load and Configure OfflineValidation and Output File
172  ##
173 process.load("Alignment.OfflineValidation.TrackerOfflineValidation_.oO[offlineValidationMode]Oo._cff")
174 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..Tracks = 'TrackRefitter2'
175 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..trajectoryInput = 'TrackRefitter2'
176 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelHistsTransient = .oO[offlineModuleLevelHistsTransient]Oo.
177 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..moduleLevelProfiles = .oO[offlineModuleLevelProfiles]Oo.
178 process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..stripYResiduals = .oO[stripYResiduals]Oo.
179 .oO[offlineValidationFileOutput]Oo.
180 
181  ##
182  ## PATH
183  ##
184 process.p = cms.Path(
185 #process.triggerSelection*
186 process.offlineBeamSpot*process.HighPuritySelector*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks
187 *process.AlignmentTrackSelector*process.TrackRefitter2*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.)
188 
189 """
190 
191 
192 ######################################################################
193 ######################################################################
194 mergeOfflineParJobsTemplate="""
195 #include "Alignment/OfflineValidation/scripts/merge_TrackerOfflineValidation.C"
196 
197 int TkAlOfflineJobsMerge(TString pars, TString outFile)
198 {
199 // load framework lite just to find the CMSSW libs...
200 gSystem->Load("libFWCoreFWLite");
201 FWLiteEnabler::enable();
202 
203 return hadd(pars, outFile);
204 }
205 """
206 
207 
208 ######################################################################
209 ######################################################################
210 offlineFileOutputTemplate = """
211 process.TFileService.fileName = '.oO[outputFile]Oo.'
212 """
213 
214 ######################################################################
215 ######################################################################
216 offlineDqmFileOutputTemplate = """
217 process.TrackerOfflineValidationSummary.oO[offlineValidationMode]Oo..removeModuleLevelHists = .oO[offlineModuleLevelHistsTransient]Oo.
218 process.DqmSaverTkAl.workflow = '.oO[workflow]Oo.'
219 process.DqmSaverTkAl.dirName = '.oO[workdir]Oo./.'
220 process.DqmSaverTkAl.forceRunNumber = .oO[firstRunNumber]Oo.
221 """
222 #offlineDqmFileOutputTemplate = """
223 #process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..workflow = .oO[workflow]Oo.
224 #process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..dirName = .oO[workdir]Oo./.
225 #process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..forceRunNumber = .oO[firstRunNumber]Oo.
226 #"""
227 
228 
229 ######################################################################
230 ######################################################################
231 LorentzAngleTemplate = "#use lorentz angle from global tag"
232 
233 
234 ######################################################################
235 ######################################################################
236 TrackSelectionTemplate = """
237 #####default for MC tracks with now further corrections etc.
238 
239 process.AlignmentTrackSelector.applyBasicCuts = True
240 # Note that pMin is overridden and set to zero in
241 # the offlineTemplate0T
242 process.AlignmentTrackSelector.pMin = 3
243 process.AlignmentTrackSelector.pMax = 9999.
244 process.AlignmentTrackSelector.ptMin = 0.65
245 process.AlignmentTrackSelector.ptMax = 9999.
246 process.AlignmentTrackSelector.etaMin = -999.
247 process.AlignmentTrackSelector.etaMax = 999.
248 process.AlignmentTrackSelector.nHitMin = 8
249 process.AlignmentTrackSelector.nHitMin2D = 2
250 process.AlignmentTrackSelector.chi2nMax = 999.
251 process.AlignmentTrackSelector.applyMultiplicityFilter = False
252 process.AlignmentTrackSelector.maxMultiplicity = 1
253 process.AlignmentTrackSelector.applyNHighestPt = False
254 process.AlignmentTrackSelector.nHighestPt = 1
255 process.AlignmentTrackSelector.seedOnlyFrom = 0
256 process.AlignmentTrackSelector.applyIsolationCut = False
257 process.AlignmentTrackSelector.minHitIsolation = 0.8
258 process.AlignmentTrackSelector.applyChargeCheck = False
259 process.AlignmentTrackSelector.minHitChargeStrip = 50.
260 #process.AlignmentTrackSelector.trackQualities = ["highPurity"]
261 #process.AlignmentTrackSelector.iterativeTrackingSteps = ["iter1","iter2"]
262 
263 ##### For Hits:
264 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
265 process.TrackerTrackHitFilter.minimumHits = 8
266 process.TrackerTrackHitFilter.commands = cms.vstring("keep PXB","keep PXE","keep TIB","keep TID","keep TOB","keep TEC")
267 process.TrackerTrackHitFilter.detsToIgnore = []
268 process.TrackerTrackHitFilter.replaceWithInactiveHits = True
269 process.TrackerTrackHitFilter.stripAllInvalidHits = False
270 process.TrackerTrackHitFilter.rejectBadStoNHits = True
271 process.TrackerTrackHitFilter.StoNcommands = cms.vstring("ALL 12.0")
272 process.TrackerTrackHitFilter.rejectLowAngleHits= True
273 process.TrackerTrackHitFilter.TrackAngleCut= 0.17 # in rads, starting from the module surface
274 process.TrackerTrackHitFilter.usePixelQualityFlag= True
275 
276 ##############
277 ##Trigger sequence
278 #############
279 #for MC only trigger bit 40 is simulated
280 #no triger on bunch crossing bit 0
281 
282 
283 # process.triggerSelection=cms.Sequence(process.bit40)
284 
285 """
286