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_condDBv2_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 .oO[offlineValidationFileOutput]Oo.
179 
180  ##
181  ## PATH
182  ##
183 process.p = cms.Path(
184 #process.triggerSelection*
185 process.offlineBeamSpot*process.HighPuritySelector*process.TrackRefitter1*process.TrackerTrackHitFilter*process.HitFilteredTracks
186 *process.AlignmentTrackSelector*process.TrackRefitter2*process.seqTrackerOfflineValidation.oO[offlineValidationMode]Oo.)
187 
188 """
189 
190 
191 ######################################################################
192 ######################################################################
193 mergeOfflineParJobsTemplate="""
194 #include ".oO[CMSSW_BASE]Oo./src/Alignment/OfflineValidation/scripts/merge_TrackerOfflineValidation.C"
195 
196 int TkAlOfflineJobsMerge(TString pars, TString outFile)
197 {
198 // load framework lite just to find the CMSSW libs...
199 gSystem->Load("libFWCoreFWLite");
200 AutoLibraryLoader::enable();
201 
202 return hadd(pars, outFile);
203 }
204 """
205 
206 
207 ######################################################################
208 ######################################################################
209 offlineFileOutputTemplate = """
210 process.TFileService.fileName = '.oO[outputFile]Oo.'
211 """
212 
213 ######################################################################
214 ######################################################################
215 offlineDqmFileOutputTemplate = """
216 process.TrackerOfflineValidationSummary.oO[offlineValidationMode]Oo..removeModuleLevelHists = .oO[offlineModuleLevelHistsTransient]Oo.
217 process.DqmSaverTkAl.workflow = '.oO[workflow]Oo.'
218 process.DqmSaverTkAl.dirName = '.oO[workdir]Oo./.'
219 process.DqmSaverTkAl.forceRunNumber = .oO[firstRunNumber]Oo.
220 """
221 #offlineDqmFileOutputTemplate = """
222 #process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..workflow = .oO[workflow]Oo.
223 #process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..dirName = .oO[workdir]Oo./.
224 #process.TrackerOfflineValidation.oO[offlineValidationMode]Oo..forceRunNumber = .oO[firstRunNumber]Oo.
225 #"""
226 
227 
228 ######################################################################
229 ######################################################################
230 LorentzAngleTemplate = "#use lorentz angle from global tag"
231 
232 
233 ######################################################################
234 ######################################################################
235 TrackSelectionTemplate = """
236 #####default for MC tracks with now further corrections etc.
237 
238 process.AlignmentTrackSelector.applyBasicCuts = True
239 # Note that pMin is overridden and set to zero in
240 # the offlineTemplate0T
241 process.AlignmentTrackSelector.pMin = 3
242 process.AlignmentTrackSelector.pMax = 9999.
243 process.AlignmentTrackSelector.ptMin = 0.65
244 process.AlignmentTrackSelector.ptMax = 9999.
245 process.AlignmentTrackSelector.etaMin = -999.
246 process.AlignmentTrackSelector.etaMax = 999.
247 process.AlignmentTrackSelector.nHitMin = 8
248 process.AlignmentTrackSelector.nHitMin2D = 2
249 process.AlignmentTrackSelector.chi2nMax = 999.
250 process.AlignmentTrackSelector.applyMultiplicityFilter = False
251 process.AlignmentTrackSelector.maxMultiplicity = 1
252 process.AlignmentTrackSelector.applyNHighestPt = False
253 process.AlignmentTrackSelector.nHighestPt = 1
254 process.AlignmentTrackSelector.seedOnlyFrom = 0
255 process.AlignmentTrackSelector.applyIsolationCut = False
256 process.AlignmentTrackSelector.minHitIsolation = 0.8
257 process.AlignmentTrackSelector.applyChargeCheck = False
258 process.AlignmentTrackSelector.minHitChargeStrip = 50.
259 #process.AlignmentTrackSelector.trackQualities = ["highPurity"]
260 #process.AlignmentTrackSelector.iterativeTrackingSteps = ["iter1","iter2"]
261 
262 ##### For Hits:
263 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
264 process.TrackerTrackHitFilter.minimumHits = 8
265 process.TrackerTrackHitFilter.commands = cms.vstring("keep PXB","keep PXE","keep TIB","keep TID","keep TOB","keep TEC")
266 process.TrackerTrackHitFilter.detsToIgnore = []
267 process.TrackerTrackHitFilter.replaceWithInactiveHits = True
268 process.TrackerTrackHitFilter.stripAllInvalidHits = False
269 process.TrackerTrackHitFilter.rejectBadStoNHits = True
270 process.TrackerTrackHitFilter.StoNcommands = cms.vstring("ALL 12.0")
271 process.TrackerTrackHitFilter.rejectLowAngleHits= True
272 process.TrackerTrackHitFilter.TrackAngleCut= 0.17 # in rads, starting from the module surface
273 process.TrackerTrackHitFilter.usePixelQualityFlag= True
274 
275 ##############
276 ##Trigger sequence
277 #############
278 #for MC only trigger bit 40 is simulated
279 #no triger on bunch crossing bit 0
280 
281 
282 # process.triggerSelection=cms.Sequence(process.bit40)
283 
284 """
285