CMS 3D CMS Logo

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

Public Member Functions

void buildTree () override
 
void clear () override
 
void insertFieldClusterElt (reco::PFBlockElement *hcalCluster) override
 
void insertTargetElt (reco::PFBlockElement *track) override
 
 KDTreeLinkerTrackHcal (const edm::ParameterSet &conf)
 
void searchLinks () override
 
void updatePFBlockEltWithLinks () override
 
 ~KDTreeLinkerTrackHcal () 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

bool checkExit_
 
BlockElt2BlockEltMap cluster2TargetLinks_
 
BlockEltSet fieldClusterSet_
 
RecHit2BlockEltMap rechit2ClusterLinks_
 
RecHitSet rechitsSet_
 
BlockEltSet targetSet_
 
reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance_
 
std::string trajectoryLayerEntranceString_
 
reco::PFTrajectoryPoint::LayerType trajectoryLayerExit_
 
std::string trajectoryLayerExitString_
 
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 8 of file KDTreeLinkerTrackHcal.cc.

Constructor & Destructor Documentation

◆ KDTreeLinkerTrackHcal()

KDTreeLinkerTrackHcal::KDTreeLinkerTrackHcal ( const edm::ParameterSet conf)

Definition at line 66 of file KDTreeLinkerTrackHcal.cc.

References cms::cuda::assert(), checkExit_, KDTreeLinkerBase::cristalPhiEtaMaxSize_, reco::PFTrajectoryPoint::HCALEntrance, reco::PFTrajectoryPoint::HCALExit, reco::PFTrajectoryPoint::layerTypeByName(), KDTreeLinkerBase::phiOffset_, trajectoryLayerEntrance_, trajectoryLayerEntranceString_, trajectoryLayerExit_, trajectoryLayerExitString_, reco::PFTrajectoryPoint::Unknown, and reco::PFTrajectoryPoint::VFcalEntrance.

◆ ~KDTreeLinkerTrackHcal()

KDTreeLinkerTrackHcal::~KDTreeLinkerTrackHcal ( )
override

Definition at line 87 of file KDTreeLinkerTrackHcal.cc.

87 { clear(); }

References clear().

Member Function Documentation

◆ buildTree()

void KDTreeLinkerTrackHcal::buildTree ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 124 of file KDTreeLinkerTrackHcal.cc.

124  {
125  // List of pseudo-rechits that will be used to create the KDTree
126  std::vector<KDTreeNodeInfo<reco::PFRecHit const*, 2>> eltList;
127 
128  // Filling of this list
129  for (RecHitSet::const_iterator it = rechitsSet_.begin(); it != rechitsSet_.end(); it++) {
130  const reco::PFRecHit::REPPoint& posrep = (*it)->positionREP();
131 
132  KDTreeNodeInfo<reco::PFRecHit const*, 2> rh1(*it, posrep.eta(), posrep.phi());
133  eltList.push_back(rh1);
134 
135  // Here we solve the problem of phi circular set by duplicating some rechits
136  // too close to -Pi (or to Pi) and adding (substracting) to them 2 * Pi.
137  if (rh1.dims[1] > (M_PI - phiOffset_)) {
138  float phi = rh1.dims[1] - 2 * M_PI;
139  KDTreeNodeInfo<reco::PFRecHit const*, 2> rh2(*it, float(posrep.eta()), phi);
140  eltList.push_back(rh2);
141  }
142 
143  if (rh1.dims[1] < (M_PI * -1.0 + phiOffset_)) {
144  float phi = rh1.dims[1] + 2 * M_PI;
145  KDTreeNodeInfo<reco::PFRecHit const*, 2> rh3(*it, float(posrep.eta()), phi);
146  eltList.push_back(rh3);
147  }
148  }
149 
150  // Here we define the upper/lower bounds of the 2D space (eta/phi).
151  float phimin = -1.0 * M_PI - phiOffset_;
152  float phimax = M_PI + phiOffset_;
153 
154  // etamin-etamax, phimin-phimax
155  KDTreeBox region(-3.0f, 3.0f, phimin, phimax);
156 
157  // We may now build the KDTree
158  tree_.build(eltList, region);
159 }

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 KDTreeLinkerTrackHcal::clear ( void  )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 264 of file KDTreeLinkerTrackHcal.cc.

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

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

Referenced by ~KDTreeLinkerTrackHcal().

◆ insertFieldClusterElt()

void KDTreeLinkerTrackHcal::insertFieldClusterElt ( reco::PFBlockElement hcalCluster)
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 95 of file KDTreeLinkerTrackHcal.cc.

