CMS 3D CMS Logo

Functions
trackselectionRefitting Namespace Reference

Functions

def _customSetattr (obj, attr, val)
 
def _getModule (process, src, modType, moduleName, options, kwargs)
 

Auxiliary functions ###

More...
 
def _TrackFitter (kwargs)
 
def _TrackHitFilter (kwargs)
 
def _TrackRefitter (kwargs)
 
def _TrackSelector (kwargs)
 
def _TrackSplitting (kwargs)
 
def getSequence (process, collection, saveCPU=False, TTRHBuilder="WithAngleAndTemplate", usePixelQualityFlag=None, openMassWindow=False, cosmicsDecoMode=False, cosmicsZeroTesla=True, momentumConstraint=None, cosmicTrackSplitting=False, use_d0cut=True)
 

Function Documentation

def trackselectionRefitting._customSetattr (   obj,
  attr,
  val 
)
private
Sets the attribute `attr` of the object `obj` using the value `val`.
`attr` can be a string or a tuple of strings, if one wants to set an
attribute of an attribute, etc.

Arguments:
- `obj`: Object, which must have a '__dict__' attribute.
- `attr`: String or tuple of strings describing the attribute's name.
- `val`: value of the attribute.

Definition at line 418 of file trackselectionRefitting.py.

Referenced by _getModule().

418 def _customSetattr(obj, attr, val):
419  """Sets the attribute `attr` of the object `obj` using the value `val`.
420  `attr` can be a string or a tuple of strings, if one wants to set an
421  attribute of an attribute, etc.
422 
423  Arguments:
424  - `obj`: Object, which must have a '__dict__' attribute.
425  - `attr`: String or tuple of strings describing the attribute's name.
426  - `val`: value of the attribute.
427  """
428 
429  if type(attr) is tuple and len(attr) > 1:
430  _customSetattr(getattr(obj, attr[0]), attr[1:], val)
431  else:
432  if type(attr) is tuple: attr = attr[0]
433  setattr(obj, attr, val)
434 
435 
def _customSetattr(obj, attr, val)
def trackselectionRefitting._getModule (   process,
  src,
  modType,
  moduleName,
  options,
  kwargs 
)
private

Auxiliary functions ###

General function for attaching the module of type `modType` to the
cms.Process `process` using `options` for customization and `moduleName` as
the name of the new attribute of `process`.

Arguments:
- `process`: 'cms.Process' object to which the module is attached.
- `src`: cms.InputTag for this module.
- `modType`: Type of the requested module.
- `options`: Dictionary with customized values for the module's options.
- `**kwargs`: Used to supply options at construction time of the module.

Definition at line 315 of file trackselectionRefitting.py.

References _customSetattr(), and clone().

Referenced by getSequence().

315 def _getModule(process, src, modType, moduleName, options, **kwargs):
316  """General function for attaching the module of type `modType` to the
317  cms.Process `process` using `options` for customization and `moduleName` as
318  the name of the new attribute of `process`.
319 
320  Arguments:
321  - `process`: 'cms.Process' object to which the module is attached.
322  - `src`: cms.InputTag for this module.
323  - `modType`: Type of the requested module.
324  - `options`: Dictionary with customized values for the module's options.
325  - `**kwargs`: Used to supply options at construction time of the module.
326  """
327 
328  objTuple = globals()["_"+modType](kwargs)
329  method = kwargs.get("method")
330  if method == "import":
331  __import__(objTuple[0])
332  obj = getattr(sys.modules[objTuple[0]], objTuple[1]).clone()
333  elif method == "load":
334  process.load(objTuple[0])
335  if kwargs.get("clone", False):
336  obj = getattr(process, objTuple[1]).clone(src=src)
337  else:
338  obj = getattr(process, objTuple[1])
339  moduleName = objTuple[1]
340  else:
341  print "Unknown method:", method
342  sys.exit(1)
343 
344  if modType == "TrackSplitting":
345  #track splitting takes the TrackSelector as tracks
346  # and the first TrackRefitter as tjTkAssociationMapTag
347  _customSetattr(obj, "tracks", src)
348  _customSetattr(obj, "tjTkAssociationMapTag", kwargs["prevsrc"])
349  else:
350  obj.src = src
351 
352  for option in options:
353  _customSetattr(obj, option, options[option])
354 
355  if moduleName is not objTuple[1]:
356  setattr(process, moduleName, obj)
357  return moduleName
358 
359 
def _customSetattr(obj, attr, val)
def _getModule(process, src, modType, moduleName, options, kwargs)
Auxiliary functions ###
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def trackselectionRefitting._TrackFitter (   kwargs)
private
Returns TrackFitter module name.

