22 std::cout <<
"entering test link by rechit function" << std::endl;
28 auto clusterZ = cluster.
position().Z();
33 double horesolscale = 1.0;
40 double tracketa = 999999.9;
41 double trackphi = 999999.9;
42 double track_X = 999999.9;
43 double track_Y = 999999.9;
44 double track_Z = 999999.9;
52 switch (cluster.
layer()) {
59 std::cout <<
"Fetching Ecal Resolution Maps" << std::endl;
85 std::cout <<
"Fetching Hcal Resolution Maps" << std::endl;
101 dHPhi = dHPhi - 2. *
M_PI;
102 else if (dHPhi < -
M_PI)
103 dHPhi = dHPhi + 2. *
M_PI;
104 tracketa = atHCAL.
positionREP().Eta() + 0.1 * dHEta;
105 trackphi = atHCAL.
positionREP().Phi() + 0.1 * dHPhi;
122 std::cout <<
"Fetching HO Resolution Maps" << std::endl;
142 if (fabs(track_Z) > 700.25)
170 std::cout <<
"No link by rechit possible for pre-shower yet!" << std::endl;
184 if (!
hcal && fabs(track_Z) < 300.)
186 if (track_Z * clusterZ < 0.)
192 if (!
hcal && fabs(track_Z) > 300.)
200 std::cout <<
"test link by rechit " << dist <<
" " << std::endl;
202 std::cout <<
" clustereta " << clustereta <<
" clusterphi " << clusterphi <<
" tracketa " << tracketa
203 <<
" trackphi " << trackphi << std::endl;
212 const std::vector<reco::PFRecHitFraction>& fracs = cluster.
recHitFractions();
214 bool linkedbyrechit =
false;
216 for (
unsigned int rhit = 0; rhit < fracs.size(); ++rhit) {
218 double fraction = fracs[rhit].fraction();
225 const auto& rechit_cluster = *rh;
226 const auto& posxyz = rechit_cluster.position();
227 const auto& posrep = rechit_cluster.positionREP();
230 const auto& cornersxyz = rechit_cluster.getCornersXYZ();
231 const auto& corners = rechit_cluster.getCornersREP();
241 if (rhsizePhi >
M_PI)
242 rhsizePhi = 2. *
M_PI - rhsizePhi;
244 const double mult = horesolscale * (1.50 + 0.5 / fracs.size());
246 rhsizePhi = rhsizePhi *
mult + 0.2 * fabs(dHPhi);
256 std::cout << rhit <<
" Hcal RecHit=" << posrep.Eta() <<
" " << posrep.Phi() <<
" " << rechit_cluster.energy()
258 for (
unsigned jc = 0; jc < 4; ++jc)
259 std::cout <<
"corners " << jc <<
" " << corners[jc].
eta() <<
" " << corners[jc].phi() << std::endl;
261 std::cout <<
"RecHit SizeEta=" << rhsizeEta <<
" SizePhi=" << rhsizePhi << std::endl;
268 double deta = fabs(posrep.eta() - tracketa);
269 double dphi = fabs(posrep.phi() - trackphi);
271 dphi = 2. *
M_PI - dphi;
275 std::cout <<
"distance=" << deta <<
" " << dphi <<
" ";
276 if (deta < (0.5 * rhsizeEta) && dphi < (0.5 * rhsizePhi))
277 std::cout <<
" link here !" << std::endl;
283 if (deta < (0.5 * rhsizeEta) && dphi < (0.5 * rhsizePhi)) {
284 linkedbyrechit =
true;
291 const auto& posxyz = rechit_cluster.position();
293 std::cout <<
"RH " << posxyz.x() <<
" " << posxyz.y() << std::endl;
295 std::cout <<
"TRACK " << track_X <<
" " << track_Y << std::endl;
302 for (
unsigned jc = 0; jc < 4; ++jc) {
303 const auto& cornerposxyz = cornersxyz[jc];
305 x[3 - jc] = cornerposxyz.x() + (cornerposxyz.x() - posxyz.x()) *
mult;
306 y[3 - jc] = cornerposxyz.y() + (cornerposxyz.y() - posxyz.y()) *
mult;
310 std::cout <<
"corners " << jc <<
" " << cornerposxyz.x() <<
" " << cornerposxyz.y() << std::endl;
322 bool isinside = TMath::IsInside(track_X, track_Y, 5,
x,
y);
325 linkedbyrechit =
true;
332 if (linkedbyrechit) {
335 std::cout <<
"Track and Cluster LINKED BY RECHIT" << std::endl;
366 static const double resPSpitch = 0.19 /
sqrt(12.);
367 static const double resPSlength = 6.1 /
sqrt(12.);
376 std::cout <<
"entering test link by rechit function for ECAL and PS" << std::endl;
380 double zECAL = clusterECAL.
position().Z();
381 double xECAL = clusterECAL.
position().X();
382 double yECAL = clusterECAL.
position().Y();
385 double zPS = clusterPS.
position().Z();
386 double xPS = clusterPS.
position().X();
387 double yPS = clusterPS.
position().Y();
389 if (zECAL * zPS < 0.)
394 switch (clusterPS.
layer()) {
397 deltaX = resPSpitch * sqr12;
398 deltaY = resPSlength * sqr12;
402 deltaY = resPSpitch * sqr12;
403 deltaX = resPSlength * sqr12;
409 auto deltaXY =
BVector2D(deltaX, deltaY).
v * 0.5;
411 auto zCorr = zPS / zECAL;
412 const std::vector<reco::PFRecHitFraction>& fracs = clusterECAL.
recHitFractions();
413 bool linkedbyrechit =
false;
415 for (
unsigned int rhit = 0; rhit < fracs.size(); ++rhit) {
416 const auto& rh = fracs[rhit].recHitRef();
417 double fraction = fracs[rhit].fraction();
432 std::cout <<
"Ecal rechit " << posxy.x() <<
" " << posxy.y() << std::endl;
433 std::cout <<
"PS cluster " << xPS <<
" " << yPS << std::endl;
439 for (
unsigned jc = 0; jc < 4; ++jc) {
442 auto dist = (cornerpos - posxy);
446 auto xy = cornerpos + (dist * (fivepercent2D + one2D / adist) * deltaXY);
458 std::cout <<
"corners " << jc <<
" " << cornerpos.x() <<
" " <<
x[3 - jc] <<
" " << cornerpos.y() <<
" "
459 <<
y[3 - jc] << std::endl;
471 bool isinside = TMath::IsInside(xPS, yPS, 5,
x,
y);
474 linkedbyrechit =
true;
480 if (linkedbyrechit) {
483 std::cout <<
"Cluster PS and Cluster ECAL LINKED BY RECHIT" << std::endl;
485 constexpr
double scale = 1. / 1000.;
496 const auto& posxyzEM = clusterHFEM.
position();
497 const auto& posxyzHAD = clusterHFHAD.
position();
499 double dX = posxyzEM.X() - posxyzHAD.X();
500 double dY = posxyzEM.Y() - posxyzHAD.Y();
501 double sameZ = posxyzEM.Z() * posxyzHAD.Z();
506 double dist2 = dX * dX + dY * dY;
510 double dist =
sqrt(dist2);
518 auto phicor = etaPhi ?
normalizedPhi(phi1 - phi2) : phi1 - phi2;
525 return std::sqrt(etadiff * etadiff + phicor * phicor);