CMS 3D CMS Logo

PFRecHitCaloNavigatorWithTime.h
Go to the documentation of this file.
1 
2 #ifndef RecoParticleFlow_PFClusterProducer_PFRecHitCaloNavigatorWithTime_h
3 #define RecoParticleFlow_PFClusterProducer_PFRecHitCaloNavigatorWithTime_h
4 
5 #include <memory>
6 
11 
17 
22 
25 
27 
28 template <typename D, typename T, bool ownsTopo = true>
30 public:
32  sigmaCut2_ = pow(iConfig.getParameter<double>("sigmaCut"), 2);
33  const edm::ParameterSet& timeResConf = iConfig.getParameterSet("timeResolutionCalc");
34  _timeResolutionCalc = std::make_unique<CaloRecHitResolutionProvider>(timeResConf);
35  }
36 
38  if (!ownsTopo) {
39  topology_.release();
40  }
41  }
42 
44  std::unique_ptr<reco::PFRecHitCollection>& hits,
45  edm::RefProd<reco::PFRecHitCollection>& refProd) override {
46  DetId detid(hit.detId());
47 
48  CaloNavigator<D> navigator(detid, topology_.get());
49 
50  DetId N(0);
51  DetId E(0);
52  DetId S(0);
53  DetId W(0);
54  DetId NW(0);
55  DetId NE(0);
56  DetId SW(0);
57  DetId SE(0);
58 
59  N = navigator.north();
60  associateNeighbour(N, hit, hits, refProd, 0, 1);
61 
62  if (N != DetId(0)) {
63  NE = navigator.east();
64  } else {
65  navigator.home();
66  E = navigator.east();
67  NE = navigator.north();
68  }
69  associateNeighbour(NE, hit, hits, refProd, 1, 1);
70  navigator.home();
71 
72  S = navigator.south();
73  associateNeighbour(S, hit, hits, refProd, 0, -1);
74 
75  if (S != DetId(0)) {
76  SW = navigator.west();
77  } else {
78  navigator.home();
79  W = navigator.west();
80  SW = navigator.south();
81  }
82  associateNeighbour(SW, hit, hits, refProd, -1, -1);
83  navigator.home();
84 
85  E = navigator.east();
86  associateNeighbour(E, hit, hits, refProd, 1, 0);
87 
88  if (E != DetId(0)) {
89  SE = navigator.south();
90  } else {
91  navigator.home();
92  S = navigator.south();
93  SE = navigator.east();
94  }
95  associateNeighbour(SE, hit, hits, refProd, 1, -1);
96  navigator.home();
97 
98  W = navigator.west();
99  associateNeighbour(W, hit, hits, refProd, -1, 0);
100 
101  if (W != DetId(0)) {
102  NW = navigator.north();
103  } else {
104  navigator.home();
105  N = navigator.north();
106  NW = navigator.west();
107  }
108  associateNeighbour(NW, hit, hits, refProd, -1, 1);
109  }
110 
111 protected:
112  double sigmaCut2_;
113  std::unique_ptr<const T> topology_;
114  std::unique_ptr<CaloRecHitResolutionProvider> _timeResolutionCalc;
115 
116  void associateNeighbour(const DetId& id,
118  std::unique_ptr<reco::PFRecHitCollection>& hits,
120  short eta,
121  short phi) {
122  double sigma2 = 10000.0;
123 
124  auto found_hit = std::lower_bound(hits->begin(), hits->end(), id, [](const reco::PFRecHit& a, DetId b) {
125  if (DetId(a.detId()).det() == DetId::Hcal || b.det() == DetId::Hcal)
126  return (HcalDetId)(a.detId()) < (HcalDetId)(b);
127 
128  else
129  return a.detId() < b.rawId();
130  });
131 
132  if (found_hit != hits->end() &&
133  ((found_hit->detId() == id.rawId()) ||
134  ((id.det() == DetId::Hcal) && ((HcalDetId)(found_hit->detId()) == (HcalDetId)(id))))) {
135  sigma2 = _timeResolutionCalc->timeResolution2(hit.energy()) +
136  _timeResolutionCalc->timeResolution2(found_hit->energy());
137  const double deltaTime = hit.time() - found_hit->time();
138  if (deltaTime * deltaTime < sigmaCut2_ * sigma2) {
139  hit.addNeighbour(eta, phi, 0, found_hit - hits->begin());
140  }
141  }
142  }
143 };
144 
145 #endif
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
ParameterSet const & getParameterSet(std::string const &) const
constexpr int pow(int x)
Definition: conifer.h:24
void associateNeighbour(const DetId &id, reco::PFRecHit &hit, std::unique_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd, short eta, short phi)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalc
Definition: DetId.h:17
#define N
Definition: blowfish.cc:9
double b
Definition: hdecay.h:120
void associateNeighbours(reco::PFRecHit &hit, std::unique_ptr< reco::PFRecHitCollection > &hits, edm::RefProd< reco::PFRecHitCollection > &refProd) override
double a
Definition: hdecay.h:121
PFRecHitCaloNavigatorWithTime(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)