45 cfg.existsAs<double>(
"SeedMomentumForBOFF") ?
cfg.getParameter<double>(
"SeedMomentumForBOFF") : 5.0) {}
51 double seedMomentumForBOFF)
52 : thePropagatorLabel(
propagator), theBOFFMomentum(seedMomentumForBOFF) {
54 if (comparitorName !=
"none") {
67 std::stringstream&
ss,
68 std::vector<Quad>& quadV,
76 bool applyDeltaPhiCuts =
QuadCutPSet.getParameter<
bool>(
"apply_DeltaPhiCuts");
77 bool ClusterShapeFiltering =
QuadCutPSet.getParameter<
bool>(
"apply_ClusterShapeFilter");
78 bool applyArbitration =
QuadCutPSet.getParameter<
bool>(
"apply_Arbitration");
79 bool applydzCAcut =
QuadCutPSet.getParameter<
bool>(
"apply_zCACut");
80 double CleaningmaxRadialDistance =
QuadCutPSet.getParameter<
double>(
"Cut_DeltaRho");
81 double BeamPipeRadiusCut =
QuadCutPSet.getParameter<
double>(
"Cut_BeamPipeRadius");
82 double CleaningMinLegPt =
QuadCutPSet.getParameter<
double>(
"Cut_minLegPt");
83 double maxLegPt =
QuadCutPSet.getParameter<
double>(
"Cut_maxLegPt");
84 double dzcut =
QuadCutPSet.getParameter<
double>(
"Cut_zCA");
86 double toleranceFactorOnDeltaPhiCuts = 0.1;
103 #ifdef mydebug_sguazz
104 std::cout <<
" --------------------------------------------------------------------------"
106 std::cout <<
" Starting a hit quad fast reco "
108 std::cout <<
" --------------------------------------------------------------------------"
120 vHit[0] = ptth2->globalPosition();
121 vHit[1] = ptth1->globalPosition();
122 vHit[2] = mtth1->globalPosition();
123 vHit[3] = mtth2->globalPosition();
158 if (h1.x() * h1.x() + h1.y() * h1.y() < h2.x() * h2.x() + h2.y() * h2.y()) {
166 if (h3.x() * h3.x() + h3.y() * h3.y() < h4.x() * h4.x() + h4.y() * h4.y()) {
187 double kP = (P1.y() - P2.y()) / (P1.x() - P2.x());
188 double dP = P1.y() - kP * P1.x();
190 double kM = (M1.y() - M2.y()) / (M1.x() - M2.x());
191 double dM = M1.y() - kM * M1.x();
193 double IPx = (dM - dP) / (kP - kM);
194 double IPy = kP * IPx + dP;
196 IP.SetXYZ(IPx, IPy, 0);
199 double P1rho2 = P1.x() * P1.x() + P1.y() * P1.y();
200 double M1rho2 = M1.x() * M1.x() + M1.y() * M1.y();
201 double maxIPrho2 = IPrho + CleaningmaxRadialDistance;
202 maxIPrho2 *= maxIPrho2;
204 if (IPrho < BeamPipeRadiusCut || P1rho2 > maxIPrho2 || M1rho2 > maxIPrho2) {
208 if (applyDeltaPhiCuts) {
209 kPI_ = std::atan(1.0) * 4;
214 QuadMean.SetXYZ((M1.x() + M2.x() + P1.x() + P2.x()) / 4.,
215 (M1.y() + M2.y() + P1.y() + P2.y()) / 4.,
216 (M1.z() + M2.z() + P1.z() + P2.z()) / 4.);
218 double fBField = bfield->
inTesla(
GlobalPoint(QuadMean.x(), QuadMean.y(), QuadMean.z())).
z();
220 double rMax = CleaningMinLegPt / (0.01 * 0.3 * fBField);
228 if (rMax_squared * 4. > Mx * Mx + My * My) {
238 double d = My / 2. -
k * Mx / 2.;
240 #ifdef mydebug_knuenz
246 double CsolutionPart1 = -2 *
k *
d;
247 double CsolutionPart2 =
std::sqrt(4 *
k *
k *
d *
d - 4 * (1 +
k *
k) * (
d *
d - rMax_squared));
248 double CsolutionPart3 = 2 * (1 +
k *
k);
249 double Cx1 = (CsolutionPart1 + CsolutionPart2) / CsolutionPart3;
250 double Cx2 = (CsolutionPart1 - CsolutionPart2) / CsolutionPart3;
251 double Cy1 =
k * Cx1 +
d;
252 double Cy2 =
k * Cx2 +
d;
257 if (C1.x() * M1.y() - C1.y() * M1.x() < 0) {
266 #ifdef mydebug_knuenz
278 double Bx1 =
std::sqrt(Mx * Mx + My * My / (1 +
k *
k));
280 double By1 =
k * Bx1 +
d;
281 double By2 =
k * Bx2 +
d;
283 #ifdef mydebug_knuenz
291 if (M1.x() * B1.y() - M1.y() * B1.x() < 0) {
300 #ifdef mydebug_knuenz
311 #ifdef mydebug_knuenz
312 std::cout <<
"DeltaPhiMaxM1P1 " << DeltaPhiMaxM1P1 << std::endl;
314 std::cout <<
"rho P1: " <<
std::sqrt(P1.x() * P1.x() + P1.y() * P1.y()) <<
"phi P1: " << P1.Phi() << std::endl;
315 std::cout <<
"rho M1: " <<
std::sqrt(M1.x() * M1.x() + M1.y() * M1.y()) <<
"phi M1: " << M1.Phi() << std::endl;
320 double tol_DeltaPhiMaxM1P1 = DeltaPhiMaxM1P1 * toleranceFactorOnDeltaPhiCuts;
323 if (DeltaPhiManualM1P1 > DeltaPhiMaxM1P1 + tol_DeltaPhiMaxM1P1 || DeltaPhiManualM1P1 < 0 - tol_DeltaPhiMaxM1P1) {
335 double rM2_squared = M2.x() * M2.x() + M2.y() * M2.y();
336 if (rMax_squared * 4. > rM2_squared) {
339 double k = -
C.x() /
C.y();
340 double d = (rM2_squared - rMax_squared +
C.x() *
C.x() +
C.y() *
C.y()) / (2 *
C.y());
342 double M2solutionPart1 = -2 *
k *
d;
343 double M2solutionPart2 =
std::sqrt(4 *
k *
k *
d *
d - 4 * (1 +
k *
k) * (
d *
d - rM2_squared));
344 double M2solutionPart3 = 2 + 2 *
k *
k;
345 double M2xMax1 = (M2solutionPart1 + M2solutionPart2) / M2solutionPart3;
346 double M2xMax2 = (M2solutionPart1 - M2solutionPart2) / M2solutionPart3;
347 double M2yMax1 =
k * M2xMax1 +
d;
348 double M2yMax2 =
k * M2xMax2 +
d;
354 if (M2MaxVec1.x() * M2MaxVec2.y() - M2MaxVec1.y() * M2MaxVec2.x() < 0) {
355 M2MaxVec.SetXYZ(M2xMax2, M2yMax2, 0);
357 M2MaxVec.SetXYZ(M2xMax1, M2yMax1, 0);
362 #ifdef mydebug_knuenz
365 std::cout <<
"M1.x() " << M1.x() << std::endl;
366 std::cout <<
"M1.y() " << M1.y() << std::endl;
367 std::cout <<
"M2.x() " << M2.x() << std::endl;
368 std::cout <<
"M2.y() " << M2.y() << std::endl;
371 std::cout <<
"M2xMax1 " << M2xMax1 << std::endl;
372 std::cout <<
"M2xMax2 " << M2xMax2 << std::endl;
373 std::cout <<
"M2yMax1 " << M2yMax1 << std::endl;
374 std::cout <<
"M2yMax2 " << M2yMax2 << std::endl;
375 std::cout <<
"M2xMax " << M2MaxVec.x() << std::endl;
376 std::cout <<
"M2yMax " << M2MaxVec.y() << std::endl;
377 std::cout <<
"rM2_squared " << rM2_squared << std::endl;
379 std::cout <<
"DeltaPhiMaxM2 " << DeltaPhiMaxM2 << std::endl;
382 double tol_DeltaPhiMaxM2 = DeltaPhiMaxM2 * toleranceFactorOnDeltaPhiCuts;
385 if (DeltaPhiManualM2M1 > DeltaPhiMaxM2 + tol_DeltaPhiMaxM2 || DeltaPhiManualM2M1 < 0 - tol_DeltaPhiMaxM2) {
391 if (DeltaPhiManualP1P2 > DeltaPhiMaxM2 + tol_DeltaPhiMaxM2 || DeltaPhiManualP1P2 < 0 - tol_DeltaPhiMaxM2) {
407 #ifdef mydebug_sguazz
411 double candPtPlus, candPtMinus;
415 if (!(nite &&
abs(nite) < 25 && nite != -1000 && nite != -2000))
421 #ifdef mydebug_sguazz
422 std::cout <<
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
425 <<
" Vertex X: " << candVtx.X() <<
" [cm] Y: " << candVtx.Y() <<
" [cm] pt+: " << candPtPlus
426 <<
" [GeV] pt-: " << candPtMinus <<
" [GeV]; #its: " << nite <<
"\n";
430 double minLegPt = CleaningMinLegPt;
431 double maxRadialDistance = CleaningmaxRadialDistance;
435 if (candPtPlus < minLegPt)
437 if (candPtMinus < minLegPt)
440 if (candPtPlus > maxLegPt)
442 if (candPtMinus > maxLegPt)
447 double maxr2 = (maxRadialDistance + cr);
449 if (h2.Perp2() > maxr2)
451 if (h3.Perp2() > maxr2)
461 if (ClusterShapeFiltering) {
473 GlobalPoint vertexPos(candVtx.x(), candVtx.y(), candVtx.z());
475 float ptMinReg = 0.1;
478 FastHelix phelix(ptth2->globalPosition(), mtth1->globalPosition(), vertexPos, nomField, &*bfield, vertexPos);
479 pkine = phelix.stateAtVertex();
480 FastHelix mhelix(mtth2->globalPosition(), mtth1->globalPosition(), vertexPos, nomField, &*bfield, vertexPos);
481 mkine = mhelix.stateAtVertex();
492 double quadPhotCotTheta = 0.;
496 double quadPhotPhi = (candVtx - vPhotVertex).
Phi();
500 candVtx.SetZ(
std::sqrt(candVtx.Perp2()) * quadPhotCotTheta + quadZ0);
501 GlobalPoint convVtxGlobalPoint(candVtx.X(), candVtx.Y(), candVtx.Z());
509 thisQuad.
x = candVtx.X();
510 thisQuad.y = candVtx.Y();
511 thisQuad.z = candVtx.Z();
512 thisQuad.ptPlus = candPtPlus;
513 thisQuad.ptMinus = candPtMinus;
514 thisQuad.cot = quadPhotCotTheta;
522 ptth2->globalPosition(), ptth1->globalPosition(), convVtxGlobalPoint, nomField, &*bfield, convVtxGlobalPoint);
526 GlobalVector(candPtPlus *
cos(quadPhotPhi), candPtPlus *
sin(quadPhotPhi), candPtPlus * quadPhotCotTheta),
528 &kinePlus.magneticField());
533 mtth2->globalPosition(), mtth1->globalPosition(), convVtxGlobalPoint, nomField, &*bfield, convVtxGlobalPoint);
537 GlobalVector(candPtMinus *
cos(quadPhotPhi), candPtMinus *
sin(quadPhotPhi), candPtMinus * quadPhotCotTheta),
539 &kineMinus.magneticField());
541 float sinThetaPlus =
sin(kinePlus.momentum().theta());
542 float sinThetaMinus =
sin(kineMinus.momentum().theta());
557 double vError =
region.originZBound();
560 std::cout <<
"QuadDispLine " << vgPhotVertex.
x() <<
" " << vgPhotVertex.
y() <<
" " << vgPhotVertex.
z() <<
" "
561 << vError <<
" " << vHit[0].
x() <<
" " << vHit[0].
y() <<
" " << vHit[0].
z() <<
" "
565 << vHit[3].
x() <<
" " << vHit[3].
y() <<
" " << vHit[3].
z() <<
" "
567 << candVtx.Z() <<
" " << fittedPrimaryVertex.X() <<
" " << fittedPrimaryVertex.Y() <<
" "
568 << fittedPrimaryVertex.Z()
572 << nite <<
" " <<
chi2 <<
"\n";
574 #ifdef mydebug_sguazz
575 std::cout <<
" >>>>> Hit quad fast reco done >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
578 std::cout <<
"[SeedForPhotonConversionFromQuadruplets]\n ptth1 ";
579 detid = ptth1->geographicalId().rawId();
581 std::cout <<
" \t " << detid <<
" " << ptth1->localPosition() <<
" " << ptth1->globalPosition();
582 detid = ptth2->geographicalId().rawId();
585 std::cout <<
" \t " << detid <<
" " << ptth2->localPosition() <<
" " << ptth2->globalPosition() <<
"\nhelix momentum "
586 << kinePlus.momentum() <<
" pt " << kinePlus.momentum().perp() <<
" radius "
587 << 1 / kinePlus.transverseCurvature() <<
" q " << kinePlus.charge();
589 detid = mtth1->geographicalId().rawId();
590 std::cout <<
" \t " << detid <<
" " << mtth1->localPosition() <<
" " << mtth1->globalPosition();
592 detid = mtth2->geographicalId().rawId();
594 std::cout <<
" \t " << detid <<
" " << mtth2->localPosition() <<
" " << mtth2->globalPosition() <<
"\nhelix momentum "
595 << kineMinus.momentum() <<
" pt " << kineMinus.momentum().perp() <<
" radius "
596 << 1 / kineMinus.transverseCurvature() <<
" q " << kineMinus.charge();
597 std::cout <<
"\n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
606 cloner = (*builder).cloner();
611 if (buildSeedBoolPos && buildSeedBoolNeg) {
622 const float cotTheta)
const {
631 bool isBOFF = (0 == nomField);
633 FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField, &*bfield, vertexPos);
634 kine = helix.stateAtVertex();
640 GlobalVector(kine.momentum().x(), kine.momentum().y(), kine.momentum().perp() * cotTheta),
642 &kine.magneticField());
652 (*pss) <<
"[SeedForPhotonConversionFromQuadruplets] initialKinematic tth1 ";
653 detid = tth1->geographicalId().rawId();
655 (*pss) <<
" \t " << detid <<
" " << tth1->localPosition() <<
" " << tth1->globalPosition();
656 detid = tth2->geographicalId().rawId();
657 (*pss) <<
" \n\t tth2 ";
659 (*pss) <<
" \t " << detid <<
" " << tth2->localPosition() <<
" " << tth2->globalPosition() <<
"\nhelix momentum "
672 float sinTheta)
const {
682 float sin2th =
sqr(sinTheta);
685 float zErr = vertexErr.
czz();
686 float transverseErr = vertexErr.
cxx();
687 C[3][3] = transverseErr;
688 C[4][4] = zErr * sin2th + transverseErr * (1 - sin2th);
717 for (
unsigned int iHit = 0; iHit <
hits.size() && iHit < 2; iHit++) {
731 uint32_t detid =
hit->geographicalId().rawId();
732 (*pss) <<
"\n[SeedForPhotonConversionFromQuadruplets] hit " << iHit;
734 (*pss) <<
" " << detid <<
"\t lp " <<
hit->localPosition() <<
" tth " << tth->localPosition() <<
" newtth "
755 double dzcut)
const {
774 for (
unsigned int iHit = 0; iHit <
hits.size() && iHit < 2; iHit++) {
809 double EstMomGamLength =
810 std::sqrt(EstMomGam.x() * EstMomGam.x() + EstMomGam.y() * EstMomGam.y() + EstMomGam.z() * EstMomGam.z());
812 EstMomGam.x() / EstMomGamLength, EstMomGam.y() / EstMomGamLength, EstMomGam.z() / EstMomGamLength);
827 EstPosGamGlobalPoint, EstMomGamGlobalVector, qCharge, magField);
831 for (
int i = 0;
i < 6; ++
i)
832 for (
int j = 0;
j < 6; ++
j)
833 aCovarianceMatrix(
i,
j) = 1
e-4;
837 const FreeTrajectoryState stateForProjectionToBeamLine(myGlobalTrajectoryParameter, myCartesianError);
845 double CovMatEntry = 0.;
847 for (
int i = 0;
i < 3; ++
i) {
848 cov(
i,
i) = CovMatEntry;
852 reco::BeamSpot myBeamSpot(BeamSpotPoint, 0., 0., 0., 0., cov, BeamType_);
855 if (tscbl.
isValid() ==
false) {
894 #ifdef mydebug_knuenz
895 std::cout <<
"zCA: " << zCA << std::endl;
898 if (std::fabs(zCA) > dzcut)
922 (*pss) <<
"\n" <<
s <<
"\t";
923 for (
size_t i = 0;
i < 2; ++
i)
924 (*
pss) << std::setw(60) <<
d[
i] << std::setw(1) <<
" | ";
928 (*pss) <<
"\n" <<
s <<
"\t";
929 for (
size_t i = 0;
i < 2; ++
i)
930 (*
pss) << std::setw(60) <<
d[
i] << std::setw(1) <<
" | ";
934 (*pss) <<
"\n" <<
s <<
"\t";
935 for (
size_t i = 0;
i < 2; ++
i)
936 (*
pss) << std::setw(20) <<
d[
i] <<
" r " <<
d[
i].perp() <<
" phi " <<
d[
i].phi() <<
" | ";
940 (*pss) <<
"\n" <<
s <<
"\n";
941 for (
int i = 0;
i <
n; ++
i)
942 (*
pss) << std::setw(20) <<
d[
i] <<
" r " <<
d[
i].perp() <<
" phi " <<
d[
i].phi() <<
"\n";
954 for (
int i = 0;
i <
n -
j;
i++) {
972 for (
int i = 0;
i <
n -
j;
i++) {
990 double x[5],
y[5], e2y[5];
995 x[0] = ohit->globalPosition().perp();
996 y[0] = ohit->globalPosition().z();
999 x[1] = nohit->globalPosition().perp();
1000 y[1] = nohit->globalPosition().z();
1003 x[2] = nihit->globalPosition().perp();
1004 y[2] = nihit->globalPosition().z();
1007 x[3] = ihit->globalPosition().perp();
1008 y[3] = ihit->globalPosition().z();
1012 x[4] =
region.origin().perp();
1014 double vError =
region.originZBound();
1017 e2y[4] =
sqr(vError);
1026 int size,
double* ax,
double* ay,
double* e2y,
double& p0,
double& e2p0,
double&
p1) {
1037 double sqrProjFactor =
1038 sqr((
hit->globalPosition().
z() -
region.origin().z()) / (
hit->globalPosition().perp() -
region.origin().perp()));
1039 return (
hit->globalPositionError().czz() + sqrProjFactor *
hit->globalPositionError().rerr(
hit->globalPosition()));
1043 for (
auto const& quad : quadV) {
1044 double dx = thisQuad.
x - quad.x;
1045 double dy = thisQuad.
y - quad.y;
1063 if (
sqrt(
dx *
dx +
dy *
dy) < 1. && fabs(thisQuad.
ptPlus - quad.ptPlus) < 0.5 * quad.ptPlus &&
1064 fabs(thisQuad.
ptMinus - quad.ptMinus) < 0.5 * quad.ptMinus) {
1069 quadV.push_back(thisQuad);
1074 double kTWOPI = 2. *
kPI_;
1075 double DeltaPhiMan = v1.Phi() - v2.Phi();
1076 while (DeltaPhiMan >=
kPI_)
1077 DeltaPhiMan -= kTWOPI;
1078 while (DeltaPhiMan < -
kPI_)
1079 DeltaPhiMan += kTWOPI;