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 Types | Private Member Functions | Private Attributes
QuadrupletSeedMerger Class Reference

#include <QuadrupletSeedMerger.h>

Public Member Functions

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

Private Types

typedef std::array
< SeedingHitSet::ConstRecHitPointer, 4 > 
QuadrupletHits
 

Private Member Functions

bool isValidQuadruplet (const QuadrupletHits &quadruplet, const std::vector< SeedMergerPixelLayer > &layers, const TrackerTopology *tTopo) const
 
void mySort (QuadrupletHits &unsortedHits)
 
 QuadrupletSeedMerger (const edm::ParameterSet &iConfig, SeedCreator *seedCreator, edm::ConsumesCollector &iC)
 

Private Attributes

bool isAddRemainingTriplets_
 
bool isMergeTriplets_
 
OrderedHitSeeds quads_
 
SeedingLayerSetsBuilder theLayerBuilder_
 
ctfseeding::SeedingLayerSets theLayerSets_
 
std::unique_ptr< SeedCreatortheSeedCreator_
 
edm::ESHandle< TrackerGeometrytheTrackerGeometry_
 
edm::ESHandle
< TransientTrackingRecHitBuilder
theTTRHBuilder_
 
std::string theTTRHBuilderLabel_
 

Detailed Description

merge triplets into quadruplets

Definition at line 76 of file QuadrupletSeedMerger.h.

Member Typedef Documentation

Definition at line 96 of file QuadrupletSeedMerger.h.

Constructor & Destructor Documentation

QuadrupletSeedMerger::QuadrupletSeedMerger ( const edm::ParameterSet iConfig,
edm::ConsumesCollector iC 
)
explicit

Definition at line 73 of file QuadrupletSeedMerger.cc.

