41 const std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>& hits,
43 DetId firstHitId = hits.first->geographicalId();
44 DetId secondHitId = hits.second->geographicalId();
119 std::vector<std::pair<double,double> > phiEtaCache;
120 std::vector<SeedingHitSet> tripletCache;
122 const unsigned int nInputTriplets = inputTriplets.
size();
123 phiEtaCache.reserve(nInputTriplets);
124 tripletCache.reserve(nInputTriplets);
126 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
127 tripletCache.push_back((inputTriplets[it]));
138 bool isAllTriplets =
true;
139 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
140 if( tripletCache[it].
size() != 3 ) {
141 isAllTriplets =
false;
147 std::cout <<
"[QuadrupletSeedMerger::mergeTriplets] (in HLT) ** bailing out since non-triplets in input." << std::endl;
150 quads_.reserve(nInputTriplets);
151 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
152 quads_.push_back( (tripletCache[it]));
159 quads_.reserve(0.2*nInputTriplets);
164 std::vector<bool> usedTriplets(nInputTriplets,
false);
165 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>
sharedHits;
166 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> nonSharedHits;
170 std::vector<KDTreeNodeInfo<unsigned int> > nodes;
171 std::vector<unsigned int> foundNodes;
172 nodes.reserve(2*nInputTriplets);
173 foundNodes.reserve(100);
176 for(
unsigned int it=0; it < nInputTriplets; ++it) {
177 double phi = phiEtaCache[it].first;
178 double eta = phiEtaCache[it].second;
189 kdtree.
build(nodes, kdEtaPhi);
195 std::vector<unsigned int> t1List;
196 std::vector<unsigned int> t2List;
197 std::vector<short> t1NonSharedHitList;
198 std::vector<short> t2NonSharedHitList;
199 constexpr short sharedToNonShared[7] = {-1, -1, -1,
204 constexpr short nonSharedToShared[3][2] = {
210 typedef std::tuple<unsigned int, short, short> T2NonSharedTuple;
211 std::vector<T2NonSharedTuple> t2Tmp;
212 for(
unsigned int t1=0; t1<nInputTriplets; ++t1) {
213 double phi = phiEtaCache[t1].first;
214 double eta = phiEtaCache[t1].second;
216 KDTreeBox box(eta-0.05, eta+0.05, phi-0.15, phi+0.15);
218 kdtree.
search(box, foundNodes);
219 if(foundNodes.empty())
224 for(
unsigned int t2: foundNodes) {
238 unsigned int t1Shared = 0;
239 unsigned int t2Shared = 0;
240 for(
unsigned int i=0;
i<2; ++
i) {
241 for(
unsigned int j=0;
j<3; ++
j) {
242 if(areHitsEqual(*tr1[
i], *tr2[
j])) {
255 for(
unsigned int j=0;
j<3; ++
j) {
256 if(areHitsEqual(*tr1[2], *tr2[
j])) {
267 assert(t1Shared <= 6 && t2Shared <= 6);
268 short t1NonShared = sharedToNonShared[t1Shared];
269 short t2NonShared = sharedToNonShared[t2Shared];
270 assert(t1NonShared >= 0 && t2NonShared >= 0);
272 t2Tmp.emplace_back(
t2, t1NonShared, t2NonShared);
276 std::sort(t2Tmp.begin(), t2Tmp.end(), [](
const T2NonSharedTuple&
a,
const T2NonSharedTuple&
b){
277 return std::get<0>(
a) < std::get<0>(
b);
279 for(T2NonSharedTuple& t2tpl: t2Tmp) {
280 t1List.push_back(t1);
281 t2List.push_back(std::get<0>(t2tpl));
282 t1NonSharedHitList.push_back(std::get<1>(t2tpl));
283 t2NonSharedHitList.push_back(std::get<2>(t2tpl));
289 for( ctfseeding::SeedingLayerSets::const_iterator lsIt = theLayerSets_.begin(); lsIt < theLayerSets_.end(); ++lsIt ) {
292 std::vector<SeedMergerPixelLayer> currentLayers;
293 currentLayers.reserve(lsIt->size());
294 for( ctfseeding::SeedingLayers::const_iterator layIt = lsIt->begin(); layIt < lsIt->end(); ++layIt ) {
302 for(
unsigned int s1=0; s1<currentLayers.size()-1; s1++) {
304 for(
unsigned int s2=s1+1;
s2<currentLayers.size();
s2++) {
306 std::vector<unsigned int> nonSharedLayerNums;
307 for (
unsigned int us1=0; us1<currentLayers.size(); us1++) {
308 if ( s1!=us1 &&
s2!=us1) nonSharedLayerNums.push_back(us1);
312 for (
unsigned int t12=0; t12<t1List.size(); t12++) {
313 unsigned int t1=t1List[t12];
314 unsigned int t2=t2List[t12];
316 if (usedTriplets[t1] || usedTriplets[t2] )
continue;
320 short t1NonShared = t1NonSharedHitList[t12];
321 sharedHits.first = firstTriplet[nonSharedToShared[t1NonShared][0]];
322 sharedHits.second = firstTriplet[nonSharedToShared[t1NonShared][1]];
325 if(areHitsOnLayers(currentLayers[s1], currentLayers[
s2], sharedHits, tTopo)) {
326 short t2NonShared = t2NonSharedHitList[t12];
328 nonSharedHits.first = firstTriplet[t1NonShared];
329 nonSharedHits.second = secondTriplet[t2NonShared];
332 if(areHitsOnLayers(currentLayers[nonSharedLayerNums[0]], currentLayers[nonSharedLayerNums[1]], nonSharedHits, tTopo)) {
333 QuadrupletHits unsortedHits{ {sharedHits.first, sharedHits.second,
334 nonSharedHits.first, nonSharedHits.second} };
341 SeedingHitSet quadruplet(unsortedHits[0],unsortedHits[1],unsortedHits[2],unsortedHits[3]);
344 quads_.push_back( quadruplet );
347 usedTriplets[t1]=
true;
348 usedTriplets[
t2]=
true;
362 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
363 if ( !usedTriplets[it] )
364 quads_.push_back( tripletCache[it]);
409 bool isAllTriplets =
true;
410 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
411 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
412 if( 3 != aTrajectorySeed->nHits() ) isAllTriplets =
false;
416 std::cout <<
" [QuadrupletSeedMerger::mergeTriplets] (in RECO) -- bailing out since non-triplets in input." << std::endl;
419 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
420 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
421 theResult.push_back( *aTrajectorySeed );
435 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
436 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
438 std::vector<TransientTrackingRecHit::RecHitPointer> recHitPointers;
443 aHit < theHitsRange.second; ++aHit ) {
451 inputTriplets.push_back(
OrderedHitTriplet( recHitPointers.at( 0 ), recHitPointers.at( 1 ), recHitPointers.at( 2 ) ) );
467 seedCreator->init(region, es, 0);
468 for (
unsigned int i=0;
i< quadrupletHitSets.
size();
i++) {
470 seedCreator->makeSeed( theResult, quadrupletHitSets[
i]);
491 const double x1 = p1.
x();
492 const double x2 = p2.
x();
493 const double y1 = p1.
y();
494 const double y2 = p2.
y();
495 const double z1 = p1.
z();
496 const double z2 = p2.
z();
498 const double phi = atan2( x2 - x1, y2 -y1 );
499 const double eta = acos( (z2 - z1) /
sqrt(
sqr( x2 - x1 ) +
sqr( y2 - y1 ) +
sqr( z2 - z1 ) ) );
501 std::pair<double,double> retVal;
502 retVal=std::make_pair (phi,eta);
531 std::cout <<
"<RecHit> x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
543 for(
unsigned int aHit = 0; aHit < aNtuplet.
size(); ++aHit ) {
550 const double r =
sqrt( x*x + y*y );
561 if( z > 0 ) detName +=
"+";
568 std::cout <<
"<NtupletHit> D: " << detName <<
" L: " << layer <<
" x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
572 std::cout <<
"<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
623 const unsigned int quadrupletSize = quadruplet.size();
626 if( quadrupletSize != layers.size() ) {
627 std::cout <<
" [QuadrupletSeedMerger::isValidQuadruplet] ** WARNING: size mismatch: "
628 << quadrupletSize <<
"/" << layers.size() << std::endl;
634 if( ! layers[
index].isContainsDetector( quadruplet[
index]->geographicalId(), tTopo ) ) {
650 std::cerr <<
" [SeedMergerPixelLayer::SeedMergerPixelLayer] ** ERROR: illegal name: \"" << name <<
"\"." << std::endl;
659 if( std::string::npos !=
name_.find(
"BPix" ) )
661 else if( std::string::npos !=
name_.find(
"FPix" ) )
666 std::cerr <<
" [PixelLayerNameParser::side] ** ERROR: something's wrong here.." << std::endl;
671 std::cerr <<
" [PixelLayerNameParser::subdetector] ** ERROR: something's wrong here.." << std::endl;
686 const int layer = atoi( name.substr( 4, 1 ).c_str() );
688 if( std::string::npos != name.find(
"BPix" ) ) {
689 if( layer > 0 && layer < 5 )
return true;
692 else if( std::string::npos != name.find(
"FPix" ) ) {
693 if( layer > 0 && layer < 4 ) {
694 if( std::string::npos != name.find(
"pos", 6 ) || std::string::npos != name.find(
"neg", 6 ) )
return true;
699 std::cerr <<
" [SeedMergerPixelLayer::isValidName] ** WARNING: invalid name: \"" << name <<
"\"." << std::endl;
743 for (
unsigned int iR=0; iR<4; iR++){
745 radiiSq[iR]=( p1.
x()*p1.
x()+p1.
y()*p1.
y());
749 for (
unsigned int iR1=0; iR1<3; iR1++) {
750 for (
unsigned int iR2=iR1+1; iR2<4; iR2++) {
751 if (radiiSq[iR1]>radiiSq[iR2]) {
752 tempRHP=unsortedHits[iR1];
753 unsortedHits[iR1]=unsortedHits[iR2];
754 unsortedHits[iR2]=tempRHP;
755 tempFloat=radiiSq[iR1];
756 radiiSq[iR1]=radiiSq[iR2];
757 radiiSq[iR2]=tempFloat;
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
T getParameter(std::string const &) const
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox ®ion)
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.
unsigned getLayerNumber(void) const
std::array< TransientTrackingRecHit::ConstRecHitPointer, 4 > QuadrupletHits
virtual unsigned int size() const =0
void setMergeTriplets(bool)
bool isAddRemainingTriplets_
ctfseeding::SeedingLayerSets theLayerSets_
void search(const KDTreeBox &searchBox, std::vector< KDTreeNodeInfo > &resRecHitList)
const Plane & surface() const
The nominal surface of the GeomDet.
std::pair< double, double > calculatePhiEta(SeedingHitSet const &) const
PixelSubdetector::SubDetector subdet_
void mySort(QuadrupletHits &unsortedHits)
std::vector< TrajectorySeed > TrajectorySeedCollection
const T & max(const T &a, const T &b)
auto const T2 &decltype(t1.eta()) t2
PixelSubdetector::SubDetector getSubdet(void) const
Abs< T >::type abs(const T &t)
std::pair< const_iterator, const_iterator > range
void setLayerListName(std::string)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int pxbLayer(const DetId &id) const
void update(const edm::EventSetup &)
const OrderedSeedingHits & mergeTriplets(const OrderedSeedingHits &, const edm::EventSetup &)
int layerName() const
layer id
T const * product() const
bool isContainsDetector(const DetId &, const TrackerTopology *tTopo) const
edm::ESHandle< TransientTrackingRecHitBuilder > theTTRHBuilder_
void setAddRemainingTriplets(bool)
Square< F >::type sqr(const F &f)
std::string theTTRHBuilderLabel_
unsigned int size() const
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::string layerListName_
int diskName() const
disk id
SeedMergerPixelLayer::Side side_
DetId geographicalId() const
virtual LocalPoint localPosition() const =0
const PositionType & position() const
tuple size
Write out results.
T get(const Candidate &c)
bool isValidName(const std::string &)