CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
KDTreeLinkerTrackEcal Class Reference
Inheritance diagram for KDTreeLinkerTrackEcal:
KDTreeLinkerBase

Public Member Functions

void buildTree () override
 
void clear () override
 
void insertFieldClusterElt (reco::PFBlockElement *ecalCluster) override
 
void insertTargetElt (reco::PFBlockElement *track) override
 
 KDTreeLinkerTrackEcal (const edm::ParameterSet &conf)
 
void searchLinks () override
 
void updatePFBlockEltWithLinks () override
 
 ~KDTreeLinkerTrackEcal () override
 
- Public Member Functions inherited from KDTreeLinkerBase
const reco::PFBlockElement::TypefieldType () const
 
 KDTreeLinkerBase (const edm::ParameterSet &conf)
 
void process ()
 
void setDebug (bool isDebug)
 
void setFieldType (const reco::PFBlockElement::Type &fld)
 
void setTargetType (const reco::PFBlockElement::Type &tgt)
 
const reco::PFBlockElement::TypetargetType () const
 
virtual ~KDTreeLinkerBase ()
 

Private Attributes

BlockEltSet fieldClusterSet_
 
RecHit2BlockEltMap rechit2ClusterLinks_
 
RecHitSet rechitsSet_
 
BlockElt2BlockEltMap target2ClusterLinks_
 
BlockEltSet targetSet_
 
KDTreeLinkerAlgo< reco::PFRecHit const * > tree_
 

Additional Inherited Members

- Protected Attributes inherited from KDTreeLinkerBase
reco::PFBlockElement::Type _fieldType
 
reco::PFBlockElement::Type _targetType
 
float cristalPhiEtaMaxSize_ = 0.04
 
float cristalXYMaxSize_ = 3.
 
const float cutOffFrac = 1E-4
 
bool debug_ = false
 
float phiOffset_ = 0.25
 

Detailed Description

Definition at line 10 of file KDTreeLinkerTrackEcal.cc.

Constructor & Destructor Documentation

◆ KDTreeLinkerTrackEcal()

KDTreeLinkerTrackEcal::KDTreeLinkerTrackEcal ( const edm::ParameterSet conf)

Definition at line 61 of file KDTreeLinkerTrackEcal.cc.

61 : KDTreeLinkerBase(conf) {}

◆ ~KDTreeLinkerTrackEcal()

KDTreeLinkerTrackEcal::~KDTreeLinkerTrackEcal ( )
override

Definition at line 63 of file KDTreeLinkerTrackEcal.cc.

63 { clear(); }

References clear().

Member Function Documentation

◆ buildTree()

void KDTreeLinkerTrackEcal::buildTree ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 100 of file KDTreeLinkerTrackEcal.cc.

100  {
101  // List of pseudo-rechits that will be used to create the KDTree
102  std::vector<KDTreeNodeInfo<reco::PFRecHit const *, 2>> eltList;
103 
104  // Filling of this list
105  for (RecHitSet::const_iterator it = rechitsSet_.begin(); it != rechitsSet_.end(); it++) {
106  const reco::PFRecHit::REPPoint &posrep = (*it)->positionREP();
107 
108  KDTreeNodeInfo<reco::PFRecHit const *, 2> rh1(*it, posrep.eta(), posrep.phi());
109  eltList.push_back(rh1);
110 
111  // Here we solve the problem of phi circular set by duplicating some rechits
112  // too close to -Pi (or to Pi) and adding (substracting) to them 2 * Pi.
113  if (rh1.dims[1] > (M_PI - phiOffset_)) {
114  float phi = rh1.dims[1] - 2 * M_PI;
115  KDTreeNodeInfo<reco::PFRecHit const *, 2> rh2(*it, float(posrep.eta()), phi);
116  eltList.push_back(rh2);
117  }
118 
119  if (rh1.dims[1] < (M_PI * -1.0 + phiOffset_)) {
120  float phi = rh1.dims[1] + 2 * M_PI;
121  KDTreeNodeInfo<reco::PFRecHit const *, 2> rh3(*it, float(posrep.eta()), phi);
122  eltList.push_back(rh3);
123  }
124  }
125 
126  // Here we define the upper/lower bounds of the 2D space (eta/phi).
127  float phimin = -1.0 * M_PI - phiOffset_;
128  float phimax = M_PI + phiOffset_;
129 
130  // etamin-etamax, phimin-phimax
131  KDTreeBox region(-3.0f, 3.0f, phimin, phimax);
132 
133  // We may now build the KDTree
134  tree_.build(eltList, region);
135 }

