23 TkGluedMeasurementDet::TkGluedMeasurementDet(
const GluedGeomDet* gdet,
27 theMatcher(matcher), theCPE(cpe),
33 theMonoDet =
dynamic_cast<const TkStripMeasurementDet *
>(monoDet);
34 theStereoDet =
dynamic_cast<const TkStripMeasurementDet *
>(stereoDet);
36 if ((theMonoDet == 0) || (theStereoDet == 0)) {
37 throw MeasurementDetException(
"TkGluedMeasurementDet ERROR: Trying to glue a det which is not a TkStripMeasurementDet");
41 TkGluedMeasurementDet::RecHitContainer
46 HitCollectorForRecHits collector( &fastGeomDet(), theMatcher, theCPE, result );
47 collectRecHits(ts, collector);
54 template<
typename Collector>
58 doubleMatch(ts,collector);
61 template<
typename Collector>
68 RecHitContainer monoHits = theMonoDet->recHits( ts);
75 if (monoHits.empty()) {
77 projectOnGluedDet( collector, theStereoDet->recHits(ts), glbDir);
80 static std::vector<SiStripRecHit2D> simpleSteroHitsByValue;
81 simpleSteroHitsByValue.clear();
82 theStereoDet->simpleRecHits(ts, simpleSteroHitsByValue);
84 if (simpleSteroHitsByValue.empty()) {
85 projectOnGluedDet( collector, monoHits, glbDir);
90 vsStereoHits.resize(simpleSteroHitsByValue.size());
94 for (RecHitContainer::const_iterator monoHit = monoHits.begin();
95 monoHit != monoHits.end(); ++monoHit) {
97 const SiStripRecHit2D* verySpecificMonoHit =
reinterpret_cast<const SiStripRecHit2D*
>(tkhit);
98 theMatcher->match( verySpecificMonoHit, vsStereoHits.begin(), vsStereoHits.end(),
99 collector.collector(), &specificGeomDet(), tkDir);
101 if (collector.hasNewMatchedHits()) {
102 collector.clearNewMatchedHitsFlag();
104 collector.addProjected( **monoHit, glbDir );
145 if(fm!=0&&fs!=0) ++matchF;
146 if(fm!=0||fs!=0) ++singleF;
150 printf(
"Matches:%d/%d/%d/%d/%d/%d : %f/%f/%f/%f/%f/%f/%f\n",
151 int(totCall),
int(matchF),
int(singleF-matchF),
int(matchT),
int(zeroM),
int(zeroS),
152 totMono/totCall,totStereo/totCall,totComb/totCall,totMatched/matchT,
153 filtMono/totCall,filtStereo/totCall,filtComb/matchF);
163 TempMeasurements & result)
const {
165 if unlikely((!theMonoDet->isActive()) && (!theStereoDet->isActive())) {
171 auto oldSize = result.size();
173 HitCollectorForFastMeasurements collector( &fastGeomDet(), theMatcher, theCPE, stateOnThisDet, est, result);
174 collectRecHits(stateOnThisDet, collector);
177 if (result.size()>oldSize)
return true;
180 const BoundPlane &gluedPlane = geomDet().surface();
184 (theMonoDet->isActive() &&
185 (theMonoDet->hasAllGoodChannels() ||
186 testStrips(stateOnThisDet,gluedPlane,*theMonoDet)
189 (theStereoDet->isActive() &&
190 (theStereoDet->hasAllGoodChannels() ||
191 testStrips(stateOnThisDet,gluedPlane,*theStereoDet)
204 TkGluedMeasurementDet::RecHitContainer
205 TkGluedMeasurementDet::projectOnGluedDet(
const RecHitContainer& hits,
208 if (hits.empty())
return hits;
211 for ( RecHitContainer::const_iterator ihit = hits.begin(); ihit!=hits.end(); ihit++) {
212 result.push_back( proj.
project( **ihit, fastGeomDet(), ts));
217 template<
typename Collector>
219 TkGluedMeasurementDet::projectOnGluedDet( Collector& collector,
220 const RecHitContainer& hits,
223 for ( RecHitContainer::const_iterator ihit = hits.begin(); ihit!=hits.end(); ihit++) {
224 collector.addProjected( **ihit, gdir );
229 const RecHitContainer& monoHits,
230 const RecHitContainer& stereoHits)
const
232 for (RecHitContainer::const_iterator
i=monoHits.begin();
i != monoHits.end(); ++
i) {
233 checkHitProjection( **
i, ts, fastGeomDet());
235 for (RecHitContainer::const_iterator
i=stereoHits.begin();
i != stereoHits.end(); ++
i) {
236 checkHitProjection( **
i, ts, fastGeomDet());
250 if ((projectedHit->localPosition()-propState.
localPosition()).
mag() > 0.0001) {
251 cout <<
"PROBLEM: projected and propagated hit positions differ by "
255 LocalError le1 = projectedHit->localPositionError();
260 fabs(le1.
xy() - le2.
xy())/(cutoff+fabs(le1.
xy()))),
261 fabs(le1.
yy() - le2.
yy())/(cutoff+le1.
xx()));
263 cout <<
"PROBLEM: projected and propagated hit errors differ by "
272 const TkStripMeasurementDet &mdet)
const {
274 const GeomDet &det = mdet.fastGeomDet();
296 if (stripPlane.normalVector().dot( gluedPlane.normalVector()) < 0) {
314 const StripTopology &topo = mdet.specificGeomDet().specificTopology();
317 return mdet.testStrips(utraj, uerr);
320 #include<boost/bind.hpp>
321 TkGluedMeasurementDet::HitCollectorForRecHits::HitCollectorForRecHits(
const GeomDet * geomDet,
323 RecHitContainer &
target) :
324 geomDet_(geomDet), matcher_(matcher), cpe_(cpe),target_(target),
325 collector_(boost::bind(&HitCollectorForRecHits::
add,boost::ref(*this),_1)),
335 target_.push_back( proj.
project( hit, *geomDet_, gdir));
338 TkGluedMeasurementDet::HitCollectorForFastMeasurements::HitCollectorForFastMeasurements
343 TempMeasurements &
target) :
344 geomDet_(geomDet), matcher_(matcher), cpe_(cpe),stateOnThisDet_(stateOnThisDet), est_(est), target_(target),
345 collector_(boost::bind(&HitCollectorForFastMeasurements::
add,boost::ref(*this),_1)),
354 std::auto_ptr<TSiStripMatchedRecHit> & cache = lcache.
ptr;
355 TSiStripMatchedRecHit::buildInPlace( cache, geomDet_, &hit2d, matcher_, cpe_ );
356 std::pair<bool,double> diffEst = est_.estimate( stateOnThisDet_, *cache);
357 if ( diffEst.first) {
358 cache->clonePersistentHit();
359 target_.add(RecHitPointer(cache.release()),
362 cache->clearPersistentHit();
373 RecHitPointer && phit = proj.
project( hit, *geomDet_, gdir );
374 std::pair<bool,double> diffEst = est_.estimate( stateOnThisDet_, *phit);
375 if ( diffEst.first) {
376 target_.add(phit, diffEst.second);
384 #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
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
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)