CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
QuadrupletSeedMerger Class Reference

#include <QuadrupletSeedMerger.h>

Public Member Functions

std::pair< double, double > calculatePhiEta (SeedingHitSet const &) const
 
bool isEqual (const TrackingRecHit *, const TrackingRecHit *) const
 
const OrderedSeedingHitsmergeTriplets (const OrderedSeedingHits &, const edm::EventSetup &)
 
const TrajectorySeedCollection mergeTriplets (const TrajectorySeedCollection &, const TrackingRegion &, const edm::EventSetup &, const edm::ParameterSet &)
 
void printHit (const TrackingRecHit *) const
 
void printHit (const TransientTrackingRecHit::ConstRecHitPointer &) const
 
void printNtuplet (const SeedingHitSet &) const
 
 QuadrupletSeedMerger ()
 
void setAddRemainingTriplets (bool)
 
void setLayerListName (std::string)
 
void setMergeTriplets (bool)
 
void setTTRHBuilderLabel (std::string)
 
void update (const edm::EventSetup &)
 
 ~QuadrupletSeedMerger ()
 

Private Member Functions

bool isMergeableHitsInTriplets (const SeedingHitSet &firstTriplet, const SeedingHitSet &secondTriplet, const SeedMergerPixelLayer &nonShared1, const SeedMergerPixelLayer &nonShared2, std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &hits, const TrackerTopology *tTopo) const
 
bool isTripletsShareHitsOnLayers (const SeedingHitSet &firstTriplet, const SeedingHitSet &secondTriplet, const SeedMergerPixelLayer &share1, const SeedMergerPixelLayer &share2, std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &hits, const TrackerTopology *tTopo) const
 
bool isValidQuadruplet (std::vector< TransientTrackingRecHit::ConstRecHitPointer > &quadruplet, const std::vector< SeedMergerPixelLayer > &layers, const TrackerTopology *tTopo) const
 
std::vector
< TransientTrackingRecHit::ConstRecHitPointer
mySort (TransientTrackingRecHit::ConstRecHitPointer &h1, TransientTrackingRecHit::ConstRecHitPointer &h2, TransientTrackingRecHit::ConstRecHitPointer &h3, TransientTrackingRecHit::ConstRecHitPointer &h4)
 

Private Attributes

bool isAddRemainingTriplets_
 
bool isMergeTriplets_
 
std::string layerListName_
 
OrderedHitSeeds quads_
 
ctfseeding::SeedingLayerSets theLayerSets_
 
edm::ESHandle< TrackerGeometrytheTrackerGeometry_
 
edm::ESHandle
< TransientTrackingRecHitBuilder
theTTRHBuilder_
 
std::string theTTRHBuilderLabel_
 

Detailed Description

merge triplets into quadruplets

Definition at line 76 of file QuadrupletSeedMerger.h.

Constructor & Destructor Documentation

QuadrupletSeedMerger::QuadrupletSeedMerger ( )

Definition at line 32 of file QuadrupletSeedMerger.cc.

References isAddRemainingTriplets_, isMergeTriplets_, layerListName_, and AlCaHLTBitMon_QueryRunRegistry::string.

32  {
33 
34  // by default, do not..
35  // ..merge triplets
36  isMergeTriplets_ = false;
37  // ..add remaining triplets
39 
40  // default is the layer list from plain quadrupletseedmerging_cff
41  // unless configured contrarily via setLayerListName()
42  layerListName_ = std::string( "PixelSeedMergerQuadruplets" );
43 }
QuadrupletSeedMerger::~QuadrupletSeedMerger ( )

Definition at line 53 of file QuadrupletSeedMerger.cc.

53  {
54 
55 }

Member Function Documentation

std::pair< double, double > QuadrupletSeedMerger::calculatePhiEta ( SeedingHitSet const &  nTuplet) const

Definition at line 379 of file QuadrupletSeedMerger.cc.

References eta(), TrackingRecHit::geographicalId(), TrackingRecHit::localPosition(), p1, p2, phi, funct::pow(), mathSSE::sqrt(), theTrackerGeometry_, GeomDet::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by mergeTriplets().