References KDTreeLinkerAlgo< DATA, DIM >::build(), RhoEtaPhi::eta(), f, M_PI, phi, RhoEtaPhi::phi(), phimax, phimin, KDTreeLinkerBase::phiOffset_, rechitsSet_, HLT_2018_cff::region, and tree_.

◆ clear()

void KDTreeLinkerTrackEcal::clear ( void  )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 259 of file KDTreeLinkerTrackEcal.cc.

259  {
260  targetSet_.clear();
261  fieldClusterSet_.clear();
262 
263  rechitsSet_.clear();
264 
265  rechit2ClusterLinks_.clear();
266  target2ClusterLinks_.clear();
267 
268  tree_.clear();
269 }

References KDTreeLinkerAlgo< DATA, DIM >::clear(), fieldClusterSet_, rechit2ClusterLinks_, rechitsSet_, target2ClusterLinks_, targetSet_, and tree_.

Referenced by ~KDTreeLinkerTrackEcal().

◆ insertFieldClusterElt()

void KDTreeLinkerTrackEcal::insertFieldClusterElt ( reco::PFBlockElement ecalCluster)
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 71 of file KDTreeLinkerTrackEcal.cc.

71  {
72  const reco::PFClusterRef &clusterref = ecalCluster->clusterRef();
73 
74  // This test is more or less done in PFBlockAlgo.h. In others cases, it should be switch on.
75  // if (!((clusterref->layer() == PFLayer::ECAL_ENDCAP) ||
76  // (clusterref->layer() == PFLayer::ECAL_BARREL)))
77  // return;
78 
79  const std::vector<reco::PFRecHitFraction> &fraction = clusterref->recHitFractions();
80 
81  // We create a list of ecalCluster
82  fieldClusterSet_.insert(ecalCluster);
83  for (size_t rhit = 0; rhit < fraction.size(); ++rhit) {
84  const reco::PFRecHitRef &rh = fraction[rhit].recHitRef();
85  double fract = fraction[rhit].fraction();
86 
87  if ((rh.isNull()) || (fract < cutOffFrac))
88  continue;
89 
90  const reco::PFRecHit &rechit = *rh;
91 
92  // We save the links rechit to EcalClusters
93  rechit2ClusterLinks_[&rechit].insert(ecalCluster);
94 
95  // We create a liste of rechits
96  rechitsSet_.insert(&rechit);
97  }
98 }

References reco::PFBlockElement::clusterRef(), KDTreeLinkerBase::cutOffFrac, fieldClusterSet_, funct::fract(), HLT_2018_cff::fraction, edm::Ref< C, T, F >::isNull(), rechit2ClusterLinks_, and rechitsSet_.

◆ insertTargetElt()

void KDTreeLinkerTrackEcal::insertTargetElt ( reco::PFBlockElement track)
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 65 of file KDTreeLinkerTrackEcal.cc.

65  {
66  if (track->trackRefPF()->extrapolatedPoint(reco::PFTrajectoryPoint::ECALShowerMax).isValid()) {
67  targetSet_.insert(track);
68  }
69 }

References reco::PFTrajectoryPoint::ECALShowerMax, targetSet_, and HLT_2018_cff::track.

◆ searchLinks()

void KDTreeLinkerTrackEcal::searchLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 137 of file KDTreeLinkerTrackEcal.cc.

