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

Referenced by _getModule().

332 def _customSetattr(obj, attr, val):
333  """Sets the attribute `attr` of the object `obj` using the value `val`.
334  `attr` can be a string or a tuple of strings, if one wants to set an
335  attribute of an attribute, etc.
336 
337  Arguments:
338  - `obj`: Object, which must have a '__dict__' attribute.
339  - `attr`: String or tuple of strings describing the attribute's name.
340  - `val`: value of the attribute.
341  """
342 
343  if type(attr) is tuple and len(attr) > 1:
344  _customSetattr(getattr(obj, attr[0]), attr[1:], val)
345  else:
346  if type(attr) is tuple: attr = attr[0]
347  setattr(obj, attr, val)
348 
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 239 of file trackselectionRefitting.py.

References _customSetattr(), and clone().

Referenced by getSequence().

240 def _getModule(process, src, modType, moduleName, options, **kwargs):
241  """General function for attaching the module of type `modType` to the
242  cms.Process `process` using `options` for customization and `moduleName` as
243  the name of the new attribute of `process`.
244 
245  Arguments:
246  - `process`: 'cms.Process' object to which the module is attached.
247  - `src`: cms.InputTag for this module.
248  - `modType`: Type of the requested module.
249  - `options`: Dictionary with customized values for the module's options.
250  - `**kwargs`: Used to supply options at construction time of the module.
251  """
252 
253  objTuple = globals()["_"+modType](kwargs)
254  method = kwargs.get("method")
255  if method is "import":
256  __import__(objTuple[0])
257  obj = getattr(sys.modules[objTuple[0]], objTuple[1]).clone(src=src)
258  elif method is "load":
259  process.load(objTuple[0])
260  if kwargs.get("clone", False):
261  obj = getattr(process, objTuple[1]).clone(src=src)
262  else:
263  obj = getattr(process, objTuple[1])
264  obj.src = src
265  moduleName = objTuple[1]
266  else:
267  print "Unknown method:", method
268  sys.exit(1)
269 
270  for option in options:
271  _customSetattr(obj, option, options[option])
272 
273  if moduleName is not objTuple[1]:
274  setattr(process, moduleName, obj)
275  return moduleName
276 
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 299 of file trackselectionRefitting.py.

