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

Referenced by _getModule().

305 def _customSetattr(obj, attr, val):
306  """Sets the attribute `attr` of the object `obj` using the value `val`.
307  `attr` can be a string or a tuple of strings, if one wants to set an
308  attribute of an attribute, etc.
309 
310  Arguments:
311  - `obj`: Object, which must have a '__dict__' attribute.
312  - `attr`: String or tuple of strings describing the attribute's name.
313  - `val`: value of the attribute.
314  """
315 
316  if type(attr) is tuple and len(attr) > 1:
317  _customSetattr(getattr(obj, attr[0]), attr[1:], val)
318  else:
319  if type(attr) is tuple: attr = attr[0]
320  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 212 of file trackselectionRefitting.py.

References _customSetattr(), and clone().

Referenced by getSequence().

213 def _getModule(process, src, modType, moduleName, options, **kwargs):
214  """General function for attaching the module of type `modType` to the
215  cms.Process `process` using `options` for customization and `moduleName` as
216  the name of the new attribute of `process`.
217 
218  Arguments:
219  - `process`: 'cms.Process' object to which the module is attached.
220  - `src`: cms.InputTag for this module.
221  - `modType`: Type of the requested module.
222  - `options`: Dictionary with customized values for the module's options.
223  - `**kwargs`: Used to supply options at construction time of the module.
224  """
225 
226  objTuple = globals()["_"+modType](kwargs)
227  method = kwargs.get("method")
228  if method is "import":
229  __import__(objTuple[0])
230  obj = getattr(sys.modules[objTuple[0]], objTuple[1]).clone(src=src)
231  elif method is "load":
232  process.load(objTuple[0])
233  if kwargs.get("clone", False):
234  obj = getattr(process, objTuple[1]).clone(src=src)
235  else:
236  obj = getattr(process, objTuple[1])
237  obj.src = src
238  moduleName = objTuple[1]
239  else:
240  print "Unknown method:", method
241  sys.exit(1)
242 
243  for option in options:
244  _customSetattr(obj, option, options[option])
245 
246  if moduleName is not objTuple[1]:
247  setattr(process, moduleName, obj)
248  return moduleName
249 
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 272 of file trackselectionRefitting.py.

273 def _TrackFitter(kwargs):
274  """Returns TrackFitter module name.
275 
276  Arguments:
277  - `kwargs`: Used to supply options at construction time of the object.
278  """
279 
280  isCosmics = kwargs.get("isCosmics", False)
281  if isCosmics:
282  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
283  "ctfWithMaterialTracksCosmics")
284  else:
285  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
286  "ctfWithMaterialTracks")
287 
def trackselectionRefitting._TrackHitFilter (   kwargs)
private
Returns TrackHitFilter module name.

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

Definition at line 250 of file trackselectionRefitting.py.

251 def _TrackHitFilter(kwargs):
252  """Returns TrackHitFilter module name.
253 
254  Arguments:
255  - `kwargs`: Not used in this function.
256  """
257 
258  return ("RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
259  "TrackerTrackHitFilter")
260 
def trackselectionRefitting._TrackRefitter (   kwargs)
private
Returns TrackRefitter module name.

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

Definition at line 288 of file trackselectionRefitting.py.

289 def _TrackRefitter(kwargs):
290  """Returns TrackRefitter module name.
291 
292  Arguments:
293  - `kwargs`: Used to supply options at construction time of the object.
294  """
295 
296  isCosmics = kwargs.get("isCosmics", False)
297  if isCosmics:
298  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
299  "TrackRefitterP5")
300  else:
301  return ("RecoTracker.TrackProducer.TrackRefitters_cff",
302  "TrackRefitter")
303 
def trackselectionRefitting._TrackSelector (   kwargs)
private
Returns TrackSelector module name.

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

Definition at line 261 of file trackselectionRefitting.py.

262 def _TrackSelector(kwargs):
263  """Returns TrackSelector module name.
264 
265  Arguments:
266  - `kwargs`: Not used in this function.
267  """
268 
269  return ("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
270  "AlignmentTrackSelector")
271 
def trackselectionRefitting.getSequence (   process,
  collection,
  saveCPU = False,
  TTRHBuilder = "WithAngleAndTemplate",
  usePixelQualityFlag = True,
  openMassWindow = False,
  cosmicsDecoMode = False,
  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.
- `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 12 of file trackselectionRefitting.py.

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

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