2 import FWCore.ParameterSet.Config
as cms
8 TTRHBuilder =
"WithAngleAndTemplate",
9 usePixelQualityFlag =
None,
10 openMassWindow =
False,
11 cosmicsDecoMode =
False,
12 cosmicsZeroTesla =
True,
13 momentumConstraint =
None,
14 cosmicTrackSplitting =
False,
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 24 - `process`: 'cms.Process' object to which the modules of the sequence will 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 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. 52 if usePixelQualityFlag
is None:
53 if "Template" not in TTRHBuilder:
54 usePixelQualityFlag =
False 55 print "Using 'TTRHBuilder' without templates:", TTRHBuilder
56 print " --> Turning off pixel quality flag in hit filter." 58 usePixelQualityFlag =
True 65 options = {
"TrackHitFilter": {},
70 options[
"TrackSelector"][
"HighPurity"] = {
71 "trackQualities": [
"highPurity"],
77 options[
"TrackSelector"][
"Alignment"] = {
88 options[
"TrackRefitter"][
"First"] = {
89 "NavigationSchool":
"",
90 "TTRHBuilder": TTRHBuilder,
92 options[
"TrackRefitter"][
"Second"] = {
93 "NavigationSchool":
"",
94 "TTRHBuilder": TTRHBuilder,
96 options[
"TrackHitFilter"][
"Tracker"] = {
97 "useTrajectories":
True,
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,
108 options[
"TrackFitter"][
"HitFilteredTracks"] = {
109 "NavigationSchool":
"",
110 "TTRHBuilder": TTRHBuilder,
119 if collection
in (
"ALCARECOTkAlMinBias",
"generalTracks",
120 "ALCARECOTkAlMinBiasHI",
"hiGeneralTracks"):
121 options[
"TrackSelector"][
"Alignment"].
update({
125 options[
"TrackHitFilter"][
"Tracker"].
update({
128 elif collection
in (
"ALCARECOTkAlCosmicsCTF0T",
129 "ALCARECOTkAlCosmicsInCollisions"):
131 options[
"TrackSelector"][
"HighPurity"] = {}
132 if not cosmicsDecoMode:
133 options[
"TrackHitFilter"][
"Tracker"].
update({
134 "StoNcommands": cms.vstring(
"ALL 18.0")
137 options[
"TrackHitFilter"][
"Tracker"].
update({
141 options[
"TrackHitFilter"][
"Tracker"].
update({
144 options[
"TrackSelector"][
"Alignment"].
update({
148 "applyMultiplicityFilter":
True,
151 if cosmicTrackSplitting:
152 options[
"TrackSplitting"] = {}
153 options[
"TrackSplitting"][
"TrackSplitting"] = {}
155 options[
"TrackSelector"][
"Alignment"].
update({
159 elif collection
in (
"ALCARECOTkAlMuonIsolated",
160 "ALCARECOTkAlMuonIsolatedHI",
161 "ALCARECOTkAlMuonIsolatedPA"):
162 options[
"TrackSelector"][
"Alignment"].
update({
163 (
"minHitsPerSubDet",
"inPIXEL"): 1,
166 "applyMultiplicityFilter":
True,
167 "maxMultiplicity": 1,
169 elif collection
in (
"ALCARECOTkAlZMuMu",
170 "ALCARECOTkAlZMuMuHI",
171 "ALCARECOTkAlZMuMuPA"):
172 options[
"TrackSelector"][
"Alignment"].
update({
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
189 options[
"TrackHitFilter"][
"Tracker"].
update({
192 elif collection ==
"ALCARECOTkAlUpsilonMuMu":
193 options[
"TrackSelector"][
"Alignment"].
update({
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
210 options[
"TrackHitFilter"][
"Tracker"].
update({
213 elif collection ==
"ALCARECOTkAlJpsiMuMu":
214 options[
"TrackSelector"][
"Alignment"].
update({
219 "applyMultiplicityFilter":
True,
220 "minMultiplicity": 2,
221 "maxMultiplicity": 2,
222 (
"minHitsPerSubDet",
"inPIXEL"): 1,
223 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
224 (
"TwoBodyDecaySelector",
"charge"): 0,
225 (
"TwoBodyDecaySelector",
226 "applyMassrangeFilter"):
not openMassWindow,
227 (
"TwoBodyDecaySelector",
"minXMass"): 2.7,
228 (
"TwoBodyDecaySelector",
"maxXMass"): 3.4,
229 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
231 options[
"TrackHitFilter"][
"Tracker"].
update({
235 raise ValueError(
"Unknown input track collection: {}".
format(collection))
237 if cosmicTrackSplitting
and not isCosmics:
238 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
247 if cosmicTrackSplitting:
248 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
249 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
250 (
"TrackRefitter",
"First", {
"method":
"load",
252 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
253 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
254 options[
"TrackSelector"][
"Alignment"].
update(
255 options[
"TrackSelector"][
"HighPurity"])
256 elif cosmicTrackSplitting:
257 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
259 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
260 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
261 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
262 (
"TrackRefitter",
"Second", {
"method":
"load",
265 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
266 (
"TrackRefitter",
"First", {
"method":
"load",
268 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
269 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
270 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
271 (
"TrackRefitter",
"Second", {
"method":
"load",
273 if isCosmics: mods = mods[1:]
280 if momentumConstraint
is not None:
281 for mod
in options[
"TrackRefitter"]:
282 momconstrspecs = momentumConstraint.split(
',')
283 if len(momconstrspecs)==1:
284 options[
"TrackRefitter"][mod].
update({
285 "constraint":
"momentum",
286 "srcConstr": momconstrspecs[0]
289 options[
"TrackRefitter"][mod].
update({
290 "constraint": momconstrspecs[1],
291 "srcConstr": momconstrspecs[0]
299 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
310 for mod
in mods[:-1]:
311 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
312 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
314 modules.append(getattr(process, src))
316 if mods[-1][-1][
"method"]
is "load" and \
317 not mods[-1][-1].
get(
"clone",
False):
318 print "Name of the last module needs to be modifiable." 320 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
321 options[mods[-1][0]][mods[-1][1]],
322 isCosmics = isCosmics, **(mods[-1][2]))
323 modules.append(getattr(process, src))
325 moduleSum = process.offlineBeamSpot
326 for module
in modules:
328 if hasattr(module,
"srcConstr"):
329 strSrcConstr = module.srcConstr.getModuleLabel()
331 procsrcconstr = getattr(process,strSrcConstr)
332 if procsrcconstr.src != module.src:
336 moduleSum += procsrcconstr
340 return cms.Sequence(moduleSum)
355 def _getModule(process, src, modType, moduleName, options, **kwargs):
356 """General function for attaching the module of type `modType` to the 357 cms.Process `process` using `options` for customization and `moduleName` as 358 the name of the new attribute of `process`. 361 - `process`: 'cms.Process' object to which the module is attached. 362 - `src`: cms.InputTag for this module. 363 - `modType`: Type of the requested module. 364 - `options`: Dictionary with customized values for the module's options. 365 - `**kwargs`: Used to supply options at construction time of the module. 368 objTuple = globals()[
"_"+modType](kwargs)
369 method = kwargs.get(
"method")
370 if method ==
"import":
371 __import__(objTuple[0])
372 obj = getattr(sys.modules[objTuple[0]], objTuple[1]).
clone()
373 elif method ==
"load":
374 process.load(objTuple[0])
375 if kwargs.get(
"clone",
False):
376 obj = getattr(process, objTuple[1]).
clone(src=src)
378 obj = getattr(process, objTuple[1])
379 moduleName = objTuple[1]
381 print "Unknown method:", method
384 if modType ==
"TrackSplitting":
392 for option
in options:
395 if moduleName
is not objTuple[1]:
396 setattr(process, moduleName, obj)
401 """Returns TrackHitFilter module name. 404 - `kwargs`: Not used in this function. 407 return (
"RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
408 "TrackerTrackHitFilter")
412 """Returns TrackSelector module name. 415 - `kwargs`: Not used in this function. 418 return (
"Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
419 "AlignmentTrackSelector")
423 """Returns TrackFitter module name. 426 - `kwargs`: Used to supply options at construction time of the object. 429 isCosmics = kwargs.get(
"isCosmics",
False)
431 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
432 "ctfWithMaterialTracksCosmics")
434 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
435 "ctfWithMaterialTracks")
439 """Returns TrackRefitter module name. 442 - `kwargs`: Used to supply options at construction time of the object. 445 isCosmics = kwargs.get(
"isCosmics",
False)
447 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
450 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
454 return (
"RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi",
455 "cosmicTrackSplitter")
459 """Sets the attribute `attr` of the object `obj` using the value `val`. 460 `attr` can be a string or a tuple of strings, if one wants to set an 461 attribute of an attribute, etc. 464 - `obj`: Object, which must have a '__dict__' attribute. 465 - `attr`: String or tuple of strings describing the attribute's name. 466 - `val`: value of the attribute. 469 if type(attr)
is tuple
and len(attr) > 1:
472 if type(attr)
is tuple: attr = attr[0]
473 setattr(obj, attr, val)
def _customSetattr(obj, attr, val)
def getSequence(process, collection, saveCPU=False, TTRHBuilder="WithAngleAndTemplate", usePixelQualityFlag=None, openMassWindow=False, cosmicsDecoMode=False, cosmicsZeroTesla=True, momentumConstraint=None, cosmicTrackSplitting=False, use_d0cut=True)
def _TrackSplitting(kwargs)
def _TrackSelector(kwargs)
def _getModule(process, src, modType, moduleName, options, kwargs)
Auxiliary functions ###
def _TrackRefitter(kwargs)
def _TrackHitFilter(kwargs)
static std::string join(char **cmd)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
T get(const Candidate &c)