Arguments:
- `kwargs`: Used to supply options at construction time of the object.

Definition at line 382 of file trackselectionRefitting.py.

382 def _TrackFitter(kwargs):
383  """Returns TrackFitter module name.
384 
385  Arguments:
386  - `kwargs`: Used to supply options at construction time of the object.
387  """
388 
389  isCosmics = kwargs.get("isCosmics", False)
390  if isCosmics:
391  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
392  "ctfWithMaterialTracksCosmics")
393  else:
394  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
395  "ctfWithMaterialTracks")
396 
397 
def trackselectionRefitting._TrackHitFilter (   kwargs)
private
Returns TrackHitFilter module name.

Arguments:
- `kwargs`: Not used in this function.

Definition at line 360 of file trackselectionRefitting.py.

360 def _TrackHitFilter(kwargs):
361  """Returns TrackHitFilter module name.
362 
363  Arguments:
364  - `kwargs`: Not used in this function.
365  """
366 
367  return ("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
368  "TrackerTrackHitFilter")
369 
370 
def trackselectionRefitting._TrackRefitter (   kwargs)
private
Returns TrackRefitter module name.

Arguments:
- `kwargs`: Used to supply options at construction time of the object.

Definition at line 398 of file trackselectionRefitting.py.

398 def _TrackRefitter(kwargs):
399  """Returns TrackRefitter module name.
400 
401  Arguments:
402  - `kwargs`: Used to supply options at construction time of the object.
403  """
404 
405  isCosmics = kwargs.get("isCosmics", False)
406  if isCosmics:
407  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
408  "TrackRefitterP5")
409  else:
410  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
411  "TrackRefitter")
412 
def trackselectionRefitting._TrackSelector (   kwargs)
private
Returns TrackSelector module name.

Arguments:
- `kwargs`: Not used in this function.

Definition at line 371 of file trackselectionRefitting.py.

371 def _TrackSelector(kwargs):
372  """Returns TrackSelector module name.
373 
374  Arguments:
375  - `kwargs`: Not used in this function.
376  """
377 
378  return ("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
379  "AlignmentTrackSelector")
380 
381 
def trackselectionRefitting._TrackSplitting (   kwargs)
private

Definition at line 413 of file trackselectionRefitting.py.

413 def _TrackSplitting(kwargs):
414  return ("RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi",
415  "cosmicTrackSplitter")
416 
417 
def trackselectionRefitting.getSequence (   process,
  collection,
  saveCPU = False,
  TTRHBuilder = "WithAngleAndTemplate",
  usePixelQualityFlag = None,
  openMassWindow = False,
  cosmicsDecoMode = False,
  cosmicsZeroTesla = True,
  momentumConstraint = None,
  cosmicTrackSplitting = False,
  use_d0cut = True 
)
This function returns a cms.Sequence containing as last element the
module 'FinalTrackRefitter', which can be used as cms.InputTag for
subsequent processing steps.
The modules in the sequence are already attached to the given `process`
object using the given track collection `collection` and the given
optional arguments.

Arguments:
- `process`: 'cms.Process' object to which the modules of the sequence will
             be attached.
- `collection`: String indicating the input track collection.
- `saveCPU`: If set to 'True', some steps are merged to reduce CPU time.
             Reduces a little the accuracy of the results.
             This option is currently not recommended.
- `TTRHBuilder`: Option used for the Track(Re)Fitter modules.
- `usePixelQualityFlag`: Option used for the TrackHitFilter module.
                         Defaults to 'True' but is automatically set to
                         'False' if a `TTRHBuilder` without templates is
                         used.
                         If this is still wanted for some reason, one can
                         explicitely specify it as 'True'.
