25 std::cout<<
"entering test link by rechit function"<<std::endl;
31 auto clusterZ = cluster.
position().Z();
36 double horesolscale=1.0;
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;
57 switch (cluster.
layer()) {
62 std::cout <<
"Fetching Ecal Resolution Maps"<< std::endl;
65 if( ! atECAL.
isValid() )
return -1.;
85 std::cout <<
"Fetching Hcal Resolution Maps" << std::endl;
96 if( ! atHCAL.
isValid() )
return -1.;
101 if ( dHPhi >
M_PI ) dHPhi = dHPhi - 2.*
M_PI;
102 else if ( dHPhi < -
M_PI ) dHPhi = dHPhi + 2.*
M_PI;
120 std::cout <<
"Fetching HO Resolution Maps" << std::endl;
130 if( ! atHO.
isValid() )
return -1.;
140 if ( fabs(track_Z) > 700.25 )
return -1.;
167 std::cout <<
"No link by rechit possible for pre-shower yet!" 183 if ( !hcal && fabs(track_Z) < 300. )
return -1.;
184 if ( track_Z * clusterZ < 0. )
return -1.;
189 if ( !hcal && fabs(track_Z) > 300. )
return -1.;
196 if(debug)
std::cout<<
"test link by rechit "<< dist <<
" "<<std::endl;
199 <<
" clusterphi " << clusterphi
200 <<
" tracketa " << tracketa
201 <<
" trackphi " << trackphi << std::endl;
210 const std::vector< reco::PFRecHitFraction >&
213 bool linkedbyrechit =
false;
215 for(
unsigned int rhit = 0; rhit < fracs.size(); ++rhit){
218 double fraction = fracs[rhit].fraction();
219 if(fraction < 1E-4)
continue;
223 const auto & rechit_cluster = *rh;
225 = rechit_cluster.position();
227 = rechit_cluster.positionREP();
230 const auto & cornersxyz = rechit_cluster.getCornersXYZ();
231 const auto & corners = rechit_cluster.getCornersREP();
234 if( barrel || hcal ){
244 if ( rhsizePhi >
M_PI ) rhsizePhi = 2.*
M_PI - rhsizePhi;
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);
251 const double mult = 2.00 + 1.0/(fracs.size()*
std::min(1.,0.5*trackPt));
259 << posrep.Eta() <<
" " 260 << posrep.Phi() <<
" " 261 << rechit_cluster.energy()
263 for (
unsigned jc=0; jc<4; ++jc )
265 <<
" "<<corners[jc].phi()<<std::endl;
267 std::cout <<
"RecHit SizeEta=" << rhsizeEta
268 <<
" SizePhi=" << rhsizePhi << std::endl;
275 double deta = fabs(posrep.eta() - tracketa);
276 double dphi = fabs(posrep.phi() - trackphi);
277 if ( dphi >
M_PI ) dphi = 2.*
M_PI - dphi;
284 if(deta < (0.5*rhsizeEta) && dphi < (0.5*rhsizePhi))
285 std::cout <<
" link here !" << std::endl;
290 if(deta < (0.5*rhsizeEta) && dphi < (0.5*rhsizePhi)){
291 linkedbyrechit =
true;
300 = rechit_cluster.position();
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;
324 <<
" " << cornerposxyz.x()
325 <<
" " << cornerposxyz.y()
338 bool isinside = TMath::IsInside(track_X,
343 linkedbyrechit =
true;
350 if( linkedbyrechit ) {
353 std::cout <<
"Track and Cluster LINKED BY RECHIT" << std::endl;
389 static const double resPSpitch = 0.19/
sqrt(12.);
390 static const double resPSlength = 6.1/
sqrt(12.);
399 std::cout<<
"entering test link by rechit function for ECAL and PS"<<std::endl;
403 double zECAL = clusterECAL.
position().Z();
404 double xECAL = clusterECAL.
position().X();
405 double yECAL = clusterECAL.
position().Y();
408 double zPS = clusterPS.
position().Z();
409 double xPS = clusterPS.
position().X();
410 double yPS = clusterPS.
position().Y();
412 if (zECAL*zPS <0.)
return -1.;
416 switch (clusterPS.
layer()) {
419 deltaX = resPSpitch * sqr12;
420 deltaY = resPSlength * sqr12;
424 deltaY = resPSpitch * sqr12;
425 deltaX = resPSlength * sqr12;
432 auto deltaXY =
BVector2D(deltaX,deltaY).
v*0.5;
434 auto zCorr = zPS/zECAL;
435 const std::vector< reco::PFRecHitFraction >& fracs = clusterECAL.
recHitFractions();
436 bool linkedbyrechit =
false;
438 for(
unsigned int rhit = 0; rhit < fracs.size(); ++rhit){
440 const auto & rh = fracs[rhit].recHitRef();
441 double fraction = fracs[rhit].fraction();
442 if(fraction < 1E-4)
continue;
443 if(rh.isNull())
continue;
454 std::cout <<
"Ecal rechit " << posxy.x() <<
" " << posxy.y() << std::endl;
455 std::cout <<
"PS cluster " << xPS <<
" " << yPS << std::endl;
461 for (
unsigned jc=0; jc<4; ++jc ) {
464 auto dist = (cornerpos-posxy);
467 auto xy = cornerpos + (dist * (fivepercent2D +one2D/adist)*deltaXY);
480 <<
" " << cornerpos.x() <<
" " << x[3-jc]
481 <<
" " << cornerpos.y() <<
" " << y[3-jc]
494 bool isinside = TMath::IsInside(xPS,yPS,5,x,y);
497 linkedbyrechit =
true;
503 if( linkedbyrechit ) {
505 if( debug )
std::cout <<
"Cluster PS and Cluster ECAL LINKED BY RECHIT" << std::endl;
508 double dist =
computeDist( xECAL*scale,yECAL*scale,
509 xPS*scale ,yPS*scale,
525 const auto& posxyzEM = clusterHFEM.
position();
526 const auto& posxyzHAD = clusterHFHAD.
position();
528 double dX = posxyzEM.X()-posxyzHAD.X();
529 double dY = posxyzEM.Y()-posxyzHAD.Y();
530 double sameZ = posxyzEM.Z()*posxyzHAD.Z();
532 if(sameZ<0)
return -1.;
534 double dist2 = dX*dX + dY*dY;
538 double dist =
sqrt( dist2 );
548 double eta2,
double phi2,
551 auto phicor = etaPhi ?
normalizedPhi(phi1 - phi2) : phi1 - phi2;
552 auto etadiff = eta1 - eta2;
558 return std::sqrt(etadiff*etadiff + phicor*phicor);
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
const REPPoint & positionREP() const
trajectory position in (rho, eta, phi) base
const math::XYZPoint & position() const
cluster centroid position
reconstructed track used as an input to particle flow
Basic2DVector< T > xy() const
static double computeDist(double eta1, double phi1, double eta2, double phi2, bool etaPhi=true)
computes a chisquare
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
static double testECALAndPSByRecHit(const reco::PFCluster &clusterECAL, const reco::PFCluster &clusterPS, bool debug=false)
const math::XYZPoint & position() const
cartesian position (x, y, z)
constexpr T normalizedPhi(T phi)
PositionType const & position() const
rechit cell centre x, y, z
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Basic2DVector< double >::MathVector Vector2D
Point of closest approach from beam axis (initial point in the case of PFSimParticle) ...
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Abs< T >::type abs(const T &t)
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
bool isNull() const
Checks for null.
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
bool isValid() const
is this point valid ?
static double testHFEMAndHFHADByRecHit(const reco::PFCluster &clusterHFEM, const reco::PFCluster &clusterHFHAD, bool debug=false)
test association between HFEM and HFHAD, by rechit
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Basic2DVector< double > BVector2D
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
static double testTrackAndClusterByRecHit(const reco::PFRecTrack &track, const reco::PFCluster &cluster, bool isBrem=false, bool debug=false)
CornersVec const & getCornersXYZ() const
rechit corners