95  {
96  const reco::PFClusterRef& clusterref = hcalCluster->clusterRef();
97 
98  // This test is more or less done in PFBlockAlgo.h. In others cases, it should be switch on.
99  // if (!((clusterref->layer() == PFLayer::HCAL_ENDCAP) ||
100  // (clusterref->layer() == PFLayer::HCAL_BARREL1)))
101  // return;
102 
103  const std::vector<reco::PFRecHitFraction>& fraction = clusterref->recHitFractions();
104 
105  // We create a list of hcalCluster
106  fieldClusterSet_.insert(hcalCluster);
107  for (size_t rhit = 0; rhit < fraction.size(); ++rhit) {
108  const reco::PFRecHitRef& rh = fraction[rhit].recHitRef();
109  double fract = fraction[rhit].fraction();
110 
111  if ((rh.isNull()) || (fract < cutOffFrac))
112  continue;
113 
114  const reco::PFRecHit& rechit = *rh;
115 
116  // We save the links rechit to HcalClusters
117  rechit2ClusterLinks_[&rechit].insert(hcalCluster);
118 
119  // We create a liste of rechits
120  rechitsSet_.insert(&rechit);
121  }
122 }

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

◆ insertTargetElt()

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

Implements KDTreeLinkerBase.

Definition at line 89 of file KDTreeLinkerTrackHcal.cc.

89  {
90  if (track->trackRefPF()->extrapolatedPoint(trajectoryLayerEntrance_).isValid()) {
91  targetSet_.insert(track);
92  }
93 }

References targetSet_, HLT_2018_cff::track, and trajectoryLayerEntrance_.

◆ searchLinks()

void KDTreeLinkerTrackHcal::searchLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 161 of file KDTreeLinkerTrackHcal.cc.

161  {
162  // Most of the code has been taken from LinkByRecHit.cc
163 
164  // We iterate over the tracks.
165  for (BlockEltSet::iterator it = targetSet_.begin(); it != targetSet_.end(); it++) {
166  reco::PFRecTrackRef trackref = (*it)->trackRefPF();
167 
168  const reco::PFTrajectoryPoint& atHCAL = trackref->extrapolatedPoint(trajectoryLayerEntrance_);
169 
170  // The track didn't reach hcal
171  if (!atHCAL.isValid())
172  continue;
173 
174  // In case the exit point check is requested, check eta and phi differences between entrance and exit
175  double dHeta = 0.0;
176  float dHphi = 0.0;
177  if (checkExit_) {
178  const reco::PFTrajectoryPoint& atHCALExit = trackref->extrapolatedPoint(trajectoryLayerExit_);
179  dHeta = atHCALExit.positionREP().eta() - atHCAL.positionREP().eta();
180  dHphi = atHCALExit.positionREP().phi() - atHCAL.positionREP().phi();
181  if (dHphi > M_PI)
182  dHphi = dHphi - 2. * M_PI;
183  else if (dHphi < -M_PI)
184  dHphi = dHphi + 2. * M_PI;
185  } // checkExit_
186 
187  float tracketa = atHCAL.positionREP().eta() + 0.1 * dHeta;
188  float trackphi = atHCAL.positionREP().phi() + 0.1 * dHphi;
189 
190  if (trackphi > M_PI)
191  trackphi -= 2 * M_PI;
192  else if (trackphi < -M_PI)
193  trackphi += 2 * M_PI;
194 
195  // Estimate the maximal envelope in phi/eta that will be used to find rechit candidates.
196  // Same envelope for cap et barrel rechits.
197  double inflation = 1.;
198  float rangeeta = (cristalPhiEtaMaxSize_ * (1.5 + 0.5) + 0.2 * fabs(dHeta)) * inflation;
199  float rangephi = (cristalPhiEtaMaxSize_ * (1.5 + 0.5) + 0.2 * fabs(dHphi)) * inflation;
200 
201  // We search for all candidate recHits, ie all recHits contained in the maximal size envelope.
202  std::vector<reco::PFRecHit const*> recHits;
203  KDTreeBox trackBox(tracketa - rangeeta, tracketa + rangeeta, trackphi - rangephi, trackphi + rangephi);
204  tree_.search(trackBox, recHits);
205 
206  // Here we check all rechit candidates using the non-approximated method.
207  for (auto const& recHit : recHits) {
208  const auto& rhrep = recHit->positionREP();
209  const auto& corners = recHit->getCornersREP();
210 
211  double rhsizeeta = fabs(corners[3].eta() - corners[1].eta());
212  double rhsizephi = fabs(corners[3].phi() - corners[1].phi());
213  if (rhsizephi > M_PI)
214  rhsizephi = 2. * M_PI - rhsizephi;
215 
216  double deta = fabs(rhrep.eta() - tracketa);
217  double dphi = fabs(rhrep.phi() - trackphi);
218  if (dphi > M_PI)
219  dphi = 2. * M_PI - dphi;
220 
221  // Find all clusters associated to given rechit
222  RecHit2BlockEltMap::iterator ret = rechit2ClusterLinks_.find(recHit);
223 
224  for (BlockEltSet::iterator clusterIt = ret->second.begin(); clusterIt != ret->second.end(); clusterIt++) {
225  const reco::PFClusterRef clusterref = (*clusterIt)->clusterRef();
226  int fracsNbr = clusterref->recHitFractions().size();
227 
228  double _rhsizeeta = rhsizeeta * (1.5 + 0.5 / fracsNbr) + 0.2 * fabs(dHeta);
229  double _rhsizephi = rhsizephi * (1.5 + 0.5 / fracsNbr) + 0.2 * fabs(dHphi);
230 
231  // Check if the track and the cluster are linked
232  if (deta < (_rhsizeeta / 2.) && dphi < (_rhsizephi / 2.))
233  cluster2TargetLinks_[*clusterIt].insert(*it);
234  }
235  }
236  }
237 }

