CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions
LinkByRecHit Class Reference

#include <LinkByRecHit.h>

Public Member Functions

 LinkByRecHit ()
 
 ~LinkByRecHit ()
 

Static Public Member Functions

static double computeDist (double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
 computes a chisquare More...
 
static double testECALAndPSByRecHit (const reco::PFCluster &clusterECAL, const reco::PFCluster &clusterPS, bool debug=false)
 
static double testHFEMAndHFHADByRecHit (const reco::PFCluster &clusterHFEM, const reco::PFCluster &clusterHFHAD, bool debug=false)
 test association between HFEM and HFHAD, by rechit More...
 
static double testTrackAndClusterByRecHit (const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
 

Detailed Description

Definition at line 9 of file LinkByRecHit.h.

Constructor & Destructor Documentation

LinkByRecHit::LinkByRecHit ( )
inline

Definition at line 11 of file LinkByRecHit.h.

11 {};
LinkByRecHit::~LinkByRecHit ( )
inline

Member Function Documentation

double LinkByRecHit::computeDist ( double  eta1,
double  phi1,
double  eta2,
double  phi2,
bool  etaPhi = true 
)
static

computes a chisquare

Definition at line 547 of file LinkByRecHit.cc.

References normalizedPhi(), and mathSSE::sqrt().

Referenced by testECALAndPSByRecHit(), ECALAndHCALCaloJetLinker::testLink(), HCALAndHOLinker::testLink(), ECALAndHCALLinker::testLink(), HGCalAndBREMLinker::testLink(), GSFAndHGCalLinker::testLink(), SCAndECALLinker::testLink(), TrackAndHCALLinker::testLink(), ECALAndECALLinker::testLink(), SCAndHGCalLinker::testLink(), PreshowerAndECALLinker::testLink(), TrackAndECALLinker::testLink(), testTrackAndClusterByRecHit(), and ~LinkByRecHit().

549  {
550 
551  auto phicor = etaPhi ? normalizedPhi(phi1 - phi2) : phi1 - phi2;
552  auto etadiff = eta1 - eta2;
553 
554  // double chi2 =
555  // (eta1 - eta2)*(eta1 - eta2) / ( reta1*reta1+ reta2*reta2 ) +
556  // phicor*phicor / ( rphi1*rphi1+ rphi2*rphi2 );
557 
558  return std::sqrt(etadiff*etadiff + phicor*phicor);
559 
560 }
T normalizedPhi(T phi)
Definition: normalizedPhi.h:9
T sqrt(T t)
Definition: SSEVec.h:18
double LinkByRecHit::testECALAndPSByRecHit ( const reco::PFCluster clusterECAL,
const reco::PFCluster clusterPS,
bool  debug = false 
)
static

Definition at line 383 of file LinkByRecHit.cc.

References funct::abs(), computeDist(), constexpr, gather_cfg::cout, PFLayer::ECAL_ENDCAP, dedxEstimators_cff::fraction, reco::PFRecHit::getCornersXYZ(), reco::PFCluster::layer(), reco::PFRecHit::position(), reco::CaloCluster::position(), PFLayer::PS1, PFLayer::PS2, reco::PFCluster::recHitFractions(), Scenarios_cff::scale, mathSSE::sqrt(), Basic2DVector< T >::v, findQualityFiles::v, x, geometryCSVtoXML::xy, Basic3DVector< T >::xy(), and y.

Referenced by PreshowerAndECALLinker::testLink(), and ~LinkByRecHit().

385  {
386 
387 // 0.19 <-> strip_pitch
388 // 6.1 <-> strip_length
389  static const double resPSpitch = 0.19/sqrt(12.);
390  static const double resPSlength = 6.1/sqrt(12.);
391 
392  // Check that clusterECAL is in ECAL endcap and that clusterPS is a preshower cluster
393  if ( clusterECAL.layer() != PFLayer::ECAL_ENDCAP ||
394  ( clusterPS.layer() != PFLayer::PS1 &&
395  clusterPS.layer() != PFLayer::PS2 ) ) return -1.;
396 
397 #ifdef PFLOW_DEBUG
398  if( debug )
399  std::cout<<"entering test link by rechit function for ECAL and PS"<<std::endl;
400 #endif
401 
402  //ECAL cluster position
403  double zECAL = clusterECAL.position().Z();
404  double xECAL = clusterECAL.position().X();
405  double yECAL = clusterECAL.position().Y();
406 
407  // PS cluster position, extrapolated to ECAL
408  double zPS = clusterPS.position().Z();
409  double xPS = clusterPS.position().X(); //* zECAL/zPS;
410  double yPS = clusterPS.position().Y(); //* zECAL/zPS;
411 // MDN jan09 : check that zEcal and zPs have the same sign
412  if (zECAL*zPS <0.) return -1.;
413  double deltaX = 0.;
414  double deltaY = 0.;
415  double sqr12 = std::sqrt(12.);
416  switch (clusterPS.layer()) {
417  case PFLayer::PS1:
418  // vertical strips, measure x with pitch precision
419  deltaX = resPSpitch * sqr12;
420  deltaY = resPSlength * sqr12;
421  break;
422  case PFLayer::PS2:
423  // horizontal strips, measure y with pitch precision
424  deltaY = resPSpitch * sqr12;
425  deltaX = resPSlength * sqr12;
426  break;
427  default:
428  break;
429  }
430 
431 
432  auto deltaXY = BVector2D(deltaX,deltaY).v*0.5;
433  // Get the rechits
434  auto zCorr = zPS/zECAL;
435  const std::vector< reco::PFRecHitFraction >& fracs = clusterECAL.recHitFractions();
436  bool linkedbyrechit = false;
437  //loop rechits
438  for(unsigned int rhit = 0; rhit < fracs.size(); ++rhit){
439 
440  const auto & rh = fracs[rhit].recHitRef();
441  double fraction = fracs[rhit].fraction();
442  if(fraction < 1E-4) continue;
443  if(rh.isNull()) continue;
444 
445  //getting rechit center position
446  const reco::PFRecHit& rechit_cluster = *rh;
447 
448  //getting rechit corners
449  auto const & corners = rechit_cluster.getCornersXYZ();
450 
451  auto posxy = BVector2D(rechit_cluster.position().xy()).v*zCorr;
452 #ifdef PFLOW_DEBUG
453  if( debug ){
454  std::cout << "Ecal rechit " << posxy.x() << " " << posxy.y() << std::endl;
455  std::cout << "PS cluster " << xPS << " " << yPS << std::endl;
456  }
457 #endif
458 
459  double x[5];
460  double y[5];
461  for ( unsigned jc=0; jc<4; ++jc ) {
462  // corner position projected onto the preshower
463  Vector2D cornerpos = BVector2D(corners[jc].basicVector().xy()).v*zCorr;
464  auto dist = (cornerpos-posxy);
465  auto adist = BVector2D(std::abs(dist[0]),std::abs(dist[1])).v; // all this beacuse icc does not support vector extension
466  // Inflate the size by the size of the PS strips, and by 5% to include ECAL cracks.
467  auto xy = cornerpos + (dist * (fivepercent2D +one2D/adist)*deltaXY);
468  /*
469  Vector2D xy(
470  cornerpos.x() + (cornerpos.x()-posxy.x()) * (0.05 +1.0/std::abs((cornerpos.x()-posxy.x()))*deltaXY.x()),
471  cornerpos.y() + (cornerpos.y()-posxy.y()) * (0.05 +1.0/std::abs((cornerpos.y()-posxy.y()))*deltaXY.y())
472  );
473  */
474  x[3-jc] = xy[0];
475  y[3-jc] = xy[1];
476 
477 #ifdef PFLOW_DEBUG
478  if( debug ){
479  std::cout<<"corners "<<jc
480  << " " << cornerpos.x() << " " << x[3-jc]
481  << " " << cornerpos.y() << " " << y[3-jc]
482  << std::endl;
483  }
484 #endif
485  }//loop corners
486 
487  //need to close the polygon in order to
488  //use the TMath::IsInside fonction from root lib
489  x[4] = x[0];
490  y[4] = y[0];
491 
492  //Check if the extrapolation point of the track falls
493  //within the rechit boundaries
494  bool isinside = TMath::IsInside(xPS,yPS,5,x,y);
495 
496  if( isinside ){
497  linkedbyrechit = true;
498  break;
499  }
500 
501  }//loop rechits
502 
503  if( linkedbyrechit ) {
504 #ifdef PFLOW_DEBUG
505  if( debug ) std::cout << "Cluster PS and Cluster ECAL LINKED BY RECHIT" << std::endl;
506 #endif
507  constexpr double scale = 1./1000.;
508  double dist = computeDist( xECAL*scale,yECAL*scale,
509  xPS*scale ,yPS*scale,
510  false);
511  return dist;
512  } else {
513  return -1.;
514  }
515 
516 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:128
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:129
Basic2DVector< T > xy() const
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
PositionType const & position() const
rechit cell centre x, y, z
Definition: PFRecHit.h:129
#define constexpr
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
Basic2DVector< double >::MathVector Vector2D
Definition: LinkByRecHit.cc:7
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define debug
Definition: HDRShower.cc:19
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
Basic2DVector< double > BVector2D
Definition: LinkByRecHit.cc:6
CornersVec const & getCornersXYZ() const
rechit corners
Definition: PFRecHit.h:134
double LinkByRecHit::testHFEMAndHFHADByRecHit ( const reco::PFCluster clusterHFEM,
const reco::PFCluster clusterHFHAD,
bool  debug = false 
)
static

test association between HFEM and HFHAD, by rechit

Definition at line 521 of file LinkByRecHit.cc.

References reco::CaloCluster::position(), and mathSSE::sqrt().

Referenced by HFEMAndHFHADLinker::testLink(), and ~LinkByRecHit().

523  {
524 
525  const auto& posxyzEM = clusterHFEM.position();
526  const auto& posxyzHAD = clusterHFHAD.position();
527 
528  double dX = posxyzEM.X()-posxyzHAD.X();
529  double dY = posxyzEM.Y()-posxyzHAD.Y();
530  double sameZ = posxyzEM.Z()*posxyzHAD.Z();
531 
532  if(sameZ<0) return -1.;
533 
534  double dist2 = dX*dX + dY*dY;
535 
536  if( dist2 < 0.1 ) {
537  // less than one mm
538  double dist = sqrt( dist2 );
539  return dist;;
540  }
541  else
542  return -1.;
543 
544 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:129
T sqrt(T t)
Definition: SSEVec.h:18
double LinkByRecHit::testTrackAndClusterByRecHit ( const reco::PFRecTrack track,
const reco::PFCluster cluster,
bool  isBrem = false,
bool  debug = false 
)
static

Definition at line 18 of file LinkByRecHit.cc.

References funct::abs(), Reference_intrackfit_cff::barrel, reco::PFTrajectoryPoint::ClosestApproach, computeDist(), gather_cfg::cout, PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, reco::PFTrajectoryPoint::ECALShowerMax, PVValHelper::eta, reco::PFTrack::extrapolatedPoint(), dedxEstimators_cff::fraction, PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, PFLayer::HCAL_ENDCAP, reco::PFTrajectoryPoint::HCALEntrance, reco::PFTrajectoryPoint::HCALExit, reco::PFTrajectoryPoint::HOLayer, edm::Ref< C, T, F >::isNull(), reco::PFTrajectoryPoint::isValid(), reco::PFCluster::layer(), M_PI, min(), reco::PFTrajectoryPoint::momentum(), phi, reco::PFTrajectoryPoint::position(), reco::CaloCluster::position(), reco::PFCluster::positionREP(), reco::PFTrajectoryPoint::positionREP(), PFLayer::PS1, PFLayer::PS2, reco::PFCluster::recHitFractions(), mathSSE::sqrt(), listHistos::trackPt, x, and y.

Referenced by PFElecTkProducer::isSharingEcalEnergyWithEgSC(), ConvBremPFTrackFinder::runConvBremFinder(), TrackAndHOLinker::testLink(), HCALAndBREMLinker::testLink(), GSFAndHCALLinker::testLink(), ECALAndBREMLinker::testLink(), GSFAndECALLinker::testLink(), TrackAndHCALLinker::testLink(), TrackAndECALLinker::testLink(), and ~LinkByRecHit().

21  {
22 
23 #ifdef PFLOW_DEBUG
24  if( debug )
25  std::cout<<"entering test link by rechit function"<<std::endl;
26 #endif
27 
28  //cluster position
29  auto clustereta = cluster.positionREP().Eta();
30  auto clusterphi = cluster.positionREP().Phi();
31  auto clusterZ = cluster.position().Z();
32 
33  bool barrel = false;
34  bool hcal = false;
35  // double distance = 999999.9;
36  double horesolscale=1.0;
37 
38  //track extrapolation
39  const reco::PFTrajectoryPoint& atVertex
41  const reco::PFTrajectoryPoint& atECAL
43 
44  //track at calo's
45  double tracketa = 999999.9;
46  double trackphi = 999999.9;
47  double track_X = 999999.9;
48  double track_Y = 999999.9;
49  double track_Z = 999999.9;
50  double dHEta = 0.;
51  double dHPhi = 0.;
52 
53  // Quantities at vertex
54  double trackPt = isBrem ? 999. : sqrt(atVertex.momentum().Vect().Perp2());
55  // double trackEta = isBrem ? 999. : atVertex.momentum().Vect().Eta();
56 
57  switch (cluster.layer()) {
58  case PFLayer::ECAL_BARREL: barrel = true;
60 #ifdef PFLOW_DEBUG
61  if( debug )
62  std::cout << "Fetching Ecal Resolution Maps"<< std::endl;
63 #endif
64  // did not reach ecal, cannot be associated with a cluster.
65  if( ! atECAL.isValid() ) return -1.;
66 
67  tracketa = atECAL.positionREP().Eta();
68  trackphi = atECAL.positionREP().Phi();
69  track_X = atECAL.position().X();
70  track_Y = atECAL.position().Y();
71  track_Z = atECAL.position().Z();
72 
73 /* distance
74  = std::sqrt( (track_X-clusterX)*(track_X-clusterX)
75  +(track_Y-clusterY)*(track_Y-clusterY)
76  +(track_Z-clusterZ)*(track_Z-clusterZ)
77  );
78 */
79  break;
80 
81  case PFLayer::HCAL_BARREL1: barrel = true;
83 #ifdef PFLOW_DEBUG
84  if( debug )
85  std::cout << "Fetching Hcal Resolution Maps" << std::endl;
86 #endif
87  if( isBrem ) {
88  return -1.;
89  } else {
90  hcal=true;
91  const reco::PFTrajectoryPoint& atHCAL
93  const reco::PFTrajectoryPoint& atHCALExit
95  // did not reach hcal, cannot be associated with a cluster.
96  if( ! atHCAL.isValid() ) return -1.;
97 
98  // The link is computed between 0 and ~1 interaction length in HCAL
99  dHEta = atHCALExit.positionREP().Eta()-atHCAL.positionREP().Eta();
100  dHPhi = atHCALExit.positionREP().Phi()-atHCAL.positionREP().Phi();
101  if ( dHPhi > M_PI ) dHPhi = dHPhi - 2.*M_PI;
102  else if ( dHPhi < -M_PI ) dHPhi = dHPhi + 2.*M_PI;
103  tracketa = atHCAL.positionREP().Eta() + 0.1*dHEta;
104  trackphi = atHCAL.positionREP().Phi() + 0.1*dHPhi;
105  track_X = atHCAL.position().X();
106  track_Y = atHCAL.position().Y();
107  track_Z = atHCAL.position().Z();
108 /* distance
109  = -std::sqrt( (track_X-clusterX)*(track_X-clusterX)
110  +(track_Y-clusterY)*(track_Y-clusterY)
111  +(track_Z-clusterZ)*(track_Z-clusterZ)
112  );
113 */
114  }
115  break;
116 
117  case PFLayer::HCAL_BARREL2: barrel = true;
118 #ifdef PFLOW_DEBUG
119  if( debug )
120  std::cout << "Fetching HO Resolution Maps" << std::endl;
121 #endif
122  if( isBrem ) {
123  return -1.;
124  } else {
125  hcal=true;
126  horesolscale=1.15;
127  const reco::PFTrajectoryPoint& atHO
129  // did not reach ho, cannot be associated with a cluster.
130  if( ! atHO.isValid() ) return -1.;
131 
132  //
133  tracketa = atHO.positionREP().Eta();
134  trackphi = atHO.positionREP().Phi();
135  track_X = atHO.position().X();
136  track_Y = atHO.position().Y();
137  track_Z = atHO.position().Z();
138 
139  // Is this check really useful ?
140  if ( fabs(track_Z) > 700.25 ) return -1.;
141 
142 
143 /* distance
144  = std::sqrt( (track_X-clusterX)*(track_X-clusterX)
145  +(track_Y-clusterY)*(track_Y-clusterY)
146  +(track_Z-clusterZ)*(track_Z-clusterZ)
147  );
148 */
149 #ifdef PFLOW_DEBUG
150 /* if( debug ) {
151  std::cout <<"dist "<<distance<<" "<<cluster.energy()<<" "<<cluster.layer()<<" "
152  <<track_X<<" "<<clusterX<<" "
153  <<track_Y<<" "<<clusterY<<" "
154  <<track_Z<<" "<<clusterZ<<std::endl;
155  }
156 */
157 #endif
158  }
159  break;
160 
161  case PFLayer::PS1:
162  case PFLayer::PS2:
163  //Note Alex: Nothing implemented for the
164  //PreShower (No resolution maps yet)
165 #ifdef PFLOW_DEBUG
166  if( debug )
167  std::cout << "No link by rechit possible for pre-shower yet!"
168  << std::endl;
169 #endif
170  return -1.;
171  default:
172  return -1.;
173  }
174 
175 
176  // Check that, if the cluster is in the endcap,
177  // 0) the track indeed points to the endcap at vertex (DISABLED)
178  // 1) the track extrapolation is in the endcap too !
179  // 2) the track is in the same end-cap !
180  // PJ - 10-May-09
181  if ( !barrel ) {
182  // if ( fabs(trackEta) < 1.0 ) return -1;
183  if ( !hcal && fabs(track_Z) < 300. ) return -1.;
184  if ( track_Z * clusterZ < 0. ) return -1.;
185  }
186  // Check that, if the cluster is in the barrel,
187  // 1) the track is in the barrel too !
188  if ( barrel ) {
189  if ( !hcal && fabs(track_Z) > 300. ) return -1.;
190  }
191 
192  double dist = LinkByRecHit::computeDist( clustereta, clusterphi,
193  tracketa, trackphi);
194 
195 #ifdef PFLOW_DEBUG
196  if(debug) std::cout<<"test link by rechit "<< dist <<" "<<std::endl;
197  if(debug){
198  std::cout<<" clustereta " << clustereta
199  <<" clusterphi " << clusterphi
200  <<" tracketa " << tracketa
201  <<" trackphi " << trackphi << std::endl;
202  }
203 #endif
204 
205  //Testing if Track can be linked by rechit to a cluster.
206  //A cluster can be linked to a track if the extrapolated position
207  //of the track to the ECAL ShowerMax/HCAL entrance falls within
208  //the boundaries of any cell that belongs to this cluster.
209 
210  const std::vector< reco::PFRecHitFraction >&
211  fracs = cluster.recHitFractions();
212 
213  bool linkedbyrechit = false;
214  //loop rechits
215  for(unsigned int rhit = 0; rhit < fracs.size(); ++rhit){
216 
217  const reco::PFRecHitRef& rh = fracs[rhit].recHitRef();
218  double fraction = fracs[rhit].fraction();
219  if(fraction < 1E-4) continue;
220  if(rh.isNull()) continue;
221 
222  //getting rechit center position
223  const auto & rechit_cluster = *rh;
224  const auto & posxyz
225  = rechit_cluster.position();
226  const auto & posrep
227  = rechit_cluster.positionREP();
228 
229  //getting rechit corners
230  const auto & cornersxyz = rechit_cluster.getCornersXYZ();
231  const auto & corners = rechit_cluster.getCornersREP();
232 
233 
234  if( barrel || hcal ){ // barrel case matching in eta/phi
235  // (and HCAL endcap too!)
236 
237  //rechit size determination
238  // blown up by 50% (HCAL) to 100% (ECAL) to include cracks & gaps
239  // also blown up to account for multiple scattering at low pt.
240  double rhsizeEta
241  = std::abs(corners[3].eta() - corners[1].eta());
242  double rhsizePhi
243  = std::abs(corners[3].phi() - corners[1].phi());
244  if ( rhsizePhi > M_PI ) rhsizePhi = 2.*M_PI - rhsizePhi;
245  if ( hcal ) {
246  const double mult = horesolscale * (1.50 + 0.5/fracs.size());
247  rhsizeEta = rhsizeEta * mult + 0.2*std::abs(dHEta);
248  rhsizePhi = rhsizePhi * mult + 0.2*fabs(dHPhi);
249 
250  } else {
251  const double mult = 2.00 + 1.0/(fracs.size()*std::min(1.,0.5*trackPt));
252  rhsizeEta *= mult;
253  rhsizePhi *= mult;
254  }
255 
256 #ifdef PFLOW_DEBUG
257  if( debug ) {
258  std::cout << rhit << " Hcal RecHit="
259  << posrep.Eta() << " "
260  << posrep.Phi() << " "
261  << rechit_cluster.energy()
262  << std::endl;
263  for ( unsigned jc=0; jc<4; ++jc )
264  std::cout<<"corners "<<jc<<" "<<corners[jc].eta()
265  <<" "<<corners[jc].phi()<<std::endl;
266 
267  std::cout << "RecHit SizeEta=" << rhsizeEta
268  << " SizePhi=" << rhsizePhi << std::endl;
269  }
270 #endif
271 
272  //distance track-rechit center
273  // const math::XYZPoint& posxyz
274  // = rechit_cluster.position();
275  double deta = fabs(posrep.eta() - tracketa);
276  double dphi = fabs(posrep.phi() - trackphi);
277  if ( dphi > M_PI ) dphi = 2.*M_PI - dphi;
278 
279 #ifdef PFLOW_DEBUG
280  if( debug ){
281  std::cout << "distance="
282  << deta << " "
283  << dphi << " ";
284  if(deta < (0.5*rhsizeEta) && dphi < (0.5*rhsizePhi))
285  std::cout << " link here !" << std::endl;
286  else std::cout << std::endl;
287  }
288 #endif
289 
290  if(deta < (0.5*rhsizeEta) && dphi < (0.5*rhsizePhi)){
291  linkedbyrechit = true;
292  break;
293  }
294  }
295  else { //ECAL & PS endcap case, matching in X,Y
296 
297 #ifdef PFLOW_DEBUG
298  if( debug ){
299  const auto & posxyz
300  = rechit_cluster.position();
301 
302  std::cout << "RH " << posxyz.x()
303  << " " << posxyz.y()
304  << std::endl;
305 
306  std::cout << "TRACK " << track_X
307  << " " << track_Y
308  << std::endl;
309  }
310 #endif
311 
312  double x[5];
313  double y[5];
314 
315  for ( unsigned jc=0; jc<4; ++jc ) {
316  const auto & cornerposxyz = cornersxyz[jc];
317  const double mult = (1.00+0.50/(fracs.size()*std::min(1.,0.5*trackPt)));
318  x[3-jc] = cornerposxyz.x() + (cornerposxyz.x()-posxyz.x()) * mult;
319  y[3-jc] = cornerposxyz.y() + (cornerposxyz.y()-posxyz.y()) * mult;
320 
321 #ifdef PFLOW_DEBUG
322  if( debug ){
323  std::cout<<"corners "<<jc
324  << " " << cornerposxyz.x()
325  << " " << cornerposxyz.y()
326  << std::endl;
327  }
328 #endif
329  }//loop corners
330 
331  //need to close the polygon in order to
332  //use the TMath::IsInside fonction from root lib
333  x[4] = x[0];
334  y[4] = y[0];
335 
336  //Check if the extrapolation point of the track falls
337  //within the rechit boundaries
338  bool isinside = TMath::IsInside(track_X,
339  track_Y,
340  5,x,y);
341 
342  if( isinside ){
343  linkedbyrechit = true;
344  break;
345  }
346  }//
347 
348  }//loop rechits
349 
350  if( linkedbyrechit ) {
351 #ifdef PFLOW_DEBUG
352  if( debug )
353  std::cout << "Track and Cluster LINKED BY RECHIT" << std::endl;
354 #endif
355  /*
356  //if ( distance > 40. || distance < -100. )
357  double clusterr = std::sqrt(clusterX*clusterX+clusterY*clusterY);
358  double trackr = std::sqrt(track_X*track_X+track_Y*track_Y);
359  if ( distance > 40. )
360  std::cout << "Distance = " << distance
361  << ", Barrel/Hcal/Brem ? " << barrel << " " << hcal << " " << isBrem << std::endl
362  << " Cluster " << clusterr << " " << clusterZ << " " << clusterphi << " " << clustereta << std::endl
363  << " Track " << trackr << " " << track_Z << " " << trackphi << " " << tracketa << std::endl;
364  if ( !barrel && fabs(trackEta) < 1.0 ) {
365  double clusterr = std::sqrt(clusterX*clusterX+clusterY*clusterY);
366  double trackr = std::sqrt(track_X*track_X+track_Y*track_Y);
367  std::cout << "TrackEta/Pt = " << trackEta << " " << trackPt << ", distance = " << distance << std::endl
368  << ", Barrel/Hcal/Brem ? " << barrel << " " << hcal << " " << isBrem << std::endl
369  << " Cluster " << clusterr << " " << clusterZ << " " << clusterphi << " " << clustereta << std::endl
370  << " Track " << trackr << " " << track_Z << " " << trackphi << " " << tracketa << " " << trackEta << " " << trackPt << std::endl;
371  }
372  */
373  return dist;
374  } else {
375  return -1.;
376  }
377 
378 }
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:128
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:129
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
const math::XYZPoint & position() const
cartesian position (x, y, z)
Point of closest approach from beam axis (initial point in the case of PFSimParticle) ...
T sqrt(T t)
Definition: SSEVec.h:18
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:97
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
T min(T a, T b)
Definition: MathUtil.h:58
bool isNull() const
Checks for null.
Definition: Ref.h:250
#define M_PI
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
#define debug
Definition: HDRShower.cc:19
bool isValid() const
is this point valid ?
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...