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,
15 isPVValidation =
False,
17 """This function returns a cms.Sequence containing as last element the 18 module 'FinalTrackRefitter', which can be used as cms.InputTag for 19 subsequent processing steps. 20 The modules in the sequence are already attached to the given `process` 21 object using the given track collection `collection` and the given 25 - `process`: 'cms.Process' object to which the modules of the sequence will 27 - `collection`: String indicating the input track collection. 28 - `saveCPU`: If set to 'True', some steps are merged to reduce CPU time. 29 Reduces a little the accuracy of the results. 30 This option is currently not recommended. 31 - `TTRHBuilder`: Option used for the Track(Re)Fitter modules. 32 - `usePixelQualityFlag`: Option used for the TrackHitFilter module. 33 Defaults to 'True' but is automatically set to 34 'False' if a `TTRHBuilder` without templates is 36 If this is still wanted for some reason, one can 37 explicitely specify it as 'True'. 38 - `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu. 39 - `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used. 40 - `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used. 41 - `momentumConstraint`: If you want to apply a momentum constraint for the 42 track refitting, e.g. for CRUZET data, you need 43 to provide here the name of the constraint module. 44 - `cosmicTrackSplitting`: If set to 'True' cosmic tracks are split before the 45 second track refitter. 46 - `isPVValidation`: If set to 'True' most of the selection cuts are overridden 47 to allow unbiased selection of tracks for vertex refitting 48 - `use_d0cut`: If 'True' (default), apply a cut |d0| < 50. 55 if usePixelQualityFlag
is None:
56 if "Template" not in TTRHBuilder:
57 usePixelQualityFlag =
False 58 print "Using 'TTRHBuilder' without templates:", TTRHBuilder
59 print " --> Turning off pixel quality flag in hit filter." 61 usePixelQualityFlag =
True 68 options = {
"TrackHitFilter": {},
73 options[
"TrackSelector"][
"HighPurity"] = {
74 "trackQualities": [
"highPurity"],
80 options[
"TrackSelector"][
"Alignment"] = {
91 options[
"TrackRefitter"][
"First"] = {
92 "NavigationSchool":
"",
93 "TTRHBuilder": TTRHBuilder,
95 options[
"TrackRefitter"][
"Second"] = {
96 "NavigationSchool":
"",
97 "TTRHBuilder": TTRHBuilder,
99 options[
"TrackHitFilter"][
"Tracker"] = {
100 "useTrajectories":
True,
102 "commands": cms.vstring(
"keep PXB",
"keep PXE",
"keep TIB",
"keep TID",
103 "keep TOB",
"keep TEC"),
104 "replaceWithInactiveHits":
True,
105 "rejectBadStoNHits":
True,
106 "rejectLowAngleHits":
True,
107 "usePixelQualityFlag": usePixelQualityFlag,
108 "StoNcommands": cms.vstring(
"ALL 12.0"),
109 "TrackAngleCut": 0.087,
111 options[
"TrackFitter"][
"HitFilteredTracks"] = {
112 "NavigationSchool":
"",
113 "TTRHBuilder": TTRHBuilder,
122 if collection
in (
"ALCARECOTkAlMinBias",
"generalTracks",
123 "ALCARECOTkAlMinBiasHI",
"hiGeneralTracks"):
124 options[
"TrackSelector"][
"Alignment"].
update({
128 options[
"TrackHitFilter"][
"Tracker"].
update({
131 elif collection
in (
"ALCARECOTkAlCosmicsCTF0T",
132 "ALCARECOTkAlCosmicsInCollisions"):
134 options[
"TrackSelector"][
"HighPurity"] = {}
135 if not cosmicsDecoMode:
136 options[
"TrackHitFilter"][
"Tracker"].
update({
137 "StoNcommands": cms.vstring(
"ALL 18.0")
140 options[
"TrackHitFilter"][
"Tracker"].
update({
144 options[
"TrackHitFilter"][
"Tracker"].
update({
147 options[
"TrackSelector"][
"Alignment"].
update({
151 "applyMultiplicityFilter":
True,
154 if cosmicTrackSplitting:
155 options[
"TrackSplitting"] = {}
156 options[
"TrackSplitting"][
"TrackSplitting"] = {}
158 options[
"TrackSelector"][
"Alignment"].
update({
162 elif collection
in (
"ALCARECOTkAlMuonIsolated",
163 "ALCARECOTkAlMuonIsolatedHI",
164 "ALCARECOTkAlMuonIsolatedPA"):
165 options[
"TrackSelector"][
"Alignment"].
update({
166 (
"minHitsPerSubDet",
"inPIXEL"): 1,
169 "applyMultiplicityFilter":
True,
170 "maxMultiplicity": 1,
172 elif collection
in (
"ALCARECOTkAlZMuMu",
173 "ALCARECOTkAlZMuMuHI",
174 "ALCARECOTkAlZMuMuPA"):
175 options[
"TrackSelector"][
"Alignment"].
update({
180 "applyMultiplicityFilter":
True,
181 "minMultiplicity": 2,
182 "maxMultiplicity": 2,
183 (
"minHitsPerSubDet",
"inPIXEL"): 1,
184 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
185 (
"TwoBodyDecaySelector",
"charge"): 0,
186 (
"TwoBodyDecaySelector",
187 "applyMassrangeFilter"):
not openMassWindow,
188 (
"TwoBodyDecaySelector",
"minXMass"): 85.8,
189 (
"TwoBodyDecaySelector",
"maxXMass"): 95.8,
190 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
192 options[
"TrackHitFilter"][
"Tracker"].
update({
195 elif collection ==
"ALCARECOTkAlUpsilonMuMu":
196 options[
"TrackSelector"][
"Alignment"].
update({
201 "applyMultiplicityFilter":
True,
202 "minMultiplicity": 2,
203 "maxMultiplicity": 2,
204 (
"minHitsPerSubDet",
"inPIXEL"): 1,
205 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
206 (
"TwoBodyDecaySelector",
"charge"): 0,
207 (
"TwoBodyDecaySelector",
208 "applyMassrangeFilter"):
not openMassWindow,
209 (
"TwoBodyDecaySelector",
"minXMass"): 9.2,
210 (
"TwoBodyDecaySelector",
"maxXMass"): 9.7,
211 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
213 options[
"TrackHitFilter"][
"Tracker"].
update({
216 elif collection ==
"ALCARECOTkAlJpsiMuMu":
217 options[
"TrackSelector"][
"Alignment"].
update({
222 "applyMultiplicityFilter":
True,
223 "minMultiplicity": 2,
224 "maxMultiplicity": 2,
225 (
"minHitsPerSubDet",
"inPIXEL"): 1,
226 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
227 (
"TwoBodyDecaySelector",
"charge"): 0,
228 (
"TwoBodyDecaySelector",
229 "applyMassrangeFilter"):
not openMassWindow,
230 (
"TwoBodyDecaySelector",
"minXMass"): 2.7,
231 (
"TwoBodyDecaySelector",
"maxXMass"): 3.4,
232 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
234 options[
"TrackHitFilter"][
"Tracker"].
update({
238 raise ValueError(
"Unknown input track collection: {}".
format(collection))
240 if cosmicTrackSplitting
and not isCosmics:
241 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
250 if cosmicTrackSplitting:
251 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
252 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
253 (
"TrackRefitter",
"First", {
"method":
"load",
255 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
256 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
257 options[
"TrackSelector"][
"Alignment"].
update(
258 options[
"TrackSelector"][
"HighPurity"])
259 elif cosmicTrackSplitting:
260 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
262 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
263 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
264 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
265 (
"TrackRefitter",
"Second", {
"method":
"load",
268 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
269 (
"TrackRefitter",
"First", {
"method":
"load",
271 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
272 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
273 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
274 (
"TrackRefitter",
"Second", {
"method":
"load",
276 if isCosmics: mods = mods[1:]
283 options[
"TrackSelector"][
"HighPurity"].
update({
284 "trackQualities": [],
287 options[
"TrackSelector"][
"Alignment"].
update({
302 if momentumConstraint
is not None:
303 for mod
in options[
"TrackRefitter"]:
304 momconstrspecs = momentumConstraint.split(
',')
305 if len(momconstrspecs)==1:
306 options[
"TrackRefitter"][mod].
update({
307 "constraint":
"momentum",
308 "srcConstr": momconstrspecs[0]
311 options[
"TrackRefitter"][mod].
update({
312 "constraint": momconstrspecs[1],
313 "srcConstr": momconstrspecs[0]
321 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
332 for mod
in mods[:-1]:
333 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
334 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
336 modules.append(getattr(process, src))
338 if mods[-1][-1][
"method"]
is "load" and \
339 not mods[-1][-1].
get(
"clone",
False):
340 print "Name of the last module needs to be modifiable." 342 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
343 options[mods[-1][0]][mods[-1][1]],
344 isCosmics = isCosmics, **(mods[-1][2]))
345 modules.append(getattr(process, src))
347 moduleSum = process.offlineBeamSpot
348 for module
in modules:
350 if hasattr(module,
"srcConstr"):
351 strSrcConstr = module.srcConstr.getModuleLabel()
353 procsrcconstr = getattr(process,strSrcConstr)
354 if hasattr(procsrcconstr,
"src"):
355 if procsrcconstr.src != module.src:
359 moduleSum += procsrcconstr
360 elif hasattr(procsrcconstr,
"srcTrk"):
361 if procsrcconstr.srcTrk != module.src:
365 procsrcconstrsrcvtx = getattr(process,procsrcconstr.srcVtx.getModuleLabel())
366 if type(procsrcconstrsrcvtx)
is cms.EDFilter:
367 procsrcconstrsrcvtxprefilter = getattr(process,procsrcconstrsrcvtx.src.getModuleLabel())
368 moduleSum += procsrcconstrsrcvtxprefilter
369 moduleSum += procsrcconstrsrcvtx
370 moduleSum += procsrcconstr
374 return cms.Sequence(moduleSum)
389 def _getModule(process, src, modType, moduleName, options, **kwargs):
390 """General function for attaching the module of type `modType` to the 391 cms.Process `process` using `options` for customization and `moduleName` as 392 the name of the new attribute of `process`. 395 - `process`: 'cms.Process' object to which the module is attached. 396 - `src`: cms.InputTag for this module. 397 - `modType`: Type of the requested module. 398 - `options`: Dictionary with customized values for the module's options. 399 - `**kwargs`: Used to supply options at construction time of the module. 402 objTuple = globals()[
"_"+modType](kwargs)
403 method = kwargs.get(
"method")
404 if method ==
"import":
405 __import__(objTuple[0])
406 obj = getattr(sys.modules[objTuple[0]], objTuple[1]).
clone()
407 elif method ==
"load":
408 process.load(objTuple[0])
409 if kwargs.get(
"clone",
False):
410 obj = getattr(process, objTuple[1]).
clone(src=src)
412 obj = getattr(process, objTuple[1])
413 moduleName = objTuple[1]
415 print "Unknown method:", method
418 if modType ==
"TrackSplitting":
426 for option
in options:
429 if moduleName
is not objTuple[1]:
430 setattr(process, moduleName, obj)
435 """Returns TrackHitFilter module name. 438 - `kwargs`: Not used in this function. 441 return (
"RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
442 "TrackerTrackHitFilter")
446 """Returns TrackSelector module name. 449 - `kwargs`: Not used in this function. 452 return (
"Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
453 "AlignmentTrackSelector")
457 """Returns TrackFitter module name. 460 - `kwargs`: Used to supply options at construction time of the object. 463 isCosmics = kwargs.get(
"isCosmics",
False)
465 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
466 "ctfWithMaterialTracksCosmics")
468 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
469 "ctfWithMaterialTracks")
473 """Returns TrackRefitter module name. 476 - `kwargs`: Used to supply options at construction time of the object. 479 isCosmics = kwargs.get(
"isCosmics",
False)
481 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
484 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
488 return (
"RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi",
489 "cosmicTrackSplitter")
493 """Sets the attribute `attr` of the object `obj` using the value `val`. 494 `attr` can be a string or a tuple of strings, if one wants to set an 495 attribute of an attribute, etc. 498 - `obj`: Object, which must have a '__dict__' attribute. 499 - `attr`: String or tuple of strings describing the attribute's name. 500 - `val`: value of the attribute. 503 if isinstance(attr, tuple)
and len(attr) > 1:
506 if isinstance(attr, tuple): attr = attr[0]
507 setattr(obj, attr, val)
def _customSetattr(obj, attr, val)
def _TrackSplitting(kwargs)
def _TrackSelector(kwargs)
def _getModule(process, src, modType, moduleName, options, kwargs)
Auxiliary functions ###
def _TrackRefitter(kwargs)
def _TrackHitFilter(kwargs)
def getSequence(process, collection, saveCPU=False, TTRHBuilder="WithAngleAndTemplate", usePixelQualityFlag=None, openMassWindow=False, cosmicsDecoMode=False, cosmicsZeroTesla=True, momentumConstraint=None, cosmicTrackSplitting=False, isPVValidation=False, use_d0cut=True)
static std::string join(char **cmd)
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
T get(const Candidate &c)