References checkExit_, cluster2TargetLinks_, KDTreeLinkerBase::cristalPhiEtaMaxSize_, PVValHelper::eta, reco::PFTrajectoryPoint::isValid(), M_PI, phi, reco::PFTrajectoryPoint::positionREP(), rpcPointValidation_cfi::recHit, rechit2ClusterLinks_, FastTrackerRecHitMaskProducer_cfi::recHits, runTheMatrix::ret, KDTreeLinkerAlgo< DATA, DIM >::search(), targetSet_, trajectoryLayerEntrance_, trajectoryLayerExit_, and tree_.

◆ updatePFBlockEltWithLinks()

void KDTreeLinkerTrackHcal::updatePFBlockEltWithLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 239 of file KDTreeLinkerTrackHcal.cc.

239  {
240  //TODO YG : Check if cluster positionREP() is valid ?
241 
242  // Here we save in each HCAL cluster the list of phi/eta values of linked clusters (actually tracks).
243  for (BlockElt2BlockEltMap::iterator it = cluster2TargetLinks_.begin(); it != cluster2TargetLinks_.end(); ++it) {
244  reco::PFMultiLinksTC multitracks(true);
245 
246  for (BlockEltSet::iterator jt = it->second.begin(); jt != it->second.end(); ++jt) {
247  reco::PFRecTrackRef trackref = (*jt)->trackRefPF();
248  const reco::PFTrajectoryPoint& atHCAL = trackref->extrapolatedPoint(trajectoryLayerEntrance_);
249  double tracketa = atHCAL.positionREP().eta();
250  double trackphi = atHCAL.positionREP().phi();
251 
252  multitracks.linkedClusters.push_back(std::make_pair(trackphi, tracketa));
253  }
254 
255  it->first->setMultilinks(multitracks);
256  }
257 
258  // We set the multilinks flag of the track to true. It will allow us to
259  // use in an optimized way our algo results in the recursive linking algo.
260  for (BlockEltSet::iterator it = fieldClusterSet_.begin(); it != fieldClusterSet_.end(); ++it)
261  (*it)->setIsValidMultilinks(true);
262 }

References cluster2TargetLinks_, fieldClusterSet_, reco::PFMultiLinksTC::linkedClusters, reco::PFTrajectoryPoint::positionREP(), and trajectoryLayerEntrance_.

Member Data Documentation

◆ checkExit_

bool KDTreeLinkerTrackHcal::checkExit_
private

Definition at line 59 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal(), and searchLinks().

◆ cluster2TargetLinks_

BlockElt2BlockEltMap KDTreeLinkerTrackHcal::cluster2TargetLinks_
private

Definition at line 46 of file KDTreeLinkerTrackHcal.cc.

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

◆ fieldClusterSet_

BlockEltSet KDTreeLinkerTrackHcal::fieldClusterSet_
private

◆ rechit2ClusterLinks_

RecHit2BlockEltMap KDTreeLinkerTrackHcal::rechit2ClusterLinks_
private

Definition at line 49 of file KDTreeLinkerTrackHcal.cc.

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

◆ rechitsSet_

RecHitSet KDTreeLinkerTrackHcal::rechitsSet_
private

Definition at line 43 of file KDTreeLinkerTrackHcal.cc.

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

◆ targetSet_

BlockEltSet KDTreeLinkerTrackHcal::targetSet_
private

Definition at line 39 of file KDTreeLinkerTrackHcal.cc.

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

◆ trajectoryLayerEntrance_

reco::PFTrajectoryPoint::LayerType KDTreeLinkerTrackHcal::trajectoryLayerEntrance_
private

◆ trajectoryLayerEntranceString_

