CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
KDTreeLinkerPSEcal Class Reference

#include <KDTreeLinkerPSEcal.h>

Inheritance diagram for KDTreeLinkerPSEcal:
KDTreeLinkerBase

Public Member Functions

void buildTree () override
 
void clear () override
 
void insertFieldClusterElt (reco::PFBlockElement *ecalCluster) override
 
void insertTargetElt (reco::PFBlockElement *psCluster) override
 
 KDTreeLinkerPSEcal ()
 
void searchLinks () override
 
void updatePFBlockEltWithLinks () override
 
 ~KDTreeLinkerPSEcal () override
 
- Public Member Functions inherited from KDTreeLinkerBase
const reco::PFBlockElement::TypefieldType () const
 
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 Member Functions

void buildTree (const RecHitSet &rechitsSet, KDTreeLinkerAlgo< reco::PFRecHit const * > &tree)
 

Private Attributes

BlockEltSet fieldClusterSet_
 
const double ps1ToEcal_
 
const double ps2ToEcal_
 
RecHit2BlockEltMap rechit2ClusterLinks_
 
RecHitSet rechitsNegSet_
 
RecHitSet rechitsPosSet_
 
const double resPSlength_
 
const double resPSpitch_
 
BlockElt2BlockEltMap target2ClusterLinks_
 
BlockEltSet targetSet_
 
KDTreeLinkerAlgo< reco::PFRecHit const * > treeNeg_
 
KDTreeLinkerAlgo< reco::PFRecHit const * > treePos_
 

Additional Inherited Members

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

Detailed Description

Definition at line 12 of file KDTreeLinkerPSEcal.h.

Constructor & Destructor Documentation

KDTreeLinkerPSEcal::KDTreeLinkerPSEcal ( )

Definition at line 12 of file KDTreeLinkerPSEcal.cc.

13  : KDTreeLinkerBase(),
14  resPSpitch_ (0.19),
15  resPSlength_ (6.1),
16  ps1ToEcal_ (1.072),
17  ps2ToEcal_ (1.057)
18 {}
const double resPSlength_
const double resPSpitch_
KDTreeLinkerPSEcal::~KDTreeLinkerPSEcal ( )
override

Definition at line 20 of file KDTreeLinkerPSEcal.cc.

References clear().

21 {
22  clear();
23 }

Member Function Documentation

void KDTreeLinkerPSEcal::buildTree ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 70 of file KDTreeLinkerPSEcal.cc.

References rechitsNegSet_, rechitsPosSet_, treeNeg_, and treePos_.

71 {
74 }
KDTreeLinkerAlgo< reco::PFRecHit const * > treePos_
void buildTree() override
KDTreeLinkerAlgo< reco::PFRecHit const * > treeNeg_
void KDTreeLinkerPSEcal::buildTree ( const RecHitSet rechitsSet,
KDTreeLinkerAlgo< reco::PFRecHit const * > &  tree 
)
private

Definition at line 77 of file KDTreeLinkerPSEcal.cc.

References KDTreeLinkerAlgo< DATA >::build(), and reco::PFRecHit::position().

79 {
80  // List of pseudo-rechits that will be used to create the KDTree
81  std::vector<KDTreeNodeInfo<reco::PFRecHit const*>> eltList;
82 
83  // Filling of this eltList
84  for(RecHitSet::const_iterator it = rechitsSet.begin();
85  it != rechitsSet.end(); it++) {
86 
87  const reco::PFRecHit* rh = *it;
88  const auto & posxyz = rh->position();
89 
90  KDTreeNodeInfo rhinfo {rh, posxyz.x(), posxyz.y()};
91  eltList.push_back(rhinfo);
92  }
93 
94  // xmin-xmax, ymain-ymax
95  KDTreeBox region{-150., 150., -150., 150.};
96 
97  // We may now build the KDTree
98  tree.build(eltList, region);
99 }
PositionType const & position() const
rechit cell centre x, y, z
Definition: PFRecHit.h:117
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
void build(std::vector< KDTreeNodeInfo< DATA > > &eltList, const KDTreeBox &region)
void KDTreeLinkerPSEcal::clear ( void  )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 230 of file KDTreeLinkerPSEcal.cc.

