60 bool stereLayerFirst)
const;
64 const StripPosition&
strip,
69 throw cms::Exception(
"FastTrackerRecHitMatcher") <<
"all rechits in simHit2RecHitMap must be instances of FastSingleTrackerRecHit. recHit's rtti: " << recHit->
rtti() << std::endl;
86 produces<FastTrackerRecHitCollection>();
87 produces<FastTrackerRecHitRefCollection>(
"simHit2RecHitMap");
105 auto output_recHits = std::make_unique<FastTrackerRecHitCollection>();
106 auto output_simHit2RecHitMap = std::make_unique<FastTrackerRecHitRefCollection>(simHit2RecHitMap->size(),
FastTrackerRecHitRef());
109 bool skipNext =
false;
110 for(
unsigned simHitCounter = 0;simHitCounter < simHits->size();++simHitCounter){
132 unsigned int subdet = detid.
subdetId();
136 (*output_simHit2RecHitMap)[simHitCounter] = recHitRef;
145 if(!stripSubDetId.
glued()){
146 (*output_simHit2RecHitMap)[simHitCounter] = recHitRef;
164 if(simHitCounter + 1 < simHits->size()){
166 const PSimHit & nextSimHit = (*simHits)[simHitCounter + 1];
170 if( (!nextRecHitRef.
isNull())
178 std::unique_ptr<FastTrackerRecHit> newRecHit(
nullptr);
183 stripSubDetId.
stereo() ? recHit : partnerRecHit,
184 gluedDet , gluedLocalSimTrackDir,
189 newRecHit =
projectOnly( recHit , geometry->
idToDet(detid),gluedDet, gluedLocalSimTrackDir );
191 output_recHits->push_back(
std::move(newRecHit));
192 (*output_simHit2RecHitMap)[simHitCounter] =
FastTrackerRecHitRef(output_recHits_refProd,output_recHits->size()-1);
198 iEvent.
put(
std::move(output_simHit2RecHitMap),
"simHit2RecHitMap");
206 bool stereoHitFirst)
const 225 if(trackdirection.
mag2()<FLT_MIN){
237 LocalVector RPHIpositiononGluedendvector=projectedstripmono.second-projectedstripmono.first;
238 double c1=
sin(RPHIpositiononGluedendvector.
phi());
239 double s1=-
cos(RPHIpositiononGluedendvector.
phi());
242 double sigmap12=errormonoRH.uu()*pitch*pitch;
254 StripPosition projectedstripstereo=
project(partnerstripdet,gluedDet,stripstereo,trackdirection);
259 m(0,0)=-(projectedstripmono.second.y()-projectedstripmono.first.y());
m(0,1)=(projectedstripmono.second.x()-projectedstripmono.first.x());
260 m(1,0)=-(projectedstripstereo.second.y()-projectedstripstereo.first.y());
m(1,1)=(projectedstripstereo.second.x()-projectedstripstereo.first.x());
261 c(0)=
m(0,1)*projectedstripmono.first.y()+
m(0,0)*projectedstripmono.first.x();
262 c(1)=
m(1,1)*projectedstripstereo.first.y()+
m(1,0)*projectedstripstereo.first.x();
263 m.Invert(); solution = m *
c;
275 LocalVector stereopositiononGluedendvector=projectedstripstereo.second-projectedstripstereo.first;
276 double c2=
sin(stereopositiononGluedendvector.
phi());
double s2=-
cos(stereopositiononGluedendvector.
phi());
279 double sigmap22=errorstereoRH.uu()*pitch*pitch;
280 double diff=(c1*s2-c2*s1);
281 double invdet2=1/(diff*
diff);
282 float xx=invdet2*(sigmap12*s2*s2+sigmap22*s1*s1);
283 float xy=-invdet2*(sigmap12*c2*s2+sigmap22*c1*s1);
284 float yy=invdet2*(sigmap12*c2*c2+sigmap22*c1*
c1);
289 if(det.subdetId() > 2) {
290 return std::make_unique<FastMatchedTrackerRecHit>(
position,
error, *gluedDet, *monoRH, *stereoRH,stereoHitFirst);
295 throw cms::Exception(
"FastTrackerRecHitMatcher") <<
"Matched Pixel!?";
316 float scale=-positiononGluedini.
z()/trackdirection.
z();
318 LocalPoint projpositiononGluedini= positiononGluedini + scale*trackdirection;
319 LocalPoint projpositiononGluedend= positiononGluedend + scale*trackdirection;
321 return StripPosition(projpositiononGluedini,projpositiononGluedend);
335 double delta = gluedPlane.localZ( hitPlane.position());
338 LocalPoint projectedHitPos = lhitPos - ldir * delta/ldir.
z();
343 if (gluedPlane.normalVector().dot( hitPlane.normalVector()) < 0) {
359 if ((isMono && isStereo)||(!isMono&&!isStereo))
throw cms::Exception(
"FastTrackerRecHitMatcher") <<
"Something wrong with DetIds.";
360 return std::make_unique<FastProjectedTrackerRecHit>(projectedHitPos, rotatedError, *gluedDet, *originalRH);
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Point3DBase< Scalar, LocalTag > LocalPoint
const GeomDetUnit * monoDet() const
~FastTrackerRecHitMatcher()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual const Topology & topology() const
std::unique_ptr< FastTrackerRecHit > projectOnly(const FastSingleTrackerRecHit *originalRH, const GeomDet *monoDet, const GluedGeomDet *gluedDet, LocalVector &ldir) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
std::unique_ptr< FastTrackerRecHit > match(const FastSingleTrackerRecHit *monoRH, const FastSingleTrackerRecHit *stereoRH, const GluedGeomDet *gluedDet, LocalVector &trackdirection, bool stereLayerFirst) const
LocalVector toLocal(const reco::Track::Vector &v, const Surface &s)
const Plane & surface() const
The nominal surface of the GeomDet.
edm::Ref< FastTrackerRecHitCollection > FastTrackerRecHitRef
FastTrackerRecHitMatcher(const edm::ParameterSet &)
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepStd< double, 2, 2 > > AlgebraicMatrix22
uint32_t rawId() const
get the raw id
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
unsigned int glued() const
glued
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< FastTrackerRecHitRefCollection > simHit2RecHitMapToken
virtual LocalPoint localPosition(float strip) const =0
const GeomDet * det() const
LocalPoint toLocal(const GlobalPoint &gp) const
Cos< T >::type cos(const T &t)
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
edm::EDGetTokenT< edm::PSimHitContainer > simHitsToken
DetId geographicalId() const
The label of this GeomDet.
T const * get() const
Returns C++ pointer to the item.
virtual LocalPoint localPosition() const final
StripPosition project(const GeomDetUnit *det, const GluedGeomDet *glueddet, const StripPosition &strip, const LocalVector &trackdirection) const
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool isNull() const
Checks for null.
RefProd< PROD > getRefBeforePut()
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
unsigned int stereo() const
stereo
const FastSingleTrackerRecHit * _cast2Single(const FastTrackerRecHit *recHit) const
virtual float localPitch(const LocalPoint &) const =0
std::pair< LocalPoint, LocalPoint > StripPosition
ESHandle< TrackerGeometry > geometry
static int position[264][3]
const TrackerGeomDet * idToDet(DetId) const override
unsigned int trackId() const
trackerHitRTTI::RTTI rtti() const
DetId geographicalId() const
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)
virtual LocalError localPositionError() const final
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ROOT::Math::SVector< double, 2 > AlgebraicVector2
const GeomDetUnit * stereoDet() const