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