379  {
380 
381 // if( nTuplet.size() < 3 ) {
382 // std::cerr << " [QuadrupletSeedMerger::calculatePhiEta] ** ERROR: nTuplet has less than 3 hits" << std::endl;
383 // throw; // tbr.
384 // }
385 
386  const TrackingRecHit* hit1 = nTuplet[0]->hit();
387  const GeomDet* geomDet1 = theTrackerGeometry_->idToDet( hit1->geographicalId() );
388 
389  const TrackingRecHit* hit2 = nTuplet[1]->hit();
390  const GeomDet* geomDet2 = theTrackerGeometry_->idToDet( hit2->geographicalId() );
391 
392  GlobalPoint p1=geomDet1->toGlobal( hit1->localPosition() );
393  GlobalPoint p2=geomDet2->toGlobal( hit2->localPosition() );
394 
395  const double x1 = p1.x();
396  const double x2 = p2.x();
397  const double y1 = p1.y();
398  const double y2 = p2.y();
399  const double z1 = p1.z();
400  const double z2 = p2.z();
401 
402  const double phi = atan2( x2 - x1, y2 -y1 );
403  const double eta = acos( (z2 - z1) / sqrt( pow( x2 - x1, 2. ) + pow( y2 - y1, 2. ) + pow( z2 - z1, 2. ) ) );
404 
405  std::pair<double,double> retVal;
406  retVal=std::make_pair (phi,eta);
407  return retVal;
408  //return std::make_pair<double,double>( phi, eta );
409 
410 }
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
T y() const
Definition: PV3DBase.h:63
T eta() const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
DetId geographicalId() const
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const =0
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: DDAxes.h:10
bool QuadrupletSeedMerger::isEqual ( const TrackingRecHit hit1,
const TrackingRecHit hit2 
) const

Definition at line 357 of file QuadrupletSeedMerger.cc.

