CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
void clear ()
 
void insertFieldClusterElt (reco::PFBlockElement *ecalCluster)
 
void insertTargetElt (reco::PFBlockElement *psCluster)
 
 KDTreeLinkerPSEcal ()
 
void searchLinks ()
 
void updatePFBlockEltWithLinks ()
 
 ~KDTreeLinkerPSEcal ()
 
- Public Member Functions inherited from KDTreeLinkerBase
float getCristalPhiEtaMaxSize () const
 
float getCristalXYMaxSize () const
 
float getPhiOffset () const
 
 KDTreeLinkerBase ()
 
virtual void process ()
 
void setCristalPhiEtaMaxSize (float size)
 
void setCristalXYMaxSize (float size)
 
void setDebug (bool isDebug)
 
void setPhiOffset (double phiOffset)
 
virtual ~KDTreeLinkerBase ()
 

Private Member Functions

void buildTree (const RecHitSet &rechitsSet, KDTreeLinkerAlgo &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 treeNeg_
 
KDTreeLinkerAlgo treePos_
 

Additional Inherited Members

- Protected Attributes inherited from KDTreeLinkerBase
float cristalPhiEtaMaxSize_
 
float cristalXYMaxSize_
 
bool debug_
 
float phiOffset_
 

Detailed Description

Definition at line 12 of file KDTreeLinkerPSEcal.h.

Constructor & Destructor Documentation

KDTreeLinkerPSEcal::KDTreeLinkerPSEcal ( )

Definition at line 6 of file KDTreeLinkerPSEcal.cc.

8  resPSpitch_ (0.19),
9  resPSlength_ (6.1),
10  ps1ToEcal_ (1.072),
11  ps2ToEcal_ (1.057)
12 {}
const double resPSlength_
const double resPSpitch_
KDTreeLinkerPSEcal::~KDTreeLinkerPSEcal ( )

Definition at line 14 of file KDTreeLinkerPSEcal.cc.

References clear().

15 {
16  clear();
17 }

Member Function Documentation

void KDTreeLinkerPSEcal::buildTree ( )
virtual

Implements KDTreeLinkerBase.

Definition at line 68 of file KDTreeLinkerPSEcal.cc.

References rechitsNegSet_, rechitsPosSet_, treeNeg_, and treePos_.

void KDTreeLinkerPSEcal::buildTree ( const RecHitSet rechitsSet,
KDTreeLinkerAlgo tree 
)
private

Definition at line 75 of file KDTreeLinkerPSEcal.cc.

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

77 {
78  // List of pseudo-rechits that will be used to create the KDTree
79  std::vector<KDTreeNodeInfo> eltList;
80 
81  // Filling of this eltList
82  for(RecHitSet::const_iterator it = rechitsSet.begin();
83  it != rechitsSet.end(); it++) {
84 
85  const reco::PFRecHit* rh = *it;
86  const math::XYZPoint& posxyz = rh->position();
87 
88  KDTreeNodeInfo rhinfo (rh, posxyz.X(), posxyz.Y());
89  eltList.push_back(rhinfo);
90  }
91 
92  // xmin-xmax, ymain-ymax
93  KDTreeBox region(-150., 150., -150., 150.);
94 
95  // We may now build the KDTree
96  tree.build(eltList, region);
97 }
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox &region)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
const math::XYZPoint & position() const
is seed ?
Definition: PFRecHit.h:141
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
void KDTreeLinkerPSEcal::clear ( void  )
virtual

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 }
BlockElt2BlockEltMap target2ClusterLinks_
KDTreeLinkerAlgo treePos_
BlockEltSet fieldClusterSet_
KDTreeLinkerAlgo treeNeg_
RecHit2BlockEltMap rechit2ClusterLinks_
void KDTreeLinkerPSEcal::insertFieldClusterElt ( reco::PFBlockElement ecalCluster)
virtual

Implements KDTreeLinkerBase.

Definition at line 35 of file KDTreeLinkerPSEcal.cc.

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

Referenced by PFBlockAlgo::setInput().

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

Implements KDTreeLinkerBase.

Definition at line 21 of file KDTreeLinkerPSEcal.cc.

References reco::PFBlockElement::clusterRef(), and targetSet_.

Referenced by PFBlockAlgo::setInput().

22 {
23  reco::PFClusterRef clusterref = psCluster->clusterRef();
24 
25  // This test is more or less done in PFBlockAlgo.h. In others cases, it should be switch on.
26  // if (!((clusterref->layer() == PFLayer::PS1) ||
27  // (clusterref->layer() == PFLayer::PS2)))
28  // return;
29 
30  targetSet_.insert(psCluster);
31 }
virtual PFClusterRef clusterRef() const
void KDTreeLinkerPSEcal::searchLinks ( )
virtual

