24 TkGluedMeasurementDet::TkGluedMeasurementDet(
const GluedGeomDet* gdet,
28 theMatcher(matcher), theCPE(cpe),
34 theMonoDet =
dynamic_cast<const TkStripMeasurementDet *
>(monoDet);
35 theStereoDet =
dynamic_cast<const TkStripMeasurementDet *
>(stereoDet);
37 if ((theMonoDet == 0) || (theStereoDet == 0)) {
38 throw MeasurementDetException(
"TkGluedMeasurementDet ERROR: Trying to glue a det which is not a TkStripMeasurementDet");
42 TkGluedMeasurementDet::RecHitContainer
47 HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result );
48 collectRecHits(ts, data, collector);
55 template<
typename Collector>
59 doubleMatch(ts,data,collector);
62 template<
typename Collector>
69 RecHitContainer monoHits = theMonoDet->recHits( ts, data );
76 if (monoHits.empty()) {
78 projectOnGluedDet( collector, theStereoDet->recHits(ts, data), glbDir);
81 static std::vector<SiStripRecHit2D> simpleSteroHitsByValue;
82 simpleSteroHitsByValue.clear();
83 theStereoDet->simpleRecHits(ts, data, simpleSteroHitsByValue);
85 if (simpleSteroHitsByValue.empty()) {
86 projectOnGluedDet( collector, monoHits, glbDir);
91 vsStereoHits.resize(simpleSteroHitsByValue.size());
95 for (RecHitContainer::const_iterator monoHit = monoHits.begin();
96 monoHit != monoHits.end(); ++monoHit) {
98 const SiStripRecHit2D* verySpecificMonoHit =
reinterpret_cast<const SiStripRecHit2D*
>(tkhit);
99 theMatcher->match( verySpecificMonoHit, vsStereoHits.begin(), vsStereoHits.end(),
100 collector.collector(), &specificGeomDet(), tkDir);
102 if (collector.hasNewMatchedHits()) {
103 collector.clearNewMatchedHitsFlag();
105 collector.addProjected( **monoHit, glbDir );
146 if(fm!=0&&fs!=0) ++matchF;
147 if(fm!=0||fs!=0) ++singleF;
151 printf(
"Matches:%d/%d/%d/%d/%d/%d : %f/%f/%f/%f/%f/%f/%f\n",
152 int(totCall),
int(matchF),
int(singleF-matchF),
int(matchT),
int(zeroM),
int(zeroS),
153 totMono/totCall,totStereo/totCall,totComb/totCall,totMatched/matchT,
154 filtMono/totCall,filtStereo/totCall,filtComb/matchF);
165 TempMeasurements & result)
const {
167 if unlikely((!theMonoDet->isActive(data)) && (!theStereoDet->isActive(data))) {
173 auto oldSize = result.size();
175 HitCollectorForFastMeasurements collector( &fastGeomDet(), theMatcher, theCPE, stateOnThisDet, est, result);
176 collectRecHits(stateOnThisDet, data, collector);
179 if (result.size()>oldSize)
return true;
182 const BoundPlane &gluedPlane = geomDet().surface();
186 (theMonoDet->isActive(data) &&
187 (theMonoDet->hasAllGoodChannels() ||
188 testStrips(stateOnThisDet,gluedPlane,*theMonoDet)
191 (theStereoDet->isActive(data) &&
192 (theStereoDet->hasAllGoodChannels() ||
193 testStrips(stateOnThisDet,gluedPlane,*theStereoDet)
206 TkGluedMeasurementDet::RecHitContainer
207 TkGluedMeasurementDet::projectOnGluedDet(
const RecHitContainer& hits,
210 if (hits.empty())
return hits;
213 for ( RecHitContainer::const_iterator ihit = hits.begin(); ihit!=hits.end(); ihit++) {
214 result.push_back( proj.
project( **ihit, fastGeomDet(), ts));
219 template<
typename Collector>
221 TkGluedMeasurementDet::projectOnGluedDet( Collector& collector,
222 const RecHitContainer& hits,
225 for ( RecHitContainer::const_iterator ihit = hits.begin(); ihit!=hits.end(); ihit++) {
226 collector.addProjected( **ihit, gdir );
231 const RecHitContainer& monoHits,
232 const RecHitContainer& stereoHits)
const
234 for (RecHitContainer::const_iterator
i=monoHits.begin();
i != monoHits.end(); ++
i) {
235 checkHitProjection( **
i, ts, fastGeomDet());
237 for (RecHitContainer::const_iterator
i=stereoHits.begin();
i != stereoHits.end(); ++
i) {
238 checkHitProjection( **
i, ts, fastGeomDet());
252 if ((projectedHit->localPosition()-propState.
localPosition()).
mag() > 0.0001) {
253 cout <<
"PROBLEM: projected and propagated hit positions differ by "
257 LocalError le1 = projectedHit->localPositionError();
262 fabs(le1.
xy() - le2.
xy())/(cutoff+fabs(le1.
xy()))),
263 fabs(le1.
yy() - le2.
yy())/(cutoff+le1.
xx()));
265 cout <<
"PROBLEM: projected and propagated hit errors differ by "
274 const TkStripMeasurementDet &mdet)
const {
276 const GeomDet &det = mdet.fastGeomDet();
298 if (stripPlane.normalVector().dot( gluedPlane.normalVector()) < 0) {
316 const StripTopology &topo = mdet.specificGeomDet().specificTopology();
319 return mdet.testStrips(utraj, uerr);
322 #include<boost/bind.hpp>
323 TkGluedMeasurementDet::HitCollectorForRecHits::HitCollectorForRecHits(
const GeomDet * geomDet,
325 RecHitContainer &
target) :
326 geomDet_(geomDet), matcher_(matcher), cpe_(cpe),target_(target),
327 collector_(boost::bind(&HitCollectorForRecHits::
add,boost::ref(*this),_1)),
337 target_.push_back( proj.
project( hit, *geomDet_, gdir));
340 TkGluedMeasurementDet::HitCollectorForFastMeasurements::HitCollectorForFastMeasurements
345 TempMeasurements &
target) :
346 geomDet_(geomDet), matcher_(matcher), cpe_(cpe),stateOnThisDet_(stateOnThisDet), est_(est), target_(target),
347 collector_(boost::bind(&HitCollectorForFastMeasurements::
add,boost::ref(*this),_1)),
355 static thread_local std::auto_ptr<TSiStripMatchedRecHit> lcache;
356 std::auto_ptr<TSiStripMatchedRecHit> & cache = lcache;
357 TSiStripMatchedRecHit::buildInPlace( cache, geomDet_, &hit2d, matcher_, cpe_ );
358 std::pair<bool,double> diffEst = est_.estimate( stateOnThisDet_, *cache);
359 if ( diffEst.first) {
360 cache->clonePersistentHit();
361 target_.add(RecHitPointer(cache.release()),
364 cache->clearPersistentHit();
375 RecHitPointer && phit = proj.
project( hit, *geomDet_, gdir );
376 std::pair<bool,double> diffEst = est_.estimate( stateOnThisDet_, *phit);
377 if ( diffEst.first) {
378 target_.add(phit, diffEst.second);
386 #include "doubleMatch.icc"
TrajectoryStateOnSurface propagate(const TransientTrackingRecHit &hit, const Plane &plane, const TrajectoryStateOnSurface &ts) const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
LocalVector localDirection() const
LocalPoint localPosition() const
Global3DPoint GlobalPoint
GlobalPoint globalPosition() const
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
const Plane & surface() const
The nominal surface of the GeomDet.
LocalError positionError() const
static int position[TOTALCHAMBERS][3]
RecHitPointer project(const TransientTrackingRecHit &hit, const GeomDet &det, const TrajectoryStateOnSurface &ts) const
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const =0
const T & max(const T &a, const T &b)
GlobalVector momentum() const
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
const LocalTrajectoryError & localError() const
const T * operator()(const T &val) const
unsigned long long uint64_t
const GlobalTrajectoryParameters & globalParameters() const
std::vector< const SiStripRecHit2D * > SimpleHitCollection
char data[epos_bytes_allocation]
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
volatile std::atomic< bool > shutdown_flag false
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)