137  {
138  // Most of the code has been taken from LinkByRecHit.cc
139 
140  // We iterate over the tracks.
141  for (BlockEltSet::iterator it = targetSet_.begin(); it != targetSet_.end(); it++) {
142  reco::PFRecTrackRef trackref = (*it)->trackRefPF();
143 
144  // We set the multilinks flag of the track to true. It will allow us to
145  // use in an optimized way our algo results in the recursive linking algo.
146  (*it)->setIsValidMultilinks(true);
147 
148  const reco::PFTrajectoryPoint &atECAL = trackref->extrapolatedPoint(reco::PFTrajectoryPoint::ECALShowerMax);
149 
150  // The track didn't reach ecal
151  if (!atECAL.isValid())
152  continue;
153 
154  const reco::PFTrajectoryPoint &atVertex = trackref->extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach);
155 
156  double trackPt = sqrt(atVertex.momentum().Vect().Perp2());
157  float tracketa = atECAL.positionREP().eta();
158  float trackphi = atECAL.positionREP().phi();
159  double trackx = atECAL.position().X();
160  double tracky = atECAL.position().Y();
161  double trackz = atECAL.position().Z();
162 
163  // Estimate the maximal envelope in phi/eta that will be used to find rechit candidates.
164  // Same envelope for cap et barrel rechits.
165  float range = cristalPhiEtaMaxSize_ * (2.0 + 1.0 / std::min(1., trackPt / 2.));
166 
167  // We search for all candidate recHits, ie all recHits contained in the maximal size envelope.
168  std::vector<reco::PFRecHit const *> recHits;
169  KDTreeBox trackBox(tracketa - range, tracketa + range, trackphi - range, trackphi + range);
170  tree_.search(trackBox, recHits);
171 
172  // Here we check all rechit candidates using the non-approximated method.
173  for (auto const &recHit : recHits) {
174  const auto &cornersxyz = recHit->getCornersXYZ();
175  const auto &posxyz = recHit->position();
176  const auto &rhrep = recHit->positionREP();
177  const auto &corners = recHit->getCornersREP();
178 
179  double rhsizeeta = fabs(corners[3].eta() - corners[1].eta());
180  double rhsizephi = fabs(corners[3].phi() - corners[1].phi());
181  if (rhsizephi > M_PI)
182  rhsizephi = 2. * M_PI - rhsizephi;
183 
184  double deta = fabs(rhrep.eta() - tracketa);
185  double dphi = fabs(rhrep.phi() - trackphi);
186  if (dphi > M_PI)
187  dphi = 2. * M_PI - dphi;
188 
189  // Find all clusters associated to given rechit
190  RecHit2BlockEltMap::iterator ret = rechit2ClusterLinks_.find(recHit);
191 
192  for (BlockEltSet::const_iterator clusterIt = ret->second.begin(); clusterIt != ret->second.end(); clusterIt++) {
193  reco::PFClusterRef clusterref = (*clusterIt)->clusterRef();
194  double clusterz = clusterref->position().z();
195  int fracsNbr = clusterref->recHitFractions().size();
196 
197  if (clusterref->layer() == PFLayer::ECAL_BARREL) { // BARREL
198  // Check if the track is in the barrel
199  if (fabs(trackz) > 300.)
200  continue;
201 
202  double _rhsizeeta = rhsizeeta * (2.00 + 1.0 / (fracsNbr * std::min(1., trackPt / 2.)));
203  double _rhsizephi = rhsizephi * (2.00 + 1.0 / (fracsNbr * std::min(1., trackPt / 2.)));
204 
205  // Check if the track and the cluster are linked
206  if (deta < (_rhsizeeta / 2.) && dphi < (_rhsizephi / 2.))
207  target2ClusterLinks_[*it].insert(*clusterIt);
208 
209  } else { // ENDCAP
210 
211  // Check if the track is in the cap
212  if (fabs(trackz) < 300.)
213  continue;
214  if (trackz * clusterz < 0.)
215  continue;
216 
217  double x[5];
218  double y[5];
219  for (unsigned jc = 0; jc < 4; ++jc) {
220  auto cornerposxyz = cornersxyz[jc];
221  x[3 - jc] = cornerposxyz.x() +
222  (cornerposxyz.x() - posxyz.x()) * (1.00 + 0.50 / fracsNbr / std::min(1., trackPt / 2.));
223  y[3 - jc] = cornerposxyz.y() +
224  (cornerposxyz.y() - posxyz.y()) * (1.00 + 0.50 / fracsNbr / std::min(1., trackPt / 2.));
225  }
226 
227  x[4] = x[0];
228  y[4] = y[0];
229 
230  bool isinside = TMath::IsInside(trackx, tracky, 5, x, y);
231 
232  // Check if the track and the cluster are linked
233  if (isinside)
234  target2ClusterLinks_[*it].insert(*clusterIt);
235  }
236  }
237  }
238  }
239 }