300 def _TrackFitter(kwargs):
301  """Returns TrackFitter 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.CTFFinalFitWithMaterialP5_cff",
310  "ctfWithMaterialTracksCosmics")
311  else:
312  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
313  "ctfWithMaterialTracks")
314 
def trackselectionRefitting._TrackHitFilter (   kwargs)
private
Returns TrackHitFilter module name.

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

Definition at line 277 of file trackselectionRefitting.py.

278 def _TrackHitFilter(kwargs):
279  """Returns TrackHitFilter module name.
280 
281  Arguments:
282  - `kwargs`: Not used in this function.
283  """
284 
285  return ("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
286  "TrackerTrackHitFilter")
287 
def trackselectionRefitting._TrackRefitter (   kwargs)
private
Returns TrackRefitter module name.

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

Definition at line 315 of file trackselectionRefitting.py.

316 def _TrackRefitter(kwargs):
317  """Returns TrackRefitter module name.
318 
319  Arguments:
320  - `kwargs`: Used to supply options at construction time of the object.
321  """
322 
323  isCosmics = kwargs.get("isCosmics", False)
324  if isCosmics:
325  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
326  "TrackRefitterP5")
327  else:
328  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
329  "TrackRefitter")
330 
def trackselectionRefitting._TrackSelector (   kwargs)
private
Returns TrackSelector module name.

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

Definition at line 288 of file trackselectionRefitting.py.

289 def _TrackSelector(kwargs):
290  """Returns TrackSelector module name.
291 
292  Arguments:
293  - `kwargs`: Not used in this function.
294  """
295 
296  return ("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
297  "AlignmentTrackSelector")
298 
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  "pMin": 8.0
55  }
56  options["TrackSelector"]["Alignment"] = {
57  "filter": True,
58  "pMin": 3.0,
59  "nHitMin2D": 2,
60  "d0Min": -50.0,
61  "d0Max": 50.0,
62  "etaMin": -3.0,
63  "etaMax": 3.0,
64  "nHitMin": 8,
65  "chi2nMax": 9999.0
66  }
67  options["TrackRefitter"]["First"] = {
68  "NavigationSchool": "",
69  }
70  options["TrackRefitter"]["Second"] = {
71  "NavigationSchool": "",
72  "TTRHBuilder": TTRHBuilder
73  }
74  options["TrackHitFilter"]["Tracker"] = {
75  "useTrajectories": True,
76  "minimumHits": 8,
77  "commands": cms.vstring("keep PXB", "keep PXE", "keep TIB", "keep TID",
78  "keep TOB", "keep TEC"),
79  "replaceWithInactiveHits": True,
80  "rejectBadStoNHits": True,
81  "rejectLowAngleHits": True,
82  "usePixelQualityFlag": usePixelQualityFlag,
83  "StoNcommands": cms.vstring("ALL 12.0"),
84  "TrackAngleCut": 0.087
85  }
86  options["TrackFitter"]["HitFilteredTracks"] = {
87  "NavigationSchool": "",
88  "TTRHBuilder": TTRHBuilder
89  }
90 
91 
92  #########################################
93  ## setting collection specific options ##
94  #########################################
95  isCosmics = False
96 
97  if collection == "ALCARECOTkAlMinBias" or collection == "generalTracks":
98  options["TrackSelector"]["Alignment"].update({
99  "ptMin": 1.0,
100  "pMin": 8.,
101  })
102  options["TrackHitFilter"]["Tracker"].update({
103  "minimumHits": 10,
104  })
105  elif collection == "ALCARECOTkAlCosmicsCTF0T":
106  isCosmics = True
107  options["TrackSelector"]["HighPurity"] = {} # drop high purity cut
108  if not cosmicsDecoMode:
109  options["TrackHitFilter"]["Tracker"].update({
110  "StoNcommands": cms.vstring("ALL 18.0")
111  })
112  if cosmicsZeroTesla:
113  options["TrackHitFilter"]["Tracker"].update({
114  "TrackAngleCut": 0.1 # Run-I: 0.087 for 0T
115  })
116  else:
117  options["TrackHitFilter"]["Tracker"].update({
118  "TrackAngleCut": 0.1 # Run-I: 0.35 for 3.8T
119  })
120  options["TrackSelector"]["Alignment"].update({
121  "pMin": 4.0,
122  "etaMin": -99.0,
123  "etaMax": 99.0,
124  "applyMultiplicityFilter": True,
125  "maxMultiplicity": 1
126  })
127  elif collection == "ALCARECOTkAlMuonIsolated":
128  options["TrackSelector"]["Alignment"].update({
129  ("minHitsPerSubDet", "inPIXEL"): 1,
130  "ptMin": 5.0,
131  "nHitMin": 10,
132  "applyMultiplicityFilter": True,
133  "maxMultiplicity": 1,
134  })
135  elif collection == "ALCARECOTkAlZMuMu":
136  options["TrackSelector"]["Alignment"].update({
137  "ptMin": 15.0,
138  "etaMin": -3.0,
139  "etaMax": 3.0,
140  "nHitMin": 10,
141  "applyMultiplicityFilter": True,
142  "minMultiplicity": 2,
143  "maxMultiplicity": 2,
144  ("minHitsPerSubDet", "inPIXEL"): 1,
145  ("TwoBodyDecaySelector", "applyChargeFilter"): True,
146  ("TwoBodyDecaySelector", "charge"): 0,
147  ("TwoBodyDecaySelector",
148  "applyMassrangeFilter"): not openMassWindow,
149  ("TwoBodyDecaySelector", "minXMass"): 85.8,
150  ("TwoBodyDecaySelector", "maxXMass"): 95.8,
151  ("TwoBodyDecaySelector", "daughterMass"): 0.105
152  })
153  options["TrackHitFilter"]["Tracker"].update({
154  "minimumHits": 10,
155  })
156  pass
157  else:
158  print "Unknown input track collection:", collection
159  sys.exit(1)
160 
161 
162 
163  ####################
164  ## save CPU time? ##
165  ####################
166 
167  if saveCPU:
168  mods = [("TrackSelector", "Alignment", {"method": "load"}),
169  ("TrackRefitter", "First", {"method": "load",
170  "clone": True}),
171  ("TrackHitFilter", "Tracker", {"method": "load"}),
172  ("TrackFitter", "HitFilteredTracks", {"method": "import"})]
173  options["TrackSelector"]["Alignment"].update(
174  options["TrackSelector"]["HighPurity"])
175  else:
176  mods = [("TrackSelector", "HighPurity", {"method": "import"}),
177  ("TrackRefitter", "First", {"method": "load",
178  "clone": True}),
179  ("TrackHitFilter", "Tracker", {"method": "load"}),
180  ("TrackFitter", "HitFilteredTracks", {"method": "import"}),
181  ("TrackSelector", "Alignment", {"method": "load"}),
182  ("TrackRefitter", "Second", {"method": "load",
183  "clone": True})]
184  if isCosmics: mods = mods[1:]
185 
186 
187 
188  ################################
189  ## apply momentum constraint? ##
190  ################################
191 
192  if momentumConstraint is not None:
193  for mod in options["TrackRefitter"]:
194  options["TrackRefitter"][mod].update({
195  "constraint": "momentum",
196  "srcConstr": momentumConstraint
197  })
198 
199 
200 
201  ###############################
202  ## put the sequence together ##
203  ###############################
204 
205  modules = []
206  src = collection
207  for mod in mods[:-1]:
208  src = _getModule(process, src, mod[0], "".join(reversed(mod[:-1])),
209  options[mod[0]][mod[1]], isCosmics = isCosmics,
210  **(mod[2]))
211  modules.append(getattr(process, src))
212  else:
213  if mods[-1][-1]["method"] is "load" and \
214  not mods[-1][-1].get("clone", False):
215  print "Name of the last module needs to be modifiable."
216  sys.exit(1)
217  src = _getModule(process, src, mods[-1][0], "FinalTrackRefitter",
218  options[mods[-1][0]][mods[-1][1]],
219  isCosmics = isCosmics, **(mods[-1][2]))
220  modules.append(getattr(process, src))
221 
222  moduleSum = modules[0]
223  for mod in modules[1:]:
224  moduleSum += mod
225  return cms.Sequence(moduleSum)
226 
227 
228 
229 
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