CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
SeedForPhotonConversionFromQuadruplets Class Reference

#include <SeedForPhotonConversionFromQuadruplets.h>

Public Member Functions

void bubbleReverseSortVsPhi (GlobalPoint arr[], int n, GlobalPoint vtx)
 
void bubbleSortVsPhi (GlobalPoint arr[], int n, GlobalPoint vtx)
 
double getSqrEffectiveErrorOnZ (const SeedingHitSet::ConstRecHitPointer &hit, const TrackingRegion &region)
 
 SeedForPhotonConversionFromQuadruplets (const edm::ParameterSet &cfg, edm::ConsumesCollector &iC, const edm::ParameterSet &SeedComparitorPSet)
 
 SeedForPhotonConversionFromQuadruplets (edm::ConsumesCollector &iC, const edm::ParameterSet &SeedComparitorPSet, const std::string &propagator="PropagatorWithMaterial", double seedMomentumForBOFF=-5.0)
 
double simpleGetSlope (const SeedingHitSet::ConstRecHitPointer &ohit, const SeedingHitSet::ConstRecHitPointer &nohit, const SeedingHitSet::ConstRecHitPointer &ihit, const SeedingHitSet::ConstRecHitPointer &nihit, const TrackingRegion &region, double &cotTheta, double &z0)
 
void stupidPrint (std::string s, float *d)
 
void stupidPrint (std::string s, double *d)
 
void stupidPrint (const char *s, GlobalPoint *d)
 
void stupidPrint (const char *s, GlobalPoint *d, int n)
 
const TrajectorySeedtrajectorySeed (TrajectorySeedCollection &seedCollection, const SeedingHitSet &phits, const SeedingHitSet &mhits, const TrackingRegion &region, const edm::Event &ev, const edm::EventSetup &es, std::stringstream &ss, std::vector< Quad > &quadV, edm::ParameterSet &QuadCutPSet)
 
double verySimpleFit (int size, double *ax, double *ay, double *e2y, double &p0, double &e2p0, double &p1)
 
 ~SeedForPhotonConversionFromQuadruplets ()
 

Static Public Attributes

static const int cotTheta_Max = 99999
 

Protected Member Functions

const TrajectorySeedbuildSeed (TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts, const edm::EventSetup &es, bool apply_dzCut, const TrackingRegion &region) const
 
bool buildSeedBool (TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts, const edm::EventSetup &es, bool apply_dzCut, const TrackingRegion &region, double dzcut) const
 
bool checkHit (const TrajectoryStateOnSurface &, const SeedingHitSet::ConstRecHitPointer &hit, const edm::EventSetup &es) const
 
double DeltaPhiManual (const math::XYZVector &v1, const math::XYZVector &v2)
 
CurvilinearTrajectoryError initialError (const GlobalVector &vertexBounds, float ptMin, float sinTheta) const
 
GlobalTrajectoryParameters initialKinematic (const SeedingHitSet &hits, const GlobalPoint &vertexPos, const edm::EventSetup &es, const float cotTheta) const
 
SeedingHitSet::RecHitPointer refitHit (SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
 
bool similarQuadExist (Quad &thisQuad, std::vector< Quad > &quadV)
 

Protected Attributes

TkClonerImpl cloner
 
double kPI_
 
PrintRecoObjects po
 
std::stringstream * pss
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordtheBfieldToken
 
double theBOFFMomentum
 
std::unique_ptr< SeedComparitortheComparitor
 
edm::ESGetToken< Propagator, TrackingComponentsRecordthePropagatorToken
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtheTrackerToken
 
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordtheTTRHBuilderToken
 

Detailed Description

Definition at line 22 of file SeedForPhotonConversionFromQuadruplets.h.

Constructor & Destructor Documentation

◆ SeedForPhotonConversionFromQuadruplets() [1/2]

SeedForPhotonConversionFromQuadruplets::SeedForPhotonConversionFromQuadruplets ( const edm::ParameterSet cfg,
edm::ConsumesCollector iC,
const edm::ParameterSet SeedComparitorPSet 
)

Definition at line 38 of file SeedForPhotonConversionFromQuadruplets.cc.

41  iC,
43  cfg.getParameter<std::string>("propagator"),
44  cfg.existsAs<double>("SeedMomentumForBOFF") ? cfg.getParameter<double>("SeedMomentumForBOFF") : 5.0) {}
SeedForPhotonConversionFromQuadruplets(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC, const edm::ParameterSet &SeedComparitorPSet)

◆ SeedForPhotonConversionFromQuadruplets() [2/2]

SeedForPhotonConversionFromQuadruplets::SeedForPhotonConversionFromQuadruplets ( edm::ConsumesCollector iC,
const edm::ParameterSet SeedComparitorPSet,
const std::string &  propagator = "PropagatorWithMaterial",
double  seedMomentumForBOFF = -5.0 
)

Definition at line 46 of file SeedForPhotonConversionFromQuadruplets.cc.

References get, HLT_2024v14_cff::SeedComparitorPSet, AlCaHLTBitMon_QueryRunRegistry::string, and theComparitor.

51  : theBfieldToken(iC.esConsumes()),
52  theTTRHBuilderToken(iC.esConsumes(edm::ESInputTag("", "WithTrackAngle"))), // FIXME: add to config
55  theBOFFMomentum(seedMomentumForBOFF) {
56  std::string comparitorName = SeedComparitorPSet.getParameter<std::string>("ComponentName");
57  if (comparitorName != "none") {
58  theComparitor = SeedComparitorFactory::get()->create(comparitorName, SeedComparitorPSet, iC);
59  }
60 }
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theBfieldToken
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theTrackerToken
edm::ESGetToken< Propagator, TrackingComponentsRecord > thePropagatorToken
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTTRHBuilderToken
#define get

◆ ~SeedForPhotonConversionFromQuadruplets()

SeedForPhotonConversionFromQuadruplets::~SeedForPhotonConversionFromQuadruplets ( )

Definition at line 62 of file SeedForPhotonConversionFromQuadruplets.cc.

62 {}

Member Function Documentation

◆ bubbleReverseSortVsPhi()

void SeedForPhotonConversionFromQuadruplets::bubbleReverseSortVsPhi ( GlobalPoint  arr[],
int  n,
GlobalPoint  vtx 
)

Definition at line 954 of file SeedForPhotonConversionFromQuadruplets.cc.

References barePhi(), reco::deltaPhi(), mps_fire::i, dqmiolumiharvest::j, dqmiodumpmetadata::n, createJobs::tmp, and L1BJetProducer_cff::vtx.

