test
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
const reco::PFBlockElement::TypefieldType () const
 
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 setFieldType (const reco::PFBlockElement::Type &fld)
 
void setPhiOffset (double phiOffset)
 
void setTargetType (const reco::PFBlockElement::Type &tgt)
 
const reco::PFBlockElement::TypetargetType () const
 
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
reco::PFBlockElement::Type _fieldType
 
reco::PFBlockElement::Type _targetType
 
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 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 ( )

Definition at line 20 of file KDTreeLinkerPSEcal.cc.

References clear().

21 {
22  clear();
23 }

Member Function Documentation

void KDTreeLinkerPSEcal::buildTree ( )
virtual

Implements KDTreeLinkerBase.

Definition at line 74 of file KDTreeLinkerPSEcal.cc.

References rechitsNegSet_, rechitsPosSet_, treeNeg_, and treePos_.

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

Definition at line 81 of file KDTreeLinkerPSEcal.cc.

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

83 {
84  // List of pseudo-rechits that will be used to create the KDTree
85  std::vector<KDTreeNodeInfo> eltList;
86 
87  // Filling of this eltList
88  for(RecHitSet::const_iterator it = rechitsSet.begin();
89  it != rechitsSet.end(); it++) {
90 
91  const reco::PFRecHit* rh = *it;
92  const math::XYZPoint& posxyz = rh->position();
93 
94  KDTreeNodeInfo rhinfo (rh, posxyz.X(), posxyz.Y());
95  eltList.push_back(rhinfo);
96  }
97 
98  // xmin-xmax, ymain-ymax
99  KDTreeBox region(-150., 150., -150., 150.);
100 
101  // We may now build the KDTree
102  tree.build(eltList, region);
103 }
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:35
const math::XYZPoint & position() const
rechit cell centre x, y, z
Definition: PFRecHit.h:123
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void KDTreeLinkerPSEcal::clear ( void  )
virtual

Implements KDTreeLinkerBase.

Definition at line 236 of file KDTreeLinkerPSEcal.cc.

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

Referenced by ~KDTreeLinkerPSEcal().

237 {
238  targetSet_.clear();
239  fieldClusterSet_.clear();
240 
241  rechitsNegSet_.clear();
242  rechitsPosSet_.clear();
243 
244  rechit2ClusterLinks_.clear();
245  target2ClusterLinks_.clear();
246 
247  treeNeg_.clear();
248  treePos_.clear();
249 }
BlockElt2BlockEltMap target2ClusterLinks_
KDTreeLinkerAlgo treePos_
BlockEltSet fieldClusterSet_
KDTreeLinkerAlgo treeNeg_
RecHit2BlockEltMap rechit2ClusterLinks_
void KDTreeLinkerPSEcal::insertFieldClusterElt ( reco::PFBlockElement ecalCluster)
virtual

Implements KDTreeLinkerBase.

Definition at line 41 of file KDTreeLinkerPSEcal.cc.

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

42 {
43  reco::PFClusterRef clusterref = ecalCluster->clusterRef();
44 
45  if (clusterref->layer() != PFLayer::ECAL_ENDCAP)
46  return;
47 
48  const std::vector<reco::PFRecHitFraction> &fraction = clusterref->recHitFractions();
49 
50  // We create a list of cluster
51  fieldClusterSet_.insert(ecalCluster);
52 
53  double clusterz = clusterref->position().Z();
54  RecHitSet& rechitsSet = (clusterz < 0) ? rechitsNegSet_ : rechitsPosSet_;
55 
56  for(size_t rhit = 0; rhit < fraction.size(); ++rhit) {
57  const reco::PFRecHitRef& rh = fraction[rhit].recHitRef();
58  double fract = fraction[rhit].fraction();
59 
60  if ((rh.isNull()) || (fract < 1E-4))
61  continue;
62 
63  const reco::PFRecHit& rechit = *rh;
64 
65  // We save the links rechit to Clusters
66  rechit2ClusterLinks_[&rechit].insert(ecalCluster);
67 
68  // We create a liste of rechits
69  rechitsSet.insert(&rechit);
70  }
71 }
virtual const PFClusterRef & clusterRef() const
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:35
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 27 of file KDTreeLinkerPSEcal.cc.

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

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

Implements KDTreeLinkerBase.

Definition at line 106 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.

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

Implements KDTreeLinkerBase.

Definition at line 213 of file KDTreeLinkerPSEcal.cc.

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

214 {
215  //TODO YG : Check if cluster positionREP() is valid ?
216 
217  // Here we save in each track the list of phi/eta values of linked clusters.
218  for (BlockElt2BlockEltMap::iterator it = target2ClusterLinks_.begin();
219  it != target2ClusterLinks_.end(); ++it) {
220  reco::PFMultiLinksTC multitracks(true);
221 
222  for (BlockEltSet::iterator jt = it->second.begin();
223  jt != it->second.end(); ++jt) {
224 
225  double clusterPhi = (*jt)->clusterRef()->positionREP().Phi();
226  double clusterEta = (*jt)->clusterRef()->positionREP().Eta();
227 
228  multitracks.linkedClusters.push_back(std::make_pair(clusterPhi, clusterEta));
229  }
230 
231  it->first->setMultilinks(multitracks);
232  }
233 }
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().