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
 
double theBOFFMomentum
 
std::unique_ptr< SeedComparitortheComparitor
 
std::string thePropagatorLabel
 

Detailed Description

Definition at line 20 of file SeedForPhotonConversionFromQuadruplets.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file SeedForPhotonConversionFromQuadruplets.cc.

37  :
39  SeedComparitorPSet,
40  cfg.getParameter<std::string>("propagator"),
41  cfg.existsAs<double>("SeedMomentumForBOFF") ? cfg.getParameter<double>("SeedMomentumForBOFF") : 5.0)
42 {}
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
SeedForPhotonConversionFromQuadruplets(const edm::ParameterSet &cfg, edm::ConsumesCollector &iC, const edm::ParameterSet &SeedComparitorPSet)
SeedForPhotonConversionFromQuadruplets::SeedForPhotonConversionFromQuadruplets ( edm::ConsumesCollector iC,
const edm::ParameterSet SeedComparitorPSet,
const std::string &  propagator = "PropagatorWithMaterial",
double  seedMomentumForBOFF = -5.0 
)

Definition at line 44 of file SeedForPhotonConversionFromQuadruplets.cc.

References beamerCreator::create(), reco::get(), edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, and theComparitor.

45  : thePropagatorLabel(propagator), theBOFFMomentum(seedMomentumForBOFF)
46 {
47  std::string comparitorName = SeedComparitorPSet.getParameter<std::string>("ComponentName");
48  if(comparitorName != "none") {
49  theComparitor.reset(SeedComparitorFactory::get()->create( comparitorName, SeedComparitorPSet, iC));
50  }
51 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
T get(const Candidate &c)
Definition: component.h:55
SeedForPhotonConversionFromQuadruplets::~SeedForPhotonConversionFromQuadruplets ( )

Definition at line 53 of file SeedForPhotonConversionFromQuadruplets.cc.

53 {}

Member Function Documentation

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

Definition at line 983 of file SeedForPhotonConversionFromQuadruplets.cc.

References barePhi(), reco::deltaPhi(), mps_fire::i, simpleGetSlope(), and tmp.

Referenced by bubbleSortVsPhi().

983  {
984  bool swapped = true;
985  int j = 0;
987  while (swapped) {
988  swapped = false;
989  j++;
990  for (int i = 0; i < n - j; i++) {
991  if ( reco::deltaPhi( (arr[i]-vtx).barePhi(), (arr[i + 1]-vtx).barePhi() ) < 0. ) {
992  tmp = arr[i];
993  arr[i] = arr[i + 1];
994  arr[i + 1] = tmp;
995  swapped = true;
996  }
997  }
998  }
999 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
T barePhi() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void SeedForPhotonConversionFromQuadruplets::bubbleSortVsPhi ( GlobalPoint  arr[],
int  n,
GlobalPoint  vtx 
)

Definition at line 964 of file SeedForPhotonConversionFromQuadruplets.cc.

References barePhi(), bubbleReverseSortVsPhi(), reco::deltaPhi(), mps_fire::i, and tmp.

Referenced by stupidPrint().

964  {
965  bool swapped = true;
966  int j = 0;
968  while (swapped) {
969  swapped = false;
970  j++;
971  for (int i = 0; i < n - j; i++) {
972  if ( reco::deltaPhi( (arr[i]-vtx).barePhi(), (arr[i + 1]-vtx).barePhi() ) > 0. ) {
973  tmp = arr[i];
974  arr[i] = arr[i + 1];
975  arr[i + 1] = tmp;
976  swapped = true;
977  }
978  }
979  }
980 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
T barePhi() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
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 695 of file SeedForPhotonConversionFromQuadruplets.cc.

References alongMomentum, TrackingRecHit::geographicalId(), edm::EventSetup::get(), TrajectoryStateOnSurface::globalMomentum(), TrackerGeometry::idToDet(), BaseTrackerRecHit::localPosition(), TrackingRecHit::localPosition(), PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), po, PrintRecoObjects::print(), Propagator::propagate(), PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::propagator, edm::OwnVector< T, P >::push_back(), DetId::rawId(), refitHit(), SeedingHitSet::size(), thePropagatorLabel, trackingTruthProducer_cfi::tracker, KFUpdator::update(), TrackInfoProducer_cfi::updatedState, and gsfElectronCkfTrackCandidateMaker_cff::updator.

Referenced by trajectorySeed().

702 {
703  // get tracker
705  es.get<TrackerDigiGeometryRecord>().get(tracker);
706 
707  // get propagator
708  edm::ESHandle<Propagator> propagatorHandle;
709  es.get<TrackingComponentsRecord>().get(thePropagatorLabel, propagatorHandle);
710  const Propagator* propagator = &(*propagatorHandle);
711 
712  // get updator
714 
715  // Now update initial state track using information from seed hits.
716 
719 
720  const TrackingRecHit* hit = nullptr;
721  for ( unsigned int iHit = 0; iHit < hits.size() && iHit<2; iHit++) {
722  hit = hits[iHit];
723  TrajectoryStateOnSurface state = (iHit==0) ?
724  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
725  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
726 
727  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
728 
729  SeedingHitSet::RecHitPointer newtth = refitHit( tth, state);
730 
731  updatedState = updator.update(state, *newtth);
732 
733  seedHits.push_back(newtth);
734 #ifdef mydebug_seed
735  uint32_t detid = hit->geographicalId().rawId();
736  (*pss) << "\n[SeedForPhotonConversionFromQuadruplets] hit " << iHit;
737  po.print(*pss, detid);
738  (*pss) << " " << detid << "\t lp " << hit->localPosition()
739  << " tth " << tth->localPosition() << " newtth " << newtth->localPosition() << " state " << state.globalMomentum().perp();
740 #endif
741  }
742 
743  if(!hit) return nullptr;
744 
745  PTrajectoryStateOnDet const & PTraj =
747 
748 
749  seedCollection.push_back( TrajectorySeed(PTraj,seedHits,alongMomentum));
750  return &seedCollection.back();
751 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
T perp() const
Definition: PV3DBase.h:72
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
void push_back(D *&d)
Definition: OwnVector.h:290
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:169
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
void print(std::stringstream &ss, const SiStripCluster &clus)
virtual LocalPoint localPosition() const =0
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
GlobalVector globalMomentum() const
T get() const
Definition: EventSetup.h:63
unsigned int size() const
Definition: SeedingHitSet.h:46
const TrackerGeomDet * idToDet(DetId) const override
LocalPoint localPosition() const final
DetId geographicalId() const
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
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 757 of file SeedForPhotonConversionFromQuadruplets.cc.

References checkHit(), TrackingRecHit::clone(), gather_cfg::cout, MillePedeFileConverter_cfg::e, TrackingRecHit::geographicalId(), edm::EventSetup::get(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), BaseTrackerRecHit::hit(), mps_fire::i, TrackerGeometry::idToDet(), TrajectoryStateClosestToBeamLine::isValid(), TrajectoryStateOnSurface::isValid(), TrackingRegion::origin(), FreeTrajectoryState::position(), Propagator::propagate(), PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::propagator, edm::OwnVector< T, P >::push_back(), refitHit(), SeedingHitSet::size(), mathSSE::sqrt(), thePropagatorLabel, trackingTruthProducer_cfi::tracker, TrajectoryStateClosestToBeamLine::trackStateAtPCA(), reco::BeamSpot::Unknown, KFUpdator::update(), TrackInfoProducer_cfi::updatedState, gsfElectronCkfTrackCandidateMaker_cff::updator, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by trajectorySeed().

765 {
766  // get tracker
768  es.get<TrackerDigiGeometryRecord>().get(tracker);
769 
770  // get propagator
771  edm::ESHandle<Propagator> propagatorHandle;
772  es.get<TrackingComponentsRecord>().get(thePropagatorLabel, propagatorHandle);
773  const Propagator* propagator = &(*propagatorHandle);
774 
775  // get updator
777 
778  // Now update initial state track using information from seed hits.
779 
782 
783  const TrackingRecHit* hit = nullptr;
784  for ( unsigned int iHit = 0; iHit < hits.size() && iHit<2; iHit++) {
785  hit = hits[iHit]->hit();
786  TrajectoryStateOnSurface state = (iHit==0) ?
787  propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface())
788  : propagator->propagate(updatedState, tracker->idToDet(hit->geographicalId())->surface());
789  if (!state.isValid()) {
790  return false;}
791 
792  SeedingHitSet::ConstRecHitPointer tth = hits[iHit];
793 
794  SeedingHitSet::RecHitPointer newtth = refitHit( tth, state);
795 
796 
797  if (!checkHit(state,newtth,es)){
798  return false;
799  }
800 
801  updatedState = updator.update(state, *newtth);
802  if (!updatedState.isValid()){
803  return false;
804  }
805 
806  seedHits.push_back(newtth->hit()->clone());
807  }
808 
809  if(apply_dzCut){
811 
812  double zCA;
813 
814  math::XYZVector EstMomGam(updatedState.globalMomentum().x(),updatedState.globalMomentum().y(),updatedState.globalMomentum().z());
815  math::XYZVector EstPosGam(updatedState.globalPosition().x(),updatedState.globalPosition().y(),updatedState.globalPosition().z());
816 
817  double EstMomGamLength=std::sqrt(EstMomGam.x()*EstMomGam.x()+EstMomGam.y()*EstMomGam.y()+EstMomGam.z()*EstMomGam.z());
818  math::XYZVector EstMomGamNorm(EstMomGam.x()/EstMomGamLength,EstMomGam.y()/EstMomGamLength,EstMomGam.z()/EstMomGamLength);
819 
820  //Calculate dz of point of closest approach of the two lines (WA approach) -> cut on dz
821 
822 
823  const GlobalPoint EstPosGamGlobalPoint(updatedState.globalPosition().x(),updatedState.globalPosition().y(),updatedState.globalPosition().z());
824  const GlobalVector EstMomGamGlobalVector(updatedState.globalMomentum().x(),updatedState.globalMomentum().y(),updatedState.globalMomentum().z());
825 
826 
828  es.get<IdealMagneticFieldRecord>().get(bfield);
829  const MagneticField* magField = bfield.product();
830  TrackCharge qCharge = 0;
831 
832  const GlobalTrajectoryParameters myGlobalTrajectoryParameter(EstPosGamGlobalPoint, EstMomGamGlobalVector, qCharge, magField);
833 
834  AlgebraicSymMatrix66 aCovarianceMatrix;
835 
836  for (int i =0;i<6;++i)
837  for (int j =0;j<6;++j)
838  aCovarianceMatrix(i, j) = 1e-4;
839 
840  CartesianTrajectoryError myCartesianError (aCovarianceMatrix);
841 
842  const FreeTrajectoryState stateForProjectionToBeamLine(myGlobalTrajectoryParameter,myCartesianError);
843 
844  const GlobalPoint BeamSpotGlobalPoint(0,0,0);
845 
846  const reco::BeamSpot::Point BeamSpotPoint(region.origin().x(),region.origin().y(),region.origin().z());
847 
848  TSCBLBuilderNoMaterial tscblBuilder;
849 
850  double CovMatEntry=0.;
852  for (int i=0;i<3;++i) {
853  cov(i,i) = CovMatEntry;
854  }
856 
857  reco::BeamSpot myBeamSpot(BeamSpotPoint, 0.,0.,0.,0., cov,BeamType_);
858 
859  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(stateForProjectionToBeamLine,myBeamSpot);
860  if (tscbl.isValid()==false) {
861  zCA=0;
862  }
863  else{
864  GlobalPoint v = tscbl.trackStateAtPCA().position(); // Position of closest approach to BS
865  zCA=v.z();
866  }
867 
868 /* //Calculate dz of point of closest approach of the two lines -> cut on dz
869 
870  double newX,newY,newR;
871  double Rbuff=std::sqrt(EstPosGam.x()*EstPosGam.x()+EstPosGam.y()*EstPosGam.y());
872  double deltas,s,sbuff;
873  double rMin=1e9;
874 
875  double InitXp=EstPosGam.x()+1*EstMomGamNorm.x();
876  double InitXm=EstPosGam.x()-1*EstMomGamNorm.x();
877  double InitYp=EstPosGam.y()+1*EstMomGamNorm.y();
878  double InitYm=EstPosGam.y()-1*EstMomGamNorm.y();
879 
880  if(InitXp*InitXp+InitYp*InitYp < InitXm*InitXm+InitYm*InitYm) {s=5; deltas=5;}
881  else {s=-5; deltas=-5;}
882 
883  int nTurns=0;
884  int nIterZ=0;
885  for (int i_dz=0;i_dz<1000;i_dz++){
886  newX=EstPosGam.x()+s*EstMomGamNorm.x();
887  newY=EstPosGam.y()+s*EstMomGamNorm.y();
888  newR=std::sqrt(newX*newX+newY*newY);
889  if(newR>Rbuff) {deltas=-1*deltas/10;nTurns++;}
890  else {Rbuff=newR;}
891  if(newR<rMin) {rMin=newR; sbuff=s;}
892  s=s+deltas;
893  nIterZ++;
894  if(nTurns>1) break;
895  }
896 
897  zCA=EstPosGam.z()+sbuff*EstMomGamNorm.z();
898 */
899 
900 #ifdef mydebug_knuenz
901  std::cout<< "zCA: " << zCA <<std::endl;
902 #endif
903 
904  if(std::fabs(zCA)>dzcut) return false;
905 
906 
907  }
908 
909 
910  return true;
911 }
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:31
BeamType
beam spot flags
Definition: BeamSpot.h:26
GlobalPoint const & origin() const
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
int TrackCharge
Definition: TrackCharge.h:4
void push_back(D *&d)
Definition: OwnVector.h:290
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:169
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
T sqrt(T t)
Definition: SSEVec.h:18
BaseTrackerRecHit const * hit() const final
T z() const
Definition: PV3DBase.h:64
virtual TrackingRecHit * clone() const =0
bool checkHit(const TrajectoryStateOnSurface &, const SeedingHitSet::ConstRecHitPointer &hit, const edm::EventSetup &es) const
GlobalPoint position() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
GlobalVector globalMomentum() const
T get() const
Definition: EventSetup.h:63
unsigned int size() const
Definition: SeedingHitSet.h:46
const TrackerGeomDet * idToDet(DetId) const override
DetId geographicalId() const
SeedingHitSet::RecHitPointer refitHit(SeedingHitSet::ConstRecHitPointer hit, const TrajectoryStateOnSurface &state) const
T x() const
Definition: PV3DBase.h:62
bool SeedForPhotonConversionFromQuadruplets::checkHit ( const TrajectoryStateOnSurface ,
const SeedingHitSet::ConstRecHitPointer hit,
const edm::EventSetup es 
) const
inlineprotected

Definition at line 62 of file SeedForPhotonConversionFromQuadruplets.h.

References hfClusterShapes_cfi::hits, and ptMin.

Referenced by buildSeedBool().

65  { return true; }
double SeedForPhotonConversionFromQuadruplets::DeltaPhiManual ( const math::XYZVector v1,
const math::XYZVector v2 
)
protected

Definition at line 1094 of file SeedForPhotonConversionFromQuadruplets.cc.

References kPI_.

Referenced by trajectorySeed().

1094  {
1095 
1096  double kTWOPI = 2.*kPI_;
1097  double DeltaPhiMan=v1.Phi()-v2.Phi();
1098  while (DeltaPhiMan >= kPI_) DeltaPhiMan -= kTWOPI;
1099  while (DeltaPhiMan < -kPI_) DeltaPhiMan += kTWOPI;
1100 
1101  return DeltaPhiMan;
1102 
1103 }
double SeedForPhotonConversionFromQuadruplets::getSqrEffectiveErrorOnZ ( const SeedingHitSet::ConstRecHitPointer hit,
const TrackingRegion region 
)

Definition at line 1046 of file SeedForPhotonConversionFromQuadruplets.cc.

References TrackingRegion::origin(), PV3DBase< T, PVType, FrameType >::perp(), sqr(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by simpleGetSlope(), and trajectorySeed().

1046  {
1047 
1048  //
1049  //Fit-wise the effective error on Z is the sum in quadrature of the error on Z
1050  //and the error on R correctly projected by using hit-vertex direction
1051 
1052  double sqrProjFactor = sqr((hit->globalPosition().z()-region.origin().z())/(hit->globalPosition().perp()-region.origin().perp()));
1053  return (hit->globalPositionError().czz()+sqrProjFactor*hit->globalPositionError().rerr(hit->globalPosition()));
1054 
1055 }
T perp() const
Definition: PV3DBase.h:72
GlobalPoint const & origin() const
T z() const
Definition: PV3DBase.h:64
CurvilinearTrajectoryError SeedForPhotonConversionFromQuadruplets::initialError ( const GlobalVector vertexBounds,
float  ptMin,
float  sinTheta 
) const
protected

Definition at line 666 of file SeedForPhotonConversionFromQuadruplets.cc.

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

Referenced by initialKinematic(), and trajectorySeed().

670 {
671  // Set initial uncertainty on track parameters, using only P.V. constraint and no hit
672  // information.
673  GlobalError vertexErr( sqr(vertexBounds.x()), 0,
674  sqr(vertexBounds.y()), 0, 0,
675  sqr(vertexBounds.z())
676  );
677 
678 
679  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
680 
681 // FIXME: minC00. Prevent apriori uncertainty in 1/P from being too small,
682 // to avoid instabilities.
683 // N.B. This parameter needs optimising ...
684  float sin2th = sqr(sinTheta);
685  float minC00 = 1.0;
686  C[0][0] = std::max(sin2th/sqr(ptMin), minC00);
687  float zErr = vertexErr.czz();
688  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
689  C[3][3] = transverseErr;
690  C[4][4] = zErr*sin2th + transverseErr*(1-sin2th);
691 
692  return CurvilinearTrajectoryError(C);
693 }
T y() const
Definition: PV3DBase.h:63
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
T z() const
Definition: PV3DBase.h:64
T x() const
Definition: PV3DBase.h:62
GlobalTrajectoryParameters SeedForPhotonConversionFromQuadruplets::initialKinematic ( const SeedingHitSet hits,
const GlobalPoint vertexPos,
const edm::EventSetup es,
const float  cotTheta 
) const
protected

Definition at line 607 of file SeedForPhotonConversionFromQuadruplets.cc.

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

612 {
614 
615  SeedingHitSet::ConstRecHitPointer tth1 = hits[0];
616  SeedingHitSet::ConstRecHitPointer tth2 = hits[1];
617 
619  es.get<IdealMagneticFieldRecord>().get(bfield);
620  float nomField = bfield->nominalValue();
621  bool isBOFF = (0==nomField);
622 
623 
624  FastHelix helix(tth2->globalPosition(), tth1->globalPosition(), vertexPos, nomField,&*bfield, vertexPos);
625  kine = helix.stateAtVertex();
626 
627  //force the pz/pt equal to the measured one
628  if(fabs(cotTheta)<cotTheta_Max)
629  kine = GlobalTrajectoryParameters(kine.position(),
630  GlobalVector(kine.momentum().x(),kine.momentum().y(),kine.momentum().perp()*cotTheta),
631  kine.charge(),
632  & kine.magneticField()
633  );
634  else
635  kine = GlobalTrajectoryParameters(kine.position(),
636  GlobalVector(kine.momentum().x(),kine.momentum().y(),kine.momentum().perp()*cotTheta_Max),
637  kine.charge(),
638  & kine.magneticField()
639  );
640 
641 #ifdef mydebug_seed
642  uint32_t detid;
643  (*pss) << "[SeedForPhotonConversionFromQuadruplets] initialKinematic tth1 " ;
644  detid=tth1->geographicalId().rawId();
645  po.print(*pss, detid );
646  (*pss) << " \t " << detid << " " << tth1->localPosition() << " " << tth1->globalPosition() ;
647  detid= tth2->geographicalId().rawId();
648  (*pss) << " \n\t tth2 ";
649  po.print(*pss, detid );
650  (*pss) << " \t " << detid << " " << tth2->localPosition() << " " << tth2->globalPosition()
651  << "\nhelix momentum " << kine.momentum() << " pt " << kine.momentum().perp() << " radius " << 1/kine.transverseCurvature();
652 #endif
653 
654  if (isBOFF && (theBOFFMomentum > 0)) {
655  kine = GlobalTrajectoryParameters(kine.position(),
656  kine.momentum().unit() * theBOFFMomentum,
657  kine.charge(),
658  &*bfield);
659  }
660  return kine;
661 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
T perp() const
Definition: PV3DBase.h:72
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:58
T y() const
Definition: PV3DBase.h:63
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
void print(std::stringstream &ss, const SiStripCluster &clus)
Vector3DBase unit() const
Definition: Vector3DBase.h:57
T get() const
Definition: EventSetup.h:63
const MagneticField & magneticField() const
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10
SeedingHitSet::RecHitPointer SeedForPhotonConversionFromQuadruplets::refitHit ( SeedingHitSet::ConstRecHitPointer  hit,
const TrajectoryStateOnSurface state 
) const
protected

Definition at line 915 of file SeedForPhotonConversionFromQuadruplets.cc.

References cloner, and stupidPrint().

Referenced by buildSeed(), and buildSeedBool().

918 {
919  //const TransientTrackingRecHit* a= hit.get();
920  //return const_cast<TransientTrackingRecHit*> (a);
921  //This was modified otherwise the rechit will have just the local x component and local y=0
922  // To understand how to modify for pixels
923 
924  //const TSiStripRecHit2DLocalPos* b = dynamic_cast<const TSiStripRecHit2DLocalPos*>(a);
925  //return const_cast<TSiStripRecHit2DLocalPos*>(b);
926  return (SeedingHitSet::RecHitPointer)(cloner(*hit,state));
927 }
bool SeedForPhotonConversionFromQuadruplets::similarQuadExist ( Quad thisQuad,
std::vector< Quad > &  quadV 
)
protected

Definition at line 1057 of file SeedForPhotonConversionFromQuadruplets.cc.

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

Referenced by trajectorySeed().

1057  {
1058 
1059  BOOST_FOREACH( Quad quad, quadV )
1060  {
1061  double dx = thisQuad.x-quad.x;
1062  double dy = thisQuad.y-quad.y;
1063  //double dz = abs(thisQuad.z-quad.z);
1064  //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
1065  //std::cout<<"x1-x2="<<dx<<"y1-y2="<<dy<<"dx*dx+dy*dy="<<dx*dx+dy*dy<<std::endl; //ValDebug
1066  //std::cout<<"thisQuad.ptPlus-quad.ptPlus="<<thisQuad.ptPlus-quad.ptPlus<<"abs(thisQuad.ptPlus-quad.ptPlus)="<<abs(thisQuad.ptPlus-quad.ptPlus)<<std::endl; //ValDebug
1067  //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
1068  //if ( sqrt(dx*dx+dy*dy)<1.)
1069  // 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
1070  // ( sqrt(dx*dx+dy*dy)<1. &&
1071  //z<3. &&
1072  //bs(thisQuad.ptPlus-quad.ptPlus)<0.5*quad.ptPlus &&
1073  //bs(thisQuad.ptMinus-quad.ptMinus)<0.5*quad.ptMinus &&
1074  //bs(thisQuad.cot-quad.cot)<0.3*quad.cot
1075  //
1076  // {
1077  // //std::cout<<"Seed rejected due to arbitration"<<std::endl;
1078  // return true;
1079  // }
1080  if ( sqrt(dx*dx+dy*dy)<1. &&
1081  fabs(thisQuad.ptPlus-quad.ptPlus)<0.5*quad.ptPlus &&
1082  fabs(thisQuad.ptMinus-quad.ptMinus)<0.5*quad.ptMinus
1083  )
1084  {
1085  //std::cout<<"Seed rejected due to arbitration"<<std::endl;
1086  return true;
1087  }
1088  }
1089  quadV.push_back(thisQuad);
1090  return false;
1091 
1092 }
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:18
double y
Definition: Quad.h:6
Definition: Quad.h:4
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 1003 of file SeedForPhotonConversionFromQuadruplets.cc.

References vertices_cff::chi2, getSqrEffectiveErrorOnZ(), TrackingRegion::origin(), TrackingRegion::originZBound(), PV3DBase< T, PVType, FrameType >::perp(), sqr(), verySimpleFit(), x, y, and PV3DBase< T, PVType, FrameType >::z().

Referenced by bubbleReverseSortVsPhi(), and trajectorySeed().

1003  {
1004 
1005  double x[5], y[5], e2y[5];
1006 
1007  //The fit is done filling x with r values, y with z values of the four hits and the vertex
1008  //
1009  //Hits
1010  x[0] = ohit->globalPosition().perp();
1011  y[0] = ohit->globalPosition().z();
1012  e2y[0] = getSqrEffectiveErrorOnZ(ohit, region);
1013  //
1014  x[1] = nohit->globalPosition().perp();
1015  y[1] = nohit->globalPosition().z();
1016  e2y[1] = getSqrEffectiveErrorOnZ(nohit, region);
1017  //
1018  x[2] = nihit->globalPosition().perp();
1019  y[2] = nihit->globalPosition().z();
1020  e2y[2] = getSqrEffectiveErrorOnZ(nihit, region);
1021  //
1022  x[3] = ihit->globalPosition().perp();
1023  y[3] = ihit->globalPosition().z();
1024  e2y[3] = getSqrEffectiveErrorOnZ(ihit, region);
1025  //
1026  //Vertex
1027  x[4] = region.origin().perp();
1028  y[4] = region.origin().z();
1029  double vError = region.originZBound();
1030  if ( vError > 15. ) vError = 1.;
1031  e2y[4] = sqr(vError);
1032 
1033  double e2z0;
1034  double chi2 = verySimpleFit(5, x, y, e2y, z0, e2z0, cotTheta);
1035 
1036  return chi2;
1037 
1038 }
T perp() const
Definition: PV3DBase.h:72
GlobalPoint const & origin() const
double verySimpleFit(int size, double *ax, double *ay, double *e2y, double &p0, double &e2p0, double &p1)
T z() const
Definition: PV3DBase.h:64
float originZBound() const
bounds the particle vertex in the longitudinal plane
double getSqrEffectiveErrorOnZ(const SeedingHitSet::ConstRecHitPointer &hit, const TrackingRegion &region)
void SeedForPhotonConversionFromQuadruplets::stupidPrint ( std::string  s,
float *  d 
)

Definition at line 934 of file SeedForPhotonConversionFromQuadruplets.cc.

References mps_fire::i.

Referenced by refitHit(), and stupidPrint().

934  {
935  (*pss) << "\n" << s << "\t";
936  for(size_t i=0;i<2;++i)
937  (*pss) << std::setw (60) << d[i] << std::setw(1) << " | ";
938 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
void SeedForPhotonConversionFromQuadruplets::stupidPrint ( std::string  s,
double *  d 
)

Definition at line 941 of file SeedForPhotonConversionFromQuadruplets.cc.

References mps_fire::i, and stupidPrint().

941  {
942  (*pss) << "\n" << s << "\t";
943  for(size_t i=0;i<2;++i)
944  (*pss) << std::setw (60) << d[i] << std::setw(1) << " | ";
945 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
void SeedForPhotonConversionFromQuadruplets::stupidPrint ( const char *  s,
GlobalPoint d 
)

Definition at line 948 of file SeedForPhotonConversionFromQuadruplets.cc.

References mps_fire::i, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), and stupidPrint().

948  {
949  (*pss) << "\n" << s << "\t";
950  for(size_t i=0;i<2;++i)
951  (*pss) << std::setw(20) << d[i] << " r " << d[i].perp() << " phi " << d[i].phi() << " | ";
952 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void SeedForPhotonConversionFromQuadruplets::stupidPrint ( const char *  s,
GlobalPoint d,
int  n 
)

Definition at line 955 of file SeedForPhotonConversionFromQuadruplets.cc.

References bubbleSortVsPhi(), mps_fire::i, gen::n, PV3DBase< T, PVType, FrameType >::perp(), and PV3DBase< T, PVType, FrameType >::phi().

955  {
956  (*pss) << "\n" << s << "\n";
957  for(int i=0;i<n;++i)
958  (*pss) << std::setw(20) << d[i] << " r " << d[i].perp() << " phi " << d[i].phi() << "\n";
959 }
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
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 56 of file SeedForPhotonConversionFromQuadruplets.cc.

References funct::abs(), TtFullHadDaughter::B, buildSeed(), buildSeedBool(), patCaloMETCorrections_cff::C, vertices_cff::chi2, cloner, Conv4HitsReco2::ConversionCandidate(), funct::cos(), gather_cfg::cout, edmIntegrityCheck::d, DeltaPhiManual(), Conv4HitsReco2::Dump(), edm::EventSetup::get(), edm::ParameterSet::getParameter(), getSqrEffectiveErrorOnZ(), initialError(), MagneticField::inTesla(), listHistos::IP, gen::k, kPI_, MagneticField::nominalValue(), TrackingRegion::origin(), TrackingRegion::originRBound(), TrackingRegion::originZBound(), colinearityKinematic::Phi, edm::ESHandle< T >::product(), TrackingRegion::ptMin(), ptmin, PhotonConversionTrajectorySeedProducerFromQuadruplets_cfi::rejectAllQuads, conversionPostprocessing_cfi::rMax, Conv4HitsReco2::SetMaxNumberOfIterations(), similarQuadExist(), simpleGetSlope(), funct::sin(), SeedingHitSet::size(), mathSSE::sqrt(), theComparitor, LaserSeedGenerator_cfi::TTRHBuilder, Quad::x, x, PV3DBase< T, PVType, FrameType >::x(), y, PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

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

Definition at line 1040 of file SeedForPhotonConversionFromQuadruplets.cc.

Referenced by simpleGetSlope().

1040  {
1041 
1042  //#include "verySimpleFit.icc"
1043  return 0;
1044 }

Member Data Documentation

TkClonerImpl SeedForPhotonConversionFromQuadruplets::cloner
protected

Definition at line 110 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by refitHit(), and trajectorySeed().

const int SeedForPhotonConversionFromQuadruplets::cotTheta_Max =99999
static

Definition at line 22 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by initialKinematic().

double SeedForPhotonConversionFromQuadruplets::kPI_
protected

Definition at line 107 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by DeltaPhiManual(), and trajectorySeed().

PrintRecoObjects SeedForPhotonConversionFromQuadruplets::po
protected

Definition at line 113 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by buildSeed(), and initialKinematic().

std::stringstream* SeedForPhotonConversionFromQuadruplets::pss
protected

Definition at line 112 of file SeedForPhotonConversionFromQuadruplets.h.

double SeedForPhotonConversionFromQuadruplets::theBOFFMomentum
protected

Definition at line 106 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by initialKinematic().

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

Definition at line 105 of file SeedForPhotonConversionFromQuadruplets.h.

Referenced by buildSeed(), and buildSeedBool().