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

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

Additional Inherited Members

- Static Protected Member Functions inherited from KDTreeLinkerBase
template<typename T >
static std::vector< size_t > sort_indexes (const std::vector< T > &v)
 
- 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 11 of file KDTreeLinkerTrackEcal.cc.

Constructor & Destructor Documentation

◆ KDTreeLinkerTrackEcal()

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

Definition at line 62 of file KDTreeLinkerTrackEcal.cc.

62 : KDTreeLinkerBase(conf) {}

◆ ~KDTreeLinkerTrackEcal()

KDTreeLinkerTrackEcal::~KDTreeLinkerTrackEcal ( )
override

Definition at line 64 of file KDTreeLinkerTrackEcal.cc.

64 { clear(); }

References clear().

Member Function Documentation

◆ buildTree()

void KDTreeLinkerTrackEcal::buildTree ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 101 of file KDTreeLinkerTrackEcal.cc.

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

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

◆ clear()

void KDTreeLinkerTrackEcal::clear ( void  )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 265 of file KDTreeLinkerTrackEcal.cc.

265  {
266  targetSet_.clear();
267  fieldClusterSet_.clear();
268 
269  rechitsSet_.clear();
270 
271  rechit2ClusterLinks_.clear();
272  cluster2TargetLinks_.clear();
273 
274  tree_.clear();
275 }

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

Referenced by ~KDTreeLinkerTrackEcal().

◆ insertFieldClusterElt()

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

Implements KDTreeLinkerBase.

Definition at line 72 of file KDTreeLinkerTrackEcal.cc.

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

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

◆ insertTargetElt()

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

Implements KDTreeLinkerBase.

Definition at line 66 of file KDTreeLinkerTrackEcal.cc.

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

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

◆ searchLinks()

void KDTreeLinkerTrackEcal::searchLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 138 of file KDTreeLinkerTrackEcal.cc.

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

References reco::PFTrajectoryPoint::ClosestApproach, cluster2TargetLinks_, 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(), targetSet_, listHistos::trackPt, tree_, x, and y.

◆ updatePFBlockEltWithLinks()

void KDTreeLinkerTrackEcal::updatePFBlockEltWithLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 238 of file KDTreeLinkerTrackEcal.cc.

238  {
239  //TODO YG : Check if cluster positionREP() is valid ?
240 
241  // Here we save in each ECAL cluster the list of phi/eta values of linked tracks.
242  for (BlockElt2BlockEltMap::iterator it = cluster2TargetLinks_.begin(); it != cluster2TargetLinks_.end(); ++it) {
243  const auto &ecalElt = it->first;
244  const auto &trackEltSet = it->second;
245  reco::PFMultiLinksTC multitracks(true);
246 
247  for (const auto &trackElt : trackEltSet) {
248  const reco::PFRecTrackRef &trackref = trackElt->trackRefPF();
249  const reco::PFTrajectoryPoint &atECAL = trackref->extrapolatedPoint(reco::PFTrajectoryPoint::ECALShowerMax);
250  double tracketa = atECAL.positionREP().eta();
251  double trackphi = atECAL.positionREP().phi();
252 
253  multitracks.linkedClusters.push_back(std::make_pair(trackphi, tracketa));
254 
255  // We set the multilinks flag of the track (for links to ECAL) to true. It will allow us to
256  // use it in an optimized way in prefilter
257  trackElt->setIsValidMultilinks(true, _fieldType);
258  }
259 
260  // We set multilinks of the ECAL element (for links to tracks)
261  ecalElt->setMultilinks(multitracks, _targetType);
262  }
263 }

References KDTreeLinkerBase::_fieldType, KDTreeLinkerBase::_targetType, cluster2TargetLinks_, reco::PFTrajectoryPoint::ECALShowerMax, reco::PFMultiLinksTC::linkedClusters, and reco::PFTrajectoryPoint::positionREP().

Member Data Documentation

◆ cluster2TargetLinks_

BlockElt2BlockEltMap KDTreeLinkerTrackEcal::cluster2TargetLinks_
private

Definition at line 49 of file KDTreeLinkerTrackEcal.cc.

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

◆ fieldClusterSet_

BlockEltSet KDTreeLinkerTrackEcal::fieldClusterSet_
private

Definition at line 43 of file KDTreeLinkerTrackEcal.cc.

Referenced by clear(), and insertFieldClusterElt().

◆ rechit2ClusterLinks_

RecHit2BlockEltMap KDTreeLinkerTrackEcal::rechit2ClusterLinks_
private

Definition at line 52 of file KDTreeLinkerTrackEcal.cc.

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

◆ rechitsSet_

RecHitSet KDTreeLinkerTrackEcal::rechitsSet_
private

Definition at line 46 of file KDTreeLinkerTrackEcal.cc.

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

◆ targetSet_

BlockEltSet KDTreeLinkerTrackEcal::targetSet_
private

Definition at line 42 of file KDTreeLinkerTrackEcal.cc.

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

◆ tree_

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

Definition at line 55 of file KDTreeLinkerTrackEcal.cc.

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

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:373
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
DDAxes::y
KDTreeLinkerTrackEcal::rechitsSet_
RecHitSet rechitsSet_
Definition: KDTreeLinkerTrackEcal.cc:46
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
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:55
DDAxes::x
KDTreeLinkerTrackEcal::cluster2TargetLinks_
BlockElt2BlockEltMap cluster2TargetLinks_
Definition: KDTreeLinkerTrackEcal.cc:49
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
KDTreeLinkerBase::_targetType
reco::PFBlockElement::Type _targetType
Definition: KDTreeLinkerBase.h:75
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52795
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
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88272
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
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:42
KDTreeLinkerTrackEcal::fieldClusterSet_
BlockEltSet fieldClusterSet_
Definition: KDTreeLinkerTrackEcal.cc:43
KDTreeLinkerBase::_fieldType
reco::PFBlockElement::Type _fieldType
Definition: KDTreeLinkerBase.h:75
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
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:52
listHistos.trackPt
trackPt
Definition: listHistos.py:120
KDTreeLinkerTrackEcal::clear
void clear() override
Definition: KDTreeLinkerTrackEcal.cc:265
reco::PFBlockElement::clusterRef
virtual const PFClusterRef & clusterRef() const
Definition: PFBlockElement.h:90