9 TTRHBuilder = "WithAngleAndTemplate",
10 usePixelQualityFlag = None,
11 openMassWindow = False,
12 cosmicsDecoMode = False,
13 cosmicsZeroTesla = True,
14 momentumConstraint = None,
15 cosmicTrackSplitting = False,
16 isPVValidation = False,
18 """This function returns a cms.Sequence containing as last element the
19 module 'FinalTrackRefitter', which can be used as cms.InputTag for
20 subsequent processing steps.
21 The modules in the sequence are already attached to the given `process`
22 object using the given track collection `collection` and the given
26 - `process`: 'cms.Process' object to which the modules of the sequence will
28 - `collection`: String indicating the input track collection.
29 - `saveCPU`: If set to 'True', some steps are merged to reduce CPU time.
30 Reduces a little the accuracy of the results.
31 This option is currently not recommended.
32 - `TTRHBuilder`: Option used for the Track(Re)Fitter modules.
33 - `usePixelQualityFlag`: Option used for the TrackHitFilter module.
34 Defaults to 'True' but is automatically set to
35 'False' if a `TTRHBuilder` without templates is
37 If this is still wanted for some reason, one can
38 explicitely specify it as 'True'.
39 - `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu.
40 - `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used.
41 - `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used.
42 - `momentumConstraint`: If you want to apply a momentum constraint for the
43 track refitting, e.g. for CRUZET data, you need
44 to provide here the name of the constraint module.
45 - `cosmicTrackSplitting`: If set to 'True' cosmic tracks are split before the
46 second track refitter.
47 - `isPVValidation`: If set to 'True' most of the selection cuts are overridden
48 to allow unbiased selection of tracks for vertex refitting
49 - `use_d0cut`: If 'True' (default), apply a cut |d0| < 50.
56 if usePixelQualityFlag
is None:
57 if "Template" not in TTRHBuilder:
58 usePixelQualityFlag =
False
59 print(
"Using 'TTRHBuilder' without templates:", TTRHBuilder)
60 print(
" --> Turning off pixel quality flag in hit filter.")
62 usePixelQualityFlag =
True
69 options = {
"TrackHitFilter": {},
74 options[
"TrackSelector"][
"HighPurity"] = {
75 "trackQualities": [
"highPurity"],
81 options[
"TrackSelector"][
"Alignment"] = {
92 options[
"TrackRefitter"][
"First"] = {
93 "NavigationSchool":
"",
94 "TTRHBuilder": TTRHBuilder,
96 options[
"TrackRefitter"][
"Second"] = {
97 "NavigationSchool":
"",
98 "TTRHBuilder": TTRHBuilder,
100 options[
"TrackHitFilter"][
"Tracker"] = {
101 "useTrajectories":
True,
103 "commands": cms.vstring(
"keep PXB",
"keep PXE",
"keep TIB",
"keep TID",
104 "keep TOB",
"keep TEC"),
105 "replaceWithInactiveHits":
True,
106 "rejectBadStoNHits":
True,
107 "rejectLowAngleHits":
True,
108 "usePixelQualityFlag": usePixelQualityFlag,
109 "StoNcommands": cms.vstring(
"ALL 12.0"),
110 "TrackAngleCut": 0.087,
112 options[
"TrackFitter"][
"HitFilteredTracks"] = {
113 "NavigationSchool":
"",
114 "TTRHBuilder": TTRHBuilder,
123 if collection
in (
"ALCARECOTkAlMinBias",
"generalTracks",
124 "ALCARECOTkAlMinBiasHI",
"hiGeneralTracks"):
125 options[
"TrackSelector"][
"Alignment"].
update({
129 options[
"TrackHitFilter"][
"Tracker"].
update({
132 elif collection
in (
"ALCARECOTkAlCosmicsCTF0T",
133 "ALCARECOTkAlCosmicsCosmicTF0T",
134 "ALCARECOTkAlCosmicsInCollisions"):
136 options[
"TrackSelector"][
"HighPurity"] = {}
137 if not cosmicsDecoMode:
138 options[
"TrackHitFilter"][
"Tracker"].
update({
139 "StoNcommands": cms.vstring(
"ALL 18.0")
142 options[
"TrackHitFilter"][
"Tracker"].
update({
146 options[
"TrackHitFilter"][
"Tracker"].
update({
149 options[
"TrackSelector"][
"Alignment"].
update({
153 "applyMultiplicityFilter":
True,
156 if cosmicTrackSplitting:
157 options[
"TrackSplitting"] = {}
158 options[
"TrackSplitting"][
"TrackSplitting"] = {}
160 options[
"TrackSelector"][
"Alignment"].
update({
164 elif collection
in (
"ALCARECOTkAlMuonIsolated",
165 "ALCARECOTkAlMuonIsolatedHI",
166 "ALCARECOTkAlMuonIsolatedPA"):
167 options[
"TrackSelector"][
"Alignment"].
update({
168 (
"minHitsPerSubDet",
"inPIXEL"): 1,
171 "applyMultiplicityFilter":
True,
172 "maxMultiplicity": 1,
174 elif collection
in (
"ALCARECOTkAlZMuMu",
175 "ALCARECOTkAlZMuMuHI",
176 "ALCARECOTkAlZMuMuPA"):
177 options[
"TrackSelector"][
"Alignment"].
update({
182 "applyMultiplicityFilter":
True,
183 "minMultiplicity": 2,
184 "maxMultiplicity": 2,
185 (
"minHitsPerSubDet",
"inPIXEL"): 1,
186 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
187 (
"TwoBodyDecaySelector",
"charge"): 0,
188 (
"TwoBodyDecaySelector",
189 "applyMassrangeFilter"):
not openMassWindow,
190 (
"TwoBodyDecaySelector",
"minXMass"): 85.8,
191 (
"TwoBodyDecaySelector",
"maxXMass"): 95.8,
192 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
194 options[
"TrackHitFilter"][
"Tracker"].
update({
197 elif collection ==
"ALCARECOTkAlUpsilonMuMu":
198 options[
"TrackSelector"][
"Alignment"].
update({
203 "applyMultiplicityFilter":
True,
204 "minMultiplicity": 2,
205 "maxMultiplicity": 2,
206 (
"minHitsPerSubDet",
"inPIXEL"): 1,
207 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
208 (
"TwoBodyDecaySelector",
"charge"): 0,
209 (
"TwoBodyDecaySelector",
210 "applyMassrangeFilter"):
not openMassWindow,
211 (
"TwoBodyDecaySelector",
"minXMass"): 9.2,
212 (
"TwoBodyDecaySelector",
"maxXMass"): 9.7,
213 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
215 options[
"TrackHitFilter"][
"Tracker"].
update({
218 elif collection ==
"ALCARECOTkAlJpsiMuMu":
219 options[
"TrackSelector"][
"Alignment"].
update({
224 "applyMultiplicityFilter":
True,
225 "minMultiplicity": 2,
226 "maxMultiplicity": 2,
227 (
"minHitsPerSubDet",
"inPIXEL"): 1,
228 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
229 (
"TwoBodyDecaySelector",
"charge"): 0,
230 (
"TwoBodyDecaySelector",
231 "applyMassrangeFilter"):
not openMassWindow,
232 (
"TwoBodyDecaySelector",
"minXMass"): 2.7,
233 (
"TwoBodyDecaySelector",
"maxXMass"): 3.4,
234 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
236 options[
"TrackHitFilter"][
"Tracker"].
update({
240 raise ValueError(
"Unknown input track collection: {}".
format(collection))
242 if cosmicTrackSplitting
and not isCosmics:
243 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
252 if cosmicTrackSplitting:
253 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
254 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
255 (
"TrackRefitter",
"First", {
"method":
"load",
257 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
258 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
259 options[
"TrackSelector"][
"Alignment"].
update(
260 options[
"TrackSelector"][
"HighPurity"])
261 elif cosmicTrackSplitting:
262 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
264 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
265 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
266 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
267 (
"TrackRefitter",
"Second", {
"method":
"load",
270 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
271 (
"TrackRefitter",
"First", {
"method":
"load",
273 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
274 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
275 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
276 (
"TrackRefitter",
"Second", {
"method":
"load",
278 if isCosmics: mods = mods[1:]
285 options[
"TrackSelector"][
"HighPurity"].
update({
286 "trackQualities": [],
289 options[
"TrackSelector"][
"Alignment"].
update({
304 if momentumConstraint
is not None:
305 for mod
in options[
"TrackRefitter"]:
306 momconstrspecs = momentumConstraint.split(
',')
307 if len(momconstrspecs)==1:
308 options[
"TrackRefitter"][mod].
update({
309 "constraint":
"momentum",
310 "srcConstr": momconstrspecs[0]
313 options[
"TrackRefitter"][mod].
update({
314 "constraint": momconstrspecs[1],
315 "srcConstr": momconstrspecs[0]
323 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
334 for mod
in mods[:-1]:
335 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
336 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
338 modules.append(getattr(process, src))
340 if mods[-1][-1][
"method"]
is "load" and \
341 not mods[-1][-1].get(
"clone",
False):
342 print(
"Name of the last module needs to be modifiable.")
344 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
345 options[mods[-1][0]][mods[-1][1]],
346 isCosmics = isCosmics, **(mods[-1][2]))
347 modules.append(getattr(process, src))
349 moduleSum = process.offlineBeamSpot
350 for module
in modules:
352 if hasattr(module,
"srcConstr"):
353 strSrcConstr = module.srcConstr.getModuleLabel()
355 procsrcconstr = getattr(process,strSrcConstr)
356 if hasattr(procsrcconstr,
"src"):
357 if procsrcconstr.src != module.src:
361 moduleSum += procsrcconstr
362 elif hasattr(procsrcconstr,
"srcTrk"):
363 if procsrcconstr.srcTrk != module.src:
367 procsrcconstrsrcvtx = getattr(process,procsrcconstr.srcVtx.getModuleLabel())
368 if type(procsrcconstrsrcvtx)
is cms.EDFilter:
369 procsrcconstrsrcvtxprefilter = getattr(process,procsrcconstrsrcvtx.src.getModuleLabel())
370 moduleSum += procsrcconstrsrcvtxprefilter
371 moduleSum += procsrcconstrsrcvtx
372 moduleSum += procsrcconstr
376 return cms.Sequence(moduleSum)