1 from __future__
import print_function
3 import FWCore.ParameterSet.Config
as cms
6 print(
"# MSG-i trackselectionRefitting: %s" % s)
10 TTRHBuilder = "WithAngleAndTemplate",
11 usePixelQualityFlag = None,
12 openMassWindow = False,
13 cosmicsDecoMode = False,
14 cosmicsZeroTesla = True,
15 momentumConstraint = None,
16 cosmicTrackSplitting = False,
17 isPVValidation = False,
20 """This function returns a cms.Sequence containing as last element the 21 module 'FinalTrackRefitter', which can be used as cms.InputTag for 22 subsequent processing steps. 23 The modules in the sequence are already attached to the given `process` 24 object using the given track collection `collection` and the given 28 - `process`: 'cms.Process' object to which the modules of the sequence will 30 - `collection`: String indicating the input track collection. 31 - `saveCPU`: If set to 'True', some steps are merged to reduce CPU time. 32 Reduces a little the accuracy of the results. 33 This option is currently not recommended. 34 - `TTRHBuilder`: Option used for the Track(Re)Fitter modules. 35 - `usePixelQualityFlag`: Option used for the TrackHitFilter module. 36 Defaults to 'True' but is automatically set to 37 'False' if a `TTRHBuilder` without templates is 39 If this is still wanted for some reason, one can 40 explicitely specify it as 'True'. 41 - `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu. 42 - `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used. 43 - `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used. 44 - `momentumConstraint`: If you want to apply a momentum constraint for the 45 track refitting, e.g. for CRUZET data, you need 46 to provide here the name of the constraint module. 47 - `cosmicTrackSplitting`: If set to 'True' cosmic tracks are split before the 48 second track refitter. 49 - `isPVValidation`: If set to 'True' most of the selection cuts are overridden 50 to allow unbiased selection of tracks for vertex refitting 51 - `use_d0cut`: If 'True' (default), apply a cut |d0| < 50. 60 if usePixelQualityFlag
is None:
61 if "Template" not in TTRHBuilder:
62 usePixelQualityFlag =
False 63 customlog(
"Using 'TTRHBuilder' without templates %s" % TTRHBuilder)
64 customlog(
" --> Turning off pixel quality flag in hit filter.")
66 usePixelQualityFlag =
True 73 options = {
"TrackHitFilter": {},
79 options[
"TrackSelector"][
"HighPurity"] = {
80 "trackQualities": [
"highPurity"],
86 options[
"TrackSelector"][
"Alignment"] = {
97 options[
"TrackRefitter"][
"First"] = {
98 "NavigationSchool":
"",
99 "TTRHBuilder": TTRHBuilder,
101 options[
"TrackRefitter"][
"Second"] = {
102 "NavigationSchool":
"",
103 "TTRHBuilder": TTRHBuilder,
105 options[
"TrackHitFilter"][
"Tracker"] = {
106 "useTrajectories":
True,
108 "commands": cms.vstring(
"keep PXB",
"keep PXE",
"keep TIB",
"keep TID",
109 "keep TOB",
"keep TEC"),
110 "replaceWithInactiveHits":
True,
111 "rejectBadStoNHits":
True,
112 "rejectLowAngleHits":
True,
113 "usePixelQualityFlag": usePixelQualityFlag,
114 "StoNcommands": cms.vstring(
"ALL 12.0"),
115 "TrackAngleCut": 0.087,
117 options[
"TrackFitter"][
"HitFilteredTracks"] = {
118 "NavigationSchool":
"",
119 "TTRHBuilder": TTRHBuilder,
121 options[
"geopro"][
""] = {
125 options[
"TrackRefitter"][
"Second"] = {
126 "AlgorithmName" : cms.string(
'undefAlgorithm'),
127 "Fitter" : cms.string(
'G4eFitterSmoother'),
128 "GeometricInnerState" : cms.bool(
False),
129 "MeasurementTracker" : cms.string(
''),
130 "MeasurementTrackerEvent" : cms.InputTag(
"MeasurementTrackerEvent"),
131 "NavigationSchool" : cms.string(
'SimpleNavigationSchool'),
132 "Propagator" : cms.string(
'Geant4ePropagator'),
133 "TTRHBuilder" : cms.string(
'WithAngleAndTemplate'),
134 "TrajectoryInEvent" : cms.bool(
True),
135 "beamSpot" : cms.InputTag(
"offlineBeamSpot"),
136 "constraint" : cms.string(
''),
137 "src" : cms.InputTag(
"AlignmentTrackSelector"),
138 "srcConstr" : cms.InputTag(
""),
139 "useHitsSplitting" : cms.bool(
False),
140 "usePropagatorForPCA" : cms.bool(
True)
148 if collection
in (
"ALCARECOTkAlMinBias",
"generalTracks",
149 "ALCARECOTkAlMinBiasHI",
"hiGeneralTracks",
150 "ALCARECOTkAlJetHT",
"ALCARECOTkAlDiMuonVertexTracks"):
151 options[
"TrackSelector"][
"Alignment"].
update({
155 options[
"TrackHitFilter"][
"Tracker"].
update({
158 elif collection
in (
"ALCARECOTkAlCosmicsCTF0T",
159 "ALCARECOTkAlCosmicsCosmicTF0T",
160 "ALCARECOTkAlCosmicsInCollisions"):
162 options[
"TrackSelector"][
"HighPurity"] = {}
163 if not cosmicsDecoMode:
164 options[
"TrackHitFilter"][
"Tracker"].
update({
165 "StoNcommands": cms.vstring(
"ALL 18.0")
168 options[
"TrackHitFilter"][
"Tracker"].
update({
172 options[
"TrackHitFilter"][
"Tracker"].
update({
175 options[
"TrackSelector"][
"Alignment"].
update({
179 "applyMultiplicityFilter":
True,
182 if cosmicTrackSplitting:
183 options[
"TrackSplitting"] = {}
184 options[
"TrackSplitting"][
"TrackSplitting"] = {}
186 options[
"TrackSelector"][
"Alignment"].
update({
190 elif collection
in (
"ALCARECOTkAlMuonIsolated",
191 "ALCARECOTkAlMuonIsolatedHI",
192 "ALCARECOTkAlMuonIsolatedPA"):
193 options[
"TrackSelector"][
"Alignment"].
update({
194 (
"minHitsPerSubDet",
"inPIXEL"): 1,
197 "applyMultiplicityFilter":
True,
198 "maxMultiplicity": 1,
200 elif collection
in (
"ALCARECOTkAlZMuMu",
201 "ALCARECOTkAlZMuMuHI",
202 "ALCARECOTkAlZMuMuPA",
203 "ALCARECOTkAlDiMuon"):
204 options[
"TrackSelector"][
"Alignment"].
update({
209 "applyMultiplicityFilter":
True,
210 "minMultiplicity": 2,
211 "maxMultiplicity": 2,
212 (
"minHitsPerSubDet",
"inPIXEL"): 1,
213 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
214 (
"TwoBodyDecaySelector",
"charge"): 0,
215 (
"TwoBodyDecaySelector",
216 "applyMassrangeFilter"):
not openMassWindow,
217 (
"TwoBodyDecaySelector",
"minXMass"): 85.8,
218 (
"TwoBodyDecaySelector",
"maxXMass"): 95.8,
219 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
221 options[
"TrackHitFilter"][
"Tracker"].
update({
224 elif collection ==
"ALCARECOTkAlUpsilonMuMu":
225 options[
"TrackSelector"][
"Alignment"].
update({
230 "applyMultiplicityFilter":
True,
231 "minMultiplicity": 2,
232 "maxMultiplicity": 2,
233 (
"minHitsPerSubDet",
"inPIXEL"): 1,
234 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
235 (
"TwoBodyDecaySelector",
"charge"): 0,
236 (
"TwoBodyDecaySelector",
237 "applyMassrangeFilter"):
not openMassWindow,
238 (
"TwoBodyDecaySelector",
"minXMass"): 9.2,
239 (
"TwoBodyDecaySelector",
"maxXMass"): 9.7,
240 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
242 options[
"TrackHitFilter"][
"Tracker"].
update({
245 elif collection ==
"ALCARECOTkAlJpsiMuMu":
246 options[
"TrackSelector"][
"Alignment"].
update({
251 "applyMultiplicityFilter":
True,
252 "minMultiplicity": 2,
253 "maxMultiplicity": 2,
254 (
"minHitsPerSubDet",
"inPIXEL"): 1,
255 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
256 (
"TwoBodyDecaySelector",
"charge"): 0,
257 (
"TwoBodyDecaySelector",
258 "applyMassrangeFilter"):
not openMassWindow,
259 (
"TwoBodyDecaySelector",
"minXMass"): 2.7,
260 (
"TwoBodyDecaySelector",
"maxXMass"): 3.4,
261 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
263 options[
"TrackHitFilter"][
"Tracker"].
update({
267 raise ValueError(
"Unknown input track collection: {}".
format(collection))
269 if cosmicTrackSplitting
and not isCosmics:
270 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
279 if cosmicTrackSplitting:
280 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
281 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
282 (
"TrackRefitter",
"First", {
"method":
"load",
284 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
285 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
286 options[
"TrackSelector"][
"Alignment"].
update(
287 options[
"TrackSelector"][
"HighPurity"])
288 elif cosmicTrackSplitting:
289 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
291 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
292 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
293 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
294 (
"TrackRefitter",
"Second", {
"method":
"load",
297 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
298 (
"TrackRefitter",
"First", {
"method":
"load",
300 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
301 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
302 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
304 (
"TrackRefitter",
"Second", {
"method":
"load",
306 if isCosmics: mods = mods[1:]
308 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
309 (
"TrackRefitter",
"First", {
"method":
"load",
311 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
312 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
313 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
314 (
"TrackRefitter",
"Second", {
"method":
"load",
316 if isCosmics: mods = mods[1:]
323 options[
"TrackSelector"][
"HighPurity"].
update({
324 "trackQualities": [],
327 options[
"TrackSelector"][
"Alignment"].
update({
342 if momentumConstraint
is not None:
343 for mod
in options[
"TrackRefitter"]:
344 momconstrspecs = momentumConstraint.split(
',')
345 if len(momconstrspecs)==1:
346 options[
"TrackRefitter"][mod].
update({
347 "constraint":
"momentum",
348 "srcConstr": momconstrspecs[0]
351 options[
"TrackRefitter"][mod].
update({
352 "constraint": momconstrspecs[1],
353 "srcConstr": momconstrspecs[0]
361 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
370 for mod
in mods[:-1]:
371 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
372 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
374 modules.append(getattr(process, src))
376 if mods[-1][-1][
"method"] ==
"load" and \
377 not mods[-1][-1].get(
"clone",
False):
378 customlog(
"Name of the last module needs to be modifiable.")
382 customlog(
"Here we must include geopro first")
383 process.load(
'Configuration.StandardSequences.GeometryDB_cff')
384 process.load(
"TrackPropagation.Geant4e.geantRefit_cff")
385 modules.append(getattr(process,
"geopro"))
387 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
388 options[mods[-1][0]][mods[-1][1]],
389 isCosmics = isCosmics, **(mods[-1][2]))
390 modules.append(getattr(process, src))
392 moduleSum = process.offlineBeamSpot
395 moduleSum += getattr(process,
"MeasurementTrackerEvent")
397 for module
in modules:
399 if hasattr(module,
"srcConstr"):
400 strSrcConstr = module.srcConstr.getModuleLabel()
402 procsrcconstr = getattr(process,strSrcConstr)
403 if hasattr(procsrcconstr,
"src"):
404 if procsrcconstr.src != module.src:
408 moduleSum += procsrcconstr
409 elif hasattr(procsrcconstr,
"srcTrk"):
410 if procsrcconstr.srcTrk != module.src:
414 procsrcconstrsrcvtx = getattr(process,procsrcconstr.srcVtx.getModuleLabel())
415 if type(procsrcconstrsrcvtx)
is cms.EDFilter:
416 procsrcconstrsrcvtxprefilter = getattr(process,procsrcconstrsrcvtx.src.getModuleLabel())
417 moduleSum += procsrcconstrsrcvtxprefilter
418 moduleSum += procsrcconstrsrcvtx
419 moduleSum += procsrcconstr
423 return cms.Sequence(moduleSum)
434 def _getModule(process, src, modType, moduleName, options, **kwargs):
435 """General function for attaching the module of type `modType` to the 436 cms.Process `process` using `options` for customization and `moduleName` as 437 the name of the new attribute of `process`. 440 - `process`: 'cms.Process' object to which the module is attached. 441 - `src`: cms.InputTag for this module. 442 - `modType`: Type of the requested module. 443 - `options`: Dictionary with customized values for the module's options. 444 - `**kwargs`: Used to supply options at construction time of the module. 447 objTuple = globals()[
"_"+modType](kwargs)
448 method = kwargs.get(
"method")
449 if method ==
"import":
450 __import__(objTuple[0])
451 obj = getattr(sys.modules[objTuple[0]], objTuple[1]).
clone()
452 elif method ==
"load":
453 process.load(objTuple[0])
454 if kwargs.get(
"clone",
False):
455 obj = getattr(process, objTuple[1]).
clone(src=src)
457 obj = getattr(process, objTuple[1])
458 moduleName = objTuple[1]
463 if modType ==
"TrackSplitting":
471 for option
in options:
474 if moduleName
is not objTuple[1]:
475 setattr(process, moduleName, obj)
480 """Returns TrackHitFilter module name. 483 - `kwargs`: Not used in this function. 486 return (
"RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
487 "TrackerTrackHitFilter")
491 """Returns TrackSelector module name. 494 - `kwargs`: Not used in this function. 497 return (
"Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
498 "AlignmentTrackSelector")
502 """Returns TrackFitter module name. 505 - `kwargs`: Used to supply options at construction time of the object. 508 isCosmics = kwargs.get(
"isCosmics",
False)
510 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
511 "ctfWithMaterialTracksCosmics")
513 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
514 "ctfWithMaterialTracks")
518 """Returns TrackRefitter module name. 521 - `kwargs`: Used to supply options at construction time of the object. 524 isCosmics = kwargs.get(
"isCosmics",
False)
526 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
529 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
533 return (
"RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi",
534 "cosmicTrackSplitter")
537 return (
"TrackPropagation.Geant4e.geantRefit_cff",
"geopro")
541 """Sets the attribute `attr` of the object `obj` using the value `val`. 542 `attr` can be a string or a tuple of strings, if one wants to set an 543 attribute of an attribute, etc. 546 - `obj`: Object, which must have a '__dict__' attribute. 547 - `attr`: String or tuple of strings describing the attribute's name. 548 - `val`: value of the attribute. 551 if isinstance(attr, tuple)
and len(attr) > 1:
554 if isinstance(attr, tuple): attr = attr[0]
555 setattr(obj, attr, val)
def _customSetattr(obj, attr, val)
def _TrackSplitting(kwargs)
def getSequence(process, collection, saveCPU=False, TTRHBuilder="WithAngleAndTemplate", usePixelQualityFlag=None, openMassWindow=False, cosmicsDecoMode=False, cosmicsZeroTesla=True, momentumConstraint=None, cosmicTrackSplitting=False, isPVValidation=False, use_d0cut=True, g4Refitting=False)
def _TrackSelector(kwargs)
def _getModule(process, src, modType, moduleName, options, kwargs)
Auxiliary functions ###
def _TrackRefitter(kwargs)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def _TrackHitFilter(kwargs)
static std::string join(char **cmd)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)