std::string KDTreeLinkerTrackHcal::trajectoryLayerEntranceString_
private

Definition at line 55 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal().

◆ trajectoryLayerExit_

reco::PFTrajectoryPoint::LayerType KDTreeLinkerTrackHcal::trajectoryLayerExit_
private

Definition at line 58 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal(), and searchLinks().

◆ trajectoryLayerExitString_

std::string KDTreeLinkerTrackHcal::trajectoryLayerExitString_
private

Definition at line 56 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal().

◆ tree_

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

Definition at line 52 of file KDTreeLinkerTrackHcal.cc.

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

KDTreeLinkerTrackHcal::rechitsSet_
RecHitSet rechitsSet_
Definition: KDTreeLinkerTrackHcal.cc:43
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
KDTreeLinkerTrackHcal::trajectoryLayerExitString_
std::string trajectoryLayerExitString_
Definition: KDTreeLinkerTrackHcal.cc:56
KDTreeLinkerTrackHcal::tree_
KDTreeLinkerAlgo< reco::PFRecHit const * > tree_
Definition: KDTreeLinkerTrackHcal.cc:52
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
edm::Ref::isNull
bool isNull() const
Checks for null.
Definition: Ref.h:235
reco::PFTrajectoryPoint::HCALExit
HCAL exit.
Definition: PFTrajectoryPoint.h:50
cms::cuda::assert
assert(be >=bs)
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 >
KDTreeLinkerTrackHcal::clear
void clear() override
Definition: KDTreeLinkerTrackHcal.cc:264
KDTreeLinkerTrackHcal::targetSet_
BlockEltSet targetSet_
Definition: KDTreeLinkerTrackHcal.cc:39
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
KDTreeBox
Definition: KDTreeLinkerAlgo.h:14
reco::PFMultiLinksTC
Definition: PFMultilinksTC.h:14
KDTreeLinkerTrackHcal::trajectoryLayerExit_
reco::PFTrajectoryPoint::LayerType trajectoryLayerExit_
Definition: KDTreeLinkerTrackHcal.cc:58
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
KDTreeLinkerBase::cristalPhiEtaMaxSize_
float cristalPhiEtaMaxSize_
Definition: KDTreeLinkerBase.h:77
reco::PFTrajectoryPoint::HCALEntrance
HCAL front face.
Definition: PFTrajectoryPoint.h:48
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
funct::fract
const Fraction< n, m >::type & fract()
Definition: Fraction.h:36
reco::PFTrajectoryPoint::layerTypeByName
static LayerType layerTypeByName(const std::string &name)
Definition: PFTrajectoryPoint.cc:42
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
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
reco::PFTrajectoryPoint::VFcalEntrance
VFcal(HF) front face.
Definition: PFTrajectoryPoint.h:54
RhoEtaPhi::phi
float phi() const
momentum azimuthal angle
Definition: PtEtaPhiMass.h:54
KDTreeLinkerAlgo::clear
void clear()
Definition: KDTreeLinkerAlgo.h:122
reco::PFTrajectoryPoint::Unknown
Definition: PFTrajectoryPoint.h:58
reco::PFTrajectoryPoint
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
Definition: PFTrajectoryPoint.h:26
KDTreeLinkerTrackHcal::trajectoryLayerEntranceString_
std::string trajectoryLayerEntranceString_
Definition: KDTreeLinkerTrackHcal.cc:55
HLT_2018_cff.region
region
Definition: HLT_2018_cff.py:81479
KDTreeLinkerTrackHcal::fieldClusterSet_
BlockEltSet fieldClusterSet_
Definition: KDTreeLinkerTrackHcal.cc:40
KDTreeLinkerBase::KDTreeLinkerBase
KDTreeLinkerBase(const edm::ParameterSet &conf)
Definition: KDTreeLinkerBase.h:21
KDTreeLinkerTrackHcal::trajectoryLayerEntrance_
reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance_
Definition: KDTreeLinkerTrackHcal.cc:57
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
KDTreeLinkerTrackHcal::rechit2ClusterLinks_
RecHit2BlockEltMap rechit2ClusterLinks_
Definition: KDTreeLinkerTrackHcal.cc:49
KDTreeLinkerTrackHcal::checkExit_
bool checkExit_
Definition: KDTreeLinkerTrackHcal.cc:59
KDTreeLinkerTrackHcal::cluster2TargetLinks_
BlockElt2BlockEltMap cluster2TargetLinks_
Definition: KDTreeLinkerTrackHcal.cc:46
HLT_2018_cff.fraction
fraction
Definition: HLT_2018_cff.py:51317
reco::PFBlockElement::clusterRef
virtual const PFClusterRef & clusterRef() const
Definition: PFBlockElement.h:90