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 "ALCARECOTkAlJetHT"):
126 options[
"TrackSelector"][
"Alignment"].
update({
130 options[
"TrackHitFilter"][
"Tracker"].
update({
133 elif collection
in (
"ALCARECOTkAlCosmicsCTF0T",
134 "ALCARECOTkAlCosmicsCosmicTF0T",
135 "ALCARECOTkAlCosmicsInCollisions"):
137 options[
"TrackSelector"][
"HighPurity"] = {}
138 if not cosmicsDecoMode:
139 options[
"TrackHitFilter"][
"Tracker"].
update({
140 "StoNcommands": cms.vstring(
"ALL 18.0")
143 options[
"TrackHitFilter"][
"Tracker"].
update({
147 options[
"TrackHitFilter"][
"Tracker"].
update({
150 options[
"TrackSelector"][
"Alignment"].
update({
154 "applyMultiplicityFilter":
True,
157 if cosmicTrackSplitting:
158 options[
"TrackSplitting"] = {}
159 options[
"TrackSplitting"][
"TrackSplitting"] = {}
161 options[
"TrackSelector"][
"Alignment"].
update({
165 elif collection
in (
"ALCARECOTkAlMuonIsolated",
166 "ALCARECOTkAlMuonIsolatedHI",
167 "ALCARECOTkAlMuonIsolatedPA"):
168 options[
"TrackSelector"][
"Alignment"].
update({
169 (
"minHitsPerSubDet",
"inPIXEL"): 1,
172 "applyMultiplicityFilter":
True,
173 "maxMultiplicity": 1,
175 elif collection
in (
"ALCARECOTkAlZMuMu",
176 "ALCARECOTkAlZMuMuHI",
177 "ALCARECOTkAlZMuMuPA"):
178 options[
"TrackSelector"][
"Alignment"].
update({
183 "applyMultiplicityFilter":
True,
184 "minMultiplicity": 2,
185 "maxMultiplicity": 2,
186 (
"minHitsPerSubDet",
"inPIXEL"): 1,
187 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
188 (
"TwoBodyDecaySelector",
"charge"): 0,
189 (
"TwoBodyDecaySelector",
190 "applyMassrangeFilter"):
not openMassWindow,
191 (
"TwoBodyDecaySelector",
"minXMass"): 85.8,
192 (
"TwoBodyDecaySelector",
"maxXMass"): 95.8,
193 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
195 options[
"TrackHitFilter"][
"Tracker"].
update({
198 elif collection ==
"ALCARECOTkAlUpsilonMuMu":
199 options[
"TrackSelector"][
"Alignment"].
update({
204 "applyMultiplicityFilter":
True,
205 "minMultiplicity": 2,
206 "maxMultiplicity": 2,
207 (
"minHitsPerSubDet",
"inPIXEL"): 1,
208 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
209 (
"TwoBodyDecaySelector",
"charge"): 0,
210 (
"TwoBodyDecaySelector",
211 "applyMassrangeFilter"):
not openMassWindow,
212 (
"TwoBodyDecaySelector",
"minXMass"): 9.2,
213 (
"TwoBodyDecaySelector",
"maxXMass"): 9.7,
214 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
216 options[
"TrackHitFilter"][
"Tracker"].
update({
219 elif collection ==
"ALCARECOTkAlJpsiMuMu":
220 options[
"TrackSelector"][
"Alignment"].
update({
225 "applyMultiplicityFilter":
True,
226 "minMultiplicity": 2,
227 "maxMultiplicity": 2,
228 (
"minHitsPerSubDet",
"inPIXEL"): 1,
229 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
230 (
"TwoBodyDecaySelector",
"charge"): 0,
231 (
"TwoBodyDecaySelector",
232 "applyMassrangeFilter"):
not openMassWindow,
233 (
"TwoBodyDecaySelector",
"minXMass"): 2.7,
234 (
"TwoBodyDecaySelector",
"maxXMass"): 3.4,
235 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
237 options[
"TrackHitFilter"][
"Tracker"].
update({
241 raise ValueError(
"Unknown input track collection: {}".
format(collection))
243 if cosmicTrackSplitting
and not isCosmics:
244 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
253 if cosmicTrackSplitting:
254 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
255 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
256 (
"TrackRefitter",
"First", {
"method":
"load",
258 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
259 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
260 options[
"TrackSelector"][
"Alignment"].
update(
261 options[
"TrackSelector"][
"HighPurity"])
262 elif cosmicTrackSplitting:
263 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
265 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
266 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
267 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
268 (
"TrackRefitter",
"Second", {
"method":
"load",
271 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
272 (
"TrackRefitter",
"First", {
"method":
"load",
274 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
275 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
276 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
277 (
"TrackRefitter",
"Second", {
"method":
"load",
279 if isCosmics: mods = mods[1:]
286 options[
"TrackSelector"][
"HighPurity"].
update({
287 "trackQualities": [],
290 options[
"TrackSelector"][
"Alignment"].
update({
305 if momentumConstraint
is not None:
306 for mod
in options[
"TrackRefitter"]:
307 momconstrspecs = momentumConstraint.split(
',')
308 if len(momconstrspecs)==1:
309 options[
"TrackRefitter"][mod].
update({
310 "constraint":
"momentum",
311 "srcConstr": momconstrspecs[0]
314 options[
"TrackRefitter"][mod].
update({
315 "constraint": momconstrspecs[1],
316 "srcConstr": momconstrspecs[0]
324 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
335 for mod
in mods[:-1]:
336 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
337 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
339 modules.append(getattr(process, src))
341 if mods[-1][-1][
"method"] ==
"load" and \
342 not mods[-1][-1].get(
"clone",
False):
343 print(
"Name of the last module needs to be modifiable.")
345 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
346 options[mods[-1][0]][mods[-1][1]],
347 isCosmics = isCosmics, **(mods[-1][2]))
348 modules.append(getattr(process, src))
350 moduleSum = process.offlineBeamSpot
351 for module
in modules:
353 if hasattr(module,
"srcConstr"):
354 strSrcConstr = module.srcConstr.getModuleLabel()
356 procsrcconstr = getattr(process,strSrcConstr)
357 if hasattr(procsrcconstr,
"src"):
358 if procsrcconstr.src != module.src:
362 moduleSum += procsrcconstr
363 elif hasattr(procsrcconstr,
"srcTrk"):
364 if procsrcconstr.srcTrk != module.src:
368 procsrcconstrsrcvtx = getattr(process,procsrcconstr.srcVtx.getModuleLabel())
369 if type(procsrcconstrsrcvtx)
is cms.EDFilter:
370 procsrcconstrsrcvtxprefilter = getattr(process,procsrcconstrsrcvtx.src.getModuleLabel())
371 moduleSum += procsrcconstrsrcvtxprefilter
372 moduleSum += procsrcconstrsrcvtx
373 moduleSum += procsrcconstr
377 return cms.Sequence(moduleSum)
def _getModule(process, src, modType, moduleName, options, kwargs)
Auxiliary functions ###
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)