CMS 3D CMS Logo

customiseForTripletsByCellularAutomaton.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 = 20, value2 = 10,
7  enabled = True,
8  ),
9  useBendingCorrection = True,
10  CAThetaCut = 0.0015,
11  CAPhiCut = 0.01,
12  CAHardPtCut = 0,
13 )
14 
16  pset = getattr(module, "OrderedHitsFactoryPSet")
17  if not hasattr(pset, "ComponentName"):
18  return
19  if pset.ComponentName != "StandardHitTripletGenerator":
20  return
21  # Adjust seeding layers
22  seedingLayersName = module.OrderedHitsFactoryPSet.SeedingLayers.getModuleLabel()
23 
24 
25  # Configure seed generator / pixel track producer
26  Triplets = module.OrderedHitsFactoryPSet.clone()
27  from RecoPixelVertexing.PixelTriplets.CAHitTripletGenerator_cfi import CAHitTripletGenerator as _CAHitTripletGenerator
28 
29  module.OrderedHitsFactoryPSet = _CAHitTripletGenerator.clone(
30  ComponentName = "CAHitTripletGenerator",
31  extraHitRPhitolerance = Triplets.GeneratorPSet.extraHitRPhitolerance,
32  SeedingLayers = seedingLayersName,
33  **_CAParameters
34  )
35 
36  if hasattr(Triplets.GeneratorPSet, "SeedComparitorPSet"):
37  module.OrderedHitsFactoryPSet.SeedComparitorPSet = Triplets.GeneratorPSet.SeedComparitorPSet
38 
39 def customiseNewSeeding(process, module):
40  doubletModuleName = module.doublets.getModuleLabel()
41  doubletModule = getattr(process, doubletModuleName)
42 
43  # Generate doublets for all adjacent layer pairs
44  doubletModule.layerPairs = [
45  0, # layer pair (0,1)
46  1, # layer pair (1,2)
47  ]
48 
49  # Bit of a hack to replace a module with another, but works
50  #
51  # In principle setattr(process) could work too, but it expands the
52  # sequences and I don't want that
53  modifier = cms.Modifier()
54  modifier._setChosen()
55 
56  comparitor = None
57  if hasattr(module, "SeedComparitorPSet"):
58  comparitor = module.SeedComparitorPSet.clone()
59 
60  # Replace triplet generator with the CA version
61  from RecoPixelVertexing.PixelTriplets.caHitTripletEDProducer_cfi import caHitTripletEDProducer as _caHitTripletEDProducer
62  modifier.toReplaceWith(module, _caHitTripletEDProducer.clone(
63  doublets = doubletModuleName,
64  extraHitRPhitolerance = module.extraHitRPhitolerance,
65  **_CAParameters
66  ))
67 
68  if comparitor:
69  module.SeedComparitorPSet = comparitor
70 
71 
73  for module in process._Process__producers.values():
74  if hasattr(module, "OrderedHitsFactoryPSet"):
76  elif module._TypedParameterizable__type in ["PixelTripletHLTEDProducer", "PixelTripletLargeTipEDProducer"]:
77  customiseNewSeeding(process, module)
78  return process