73  :
74  QuadrupletSeedMerger(iConfig, nullptr, iC) {}
QuadrupletSeedMerger(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
QuadrupletSeedMerger::QuadrupletSeedMerger ( const edm::ParameterSet iConfig,
const edm::ParameterSet seedCreatorConfig,
edm::ConsumesCollector iC 
)

Definition at line 75 of file QuadrupletSeedMerger.cc.

75  :
76  QuadrupletSeedMerger(iConfig, createSeedCreator(seedCreatorConfig), iC) {}
QuadrupletSeedMerger(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
QuadrupletSeedMerger::~QuadrupletSeedMerger ( )

Definition at line 97 of file QuadrupletSeedMerger.cc.

97  {
98 
99 }
QuadrupletSeedMerger::QuadrupletSeedMerger ( const edm::ParameterSet iConfig,
SeedCreator seedCreator,
edm::ConsumesCollector iC 
)
private

Definition at line 77 of file QuadrupletSeedMerger.cc.

References isAddRemainingTriplets_, and isMergeTriplets_.

77  :
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 }
std::unique_ptr< SeedCreator > theSeedCreator_
SeedingLayerSetsBuilder theLayerBuilder_

Member Function Documentation

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

Definition at line 486 of file QuadrupletSeedMerger.cc.

References eta(), p1, p2, phi, funct::sqr(), mathSSE::sqrt(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by mergeTriplets().

486  {
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 }
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
Square< F >::type sqr(const F &f)
Definition: Square.h:13
T x() const
Definition: PV3DBase.h:62
Definition: DDAxes.h:10
bool QuadrupletSeedMerger::isValidQuadruplet ( const QuadrupletHits 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 607 of file QuadrupletSeedMerger.cc.

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

Referenced by mergeTriplets().

607  {
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 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
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 113 of file QuadrupletSeedMerger.cc.

References a, assert(), b, KDTreeLinkerAlgo< DATA >::build(), calculatePhiEta(), SeedingLayerSetsBuilder::check(), constexpr, gather_cfg::cout, eta(), edm::EventSetup::get(), i, isAddRemainingTriplets_, isMergeTriplets_, isValidQuadruplet(), j, SeedingLayerSetsBuilder::layers(), bookConverter::max, maxEta, min(), benchmark_cfg::minEta, mySort(), class-composition::nodes, phi, edm::ESHandle< class >::product(), quads_, indexGen::s2, KDTreeLinkerAlgo< DATA >::search(), EgAmbiguityTools::sharedHits(), OrderedSeedingHits::size(), findQualityFiles::size, python.multivaluedict::sort(), theLayerBuilder_, theLayerSets_, and Geom::twoPi().

Referenced by mergeTriplets().

113  {
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 }
int i
Definition: DBlmapReader.cc:9
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es)
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox &region)
assert(m_qm.get())
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)
std::pair< double, double > calculatePhiEta(SeedingHitSet const &) const
#define constexpr
void mySort(QuadrupletHits &unsortedHits)
int sharedHits(const reco::GsfTrackRef &, const reco::GsfTrackRef &)
tuple s2
Definition: indexGen.py:106
int j
Definition: DBlmapReader.cc:9
std::array< SeedingHitSet::ConstRecHitPointer, 4 > QuadrupletHits
T min(T a, T b)
Definition: MathUtil.h:58
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
double twoPi()
Definition: Pi.h:32
bool isValidQuadruplet(const QuadrupletHits &quadruplet, const std::vector< SeedMergerPixelLayer > &layers, const TrackerTopology *tTopo) const
tuple cout
Definition: gather_cfg.py:121
SeedingLayerSetsBuilder theLayerBuilder_
tuple size
Write out results.
Definition: DDAxes.h:10
const TrajectorySeedCollection QuadrupletSeedMerger::mergeTriplets ( const TrajectorySeedCollection seedCollection,
const TrackingRegion region,
const edm::EventSetup es 
)

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 405 of file QuadrupletSeedMerger.cc.

References gather_cfg::cout, edm::EventSetup::get(), i, isMergeTriplets_, mergeTriplets(), OrderedSeedingHits::size(), theSeedCreator_, theTTRHBuilder_, and theTTRHBuilderLabel_.

407  {
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 }
int i
Definition: DBlmapReader.cc:9
virtual unsigned int size() const =0
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
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_
std::unique_ptr< SeedCreator > theSeedCreator_
tuple cout
Definition: gather_cfg.py:121
void QuadrupletSeedMerger::mySort ( QuadrupletHits unsortedHits)
private

Definition at line 727 of file QuadrupletSeedMerger.cc.

References p1, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by mergeTriplets().

727  {
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 }
T y() const
Definition: PV3DBase.h:63
BaseTrackerRecHit const * ConstRecHitPointer
Definition: SeedingHitSet.h:11
double p1[4]
Definition: TauolaWrapper.h:89
T x() const
Definition: PV3DBase.h:62
void QuadrupletSeedMerger::printHit ( const TrackingRecHit aHit) const

Definition at line 519 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.

519  {
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 }
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:52
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:40
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::printNtuplet ( const SeedingHitSet aNtuplet) const

Definition at line 533 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.

533  {
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 }
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:52
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:37
unsigned int size() const
Definition: SeedingHitSet.h:44
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 596 of file QuadrupletSeedMerger.cc.

References isAddRemainingTriplets_.

596  {
597  isAddRemainingTriplets_ = isAddTriplets;
598 }
void QuadrupletSeedMerger::setMergeTriplets ( bool  isMergeTriplets)

Definition at line 587 of file QuadrupletSeedMerger.cc.

References isMergeTriplets_.

587  {
588  isMergeTriplets_ = isMergeTriplets;
589 }
void QuadrupletSeedMerger::setTTRHBuilderLabel ( std::string  label)

Definition at line 576 of file QuadrupletSeedMerger.cc.

References diffTwoXMLs::label, and theTTRHBuilderLabel_.

576  {
577 
579 
580 }
void QuadrupletSeedMerger::update ( const edm::EventSetup es)

Definition at line 89 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(), 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(), 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().

89  {
90  // copy geometry
92 }
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 111 of file QuadrupletSeedMerger.h.

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

OrderedHitSeeds QuadrupletSeedMerger::quads_
private

Definition at line 114 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

SeedingLayerSetsBuilder QuadrupletSeedMerger::theLayerBuilder_
private

Definition at line 106 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

ctfseeding::SeedingLayerSets QuadrupletSeedMerger::theLayerSets_
private

Definition at line 107 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

std::unique_ptr<SeedCreator> QuadrupletSeedMerger::theSeedCreator_
private

Definition at line 110 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

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

Definition at line 108 of file QuadrupletSeedMerger.h.

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

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

Definition at line 109 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets().

std::string QuadrupletSeedMerger::theTTRHBuilderLabel_
private

Definition at line 113 of file QuadrupletSeedMerger.h.

Referenced by mergeTriplets(), and setTTRHBuilderLabel().