References reco::PFTrajectoryPoint::ClosestApproach, KDTreeLinkerBase::cristalPhiEtaMaxSize_, PFLayer::ECAL_BARREL, reco::PFTrajectoryPoint::ECALShowerMax, PVValHelper::eta, reco::PFTrajectoryPoint::isValid(), M_PI, min(), reco::PFTrajectoryPoint::momentum(), phi, reco::PFTrajectoryPoint::position(), reco::PFTrajectoryPoint::positionREP(), FastTimerService_cff::range, rpcPointValidation_cfi::recHit, rechit2ClusterLinks_, FastTrackerRecHitMaskProducer_cfi::recHits, runTheMatrix::ret, KDTreeLinkerAlgo< DATA, DIM >::search(), mathSSE::sqrt(), target2ClusterLinks_, targetSet_, listHistos::trackPt, tree_, x, and y.

◆ updatePFBlockEltWithLinks()

void KDTreeLinkerTrackEcal::updatePFBlockEltWithLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 241 of file KDTreeLinkerTrackEcal.cc.

241  {
242  //TODO YG : Check if cluster positionREP() is valid ?
243 
244  // Here we save in each track the list of phi/eta values of linked clusters.
245  for (BlockElt2BlockEltMap::iterator it = target2ClusterLinks_.begin(); it != target2ClusterLinks_.end(); ++it) {
246  reco::PFMultiLinksTC multitracks(true);
247 
248  for (BlockEltSet::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) {
249  double clusterphi = (*jt)->clusterRef()->positionREP().phi();
250  double clustereta = (*jt)->clusterRef()->positionREP().eta();
251 
252  multitracks.linkedClusters.push_back(std::make_pair(clusterphi, clustereta));
253  }
254 
255  it->first->setMultilinks(multitracks);
256  }
257 }

References reco::PFMultiLinksTC::linkedClusters, and target2ClusterLinks_.

Member Data Documentation

◆ fieldClusterSet_

BlockEltSet KDTreeLinkerTrackEcal::fieldClusterSet_
private

Definition at line 42 of file KDTreeLinkerTrackEcal.cc.

Referenced by clear(), and insertFieldClusterElt().

◆ rechit2ClusterLinks_

RecHit2BlockEltMap KDTreeLinkerTrackEcal::rechit2ClusterLinks_
private

Definition at line 51 of file KDTreeLinkerTrackEcal.cc.

Referenced by clear(), insertFieldClusterElt(), and searchLinks().

◆ rechitsSet_

RecHitSet KDTreeLinkerTrackEcal::rechitsSet_
private

Definition at line 45 of file KDTreeLinkerTrackEcal.cc.

Referenced by buildTree(), clear(), and insertFieldClusterElt().

◆ target2ClusterLinks_

BlockElt2BlockEltMap KDTreeLinkerTrackEcal::target2ClusterLinks_
private

Definition at line 48 of file KDTreeLinkerTrackEcal.cc.

Referenced by clear(), searchLinks(), and updatePFBlockEltWithLinks().

◆ targetSet_

BlockEltSet KDTreeLinkerTrackEcal::targetSet_
private

Definition at line 41 of file KDTreeLinkerTrackEcal.cc.

Referenced by clear(), insertTargetElt(), and searchLinks().

◆ tree_

KDTreeLinkerAlgo<reco::PFRecHit const *> KDTreeLinkerTrackEcal::tree_
private

Definition at line 54 of file KDTreeLinkerTrackEcal.cc.

