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 procsrcconstr.src != module.src:
358 moduleSum += procsrcconstr
362 return cms.Sequence(moduleSum)
377 def _getModule(process, src, modType, moduleName, options, **kwargs):
378 """General function for attaching the module of type `modType` to the 379 cms.Process `process` using `options` for customization and `moduleName` as 380 the name of the new attribute of `process`. 383 - `process`: 'cms.Process' object to which the module is attached. 384 - `src`: cms.InputTag for this module. 385 - `modType`: Type of the requested module. 386 - `options`: Dictionary with customized values for the module's options. 387 - `**kwargs`: Used to supply options at construction time of the module. 390 objTuple = globals()[
"_"+modType](kwargs)
391 method = kwargs.get(
"method")
392 if method ==
"import":
393 __import__(objTuple[0])
394 obj = getattr(sys.modules[objTuple[0]], objTuple[1]).
clone()
395 elif method ==
"load":
396 process.load(objTuple[0])
397 if kwargs.get(
"clone",
False):
398 obj = getattr(process, objTuple[1]).
clone(src=src)
400 obj = getattr(process, objTuple[1])
401 moduleName = objTuple[1]
403 print "Unknown method:", method
406 if modType ==
"TrackSplitting":
414 for option
in options:
417 if moduleName
is not objTuple[1]:
418 setattr(process, moduleName, obj)
423 """Returns TrackHitFilter module name. 426 - `kwargs`: Not used in this function. 429 return (
"RecoTracker.FinalTrackSelectors.TrackerTrackHitFilter_cff",
430 "TrackerTrackHitFilter")
434 """Returns TrackSelector module name. 437 - `kwargs`: Not used in this function. 440 return (
"Alignment.CommonAlignmentProducer.AlignmentTrackSelector_cfi",
441 "AlignmentTrackSelector")
445 """Returns TrackFitter module name. 448 - `kwargs`: Used to supply options at construction time of the object. 451 isCosmics = kwargs.get(
"isCosmics",
False)
453 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterialP5_cff",
454 "ctfWithMaterialTracksCosmics")
456 return (
"RecoTracker.TrackProducer.CTFFinalFitWithMaterial_cff",
457 "ctfWithMaterialTracks")
461 """Returns TrackRefitter module name. 464 - `kwargs`: Used to supply options at construction time of the object. 467 isCosmics = kwargs.get(
"isCosmics",
False)
469 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
472 return (
"RecoTracker.TrackProducer.TrackRefitters_cff",
476 return (
"RecoTracker.FinalTrackSelectors.cosmicTrackSplitter_cfi",
477 "cosmicTrackSplitter")
481 """Sets the attribute `attr` of the object `obj` using the value `val`. 482 `attr` can be a string or a tuple of strings, if one wants to set an 483 attribute of an attribute, etc. 486 - `obj`: Object, which must have a '__dict__' attribute. 487 - `attr`: String or tuple of strings describing the attribute's name. 488 - `val`: value of the attribute. 491 if type(attr)
is tuple
and len(attr) > 1:
494 if type(attr)
is tuple: attr = attr[0]
495 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)