CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QuadrupletSeedMerger.cc
Go to the documentation of this file.
5 
6 
8 
9 #include <algorithm>
10 
11 namespace {
12  template <typename T>
13  constexpr T sqr(T x) {
14  return x*x;
15  }
16 }
17 
18 /***
19 
20 QuadrupletSeedMerger
21 
22 * merge triplet into quadruplet seeds
23  for either SeedingHitSets or TrajectorySeeds
24 
25 * method:
26  QuadrupletSeedMerger::mergeTriplets( const OrderedSeedingHits&, const edm::EventSetup& ) const
27  for use in HLT with: RecoPixelVertexing/PixelTrackFitting/src/PixelTrackReconstruction.cc
28  contains the merging functionality
29 
30 * method:
31  QuadrupletSeedMerger::mergeTriplets( const TrajectorySeedCollection&, TrackingRegion&, EventSetup& ) const
32  is a wrapper for the former, running on TrajectorySeeds
33  for use in iterative tracking with: RecoTracker/TkSeedGenerator/plugins/SeedGeneratorFromRegionHitsEDProducer
34 
35 ***/
36 
37 
38 // Helper functions
39 namespace {
40  bool areHitsOnLayers(const SeedMergerPixelLayer& layer1, const SeedMergerPixelLayer& layer2,
41  const std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>& hits,
42  const TrackerTopology *tTopo) {
43  DetId firstHitId = hits.first->geographicalId();
44  DetId secondHitId = hits.second->geographicalId();
45  return ((layer1.isContainsDetector(firstHitId, tTopo) &&
46  layer2.isContainsDetector(secondHitId, tTopo)) ||
47  (layer1.isContainsDetector(secondHitId, tTopo) &&
48  layer2.isContainsDetector(firstHitId, tTopo)));
49  }
50 
51  bool areHitsEqual(const TransientTrackingRecHit& hit1, const TransientTrackingRecHit& hit2) {
52  constexpr double epsilon = 0.00001;
53  if(hit1.geographicalId() != hit2.geographicalId())
54  return false;
55 
56  LocalPoint lp1 = hit1.localPosition(), lp2 = hit2.localPosition();
57  return std::abs(lp1.x() - lp2.x()) < epsilon && std::abs(lp1.y() - lp2.y()) < epsilon;
58  }
59 }
60 
61 
62 
67  theLayerBuilder_(iConfig, iC)
68  {
69 
70  // by default, do not..
71  // ..merge triplets
72  isMergeTriplets_ = false;
73  // ..add remaining triplets
75 }
76 
78  // copy geometry
80 }
81 
86 
87 }
88 
89 
90 
99 
100 //const std::vector<SeedingHitSet> QuadrupletSeedMerger::mergeTriplets( const OrderedSeedingHits& inputTriplets, const edm::EventSetup& es ) {
102 
103  //Retrieve tracker topology from geometry
105  es.get<IdealGeometryRecord>().get(tTopoHand);
106  const TrackerTopology *tTopo=tTopoHand.product();
107 
108  // the list of layers on which quadruplets should be formed
109  if(theLayerBuilder_.check(es)) {
110  theLayerSets_ = theLayerBuilder_.layers( es ); // this is a vector<vector<SeedingLayer> >
111  }
112 
113 
114  // make a working copy of the input triplets
115  // to be able to remove merged triplets
116 
117  std::vector<std::pair<double,double> > phiEtaCache;
118  std::vector<SeedingHitSet> tripletCache; //somethings strange about OrderedSeedingHits?
119 
120  const unsigned int nInputTriplets = inputTriplets.size();
121  phiEtaCache.reserve(nInputTriplets);
122  tripletCache.reserve(nInputTriplets);
123 
124  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
125  tripletCache.push_back((inputTriplets[it]));
126  phiEtaCache.push_back(calculatePhiEta( (tripletCache[it]) ));
127 
128  }
129 
130  // the output
131  quads_.clear();
132 
133  // check if the input is all triplets
134  // (code is also used for pairs..)
135  // if not, copy the input to the output & return
136  bool isAllTriplets = true;
137  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
138  if( tripletCache[it].size() != 3 ) {
139  isAllTriplets = false;
140  break;
141  }
142  }
143 
144  if( !isAllTriplets && isMergeTriplets_ )
145  std::cout << "[QuadrupletSeedMerger::mergeTriplets] (in HLT) ** bailing out since non-triplets in input." << std::endl;
146 
147  if( !isAllTriplets || !isMergeTriplets_ ) {
148  quads_.reserve(nInputTriplets);
149  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
150  quads_.push_back( (tripletCache[it]));
151  }
152 
153  return quads_;
154  }
155 
156 
157  quads_.reserve(0.2*nInputTriplets); //rough guess
158 
159  // loop all possible 4-layer combinations
160  // as specified in python/quadrupletseedmerging_cff.py
161 
162  std::vector<bool> usedTriplets(nInputTriplets,false);
163  std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> sharedHits;
164  std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> nonSharedHits;
165 
166  // k-d tree, indices are (th)eta, phi
167  // build the tree
168  std::vector<KDTreeNodeInfo<unsigned int> > nodes;
169  std::vector<unsigned int> foundNodes;
170  nodes.reserve(2*nInputTriplets);
171  foundNodes.reserve(100);
173  double minEta=1e10, maxEta=-1e10;
174  for(unsigned int it=0; it < nInputTriplets; ++it) {
175  double phi = phiEtaCache[it].first;
176  double eta = phiEtaCache[it].second;
177  nodes.push_back(KDTreeNodeInfo<unsigned int>(it, eta, phi));
178  minEta = std::min(minEta, eta);
179  maxEta = std::max(maxEta, eta);
180 
181  // to wrap all points in phi
182  // if(phi < 0) phi += twoPi(); else phi -= twoPi();
183  double twoPi = std::copysign(Geom::twoPi(), phi);
184  nodes.push_back(KDTreeNodeInfo<unsigned int>(it, eta, phi-twoPi));
185  }
186  KDTreeBox kdEtaPhi(minEta-0.01, maxEta+0.01, -1*Geom::twoPi(), Geom::twoPi());
187  kdtree.build(nodes, kdEtaPhi);
188  nodes.clear();
189 
190  // loop over triplets, search for close-by triplets by using the k-d tree
191  // also identify the hits which are shared by triplet pairs, and
192  // store indices to hits which are not shared
193  std::vector<unsigned int> t1List;
194  std::vector<unsigned int> t2List;
195  std::vector<short> t1NonSharedHitList;
196  std::vector<short> t2NonSharedHitList;
197  constexpr short sharedToNonShared[7] = {-1, -1, -1,
198  2, // 011=3 shared, not shared = 2
199  -1,
200  1, // 101=5 shared, not shared = 1
201  0}; // 110=6 shared, not shared = 0
202  constexpr short nonSharedToShared[3][2] = {
203  {1, 2},
204  {0, 2},
205  {0, 1}
206  };
207 
208  typedef std::tuple<unsigned int, short, short> T2NonSharedTuple;
209  std::vector<T2NonSharedTuple> t2Tmp; // temporary to sort t2's before insertion to t2List
210  for(unsigned int t1=0; t1<nInputTriplets; ++t1) {
211  double phi = phiEtaCache[t1].first;
212  double eta = phiEtaCache[t1].second;
213 
214  KDTreeBox box(eta-0.05, eta+0.05, phi-0.15, phi+0.15);
215  foundNodes.clear();
216  kdtree.search(box, foundNodes);
217  if(foundNodes.empty())
218  continue;
219 
220  const SeedingHitSet& tr1 = tripletCache[t1];
221 
222  for(unsigned int t2: foundNodes) {
223  if(t1 >= t2)
224  continue;
225 
226  // Ensure here that the triplet pairs share two hits.
227  const SeedingHitSet& tr2 = tripletCache[t2];
228 
229  // If neither of first two hits in tr1 are found from tr2, this
230  // pair can be skipped
231  int equalHits=0;
232  // Find the indices of shared hits in both t1 and t2, use them
233  // to obtain the index of non-shared hit for both. The index of
234  // non-shared hit is then stored for later use (the indices of
235  // shared hits can be easily obtained from them).
236  unsigned int t1Shared = 0;
237  unsigned int t2Shared = 0;
238  for(unsigned int i=0; i<2; ++i) {
239  for(unsigned int j=0; j<3; ++j) {
240  if(areHitsEqual(*tr1[i], *tr2[j])) {
241  t1Shared |= (1<<i);
242  t2Shared |= (1<<j);
243  ++equalHits;
244  break;
245  }
246  }
247  }
248  if(equalHits == 0)
249  continue;
250  // If, after including the third hit of tr1, number of equal
251  // hits is not 2, this pair can be skipped
252  if(equalHits != 2) {
253  for(unsigned int j=0; j<3; ++j) {
254  if(areHitsEqual(*tr1[2], *tr2[j])) {
255  t1Shared |= (1<<2);
256  t2Shared |= (1<<j);
257  ++equalHits;
258  break;
259  }
260  }
261  if(equalHits != 2)
262  continue;
263  }
264  // valid values for the bitfields are 011=3, 101=5, 110=6
265  assert(t1Shared <= 6 && t2Shared <= 6); // against out-of-bounds of sharedToNonShared[]
266  short t1NonShared = sharedToNonShared[t1Shared];
267  short t2NonShared = sharedToNonShared[t2Shared];
268  assert(t1NonShared >= 0 && t2NonShared >= 0); // against invalid value from sharedToNonShared[]
269 
270  t2Tmp.emplace_back(t2, t1NonShared, t2NonShared);
271  }
272 
273  // Sort to increasing order in t2 in order to get exactly same result as before
274  std::sort(t2Tmp.begin(), t2Tmp.end(), [](const T2NonSharedTuple& a, const T2NonSharedTuple& b){
275  return std::get<0>(a) < std::get<0>(b);
276  });
277  for(T2NonSharedTuple& t2tpl: t2Tmp) {
278  t1List.push_back(t1);
279  t2List.push_back(std::get<0>(t2tpl));
280  t1NonSharedHitList.push_back(std::get<1>(t2tpl));
281  t2NonSharedHitList.push_back(std::get<2>(t2tpl));
282  }
283  t2Tmp.clear();
284  }
285  nodes.clear();
286 
287  for( ctfseeding::SeedingLayerSets::const_iterator lsIt = theLayerSets_.begin(); lsIt < theLayerSets_.end(); ++lsIt ) {
288 
289  // fill a vector with the layers in this set
290  std::vector<SeedMergerPixelLayer> currentLayers;
291  currentLayers.reserve(lsIt->size());
292  for( ctfseeding::SeedingLayers::const_iterator layIt = lsIt->begin(); layIt < lsIt->end(); ++layIt ) {
293  currentLayers.push_back( SeedMergerPixelLayer( layIt->name() ) );
294  }
295  // loop all pair combinations of these 4 layers;
296  // strategy is to look for shared hits on such a pair and
297  // then merge the remaining hits in both triplets if feasible
298  // (SeedingLayers is a vector<SeedingLayer>)
299 
300  for( unsigned int s1=0; s1<currentLayers.size()-1; s1++) {
301 
302  for( unsigned int s2=s1+1; s2<currentLayers.size(); s2++) {
303 
304  std::vector<unsigned int> nonSharedLayerNums;
305  for ( unsigned int us1=0; us1<currentLayers.size(); us1++) {
306  if ( s1!=us1 && s2!=us1) nonSharedLayerNums.push_back(us1);
307  }
308 
309  // loop all possible triplet pairs (which come as input)
310  for (unsigned int t12=0; t12<t1List.size(); t12++) {
311  unsigned int t1=t1List[t12];
312  unsigned int t2=t2List[t12];
313 
314  if (usedTriplets[t1] || usedTriplets[t2] ) continue;
315 
316  const SeedingHitSet& firstTriplet = tripletCache[t1];
317 
318  short t1NonShared = t1NonSharedHitList[t12];
319  sharedHits.first = firstTriplet[nonSharedToShared[t1NonShared][0]];
320  sharedHits.second = firstTriplet[nonSharedToShared[t1NonShared][1]];
321 
322  // are the shared hits on these two layers?
323  if(areHitsOnLayers(currentLayers[s1], currentLayers[s2], sharedHits, tTopo)) {
324  short t2NonShared = t2NonSharedHitList[t12];
325  const SeedingHitSet& secondTriplet = tripletCache[t2];
326  nonSharedHits.first = firstTriplet[t1NonShared];
327  nonSharedHits.second = secondTriplet[t2NonShared];
328 
329  // are the remaining hits on different layers?
330  if(areHitsOnLayers(currentLayers[nonSharedLayerNums[0]], currentLayers[nonSharedLayerNums[1]], nonSharedHits, tTopo)) {
331  QuadrupletHits unsortedHits{ {sharedHits.first, sharedHits.second,
332  nonSharedHits.first, nonSharedHits.second} };
333 
334  mySort(unsortedHits);
335 
336  //start here with old addtoresult
337  if( isValidQuadruplet( unsortedHits, currentLayers, tTopo ) ) {
338  // and create the quadruplet
339  SeedingHitSet quadruplet(unsortedHits[0],unsortedHits[1],unsortedHits[2],unsortedHits[3]);
340 
341  // insert this quadruplet
342  quads_.push_back( quadruplet );
343  // remove both triplets from the list,
344  // needs this 4-permutation since we're in a double loop
345  usedTriplets[t1]=true;
346  usedTriplets[t2]=true;
347  }
348 
349  } // isMergeableHitsInTriplets
350  } // isTripletsShareHitsOnLayers
351  // } // triplet double loop
352  }
353  } // seeding layers double loop
354  }
355 
356  } // seeding layer sets
357 
358  // add the remaining triplets
360  for( unsigned int it = 0; it < nInputTriplets; ++it ) {
361  if ( !usedTriplets[it] )
362  quads_.push_back( tripletCache[it]);
363  }
364  }
365 
366  //calc for printout...
367 // unsigned int nLeft=0;
368 // for ( unsigned int i=0; i<nInputTriplets; i++)
369 // if ( !usedTriplets[i] ) nLeft++;
370  // some stats
371 // std::cout << " [QuadrupletSeedMerger::mergeTriplets] -- Created: " << theResult.size()
372 // << " quadruplets from: " << nInputTriplets << " input triplets (" << nLeft
373 // << " remaining ";
374 // std::cout << (isAddRemainingTriplets_?"added":"dropped");
375 // std::cout << ")." << std::endl;
376 
377  return quads_;
378 
379 }
380 
381 
382 
394  const TrackingRegion& region,
395  const edm::EventSetup& es,
396  const edm::ParameterSet& cfg ) {
397 
398  // ttrh builder for HitSet -> TrajectorySeed conversion;
399  // require this to be correctly configured, otherwise -> exception
401 
402  // output collection
403  TrajectorySeedCollection theResult;
404 
405  // loop to see if we have triplets ONLY
406  // if not, copy input -> output and return
407  bool isAllTriplets = true;
408  for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
409  aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
410  if( 3 != aTrajectorySeed->nHits() ) isAllTriplets = false;
411  }
412 
413  if( !isAllTriplets && isMergeTriplets_ )
414  std::cout << " [QuadrupletSeedMerger::mergeTriplets] (in RECO) -- bailing out since non-triplets in input." << std::endl;
415 
416  if( !isAllTriplets || !isMergeTriplets_ ) {
417  for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
418  aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
419  theResult.push_back( *aTrajectorySeed );
420  }
421 
422  return theResult;
423  }
424 
425 
426  // all this fiddling here is now about converting
427  // TrajectorySeedCollection <-> OrderedSeedingHits
428 
429  // create OrderedSeedingHits first;
430  OrderedHitTriplets inputTriplets;
431 
432  // loop seeds
433  for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
434  aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
435 
436  std::vector<TransientTrackingRecHit::RecHitPointer> recHitPointers;
437 
438  // loop RecHits
439  const TrajectorySeed::range theHitsRange = aTrajectorySeed->recHits();
440  for( edm::OwnVector<TrackingRecHit>::const_iterator aHit = theHitsRange.first;
441  aHit < theHitsRange.second; ++aHit ) {
442 
443  // this is a collection of: ReferenceCountingPointer< TransientTrackingRecHit>
444  recHitPointers.push_back( theTTRHBuilder_->build( &(*aHit) ) );
445 
446  }
447 
448  // add to input collection
449  inputTriplets.push_back( OrderedHitTriplet( recHitPointers.at( 0 ), recHitPointers.at( 1 ), recHitPointers.at( 2 ) ) );
450 
451  }
452 
453  // do the real merging..
454  const OrderedSeedingHits &quadrupletHitSets = mergeTriplets( inputTriplets, es );
455 
456  // convert back to TrajectorySeedCollection
457 
458  // the idea here is to fetch the same SeedCreator and PSet
459  // as those used by the plugin which is calling the merger
460  // (at the moment that's SeedGeneratorFromRegionHitsEDProducer)
461  edm::ParameterSet creatorPSet = cfg.getParameter<edm::ParameterSet>("SeedCreatorPSet");
462  std::string const& creatorName = creatorPSet.getParameter<std::string>( "ComponentName" );
463  // leak????
464  SeedCreator* seedCreator = SeedCreatorFactory::get()->create( creatorName, creatorPSet );
465  seedCreator->init(region, es, 0);
466  for ( unsigned int i=0; i< quadrupletHitSets.size(); i++) {
467  // add trajectory seed to result collection
468  seedCreator->makeSeed( theResult, quadrupletHitSets[i]);
469  }
470 
471  return theResult;
472 
473 }
474 
475 
479 std::pair<double,double> QuadrupletSeedMerger::calculatePhiEta( SeedingHitSet const& nTuplet ) const {
480 
481 // if( nTuplet.size() < 3 ) {
482 // std::cerr << " [QuadrupletSeedMerger::calculatePhiEta] ** ERROR: nTuplet has less than 3 hits" << std::endl;
483 // throw; // tbr.
484 // }
485 
486  GlobalPoint p1 = nTuplet[0]->globalPosition();
487  GlobalPoint p2 = nTuplet[1]->globalPosition();
488 
489  const double x1 = p1.x();
490  const double x2 = p2.x();
491  const double y1 = p1.y();
492  const double y2 = p2.y();
493  const double z1 = p1.z();
494  const double z2 = p2.z();
495 
496  const double phi = atan2( x2 - x1, y2 -y1 );
497  const double eta = acos( (z2 - z1) / sqrt( sqr( x2 - x1 ) + sqr( y2 - y1 ) + sqr( z2 - z1 ) ) ); // this is theta angle in reality
498 
499  std::pair<double,double> retVal;
500  retVal=std::make_pair (phi,eta);
501  return retVal;
502  //return std::make_pair<double,double>( phi, eta );
503 
504 }
505 
506 
507 
512 
513  printHit( aRecHitPointer->hit() );
514 
515 }
516 
517 
518 
523 
524  const GeomDet* geomDet = theTrackerGeometry_->idToDet( aHit->geographicalId() );
525  const double r = geomDet->surface().position().perp();
526  const double x = geomDet->toGlobal( aHit->localPosition() ).x();
527  const double y = geomDet->toGlobal( aHit->localPosition() ).y();
528  const double z = geomDet->toGlobal( aHit->localPosition() ).z();
529  std::cout << "<RecHit> x: " << x << " y: " << y << " z: " << z << " r: " << r << std::endl;
530 
531 }
532 
536 void QuadrupletSeedMerger::printNtuplet( const SeedingHitSet& aNtuplet ) const {
537 
538  std::cout << "DUMPING NTUPLET OF SIZE:";
539  std::cout << aNtuplet.size() << std::endl;
540 
541  for( unsigned int aHit = 0; aHit < aNtuplet.size(); ++aHit ) {
542 
543  const TrackingRecHit* theHit = aNtuplet[aHit]->hit();
544  const GeomDet* geomDet = theTrackerGeometry_->idToDet( theHit->geographicalId() );
545  const double x = geomDet->toGlobal( theHit->localPosition() ).x();
546  const double y = geomDet->toGlobal( theHit->localPosition() ).y();
547  const double z = geomDet->toGlobal( theHit->localPosition() ).z();
548  const double r = sqrt( x*x + y*y );
549 
550  unsigned int layer;
551  std::string detName;
553  detName = "BPIX ";
554  PixelBarrelName pbn( aNtuplet[aHit]->hit()->geographicalId());
555  layer = pbn.layerName();
556  }
557  else {
558  detName = "FPIX";
559  if( z > 0 ) detName += "+";
560  else detName += "-";
561 
562  PixelEndcapName pen( theHit->geographicalId() );
563  layer = pen.diskName();
564  }
565 
566  std::cout << "<NtupletHit> D: " << detName << " L: " << layer << " x: " << x << " y: " << y << " z: " << z << " r: " << r << std::endl;
567 
568 }
569 
570  std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
571 
572 }
573 
574 
575 
580 
582 
583 }
584 
585 
586 
590 void QuadrupletSeedMerger::setMergeTriplets( bool isMergeTriplets ) {
591  isMergeTriplets_ = isMergeTriplets;
592 }
593 
594 
595 
600  isAddRemainingTriplets_ = isAddTriplets;
601 }
602 
603 
604 
610 bool QuadrupletSeedMerger::isValidQuadruplet(const QuadrupletHits &quadruplet, const std::vector<SeedMergerPixelLayer>& layers, const TrackerTopology *tTopo) const {
611 
612  const unsigned int quadrupletSize = quadruplet.size();
613 
614  // basic size test..
615  if( quadrupletSize != layers.size() ) {
616  std::cout << " [QuadrupletSeedMerger::isValidQuadruplet] ** WARNING: size mismatch: "
617  << quadrupletSize << "/" << layers.size() << std::endl;
618  return false;
619  }
620 
621  // go along layers and check if all (parallel) quadruplet hits match
622  for( unsigned int index = 0; index < quadrupletSize; ++index ) {
623  if( ! layers[index].isContainsDetector( quadruplet[index]->geographicalId(), tTopo ) ) {
624  return false;
625  }
626  }
627 
628  return true;
629 
630 }
631 
632 
637 
638  if( ! isValidName( name ) ) {
639  std::cerr << " [SeedMergerPixelLayer::SeedMergerPixelLayer] ** ERROR: illegal name: \"" << name << "\"." << std::endl;
640  isValid_ = false;
641  return;
642  }
643 
644  // bare name, can be done here
645  name_ = name;
646 
647  // (output format -> see DataFormats/SiPixelDetId/interface/PixelSubdetector.h)
648  if( std::string::npos != name_.find( "BPix" ) )
650  else if( std::string::npos != name_.find( "FPix" ) )
652  if( std::string::npos != name_.find( "pos", 6 ) ) side_ = Plus;
653  else if( std::string::npos != name_.find( "neg", 6 ) ) side_ = Minus;
654  else {
655  std::cerr << " [PixelLayerNameParser::side] ** ERROR: something's wrong here.." << std::endl;
656  side_ = SideError;
657  }
658  }
659  else {
660  std::cerr << " [PixelLayerNameParser::subdetector] ** ERROR: something's wrong here.." << std::endl;
661  }
662 
663  // layer
664  layer_ = atoi( name_.substr( 4, 1 ).c_str() );
665 
666 }
667 
668 
669 
674 
675  const int layer = atoi( name.substr( 4, 1 ).c_str() );
676 
677  if( std::string::npos != name.find( "BPix" ) ) {
678  if( layer > 0 && layer < 5 ) return true;
679  }
680 
681  else if( std::string::npos != name.find( "FPix" ) ) {
682  if( layer > 0 && layer < 4 ) {
683  if( std::string::npos != name.find( "pos", 6 ) || std::string::npos != name.find( "neg", 6 ) ) return true;
684  }
685 
686  }
687 
688  std::cerr << " [SeedMergerPixelLayer::isValidName] ** WARNING: invalid name: \"" << name << "\"." << std::endl;
689  return false;
690 
691 }
692 
693 
694 
699 bool SeedMergerPixelLayer::isContainsDetector( const DetId& detId, const TrackerTopology *tTopo ) const {
700 
702 
703  // same subdet?
704  if( detId.subdetId() == subdet ) {
705 
706  // same barrel layer?
707  if( PixelSubdetector::PixelBarrel == subdet ) {
708  if (tTopo->pxbLayer(detId) == getLayerNumber()) {
709  return true;
710  }
711  }
712 
713  // same endcap disk?
714  else if( PixelSubdetector::PixelEndcap == subdet ) {
715 
716  if (tTopo->pxfDisk(detId) == getLayerNumber()) {
717  if (tTopo->pxfSide(detId) == (unsigned)getSide()) {
718  return true;
719  }
720  }
721  }
722 
723  }
724 
725  return false;
726 
727 }
728 
729 
730 void QuadrupletSeedMerger::mySort(std::array<TransientTrackingRecHit::ConstRecHitPointer, 4>& unsortedHits) {
731  float radiiSq[4];
732  for ( unsigned int iR=0; iR<4; iR++){
733  GlobalPoint p1 = unsortedHits[iR]->globalPosition();
734  radiiSq[iR]=( p1.x()*p1.x()+p1.y()*p1.y()); // no need to take the sqrt
735  }
737  float tempFloat=0.;
738  for ( unsigned int iR1=0; iR1<3; iR1++) {
739  for ( unsigned int iR2=iR1+1; iR2<4; iR2++) {
740  if (radiiSq[iR1]>radiiSq[iR2]) {
741  tempRHP=unsortedHits[iR1];
742  unsortedHits[iR1]=unsortedHits[iR2];
743  unsortedHits[iR2]=tempRHP;
744  tempFloat=radiiSq[iR1];
745  radiiSq[iR1]=radiiSq[iR2];
746  radiiSq[iR2]=tempFloat;
747  }
748  }
749  }
750 }
751 
752 
753 
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es)
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox &region)
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
T perp() const
Definition: PV3DBase.h:72
void setTTRHBuilderLabel(std::string)
void printNtuplet(const SeedingHitSet &) const
SeedMergerPixelLayer(const std::string &)
unsigned int pxfDisk(const DetId &id) const
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
unsigned getLayerNumber(void) const
QuadrupletSeedMerger(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
T y() const
Definition: PV3DBase.h:63
std::array< TransientTrackingRecHit::ConstRecHitPointer, 4 > QuadrupletHits
double maxEta
virtual unsigned int size() const =0
bool check(const edm::EventSetup &es)
T eta() const
ctfseeding::SeedingLayerSets theLayerSets_
void search(const KDTreeBox &searchBox, std::vector< KDTreeNodeInfo > &resRecHitList)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
std::pair< double, double > calculatePhiEta(SeedingHitSet const &) const
float float float z
PixelSubdetector::SubDetector subdet_
void mySort(QuadrupletHits &unsortedHits)
int sharedHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &)
tuple s2
Definition: indexGen.py:106
std::vector< TrajectorySeed > TrajectorySeedCollection
const T & max(const T &a, const T &b)
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:18
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
PixelSubdetector::SubDetector getSubdet(void) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
std::pair< const_iterator, const_iterator > range
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
double p2[4]
Definition: TauolaWrapper.h:90
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
void update(const edm::EventSetup &)
const T & get() const
Definition: EventSetup.h:55
const OrderedSeedingHits & mergeTriplets(const OrderedSeedingHits &, const edm::EventSetup &)
int layerName() const
layer id
T const * product() const
Definition: ESHandle.h:62
bool isContainsDetector(const DetId &, const TrackerTopology *tTopo) const
double b
Definition: hdecay.h:120
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder_
Side getSide(void) const
double p1[4]
Definition: TauolaWrapper.h:89
double a
Definition: hdecay.h:121
Square< F >::type sqr(const F &f)
Definition: Square.h:13
double twoPi()
Definition: Pi.h:32
unsigned int size() const
Definition: SeedingHitSet.h:41
void printHit(const TrackingRecHit *) const
bool isValidQuadruplet(const QuadrupletHits &quadruplet, const std::vector< SeedMergerPixelLayer > &layers, const TrackerTopology *tTopo) const
unsigned int pxfSide(const DetId &id) const
tuple cout
Definition: gather_cfg.py:121
SeedingLayerSetsBuilder theLayerBuilder_
int diskName() const
disk id
SeedMergerPixelLayer::Side side_
DetId geographicalId() const
const double epsilon
Definition: DDAxes.h:10
long double T
T x() const
Definition: PV3DBase.h:62
virtual LocalPoint localPosition() const =0
const PositionType & position() const
tuple size
Write out results.
T get(const Candidate &c)
Definition: component.h:55
#define constexpr
bool isValidName(const std::string &)
Definition: DDAxes.h:10