Referenced by buildTree(), clear(), and searchLinks().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DDAxes::y
KDTreeLinkerTrackEcal::rechitsSet_
RecHitSet rechitsSet_
Definition: KDTreeLinkerTrackEcal.cc:45
reco::PFTrajectoryPoint::momentum
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
Definition: PFTrajectoryPoint.h:109
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
min
T min(T a, T b)
Definition: MathUtil.h:58
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
KDTreeLinkerTrackEcal::tree_
KDTreeLinkerAlgo< reco::PFRecHit const * > tree_
Definition: KDTreeLinkerTrackEcal.cc:54
DDAxes::x
KDTreeLinkerBase::phiOffset_
float phiOffset_
Definition: KDTreeLinkerBase.h:84
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
KDTreeLinkerBase::cutOffFrac
const float cutOffFrac
Definition: KDTreeLinkerBase.h:87
edm::Ref< PFClusterCollection >
PFLayer::ECAL_BARREL
Definition: PFLayer.h:33
reco::PFTrajectoryPoint::positionREP
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
Definition: PFTrajectoryPoint.h:103
RhoEtaPhi
Definition: PtEtaPhiMass.h:38
KDTreeLinkerAlgo::search
void search(const KDTreeBox< DIM > &searchBox, std::vector< DATA > &resRecHitList)
Definition: KDTreeLinkerAlgo.h:203
PVValHelper::eta
Definition: PVValidationHelpers.h:69
reco::PFTrajectoryPoint::ECALShowerMax
Definition: PFTrajectoryPoint.h:46
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
KDTreeBox
Definition: KDTreeLinkerAlgo.h:14
reco::PFMultiLinksTC
Definition: PFMultilinksTC.h:14
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
KDTreeLinkerBase::cristalPhiEtaMaxSize_
float cristalPhiEtaMaxSize_
Definition: KDTreeLinkerBase.h:77
reco::PFTrajectoryPoint::position
const math::XYZPoint & position() const
cartesian position (x, y, z)
Definition: PFTrajectoryPoint.h:100
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
funct::fract
const Fraction< n, m >::type & fract()
Definition: Fraction.h:36
KDTreeNodeInfo
Definition: KDTreeLinkerAlgo.h:34
RhoEtaPhi::eta
float eta() const
momentum pseudorapidity
Definition: PtEtaPhiMass.h:52
reco::PFTrajectoryPoint::isValid
bool isValid() const
is this point valid ?
Definition: PFTrajectoryPoint.h:84
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
DDAxes::phi
RhoEtaPhi::phi
float phi() const
momentum azimuthal angle
Definition: PtEtaPhiMass.h:54
KDTreeLinkerAlgo::clear
void clear()
Definition: KDTreeLinkerAlgo.h:122
reco::PFTrajectoryPoint
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
Definition: PFTrajectoryPoint.h:26
KDTreeLinkerTrackEcal::targetSet_
BlockEltSet targetSet_
Definition: KDTreeLinkerTrackEcal.cc:41
KDTreeLinkerTrackEcal::fieldClusterSet_
BlockEltSet fieldClusterSet_
Definition: KDTreeLinkerTrackEcal.cc:42
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
KDTreeLinkerBase::KDTreeLinkerBase
KDTreeLinkerBase(const edm::ParameterSet &conf)
Definition: KDTreeLinkerBase.h:21
reco::PFRecHit
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
KDTreeLinkerAlgo::build
void build(std::vector< KDTreeNodeInfo< DATA, DIM > > &eltList, const KDTreeBox< DIM > &region)
Definition: KDTreeLinkerAlgo.h:147
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
reco::PFTrajectoryPoint::ClosestApproach
Point of closest approach from beam axis (initial point in the case of PFSimParticle)
Definition: PFTrajectoryPoint.h:36
KDTreeLinkerTrackEcal::rechit2ClusterLinks_
RecHit2BlockEltMap rechit2ClusterLinks_
Definition: KDTreeLinkerTrackEcal.cc:51
listHistos.trackPt
trackPt
Definition: listHistos.py:120
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
KDTreeLinkerTrackEcal::clear
void clear() override
Definition: KDTreeLinkerTrackEcal.cc:259
reco::PFBlockElement::clusterRef
virtual const PFClusterRef & clusterRef() const
Definition: PFBlockElement.h:90
KDTreeLinkerTrackEcal::target2ClusterLinks_
BlockElt2BlockEltMap target2ClusterLinks_
Definition: KDTreeLinkerTrackEcal.cc:48