Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 75 additions & 108 deletions RecoTracker/TkDetLayers/src/GeometricSearchTrackerBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@
#include "TIDLayerBuilder.h"
#include "TECLayerBuilder.h"

#include "Geometry/TrackerGeometryBuilder/interface/trackerHierarchy.h"

#include "Geometry/CommonDetUnit/interface/GeomDet.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h"

#include "DataFormats/Common/interface/Trie.h"

using namespace std;

GeometricSearchTracker *GeometricSearchTrackerBuilder::build(const GeometricDet *theGeometricTracker,
Expand Down Expand Up @@ -46,149 +42,120 @@ GeometricSearchTracker *GeometricSearchTrackerBuilder::build(const GeometricDet
bool useBrothers = !usePhase2Stacks;

vector<const GeometricDet *> theGeometricDetLayers = theGeometricTracker->components();
for (vector<const GeometricDet *>::const_iterator it = theGeometricDetLayers.begin();
it != theGeometricDetLayers.end();
it++) {
if ((*it)->type() == GeometricDet::PixelBarrel) {
vector<const GeometricDet *> thePxlBarGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = thePxlBarGeometricDetLayers.begin();
it2 != thePxlBarGeometricDetLayers.end();
it2++) {
thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(*it2, theGeomDetGeometry));
for (const GeometricDet *theGeomDetLayer : theGeometricDetLayers) {
if (theGeomDetLayer->type() == GeometricDet::PixelBarrel) {
vector<const GeometricDet *> thePxlBarGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : thePxlBarGeometricDetLayers) {
thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::PixelPhase1Barrel) {
vector<const GeometricDet *> thePxlBarGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = thePxlBarGeometricDetLayers.begin();
it2 != thePxlBarGeometricDetLayers.end();
it2++) {
thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::PixelPhase1Barrel) {
vector<const GeometricDet *> thePxlBarGeometricDetLayers = theGeomDetLayer->components();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto const & ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally prefer to keep the original explicit declaration as it was before (here and in the other similar cases that you pointed out before): do you have any issue with it? You are the code expert, and I'll follow your prescription in that case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to add const & anyhow. Should help the compiler not to copy the vector!

Btw modenrize (in my opinion) is also use auto when is not confusing

for (const GeometricDet *thisGeomDet : thePxlBarGeometricDetLayers) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto const ?

thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::PixelPhase2Barrel) {
vector<const GeometricDet *> thePxlBarGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = thePxlBarGeometricDetLayers.begin();
it2 != thePxlBarGeometricDetLayers.end();
it2++) {
thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::PixelPhase2Barrel) {
vector<const GeometricDet *> thePxlBarGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : thePxlBarGeometricDetLayers) {
thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::TIB) {
vector<const GeometricDet *> theTIBGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = theTIBGeometricDetLayers.begin();
it2 != theTIBGeometricDetLayers.end();
it2++) {
theTIBLayers.push_back(aTIBLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::TIB) {
vector<const GeometricDet *> theTIBGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : theTIBGeometricDetLayers) {
theTIBLayers.push_back(aTIBLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::TOB) {
vector<const GeometricDet *> theTOBGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = theTOBGeometricDetLayers.begin();
it2 != theTOBGeometricDetLayers.end();
it2++) {
theTOBLayers.push_back(aTOBLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::TOB) {
vector<const GeometricDet *> theTOBGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : theTOBGeometricDetLayers) {
theTOBLayers.push_back(aTOBLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::OTPhase2Barrel) {
vector<const GeometricDet *> theTOBGeometricDetLayers = (*it)->components();

for (vector<const GeometricDet *>::const_iterator it2 = theTOBGeometricDetLayers.begin();
it2 != theTOBGeometricDetLayers.end();
it2++) {
theTOBLayers.push_back(aPhase2OTBarrelLayerBuilder.build(*it2, theGeomDetGeometry, useBrothers));
if (theGeomDetLayer->type() == GeometricDet::OTPhase2Barrel) {
vector<const GeometricDet *> theTOBGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : theTOBGeometricDetLayers) {
theTOBLayers.push_back(aPhase2OTBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry, useBrothers));
}
}

if ((*it)->type() == GeometricDet::PixelEndCap) {
vector<const GeometricDet *> thePxlFwdGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = thePxlFwdGeometricDetLayers.begin();
it2 != thePxlFwdGeometricDetLayers.end();
it2++) {
if ((*it2)->positionBounds().z() < 0)
theNegPxlFwdLayers.push_back(aPixelForwardLayerBuilder.build(*it2, theGeomDetGeometry));
if ((*it2)->positionBounds().z() > 0)
thePosPxlFwdLayers.push_back(aPixelForwardLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::PixelEndCap) {
vector<const GeometricDet *> thePxlFwdGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : thePxlFwdGeometricDetLayers) {
if (thisGeomDet->positionBounds().z() < 0)
theNegPxlFwdLayers.push_back(aPixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
else
thePosPxlFwdLayers.push_back(aPixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::PixelPhase1EndCap) {
vector<const GeometricDet *> thePxlFwdGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = thePxlFwdGeometricDetLayers.begin();
it2 != thePxlFwdGeometricDetLayers.end();
it2++) {
if ((*it2)->positionBounds().z() < 0)
theNegPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(*it2, theGeomDetGeometry));
if ((*it2)->positionBounds().z() > 0)
thePosPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::PixelPhase1EndCap) {
vector<const GeometricDet *> thePxlFwdGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : thePxlFwdGeometricDetLayers) {
if (thisGeomDet->positionBounds().z() < 0)
theNegPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
else
thePosPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::PixelPhase2EndCap) {
vector<const GeometricDet *> thePxlFwdGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = thePxlFwdGeometricDetLayers.begin();
it2 != thePxlFwdGeometricDetLayers.end();
it2++) {
if (theGeomDetLayer->type() == GeometricDet::PixelPhase2EndCap) {
vector<const GeometricDet *> thePxlFwdGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : thePxlFwdGeometricDetLayers) {
//FIXME: this is just to keep the compatibility with the PixelPhase1 extension layout
//hopefully we can get rid of it soon
if ((*it2)->positionBounds().z() < 0) {
if ((*it2)->type() == GeometricDet::PixelPhase2FullDisk ||
(*it2)->type() == GeometricDet::PixelPhase2ReducedDisk)
theNegPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(*it2, theGeomDetGeometry));
else if ((*it2)->type() == GeometricDet::PixelPhase2TDRDisk)
theNegPxlFwdLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, false));
} else if ((*it2)->positionBounds().z() > 0) {
if ((*it2)->type() == GeometricDet::PixelPhase2FullDisk ||
(*it2)->type() == GeometricDet::PixelPhase2ReducedDisk)
thePosPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(*it2, theGeomDetGeometry));
else if ((*it2)->type() == GeometricDet::PixelPhase2TDRDisk)
thePosPxlFwdLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, false));
if (thisGeomDet->positionBounds().z() < 0) {
if (thisGeomDet->type() == GeometricDet::PixelPhase2FullDisk ||
thisGeomDet->type() == GeometricDet::PixelPhase2ReducedDisk)
theNegPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
else if (thisGeomDet->type() == GeometricDet::PixelPhase2TDRDisk)
theNegPxlFwdLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, false));
} else if (thisGeomDet->positionBounds().z() > 0) {
if (thisGeomDet->type() == GeometricDet::PixelPhase2FullDisk ||
thisGeomDet->type() == GeometricDet::PixelPhase2ReducedDisk)
thePosPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
else if (thisGeomDet->type() == GeometricDet::PixelPhase2TDRDisk)
thePosPxlFwdLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, false));
} else {
edm::LogError("TkDetLayers") << "In PixelPhase2EndCap the disks are neither PixelPhase2FullDisk nor "
"PixelPhase2ReducedDisk nor PixelPhase2TDRDisk...";
}
}
}

if ((*it)->type() == GeometricDet::TID) {
vector<const GeometricDet *> theTIDGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = theTIDGeometricDetLayers.begin();
it2 != theTIDGeometricDetLayers.end();
it2++) {
if ((*it2)->positionBounds().z() < 0)
theNegTIDLayers.push_back(aTIDLayerBuilder.build(*it2, theGeomDetGeometry));
if ((*it2)->positionBounds().z() > 0)
thePosTIDLayers.push_back(aTIDLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::TID) {
vector<const GeometricDet *> theTIDGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : theTIDGeometricDetLayers) {
if (thisGeomDet->positionBounds().z() < 0)
theNegTIDLayers.push_back(aTIDLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
else
thePosTIDLayers.push_back(aTIDLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}

if ((*it)->type() == GeometricDet::OTPhase2EndCap) {
vector<const GeometricDet *> theTIDGeometricDetLayers = (*it)->components();

bool useBrothers = !usePhase2Stacks;
for (vector<const GeometricDet *>::const_iterator it2 = theTIDGeometricDetLayers.begin();
it2 != theTIDGeometricDetLayers.end();
it2++) {
if ((*it2)->positionBounds().z() < 0)
theNegTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, useBrothers));
if ((*it2)->positionBounds().z() > 0)
thePosTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(*it2, theGeomDetGeometry, useBrothers));
if (theGeomDetLayer->type() == GeometricDet::OTPhase2EndCap) {
vector<const GeometricDet *> theTIDGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : theTIDGeometricDetLayers) {
if (thisGeomDet->positionBounds().z() < 0)
theNegTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, useBrothers));
else
thePosTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, useBrothers));
}
}

if ((*it)->type() == GeometricDet::TEC) {
vector<const GeometricDet *> theTECGeometricDetLayers = (*it)->components();
for (vector<const GeometricDet *>::const_iterator it2 = theTECGeometricDetLayers.begin();
it2 != theTECGeometricDetLayers.end();
it2++) {
if ((*it2)->positionBounds().z() < 0)
theNegTECLayers.push_back(aTECLayerBuilder.build(*it2, theGeomDetGeometry));
if ((*it2)->positionBounds().z() > 0)
thePosTECLayers.push_back(aTECLayerBuilder.build(*it2, theGeomDetGeometry));
if (theGeomDetLayer->type() == GeometricDet::TEC) {
vector<const GeometricDet *> theTECGeometricDetLayers = theGeomDetLayer->components();
for (const GeometricDet *thisGeomDet : theTECGeometricDetLayers) {
if (thisGeomDet->positionBounds().z() < 0)
theNegTECLayers.push_back(aTECLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
else
thePosTECLayers.push_back(aTECLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
}
}
}
Expand Down