- `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu.
- `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used.
- `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used.
- `momentumConstraint`: If you want to apply a momentum constraint for the
                        track refitting, e.g. for CRUZET data, you need
                        to provide here the name of the constraint module.
- `cosmicTrackSplitting`: If set to 'True' cosmic tracks are split before the
                          second track refitter.
- `use_d0cut`: If 'True' (default), apply a cut |d0| < 50.

Definition at line 15 of file trackselectionRefitting.py.

References _getModule(), reco.get(), join(), and update.

15  use_d0cut = True):
16  """This function returns a cms.Sequence containing as last element the
17  module 'FinalTrackRefitter', which can be used as cms.InputTag for
18  subsequent processing steps.
19  The modules in the sequence are already attached to the given `process`
20  object using the given track collection `collection` and the given
21  optional arguments.
22 
23  Arguments:
24  - `process`: 'cms.Process' object to which the modules of the sequence will
25  be attached.
26  - `collection`: String indicating the input track collection.
27  - `saveCPU`: If set to 'True', some steps are merged to reduce CPU time.
28  Reduces a little the accuracy of the results.
29  This option is currently not recommended.
30  - `TTRHBuilder`: Option used for the Track(Re)Fitter modules.
31  - `usePixelQualityFlag`: Option used for the TrackHitFilter module.
32  Defaults to 'True' but is automatically set to
33  'False' if a `TTRHBuilder` without templates is
34  used.
35  If this is still wanted for some reason, one can
36  explicitely specify it as 'True'.
37  - `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu.
38  - `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used.
39  - `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used.
40  - `momentumConstraint`: If you want to apply a momentum constraint for the
41  track refitting, e.g. for CRUZET data, you need
42  to provide here the name of the constraint module.
43  - `cosmicTrackSplitting`: If set to 'True' cosmic tracks are split before the
44  second track refitter.
45  - `use_d0cut`: If 'True' (default), apply a cut |d0| < 50.
46  """
47 
48  ###################################################
49  # resolve default values incl. consistency checks #
50  ###################################################
51 
52  if usePixelQualityFlag is None:
53  if "Template" not in TTRHBuilder:
54  usePixelQualityFlag = False # not defined without templates
55  print "Using 'TTRHBuilder' without templates:", TTRHBuilder
56  print " --> Turning off pixel quality flag in hit filter."
57  else:
58  usePixelQualityFlag = True # default for usage with templates
59 
60 
61  #############################
62  ## setting general options ##
63  #############################
64 
65  options = {"TrackHitFilter": {},
66  "TrackFitter": {},
67  "TrackRefitter": {},
68  "TrackSelector": {}}
69 
70  options["TrackSelector"]["HighPurity"] = {
71  "trackQualities": ["highPurity"],
72  "filter": True,
73  "etaMin": -3.0,
74  "etaMax": 3.0,
75  "pMin": 8.0
76  }
77  options["TrackSelector"]["Alignment"] = {
78  "filter": True,
79  "pMin": 3.0,
80  "nHitMin2D": 2,
81  "d0Min": -50.0,
82  "d0Max": 50.0,
83  "etaMin": -3.0,
84  "etaMax": 3.0,
85  "nHitMin": 8,
86  "chi2nMax": 9999.0
87  }
88  options["TrackRefitter"]["First"] = {
89  "NavigationSchool": "",
90  "TTRHBuilder": TTRHBuilder,
91  }
92  options["TrackRefitter"]["Second"] = {
93  "NavigationSchool": "",
94  "TTRHBuilder": TTRHBuilder,
95  }
96  options["TrackHitFilter"]["Tracker"] = {
97  "useTrajectories": True,
98  "minimumHits": 8,
99  "commands": cms.vstring("keep PXB", "keep PXE", "keep TIB", "keep TID",
100  "keep TOB", "keep TEC"),
101  "replaceWithInactiveHits": True,
102  "rejectBadStoNHits": True,
103  "rejectLowAngleHits": True,
104  "usePixelQualityFlag": usePixelQualityFlag,
105  "StoNcommands": cms.vstring("ALL 12.0"),
106  "TrackAngleCut": 0.087,
107  }
108  options["TrackFitter"]["HitFilteredTracks"] = {
109  "NavigationSchool": "",
110  "TTRHBuilder": TTRHBuilder,
111  }
112 
113 
114  #########################################
115  ## setting collection specific options ##
116  #########################################
117  isCosmics = False
118 
119  if collection in ("ALCARECOTkAlMinBias", "generalTracks",
120  "ALCARECOTkAlMinBiasHI", "hiGeneralTracks"):
121  options["TrackSelector"]["Alignment"].update({
122  "ptMin": 1.0,
123  "pMin": 8.,
124  })
125  options["TrackHitFilter"]["Tracker"].update({
126  "minimumHits": 10,
127  })
128  elif collection in ("ALCARECOTkAlCosmicsCTF0T",
129  "ALCARECOTkAlCosmicsInCollisions"):
130  isCosmics = True
131  options["TrackSelector"]["HighPurity"] = {} # drop high purity cut
132  if not cosmicsDecoMode:
133  options["TrackHitFilter"]["Tracker"].update({
134  "StoNcommands": cms.vstring("ALL 18.0")
135  })
136  if cosmicsZeroTesla:
137  options["TrackHitFilter"]["Tracker"].update({
138  "TrackAngleCut": 0.1 # Run-I: 0.087 for 0T
139  })
140  else:
141  options["TrackHitFilter"]["Tracker"].update({
142  "TrackAngleCut": 0.1 # Run-I: 0.35 for 3.8T
143  })
144  options["TrackSelector"]["Alignment"].update({
145  "pMin": 4.0,
146  "etaMin": -99.0,
147  "etaMax": 99.0,
148  "applyMultiplicityFilter": True,
149  "maxMultiplicity": 1
150  })
151  if cosmicTrackSplitting:
152  options["TrackSplitting"] = {}
153  options["TrackSplitting"]["TrackSplitting"] = {}
154  if not use_d0cut:
155  options["TrackSelector"]["Alignment"].update({
156  "d0Min": -99999.0,
157  "d0Max": 99999.0,
158  })
159  elif collection in ("ALCARECOTkAlMuonIsolated",
160  "ALCARECOTkAlMuonIsolatedHI",
161  "ALCARECOTkAlMuonIsolatedPA"):
162  options["TrackSelector"]["Alignment"].update({
163  ("minHitsPerSubDet", "inPIXEL"): 1,
164  "ptMin": 5.0,
165  "nHitMin": 10,
166  "applyMultiplicityFilter": True,
167  "maxMultiplicity": 1,
168  })
169  elif collection in ("ALCARECOTkAlZMuMu",
170  "ALCARECOTkAlZMuMuHI",
171  "ALCARECOTkAlZMuMuPA"):
172  options["TrackSelector"]["Alignment"].update({
173  "ptMin": 15.0,
174  "etaMin": -3.0,
175  "etaMax": 3.0,
176  "nHitMin": 10,
177  "applyMultiplicityFilter": True,
178  "minMultiplicity": 2,
179  "maxMultiplicity": 2,
180  ("minHitsPerSubDet", "inPIXEL"): 1,
181  ("TwoBodyDecaySelector", "applyChargeFilter"): True,
182  ("TwoBodyDecaySelector", "charge"): 0,
183  ("TwoBodyDecaySelector",
184  "applyMassrangeFilter"): not openMassWindow,
185  ("TwoBodyDecaySelector", "minXMass"): 85.8,
186  ("TwoBodyDecaySelector", "maxXMass"): 95.8,
187  ("TwoBodyDecaySelector", "daughterMass"): 0.105
188  })
189  options["TrackHitFilter"]["Tracker"].update({
190  "minimumHits": 10,
191  })
192  elif collection == "ALCARECOTkAlUpsilonMuMu":
193  options["TrackSelector"]["Alignment"].update({
194  "ptMin": 3.0,
195  "etaMin": -2.4,
196  "etaMax": 2.4,
197  "nHitMin": 10,
198  "applyMultiplicityFilter": True,
199  "minMultiplicity": 2,
200  "maxMultiplicity": 2,
201  ("minHitsPerSubDet", "inPIXEL"): 1,
202  ("TwoBodyDecaySelector", "applyChargeFilter"): True,
203  ("TwoBodyDecaySelector", "charge"): 0,
204  ("TwoBodyDecaySelector",
205  "applyMassrangeFilter"): not openMassWindow,
206  ("TwoBodyDecaySelector", "minXMass"): 9.2,
207  ("TwoBodyDecaySelector", "maxXMass"): 9.7,
208  ("TwoBodyDecaySelector", "daughterMass"): 0.105
209  })
210  options["TrackHitFilter"]["Tracker"].update({
211  "minimumHits": 10,
212  })
213  else:
214  raise ValueError("Unknown input track collection: {}".format(collection))
215 
216  if cosmicTrackSplitting and not isCosmics:
217  raise ValueError("Can only do cosmic track splitting for cosmics.")
218 
219 
220 
221  ####################
222  ## save CPU time? ##
223  ####################
224 
225  if saveCPU:
226  if cosmicTrackSplitting:
227  raise ValueError("Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
228  mods = [("TrackSelector", "Alignment", {"method": "load"}),
229  ("TrackRefitter", "First", {"method": "load",
230  "clone": True}),
231  ("TrackHitFilter", "Tracker", {"method": "load"}),
232  ("TrackFitter", "HitFilteredTracks", {"method": "import"})]
233  options["TrackSelector"]["Alignment"].update(
234  options["TrackSelector"]["HighPurity"])
235  elif cosmicTrackSplitting:
236  mods = [("TrackRefitter", "First", {"method": "load",
237  "clone": True}),
238  ("TrackSelector", "Alignment", {"method": "load"}),
239  ("TrackSplitting", "TrackSplitting", {"method": "load"}),
240  ("TrackFitter", "HitFilteredTracks", {"method": "import"}),
241  ("TrackRefitter", "Second", {"method": "load",
242  "clone": True})]
243  else:
244  mods = [("TrackSelector", "HighPurity", {"method": "import"}),
245  ("TrackRefitter", "First", {"method": "load",
246  "clone": True}),
247  ("TrackHitFilter", "Tracker", {"method": "load"}),
248  ("TrackFitter", "HitFilteredTracks", {"method": "import"}),
249  ("TrackSelector", "Alignment", {"method": "load"}),
250  ("TrackRefitter", "Second", {"method": "load",
251  "clone": True})]
252  if isCosmics: mods = mods[1:] # skip high purity selector for cosmics
253 
254 
255  ################################
256  ## apply momentum constraint? ##
257  ################################
258 
259  if momentumConstraint is not None:
260  for mod in options["TrackRefitter"]:
261  options["TrackRefitter"][mod].update({
262  "constraint": "momentum",
263  "srcConstr": momentumConstraint
264  })
265 
266 
267 
268  #######################################################
269  # load offline beam spot module required by the refit #
270  #######################################################
271  process.load("RecoVertex.BeamSpotProducer.BeamSpot_cff")
272 
273 
274 
275  ###############################
276  ## put the sequence together ##
277  ###############################
278 
279  modules = []
280  src = collection
281  prevsrc = None
282  for mod in mods[:-1]:
283  src, prevsrc = _getModule(process, src, mod[0], "".join(reversed(mod[:-1])),
284  options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
285  **(mod[2])), src
286  modules.append(getattr(process, src))
287  else:
288  if mods[-1][-1]["method"] is "load" and \
289  not mods[-1][-1].get("clone", False):
290  print "Name of the last module needs to be modifiable."
291  sys.exit(1)
292  src = _getModule(process, src, mods[-1][0], "FinalTrackRefitter",
293  options[mods[-1][0]][mods[-1][1]],
294  isCosmics = isCosmics, **(mods[-1][2]))
295  modules.append(getattr(process, src))
296 
297  moduleSum = process.offlineBeamSpot # first element of the sequence
298  for module in modules: moduleSum += module # append the other modules
299 
300  return cms.Sequence(moduleSum)
301 
302 
303 
304 
305 
def _getModule(process, src, modType, moduleName, options, kwargs)
Auxiliary functions ###
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
#define update(a, b)
T get(const Candidate &c)
Definition: component.h:55