85 std::vector<std::pair<double,double> > phiEtaCache;
86 std::vector<SeedingHitSet> tripletCache;
88 const unsigned int nInputTriplets = inputTriplets.
size();
89 phiEtaCache.reserve(nInputTriplets);
90 tripletCache.reserve(nInputTriplets);
92 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
93 tripletCache.push_back((inputTriplets[it]));
104 bool isAllTriplets =
true;
105 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
106 if( tripletCache[it].
size() != 3 ) {
107 isAllTriplets =
false;
113 std::cout <<
"[QuadrupletSeedMerger::mergeTriplets] (in HLT) ** bailing out since non-triplets in input." << std::endl;
116 quads_.reserve(nInputTriplets);
117 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
118 quads_.push_back( (tripletCache[it]));
125 quads_.reserve(0.2*nInputTriplets);
130 std::vector<bool> usedTriplets(nInputTriplets,
false);
131 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>
sharedHits;
132 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> nonSharedHits;
151 std::vector<unsigned int> t1List;
152 std::vector<unsigned int> t2List;
153 for (
unsigned int t1=0; t1<nInputTriplets-1; t1++) {
154 for (
unsigned int t2=t1+1;
t2<nInputTriplets;
t2++) {
155 if( fabs( phiEtaCache[t1].
second - phiEtaCache[
t2].
second ) > 0.05 )
158 if( (temp > 0.15) && (temp <6.133185) ) {
161 t1List.push_back(t1);
162 t2List.push_back(
t2);
166 for( ctfseeding::SeedingLayerSets::const_iterator lsIt = theLayerSets_.begin(); lsIt < theLayerSets_.end(); ++lsIt ) {
169 std::vector<SeedMergerPixelLayer> currentLayers;
170 currentLayers.reserve(lsIt->size());
171 for( ctfseeding::SeedingLayers::const_iterator layIt = lsIt->begin(); layIt < lsIt->end(); ++layIt ) {
179 for(
unsigned int s1=0; s1<currentLayers.size()-1; s1++) {
181 for(
unsigned int s2=s1+1;
s2<currentLayers.size();
s2++) {
183 std::vector<unsigned int> nonSharedLayerNums;
184 for (
unsigned int us1=0; us1<currentLayers.size(); us1++) {
185 if ( s1!=us1 &&
s2!=us1) nonSharedLayerNums.push_back(us1);
189 for (
unsigned int t12=0; t12<t1List.size(); t12++) {
190 unsigned int t1=t1List[t12];
191 unsigned int t2=t2List[t12];
193 if (usedTriplets[t1] || usedTriplets[t2] )
continue;
200 currentLayers[
s2], sharedHits, tTopo ) ) {
204 currentLayers[nonSharedLayerNums[0]],
205 currentLayers[nonSharedLayerNums[1]], nonSharedHits, tTopo ) ) {
208 std::vector<TransientTrackingRecHit::ConstRecHitPointer> unsortedHits=
mySort(sharedHits.first,
211 nonSharedHits.second);
216 SeedingHitSet quadruplet(unsortedHits[0],unsortedHits[1],unsortedHits[2],unsortedHits[3]);
219 quads_.push_back( quadruplet );
222 usedTriplets[t1]=
true;
223 usedTriplets[
t2]=
true;
237 for(
unsigned int it = 0; it < nInputTriplets; ++it ) {
238 if ( !usedTriplets[it] )
239 quads_.push_back( tripletCache[it]);
284 bool isAllTriplets =
true;
285 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
286 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
287 if( 3 != aTrajectorySeed->nHits() ) isAllTriplets =
false;
291 std::cout <<
" [QuadrupletSeedMerger::mergeTriplets] (in RECO) -- bailing out since non-triplets in input." << std::endl;
294 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
295 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
296 theResult.push_back( *aTrajectorySeed );
310 for( TrajectorySeedCollection::const_iterator aTrajectorySeed = seedCollection.begin();
311 aTrajectorySeed < seedCollection.end(); ++aTrajectorySeed ) {
313 std::vector<TransientTrackingRecHit::RecHitPointer> recHitPointers;
318 aHit < theHitsRange.second; ++aHit ) {
326 inputTriplets.push_back(
OrderedHitTriplet( recHitPointers.at( 0 ), recHitPointers.at( 1 ), recHitPointers.at( 2 ) ) );
342 seedCreator->init(region, es, 0);
343 for (
unsigned int i=0;
i< quadrupletHitSets.
size();
i++) {
345 seedCreator->makeSeed( theResult, quadrupletHitSets[
i]);
359 const double epsilon = 0.00001;
364 if( ( fabs( lp1.
x() - lp2.x() ) < epsilon ) &&
365 ( fabs( lp1.
y() - lp2.y() ) < epsilon ) ) {
395 const double x1 = p1.
x();
396 const double x2 = p2.
x();
397 const double y1 = p1.
y();
398 const double y2 = p2.
y();
399 const double z1 = p1.
z();
400 const double z2 = p2.
z();
402 const double phi = atan2( x2 - x1, y2 -y1 );
403 const double eta = acos( (z2 - z1) /
sqrt(
pow( x2 - x1, 2. ) +
pow( y2 - y1, 2. ) +
pow( z2 - z1, 2. ) ) );
405 std::pair<double,double> retVal;
406 retVal=std::make_pair (phi,eta);
435 std::cout <<
"<RecHit> x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
447 for(
unsigned int aHit = 0; aHit < aNtuplet.
size(); ++aHit ) {
454 const double r =
sqrt( x*x + y*y );
465 if( z > 0 ) detName +=
"+";
472 std::cout <<
"<NtupletHit> D: " << detName <<
" L: " << layer <<
" x: " << x <<
" y: " << y <<
" z: " << z <<
" r: " << r << std::endl;
476 std::cout <<
"<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
528 const unsigned int quadrupletSize = quadruplet.size();
531 if( quadrupletSize != layers.size() ) {
532 std::cout <<
" [QuadrupletSeedMerger::isValidQuadruplet] ** WARNING: size mismatch: "
533 << quadrupletSize <<
"/" << layers.size() << std::endl;
539 if( ! layers[
index].isContainsDetector( quadruplet[
index]->geographicalId(), tTopo ) ) {
557 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>& hits,
560 bool isSuccess1[2],isSuccess2[2];
566 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer> hitsTriplet1, hitsTriplet2;
571 if( ! firstTriplet[
index]->isValid() )
return false;
572 bool firsthit(
false);
573 DetId const& thisDetId = firstTriplet[
index]->hit()->geographicalId();
575 if( ! isSuccess1[0] ) {
577 isSuccess1[0] =
true;
579 hitsTriplet1.first = firstTriplet[
index];
583 if ( (! firsthit) && (! isSuccess1[1] ) && ((
index !=3) || isSuccess1[0]) ) {
585 isSuccess1[1] =
true;
586 hitsTriplet1.second = firstTriplet[
index];
591 if ( isSuccess1[0] && isSuccess1[1]) {
594 if( ! secondTriplet[
index]->isValid() ) {
return false; }
595 bool firsthit(
false);
596 DetId const& thisDetId = secondTriplet[
index]->hit()->geographicalId();
598 if( ! isSuccess2[0] ) {
600 isSuccess2[0] =
true;
602 hitsTriplet2.first = secondTriplet[
index];
606 if( (! firsthit) && (! isSuccess2[1]) && ((
index !=3) || isSuccess2[0]) ) {
608 isSuccess2[1] =
true;
609 hitsTriplet2.second = secondTriplet[
index];
615 if( isSuccess2[0] && isSuccess2[1] ) {
616 if(
isEqual( hitsTriplet1.first->hit(), hitsTriplet2.first->hit() ) &&
617 isEqual( hitsTriplet1.second->hit(), hitsTriplet2.second->hit() ) ) {
620 hits.first = hitsTriplet1.first;
621 hits.second = hitsTriplet1.second;
640 std::pair<TransientTrackingRecHit::ConstRecHitPointer,TransientTrackingRecHit::ConstRecHitPointer>& hits,
644 for(
unsigned int index1 = 0; index1 < 3; ++index1 ) {
647 DetId const& aDetId = firstTriplet[index1]->hit()->geographicalId();
651 for(
unsigned int index2 = 0; index2 < 3; ++index2 ) {
653 DetId const& anotherDetId = secondTriplet[index2]->hit()->geographicalId();
657 hits.first = firstTriplet[index1];
658 hits.second = secondTriplet[index2];
669 DetId const& aDetId = secondTriplet[index1]->hit()->geographicalId();
673 for(
unsigned int index2 = 0; index2 < 3; ++index2 ) {
675 DetId const& anotherDetId = firstTriplet[index2]->hit()->geographicalId();
679 hits.first = firstTriplet[index1];
680 hits.second = secondTriplet[index2];
702 std::cerr <<
" [SeedMergerPixelLayer::SeedMergerPixelLayer] ** ERROR: illegal name: \"" << name <<
"\"." << std::endl;
711 if( std::string::npos !=
name_.find(
"BPix" ) )
713 else if( std::string::npos !=
name_.find(
"FPix" ) )
718 std::cerr <<
" [PixelLayerNameParser::side] ** ERROR: something's wrong here.." << std::endl;
723 std::cerr <<
" [PixelLayerNameParser::subdetector] ** ERROR: something's wrong here.." << std::endl;
738 const int layer = atoi( name.substr( 4, 1 ).c_str() );
740 if( std::string::npos != name.find(
"BPix" ) ) {
741 if( layer > 0 && layer < 5 )
return true;
744 else if( std::string::npos != name.find(
"FPix" ) ) {
745 if( layer > 0 && layer < 4 ) {
746 if( std::string::npos != name.find(
"pos", 6 ) || std::string::npos != name.find(
"neg", 6 ) )
return true;
751 std::cerr <<
" [SeedMergerPixelLayer::isValidName] ** WARNING: invalid name: \"" << name <<
"\"." << std::endl;
798 std::vector<TransientTrackingRecHit::ConstRecHitPointer> unsortedHits;
799 unsortedHits.reserve(4);
800 unsortedHits.push_back( h1);
801 unsortedHits.push_back( h2);
802 unsortedHits.push_back( h3);
803 unsortedHits.push_back( h4);
806 for (
unsigned int iR=0; iR<4; iR++){
809 radiiSq[iR]=( p1.
x()*p1.
x()+p1.
y()*p1.
y());
813 for (
unsigned int iR1=0; iR1<3; iR1++) {
814 for (
unsigned int iR2=iR1+1; iR2<4; iR2++) {
815 if (radiiSq[iR1]>radiiSq[iR2]) {
816 tempRHP=unsortedHits[iR1];
817 unsortedHits[iR1]=unsortedHits[iR2];
818 unsortedHits[iR2]=tempRHP;
819 tempFloat=radiiSq[iR1];
820 radiiSq[iR1]=radiiSq[iR2];
821 radiiSq[iR2]=tempFloat;
edm::ESHandle< TrackerGeometry > theTrackerGeometry_
T getParameter(std::string const &) const
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
virtual unsigned int size() const =0
void setMergeTriplets(bool)
bool isAddRemainingTriplets_
ctfseeding::SeedingLayerSets theLayerSets_
bool isEqual(const TrackingRecHit *, const TrackingRecHit *) const
const Plane & surface() const
The nominal surface of the GeomDet.
std::pair< double, double > calculatePhiEta(SeedingHitSet const &) const
PixelSubdetector::SubDetector subdet_
U second(std::pair< T, U > const &p)
std::vector< TrajectorySeed > TrajectorySeedCollection
auto const T2 &decltype(t1.eta()) t2
PixelSubdetector::SubDetector getSubdet(void) const
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
bool isMergeableHitsInTriplets(const SeedingHitSet &firstTriplet, const SeedingHitSet &secondTriplet, const SeedMergerPixelLayer &nonShared1, const SeedMergerPixelLayer &nonShared2, std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &hits, const TrackerTopology *tTopo) 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_
std::vector< TransientTrackingRecHit::ConstRecHitPointer > mySort(TransientTrackingRecHit::ConstRecHitPointer &h1, TransientTrackingRecHit::ConstRecHitPointer &h2, TransientTrackingRecHit::ConstRecHitPointer &h3, TransientTrackingRecHit::ConstRecHitPointer &h4)
void setAddRemainingTriplets(bool)
std::string theTTRHBuilderLabel_
unsigned int size() const
void printHit(const TrackingRecHit *) const
unsigned int pxfSide(const DetId &id) const
std::string layerListName_
int diskName() const
disk id
bool isValidQuadruplet(std::vector< TransientTrackingRecHit::ConstRecHitPointer > &quadruplet, const std::vector< SeedMergerPixelLayer > &layers, const TrackerTopology *tTopo) const
SeedMergerPixelLayer::Side side_
DetId geographicalId() const
virtual LocalPoint localPosition() const =0
const PositionType & position() const
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
T get(const Candidate &c)
bool isValidName(const std::string &)
bool isTripletsShareHitsOnLayers(const SeedingHitSet &firstTriplet, const SeedingHitSet &secondTriplet, const SeedMergerPixelLayer &share1, const SeedMergerPixelLayer &share2, std::pair< TransientTrackingRecHit::ConstRecHitPointer, TransientTrackingRecHit::ConstRecHitPointer > &hits, const TrackerTopology *tTopo) const