954  {
955  bool swapped = true;
956  int j = 0;
958  while (swapped) {
959  swapped = false;
960  j++;
961  for (int i = 0; i < n - j; i++) {
962  if (reco::deltaPhi((arr[i] - vtx).barePhi(), (arr[i + 1] - vtx).barePhi()) < 0.) {
963  tmp = arr[i];
964  arr[i] = arr[i + 1];
965  arr[i + 1] = tmp;
966  swapped = true;
967  }
968  }
969  }
970 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
T barePhi() const
tmp
align.sh
Definition: createJobs.py:716

◆ bubbleSortVsPhi()

void SeedForPhotonConversionFromQuadruplets::bubbleSortVsPhi ( GlobalPoint  arr[],
int  n,
GlobalPoint  vtx 
)

Definition at line 936 of file SeedForPhotonConversionFromQuadruplets.cc.

References barePhi(), reco::deltaPhi(), mps_fire::i, dqmiolumiharvest::j, dqmiodumpmetadata::n, createJobs::tmp, and L1BJetProducer_cff::vtx.

936  {
937  bool swapped = true;
938  int j = 0;
940  while (swapped) {
941  swapped = false;
942  j++;
943  for (int i = 0; i < n - j; i++) {
944  if (reco::deltaPhi((arr[i] - vtx).barePhi(), (arr[i + 1] - vtx).barePhi()) > 0.) {
945  tmp = arr[i];
946  arr[i] = arr[i + 1];
947  arr[i + 1] = tmp;
948  swapped = true;
949  }
950  }
951  }
952 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
T barePhi() const
tmp
align.sh
Definition: createJobs.py:716

◆ buildSeed()

const TrajectorySeed * SeedForPhotonConversionFromQuadruplets::buildSeed ( TrajectorySeedCollection seedCollection,
const SeedingHitSet hits,
const FreeTrajectoryState fts,
const edm::EventSetup es,
bool  apply_dzCut,
const TrackingRegion region 
) const
protected

Definition at line 690 of file SeedForPhotonConversionFromQuadruplets.cc.

References alongMomentum, edm::EventSetup::getData(), hfClusterShapes_cfi::hits, BaseTrackerRecHit::localPosition(), trajectoryStateTransform::persistentState(), po, PrintRecoObjects::print(), TrackCandidateProducer_cfi::propagator, edm::OwnVector< T, P >::push_back(), refitHit(), ElectronSeedTrackRefFix_cfi::seedCollection, thePropagatorToken, theTrackerToken, PbPb_ZMuSkimMuonDPG_cff::tracker, and HLT_2024v14_cff::updator.

Referenced by trajectorySeed().

695  {
696  // get tracker
697  const auto& tracker = es.getData(theTrackerToken);
698 
699  // get propagator
701 
702  // get updator
704 
705  // Now update initial state track using information from seed hits.
706 
707  TrajectoryStateOnSurface updatedState;
709 
710  const TrackingRecHit* hit = nullptr;
711  for (unsigned int iHit = 0; iHit < hits.size() && iHit < 2; iHit++) {
712  hit = hits[iHit];
714  (iHit == 0) ? propagator->propagate(fts, tracker.idToDet(hit->geographicalId())->surface())
715  : propagator->propagate(updatedState, tracker.idToDet(hit->geographicalId())->surface());
716 
718 
720 
721  updatedState = updator.update(state, *newtth);
722 
723  seedHits.push_back(newtth);
724 #ifdef mydebug_seed
725  uint32_t detid = hit->geographicalId().rawId();
726  (*pss) << "\n[SeedForPhotonConversionFromQuadruplets] hit " << iHit;
727  po.print(*pss, detid);
728  (*pss) << " " << detid << "\t lp " << hit->localPosition() << " tth " << tth->localPosition() << " newtth "
729  << newtth->localPosition() << " state " << state.globalMomentum().perp();
730 #endif
731  }
732 
733  if (!hit)
734  return nullptr;
735 
736  PTrajectoryStateOnDet const& PTraj =
737  trajectoryStateTransform::persistentState(updatedState, hit->geographicalId().rawId());
738 
739  seedCollection.push_back(TrajectorySeed(PTraj, seedHits, alongMomentum));
740  return &seedCollection.back();
741 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theTrackerToken
edm::ESGetToken< Propagator, TrackingComponentsRecord > thePropagatorToken
void push_back(D *&d)
Definition: OwnVector.h:326
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:14
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
void print(std::stringstream &ss, const SiStripCluster &clus)
LocalPoint localPosition() const override

◆ buildSeedBool()

bool SeedForPhotonConversionFromQuadruplets::buildSeedBool ( TrajectorySeedCollection seedCollection,
const SeedingHitSet hits,
const FreeTrajectoryState fts,
const edm::EventSetup es,
bool  apply_dzCut,
const TrackingRegion region,
double  dzcut 
) const
protected

Implement here the dz cut:::

Definition at line 743 of file SeedForPhotonConversionFromQuadruplets.cc.

References checkHit(), TrackingRecHit::clone(), gather_cfg::cout, MillePedeFileConverter_cfg::e, edm::EventSetup::getData(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), BaseTrackerRecHit::hit(), hfClusterShapes_cfi::hits, mps_fire::i, TrajectoryStateClosestToBeamLine::isValid(), TrajectoryStateOnSurface::isValid(), dqmiolumiharvest::j, FreeTrajectoryState::position(), TrackCandidateProducer_cfi::propagator, edm::OwnVector< T, P >::push_back(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::qCharge, refitHit(), nano_mu_digi_cff::region, mathSSE::sqrt(), theBfieldToken, thePropagatorToken, theTrackerToken, PbPb_ZMuSkimMuonDPG_cff::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), reco::BeamSpot::Unknown, HLT_2024v14_cff::updator, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by trajectorySeed().

749  {
750  // get tracker
751  const auto& tracker = es.getData(theTrackerToken);
752 
753  // get propagator
755 
756  // get updator
758 
759  // Now update initial state track using information from seed hits.
760 
761  TrajectoryStateOnSurface updatedState;
763 
764  const TrackingRecHit* hit = nullptr;
765  for (unsigned int iHit = 0; iHit < hits.size() && iHit < 2; iHit++) {
766  hit = hits[iHit]->hit();
768  (iHit == 0) ? propagator->propagate(fts, tracker.idToDet(hit->geographicalId())->surface())
769  : propagator->propagate(updatedState, tracker.idToDet(hit->geographicalId())->surface());
770  if (!state.isValid()) {
771  return false;
772  }
773 
775 
777 
778  if (!checkHit(state, newtth, es)) {
779  return false;
780  }
781 
782  updatedState = updator.update(state, *newtth);
783  if (!updatedState.isValid()) {
784  return false;
785  }
786 
787  seedHits.push_back(newtth->hit()->clone());
788  }
789 
790  if (apply_dzCut) {
792 
793  double zCA;
794 
795  math::XYZVector EstMomGam(
796  updatedState.globalMomentum().x(), updatedState.globalMomentum().y(), updatedState.globalMomentum().z());
797  math::XYZVector EstPosGam(
798  updatedState.globalPosition().x(), updatedState.globalPosition().y(), updatedState.globalPosition().z());
799 
800  double EstMomGamLength =
801  std::sqrt(EstMomGam.x() * EstMomGam.x() + EstMomGam.y() * EstMomGam.y() + EstMomGam.z() * EstMomGam.z());
802  math::XYZVector EstMomGamNorm(
803  EstMomGam.x() / EstMomGamLength, EstMomGam.y() / EstMomGamLength, EstMomGam.z() / EstMomGamLength);
804 
805  //Calculate dz of point of closest approach of the two lines (WA approach) -> cut on dz
806 
807  const GlobalPoint EstPosGamGlobalPoint(
808  updatedState.globalPosition().x(), updatedState.globalPosition().y(), updatedState.globalPosition().z());
809  const GlobalVector EstMomGamGlobalVector(
810  updatedState.globalMomentum().x(), updatedState.globalMomentum().y(), updatedState.globalMomentum().z());
811 
812  const MagneticField* magField = &es.getData(theBfieldToken);
813  TrackCharge qCharge = 0;
814 
815  const GlobalTrajectoryParameters myGlobalTrajectoryParameter(
816  EstPosGamGlobalPoint, EstMomGamGlobalVector, qCharge, magField);
817 
818  AlgebraicSymMatrix66 aCovarianceMatrix;
819 
820  for (int i = 0; i < 6; ++i)
821  for (int j = 0; j < 6; ++j)
822  aCovarianceMatrix(i, j) = 1e-4;
823 
824  CartesianTrajectoryError myCartesianError(aCovarianceMatrix);
825 
826  const FreeTrajectoryState stateForProjectionToBeamLine(myGlobalTrajectoryParameter, myCartesianError);
827 
828  const GlobalPoint BeamSpotGlobalPoint(0, 0, 0);
829 
830  const reco::BeamSpot::Point BeamSpotPoint(region.origin().x(), region.origin().y(), region.origin().z());
831 
832  TSCBLBuilderNoMaterial tscblBuilder;
833 
834  double CovMatEntry = 0.;
836  for (int i = 0; i < 3; ++i) {
837  cov(i, i) = CovMatEntry;
838  }
840 
841  reco::BeamSpot myBeamSpot(BeamSpotPoint, 0., 0., 0., 0., cov, BeamType_);
842 
843  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(stateForProjectionToBeamLine, myBeamSpot);
844  if (tscbl.isValid() == false) {
845  zCA = 0;
846  } else {
847  GlobalPoint v = tscbl.trackStateAtPCA().position(); // Position of closest approach to BS
848  zCA = v.z();
849  }
850 
851  /* //Calculate dz of point of closest approach of the two lines -> cut on dz
852 
853  double newX,newY,newR;
854  double Rbuff=std::sqrt(EstPosGam.x()*EstPosGam.x()+EstPosGam.y()*EstPosGam.y());
855  double deltas,s,sbuff;
856  double rMin=1e9;
857 
858  double InitXp=EstPosGam.x()+1*EstMomGamNorm.x();
859  double InitXm=EstPosGam.x()-1*EstMomGamNorm.x();
860  double InitYp=EstPosGam.y()+1*EstMomGamNorm.y();
861  double InitYm=EstPosGam.y()-1*EstMomGamNorm.y();
862 
863  if(InitXp*InitXp+InitYp*InitYp < InitXm*InitXm+InitYm*InitYm) {s=5; deltas=5;}
864  else {s=-5; deltas=-5;}
865 
866  int nTurns=0;
867  int nIterZ=0;
868  for (int i_dz=0;i_dz<1000;i_dz++){
869  newX=EstPosGam.x()+s*EstMomGamNorm.x();
870  newY=EstPosGam.y()+s*EstMomGamNorm.y();
871  newR=std::sqrt(newX*newX+newY*newY);
872  if(newR>Rbuff) {deltas=-1*deltas/10;nTurns++;}
873  else {Rbuff=newR;}
874  if(newR<rMin) {rMin=newR; sbuff=s;}
875  s=s+deltas;
876  nIterZ++;
877  if(nTurns>1) break;
878  }
879 
880  zCA=EstPosGam.z()+sbuff*EstMomGamNorm.z();
881 */
882 
883 #ifdef mydebug_knuenz
884  std::cout << "zCA: " << zCA << std::endl;
885 #endif
886 
887  if (std::fabs(zCA) > dzcut)
888  return false;
889  }
890 
891  return true;
892 }
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
BeamType
beam spot flags
Definition: BeamSpot.h:24
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
T z() const
Definition: PV3DBase.h:61
BaseTrackerRecHit const * hit() const final
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theBfieldToken
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theTrackerToken
edm::ESGetToken< Propagator, TrackingComponentsRecord > thePropagatorToken
GlobalPoint position() const
int TrackCharge
Definition: TrackCharge.h:4
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
void push_back(D *&d)
Definition: OwnVector.h:326
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:14
GlobalPoint globalPosition() const
T sqrt(T t)
Definition: SSEVec.h:23
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
bool checkHit(const TrajectoryStateOnSurface &, const SeedingHitSet::ConstRecHitPointer &hit, const edm::EventSetup &es) const
virtual TrackingRecHit * clone() const =0
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
GlobalVector globalMomentum() const

◆ checkHit()

bool SeedForPhotonConversionFromQuadruplets::checkHit ( const TrajectoryStateOnSurface ,
const SeedingHitSet::ConstRecHitPointer hit,
const edm::EventSetup es 
) const
inlineprotected

Definition at line 70 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by buildSeedBool().

72  {
73  return true;
74  }

◆ DeltaPhiManual()

double SeedForPhotonConversionFromQuadruplets::DeltaPhiManual ( const math::XYZVector v1,
const math::XYZVector v2 
)
protected

Definition at line 1062 of file SeedForPhotonConversionFromQuadruplets.cc.

References kPI_.

Referenced by trajectorySeed().

1062  {
1063  double kTWOPI = 2. * kPI_;
1064  double DeltaPhiMan = v1.Phi() - v2.Phi();
1065  while (DeltaPhiMan >= kPI_)
1066  DeltaPhiMan -= kTWOPI;
1067  while (DeltaPhiMan < -kPI_)
1068  DeltaPhiMan += kTWOPI;
1069 
1070  return DeltaPhiMan;
1071 }

◆ getSqrEffectiveErrorOnZ()

double SeedForPhotonConversionFromQuadruplets::getSqrEffectiveErrorOnZ ( const SeedingHitSet::ConstRecHitPointer hit,
const TrackingRegion region 
)

Definition at line 1020 of file SeedForPhotonConversionFromQuadruplets.cc.

References nano_mu_digi_cff::region, sqr(), and hit::z.

Referenced by simpleGetSlope(), and trajectorySeed().

1021  {
1022  //
1023  //Fit-wise the effective error on Z is the sum in quadrature of the error on Z
1024  //and the error on R correctly projected by using hit-vertex direction
1025 
1026  double sqrProjFactor =
1027  sqr((hit->globalPosition().z() - region.origin().z()) / (hit->globalPosition().perp() - region.origin().perp()));
1028  return (hit->globalPositionError().czz() + sqrProjFactor * hit->globalPositionError().rerr(hit->globalPosition()));
1029 }

◆ initialError()

CurvilinearTrajectoryError SeedForPhotonConversionFromQuadruplets::initialError ( const GlobalVector vertexBounds,
float  ptMin,
float  sinTheta 
) const
protected

Definition at line 667 of file SeedForPhotonConversionFromQuadruplets.cc.

References correctionTermsCaloMet_cff::C, GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::czz(), SiStripPI::max, ptMin, sqr(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by trajectorySeed().

669  {
670  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
671  // information.
672  GlobalError vertexErr(sqr(vertexBounds.x()), 0, sqr(vertexBounds.y()), 0, 0, sqr(vertexBounds.z()));
673 
674  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
675 
676  // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
677  // to avoid instabilities.
678  // N.B. This parameter needs optimising ...
679  float sin2th = sqr(sinTheta);
680  float minC00 = 1.0;
681  C[0][0] = std::max(sin2th / sqr(ptMin), minC00);
682  float zErr = vertexErr.czz();
683  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
684  C[3][3] = transverseErr;
685  C[4][4] = zErr * sin2th + transverseErr * (1 - sin2th);
686 
688 }
T z() const
Definition: PV3DBase.h:61
constexpr float ptMin
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55

◆ initialKinematic()

GlobalTrajectoryParameters SeedForPhotonConversionFromQuadruplets::initialKinematic ( const SeedingHitSet hits,
const GlobalPoint vertexPos,
const edm::EventSetup es,
const float  cotTheta 
) const
protected

Definition at line 617 of file SeedForPhotonConversionFromQuadruplets.cc.

References GlobalTrajectoryParameters::charge(), cotTheta_Max, edm::EventSetup::getData(), hfClusterShapes_cfi::hits, GlobalTrajectoryParameters::magneticField(), GlobalTrajectoryParameters::momentum(), PV3DBase< T, PVType, FrameType >::perp(), po, GlobalTrajectoryParameters::position(), PrintRecoObjects::print(), theBfieldToken, theBOFFMomentum, GlobalTrajectoryParameters::transverseCurvature(), Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

620  {
622 
625 
626  const auto& bfield = es.getData(theBfieldToken);
627  float nomField = bfield.nominalValue();
628  bool isBOFF = (0 == nomField);
629 
630  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField, &bfield, vertexPos);
631  kine = helix.stateAtVertex();
632 
633  //force the pz/pt equal to the measured one
634  if (fabs(cotTheta) < cotTheta_Max)
636  kine.position(),
637  GlobalVector(kine.momentum().x(), kine.momentum().y(), kine.momentum().perp() * cotTheta),
638  kine.charge(),
639  &kine.magneticField());
640  else
642  kine.position(),
643  GlobalVector(kine.momentum().x(), kine.momentum().y(), kine.momentum().perp() * cotTheta_Max),
644  kine.charge(),
645  &kine.magneticField());
646 
647 #ifdef mydebug_seed
648  uint32_t detid;
649  (*pss) << "[SeedForPhotonConversionFromQuadruplets] initialKinematic tth1 ";
650  detid = tth1->geographicalId().rawId();
651  po.print(*pss, detid);
652  (*pss) << " \t " << detid << " " << tth1->localPosition() << " " << tth1->globalPosition();
653  detid = tth2->geographicalId().rawId();
654  (*pss) << " \n\t tth2 ";
655  po.print(*pss, detid);
656  (*pss) << " \t " << detid << " " << tth2->localPosition() << " " << tth2->globalPosition() << "\nhelix momentum "
657  << kine.momentum() << " pt " << kine.momentum().perp() << " radius " << 1 / kine.transverseCurvature();
658 #endif
659 
660  if (isBOFF && (theBOFFMomentum > 0)) {
661  kine =
662  GlobalTrajectoryParameters(kine.position(), kine.momentum().unit() * theBOFFMomentum, kine.charge(), &bfield);
663  }
664  return kine;
665 }
T perp() const
Definition: PV3DBase.h:69
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theBfieldToken
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:14
void print(std::stringstream &ss, const SiStripCluster &clus)
const MagneticField & magneticField() const
Vector3DBase unit() const
Definition: Vector3DBase.h:54
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ refitHit()

SeedingHitSet::RecHitPointer SeedForPhotonConversionFromQuadruplets::refitHit ( SeedingHitSet::ConstRecHitPointer  hit,
const TrajectoryStateOnSurface state 
) const
protected

Definition at line 894 of file SeedForPhotonConversionFromQuadruplets.cc.

References cloner.

Referenced by buildSeed(), and buildSeedBool().

895  {
896  //const TransientTrackingRecHit* a= hit.get();
897  //return const_cast<TransientTrackingRecHit*> (a);
898  //This was modified otherwise the rechit will have just the local x component and local y=0
899  // To understand how to modify for pixels
900 
901  //const TSiStripRecHit2DLocalPos* b = dynamic_cast<const TSiStripRecHit2DLocalPos*>(a);
902  //return const_cast<TSiStripRecHit2DLocalPos*>(b);
904 }

◆ similarQuadExist()

bool SeedForPhotonConversionFromQuadruplets::similarQuadExist ( Quad thisQuad,
std::vector< Quad > &  quadV 
)
protected

Definition at line 1031 of file SeedForPhotonConversionFromQuadruplets.cc.

References PVValHelper::dx, PVValHelper::dy, Quad::ptMinus, Quad::ptPlus, mathSSE::sqrt(), Quad::x, and Quad::y.

Referenced by trajectorySeed().

1031  {
1032  for (auto const& quad : quadV) {
1033  double dx = thisQuad.x - quad.x;
1034  double dy = thisQuad.y - quad.y;
1035  //double dz = abs(thisQuad.z-quad.z);
1036  //std::cout<<"thisQuad.x="<<thisQuad.x<<" "<<"quad.x="<<quad.x<<" "<<"thisQuad.y="<<thisQuad.y<<" "<<"quad.y="<<quad.y<<" "<<"thisQuad.z"<<thisQuad.z<<" "<<"quad.z="<<quad.z<<" "<<"thisQuad.ptPlus"<<thisQuad.ptPlus<<" "<<"quad.ptPlus="<<quad.ptPlus<<" "<<"thisQuad.ptMinus="<<thisQuad.ptMinus<<" "<<"quad.ptMinus="<<quad.ptMinus<<" "<<"thisQuad.cot="<<thisQuad.cot<<" "<<"quad.cot="<<quad.cot<<std::endl; //ValDebug
1037  //std::cout<<"x1-x2="<<dx<<"y1-y2="<<dy<<"dx*dx+dy*dy="<<dx*dx+dy*dy<<std::endl; //ValDebug
1038  //std::cout<<"thisQuad.ptPlus-quad.ptPlus="<<thisQuad.ptPlus-quad.ptPlus<<"abs(thisQuad.ptPlus-quad.ptPlus)="<<abs(thisQuad.ptPlus-quad.ptPlus)<<std::endl; //ValDebug
1039  //std::cout <<sqrt(dx*dx+dy*dy)<<" <1? "<<dz<<" <3? "<<abs(thisQuad.ptPlus-quad.ptPlus)<<" <0.5? "<<abs(thisQuad.ptMinus-quad.ptMinus)<<" <0.5? "<<abs(thisQuad.cot-quad.cot)<<" <0.3? "<<std::endl; //ValDebug
1040  //if ( sqrt(dx*dx+dy*dy)<1.)
1041  // std::cout <<sqrt(dx*dx+dy*dy)<<" <1? "<<dz<<" <3? "<<abs(thisQuad.ptPlus-quad.ptPlus)<<" <"<<0.5*quad.ptPlus<<"? "<<abs(thisQuad.ptMinus-quad.ptMinus)<<" <"<<0.5*quad.ptMinus<<"? "<<abs(thisQuad.cot-quad.cot)<<" <"<<0.3*quad.cot<<"? "<<std::endl; //ValDebug
1042  // ( sqrt(dx*dx+dy*dy)<1. &&
1043  //z<3. &&
1044  //bs(thisQuad.ptPlus-quad.ptPlus)<0.5*quad.ptPlus &&
1045  //bs(thisQuad.ptMinus-quad.ptMinus)<0.5*quad.ptMinus &&
1046  //bs(thisQuad.cot-quad.cot)<0.3*quad.cot
1047  //
1048  // {
1049  // //std::cout<<"Seed rejected due to arbitration"<<std::endl;
1050  // return true;
1051  // }
1052  if (sqrt(dx * dx + dy * dy) < 1. && fabs(thisQuad.ptPlus - quad.ptPlus) < 0.5 * quad.ptPlus &&
1053  fabs(thisQuad.ptMinus - quad.ptMinus) < 0.5 * quad.ptMinus) {
1054  //std::cout<<"Seed rejected due to arbitration"<<std::endl;
1055  return true;
1056  }
1057  }
1058  quadV.push_back(thisQuad);
1059  return false;
1060 }
double ptMinus
Definition: Quad.h:9
double ptPlus
Definition: Quad.h:8
double x
Definition: Quad.h:5
T sqrt(T t)
Definition: SSEVec.h:23
double y
Definition: Quad.h:6

◆ simpleGetSlope()

double SeedForPhotonConversionFromQuadruplets::simpleGetSlope ( const SeedingHitSet::ConstRecHitPointer ohit,
const SeedingHitSet::ConstRecHitPointer nohit,
const SeedingHitSet::ConstRecHitPointer ihit,
const SeedingHitSet::ConstRecHitPointer nihit,
const TrackingRegion region,
double &  cotTheta,
double &  z0 
)

Definition at line 972 of file SeedForPhotonConversionFromQuadruplets.cc.

References nano_mu_local_reco_cff::chi2, getSqrEffectiveErrorOnZ(), nano_mu_digi_cff::region, sqr(), verySimpleFit(), x, y, and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by trajectorySeed().

978  {
979  double x[5], y[5], e2y[5];
980 
981  //The fit is done filling x with r values, y with z values of the four hits and the vertex
982  //
983  //Hits
984  x[0] = ohit->globalPosition().perp();
985  y[0] = ohit->globalPosition().z();
986  e2y[0] = getSqrEffectiveErrorOnZ(ohit, region);
987  //
988  x[1] = nohit->globalPosition().perp();
989  y[1] = nohit->globalPosition().z();
990  e2y[1] = getSqrEffectiveErrorOnZ(nohit, region);
991  //
992  x[2] = nihit->globalPosition().perp();
993  y[2] = nihit->globalPosition().z();
994  e2y[2] = getSqrEffectiveErrorOnZ(nihit, region);
995  //
996  x[3] = ihit->globalPosition().perp();
997  y[3] = ihit->globalPosition().z();
998  e2y[3] = getSqrEffectiveErrorOnZ(ihit, region);
999  //
1000  //Vertex
1001  x[4] = region.origin().perp();
1002  y[4] = region.origin().z();
1003  double vError = region.originZBound();
1004  if (vError > 15.)
1005  vError = 1.;
1006  e2y[4] = sqr(vError);
1007 
1008  double e2z0;
1009  double chi2 = verySimpleFit(5, x, y, e2y, z0, e2z0, cotTheta);
1010 
1011  return chi2;
1012 }
double verySimpleFit(int size, double *ax, double *ay, double *e2y, double &p0, double &e2p0, double &p1)
double getSqrEffectiveErrorOnZ(const SeedingHitSet::ConstRecHitPointer &hit, const TrackingRegion &region)

◆ stupidPrint() [1/4]

void SeedForPhotonConversionFromQuadruplets::stupidPrint ( std::string  s,
float *  d 
)

Definition at line 910 of file SeedForPhotonConversionFromQuadruplets.cc.

References ztail::d, mps_fire::i, and alignCSCRings::s.

910  {
911  (*pss) << "\n" << s << "\t";
912  for (size_t i = 0; i < 2; ++i)
913  (*pss) << std::setw(60) << d[i] << std::setw(1) << " | ";
914 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
d
Definition: ztail.py:151

◆ stupidPrint() [2/4]

void SeedForPhotonConversionFromQuadruplets::stupidPrint ( std::string  s,
double *  d 
)

Definition at line 916 of file SeedForPhotonConversionFromQuadruplets.cc.

References ztail::d, mps_fire::i, and alignCSCRings::s.

916  {
917  (*pss) << "\n" << s << "\t";
918  for (size_t i = 0; i < 2; ++i)
919  (*pss) << std::setw(60) << d[i] << std::setw(1) << " | ";
920 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
d
Definition: ztail.py:151

◆ stupidPrint() [3/4]

void SeedForPhotonConversionFromQuadruplets::stupidPrint ( const char *  s,
GlobalPoint d 
)

Definition at line 922 of file SeedForPhotonConversionFromQuadruplets.cc.

References ztail::d, mps_fire::i, and alignCSCRings::s.

922  {
923  (*pss) << "\n" << s << "\t";
924  for (size_t i = 0; i < 2; ++i)
925  (*pss) << std::setw(20) << d[i] << " r " << d[i].perp() << " phi " << d[i].phi() << " | ";
926 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
d
Definition: ztail.py:151

◆ stupidPrint() [4/4]

void SeedForPhotonConversionFromQuadruplets::stupidPrint ( const char *  s,
GlobalPoint d,
int  n 
)

Definition at line 928 of file SeedForPhotonConversionFromQuadruplets.cc.

References ztail::d, mps_fire::i, dqmiodumpmetadata::n, and alignCSCRings::s.

928  {
929  (*pss) << "\n" << s << "\n";
930  for (int i = 0; i < n; ++i)
931  (*pss) << std::setw(20) << d[i] << " r " << d[i].perp() << " phi " << d[i].phi() << "\n";
932 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
d
Definition: ztail.py:151

◆ trajectorySeed()

const TrajectorySeed * SeedForPhotonConversionFromQuadruplets::trajectorySeed ( TrajectorySeedCollection seedCollection,
const SeedingHitSet phits,
const SeedingHitSet mhits,
const TrackingRegion region,
const edm::Event ev,
const edm::EventSetup es,
std::stringstream &  ss,
std::vector< Quad > &  quadV,
edm::ParameterSet QuadCutPSet 
)

Definition at line 64 of file SeedForPhotonConversionFromQuadruplets.cc.

References funct::abs(), B, buildSeed(), buildSeedBool(), correctionTermsCaloMet_cff::C, nano_mu_local_reco_cff::chi2, cloner, runTheMatrix::const, Conv4HitsReco2::ConversionCandidate(), funct::cos(), gather_cfg::cout, ztail::d, DeltaPhiManual(), Conv4HitsReco2::Dump(), makeMEIFBenchmarkPlots::ev, edm::EventSetup::getData(), getSqrEffectiveErrorOnZ(), initialError(), listHistos::IP, leptonTimeLifeInfo_common_cff::IPx, leptonTimeLifeInfo_common_cff::IPy, dqmdumpme::k, kPI_, VtxSmearedParameters_cfi::Phi, phits, ptmin, PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::QuadCutPSet, nano_mu_digi_cff::region, PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::rejectAllQuads, photonAnalyzer_cfi::rMax, ElectronSeedTrackRefFix_cfi::seedCollection, Conv4HitsReco2::SetMaxNumberOfIterations(), similarQuadExist(), simpleGetSlope(), funct::sin(), SeedingHitSet::size(), mathSSE::sqrt(), contentValuesCheck::ss, theBfieldToken, theComparitor, theTTRHBuilderToken, Quad::x, x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

72  {
74 
75  bool rejectAllQuads = QuadCutPSet.getParameter<bool>("rejectAllQuads");
76  if (rejectAllQuads)
77  return nullptr;
78 
79  bool applyDeltaPhiCuts = QuadCutPSet.getParameter<bool>("apply_DeltaPhiCuts");
80  bool ClusterShapeFiltering = QuadCutPSet.getParameter<bool>("apply_ClusterShapeFilter");
81  bool applyArbitration = QuadCutPSet.getParameter<bool>("apply_Arbitration");
82  bool applydzCAcut = QuadCutPSet.getParameter<bool>("apply_zCACut");
83  double CleaningmaxRadialDistance = QuadCutPSet.getParameter<double>("Cut_DeltaRho"); //cm
84  double BeamPipeRadiusCut = QuadCutPSet.getParameter<double>("Cut_BeamPipeRadius"); //cm
85  double CleaningMinLegPt = QuadCutPSet.getParameter<double>("Cut_minLegPt"); //GeV
86  double maxLegPt = QuadCutPSet.getParameter<double>("Cut_maxLegPt"); //GeV
87  double dzcut = QuadCutPSet.getParameter<double>("Cut_zCA"); //cm
88 
89  double toleranceFactorOnDeltaPhiCuts = 0.1;
90 
91  // return 0; //FIXME, remove this line to make the code working.
92 
93  pss = &ss;
94 
95  if (phits.size() < 2)
96  return nullptr;
97  if (mhits.size() < 2)
98  return nullptr;
99 
100  //PUT HERE THE QUADRUPLET ALGORITHM, AND IN CASE USE THE METHODS ALREADY DEVELOPED, ADAPTING THEM
101 
102  //
103  // Rozzo ma efficace (per ora)
104  //
105 
106 #ifdef mydebug_sguazz
107  std::cout << " --------------------------------------------------------------------------"
108  << "\n";
109  std::cout << " Starting a hit quad fast reco "
110  << "\n";
111  std::cout << " --------------------------------------------------------------------------"
112  << "\n";
113 #endif
114 
115  //
116  // Let's build the 4 hits
119  SeedingHitSet::ConstRecHitPointer mtth1 = mhits[0];
120  SeedingHitSet::ConstRecHitPointer mtth2 = mhits[1];
121 
122  GlobalPoint vHit[4];
123  vHit[0] = ptth2->globalPosition();
124  vHit[1] = ptth1->globalPosition();
125  vHit[2] = mtth1->globalPosition();
126  vHit[3] = mtth2->globalPosition();
127 
128  //Photon source vertex primary vertex
129  const GlobalPoint& vgPhotVertex = region.origin();
130  math::XYZVector vPhotVertex(vgPhotVertex.x(), vgPhotVertex.y(), vgPhotVertex.z());
131 
132  math::XYZVector h1(vHit[0].x(), vHit[0].y(), vHit[0].z());
133  math::XYZVector h2(vHit[1].x(), vHit[1].y(), vHit[1].z());
134  math::XYZVector h3(vHit[2].x(), vHit[2].y(), vHit[2].z());
135  math::XYZVector h4(vHit[3].x(), vHit[3].y(), vHit[3].z());
136 
137  // At this point implement cleaning cuts before building the seed:::
138 
139  /*
140  Notes:
141 
142 h1, h2: positron
143 h3, h4: electron
144 
145 P1, P2: positron, ordered with radius
146 M1, M2: electron, ordered with radius
147 
148 Evan's notation:
149 V1=P1
150 V2=M1
151 V3=P2
152 V4=M2
153 
154 */
155 
156  math::XYZVector P1;
157  math::XYZVector P2;
158  math::XYZVector M1;
159  math::XYZVector M2;
160 
161  if (h1.x() * h1.x() + h1.y() * h1.y() < h2.x() * h2.x() + h2.y() * h2.y()) {
162  P1 = h1;
163  P2 = h2;
164  } else {
165  P1 = h2;
166  P2 = h1;
167  }
168 
169  if (h3.x() * h3.x() + h3.y() * h3.y() < h4.x() * h4.x() + h4.y() * h4.y()) {
170  M1 = h3;
171  M2 = h4;
172  } else {
173  M1 = h4;
174  M2 = h3;
175  }
176 
178  // Intersection-point:::
180  /*
181 Calculate the intersection point of the lines P2-P1 and M2-M1.
182 If this point is in the beam pipe, or if the distance of this
183 point to the layer of the most inner hit of the seed is less
184 than CleaningmaxRadialDistance cm, the combination is rejected.
185 */
186 
187  math::XYZVector IP(0, 0, 0);
188 
189  //Line1:
190  double kP = (P1.y() - P2.y()) / (P1.x() - P2.x());
191  double dP = P1.y() - kP * P1.x();
192  //Line2:
193  double kM = (M1.y() - M2.y()) / (M1.x() - M2.x());
194  double dM = M1.y() - kM * M1.x();
195  //Intersection:
196  double IPx = (dM - dP) / (kP - kM);
197  double IPy = kP * IPx + dP;
198 
199  IP.SetXYZ(IPx, IPy, 0);
200 
201  double IPrho = std::sqrt(IP.x() * IP.x() + IP.y() * IP.y());
202  double P1rho2 = P1.x() * P1.x() + P1.y() * P1.y();
203  double M1rho2 = M1.x() * M1.x() + M1.y() * M1.y();
204  double maxIPrho2 = IPrho + CleaningmaxRadialDistance;
205  maxIPrho2 *= maxIPrho2;
206 
207  if (IPrho < BeamPipeRadiusCut || P1rho2 > maxIPrho2 || M1rho2 > maxIPrho2) {
208  return nullptr;
209  }
210 
211  if (applyDeltaPhiCuts) {
212  kPI_ = std::atan(1.0) * 4;
213 
214  const auto& bfield = es.getData(theBfieldToken);
215  math::XYZVector QuadMean(0, 0, 0);
216  QuadMean.SetXYZ((M1.x() + M2.x() + P1.x() + P2.x()) / 4.,
217  (M1.y() + M2.y() + P1.y() + P2.y()) / 4.,
218  (M1.z() + M2.z() + P1.z() + P2.z()) / 4.);
219 
220  double fBField = bfield.inTesla(GlobalPoint(QuadMean.x(), QuadMean.y(), QuadMean.z())).z();
221 
222  double rMax = CleaningMinLegPt / (0.01 * 0.3 * fBField);
223  double rMax_squared = rMax * rMax;
224  double Mx = M1.x();
225  double My = M1.y();
226 
227  math::XYZVector B(0, 0, 0);
228  math::XYZVector C(0, 0, 0);
229 
230  if (rMax_squared * 4. > Mx * Mx + My * My) {
232  // Cleaning P1 points:::
234 
235  //Cx, Cy = Coordinates of circle center
236  //C_=line that contains the circle center
237 
238  //C_=k*x+d
239  double k = -Mx / My;
240  double d = My / 2. - k * Mx / 2.;
241 
242 #ifdef mydebug_knuenz
243  std::cout << "k" << k << std::endl;
244  std::cout << "d" << d << std::endl;
245 #endif
246 
247  //Cx1,2 and Cy1,2 are the two points that have a distance of rMax to 0,0
248  double CsolutionPart1 = -2 * k * d;
249  double CsolutionPart2 = std::sqrt(4 * k * k * d * d - 4 * (1 + k * k) * (d * d - rMax_squared));
250  double CsolutionPart3 = 2 * (1 + k * k);
251  double Cx1 = (CsolutionPart1 + CsolutionPart2) / CsolutionPart3;
252  double Cx2 = (CsolutionPart1 - CsolutionPart2) / CsolutionPart3;
253  double Cy1 = k * Cx1 + d;
254  double Cy2 = k * Cx2 + d;
255 
256  // Decide between solutions: phi(C) > phi(P)
257  double Cx, Cy;
258  math::XYZVector C1(Cx1, Cy1, 0);
259  if (C1.x() * M1.y() - C1.y() * M1.x() < 0) {
260  Cx = Cx1;
261  Cy = Cy1;
262  } else {
263  Cx = Cx2;
264  Cy = Cy2;
265  }
266  C.SetXYZ(Cx, Cy, 0);
267 
268 #ifdef mydebug_knuenz
269  std::cout << "Cx1" << Cx1 << std::endl;
270  std::cout << "Cx2" << Cx2 << std::endl;
271  std::cout << "Cy1" << Cy1 << std::endl;
272  std::cout << "Cy2" << Cy2 << std::endl;
273  std::cout << "Cx" << Cx << std::endl;
274  std::cout << "Cy" << Cy << std::endl;
275 #endif
276 
277  // Find Tangent at 0,0 to minPtCircle and point (Bx,By) on the first layer which bisects the allowed angle
278  k = -Cx / Cy;
279  d = 0;
280  double Bx1 = std::sqrt(Mx * Mx + My * My / (1 + k * k));
281  double Bx2 = -Bx1;
282  double By1 = k * Bx1 + d;
283  double By2 = k * Bx2 + d;
284 
285 #ifdef mydebug_knuenz
286  std::cout << "k" << k << std::endl;
287  std::cout << "d" << d << std::endl;
288 #endif
289 
290  // Decide between solutions: phi(B) < phi(P)
291  double Bx, By;
292  math::XYZVector B1(Bx1, By1, 0);
293  if (M1.x() * B1.y() - M1.y() * B1.x() < 0) {
294  Bx = Bx1;
295  By = By1;
296  } else {
297  Bx = Bx2;
298  By = By2;
299  }
300  B.SetXYZ(Bx, By, 0);
301 
302 #ifdef mydebug_knuenz
303  std::cout << "Bx1" << Bx1 << std::endl;
304  std::cout << "Bx2" << Bx2 << std::endl;
305  std::cout << "By1" << By1 << std::endl;
306  std::cout << "By2" << By2 << std::endl;
307  std::cout << "Bx" << Bx << std::endl;
308  std::cout << "By" << By << std::endl;
309 #endif
310 
311  double DeltaPhiMaxM1P1 = DeltaPhiManual(M1, B) * 2;
312 
313 #ifdef mydebug_knuenz
314  std::cout << "DeltaPhiMaxM1P1 " << DeltaPhiMaxM1P1 << std::endl;
315  std::cout << "M1.DeltaPhi(P1) " << DeltaPhiManual(M1, P1) << std::endl;
316  std::cout << "rho P1: " << std::sqrt(P1.x() * P1.x() + P1.y() * P1.y()) << "phi P1: " << P1.Phi() << std::endl;
317  std::cout << "rho M1: " << std::sqrt(M1.x() * M1.x() + M1.y() * M1.y()) << "phi M1: " << M1.Phi() << std::endl;
318 #endif
319 
320  //Finally Cut on DeltaPhi of P1 and M1
321 
322  double tol_DeltaPhiMaxM1P1 = DeltaPhiMaxM1P1 * toleranceFactorOnDeltaPhiCuts;
323  double DeltaPhiManualM1P1 = DeltaPhiManual(M1, P1);
324 
325  if (DeltaPhiManualM1P1 > DeltaPhiMaxM1P1 + tol_DeltaPhiMaxM1P1 || DeltaPhiManualM1P1 < 0 - tol_DeltaPhiMaxM1P1) {
326  return nullptr;
327  }
328 
329  } //if rMax > rLayerM1
330 
332  // Cleaning M2 points:::
334 
335  // if(B.DeltaPhi(P1)>0){//normal algo (with minPt circle)
336 
337  double rM2_squared = M2.x() * M2.x() + M2.y() * M2.y();
338  if (rMax_squared * 4. > rM2_squared) { //if minPt circle is smaller than 2*M2-layer radius, algo makes no sense
339 
340  //Chordales equation (line containing the two intersection points of the two circles)
341  double k = -C.x() / C.y();
342  double d = (rM2_squared - rMax_squared + C.x() * C.x() + C.y() * C.y()) / (2 * C.y());
343 
344  double M2solutionPart1 = -2 * k * d;
345  double M2solutionPart2 = std::sqrt(4 * k * k * d * d - 4 * (1 + k * k) * (d * d - rM2_squared));
346  double M2solutionPart3 = 2 + 2 * k * k;
347  double M2xMax1 = (M2solutionPart1 + M2solutionPart2) / M2solutionPart3;
348  double M2xMax2 = (M2solutionPart1 - M2solutionPart2) / M2solutionPart3;
349  double M2yMax1 = k * M2xMax1 + d;
350  double M2yMax2 = k * M2xMax2 + d;
351 
352  //double M2xMax,M2yMax;
353  math::XYZVector M2MaxVec1(M2xMax1, M2yMax1, 0);
354  math::XYZVector M2MaxVec2(M2xMax2, M2yMax2, 0);
355  math::XYZVector M2MaxVec(0, 0, 0);
356  if (M2MaxVec1.x() * M2MaxVec2.y() - M2MaxVec1.y() * M2MaxVec2.x() < 0) {
357  M2MaxVec.SetXYZ(M2xMax2, M2yMax2, 0);
358  } else {
359  M2MaxVec.SetXYZ(M2xMax1, M2yMax1, 0);
360  }
361 
362  double DeltaPhiMaxM2 = DeltaPhiManual(M2MaxVec, M1);
363 
364 #ifdef mydebug_knuenz
365  std::cout << "C.x() " << C.x() << std::endl;
366  std::cout << "C.y() " << C.y() << std::endl;
367  std::cout << "M1.x() " << M1.x() << std::endl;
368  std::cout << "M1.y() " << M1.y() << std::endl;
369  std::cout << "M2.x() " << M2.x() << std::endl;
370  std::cout << "M2.y() " << M2.y() << std::endl;
371  std::cout << "k " << k << std::endl;
372  std::cout << "d " << d << std::endl;
373  std::cout << "M2xMax1 " << M2xMax1 << std::endl;
374  std::cout << "M2xMax2 " << M2xMax2 << std::endl;
375  std::cout << "M2yMax1 " << M2yMax1 << std::endl;
376  std::cout << "M2yMax2 " << M2yMax2 << std::endl;
377  std::cout << "M2xMax " << M2MaxVec.x() << std::endl;
378  std::cout << "M2yMax " << M2MaxVec.y() << std::endl;
379  std::cout << "rM2_squared " << rM2_squared << std::endl;
380  std::cout << "rMax " << rMax << std::endl;
381  std::cout << "DeltaPhiMaxM2 " << DeltaPhiMaxM2 << std::endl;
382 #endif
383 
384  double tol_DeltaPhiMaxM2 = DeltaPhiMaxM2 * toleranceFactorOnDeltaPhiCuts;
385  double DeltaPhiManualM2M1 = DeltaPhiManual(M2, M1);
386 
387  if (DeltaPhiManualM2M1 > DeltaPhiMaxM2 + tol_DeltaPhiMaxM2 || DeltaPhiManualM2M1 < 0 - tol_DeltaPhiMaxM2) {
388  return nullptr;
389  }
390 
391  //Using the lazy solution for P2: DeltaPhiMaxP2=DeltaPhiMaxM2
392  double DeltaPhiManualP1P2 = DeltaPhiManual(P1, P2);
393  if (DeltaPhiManualP1P2 > DeltaPhiMaxM2 + tol_DeltaPhiMaxM2 || DeltaPhiManualP1P2 < 0 - tol_DeltaPhiMaxM2) {
394  return nullptr;
395  }
396  }
397  }
398 
399  // }
400 
401  // if(B.DeltaPhi(P1)<0){//different algo (without minPt circle)
402 
403  // }
404 
405  // End of pre-seed cleaning
406 
407  Conv4HitsReco2 quad(vPhotVertex, h1, h2, h3, h4);
408  quad.SetMaxNumberOfIterations(100);
409 #ifdef mydebug_sguazz
410  quad.Dump();
411 #endif
412  math::XYZVector candVtx;
413  double candPtPlus, candPtMinus;
414  //double rPlus, rMinus;
415  int nite = quad.ConversionCandidate(candVtx, candPtPlus, candPtMinus);
416 
417  if (!(nite && abs(nite) < 25 && nite != -1000 && nite != -2000))
418  return nullptr;
419 
420  // math::XYZVector plusCenter = quad.GetPlusCenter(rPlus);
421  // math::XYZVector minusCenter = quad.GetMinusCenter(rMinus);
422 
423 #ifdef mydebug_sguazz
424  std::cout << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
425  << "\n";
426  std::cout << " >>>>>>>>>>> Conv Cand: "
427  << " Vertex X: " << candVtx.X() << " [cm] Y: " << candVtx.Y() << " [cm] pt+: " << candPtPlus
428  << " [GeV] pt-: " << candPtMinus << " [GeV]; #its: " << nite << "\n";
429 #endif
430 
431  //Add here cuts
432  double minLegPt = CleaningMinLegPt;
433  double maxRadialDistance = CleaningmaxRadialDistance;
434 
435  //
436  // Cut on leg's transverse momenta
437  if (candPtPlus < minLegPt)
438  return nullptr;
439  if (candPtMinus < minLegPt)
440  return nullptr;
441  //
442  if (candPtPlus > maxLegPt)
443  return nullptr;
444  if (candPtMinus > maxLegPt)
445  return nullptr;
446  //
447  // Cut on radial distance between estimated conversion vertex and inner hits
448  double cr = std::sqrt(candVtx.Perp2());
449  double maxr2 = (maxRadialDistance + cr);
450  maxr2 *= maxr2;
451  if (h2.Perp2() > maxr2)
452  return nullptr;
453  if (h3.Perp2() > maxr2)
454  return nullptr;
455 
456  // At this point implement cleaning cuts after building the seed
457 
458  //ClusterShapeFilter_knuenz:::
459  const auto& bfield = es.getData(theBfieldToken);
460  float nomField = bfield.nominalValue();
461 
462  if (ClusterShapeFiltering) {
463  if (theComparitor)
464  theComparitor->init(ev, es);
465 
468 
469  // SeedingHitSet::ConstRecHitPointer ptth1 = phits[0]; // (never used???)
471  SeedingHitSet::ConstRecHitPointer mtth1 = mhits[0];
472  SeedingHitSet::ConstRecHitPointer mtth2 = mhits[1];
473 
474  GlobalPoint vertexPos(candVtx.x(), candVtx.y(), candVtx.z());
475 
476  float ptMinReg = 0.1;
477  GlobalTrackingRegion region(ptMinReg, vertexPos, 0, 0, true);
478 
479  FastHelix phelix(ptth2->globalPosition(), mtth1->globalPosition(), vertexPos, nomField, &bfield, vertexPos);
480  pkine = phelix.stateAtVertex();
481  FastHelix mhelix(mtth2->globalPosition(), mtth1->globalPosition(), vertexPos, nomField, &bfield, vertexPos);
482  mkine = mhelix.stateAtVertex();
483 
484  if (theComparitor && !theComparitor->compatible(phits, pkine, phelix)) {
485  return nullptr;
486  }
487  if (theComparitor && !theComparitor->compatible(mhits, mkine, mhelix)) {
488  return nullptr;
489  }
490  }
491 
492  //Do a very simple fit to estimate the slope
493  double quadPhotCotTheta = 0.;
494  double quadZ0 = 0.;
495  simpleGetSlope(ptth2, ptth1, mtth1, mtth2, region, quadPhotCotTheta, quadZ0);
496 
497  double quadPhotPhi = (candVtx - vPhotVertex).Phi();
498 
499  math::XYZVector fittedPrimaryVertex(vgPhotVertex.x(), vgPhotVertex.y(), quadZ0);
500 
501  candVtx.SetZ(std::sqrt(candVtx.Perp2()) * quadPhotCotTheta + quadZ0);
502  GlobalPoint convVtxGlobalPoint(candVtx.X(), candVtx.Y(), candVtx.Z());
503 
504  //
505  // Comparing new quad with old quad
506  //
507  //Arbitration
508 
509  Quad thisQuad;
510  thisQuad.x = candVtx.X();
511  thisQuad.y = candVtx.Y();
512  thisQuad.z = candVtx.Z();
513  thisQuad.ptPlus = candPtPlus;
514  thisQuad.ptMinus = candPtMinus;
515  thisQuad.cot = quadPhotCotTheta;
516  if (similarQuadExist(thisQuad, quadV) && applyArbitration)
517  return nullptr;
518 
519  // not able to get the mag field... doing the dirty way
520  //
521  // Plus
522  FastHelix helixPlus(
523  ptth2->globalPosition(), ptth1->globalPosition(), convVtxGlobalPoint, nomField, &bfield, convVtxGlobalPoint);
524  GlobalTrajectoryParameters kinePlus = helixPlus.stateAtVertex();
525  kinePlus = GlobalTrajectoryParameters(
526  convVtxGlobalPoint,
527  GlobalVector(candPtPlus * cos(quadPhotPhi), candPtPlus * sin(quadPhotPhi), candPtPlus * quadPhotCotTheta),
528  1, //1
529  &kinePlus.magneticField());
530 
531  //
532  // Minus
533  FastHelix helixMinus(
534  mtth2->globalPosition(), mtth1->globalPosition(), convVtxGlobalPoint, nomField, &bfield, convVtxGlobalPoint);
535  GlobalTrajectoryParameters kineMinus = helixMinus.stateAtVertex();
536  kineMinus = GlobalTrajectoryParameters(
537  convVtxGlobalPoint,
538  GlobalVector(candPtMinus * cos(quadPhotPhi), candPtMinus * sin(quadPhotPhi), candPtMinus * quadPhotCotTheta),
539  -1, //-1
540  &kineMinus.magneticField());
541 
542  float sinThetaPlus = sin(kinePlus.momentum().theta());
543  float sinThetaMinus = sin(kineMinus.momentum().theta());
544  float ptmin = region.ptMin();
545  //vertexBounds da region
546  GlobalVector vertexBounds(region.originRBound(), region.originRBound(), region.originZBound());
547 
548  CurvilinearTrajectoryError errorPlus = initialError(vertexBounds, ptmin, sinThetaPlus);
549  CurvilinearTrajectoryError errorMinus = initialError(vertexBounds, ptmin, sinThetaMinus);
550  FreeTrajectoryState ftsPlus(kinePlus, errorPlus);
551  FreeTrajectoryState ftsMinus(kineMinus, errorMinus);
552 
553  //FIXME: here probably you want to go in parallel with phits and mhits
554  //NB: the seedCollection is filled (the important thing) the return of the last TrajectorySeed is not used, but is needed
555  //to maintain the inheritance
556 
557 #ifdef quadDispLine
558  double vError = region.originZBound();
559  if (vError > 15.)
560  vError = 1.;
561  std::cout << "QuadDispLine " << vgPhotVertex.x() << " " << vgPhotVertex.y() << " " << vgPhotVertex.z() << " "
562  << vError << " " << vHit[0].x() << " " << vHit[0].y() << " " << vHit[0].z() << " "
563  << sqrt(getSqrEffectiveErrorOnZ(ptth2, region)) << " " << vHit[1].x() << " " << vHit[1].y() << " "
564  << vHit[1].z() << " " << sqrt(getSqrEffectiveErrorOnZ(ptth1, region)) << " " << vHit[2].x() << " "
565  << vHit[2].y() << " " << vHit[2].z() << " " << sqrt(getSqrEffectiveErrorOnZ(mtth1, region)) << " "
566  << vHit[3].x() << " " << vHit[3].y() << " " << vHit[3].z() << " "
567  << sqrt(getSqrEffectiveErrorOnZ(mtth2, region)) << " " << candVtx.X() << " " << candVtx.Y() << " "
568  << candVtx.Z() << " " << fittedPrimaryVertex.X() << " " << fittedPrimaryVertex.Y() << " "
569  << fittedPrimaryVertex.Z()
570  << " "
571  // << candPtPlus << " " << rPlus << " " << plusCenter.X() << " " << plusCenter.Y() << " "
572  // << candPtMinus << " " << rMinus << " " << minusCenter.X() << " " << minusCenter.Y() << " "
573  << nite << " " << chi2 << "\n";
574 #endif
575 #ifdef mydebug_sguazz
576  std::cout << " >>>>> Hit quad fast reco done >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
577  << "\n";
578  uint32_t detid;
579  std::cout << "[SeedForPhotonConversionFromQuadruplets]\n ptth1 ";
580  detid = ptth1->geographicalId().rawId();
581  // po.print(std::cout , detid );
582  std::cout << " \t " << detid << " " << ptth1->localPosition() << " " << ptth1->globalPosition();
583  detid = ptth2->geographicalId().rawId();
584  std::cout << " \n\t ptth2 ";
585  // po.print(std::cout , detid );
586  std::cout << " \t " << detid << " " << ptth2->localPosition() << " " << ptth2->globalPosition() << "\nhelix momentum "
587  << kinePlus.momentum() << " pt " << kinePlus.momentum().perp() << " radius "
588  << 1 / kinePlus.transverseCurvature() << " q " << kinePlus.charge();
589  std::cout << " \n\t mtth1 ";
590  detid = mtth1->geographicalId().rawId();
591  std::cout << " \t " << detid << " " << mtth1->localPosition() << " " << mtth1->globalPosition();
592  std::cout << " \n\t mtth2 ";
593  detid = mtth2->geographicalId().rawId();
594  // po.print(std::cout , detid );
595  std::cout << " \t " << detid << " " << mtth2->localPosition() << " " << mtth2->globalPosition() << "\nhelix momentum "
596  << kineMinus.momentum() << " pt " << kineMinus.momentum().perp() << " radius "
597  << 1 / kineMinus.transverseCurvature() << " q " << kineMinus.charge();
598  std::cout << "\n <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
599  << "\n";
600 #endif
601 
602  // get cloner
603  auto builder = static_cast<TkTransientTrackingRecHitBuilder const*>(&es.getData(theTTRHBuilderToken));
604  cloner = (*builder).cloner();
605 
606  bool buildSeedBoolPos = buildSeedBool(seedCollection, phits, ftsPlus, es, applydzCAcut, region, dzcut);
607  bool buildSeedBoolNeg = buildSeedBool(seedCollection, mhits, ftsMinus, es, applydzCAcut, region, dzcut);
608 
609  if (buildSeedBoolPos && buildSeedBoolNeg) {
610  buildSeed(seedCollection, phits, ftsPlus, es, false, region);
611  buildSeed(seedCollection, mhits, ftsMinus, es, false, region);
612  }
613 
614  return nullptr;
615 }
bool buildSeedBool(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts, const edm::EventSetup &es, bool apply_dzCut, const TrackingRegion &region, double dzcut) const
CurvilinearTrajectoryError initialError(const GlobalVector &vertexBounds, float ptMin, float sinTheta) const
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:25
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
Definition: APVGainStruct.h:7
double DeltaPhiManual(const math::XYZVector &v1, const math::XYZVector &v2)
T z() const
Definition: PV3DBase.h:61
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theBfieldToken
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
double simpleGetSlope(const SeedingHitSet::ConstRecHitPointer &ohit, const SeedingHitSet::ConstRecHitPointer &nohit, const SeedingHitSet::ConstRecHitPointer &ihit, const SeedingHitSet::ConstRecHitPointer &nihit, const TrackingRegion &region, double &cotTheta, double &z0)
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:14
const TrajectorySeed * buildSeed(TrajectorySeedCollection &seedCollection, const SeedingHitSet &hits, const FreeTrajectoryState &fts, const edm::EventSetup &es, bool apply_dzCut, const TrackingRegion &region) const
TupleMultiplicity< TrackerTraits > const *__restrict__ TrackingRecHitSoAConstView< TrackerTraits > TrackerTraits::tindex_type *__restrict__ double *__restrict__ phits
double x
Definition: Quad.h:5
T sqrt(T t)
Definition: SSEVec.h:23
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
unsigned int size() const
Definition: SeedingHitSet.h:52
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double ptmin
Definition: HydjetWrapper.h:86
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > theTTRHBuilderToken
double getSqrEffectiveErrorOnZ(const SeedingHitSet::ConstRecHitPointer &hit, const TrackingRegion &region)
bool similarQuadExist(Quad &thisQuad, std::vector< Quad > &quadV)
Definition: Quad.h:4
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ verySimpleFit()

double SeedForPhotonConversionFromQuadruplets::verySimpleFit ( int  size,
double *  ax,
double *  ay,
double *  e2y,
double &  p0,
double &  e2p0,
double &  p1 
)

Definition at line 1014 of file SeedForPhotonConversionFromQuadruplets.cc.

Referenced by simpleGetSlope().

1015  {
1016  //#include "verySimpleFit.icc"
1017  return 0;
1018 }

Member Data Documentation

◆ cloner

TkClonerImpl SeedForPhotonConversionFromQuadruplets::cloner
protected

Definition at line 114 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by refitHit(), and trajectorySeed().

◆ cotTheta_Max

const int SeedForPhotonConversionFromQuadruplets::cotTheta_Max = 99999
static

Definition at line 24 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by initialKinematic().

◆ kPI_

double SeedForPhotonConversionFromQuadruplets::kPI_
protected

Definition at line 111 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by DeltaPhiManual(), and trajectorySeed().

◆ po

PrintRecoObjects SeedForPhotonConversionFromQuadruplets::po
protected

Definition at line 117 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by buildSeed(), and initialKinematic().

◆ pss

std::stringstream* SeedForPhotonConversionFromQuadruplets::pss
protected

Definition at line 116 of file SeedForPhotonConversionFromQuadruplets.h.

◆ theBfieldToken

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> SeedForPhotonConversionFromQuadruplets::theBfieldToken
protected

◆ theBOFFMomentum

double SeedForPhotonConversionFromQuadruplets::theBOFFMomentum
protected

Definition at line 110 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by initialKinematic().

◆ theComparitor

std::unique_ptr<SeedComparitor> SeedForPhotonConversionFromQuadruplets::theComparitor
protected

◆ thePropagatorToken

edm::ESGetToken<Propagator, TrackingComponentsRecord> SeedForPhotonConversionFromQuadruplets::thePropagatorToken
protected

Definition at line 109 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by buildSeed(), and buildSeedBool().

◆ theTrackerToken

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> SeedForPhotonConversionFromQuadruplets::theTrackerToken
protected

Definition at line 108 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by buildSeed(), and buildSeedBool().

◆ theTTRHBuilderToken

edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> SeedForPhotonConversionFromQuadruplets::theTTRHBuilderToken
protected

Definition at line 107 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by trajectorySeed().