CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
trackselectionRefitting Namespace Reference

Functions

def _customSetattr
 
def _getModule
 
                  ###

Auxiliary functions ###

More...
 
def _TrackFitter
 
def _TrackHitFilter
 
def _TrackRefitter
 
def _TrackSelector
 
def getSequence
 

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 315 of file trackselectionRefitting.py.

Referenced by _getModule().

316 def _customSetattr(obj, attr, val):
317  """Sets the attribute `attr` of the object `obj` using the value `val`.
318  `attr` can be a string or a tuple of strings, if one wants to set an
319  attribute of an attribute, etc.
320 
321  Arguments:
322  - `obj`: Object, which must have a '__dict__' attribute.
323  - `attr`: String or tuple of strings describing the attribute's name.
324  - `val`: value of the attribute.
325  """
326 
327  if type(attr) is tuple and len(attr) > 1:
328  _customSetattr(getattr(obj, attr[0]), attr[1:], val)
329  else:
330  if type(attr) is tuple: attr = attr[0]
331  setattr(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 223 of file trackselectionRefitting.py.

References _customSetattr(), and clone().

Referenced by getSequence().

224 def _getModule(process, src, modType, moduleName, options, **kwargs):
225  """General function for attaching the module of type `modType` to the
226  cms.Process `process` using `options` for customization and `moduleName` as
227  the name of the new attribute of `process`.
228 
229  Arguments:
230  - `process`: 'cms.Process' object to which the module is attached.
231  - `src`: cms.InputTag for this module.
232  - `modType`: Type of the requested module.
233  - `options`: Dictionary with customized values for the module's options.
234  - `**kwargs`: Used to supply options at construction time of the module.
235  """
236 
237  objTuple = globals()["_"+modType](kwargs)
238  method = kwargs.get("method")
239  if method is "import":
240  __import__(objTuple[0])
241  obj = getattr(sys.modules[objTuple[0]], objTuple[1]).clone(src=src)
242  elif method is "load":
243  process.load(objTuple[0])
244  if kwargs.get("clone", False):
245  obj = getattr(process, objTuple[1]).clone(src=src)
246  else:
247  obj = getattr(process, objTuple[1])
248  obj.src = src
249  moduleName = objTuple[1]
250  else:
251  print "Unknown method:", method
252  sys.exit(1)
253 
254  for option in options:
255  _customSetattr(obj, option, options[option])
256 
257  if moduleName is not objTuple[1]:
258  setattr(process, moduleName, obj)
259  return moduleName
260 
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
def _getModule
### Auxiliary functions ###
def trackselectionRefitting._TrackFitter (   kwargs)
private
Returns TrackFitter module name.

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

Definition at line 283 of file trackselectionRefitting.py.

284 def _TrackFitter(kwargs):
285  """Returns TrackFitter module name.
286 
287  Arguments:
288  - `kwargs`: Used to supply options at construction time of the object.
289  """
290 
291  isCosmics = kwargs.get("isCosmics", False)
292  if isCosmics:
293  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
294  "ctfWithMaterialTracksCosmics")
295  else:
296  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
297  "ctfWithMaterialTracks")
298 
def trackselectionRefitting._TrackHitFilter (   kwargs)
private
Returns TrackHitFilter module name.

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

Definition at line 261 of file trackselectionRefitting.py.

262 def _TrackHitFilter(kwargs):
263  """Returns TrackHitFilter module name.
264 
265  Arguments:
266  - `kwargs`: Not used in this function.
267  """
268 
269  return ("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
270  "TrackerTrackHitFilter")
271 
def trackselectionRefitting._TrackRefitter (   kwargs)
private
Returns TrackRefitter module name.

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

Definition at line 299 of file trackselectionRefitting.py.

300 def _TrackRefitter(kwargs):
301  """Returns TrackRefitter module name.
302 
303  Arguments:
304  - `kwargs`: Used to supply options at construction time of the object.
305  """
306 
307  isCosmics = kwargs.get("isCosmics", False)
308  if isCosmics:
309  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
310  "TrackRefitterP5")
311  else:
312  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
313  "TrackRefitter")
314 
def trackselectionRefitting._TrackSelector (   kwargs)
private
Returns TrackSelector module name.

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