References epsilon, TrackingRecHit::geographicalId(), TrackingRecHit::localPosition(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by isTripletsShareHitsOnLayers().

357  {
358 
359  const double epsilon = 0.00001;
360 
361  DetId det1 = hit1->geographicalId(), det2 = hit2->geographicalId();
362  if (det1 == det2) {
363  LocalPoint lp1 = hit1->localPosition(), lp2 = hit2->localPosition();
364  if( ( fabs( lp1.x() - lp2.x() ) < epsilon ) &&
365  ( fabs( lp1.y() - lp2.y() ) < epsilon ) ) {
366  return true;
367  }
368 
369  }
370  return false;
371 
372 }
T y() const
Definition: PV3DBase.h:63
Definition: DetId.h:20
DetId geographicalId() const
const double epsilon
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const =0
bool QuadrupletSeedMerger::isMergeableHitsInTriplets ( const SeedingHitSet firstTriplet,
const SeedingHitSet secondTriplet,
const SeedMergerPixelLayer nonShared1,
const SeedMergerPixelLayer nonShared2,
std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &  hits,
const TrackerTopology tTopo 
) const
private

check if the triplets have hits on the nonSharedLayers triplet1 on layer1 && triplet2 on layer2, or vice versa, and return the hits on those layers (unsorted)

Definition at line 638 of file QuadrupletSeedMerger.cc.

References SeedMergerPixelLayer::isContainsDetector().

Referenced by mergeTriplets().

641  {
642 
643  // check if firstTriplet and secondTriplet have hits on sharedLayers
644  for( unsigned int index1 = 0; index1 < 3; ++index1 ) {
645 
646  { // first triplet on non-shared layer 1
647  DetId const& aDetId = firstTriplet[index1]->hit()->geographicalId();
648  if( nonShared1.isContainsDetector( aDetId, tTopo ) ) {
649 
650  // look for hit in other (second) triplet on other layer
651  for( unsigned int index2 = 0; index2 < 3; ++index2 ) {
652 
653  DetId const& anotherDetId = secondTriplet[index2]->hit()->geographicalId();
654  if( nonShared2.isContainsDetector( anotherDetId, tTopo ) ) {
655 
656  // ok!
657  hits.first = firstTriplet[index1];
658  hits.second = secondTriplet[index2];
659  return true;
660 
661  }
662  }
663  }
664  }
665 
666  // and vice versa..
667 
668  { // second triplet on non-shared layer 1
669  DetId const& aDetId = secondTriplet[index1]->hit()->geographicalId();
670  if( nonShared1.isContainsDetector( aDetId, tTopo ) ) {
671 
672  // look for hit in other (second) triplet on other layer
673  for( unsigned int index2 = 0; index2 < 3; ++index2 ) {
674 
675  DetId const& anotherDetId = firstTriplet[index2]->hit()->geographicalId();
676  if( nonShared2.isContainsDetector( anotherDetId, tTopo ) ) {
677 
678  // ok!
679  hits.first = firstTriplet[index1];
680  hits.second = secondTriplet[index2];
681  return true;
682 
683  }
684  }
685  }
686  }
687 
688  } // for( index1
689 
690  return false;
691 
692 }
Definition: DetId.h:20
bool isContainsDetector(const DetId &, const TrackerTopology *tTopo) const
bool QuadrupletSeedMerger::isTripletsShareHitsOnLayers ( const SeedingHitSet firstTriplet,
const SeedingHitSet secondTriplet,
const SeedMergerPixelLayer shared1,
const SeedMergerPixelLayer shared2,
std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &  hits,
const TrackerTopology tTopo 
) const
private

check if both triplets share a hit on either of the sharedLayers and return both hits (unsorted)

Definition at line 555 of file QuadrupletSeedMerger.cc.

References getHLTprescales::index, SeedMergerPixelLayer::isContainsDetector(), and isEqual().

Referenced by mergeTriplets().

558  {
559 
560  bool isSuccess1[2],isSuccess2[2];
561  isSuccess1[0]=false;
562  isSuccess1[1]=false;
563  isSuccess2[0]=false;
564  isSuccess2[1]=false;
565 
566  std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> hitsTriplet1, hitsTriplet2;
567 
568  // check if firstTriplet and secondTriplet have hits on sharedLayers
569  for( unsigned int index = 0; index < 3; ++index )
570  { // first triplet
571  if( ! firstTriplet[index]->isValid() ) return false; // catch invalid TTRH pointers (tbd: erase triplet)
572  bool firsthit(false); // Don't look in second layer if found in first
573  DetId const& thisDetId = firstTriplet[index]->hit()->geographicalId();
574 
575  if( ! isSuccess1[0] ) { // first triplet on shared layer 1
576  if( shared1.isContainsDetector( thisDetId, tTopo ) ) {
577  isSuccess1[0] = true;
578  firsthit = true;
579  hitsTriplet1.first = firstTriplet[index];
580  }
581  }
582 
583  if ( (! firsthit) && (! isSuccess1[1] ) && ((index !=3) || isSuccess1[0]) ) { // first triplet on shared layer 2
584  if( shared2.isContainsDetector( thisDetId, tTopo ) ) {
585  isSuccess1[1] = true;
586  hitsTriplet1.second = firstTriplet[index];
587  }
588  }
589  }
590 
591  if ( isSuccess1[0] && isSuccess1[1]) { // Don't do second triplet if first unsuccessful
592  for( unsigned int index = 0; index < 3; ++index )
593  { // second triplet
594  if( ! secondTriplet[index]->isValid() ) { return false; } // catch invalid TTRH pointers (tbd: erase triplet)
595  bool firsthit(false); // Don't look in second layer if found in first
596  DetId const& thisDetId = secondTriplet[index]->hit()->geographicalId();
597 
598  if( ! isSuccess2[0] ) { // second triplet on shared layer 1
599  if( shared1.isContainsDetector( thisDetId, tTopo ) ) {
600  isSuccess2[0] = true;
601  firsthit = true;
602  hitsTriplet2.first = secondTriplet[index];
603  }
604  }
605 
606  if( (! firsthit) && (! isSuccess2[1]) && ((index !=3) || isSuccess2[0]) ) { // second triplet on shared layer 2
607  if( shared2.isContainsDetector( thisDetId, tTopo ) ) {
608  isSuccess2[1] = true;
609  hitsTriplet2.second = secondTriplet[index];
610  }
611  }
612  }
613 
614  // check if these hits are pairwise equal
615  if( isSuccess2[0] && isSuccess2[1] ) {
616  if( isEqual( hitsTriplet1.first->hit(), hitsTriplet2.first->hit() ) &&
617  isEqual( hitsTriplet1.second->hit(), hitsTriplet2.second->hit() ) ) {
618 
619  // copy to output, take triplet1 since they're equal anyway
620  hits.first = hitsTriplet1.first;
621  hits.second = hitsTriplet1.second;
622  return true;
623  }
624  }
625  }
626 
627  // empty output, careful
628  return false;
629 
630 }
bool isEqual(const TrackingRecHit *, const TrackingRecHit *) const
Definition: DetId.h:20
bool isContainsDetector(const DetId &, const TrackerTopology *tTopo) const
bool QuadrupletSeedMerger::isValidQuadruplet ( std::vector< TransientTrackingRecHit::ConstRecHitPointer > &  quadruplet,
const std::vector< SeedMergerPixelLayer > &  layers,
const TrackerTopology tTopo 
) const
private

check for validity of a (radius-) sorted quadruplet:

  1. after sorting, hits must be on layers according to the order given in PixelSeedMergerQuadruplets (from cfg)

Definition at line 525 of file QuadrupletSeedMerger.cc.

References gather_cfg::cout, and getHLTprescales::index.

Referenced by mergeTriplets().

526  {
527 
528  const unsigned int quadrupletSize = quadruplet.size();
529 
530  // basic size test..
531  if( quadrupletSize != layers.size() ) {
532  std::cout << " [QuadrupletSeedMerger::isValidQuadruplet] ** WARNING: size mismatch: "
533  << quadrupletSize << "/" << layers.size() << std::endl;
534  return false;
535  }
536 
537  // go along layers and check if all (parallel) quadruplet hits match
538  for( unsigned int index = 0; index < quadrupletSize; ++index ) {
539  if( ! layers[index].isContainsDetector( quadruplet[index]->geographicalId(), tTopo ) ) {
540  return false;
541  }
542  }
543 
544  return true;
545 
546 }
tuple cout
Definition: gather_cfg.py:121
const OrderedSeedingHits & QuadrupletSeedMerger::mergeTriplets ( const OrderedSeedingHits inputTriplets,
const edm::EventSetup es 
)

merge triplets into quadruplets INPUT: OrderedSeedingHits OUTPUT: SeedingHitSets

this method is used in RecoPixelVertexing/PixelTrackFitting/src/PixelTrackReconstruction.cc and contains the basic merger functionality

Definition at line 69 of file QuadrupletSeedMerger.cc.

References calculatePhiEta(), gather_cfg::cout, first, edm::EventSetup::get(), isAddRemainingTriplets_, isMergeableHitsInTriplets(), isMergeTriplets_, isTripletsShareHitsOnLayers(), isValidQuadruplet(), layerListName_, mySort(), edm::ESHandle< class >::product(), quads_, indexGen::s2, edm::second(), EgAmbiguityTools::sharedHits(), OrderedSeedingHits::size(), findQualityFiles::size, reco::t2, groupFilesInBlocks::temp, and theLayerSets_.

Referenced by mergeTriplets(), SeedGeneratorFromRegionHitsEDProducer::produce(), and PixelTrackReconstruction::run().

69  {
70 
71  //Retrieve tracker topology from geometry
73  es.get<IdealGeometryRecord>().get(tTopoHand);
74  const TrackerTopology *tTopo=tTopoHand.product();
75 
76  // the list of layers on which quadruplets should be formed
78  es.get<TrackerDigiGeometryRecord>().get( layerListName_.c_str(), layerBuilder );
79  theLayerSets_ = layerBuilder->layers( es ); // this is a vector<vector<SeedingLayer> >
80 
81 
82  // make a working copy of the input triplets
83  // to be able to remove merged triplets
84 
85  std::vector<std::pair<double,double> > phiEtaCache;
86  std::vector<SeedingHitSet> tripletCache; //somethings strange about OrderedSeedingHits?
87 
88  const unsigned int nInputTriplets = inputTriplets.size();
89  phiEtaCache.reserve(nInputTriplets);
90  tripletCache.reserve(nInputTriplets);
91 
92  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
93  tripletCache.push_back((inputTriplets[it]));
94  phiEtaCache.push_back(calculatePhiEta( (tripletCache[it]) ));
95 
96  }
97 
98  // the output
99  quads_.clear();
100 
101  // check if the input is all triplets
102  // (code is also used for pairs..)
103  // if not, copy the input to the output & return
104  bool isAllTriplets = true;
105  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
106  if( tripletCache[it].size() != 3 ) {
107  isAllTriplets = false;
108  break;
109  }
110  }
111 
112  if( !isAllTriplets && isMergeTriplets_ )
113  std::cout << "[QuadrupletSeedMerger::mergeTriplets] (in HLT) ** bailing out since non-triplets in input." << std::endl;
114 
115  if( !isAllTriplets || !isMergeTriplets_ ) {
116  quads_.reserve(nInputTriplets);
117  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
118  quads_.push_back( (tripletCache[it]));
119  }
120 
121  return quads_;
122  }
123 
124 
125  quads_.reserve(0.2*nInputTriplets); //rough guess
126 
127  // loop all possible 4-layer combinations
128  // as specified in python/quadrupletseedmerging_cff.py
129 
130  std::vector<bool> usedTriplets(nInputTriplets,false);
131  std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> sharedHits;
132  std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> nonSharedHits;
133 
134  //std::vector<bool> phiEtaClose(nInputTriplets*nInputTriplets,true);
135 
136  // for (unsigned int t1=0; t1<nInputTriplets-1; t1++) {
137  // for (unsigned int t2=t1+1; t2<nInputTriplets; t2++) {
138  // if( fabs( phiEtaCache[t1].second - phiEtaCache[t2].second ) > 0.05 ) {
139  // phiEtaClose[t1*nInputTriplets+t2]=false;
140  // phiEtaClose[t2*nInputTriplets+t1]=false;
141  // continue;
142  // }
143  // double temp = fabs( phiEtaCache[t1].first - phiEtaCache[t2].first );
144  // if( (temp > 0.15) && (temp <6.133185) ) {
145  //phiEtaClose[t1*nInputTriplets+t2]=false;
146  //phiEtaClose[t2*nInputTriplets+t1]=false;
147  // }
148  //}
149  //}
150 
151  std::vector<unsigned int> t1List;
152  std::vector<unsigned int> t2List;
153  for (unsigned int t1=0; t1<nInputTriplets-1; t1++) {
154  for (unsigned int t2=t1+1; t2<nInputTriplets; t2++) {
155  if( fabs( phiEtaCache[t1].second - phiEtaCache[t2].second ) > 0.05 )
156  continue;
157  double temp = fabs( phiEtaCache[t1].first - phiEtaCache[t2].first );
158  if( (temp > 0.15) && (temp <6.133185) ) {
159  continue;
160  }
161  t1List.push_back(t1);
162  t2List.push_back(t2);
163  }
164  }
165 
166  for( ctfseeding::SeedingLayerSets::const_iterator lsIt = theLayerSets_.begin(); lsIt < theLayerSets_.end(); ++lsIt ) {
167 
168  // fill a vector with the layers in this set
169  std::vector<SeedMergerPixelLayer> currentLayers;
170  currentLayers.reserve(lsIt->size());
171  for( ctfseeding::SeedingLayers::const_iterator layIt = lsIt->begin(); layIt < lsIt->end(); ++layIt ) {
172  currentLayers.push_back( SeedMergerPixelLayer( layIt->name() ) );
173  }
174  // loop all pair combinations of these 4 layers;
175  // strategy is to look for shared hits on such a pair and
176  // then merge the remaining hits in both triplets if feasible
177  // (SeedingLayers is a vector<SeedingLayer>)
178 
179  for( unsigned int s1=0; s1<currentLayers.size()-1; s1++) {
180 
181  for( unsigned int s2=s1+1; s2<currentLayers.size(); s2++) {
182 
183  std::vector<unsigned int> nonSharedLayerNums;
184  for ( unsigned int us1=0; us1<currentLayers.size(); us1++) {
185  if ( s1!=us1 && s2!=us1) nonSharedLayerNums.push_back(us1);
186  }
187 
188  // loop all possible triplet pairs (which come as input)
189  for (unsigned int t12=0; t12<t1List.size(); t12++) {
190  unsigned int t1=t1List[t12];
191  unsigned int t2=t2List[t12];
192 
193  if (usedTriplets[t1] || usedTriplets[t2] ) continue;
194 
195  // if ( !phiEtaClose[t1*nInputTriplets+t2] ) continue;
196 
197  // do both triplets have shared hits on these two layers?
198  if( isTripletsShareHitsOnLayers( (tripletCache[t1]), (tripletCache[t2]),
199  currentLayers[s1],
200  currentLayers[s2], sharedHits, tTopo ) ) {
201 
202  // are the remaining hits on different layers?
203  if( isMergeableHitsInTriplets( (tripletCache[t1]), (tripletCache[t2]),
204  currentLayers[nonSharedLayerNums[0]],
205  currentLayers[nonSharedLayerNums[1]], nonSharedHits, tTopo ) ) {
206 
207 
208  std::vector<TransientTrackingRecHit::ConstRecHitPointer> unsortedHits=mySort(sharedHits.first,
209  sharedHits.second,
210  nonSharedHits.first,
211  nonSharedHits.second);
212 
213  //start here with old addtoresult
214  if( isValidQuadruplet( unsortedHits, currentLayers, tTopo ) ) {
215  // and create the quadruplet
216  SeedingHitSet quadruplet(unsortedHits[0],unsortedHits[1],unsortedHits[2],unsortedHits[3]);
217 
218  // insert this quadruplet
219  quads_.push_back( quadruplet );
220  // remove both triplets from the list,
221  // needs this 4-permutation since we're in a double loop
222  usedTriplets[t1]=true;
223  usedTriplets[t2]=true;
224  }
225 
226  } // isMergeableHitsInTriplets
227  } // isTripletsShareHitsOnLayers
228  // } // triplet double loop
229  }
230  } // seeding layers double loop
231  }
232 
233  } // seeding layer sets
234 
235  // add the remaining triplets
237  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
238  if ( !usedTriplets[it] )
239  quads_.push_back( tripletCache[it]);
240  }
241  }
242 
243  //calc for printout...
244 // unsigned int nLeft=0;
245 // for ( unsigned int i=0; i<nInputTriplets; i++)
246 // if ( !usedTriplets[i] ) nLeft++;
247  // some stats
248 // std::cout << " [QuadrupletSeedMerger::mergeTriplets] -- Created: " << theResult.size()
249 // << " quadruplets from: " << nInputTriplets << " input triplets (" << nLeft
250 // << " remaining ";
251 // std::cout << (isAddRemainingTriplets_?"added":"dropped");
252 // std::cout << ")." << std::endl;
253 
254  return quads_;
255 
256 }
virtual unsigned int size() const =0
ctfseeding::SeedingLayerSets theLayerSets_
std::pair< double, double > calculatePhiEta(SeedingHitSet const &) const
int sharedHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &)
tuple s2
Definition: indexGen.py:106
U second(std::pair< T, U > const &p)
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:18
bool first
Definition: L1TdeRCT.cc:94
bool isMergeableHitsInTriplets(const SeedingHitSet &firstTriplet, const SeedingHitSet &secondTriplet, const SeedMergerPixelLayer &nonShared1, const SeedMergerPixelLayer &nonShared2, std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &hits, const TrackerTopology *tTopo) const
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::vector< TransientTrackingRecHit::ConstRecHitPointer > mySort(TransientTrackingRecHit::ConstRecHitPointer &h1, TransientTrackingRecHit::ConstRecHitPointer &h2, TransientTrackingRecHit::ConstRecHitPointer &h3, TransientTrackingRecHit::ConstRecHitPointer &h4)
tuple cout
Definition: gather_cfg.py:121
bool isValidQuadruplet(std::vector< TransientTrackingRecHit::ConstRecHitPointer > &quadruplet, const std::vector< SeedMergerPixelLayer > &layers, const TrackerTopology *tTopo) const
tuple size
Write out results.
bool isTripletsShareHitsOnLayers(const SeedingHitSet &firstTriplet, const SeedingHitSet &secondTriplet, const SeedMergerPixelLayer &share1, const SeedMergerPixelLayer &share2, std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &hits, const TrackerTopology *tTopo) const
const TrajectorySeedCollection QuadrupletSeedMerger::mergeTriplets ( const TrajectorySeedCollection seedCollection,
const TrackingRegion region,
const edm::EventSetup es,
const edm::ParameterSet cfg 
)

