18 """This function returns a cms.Sequence containing as last element the 19 module 'FinalTrackRefitter', which can be used as cms.InputTag for 20 subsequent processing steps. 21 The modules in the sequence are already attached to the given `process` 22 object using the given track collection `collection` and the given 26 - `process`: 'cms.Process' object to which the modules of the sequence will 28 - `collection`: String indicating the input track collection. 29 - `saveCPU`: If set to 'True', some steps are merged to reduce CPU time. 30 Reduces a little the accuracy of the results. 31 This option is currently not recommended. 32 - `TTRHBuilder`: Option used for the Track(Re)Fitter modules. 33 - `usePixelQualityFlag`: Option used for the TrackHitFilter module. 34 Defaults to 'True' but is automatically set to 35 'False' if a `TTRHBuilder` without templates is 37 If this is still wanted for some reason, one can 38 explicitely specify it as 'True'. 39 - `openMassWindow`: Used to configure the TwoBodyDecaySelector for ZMuMu. 40 - `cosmicsDecoMode`: If set to 'True' a lower Signal/Noise cut is used. 41 - `cosmicsZeroTesla`: If set to 'True' a 0T-specific selection is used. 42 - `momentumConstraint`: If you want to apply a momentum constraint for the 43 track refitting, e.g. for CRUZET data, you need 44 to provide here the name of the constraint module. 45 - `cosmicTrackSplitting`: If set to 'True' cosmic tracks are split before the 46 second track refitter. 47 - `isPVValidation`: If set to 'True' most of the selection cuts are overridden 48 to allow unbiased selection of tracks for vertex refitting 49 - `use_d0cut`: If 'True' (default), apply a cut |d0| < 50. 56 if usePixelQualityFlag
is None:
57 if "Template" not in TTRHBuilder:
58 usePixelQualityFlag =
False 59 print(
"Using 'TTRHBuilder' without templates:", TTRHBuilder)
60 print(
" --> Turning off pixel quality flag in hit filter.")
62 usePixelQualityFlag =
True 69 options = {
"TrackHitFilter": {},
74 options[
"TrackSelector"][
"HighPurity"] = {
75 "trackQualities": [
"highPurity"],
81 options[
"TrackSelector"][
"Alignment"] = {
92 options[
"TrackRefitter"][
"First"] = {
93 "NavigationSchool":
"",
94 "TTRHBuilder": TTRHBuilder,
96 options[
"TrackRefitter"][
"Second"] = {
97 "NavigationSchool":
"",
98 "TTRHBuilder": TTRHBuilder,
100 options[
"TrackHitFilter"][
"Tracker"] = {
101 "useTrajectories":
True,
103 "commands": cms.vstring(
"keep PXB",
"keep PXE",
"keep TIB",
"keep TID",
104 "keep TOB",
"keep TEC"),
105 "replaceWithInactiveHits":
True,
106 "rejectBadStoNHits":
True,
107 "rejectLowAngleHits":
True,
108 "usePixelQualityFlag": usePixelQualityFlag,
109 "StoNcommands": cms.vstring(
"ALL 12.0"),
110 "TrackAngleCut": 0.087,
112 options[
"TrackFitter"][
"HitFilteredTracks"] = {
113 "NavigationSchool":
"",
114 "TTRHBuilder": TTRHBuilder,
123 if collection
in (
"ALCARECOTkAlMinBias",
"generalTracks",
124 "ALCARECOTkAlMinBiasHI",
"hiGeneralTracks"):
125 options[
"TrackSelector"][
"Alignment"].
update({
129 options[
"TrackHitFilter"][
"Tracker"].
update({
132 elif collection
in (
"ALCARECOTkAlCosmicsCTF0T",
133 "ALCARECOTkAlCosmicsInCollisions"):
135 options[
"TrackSelector"][
"HighPurity"] = {}
136 if not cosmicsDecoMode:
137 options[
"TrackHitFilter"][
"Tracker"].
update({
138 "StoNcommands": cms.vstring(
"ALL 18.0")
141 options[
"TrackHitFilter"][
"Tracker"].
update({
145 options[
"TrackHitFilter"][
"Tracker"].
update({
148 options[
"TrackSelector"][
"Alignment"].
update({
152 "applyMultiplicityFilter":
True,
155 if cosmicTrackSplitting:
156 options[
"TrackSplitting"] = {}
157 options[
"TrackSplitting"][
"TrackSplitting"] = {}
159 options[
"TrackSelector"][
"Alignment"].
update({
163 elif collection
in (
"ALCARECOTkAlMuonIsolated",
164 "ALCARECOTkAlMuonIsolatedHI",
165 "ALCARECOTkAlMuonIsolatedPA"):
166 options[
"TrackSelector"][
"Alignment"].
update({
167 (
"minHitsPerSubDet",
"inPIXEL"): 1,
170 "applyMultiplicityFilter":
True,
171 "maxMultiplicity": 1,
173 elif collection
in (
"ALCARECOTkAlZMuMu",
174 "ALCARECOTkAlZMuMuHI",
175 "ALCARECOTkAlZMuMuPA"):
176 options[
"TrackSelector"][
"Alignment"].
update({
181 "applyMultiplicityFilter":
True,
182 "minMultiplicity": 2,
183 "maxMultiplicity": 2,
184 (
"minHitsPerSubDet",
"inPIXEL"): 1,
185 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
186 (
"TwoBodyDecaySelector",
"charge"): 0,
187 (
"TwoBodyDecaySelector",
188 "applyMassrangeFilter"):
not openMassWindow,
189 (
"TwoBodyDecaySelector",
"minXMass"): 85.8,
190 (
"TwoBodyDecaySelector",
"maxXMass"): 95.8,
191 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
193 options[
"TrackHitFilter"][
"Tracker"].
update({
196 elif collection ==
"ALCARECOTkAlUpsilonMuMu":
197 options[
"TrackSelector"][
"Alignment"].
update({
202 "applyMultiplicityFilter":
True,
203 "minMultiplicity": 2,
204 "maxMultiplicity": 2,
205 (
"minHitsPerSubDet",
"inPIXEL"): 1,
206 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
207 (
"TwoBodyDecaySelector",
"charge"): 0,
208 (
"TwoBodyDecaySelector",
209 "applyMassrangeFilter"):
not openMassWindow,
210 (
"TwoBodyDecaySelector",
"minXMass"): 9.2,
211 (
"TwoBodyDecaySelector",
"maxXMass"): 9.7,
212 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
214 options[
"TrackHitFilter"][
"Tracker"].
update({
217 elif collection ==
"ALCARECOTkAlJpsiMuMu":
218 options[
"TrackSelector"][
"Alignment"].
update({
223 "applyMultiplicityFilter":
True,
224 "minMultiplicity": 2,
225 "maxMultiplicity": 2,
226 (
"minHitsPerSubDet",
"inPIXEL"): 1,
227 (
"TwoBodyDecaySelector",
"applyChargeFilter"):
True,
228 (
"TwoBodyDecaySelector",
"charge"): 0,
229 (
"TwoBodyDecaySelector",
230 "applyMassrangeFilter"):
not openMassWindow,
231 (
"TwoBodyDecaySelector",
"minXMass"): 2.7,
232 (
"TwoBodyDecaySelector",
"maxXMass"): 3.4,
233 (
"TwoBodyDecaySelector",
"daughterMass"): 0.105
235 options[
"TrackHitFilter"][
"Tracker"].
update({
239 raise ValueError(
"Unknown input track collection: {}".
format(collection))
241 if cosmicTrackSplitting
and not isCosmics:
242 raise ValueError(
"Can only do cosmic track splitting for cosmics.")
251 if cosmicTrackSplitting:
252 raise ValueError(
"Can't turn on both saveCPU and cosmicTrackSplitting at the same time")
253 mods = [(
"TrackSelector",
"Alignment", {
"method":
"load"}),
254 (
"TrackRefitter",
"First", {
"method":
"load",
256 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
257 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"})]
258 options[
"TrackSelector"][
"Alignment"].
update(
259 options[
"TrackSelector"][
"HighPurity"])
260 elif cosmicTrackSplitting:
261 mods = [(
"TrackRefitter",
"First", {
"method":
"load",
263 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
264 (
"TrackSplitting",
"TrackSplitting", {
"method":
"load"}),
265 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
266 (
"TrackRefitter",
"Second", {
"method":
"load",
269 mods = [(
"TrackSelector",
"HighPurity", {
"method":
"import"}),
270 (
"TrackRefitter",
"First", {
"method":
"load",
272 (
"TrackHitFilter",
"Tracker", {
"method":
"load"}),
273 (
"TrackFitter",
"HitFilteredTracks", {
"method":
"import"}),
274 (
"TrackSelector",
"Alignment", {
"method":
"load"}),
275 (
"TrackRefitter",
"Second", {
"method":
"load",
277 if isCosmics: mods = mods[1:]
284 options[
"TrackSelector"][
"HighPurity"].
update({
285 "trackQualities": [],
288 options[
"TrackSelector"][
"Alignment"].
update({
303 if momentumConstraint
is not None:
304 for mod
in options[
"TrackRefitter"]:
305 momconstrspecs = momentumConstraint.split(
',')
306 if len(momconstrspecs)==1:
307 options[
"TrackRefitter"][mod].
update({
308 "constraint":
"momentum",
309 "srcConstr": momconstrspecs[0]
312 options[
"TrackRefitter"][mod].
update({
313 "constraint": momconstrspecs[1],
314 "srcConstr": momconstrspecs[0]
322 process.load(
"RecoVertex.BeamSpotProducer.BeamSpot_cff")
333 for mod
in mods[:-1]:
334 src, prevsrc =
_getModule(process, src, mod[0],
"".
join(reversed(mod[:-1])),
335 options[mod[0]][mod[1]], isCosmics = isCosmics, prevsrc = prevsrc,
337 modules.append(getattr(process, src))
339 if mods[-1][-1][
"method"]
is "load" and \
340 not mods[-1][-1].
get(
"clone",
False):
341 print(
"Name of the last module needs to be modifiable.")
343 src =
_getModule(process, src, mods[-1][0],
"FinalTrackRefitter",
344 options[mods[-1][0]][mods[-1][1]],
345 isCosmics = isCosmics, **(mods[-1][2]))
346 modules.append(getattr(process, src))
348 moduleSum = process.offlineBeamSpot
349 for module
in modules:
351 if hasattr(module,
"srcConstr"):
352 strSrcConstr = module.srcConstr.getModuleLabel()
354 procsrcconstr = getattr(process,strSrcConstr)
355 if hasattr(procsrcconstr,
"src"):
356 if procsrcconstr.src != module.src:
360 moduleSum += procsrcconstr
361 elif hasattr(procsrcconstr,
"srcTrk"):
362 if procsrcconstr.srcTrk != module.src:
366 procsrcconstrsrcvtx = getattr(process,procsrcconstr.srcVtx.getModuleLabel())
367 if type(procsrcconstrsrcvtx)
is cms.EDFilter:
368 procsrcconstrsrcvtxprefilter = getattr(process,procsrcconstrsrcvtx.src.getModuleLabel())
369 moduleSum += procsrcconstrsrcvtxprefilter
370 moduleSum += procsrcconstrsrcvtx
371 moduleSum += procsrcconstr
375 return cms.Sequence(moduleSum)
S & print(S &os, JobReport::InputFile const &f)
def _getModule(process, src, modType, moduleName, options, kwargs)
Auxiliary functions ###
static std::string join(char **cmd)
T get(const Candidate &c)