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

Referenced by _getModule().

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

References _customSetattr(), and clone().

Referenced by getSequence().

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

301 def _TrackFitter(kwargs):
302  """Returns TrackFitter module name.
303 
304  Arguments:
305  - `kwargs`: Used to supply options at construction time of the object.
306  """
307 
308  isCosmics = kwargs.get("isCosmics", False)
309  if isCosmics:
310  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
311  "ctfWithMaterialTracksCosmics")
312  else:
313  return ("RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
314  "ctfWithMaterialTracks")
315 
def trackselectionRefitting._TrackHitFilter (   kwargs)
private
Returns TrackHitFilter module name.

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

Definition at line 278 of file trackselectionRefitting.py.

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

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

Definition at line 316 of file trackselectionRefitting.py.

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

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

Definition at line 289 of file trackselectionRefitting.py.

290 def _TrackSelector(kwargs):
291  """Returns TrackSelector module name.
292 
293  Arguments:
294  - `kwargs`: Not used in this function.
295  """
296 
297  return ("Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
298  "AlignmentTrackSelector")
299 
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" or collection == "ALCARECOTkAlMinBiasHI" or collection == "hiGeneralTracks":
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 in ("ALCARECOTkAlCosmicsCTF0T",
106  "ALCARECOTkAlCosmicsInCollisions"):
107  isCosmics = True
108  options["TrackSelector"]["HighPurity"] = {} # drop high purity cut
109  if not cosmicsDecoMode:
110  options["TrackHitFilter"]["Tracker"].update({
111  "StoNcommands": cms.vstring("ALL 18.0")
112  })
113  if cosmicsZeroTesla:
114  options["TrackHitFilter"]["Tracker"].update({
115  "TrackAngleCut": 0.1 # Run-I: 0.087 for 0T
116  })
117  else:
118  options["TrackHitFilter"]["Tracker"].update({
119  "TrackAngleCut": 0.1 # Run-I: 0.35 for 3.8T
120  })
121  options["TrackSelector"]["Alignment"].update({
122  "pMin": 4.0,
123  "etaMin": -99.0,
124  "etaMax": 99.0,
125  "applyMultiplicityFilter": True,
126  "maxMultiplicity": 1
127  })
128  elif collection == "ALCARECOTkAlMuonIsolated" or collection == "ALCARECOTkAlMuonIsolatedHI" or collection == "ALCARECOTkAlMuonIsolatedPA":
129  options["TrackSelector"]["Alignment"].update({
130  ("minHitsPerSubDet", "inPIXEL"): 1,
131  "ptMin": 5.0,
132  "nHitMin": 10,
133  "applyMultiplicityFilter": True,
134  "maxMultiplicity": 1,
135  })
136  elif collection == "ALCARECOTkAlZMuMu" or collection == "ALCARECOTkAlZMuMuHI" or collection == "ALCARECOTkAlZMuMuPA":
137  options["TrackSelector"]["Alignment"].update({
138  "ptMin": 15.0,
139  "etaMin": -3.0,
140  "etaMax": 3.0,
141  "nHitMin": 10,
142  "applyMultiplicityFilter": True,
143  "minMultiplicity": 2,
144  "maxMultiplicity": 2,
145  ("minHitsPerSubDet", "inPIXEL"): 1,
146  ("TwoBodyDecaySelector", "applyChargeFilter"): True,
147  ("TwoBodyDecaySelector", "charge"): 0,
148  ("TwoBodyDecaySelector",
149  "applyMassrangeFilter"): not openMassWindow,
150  ("TwoBodyDecaySelector", "minXMass"): 85.8,
151  ("TwoBodyDecaySelector", "maxXMass"): 95.8,
152  ("TwoBodyDecaySelector", "daughterMass"): 0.105
153  })
154  options["TrackHitFilter"]["Tracker"].update({
155  "minimumHits": 10,
156  })
157  pass
158  else:
159  print "Unknown input track collection:", collection
160  sys.exit(1)
161 
162 
163 
164  ####################
165  ## save CPU time? ##
166  ####################
167 
168  if saveCPU:
169  mods = [("TrackSelector", "Alignment", {"method": "load"}),
170  ("TrackRefitter", "First", {"method": "load",
171  "clone": True}),
172  ("TrackHitFilter", "Tracker", {"method": "load"}),
173  ("TrackFitter", "HitFilteredTracks", {"method": "import"})]
174  options["TrackSelector"]["Alignment"].update(
175  options["TrackSelector"]["HighPurity"])
176  else:
177  mods = [("TrackSelector", "HighPurity", {"method": "import"}),
178  ("TrackRefitter", "First", {"method": "load",
179  "clone": True}),
180  ("TrackHitFilter", "Tracker", {"method": "load"}),
181  ("TrackFitter", "HitFilteredTracks", {"method": "import"}),
182  ("TrackSelector", "Alignment", {"method": "load"}),
183  ("TrackRefitter", "Second", {"method": "load",
184  "clone": True})]
185  if isCosmics: mods = mods[1:]
186 
187 
188 
189  ################################
190  ## apply momentum constraint? ##
191  ################################
192 
193  if momentumConstraint is not None:
194  for mod in options["TrackRefitter"]:
195  options["TrackRefitter"][mod].update({
196  "constraint": "momentum",
197  "srcConstr": momentumConstraint
198  })
199 
200 
201 
202  ###############################
203  ## put the sequence together ##
204  ###############################
205 
206  modules = []
207  src = collection
208  for mod in mods[:-1]:
209  src = _getModule(process, src, mod[0], "".join(reversed(mod[:-1])),
210  options[mod[0]][mod[1]], isCosmics = isCosmics,
211  **(mod[2]))
212  modules.append(getattr(process, src))
213  else:
214  if mods[-1][-1]["method"] is "load" and \
215  not mods[-1][-1].get("clone", False):
216  print "Name of the last module needs to be modifiable."
217  sys.exit(1)
218  src = _getModule(process, src, mods[-1][0], "FinalTrackRefitter",
219  options[mods[-1][0]][mods[-1][1]],
220  isCosmics = isCosmics, **(mods[-1][2]))
221  modules.append(getattr(process, src))
222 
223  moduleSum = modules[0]
224  for mod in modules[1:]:
225  moduleSum += mod
226  return cms.Sequence(moduleSum)
227 
228 
229 
230 
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