merge triplets into quadruplets INPUT: TrajectorySeedCollection OUTPUT: TrajectorySeedCollection

this is a wrapper for: vector<SeedingHitSet> mergeTriplets( const OrderedSeedingHits& ) for use in RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromRegionHitsEDProducer.cc (iterative tracking)

Definition at line 270 of file QuadrupletSeedMerger.cc.

References gather_cfg::cout, edm::EventSetup::get(), reco::get(), edm::ParameterSet::getParameter(), i, isMergeTriplets_, mergeTriplets(), OrderedSeedingHits::size(), AlCaHLTBitMon_QueryRunRegistry::string, theTTRHBuilder_, and theTTRHBuilderLabel_.

273  {
274 
275  // ttrh builder for HitSet -> TrajectorySeed conversion;
276  // require this to be correctly configured, otherwise -> exception
278 
279  // output collection
280  TrajectorySeedCollection theResult;
281 
282  // loop to see if we have triplets ONLY
283  // if not, copy input -> output and return
284  bool isAllTriplets = true;
285  for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
286  aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
287  if( 3 != aTrajectorySeed->nHits() ) isAllTriplets = false;
288  }
289 
290  if( !isAllTriplets && isMergeTriplets_ )
291  std::cout << " [QuadrupletSeedMerger::mergeTriplets] (in RECO) -- bailing out since non-triplets in input." << std::endl;
292 
293  if( !isAllTriplets || !isMergeTriplets_ ) {
294  for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
295  aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
296  theResult.push_back( *aTrajectorySeed );
297  }
298 
299  return theResult;
300  }
301 
302 
303  // all this fiddling here is now about converting
304  // TrajectorySeedCollection <-> OrderedSeedingHits
305 
306  // create OrderedSeedingHits first;
307  OrderedHitTriplets inputTriplets;
308 
309  // loop seeds
310  for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
311  aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
312 
313  std::vector<TransientTrackingRecHit::RecHitPointer> recHitPointers;
314 
315  // loop RecHits
316  const TrajectorySeed::range theHitsRange = aTrajectorySeed->recHits();
317  for( edm::OwnVector<TrackingRecHit>::const_iterator aHit = theHitsRange.first;
318  aHit < theHitsRange.second; ++aHit ) {
319 
320  // this is a collection of: ReferenceCountingPointer< TransientTrackingRecHit>
321  recHitPointers.push_back( theTTRHBuilder_->build( &(*aHit) ) );
322 
323  }
324 
325  // add to input collection
326  inputTriplets.push_back( OrderedHitTriplet( recHitPointers.at( 0 ), recHitPointers.at( 1 ), recHitPointers.at( 2 ) ) );
327 
328  }
329 
330  // do the real merging..
331  const OrderedSeedingHits &quadrupletHitSets = mergeTriplets( inputTriplets, es );
332 
333  // convert back to TrajectorySeedCollection
334 
335  // the idea here is to fetch the same SeedCreator and PSet
336  // as those used by the plugin which is calling the merger
337  // (at the moment that's SeedGeneratorFromRegionHitsEDProducer)
338  edm::ParameterSet creatorPSet = cfg.getParameter<edm::ParameterSet>("SeedCreatorPSet");
339  std::string const& creatorName = creatorPSet.getParameter<std::string>( "ComponentName" );
340  // leak????
341  SeedCreator* seedCreator = SeedCreatorFactory::get()->create( creatorName, creatorPSet );
342  seedCreator->init(region, es, 0);
343  for ( unsigned int i=0; i< quadrupletHitSets.size(); i++) {
344  // add trajectory seed to result collection
345  seedCreator->makeSeed( theResult, quadrupletHitSets[i]);
346  }
347 
348  return theResult;
349 
350 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
virtual unsigned int size() const =0
std::vector< TrajectorySeed > TrajectorySeedCollection
std::pair< const_iterator, const_iterator > range
const T & get() const
Definition: EventSetup.h:55
const OrderedSeedingHits & mergeTriplets(const OrderedSeedingHits &, const edm::EventSetup &)
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder_
tuple cout
Definition: gather_cfg.py:121
T get(const Candidate &c)
Definition: component.h:56