References KDTreeLinkerAlgo< DATA >::clear(), fieldClusterSet_, rechit2ClusterLinks_, rechitsNegSet_, rechitsPosSet_, target2ClusterLinks_, targetSet_, treeNeg_, and treePos_.

Referenced by ~KDTreeLinkerPSEcal().

231 {
232  targetSet_.clear();
233  fieldClusterSet_.clear();
234 
235  rechitsNegSet_.clear();
236  rechitsPosSet_.clear();
237 
238  rechit2ClusterLinks_.clear();
239  target2ClusterLinks_.clear();
240 
241  treeNeg_.clear();
242  treePos_.clear();
243 }
KDTreeLinkerAlgo< reco::PFRecHit const * > treePos_
BlockElt2BlockEltMap target2ClusterLinks_
BlockEltSet fieldClusterSet_
KDTreeLinkerAlgo< reco::PFRecHit const * > treeNeg_
RecHit2BlockEltMap rechit2ClusterLinks_
void KDTreeLinkerPSEcal::insertFieldClusterElt ( reco::PFBlockElement ecalCluster)
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 37 of file KDTreeLinkerPSEcal.cc.

References reco::PFBlockElement::clusterRef(), PFLayer::ECAL_ENDCAP, fieldClusterSet_, funct::fract(), dedxEstimators_cff::fraction, edm::Ref< C, T, F >::isNull(), rechit2ClusterLinks_, rechitsNegSet_, and rechitsPosSet_.

38 {
39  const reco::PFClusterRef& clusterref = ecalCluster->clusterRef();
40 
41  if (clusterref->layer() != PFLayer::ECAL_ENDCAP)
42  return;
43 
44  const std::vector<reco::PFRecHitFraction> &fraction = clusterref->recHitFractions();
45 
46  // We create a list of cluster
47  fieldClusterSet_.insert(ecalCluster);
48 
49  double clusterz = clusterref->position().Z();
50  RecHitSet& rechitsSet = (clusterz < 0) ? rechitsNegSet_ : rechitsPosSet_;
51 
52  for(size_t rhit = 0; rhit < fraction.size(); ++rhit) {
53  const reco::PFRecHitRef& rh = fraction[rhit].recHitRef();
54  double fract = fraction[rhit].fraction();
55 
56  if ((rh.isNull()) || (fract < 1E-4))
57  continue;
58 
59  const reco::PFRecHit& rechit = *rh;
60 
61  // We save the links rechit to Clusters
62  rechit2ClusterLinks_[&rechit].insert(ecalCluster);
63 
64  // We create a liste of rechits
65  rechitsSet.insert(&rechit);
66  }
67 }
virtual const PFClusterRef & clusterRef() const
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
std::set< const reco::PFRecHit * > RecHitSet
const Fraction< n, m >::type & fract()
Definition: Fraction.h:37
bool isNull() const
Checks for null.
Definition: Ref.h:248
BlockEltSet fieldClusterSet_
RecHit2BlockEltMap rechit2ClusterLinks_
void KDTreeLinkerPSEcal::insertTargetElt ( reco::PFBlockElement psCluster)
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 27 of file KDTreeLinkerPSEcal.cc.

References targetSet_.

28 {
29  // This test is more or less done in PFBlockAlgo.h. In others cases, it should be switch on.
30  //if (!((psCluster->clusterRef()->layer() == PFLayer::PS1) || (psCluster->clusterRef()->layer() == PFLayer::PS2)))
31  // return;
32  targetSet_.insert(psCluster);
33 }
void KDTreeLinkerPSEcal::searchLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 102 of file KDTreeLinkerPSEcal.cc.

References KDTreeLinkerBase::cristalXYMaxSize_, reco::PFCluster::layer(), reco::CaloCluster::position(), reco::PFCluster::positionREP(), PFLayer::PS1, ps1ToEcal_, ps2ToEcal_, rpcPointValidation_cfi::recHit, rechit2ClusterLinks_, resPSlength_, resPSpitch_, KDTreeLinkerAlgo< DATA >::search(), target2ClusterLinks_, targetSet_, treeNeg_, treePos_, x, and y.

