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 ( const edm::ParameterSet conf)

Definition at line 66 of file KDTreeLinkerTrackHcal.cc.

References 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.

67  : KDTreeLinkerBase(conf),
68  trajectoryLayerEntranceString_(conf.getParameter<std::string>("trajectoryLayerEntrance")),
69  trajectoryLayerExitString_(conf.getParameter<std::string>("trajectoryLayerExit")) {
70  // Initialization
72  phiOffset_ = 0.32;
73  // convert TrajectoryLayers info from string to enum
76  // make sure the requested setting is supported
83  // flag if exit layer should be checked or not
85 }
T getParameter(std::string const &) const
reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance_
KDTreeLinkerBase(const edm::ParameterSet &conf)
std::string trajectoryLayerEntranceString_
static LayerType layerTypeByName(const std::string &name)
reco::PFTrajectoryPoint::LayerType trajectoryLayerExit_
KDTreeLinkerTrackHcal::~KDTreeLinkerTrackHcal ( )
override

Definition at line 87 of file KDTreeLinkerTrackHcal.cc.

References clear().

87 { clear(); }

Member Function Documentation

void KDTreeLinkerTrackHcal::buildTree ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 124 of file KDTreeLinkerTrackHcal.cc.

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

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 }
float phi() const
momentum azimuthal angle
Definition: PtEtaPhiMass.h:54
KDTreeLinkerAlgo< reco::PFRecHit const * > tree_
double f[11][100]
void build(std::vector< KDTreeNodeInfo< DATA, DIM > > &eltList, const KDTreeBox< DIM > &region)
#define M_PI
float eta() const
momentum pseudorapidity
Definition: PtEtaPhiMass.h:52
void KDTreeLinkerTrackHcal::clear ( void  )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 264 of file KDTreeLinkerTrackHcal.cc.

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

Referenced by ~KDTreeLinkerTrackHcal().

264  {
265  targetSet_.clear();
266  fieldClusterSet_.clear();
267 
268  rechitsSet_.clear();
269 
270  rechit2ClusterLinks_.clear();
271  cluster2TargetLinks_.clear();
272 
273  tree_.clear();
274 }
KDTreeLinkerAlgo< reco::PFRecHit const * > tree_
RecHit2BlockEltMap rechit2ClusterLinks_
BlockElt2BlockEltMap cluster2TargetLinks_
void KDTreeLinkerTrackHcal::insertFieldClusterElt ( reco::PFBlockElement hcalCluster)
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 95 of file KDTreeLinkerTrackHcal.cc.

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

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 }
virtual const PFClusterRef & clusterRef() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
RecHit2BlockEltMap rechit2ClusterLinks_
const Fraction< n, m >::type & fract()
Definition: Fraction.h:36
bool isNull() const
Checks for null.
Definition: Ref.h:235
const float cutOffFrac
void KDTreeLinkerTrackHcal::insertTargetElt ( reco::PFBlockElement track)
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 89 of file KDTreeLinkerTrackHcal.cc.

References targetSet_, reco::PFBlockElement::trackRefPF(), and trajectoryLayerEntrance_.

89  {
90  if (track->trackRefPF()->extrapolatedPoint(trajectoryLayerEntrance_).isValid()) {
91  targetSet_.insert(track);
92  }
93 }
reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance_
virtual const PFRecTrackRef & trackRefPF() const
void KDTreeLinkerTrackHcal::searchLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 161 of file KDTreeLinkerTrackHcal.cc.

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_.

161  {
162  // Must 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 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance_
void search(const KDTreeBox< DIM > &searchBox, std::vector< DATA > &resRecHitList)
ret
prodAgent to be discontinued
KDTreeLinkerAlgo< reco::PFRecHit const * > tree_
RecHit2BlockEltMap rechit2ClusterLinks_
BlockElt2BlockEltMap cluster2TargetLinks_
#define M_PI
bool isValid() const
is this point valid ?
reco::PFTrajectoryPoint::LayerType trajectoryLayerExit_
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
void KDTreeLinkerTrackHcal::updatePFBlockEltWithLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 239 of file KDTreeLinkerTrackHcal.cc.

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

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.
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 }
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
reco::PFTrajectoryPoint::LayerType trajectoryLayerEntrance_
BlockElt2BlockEltMap cluster2TargetLinks_
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...

Member Data Documentation

bool KDTreeLinkerTrackHcal::checkExit_
private

Definition at line 59 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal(), and searchLinks().

BlockElt2BlockEltMap KDTreeLinkerTrackHcal::cluster2TargetLinks_
private

Definition at line 46 of file KDTreeLinkerTrackHcal.cc.

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

BlockEltSet KDTreeLinkerTrackHcal::fieldClusterSet_
private
RecHit2BlockEltMap KDTreeLinkerTrackHcal::rechit2ClusterLinks_
private

Definition at line 49 of file KDTreeLinkerTrackHcal.cc.

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

RecHitSet KDTreeLinkerTrackHcal::rechitsSet_
private

Definition at line 43 of file KDTreeLinkerTrackHcal.cc.

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

BlockEltSet KDTreeLinkerTrackHcal::targetSet_
private

Definition at line 39 of file KDTreeLinkerTrackHcal.cc.

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

reco::PFTrajectoryPoint::LayerType KDTreeLinkerTrackHcal::trajectoryLayerEntrance_
private
std::string KDTreeLinkerTrackHcal::trajectoryLayerEntranceString_
private

Definition at line 55 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal().

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

Definition at line 58 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal(), and searchLinks().

std::string KDTreeLinkerTrackHcal::trajectoryLayerExitString_
private

Definition at line 56 of file KDTreeLinkerTrackHcal.cc.

Referenced by KDTreeLinkerTrackHcal().

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

Definition at line 52 of file KDTreeLinkerTrackHcal.cc.

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