Definition at line 793 of file QuadrupletSeedMerger.cc.

References geometryDiff::geom1, p1, theTrackerGeometry_, GeomDet::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by mergeTriplets().

796  {
797  // create an intermediate vector with all hits
798  std::vector<TransientTrackingRecHit::ConstRecHitPointer> unsortedHits;
799  unsortedHits.reserve(4);
800  unsortedHits.push_back( h1);
801  unsortedHits.push_back( h2);
802  unsortedHits.push_back( h3);
803  unsortedHits.push_back( h4);
804 
805  float radiiSq[4];
806  for ( unsigned int iR=0; iR<4; iR++){
807  const GeomDet* geom1=theTrackerGeometry_->idToDet( unsortedHits[iR]->hit()->geographicalId() );
808  GlobalPoint p1=geom1->toGlobal( unsortedHits[iR]->hit()->localPosition() );
809  radiiSq[iR]=( p1.x()*p1.x()+p1.y()*p1.y()); // no need to take the sqrt
810  }
812  float tempFloat=0.;
813  for ( unsigned int iR1=0; iR1<3; iR1++) {
814  for ( unsigned int iR2=iR1+1; iR2<4; iR2++) {
815  if (radiiSq[iR1]>radiiSq[iR2]) {
816  tempRHP=unsortedHits[iR1];
817  unsortedHits[iR1]=unsortedHits[iR2];
818  unsortedHits[iR2]=tempRHP;
819  tempFloat=radiiSq[iR1];
820  radiiSq[iR1]=radiiSq[iR2];
821  radiiSq[iR2]=tempFloat;
822  }
823  }
824  }
825  return unsortedHits;
826 }
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
T y() const
Definition: PV3DBase.h:63
double p1[4]
Definition: TauolaWrapper.h:89
T x() const
Definition: PV3DBase.h:62
void QuadrupletSeedMerger::printHit ( const TrackingRecHit aHit) const

