41 const std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>& hits,
43 DetId firstHitId = hits.first->geographicalId();
44 DetId secondHitId = hits.second->geographicalId();
67 theLayerBuilder_(iConfig, iC)
117 std::vector<std::pair<double,double> > phiEtaCache;
118 std::vector<SeedingHitSet> tripletCache;
120 const unsigned int nInputTriplets = inputTriplets.
size();
121 phiEtaCache.reserve(nInputTriplets);
122 tripletCache.reserve(nInputTriplets);
124 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
125 tripletCache.push_back((inputTriplets[it]));
136 bool isAllTriplets =
true;
137 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
138 if( tripletCache[it].
size() != 3 ) {
139 isAllTriplets =
false;
145 std::cout <<
"[QuadrupletSeedMerger::mergeTriplets] (in HLT) ** bailing out since non-triplets in input." << std::endl;
148 quads_.reserve(nInputTriplets);
149 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
150 quads_.push_back( (tripletCache[it]));
157 quads_.reserve(0.2*nInputTriplets);
162 std::vector<bool> usedTriplets(nInputTriplets,
false);
163 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>
sharedHits;
164 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> nonSharedHits;
168 std::vector<KDTreeNodeInfo<unsigned int> > nodes;
169 std::vector<unsigned int> foundNodes;
170 nodes.reserve(2*nInputTriplets);
171 foundNodes.reserve(100);
174 for(
unsigned int it=0; it < nInputTriplets; ++it) {
175 double phi = phiEtaCache[it].first;
176 double eta = phiEtaCache[it].second;
187 kdtree.
build(nodes, kdEtaPhi);
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,
202 constexpr short nonSharedToShared[3][2] = {
208 typedef std::tuple<unsigned int, short, short> T2NonSharedTuple;
209 std::vector<T2NonSharedTuple> t2Tmp;
210 for(
unsigned int t1=0; t1<nInputTriplets; ++t1) {
211 double phi = phiEtaCache[t1].first;
212 double eta = phiEtaCache[t1].second;
214 KDTreeBox box(eta-0.05, eta+0.05, phi-0.15, phi+0.15);
216 kdtree.
search(box, foundNodes);
217 if(foundNodes.empty())
222 for(
unsigned int t2: foundNodes) {
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])) {
253 for(
unsigned int j=0;
j<3; ++
j) {
254 if(areHitsEqual(*tr1[2], *tr2[
j])) {
265 assert(t1Shared <= 6 && t2Shared <= 6);
266 short t1NonShared = sharedToNonShared[t1Shared];
267 short t2NonShared = sharedToNonShared[t2Shared];
268 assert(t1NonShared >= 0 && t2NonShared >= 0);
270 t2Tmp.emplace_back(
t2, t1NonShared, t2NonShared);
274 std::sort(t2Tmp.begin(), t2Tmp.end(), [](
const T2NonSharedTuple&
a,
const T2NonSharedTuple&
b){
275 return std::get<0>(
a) < std::get<0>(
b);
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));
290 std::vector<SeedMergerPixelLayer> currentLayers;
291 currentLayers.reserve(lsIt->size());
292 for( ctfseeding::SeedingLayers::const_iterator layIt = lsIt->begin(); layIt < lsIt->end(); ++layIt ) {
300 for(
unsigned int s1=0; s1<currentLayers.size()-1; s1++) {
302 for(
unsigned int s2=s1+1;
s2<currentLayers.size();
s2++) {
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);
310 for (
unsigned int t12=0; t12<t1List.size(); t12++) {
311 unsigned int t1=t1List[t12];
312 unsigned int t2=t2List[t12];
314 if (usedTriplets[t1] || usedTriplets[t2] )
continue;
318 short t1NonShared = t1NonSharedHitList[t12];
319 sharedHits.first = firstTriplet[nonSharedToShared[t1NonShared][0]];
320 sharedHits.second = firstTriplet[nonSharedToShared[t1NonShared][1]];
323 if(areHitsOnLayers(currentLayers[s1], currentLayers[
s2], sharedHits, tTopo)) {
324 short t2NonShared = t2NonSharedHitList[t12];
326 nonSharedHits.first = firstTriplet[t1NonShared];
327 nonSharedHits.second = secondTriplet[t2NonShared];
330 if(areHitsOnLayers(currentLayers[nonSharedLayerNums[0]], currentLayers[nonSharedLayerNums[1]], nonSharedHits, tTopo)) {
331 QuadrupletHits unsortedHits{ {sharedHits.first, sharedHits.second,
332 nonSharedHits.first, nonSharedHits.second} };
339 SeedingHitSet quadruplet(unsortedHits[0],unsortedHits[1],unsortedHits[2],unsortedHits[3]);
342 quads_.push_back( quadruplet );
345 usedTriplets[t1]=
true;
346 usedTriplets[
t2]=
true;
360 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
361 if ( !usedTriplets[it] )
362 quads_.push_back( tripletCache[it]);
407 bool isAllTriplets =
true;
408 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
409 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
410 if( 3 != aTrajectorySeed->nHits() ) isAllTriplets =
false;
414 std::cout <<
" [QuadrupletSeedMerger::mergeTriplets] (in RECO) -- bailing out since non-triplets in input." << std::endl;
417 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
418 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
419 theResult.push_back( *aTrajectorySeed );
433 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
434 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
436 std::vector<TransientTrackingRecHit::RecHitPointer> recHitPointers;
441 aHit < theHitsRange.second; ++aHit ) {
449 inputTriplets.push_back(
OrderedHitTriplet( recHitPointers.at( 0 ), recHitPointers.at( 1 ), recHitPointers.at( 2 ) ) );
465 seedCreator->init(region, es, 0);
466 for (
unsigned int i=0;
i< quadrupletHitSets.
size();
i++) {
468 seedCreator->makeSeed( theResult, quadrupletHitSets[
i]);
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();
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 ) ) );
499 std::pair<double,double> retVal;
500 retVal=std::make_pair (phi,eta);
529 std::cout <<
"<RecHit> x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
541 for(
unsigned int aHit = 0; aHit < aNtuplet.
size(); ++aHit ) {
548 const double r =
sqrt( x*x + y*y );
559 if( z > 0 ) detName +=
"+";
566 std::cout <<
"<NtupletHit> D: " << detName <<
" L: " << layer <<
" x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
570 std::cout <<
"<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
612 const unsigned int quadrupletSize = quadruplet.size();
615 if( quadrupletSize != layers.size() ) {
616 std::cout <<
" [QuadrupletSeedMerger::isValidQuadruplet] ** WARNING: size mismatch: "
617 << quadrupletSize <<
"/" << layers.size() << std::endl;
623 if( ! layers[
index].isContainsDetector( quadruplet[
index]->geographicalId(), tTopo ) ) {
639 std::cerr <<
" [SeedMergerPixelLayer::SeedMergerPixelLayer] ** ERROR: illegal name: \"" << name <<
"\"." << std::endl;
648 if( std::string::npos !=
name_.find(
"BPix" ) )
650 else if( std::string::npos !=
name_.find(
"FPix" ) )
655 std::cerr <<
" [PixelLayerNameParser::side] ** ERROR: something's wrong here.." << std::endl;
660 std::cerr <<
" [PixelLayerNameParser::subdetector] ** ERROR: something's wrong here.." << std::endl;
675 const int layer = atoi( name.substr( 4, 1 ).c_str() );
677 if( std::string::npos != name.find(
"BPix" ) ) {
678 if( layer > 0 && layer < 5 )
return true;
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;
688 std::cerr <<
" [SeedMergerPixelLayer::isValidName] ** WARNING: invalid name: \"" << name <<
"\"." << std::endl;
732 for (
unsigned int iR=0; iR<4; iR++){
734 radiiSq[iR]=( p1.
x()*p1.
x()+p1.
y()*p1.
y());
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;
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
T getParameter(std::string const &) const
ctfseeding::SeedingLayerSets layers(const edm::EventSetup &es)
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox ®ion)
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
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
QuadrupletSeedMerger(const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
std::array< TransientTrackingRecHit::ConstRecHitPointer, 4 > QuadrupletHits
virtual unsigned int size() const =0
bool check(const edm::EventSetup &es)
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
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
SeedingLayerSetsBuilder theLayerBuilder_
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 &)