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({
214 raise ValueError(
"Unknown input track collection: {}".
format(collection))
216 if cosmicTrackSplitting
and not isCosmics:
217 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
226 if cosmicTrackSplitting:
227 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
228 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
229 (
"TrackRefitter",
"First", {
"method":
"load",
231 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
232 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
233 options[
"TrackSelector"][
"Alignment"].
update(
234 options[
"TrackSelector"][
"HighPurity"])
235 elif cosmicTrackSplitting:
236 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
238 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
239 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
240 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
241 (
"TrackRefitter",
"Second", {
"method":
"load",
244 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
245 (
"TrackRefitter",
"First", {
"method":
"load",
247 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
248 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
249 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
250 (
"TrackRefitter",
"Second", {
"method":
"load",
252 if isCosmics: mods = mods[1:]
259 if momentumConstraint
is not None:
260 for mod
in options[
"TrackRefitter"]:
261 options[
"TrackRefitter"][mod].
update({
262 "constraint":
"momentum",
263 "srcConstr": momentumConstraint
271 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
282 for mod
in mods[:-1]:
283 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
284 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
286 modules.append(getattr(process, src))
288 if mods[-1][-1][
"method"]
is "load" and \
289 not mods[-1][-1].
get(
"clone",
False):
290 print "Name of the last module needs to be modifiable." 292 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
293 options[mods[-1][0]][mods[-1][1]],
294 isCosmics = isCosmics, **(mods[-1][2]))
295 modules.append(getattr(process, src))
297 moduleSum = process.offlineBeamSpot
298 for module
in modules: moduleSum += module
300 return cms.Sequence(moduleSum)
315 def _getModule(process, src, modType, moduleName, options, **kwargs):
316 """General function for attaching the module of type `modType` to the 317 cms.Process `process` using `options` for customization and `moduleName` as 318 the name of the new attribute of `process`. 321 - `process`: 'cms.Process' object to which the module is attached. 322 - `src`: cms.InputTag for this module. 323 - `modType`: Type of the requested module. 324 - `options`: Dictionary with customized values for the module's options. 325 - `**kwargs`: Used to supply options at construction time of the module. 328 objTuple = globals()[
"_"+modType](kwargs)
329 method = kwargs.get(
"method")
330 if method ==
"import":
331 __import__(objTuple[0])
332 obj = getattr(sys.modules[objTuple[0]], objTuple[1]).
clone()
333 elif method ==
"load":
334 process.load(objTuple[0])
335 if kwargs.get(
"clone",
False):
336 obj = getattr(process, objTuple[1]).
clone(src=src)
338 obj = getattr(process, objTuple[1])
339 moduleName = objTuple[1]
341 print "Unknown method:", method
344 if modType ==
"TrackSplitting":
352 for option
in options:
355 if moduleName
is not objTuple[1]:
356 setattr(process, moduleName, obj)
361 """Returns TrackHitFilter module name. 364 - `kwargs`: Not used in this function. 367 return (
"RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
368 "TrackerTrackHitFilter")
372 """Returns TrackSelector module name. 375 - `kwargs`: Not used in this function. 378 return (
"Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
379 "AlignmentTrackSelector")
383 """Returns TrackFitter module name. 386 - `kwargs`: Used to supply options at construction time of the object. 389 isCosmics = kwargs.get(
"isCosmics",
False)
391 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
392 "ctfWithMaterialTracksCosmics")
394 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
395 "ctfWithMaterialTracks")
399 """Returns TrackRefitter module name. 402 - `kwargs`: Used to supply options at construction time of the object. 405 isCosmics = kwargs.get(
"isCosmics",
False)
407 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
410 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
414 return (
"RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi",
415 "cosmicTrackSplitter")
419 """Sets the attribute `attr` of the object `obj` using the value `val`. 420 `attr` can be a string or a tuple of strings, if one wants to set an 421 attribute of an attribute, etc. 424 - `obj`: Object, which must have a '__dict__' attribute. 425 - `attr`: String or tuple of strings describing the attribute's name. 426 - `val`: value of the attribute. 429 if type(attr)
is tuple
and len(attr) > 1:
432 if type(attr)
is tuple: attr = attr[0]
433 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)