Implements KDTreeLinkerBase.

Definition at line 100 of file KDTreeLinkerPSEcal.cc.

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

101 {
102  // Must of the code has been taken from LinkByRecHit.cc
103 
104  // We iterate over the PS clusters.
105  for(BlockEltSet::iterator it = targetSet_.begin();
106  it != targetSet_.end(); it++) {
107 
108  (*it)->setIsValidMultilinks(true);
109 
110  reco::PFClusterRef clusterPSRef = (*it)->clusterRef();
111  const reco::PFCluster& clusterPS = *clusterPSRef;
112 
113  // PS cluster position, extrapolated to ECAL
114  double zPS = clusterPS.position().Z();
115  double xPS = clusterPS.position().X();
116  double yPS = clusterPS.position().Y();
117 
118  double etaPS = fabs(clusterPS.positionREP().eta());
119  double deltaX = 0.;
120  double deltaY = 0.;
121  double xPSonEcal = xPS;
122  double yPSonEcal = yPS;
123 
124  if (clusterPS.layer() == PFLayer::PS1) { // PS1
125 
126  // vertical strips, measure x with pitch precision
127  deltaX = resPSpitch_;
128  deltaY = resPSlength_;
129  xPSonEcal *= ps1ToEcal_;
130  yPSonEcal *= ps1ToEcal_;
131 
132  } else { // PS2
133 
134  // horizontal strips, measure y with pitch precision
135  deltaY = resPSpitch_;
136  deltaX = resPSlength_;
137  xPSonEcal *= ps2ToEcal_;
138  yPSonEcal *= ps2ToEcal_;
139 
140  }
141 
142 
143  // Estimate the maximal envelope in phi/eta that will be used to find rechit candidates.
144  // Same envelope for cap et barrel rechits.
145 
146 
147  double maxEcalRadius = getCristalXYMaxSize() / 2.;
148 
149  // The inflation factor includes the approximate projection from Preshower to ECAL
150  double inflation = 2.4 - (etaPS-1.6);
151  double rangeX = maxEcalRadius * (1 + (0.05 + 1.0 / maxEcalRadius * deltaX / 2.)) * inflation;
152  double rangeY = maxEcalRadius * (1 + (0.05 + 1.0 / maxEcalRadius * deltaY / 2.)) * inflation;
153 
154  // We search for all candidate recHits, ie all recHits contained in the maximal size envelope.
155  std::vector<KDTreeNodeInfo> recHits;
156  KDTreeBox trackBox(xPSonEcal - rangeX, xPSonEcal + rangeX,
157  yPSonEcal - rangeY, yPSonEcal + rangeY);
158 
159  if (zPS < 0)
160  treeNeg_.search(trackBox, recHits);
161  else
162  treePos_.search(trackBox, recHits);
163 
164 
165  for(std::vector<KDTreeNodeInfo>::const_iterator rhit = recHits.begin();
166  rhit != recHits.end(); ++rhit) {
167 
168  const std::vector< math::XYZPoint >& corners = rhit->ptr->getCornersXYZ();
169  if(corners.size() != 4) continue;
170 
171  // Find all clusters associated to given rechit
172  RecHit2BlockEltMap::iterator ret = rechit2ClusterLinks_.find(rhit->ptr);
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 math::XYZPoint& posxyz = rhit->ptr->position() * zPS / clusterz;
181 
182  double x[5];
183  double y[5];
184  for ( unsigned jc=0; jc<4; ++jc ) {
185  math::XYZPoint cornerpos = corners[jc] * zPS / clusterz;
186  x[jc] = cornerpos.X() + (cornerpos.X()-posxyz.X()) * (0.05 +1.0/fabs((cornerpos.X()-posxyz.X()))*deltaX/2.);
187  y[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:81
const double resPSlength_
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:123
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
BlockElt2BlockEltMap target2ClusterLinks_
const double resPSpitch_
void search(const KDTreeBox &searchBox, std::vector< KDTreeNodeInfo > &resRecHitList)
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:76
float getCristalXYMaxSize() const
KDTreeLinkerAlgo treePos_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
Definition: DDAxes.h:10
KDTreeLinkerAlgo treeNeg_
RecHit2BlockEltMap rechit2ClusterLinks_
void KDTreeLinkerPSEcal::updatePFBlockEltWithLinks ( )
virtual

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 KDTreeLinkerPSEcal::treeNeg_
private

Definition at line 70 of file KDTreeLinkerPSEcal.h.

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

KDTreeLinkerAlgo KDTreeLinkerPSEcal::treePos_
private

Definition at line 71 of file KDTreeLinkerPSEcal.h.

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