Definition at line 272 of file trackselectionRefitting.py.

273 def _TrackSelector(kwargs):
274  """Returns TrackSelector module name.
275 
276  Arguments:
277  - `kwargs`: Not used in this function.
278  """
279 
280  return ("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
281  "AlignmentTrackSelector")
282 
def trackselectionRefitting.getSequence (   process,
  collection,
  saveCPU = False,
  TTRHBuilder = "WithAngleAndTemplate",
  usePixelQualityFlag = True,
  openMassWindow = False,
  cosmicsDecoMode = False,
  cosmicsZeroTesla = True,
  momentumConstraint = None 
)
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
optionial 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.
- `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.

Definition at line 13 of file trackselectionRefitting.py.

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

13 
14  momentumConstraint = None):
15  """This function returns a cms.Sequence containing as last element the
16  module 'FinalTrackRefitter', which can be used as cms.InputTag for
17  subsequent processing steps.
18  The modules in the sequence are already attached to the given `process`
19  object using the given track collection `collection` and the given
20  optionial arguments.
21 
22  Arguments:
23  - `process`: 'cms.Process' object to which the modules of the sequence will
24  be attached.
25  - `collection`: String indicating the input track collection.
26  - `saveCPU`: If set to 'True', some steps are merged to reduce CPU time.
27  Reduces a little the accuracy of the results.
28  This option is currently not recommended.
29  - `TTRHBuilder`: Option used for the Track(Re)Fitter modules.
30  - `usePixelQualityFlag`: Option used for the TrackHitFilter module.
31  - `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu.
32  - `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used.
33  - `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used.
34  - `momentumConstraint`: If you want to apply a momentum constraint for the
35  track refitting, e.g. for CRUZET data, you need
36  to provide here the name of the constraint module.
37  """
38 
39 
40  #############################
41  ## setting general options ##
42  #############################
43 
44  options = {"TrackHitFilter": {},
45  "TrackFitter": {},
46  "TrackRefitter": {},
47  "TrackSelector": {}}
48 
49  options["TrackSelector"]["HighPurity"] = {
50  "trackQualities": ["highPurity"],
51  "filter": True,
52  "etaMin": -3.0,
53  "etaMax": 3.0
54  }
55  options["TrackSelector"]["Alignment"] = {
56  "filter": True,
57  "pMin": 3.0,
58  "nHitMin2D": 3,
59  "d0Min": -50.0,
60  "d0Max": 50.0,
61  "etaMin": -3.0,
62  "etaMax": 3.0,
63  "nHitMin": 8,
64  "chi2nMax": 9999.0
65  }
66  options["TrackRefitter"]["First"] = {
67  "NavigationSchool": "",
68  }
69  options["TrackRefitter"]["Second"] = {
70  "NavigationSchool": "",
71  "TTRHBuilder": TTRHBuilder
72  }
73  options["TrackHitFilter"]["Tracker"] = {
74  "useTrajectories": True,
75  "minimumHits": 8,
76  "commands": cms.vstring("keep PXB", "keep PXE", "keep TIB", "keep TID",
77  "keep TOB", "keep TEC"),
78  "replaceWithInactiveHits": True,
79  "rejectBadStoNHits": True,
80  "rejectLowAngleHits": True,
81  "usePixelQualityFlag": usePixelQualityFlag,
82  "StoNcommands": cms.vstring("ALL 12.0"),
83  "TrackAngleCut": 0.17
84  }
85  options["TrackFitter"]["HitFilteredTracks"] = {
86  "NavigationSchool": "",
87  "TTRHBuilder": TTRHBuilder
88  }
89 
90 
91  #########################################
92  ## setting collection specific options ##
93  #########################################
94  isCosmics = False
95 
96  if collection is "ALCARECOTkAlMinBias":
97  options["TrackSelector"]["Alignment"].update({
98  "ptMin": 1.0,
99  })
100  elif collection is "ALCARECOTkAlCosmicsCTF0T":
101  isCosmics = True
102  options["TrackSelector"]["HighPurity"] = {} # drop high purity cut
103  if not cosmicsDecoMode:
104  options["TrackHitFilter"]["Tracker"].update({
105  "StoNcommands": cms.vstring("ALL 18.0")
106  })
107  if cosmicsZeroTesla:
108  options["TrackHitFilter"]["Tracker"].update({
109  "TrackAngleCut": 0.087 # Run-I: 0.087 for 0T
110  })
111  else:
112  options["TrackHitFilter"]["Tracker"].update({
113  "TrackAngleCut": 0.087 # Run-I: 0.35 for 3.8T
114  })
115  options["TrackSelector"]["Alignment"].update({
116  "pMin": 4.0,
117  "etaMin": -99.0,
118  "etaMax": 99.0
119  })
120  elif collection is "ALCARECOTkAlMuonIsolated":
121  options["TrackSelector"]["Alignment"].update({
122  ("minHitsPerSubDet", "inPIXEL"): 1,
123  })
124  elif collection is "ALCARECOTkAlZMuMu":
125  options["TrackSelector"]["Alignment"].update({
126  "ptMin": 15.0,
127  "etaMin": -3.0,
128  "etaMax": 3.0,
129  "nHitMin": 10,
130  "applyMultiplicityFilter": True,
131  "minMultiplicity": 2,
132  "maxMultiplicity": 2,
133  ("minHitsPerSubDet", "inPIXEL"): 1,
134  ("TwoBodyDecaySelector", "applyChargeFilter"): True,
135  ("TwoBodyDecaySelector",
136  "applyMassrangeFilter"): not openMassWindow,
137  ("TwoBodyDecaySelector", "minXMass"): 85.8,
138  ("TwoBodyDecaySelector", "maxXMass"): 95.8
139  })
140  pass
141  else:
142  print "Unknown input track collection:", collection
143  sys.exit(1)
144 
145 
146 
147  ####################
148  ## save CPU time? ##
149  ####################
150 
151  if saveCPU:
152  mods = [("TrackSelector", "Alignment", {"method": "load"}),
153  ("TrackRefitter", "First", {"method": "load",
154  "clone": True}),
155  ("TrackHitFilter", "Tracker", {"method": "load"}),
156  ("TrackFitter", "HitFilteredTracks", {"method": "import"})]
157  options["TrackSelector"]["Alignment"].update(
158  options["TrackSelector"]["HighPurity"])
159  else:
160  mods = [("TrackSelector", "HighPurity", {"method": "import"}),
161  ("TrackRefitter", "First", {"method": "load",
162  "clone": True}),
163  ("TrackHitFilter", "Tracker", {"method": "load"}),
164  ("TrackFitter", "HitFilteredTracks", {"method": "import"}),
165  ("TrackSelector", "Alignment", {"method": "load"}),
166  ("TrackRefitter", "Second", {"method": "load",
167  "clone": True})]
168  if isCosmics: mods = mods[1:]
169 
170 
171 
172  ################################
173  ## apply momentum constraint? ##
174  ################################
175 
176  if momentumConstraint is not None:
177  for mod in options["TrackRefitter"]:
178  options["TrackRefitter"][mod].update({
179  "constraint": "momentum",
180  "srcConstr": momentumConstraint
181  })
182 
183 
184 
185  ###############################
186  ## put the sequence together ##
187  ###############################
188 
189  modules = []
190  src = collection
191  for mod in mods[:-1]:
192  src = _getModule(process, src, mod[0], "".join(reversed(mod[:-1])),
193  options[mod[0]][mod[1]], isCosmics = isCosmics,
194  **(mod[2]))
195  modules.append(getattr(process, src))
196  else:
197  if mods[-1][-1]["method"] is "load" and \
198  not mods[-1][-1].get("clone", False):
199  print "Name of the last module needs to be modifiable."
200  sys.exit(1)
201  src = _getModule(process, src, mods[-1][0], "FinalTrackRefitter",
202  options[mods[-1][0]][mods[-1][1]],
203  isCosmics = isCosmics, **(mods[-1][2]))
204  modules.append(getattr(process, src))
205 
206  moduleSum = modules[0]
207  for mod in modules[1:]:
208  moduleSum += mod
209  return cms.Sequence(moduleSum)
210 
211 
212 
213 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
#define update(a, b)
def _getModule
### Auxiliary functions ###
T get(const Candidate &c)
Definition: component.h:55