17 """This function returns a cms.Sequence containing as last element the 18 module 'FinalTrackRefitter', which can be used as cms.InputTag for 19 subsequent processing steps. 20 The modules in the sequence are already attached to the given `process` 21 object using the given track collection `collection` and the given 25 - `process`: 'cms.Process' object to which the modules of the sequence will 27 - `collection`: String indicating the input track collection. 28 - `saveCPU`: If set to 'True', some steps are merged to reduce CPU time. 29 Reduces a little the accuracy of the results. 30 This option is currently not recommended. 31 - `TTRHBuilder`: Option used for the Track(Re)Fitter modules. 32 - `usePixelQualityFlag`: Option used for the TrackHitFilter module. 33 Defaults to 'True' but is automatically set to 34 'False' if a `TTRHBuilder` without templates is 36 If this is still wanted for some reason, one can 37 explicitely specify it as 'True'. 38 - `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu. 39 - `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used. 40 - `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used. 41 - `momentumConstraint`: If you want to apply a momentum constraint for the 42 track refitting, e.g. for CRUZET data, you need 43 to provide here the name of the constraint module. 44 - `cosmicTrackSplitting`: If set to 'True' cosmic tracks are split before the 45 second track refitter. 46 - `isPVValidation`: If set to 'True' most of the selection cuts are overridden 47 to allow unbiased selection of tracks for vertex refitting 48 - `use_d0cut`: If 'True' (default), apply a cut |d0| < 50. 55 print(
"g4Refitting=",g4Refitting)
57 if usePixelQualityFlag
is None:
58 if "Template" not in TTRHBuilder:
59 usePixelQualityFlag =
False 60 print(
"Using 'TTRHBuilder' without templates:", TTRHBuilder)
61 print(
" --> Turning off pixel quality flag in hit filter.")
63 usePixelQualityFlag =
True 70 options = {
"TrackHitFilter": {},
76 options[
"TrackSelector"][
"HighPurity"] = {
77 "trackQualities": [
"highPurity"],
83 options[
"TrackSelector"][
"Alignment"] = {
94 options[
"TrackRefitter"][
"First"] = {
95 "NavigationSchool":
"",
96 "TTRHBuilder": TTRHBuilder,
98 options[
"TrackRefitter"][
"Second"] = {
99 "NavigationSchool":
"",
100 "TTRHBuilder": TTRHBuilder,
102 options[
"TrackHitFilter"][
"Tracker"] = {
103 "useTrajectories":
True,
105 "commands": cms.vstring(
"keep PXB",
"keep PXE",
"keep TIB",
"keep TID",
106 "keep TOB",
"keep TEC"),
107 "replaceWithInactiveHits":
True,
108 "rejectBadStoNHits":
True,
109 "rejectLowAngleHits":
True,
110 "usePixelQualityFlag": usePixelQualityFlag,
111 "StoNcommands": cms.vstring(
"ALL 12.0"),
112 "TrackAngleCut": 0.087,
114 options[
"TrackFitter"][
"HitFilteredTracks"] = {
115 "NavigationSchool":
"",
116 "TTRHBuilder": TTRHBuilder,
118 options[
"geopro"][
""] = {
122 options[
"TrackRefitter"][
"Second"] = {
123 "AlgorithmName" : cms.string(
'undefAlgorithm'),
124 "Fitter" : cms.string(
'G4eFitterSmoother'),
125 "GeometricInnerState" : cms.bool(
False),
126 "MeasurementTracker" : cms.string(
''),
127 "MeasurementTrackerEvent" : cms.InputTag(
"MeasurementTrackerEvent"),
128 "NavigationSchool" : cms.string(
'SimpleNavigationSchool'),
129 "Propagator" : cms.string(
'Geant4ePropagator'),
130 "TTRHBuilder" : cms.string(
'WithAngleAndTemplate'),
131 "TrajectoryInEvent" : cms.bool(
True),
132 "beamSpot" : cms.InputTag(
"offlineBeamSpot"),
133 "constraint" : cms.string(
''),
134 "src" : cms.InputTag(
"AlignmentTrackSelector"),
135 "srcConstr" : cms.InputTag(
""),
136 "useHitsSplitting" : cms.bool(
False),
137 "usePropagatorForPCA" : cms.bool(
True)
145 if collection
in (
"ALCARECOTkAlMinBias",
"generalTracks",
146 "ALCARECOTkAlMinBiasHI",
"hiGeneralTracks",
147 "ALCARECOTkAlJetHT",
"ALCARECOTkAlDiMuonVertexTracks"):
148 options[
"TrackSelector"][
"Alignment"].
update({
152 options[
"TrackHitFilter"][
"Tracker"].
update({
155 elif collection
in (
"ALCARECOTkAlCosmicsCTF0T",
156 "ALCARECOTkAlCosmicsInCollisions"):
158 options[
"TrackSelector"][
"HighPurity"] = {}
159 if not cosmicsDecoMode:
160 options[
"TrackHitFilter"][
"Tracker"].
update({
161 "StoNcommands": cms.vstring(
"ALL 18.0")
164 options[
"TrackHitFilter"][
"Tracker"].
update({
168 options[
"TrackHitFilter"][
"Tracker"].
update({
171 options[
"TrackSelector"][
"Alignment"].
update({
175 "applyMultiplicityFilter":
True,
178 if cosmicTrackSplitting:
179 options[
"TrackSplitting"] = {}
180 options[
"TrackSplitting"][
"TrackSplitting"] = {}
182 options[
"TrackSelector"][
"Alignment"].
update({
186 elif collection
in (
"ALCARECOTkAlMuonIsolated",
187 "ALCARECOTkAlMuonIsolatedHI",
188 "ALCARECOTkAlMuonIsolatedPA"):
189 options[
"TrackSelector"][
"Alignment"].
update({
190 (
"minHitsPerSubDet",
"inPIXEL"): 1,
193 "applyMultiplicityFilter":
True,
194 "maxMultiplicity": 1,
196 elif collection
in (
"ALCARECOTkAlZMuMu",
197 "ALCARECOTkAlZMuMuHI",
198 "ALCARECOTkAlZMuMuPA",
199 "ALCARECOTkAlDiMuon"):
200 options[
"TrackSelector"][
"Alignment"].
update({
205 "applyMultiplicityFilter":
True,
206 "minMultiplicity": 2,
207 "maxMultiplicity": 2,
208 (
"minHitsPerSubDet",
"inPIXEL"): 1,
209 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
210 (
"TwoBodyDecaySelector",
"charge"): 0,
211 (
"TwoBodyDecaySelector",
212 "applyMassrangeFilter"):
not openMassWindow,
213 (
"TwoBodyDecaySelector",
"minXMass"): 85.8,
214 (
"TwoBodyDecaySelector",
"maxXMass"): 95.8,
215 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
217 options[
"TrackHitFilter"][
"Tracker"].
update({
220 elif collection ==
"ALCARECOTkAlUpsilonMuMu":
221 options[
"TrackSelector"][
"Alignment"].
update({
226 "applyMultiplicityFilter":
True,
227 "minMultiplicity": 2,
228 "maxMultiplicity": 2,
229 (
"minHitsPerSubDet",
"inPIXEL"): 1,
230 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
231 (
"TwoBodyDecaySelector",
"charge"): 0,
232 (
"TwoBodyDecaySelector",
233 "applyMassrangeFilter"):
not openMassWindow,
234 (
"TwoBodyDecaySelector",
"minXMass"): 9.2,
235 (
"TwoBodyDecaySelector",
"maxXMass"): 9.7,
236 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
238 options[
"TrackHitFilter"][
"Tracker"].
update({
241 elif collection ==
"ALCARECOTkAlJpsiMuMu":
242 options[
"TrackSelector"][
"Alignment"].
update({
247 "applyMultiplicityFilter":
True,
248 "minMultiplicity": 2,
249 "maxMultiplicity": 2,
250 (
"minHitsPerSubDet",
"inPIXEL"): 1,
251 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
252 (
"TwoBodyDecaySelector",
"charge"): 0,
253 (
"TwoBodyDecaySelector",
254 "applyMassrangeFilter"):
not openMassWindow,
255 (
"TwoBodyDecaySelector",
"minXMass"): 2.7,
256 (
"TwoBodyDecaySelector",
"maxXMass"): 3.4,
257 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
259 options[
"TrackHitFilter"][
"Tracker"].
update({
263 raise ValueError(
"Unknown input track collection: {}".
format(collection))
265 if cosmicTrackSplitting
and not isCosmics:
266 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
275 if cosmicTrackSplitting:
276 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
277 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
278 (
"TrackRefitter",
"First", {
"method":
"load",
280 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
281 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
282 options[
"TrackSelector"][
"Alignment"].
update(
283 options[
"TrackSelector"][
"HighPurity"])
284 elif cosmicTrackSplitting:
285 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
287 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
288 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
289 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
290 (
"TrackRefitter",
"Second", {
"method":
"load",
293 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
294 (
"TrackRefitter",
"First", {
"method":
"load",
296 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
297 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
298 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
300 (
"TrackRefitter",
"Second", {
"method":
"load",
302 if isCosmics: mods = mods[1:]
304 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
305 (
"TrackRefitter",
"First", {
"method":
"load",
307 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
308 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
309 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
310 (
"TrackRefitter",
"Second", {
"method":
"load",
312 if isCosmics: mods = mods[1:]
319 options[
"TrackSelector"][
"HighPurity"].
update({
320 "trackQualities": [],
323 options[
"TrackSelector"][
"Alignment"].
update({
338 if momentumConstraint
is not None:
339 for mod
in options[
"TrackRefitter"]:
340 momconstrspecs = momentumConstraint.split(
',')
341 if len(momconstrspecs)==1:
342 options[
"TrackRefitter"][mod].
update({
343 "constraint":
"momentum",
344 "srcConstr": momconstrspecs[0]
347 options[
"TrackRefitter"][mod].
update({
348 "constraint": momconstrspecs[1],
349 "srcConstr": momconstrspecs[0]
357 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
366 for mod
in mods[:-1]:
367 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
368 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
370 modules.append(getattr(process, src))
372 if mods[-1][-1][
"method"] ==
"load" and \
373 not mods[-1][-1].get(
"clone",
False):
374 print(
"Name of the last module needs to be modifiable.")
378 print(
"Here we must include geopro first")
379 process.load(
'Configuration.StandardSequences.GeometryDB_cff')
380 process.load(
"TrackPropagation.Geant4e.geantRefit_cff")
381 modules.append(getattr(process,
"geopro"))
383 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
384 options[mods[-1][0]][mods[-1][1]],
385 isCosmics = isCosmics, **(mods[-1][2]))
386 modules.append(getattr(process, src))
388 moduleSum = process.offlineBeamSpot
391 moduleSum += getattr(process,
"MeasurementTrackerEvent")
393 for module
in modules:
395 if hasattr(module,
"srcConstr"):
396 strSrcConstr = module.srcConstr.getModuleLabel()
398 procsrcconstr = getattr(process,strSrcConstr)
399 if hasattr(procsrcconstr,
"src"):
400 if procsrcconstr.src != module.src:
404 moduleSum += procsrcconstr
405 elif hasattr(procsrcconstr,
"srcTrk"):
406 if procsrcconstr.srcTrk != module.src:
410 procsrcconstrsrcvtx = getattr(process,procsrcconstr.srcVtx.getModuleLabel())
411 if type(procsrcconstrsrcvtx)
is cms.EDFilter:
412 procsrcconstrsrcvtxprefilter = getattr(process,procsrcconstrsrcvtx.src.getModuleLabel())
413 moduleSum += procsrcconstrsrcvtxprefilter
414 moduleSum += procsrcconstrsrcvtx
415 moduleSum += procsrcconstr
419 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)