103 {
104  // Must of the code has been taken from LinkByRecHit.cc
105 
106  // We iterate over the PS clusters.
107  for(BlockEltSet::iterator it = targetSet_.begin();
108  it != targetSet_.end(); it++) {
109 
110  (*it)->setIsValidMultilinks(true);
111 
112  reco::PFClusterRef clusterPSRef = (*it)->clusterRef();
113  const reco::PFCluster& clusterPS = *clusterPSRef;
114 
115  // PS cluster position, extrapolated to ECAL
116  double zPS = clusterPS.position().Z();
117  double xPS = clusterPS.position().X();
118  double yPS = clusterPS.position().Y();
119 
120  double etaPS = fabs(clusterPS.positionREP().eta());
121  double deltaX = 0.;
122  double deltaY = 0.;
123  double xPSonEcal = xPS;
124  double yPSonEcal = yPS;
125 
126  if (clusterPS.layer() == PFLayer::PS1) { // PS1
127 
128  // vertical strips, measure x with pitch precision
129  deltaX = resPSpitch_;
130  deltaY = resPSlength_;
131  xPSonEcal *= ps1ToEcal_;
132  yPSonEcal *= ps1ToEcal_;
133 
134  } else { // PS2
135 
136  // horizontal strips, measure y with pitch precision
137  deltaY = resPSpitch_;
138  deltaX = resPSlength_;
139  xPSonEcal *= ps2ToEcal_;
140  yPSonEcal *= ps2ToEcal_;
141 
142  }
143 
144 
145  // Estimate the maximal envelope in phi/eta that will be used to find rechit candidates.
146  // Same envelope for cap et barrel rechits.
147 
148 
149  double maxEcalRadius = cristalXYMaxSize_ / 2.;
150 
151  // The inflation factor includes the approximate projection from Preshower to ECAL
152  double inflation = 2.4 - (etaPS-1.6);
153  double rangeX = maxEcalRadius * (1 + (0.05 + 1.0 / maxEcalRadius * deltaX / 2.)) * inflation;
154  double rangeY = maxEcalRadius * (1 + (0.05 + 1.0 / maxEcalRadius * deltaY / 2.)) * inflation;
155 
156  // We search for all candidate recHits, ie all recHits contained in the maximal size envelope.
157  std::vector<reco::PFRecHit const*> recHits;
158  KDTreeBox trackBox(xPSonEcal - rangeX, xPSonEcal + rangeX,
159  yPSonEcal - rangeY, yPSonEcal + rangeY);
160 
161  if (zPS < 0)
162  treeNeg_.search(trackBox, recHits);
163  else
164  treePos_.search(trackBox, recHits);
165 
166 
167  for(auto const& recHit : recHits) {
168 
169  const auto & corners = recHit->getCornersXYZ();
170 
171  // Find all clusters associated to given rechit
172  RecHit2BlockEltMap::iterator ret = rechit2ClusterLinks_.find(recHit);
173 
174  for(BlockEltSet::const_iterator clusterIt = ret->second.begin();
175  clusterIt != ret->second.end(); clusterIt++) {
176 
177  reco::PFClusterRef clusterref = (*clusterIt)->clusterRef();
178  double clusterz = clusterref->position().z();
179 
180  const auto & posxyz = recHit->position() * zPS / clusterz;
181 
182  double x[5];
183  double y[5];
184  for ( unsigned jc=0; jc<4; ++jc ) {
185  auto cornerpos = corners[jc].basicVector() * zPS / clusterz;
186  x[3-jc] = cornerpos.x() + (cornerpos.x()-posxyz.x()) * (0.05 +1.0/fabs((cornerpos.x()-posxyz.x()))*deltaX/2.);
187  y[3-jc] = cornerpos.y() + (cornerpos.y()-posxyz.y()) * (0.05 +1.0/fabs((cornerpos.y()-posxyz.y()))*deltaY/2.);
188  }
189 
190  x[4] = x[0];
191  y[4] = y[0];
192 
193  bool isinside = TMath::IsInside(xPS,
194  yPS,
195  5,x,y);
196 
197  // Check if the track and the cluster are linked
198  if( isinside )
199  target2ClusterLinks_[*it].insert(*clusterIt);
200  }
201  }
202 
203  }
204 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:120
const double resPSlength_
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
KDTreeLinkerAlgo< reco::PFRecHit const * > treePos_
BlockElt2BlockEltMap target2ClusterLinks_
const double resPSpitch_
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:97
void search(const KDTreeBox &searchBox, std::vector< DATA > &resRecHitList)
KDTreeLinkerAlgo< reco::PFRecHit const * > treeNeg_
RecHit2BlockEltMap rechit2ClusterLinks_
void KDTreeLinkerPSEcal::updatePFBlockEltWithLinks ( )
overridevirtual

Implements KDTreeLinkerBase.

Definition at line 207 of file KDTreeLinkerPSEcal.cc.

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

208 {
209  //TODO YG : Check if cluster positionREP() is valid ?
210 
211  // Here we save in each track the list of phi/eta values of linked clusters.
212  for (BlockElt2BlockEltMap::iterator it = target2ClusterLinks_.begin();
213  it != target2ClusterLinks_.end(); ++it) {
214  reco::PFMultiLinksTC multitracks(true);
215 
216  for (BlockEltSet::iterator jt = it->second.begin();
217  jt != it->second.end(); ++jt) {
218 
219  double clusterphi = (*jt)->clusterRef()->positionREP().phi();
220  double clustereta = (*jt)->clusterRef()->positionREP().eta();
221 
222  multitracks.linkedClusters.push_back(std::make_pair(clusterphi, clustereta));
223  }
224 
225  it->first->setMultilinks(multitracks);
226  }
227 }
BlockElt2BlockEltMap target2ClusterLinks_

Member Data Documentation

BlockEltSet KDTreeLinkerPSEcal::fieldClusterSet_
private

Definition at line 56 of file KDTreeLinkerPSEcal.h.

Referenced by clear(), and insertFieldClusterElt().

const double KDTreeLinkerPSEcal::ps1ToEcal_
private

Definition at line 51 of file KDTreeLinkerPSEcal.h.

Referenced by searchLinks().

const double KDTreeLinkerPSEcal::ps2ToEcal_
private

Definition at line 52 of file KDTreeLinkerPSEcal.h.

Referenced by searchLinks().

RecHit2BlockEltMap KDTreeLinkerPSEcal::rechit2ClusterLinks_
private

Definition at line 67 of file KDTreeLinkerPSEcal.h.

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

RecHitSet KDTreeLinkerPSEcal::rechitsNegSet_
private

Definition at line 60 of file KDTreeLinkerPSEcal.h.

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

RecHitSet KDTreeLinkerPSEcal::rechitsPosSet_
private

Definition at line 61 of file KDTreeLinkerPSEcal.h.

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

const double KDTreeLinkerPSEcal::resPSlength_
private

Definition at line 50 of file KDTreeLinkerPSEcal.h.

Referenced by searchLinks().

const double KDTreeLinkerPSEcal::resPSpitch_
private

Definition at line 49 of file KDTreeLinkerPSEcal.h.

Referenced by searchLinks().

BlockElt2BlockEltMap KDTreeLinkerPSEcal::target2ClusterLinks_
private

Definition at line 64 of file KDTreeLinkerPSEcal.h.

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

BlockEltSet KDTreeLinkerPSEcal::targetSet_
private

Definition at line 55 of file KDTreeLinkerPSEcal.h.

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

KDTreeLinkerAlgo<reco::PFRecHit const*> KDTreeLinkerPSEcal::treeNeg_
private

Definition at line 70 of file KDTreeLinkerPSEcal.h.

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

KDTreeLinkerAlgo<reco::PFRecHit const*> KDTreeLinkerPSEcal::treePos_
private

Definition at line 71 of file KDTreeLinkerPSEcal.h.

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