Definition at line 428 of file QuadrupletSeedMerger.cc.

References gather_cfg::cout, TrackingRecHit::geographicalId(), TrackingRecHit::localPosition(), PV3DBase< T, PVType, FrameType >::perp(), GloballyPositioned< T >::position(), alignCSCRings::r, GeomDet::surface(), theTrackerGeometry_, GeomDet::toGlobal(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by printHit().

428  {
429 
430  const GeomDet* geomDet = theTrackerGeometry_->idToDet( aHit->geographicalId() );
431  const double r = geomDet->surface().position().perp();
432  const double x = geomDet->toGlobal( aHit->localPosition() ).x();
433  const double y = geomDet->toGlobal( aHit->localPosition() ).y();
434  const double z = geomDet->toGlobal( aHit->localPosition() ).z();
435  std::cout << "<RecHit> x: " << x << " y: " << y << " z: " << z << " r: " << r << std::endl;
436 
437 }
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
T perp() const
Definition: PV3DBase.h:72
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
float float float z
tuple cout
Definition: gather_cfg.py:121
DetId geographicalId() const
Definition: DDAxes.h:10
virtual LocalPoint localPosition() const =0
const PositionType & position() const
void QuadrupletSeedMerger::printHit ( const TransientTrackingRecHit::ConstRecHitPointer aRecHitPointer) const

Definition at line 417 of file QuadrupletSeedMerger.cc.

References printHit().

417  {
418 
419  printHit( aRecHitPointer->hit() );
420 
421 }
void printHit(const TrackingRecHit *) const
void QuadrupletSeedMerger::printNtuplet ( const SeedingHitSet aNtuplet) const

Definition at line 442 of file QuadrupletSeedMerger.cc.

References gather_cfg::cout, PixelEndcapName::diskName(), TrackingRecHit::geographicalId(), PixelBarrelName::layerName(), TrackingRecHit::localPosition(), PixelSubdetector::PixelBarrel, alignCSCRings::r, SeedingHitSet::size(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, DetId::subdetId(), theTrackerGeometry_, GeomDet::toGlobal(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

442  {
443 
444  std::cout << "DUMPING NTUPLET OF SIZE:";
445  std::cout << aNtuplet.size() << std::endl;
446 
447  for( unsigned int aHit = 0; aHit < aNtuplet.size(); ++aHit ) {
448 
449  const TrackingRecHit* theHit = aNtuplet[aHit]->hit();
450  const GeomDet* geomDet = theTrackerGeometry_->idToDet( theHit->geographicalId() );
451  const double x = geomDet->toGlobal( theHit->localPosition() ).x();
452  const double y = geomDet->toGlobal( theHit->localPosition() ).y();
453  const double z = geomDet->toGlobal( theHit->localPosition() ).z();
454  const double r = sqrt( x*x + y*y );
455 
456  unsigned int layer;
457  std::string detName;
459  detName = "BPIX ";
460  PixelBarrelName pbn( aNtuplet[aHit]->hit()->geographicalId());
461  layer = pbn.layerName();
462  }
463  else {
464  detName = "FPIX";
465  if( z > 0 ) detName += "+";
466  else detName += "-";
467 
468  PixelEndcapName pen( theHit->geographicalId() );
469  layer = pen.diskName();
470  }
471 
472  std::cout << "<NtupletHit> D: " << detName << " L: " << layer << " x: " << x << " y: " << y << " z: " << z << " r: " << r << std::endl;
473 
474 }
475 
476  std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
477 
478 }
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
float float float z
T sqrt(T t)
Definition: SSEVec.h:48
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
unsigned int size() const
Definition: SeedingHitSet.h:40
tuple cout
Definition: gather_cfg.py:121
int diskName() const
disk id
DetId geographicalId() const
Definition: DDAxes.h:10
virtual LocalPoint localPosition() const =0
void QuadrupletSeedMerger::setAddRemainingTriplets ( bool  isAddTriplets)

Definition at line 514 of file QuadrupletSeedMerger.cc.

References isAddRemainingTriplets_.

514  {
515  isAddRemainingTriplets_ = isAddTriplets;
516 }
void QuadrupletSeedMerger::setLayerListName ( std::string  layerListName)

Definition at line 496 of file QuadrupletSeedMerger.cc.

References layerListName_.

496  {
497  layerListName_ = layerListName;
498 }
void QuadrupletSeedMerger::setMergeTriplets ( bool  isMergeTriplets)

Definition at line 505 of file QuadrupletSeedMerger.cc.

References isMergeTriplets_.

505  {
506  isMergeTriplets_ = isMergeTriplets;
507 }
void QuadrupletSeedMerger::setTTRHBuilderLabel ( std::string  label)

Definition at line 485 of file QuadrupletSeedMerger.cc.

References diffTwoXMLs::label, and theTTRHBuilderLabel_.

485  {
486 
488 
489 }
void QuadrupletSeedMerger::update ( const edm::EventSetup es)

Definition at line 45 of file QuadrupletSeedMerger.cc.

References edm::EventSetup::get(), and theTrackerGeometry_.

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), PixelTrackReconstruction::init(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), SeedGeneratorFromRegionHitsEDProducer::produce(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

45  {
46  // copy geometry
48 }
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
const T & get() const
Definition: EventSetup.h:55

Member Data Documentation

bool QuadrupletSeedMerger::isAddRemainingTriplets_
private
bool QuadrupletSeedMerger::isMergeTriplets_
private

Definition at line 134 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets(), QuadrupletSeedMerger(), and setMergeTriplets().

std::string QuadrupletSeedMerger::layerListName_
private

Definition at line 133 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets(), QuadrupletSeedMerger(), and setLayerListName().

OrderedHitSeeds QuadrupletSeedMerger::quads_
private

Definition at line 137 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

ctfseeding::SeedingLayerSets QuadrupletSeedMerger::theLayerSets_
private

Definition at line 130 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

edm::ESHandle<TrackerGeometry> QuadrupletSeedMerger::theTrackerGeometry_
private

Definition at line 131 of file QuadrupletSeedMerger.h.

Referenced by calculatePhiEta(), mySort(), printHit(), printNtuplet(), and update().

edm::ESHandle<TransientTrackingRecHitBuilder> QuadrupletSeedMerger::theTTRHBuilder_
private

Definition at line 132 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

std::string QuadrupletSeedMerger::theTTRHBuilderLabel_
private

Definition at line 136 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets(), and setTTRHBuilderLabel().