CMS 3D CMS Logo

customiseForQuadrupletsByCellularAutomaton.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 _CAParameters = dict(
4  maxChi2 = dict(
5  pt1 = 0.8, pt2 = 2,
6  value1 = 200, value2 = 100,
7  enabled = True,
8  ),
9  useBendingCorrection = True,
10  fitFastCircle = True,
11  fitFastCircleChi2Cut = True,
12  CAThetaCut = 0.00125,
13  CAPhiCut = 0.1,
14  CAHardPtCut = 0,
15 )
16 
18  pset = getattr(module, "OrderedHitsFactoryPSet")
19  if not hasattr(pset, "ComponentName"):
20  return
21  if pset.ComponentName != "CombinedHitQuadrupletGenerator":
22  return
23  # Adjust seeding layers
24  seedingLayersName = module.OrderedHitsFactoryPSet.SeedingLayers.getModuleLabel()
25 
26  # Configure seed generator / pixel track producer
27  quadruplets = module.OrderedHitsFactoryPSet.clone()
28  from RecoPixelVertexing.PixelTriplets.CAHitQuadrupletGenerator_cfi import CAHitQuadrupletGenerator as _CAHitQuadrupletGenerator
29 
30  module.OrderedHitsFactoryPSet = _CAHitQuadrupletGenerator.clone(
31  ComponentName = "CAHitQuadrupletGenerator",
32  extraHitRPhitolerance = quadruplets.GeneratorPSet.extraHitRPhitolerance,
33  SeedingLayers = seedingLayersName,
34  **_CAParameters
35  )
36 
37  if hasattr(quadruplets.GeneratorPSet, "SeedComparitorPSet"):
38  module.OrderedHitsFactoryPSet.SeedComparitorPSet = quadruplets.GeneratorPSet.SeedComparitorPSet
39 
40 def customiseNewSeeding(process, module):
41  tripletModuleName = module.triplets.getModuleLabel()
42  tripletModule = getattr(process, tripletModuleName)
43  doubletModuleName = tripletModule.doublets.getModuleLabel()
44  doubletModule = getattr(process, doubletModuleName)
45 
46  # Generate doublets for all adjacent layer pairs
47  doubletModule.layerPairs = [
48  0, # layer pair (0,1)
49  1, # layer pair (1,2)
50  2 # layer pair (2,3)
51  ]
52 
53  # Bit of a hack to replace a module with another, but works
54  #
55  # In principle setattr(process) could work too, but it expands the
56  # sequences and I don't want that
57  modifier = cms.Modifier()
58  modifier._setChosen()
59 
60  # Replace quadruplet generator with the CA version
61  from RecoPixelVertexing.PixelTriplets.caHitQuadrupletEDProducer_cfi import caHitQuadrupletEDProducer as _caHitQuadrupletEDProducer
62  modifier.toReplaceWith(module, _caHitQuadrupletEDProducer.clone(
63  doublets = doubletModuleName,
64  SeedComparitorPSet = module.SeedComparitorPSet.clone(),
65  extraHitRPhitolerance = module.extraHitRPhitolerance,
66  **_CAParameters
67  ))
68 
69  # Remove triplet generator from all sequence and paths
70  for seqs in [process.sequences_(), process.paths_()]:
71  for seqName, seq in seqs.iteritems():
72  # cms.Sequence.remove() would look simpler, but it expands
73  # the contained sequences if a replacement occurs there.
74  try:
75  index = seq.index(tripletModule)
76  except:
77  continue
78 
79  seq.remove(tripletModule)
80 
81  delattr(process, tripletModuleName)
82 
84  for module in process._Process__producers.values():
85  if hasattr(module, "OrderedHitsFactoryPSet"):
87  elif module._TypedParameterizable__type == "PixelQuadrupletEDProducer":
88  customiseNewSeeding(process, module)
89 
90  return process