CMS 3D CMS Logo

HitPairGeneratorFromLayerPair.cc
Go to the documentation of this file.
3 
7 
13 
15 
16 using namespace GeomDetEnumerators;
17 using namespace std;
18 
20 
21 namespace {
22  template <class T>
23  inline T sqr(T t) {
24  return t * t;
25  }
26 } // namespace
27 
33 
35  unsigned int outer,
36  LayerCacheType* layerCache,
37  unsigned int max)
38  : theLayerCache(layerCache), theOuterLayer(outer), theInnerLayer(inner), theMaxElement(max) {}
39 
41 
42 // devirtualizer
43 #include <tuple>
44 namespace {
45 
46  template <typename Algo>
47  struct Kernel {
48  using Base = HitRZCompatibility;
49  void set(Base const* a) {
50  assert(a->algo() == Algo::me);
51  checkRZ = reinterpret_cast<Algo const*>(a);
52  }
53 
54  void operator()(int b, int e, const RecHitsSortedInPhi& innerHitsMap, bool* ok) const {
55  constexpr float nSigmaRZ = 3.46410161514f; // std::sqrt(12.f);
56  for (int i = b; i != e; ++i) {
57  Range allowed = checkRZ->range(innerHitsMap.u[i]);
58  float vErr = nSigmaRZ * innerHitsMap.dv[i];
59  Range hitRZ(innerHitsMap.v[i] - vErr, innerHitsMap.v[i] + vErr);
60  Range crossRange = allowed.intersection(hitRZ);
61  ok[i - b] = !crossRange.empty();
62  }
63  }
64  Algo const* checkRZ;
65  };
66 
67  template <typename... Args>
68  using Kernels = std::tuple<Kernel<Args>...>;
69 
70 } // namespace
71 
74  const edm::Event& iEvent,
75  const edm::EventSetup& iSetup,
76  Layers layers) {
77  auto const& ds = doublets(region, iEvent, iSetup, layers);
78  for (std::size_t i = 0; i != ds.size(); ++i) {
79  result.push_back(OrderedHitPair(ds.hit(i, HitDoublets::inner), ds.hit(i, HitDoublets::outer)));
80  }
81  if (theMaxElement != 0 && result.size() >= theMaxElement) {
82  result.clear();
83  edm::LogError("TooManyPairs") << "number of pairs exceed maximum, no pairs produced";
84  }
85 }
86 
88  const edm::Event& iEvent,
89  const edm::EventSetup& iSetup,
90  const Layer& innerLayer,
91  const Layer& outerLayer,
92  LayerCacheType& layerCache) {
93  const RecHitsSortedInPhi& innerHitsMap = layerCache(innerLayer, region, iSetup);
94  if (innerHitsMap.empty())
95  return HitDoublets(innerHitsMap, innerHitsMap);
96 
97  const RecHitsSortedInPhi& outerHitsMap = layerCache(outerLayer, region, iSetup);
98  if (outerHitsMap.empty())
99  return HitDoublets(innerHitsMap, outerHitsMap);
100  HitDoublets result(innerHitsMap, outerHitsMap);
101  result.reserve(std::max(innerHitsMap.size(), outerHitsMap.size()));
102  doublets(
103  region, *innerLayer.detLayer(), *outerLayer.detLayer(), innerHitsMap, outerHitsMap, iSetup, theMaxElement, result);
104 
105  return result;
106 }
107 
109  const DetLayer& innerHitDetLayer,
110  const DetLayer& outerHitDetLayer,
111  const RecHitsSortedInPhi& innerHitsMap,
112  const RecHitsSortedInPhi& outerHitsMap,
113  const edm::EventSetup& iSetup,
114  const unsigned int theMaxElement,
115  HitDoublets& result) {
116  // HitDoublets result(innerHitsMap,outerHitsMap); result.reserve(std::max(innerHitsMap.size(),outerHitsMap.size()));
118  InnerDeltaPhi deltaPhi(outerHitDetLayer, innerHitDetLayer, region, iSetup);
119 
120  // std::cout << "layers " << theInnerLayer.detLayer()->seqNum() << " " << outerLayer.detLayer()->seqNum() << std::endl;
121 
122  // constexpr float nSigmaRZ = std::sqrt(12.f);
123  constexpr float nSigmaPhi = 3.f;
124  for (int io = 0; io != int(outerHitsMap.theHits.size()); ++io) {
125  if (!deltaPhi.prefilter(outerHitsMap.x[io], outerHitsMap.y[io]))
126  continue;
127  Hit const& ohit = outerHitsMap.theHits[io].hit();
128  PixelRecoRange<float> phiRange =
129  deltaPhi(outerHitsMap.x[io], outerHitsMap.y[io], outerHitsMap.z[io], nSigmaPhi * outerHitsMap.drphi[io]);
130 
131  if (phiRange.empty())
132  continue;
133 
134  std::unique_ptr<const HitRZCompatibility> checkRZ =
135  region.checkRZ(&innerHitDetLayer,
136  ohit,
137  iSetup,
138  &outerHitDetLayer,
139  outerHitsMap.rv(io),
140  outerHitsMap.z[io],
141  outerHitsMap.isBarrel ? outerHitsMap.du[io] : outerHitsMap.dv[io],
142  outerHitsMap.isBarrel ? outerHitsMap.dv[io] : outerHitsMap.du[io]);
143  if (!checkRZ)
144  continue;
145 
146  Kernels<HitZCheck, HitRCheck, HitEtaCheck> kernels;
147 
148  auto innerRange = innerHitsMap.doubleRange(phiRange.min(), phiRange.max());
149  LogDebug("HitPairGeneratorFromLayerPair")
150  << "preparing for combination of: " << innerRange[1] - innerRange[0] + innerRange[3] - innerRange[2]
151  << " inner and: " << outerHitsMap.theHits.size() << " outter";
152  for (int j = 0; j < 3; j += 2) {
153  auto b = innerRange[j];
154  auto e = innerRange[j + 1];
155  if (e == b)
156  continue;
157  bool ok[e - b];
158  switch (checkRZ->algo()) {
160  std::get<0>(kernels).set(checkRZ.get());
161  std::get<0>(kernels)(b, e, innerHitsMap, ok);
162  break;
164  std::get<1>(kernels).set(checkRZ.get());
165  std::get<1>(kernels)(b, e, innerHitsMap, ok);
166  break;
168  std::get<2>(kernels).set(checkRZ.get());
169  std::get<2>(kernels)(b, e, innerHitsMap, ok);
170  break;
171  }
172  for (int i = 0; i != e - b; ++i) {
173  if (!ok[i])
174  continue;
175  if (theMaxElement != 0 && result.size() >= theMaxElement) {
176  result.clear();
177  edm::LogError("TooManyPairs") << "number of pairs exceed maximum, no pairs produced";
178  return;
179  }
180  result.add(b + i, io);
181  }
182  }
183  }
184  LogDebug("HitPairGeneratorFromLayerPair") << " total number of pairs provided back: " << result.size();
185  result.shrink_to_fit();
186 }
nSigmaRZ
constexpr double nSigmaRZ
Definition: PixelTripletLargeTipGenerator.cc:43
Hit
Definition: HitCollection.h:12
nSigmaPhi
constexpr float nSigmaPhi
Definition: PixelTripletLargeTipGenerator.cc:44
OrderedHitPairs
Definition: OrderedHitPairs.h:8
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
RecHitsSortedInPhi::u
std::vector< float > u
Definition: RecHitsSortedInPhi.h:106
TrackerGeometry.h
HitPairGeneratorFromLayerPair::innerLayer
Layer innerLayer(const Layers &layers) const
Definition: HitPairGeneratorFromLayerPair.h:63
ESHandle.h
DetLayer
Definition: DetLayer.h:21
HitDoublets::outer
Definition: RecHitsSortedInPhi.h:126
HitPairGeneratorFromLayerPair::outerLayer
Layer outerLayer(const Layers &layers) const
Definition: HitPairGeneratorFromLayerPair.h:64
InnerDeltaPhi
Definition: InnerDeltaPhi.h:19
TransientRecHitRecord.h
SeedingLayerSetsHits::SeedingLayer::detLayer
const DetLayer * detLayer() const
Definition: SeedingLayerSetsHits.h:50
RecHitsSortedInPhi::size
std::size_t size() const
Definition: RecHitsSortedInPhi.h:46
TrackerRecoGeometryRecord.h
sqr
int sqr(const T &t)
Definition: pfalgo_common_ref.h:9
cms::cuda::assert
assert(be >=bs)
RecHitsSortedInPhi::doubleRange
DoubleRange doubleRange(float phiMin, float phiMax) const
Definition: RecHitsSortedInPhi.cc:52
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
PixelRecoRange::empty
bool empty() const
Definition: PixelRecoRange.h:29
PixelRecoRange::min
T min() const
Definition: PixelRecoRange.h:25
CustomConfigs.Base
def Base(process)
Definition: CustomConfigs.py:17
LayerHitMapCache
Definition: LayerHitMapCache.h:14
RecHitsSortedInPhi::z
std::vector< float > z
Definition: RecHitsSortedInPhi.h:102
HitRZCompatibility::zAlgo
Definition: HitRZCompatibility.h:11
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
HitRZCompatibility.h
HitPairGeneratorFromLayerPair::hitPairs
void hitPairs(const TrackingRegion &reg, OrderedHitPairs &prs, const edm::Event &ev, const edm::EventSetup &es, Layers layers)
Definition: HitPairGeneratorFromLayerPair.cc:72
SurfaceOrientation::inner
Definition: Surface.h:19
PixelRecoRange::max
T max() const
Definition: PixelRecoRange.h:26
RecHitsSortedInPhi::Hit
BaseTrackerRecHit const * Hit
Definition: RecHitsSortedInPhi.h:19
PixelRecoRange::intersection
PixelRecoRange< T > intersection(const PixelRecoRange< T > &r) const
Definition: PixelRecoRange.h:40
b
double b
Definition: hdecay.h:118
Args
Definition: hcalPublishConditions.cc:31
Algo
Definition: fakeMenu.h:6
HitRZCompatibility
Definition: HitRZCompatibility.h:8
OrderedHitPairs.h
RecHitsSortedInPhi::rv
float rv(int i) const
Definition: RecHitsSortedInPhi.h:89
InnerDeltaPhi.h
RecHitsSortedInPhi
Definition: RecHitsSortedInPhi.h:17
RecHitsSortedInPhi::x
std::vector< float > x
Definition: RecHitsSortedInPhi.h:100
PixelRecoRange< float >
RecHitsSortedInPhi::theHits
std::vector< HitWithPhi > theHits
Definition: RecHitsSortedInPhi.h:95
HitDoublets
Definition: RecHitsSortedInPhi.h:124
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
a
double a
Definition: hdecay.h:119
HitPairGeneratorFromLayerPair::HitPairGeneratorFromLayerPair
HitPairGeneratorFromLayerPair(unsigned int inner, unsigned int outer, LayerCacheType *layerCache, unsigned int max=0)
Definition: HitPairGeneratorFromLayerPair.cc:34
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
RecHitsSortedInPhi::dv
std::vector< float > dv
Definition: RecHitsSortedInPhi.h:109
RecHitsSortedInPhi::empty
bool empty() const
Definition: RecHitsSortedInPhi.h:45
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
RecHitsSortedInPhi::drphi
std::vector< float > drphi
Definition: RecHitsSortedInPhi.h:103
RecHitsSortedInPhi::isBarrel
bool isBarrel
Definition: RecHitsSortedInPhi.h:98
BarrelDetLayer.h
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
RecHitsSortedInPhi::du
std::vector< float > du
Definition: RecHitsSortedInPhi.h:108
SeedingLayerSetsHits::SeedingLayer
Definition: SeedingLayerSetsHits.h:37
TrackingRegionBase.h
GeomDetEnumerators
Definition: GeomDetEnumerators.h:8
HitPairGeneratorFromLayerPair::~HitPairGeneratorFromLayerPair
~HitPairGeneratorFromLayerPair()
Definition: HitPairGeneratorFromLayerPair.cc:40
std
Definition: JetResolutionObject.h:76
HitPairGeneratorFromLayerPair.h
T
long double T
Definition: Basic3DVectorLD.h:48
ForwardDetLayer.h
HitDoublets::inner
Definition: RecHitsSortedInPhi.h:126
SeedingLayerSetsHits::SeedingLayerSet
Definition: SeedingLayerSetsHits.h:65
DetLayer.h
HitPairGeneratorFromLayerPair::theMaxElement
const unsigned int theMaxElement
Definition: HitPairGeneratorFromLayerPair.h:70
HitPairGeneratorFromLayerPair::doublets
HitDoublets doublets(const TrackingRegion &reg, const edm::Event &ev, const edm::EventSetup &es, Layers layers)
Definition: HitPairGeneratorFromLayerPair.h:24
TrackingRegion
Definition: TrackingRegion.h:41
TransientTrackingRecHitBuilder.h
mps_fire.result
result
Definition: mps_fire.py:311
TrackingRegion.h
Range
PixelRecoRange< float > Range
Definition: HitPairGeneratorFromLayerPair.cc:19
SurfaceOrientation::outer
Definition: Surface.h:19
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
HitRZCompatibility::etaAlgo
Definition: HitRZCompatibility.h:11
OrderedHitPair
Definition: OrderedHitPair.h:6
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HitRZCompatibility::rAlgo
Definition: HitRZCompatibility.h:11
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
Hit
SeedingHitSet::ConstRecHitPointer Hit
Definition: SeedGeneratorFromProtoTracksEDProducer.cc:34
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
RecHitsSortedInPhi::y
std::vector< float > y
Definition: RecHitsSortedInPhi.h:101
RecHitsSortedInPhi::v
std::vector< float > v
Definition: RecHitsSortedInPhi.h:107