43 const std::pair<SeedingHitSet::ConstRecHitPointer,SeedingHitSet::ConstRecHitPointer>&
hits,
45 DetId firstHitId = hits.first->geographicalId();
46 DetId secondHitId = hits.second->geographicalId();
126 std::vector<std::pair<double,double> > phiEtaCache;
127 std::vector<SeedingHitSet> tripletCache;
129 const unsigned int nInputTriplets = inputTriplets.
size();
130 phiEtaCache.reserve(nInputTriplets);
131 tripletCache.reserve(nInputTriplets);
133 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
134 tripletCache.push_back((inputTriplets[it]));
145 bool isAllTriplets =
true;
146 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
147 if( tripletCache[it].
size() != 3 ) {
148 isAllTriplets =
false;
154 std::cout <<
"[QuadrupletSeedMerger::mergeTriplets] (in HLT) ** bailing out since non-triplets in input." << std::endl;
157 quads_.reserve(nInputTriplets);
158 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
159 quads_.push_back( (tripletCache[it]));
166 quads_.reserve(0.2*nInputTriplets);
171 std::vector<bool> usedTriplets(nInputTriplets,
false);
172 std::pair<SeedingHitSet::ConstRecHitPointer,SeedingHitSet::ConstRecHitPointer>
sharedHits;
173 std::pair<SeedingHitSet::ConstRecHitPointer,SeedingHitSet::ConstRecHitPointer> nonSharedHits;
177 std::vector<KDTreeNodeInfo<unsigned int> >
nodes;
178 std::vector<unsigned int> foundNodes;
179 nodes.reserve(2*nInputTriplets);
180 foundNodes.reserve(100);
183 for(
unsigned int it=0; it < nInputTriplets; ++it) {
184 double phi = phiEtaCache[it].first;
185 double eta = phiEtaCache[it].second;
196 kdtree.
build(nodes, kdEtaPhi);
202 std::vector<unsigned int> t1List;
203 std::vector<unsigned int> t2List;
204 std::vector<short> t1NonSharedHitList;
205 std::vector<short> t2NonSharedHitList;
206 constexpr short sharedToNonShared[7] = {-1, -1, -1,
211 constexpr short nonSharedToShared[3][2] = {
217 typedef std::tuple<unsigned int, short, short> T2NonSharedTuple;
218 std::vector<T2NonSharedTuple> t2Tmp;
219 for(
unsigned int t1=0; t1<nInputTriplets; ++t1) {
220 double phi = phiEtaCache[t1].first;
221 double eta = phiEtaCache[t1].second;
223 KDTreeBox box(eta-0.05, eta+0.05, phi-0.15, phi+0.15);
225 kdtree.
search(box, foundNodes);
226 if(foundNodes.empty())
231 for(
unsigned int t2: foundNodes) {
245 unsigned int t1Shared = 0;
246 unsigned int t2Shared = 0;
247 for(
unsigned int i=0;
i<2; ++
i) {
248 for(
unsigned int j=0; j<3; ++j) {
249 if(areHitsEqual(*tr1[
i], *tr2[j])) {
262 for(
unsigned int j=0; j<3; ++j) {
263 if(areHitsEqual(*tr1[2], *tr2[j])) {
274 assert(t1Shared <= 6 && t2Shared <= 6);
275 short t1NonShared = sharedToNonShared[t1Shared];
276 short t2NonShared = sharedToNonShared[t2Shared];
277 assert(t1NonShared >= 0 && t2NonShared >= 0);
279 t2Tmp.emplace_back(
t2, t1NonShared, t2NonShared);
283 std::sort(t2Tmp.begin(), t2Tmp.end(), [](
const T2NonSharedTuple&
a,
const T2NonSharedTuple&
b){
284 return std::get<0>(
a) < std::get<0>(
b);
286 for(T2NonSharedTuple& t2tpl: t2Tmp) {
287 t1List.push_back(t1);
288 t2List.push_back(std::get<0>(t2tpl));
289 t1NonSharedHitList.push_back(std::get<1>(t2tpl));
290 t2NonSharedHitList.push_back(std::get<2>(t2tpl));
299 std::vector<SeedMergerPixelLayer> currentLayers;
300 currentLayers.reserve(lsIt->size());
301 for( ctfseeding::SeedingLayers::const_iterator layIt = lsIt->begin(); layIt < lsIt->end(); ++layIt ) {
309 for(
unsigned int s1=0; s1<currentLayers.size()-1; s1++) {
311 for(
unsigned int s2=s1+1;
s2<currentLayers.size();
s2++) {
313 std::vector<unsigned int> nonSharedLayerNums;
314 for (
unsigned int us1=0; us1<currentLayers.size(); us1++) {
315 if ( s1!=us1 &&
s2!=us1) nonSharedLayerNums.push_back(us1);
319 for (
unsigned int t12=0; t12<t1List.size(); t12++) {
320 unsigned int t1=t1List[t12];
321 unsigned int t2=t2List[t12];
323 if (usedTriplets[t1] || usedTriplets[t2] )
continue;
327 short t1NonShared = t1NonSharedHitList[t12];
328 sharedHits.first = firstTriplet[nonSharedToShared[t1NonShared][0]];
329 sharedHits.second = firstTriplet[nonSharedToShared[t1NonShared][1]];
332 if(areHitsOnLayers(currentLayers[s1], currentLayers[
s2], sharedHits, tTopo)) {
333 short t2NonShared = t2NonSharedHitList[t12];
335 nonSharedHits.first = firstTriplet[t1NonShared];
336 nonSharedHits.second = secondTriplet[t2NonShared];
339 if(areHitsOnLayers(currentLayers[nonSharedLayerNums[0]], currentLayers[nonSharedLayerNums[1]], nonSharedHits, tTopo)) {
340 QuadrupletHits unsortedHits{ {sharedHits.first, sharedHits.second,
341 nonSharedHits.first, nonSharedHits.second} };
348 SeedingHitSet quadruplet(unsortedHits[0],unsortedHits[1],unsortedHits[2],unsortedHits[3]);
351 quads_.push_back( quadruplet );
354 usedTriplets[t1]=
true;
355 usedTriplets[
t2]=
true;
369 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
370 if ( !usedTriplets[it] )
371 quads_.push_back( tripletCache[it]);
415 bool isAllTriplets =
true;
416 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
417 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
418 if( 3 != aTrajectorySeed->nHits() ) isAllTriplets =
false;
422 std::cout <<
" [QuadrupletSeedMerger::mergeTriplets] (in RECO) -- bailing out since non-triplets in input." << std::endl;
425 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
426 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
427 theResult.push_back( *aTrajectorySeed );
441 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
442 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
444 std::vector<SeedingHitSet::ConstRecHitPointer> recHitPointers;
449 aHit < theHitsRange.second; ++aHit ) {
457 inputTriplets.push_back(
OrderedHitTriplet( recHitPointers.at( 0 ), recHitPointers.at( 1 ), recHitPointers.at( 2 ) ) );
470 for (
unsigned int i=0;
i< quadrupletHitSets.
size();
i++) {
493 const double x1 = p1.
x();
494 const double x2 = p2.
x();
495 const double y1 = p1.
y();
496 const double y2 = p2.
y();
497 const double z1 = p1.
z();
498 const double z2 = p2.
z();
500 const double phi = atan2( x2 - x1, y2 -y1 );
501 const double eta = acos( (z2 - z1) /
sqrt(
sqr( x2 - x1 ) +
sqr( y2 - y1 ) +
sqr( z2 - z1 ) ) );
503 std::pair<double,double> retVal;
504 retVal=std::make_pair (phi,eta);
523 std::cout <<
"<RecHit> x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
535 for(
unsigned int aHit = 0; aHit < aNtuplet.
size(); ++aHit ) {
542 const double r =
sqrt( x*x + y*y );
553 if( z > 0 ) detName +=
"+";
560 std::cout <<
"<NtupletHit> D: " << detName <<
" L: " << layer <<
" x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
564 std::cout <<
"<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
606 const unsigned int quadrupletSize = quadruplet.size();
609 if( quadrupletSize != layers.size() ) {
610 std::cout <<
" [QuadrupletSeedMerger::isValidQuadruplet] ** WARNING: size mismatch: " 611 << quadrupletSize <<
"/" << layers.size() << std::endl;
617 if( ! layers[
index].isContainsDetector( quadruplet[
index]->geographicalId(), tTopo ) ) {
632 if( ! isValidName( name ) ) {
633 std::cerr <<
" [SeedMergerPixelLayer::SeedMergerPixelLayer] ** ERROR: illegal name: \"" << name <<
"\"." << std::endl;
642 if( std::string::npos != name_.find(
"BPix" ) )
644 else if( std::string::npos != name_.find(
"FPix" ) )
646 if( std::string::npos != name_.find(
"pos", 6 ) ) side_ = Plus;
647 else if( std::string::npos != name_.find(
"neg", 6 ) ) side_ = Minus;
649 std::cerr <<
" [PixelLayerNameParser::side] ** ERROR: something's wrong here.." << std::endl;
654 std::cerr <<
" [PixelLayerNameParser::subdetector] ** ERROR: something's wrong here.." << std::endl;
658 layer_ = atoi( name_.substr( 4, 1 ).c_str() );
669 const int layer = atoi( name.substr( 4, 1 ).c_str() );
671 if( std::string::npos != name.find(
"BPix" ) ) {
672 if( layer > 0 && layer < 5 )
return true;
675 else if( std::string::npos != name.find(
"FPix" ) ) {
676 if( layer > 0 && layer < 10 ) {
677 if( std::string::npos != name.find(
"pos", 6 ) || std::string::npos != name.find(
"neg", 6 ) )
return true;
682 std::cerr <<
" [SeedMergerPixelLayer::isValidName] ** WARNING: invalid name: \"" << name <<
"\"." << std::endl;
702 if (tTopo->
pxbLayer(detId) == getLayerNumber()) {
710 if (tTopo->
pxfDisk(detId) == getLayerNumber()) {
711 if (tTopo->
pxfSide(detId) == (unsigned)getSide()) {
726 for (
unsigned int iR=0; iR<4; iR++){
728 radiiSq[iR]=( p1.
x()*p1.
x()+p1.
y()*p1.
y());
732 for (
unsigned int iR1=0; iR1<3; iR1++) {
733 for (
unsigned int iR2=iR1+1; iR2<4; iR2++) {
734 if (radiiSq[iR1]>radiiSq[iR2]) {
735 tempRHP=unsortedHits[iR1];
736 unsortedHits[iR1]=unsortedHits[iR2];
737 unsortedHits[iR2]=tempRHP;
738 tempFloat=radiiSq[iR1];
739 radiiSq[iR1]=radiiSq[iR2];
740 radiiSq[iR2]=tempFloat;
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es)
static const char layer_[]
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
void setTTRHBuilderLabel(std::string)
def create(alignables, pedeDump, additionalData, outputFile, config)
void printNtuplet(const SeedingHitSet &) const
SeedMergerPixelLayer(const std::string &)
void build(std::vector< KDTreeNodeInfoT< DATA, DIM > > &eltList, const KDTreeBoxT< DIM > ®ion)
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.
QuadrupletSeedMerger(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
bool check(const edm::EventSetup &es)
void setMergeTriplets(bool)
void search(const KDTreeBoxT< DIM > &searchBox, std::vector< KDTreeNodeInfoT< DATA, DIM > > &resRecHitList)
bool isAddRemainingTriplets_
ctfseeding::SeedingLayerSets theLayerSets_
const Plane & surface() const
The nominal surface of the GeomDet.
std::pair< double, double > calculatePhiEta(SeedingHitSet const &) const
void mySort(QuadrupletHits &unsortedHits)
T x() const
Cartesian x coordinate.
BaseTrackerRecHit const * ConstRecHitPointer
std::vector< TrajectorySeed > TrajectorySeedCollection
auto const T2 &decltype(t1.eta()) t2
Abs< T >::type abs(const T &t)
std::pair< const_iterator, const_iterator > range
virtual unsigned int size() const =0
std::array< SeedingHitSet::ConstRecHitPointer, 4 > QuadrupletHits
virtual LocalPoint localPosition() const =0
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
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::unique_ptr< SeedCreator > theSeedCreator_
SeedingLayerSetsBuilder theLayerBuilder_
int diskName() const
disk id
DetId geographicalId() const
const PositionType & position() const
T const * product() const
T get(const Candidate &c)
bool isValidName(const std::string &)
const TrackerGeomDet * idToDet(DetId) const