File indexing completed on 2024-12-12 23:19:28
0001 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0002 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTrackerBuilder.h"
0003
0004 #include "PixelBarrelLayerBuilder.h"
0005 #include "Phase2OTBarrelLayerBuilder.h"
0006 #include "PixelForwardLayerBuilder.h"
0007 #include "Phase2EndcapLayerBuilder.h"
0008 #include "Phase2EndcapLayerDoubleDiskBuilder.h"
0009 #include "TIBLayerBuilder.h"
0010 #include "TOBLayerBuilder.h"
0011 #include "TIDLayerBuilder.h"
0012 #include "TECLayerBuilder.h"
0013
0014 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0015 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0016 #include "Geometry/MTDGeometryBuilder/interface/MTDTopology.h"
0017
0018 using namespace std;
0019
0020 GeometricSearchTracker *GeometricSearchTrackerBuilder::build(const GeometricDet *theGeometricTracker,
0021 const TrackerGeometry *theGeomDetGeometry,
0022 const TrackerTopology *tTopo,
0023 const bool usePhase2Stacks) {
0024 PixelBarrelLayerBuilder aPixelBarrelLayerBuilder;
0025 Phase2OTBarrelLayerBuilder aPhase2OTBarrelLayerBuilder;
0026 PixelForwardLayerBuilder<PixelBlade, PixelForwardLayer> aPixelForwardLayerBuilder;
0027 PixelForwardLayerBuilder<Phase1PixelBlade, PixelForwardLayerPhase1> aPhase1PixelForwardLayerBuilder;
0028 Phase2EndcapLayerBuilder aPhase2EndcapLayerBuilder;
0029 Phase2EndcapLayerDoubleDiskBuilder aPhase2EndcapLayerDoubleDiskBuilder;
0030 TIBLayerBuilder aTIBLayerBuilder;
0031 TOBLayerBuilder aTOBLayerBuilder;
0032 TIDLayerBuilder aTIDLayerBuilder;
0033 TECLayerBuilder aTECLayerBuilder;
0034
0035 vector<BarrelDetLayer const *> thePxlBarLayers;
0036 vector<BarrelDetLayer const *> theTIBLayers;
0037 vector<BarrelDetLayer const *> theTOBLayers;
0038 vector<ForwardDetLayer const *> theNegPxlFwdLayers;
0039 vector<ForwardDetLayer const *> thePosPxlFwdLayers;
0040 vector<ForwardDetLayer const *> theNegTIDLayers;
0041 vector<ForwardDetLayer const *> thePosTIDLayers;
0042 vector<ForwardDetLayer const *> theNegTECLayers;
0043 vector<ForwardDetLayer const *> thePosTECLayers;
0044 bool useBrothers = !usePhase2Stacks;
0045
0046 auto const &theGeometricDetLayers = theGeometricTracker->components();
0047 for (auto const &theGeomDetLayer : theGeometricDetLayers) {
0048 if (theGeomDetLayer->type() == GeometricDet::PixelBarrel) {
0049 auto const &thePxlBarGeometricDetLayers = theGeomDetLayer->components();
0050 for (auto const &thisGeomDet : thePxlBarGeometricDetLayers) {
0051 thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0052 }
0053 }
0054
0055 if (theGeomDetLayer->type() == GeometricDet::PixelPhase1Barrel) {
0056 auto const &thePxlBarGeometricDetLayers = theGeomDetLayer->components();
0057 for (auto const &thisGeomDet : thePxlBarGeometricDetLayers) {
0058 thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0059 }
0060 }
0061
0062 if (theGeomDetLayer->type() == GeometricDet::PixelPhase2Barrel) {
0063 auto const &thePxlBarGeometricDetLayers = theGeomDetLayer->components();
0064 for (auto const &thisGeomDet : thePxlBarGeometricDetLayers) {
0065 thePxlBarLayers.push_back(aPixelBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0066 }
0067 }
0068
0069 if (theGeomDetLayer->type() == GeometricDet::TIB) {
0070 auto const &theTIBGeometricDetLayers = theGeomDetLayer->components();
0071 for (auto const &thisGeomDet : theTIBGeometricDetLayers) {
0072 theTIBLayers.push_back(aTIBLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0073 }
0074 }
0075
0076 if (theGeomDetLayer->type() == GeometricDet::TOB) {
0077 auto const &theTOBGeometricDetLayers = theGeomDetLayer->components();
0078 for (auto const &thisGeomDet : theTOBGeometricDetLayers) {
0079 theTOBLayers.push_back(aTOBLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0080 }
0081 }
0082
0083 if (theGeomDetLayer->type() == GeometricDet::OTPhase2Barrel) {
0084 auto const &theTOBGeometricDetLayers = theGeomDetLayer->components();
0085 for (auto const &thisGeomDet : theTOBGeometricDetLayers) {
0086 theTOBLayers.push_back(aPhase2OTBarrelLayerBuilder.build(thisGeomDet, theGeomDetGeometry, useBrothers));
0087 }
0088 }
0089
0090 if (theGeomDetLayer->type() == GeometricDet::PixelEndCap) {
0091 auto const &thePxlFwdGeometricDetLayers = theGeomDetLayer->components();
0092 for (auto const &thisGeomDet : thePxlFwdGeometricDetLayers) {
0093 if (thisGeomDet->positionBounds().z() < 0)
0094 theNegPxlFwdLayers.push_back(aPixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0095 else
0096 thePosPxlFwdLayers.push_back(aPixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0097 }
0098 }
0099
0100 if (theGeomDetLayer->type() == GeometricDet::PixelPhase1EndCap) {
0101 auto const &thePxlFwdGeometricDetLayers = theGeomDetLayer->components();
0102 for (auto const &thisGeomDet : thePxlFwdGeometricDetLayers) {
0103 if (thisGeomDet->positionBounds().z() < 0)
0104 theNegPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0105 else
0106 thePosPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0107 }
0108 }
0109
0110 if (theGeomDetLayer->type() == GeometricDet::PixelPhase2EndCap) {
0111 auto const &thePxlFwdGeometricDetLayers = theGeomDetLayer->components();
0112 for (auto const &thisGeomDet : thePxlFwdGeometricDetLayers) {
0113
0114
0115 if (thisGeomDet->positionBounds().z() < 0) {
0116 if (thisGeomDet->type() == GeometricDet::PixelPhase2FullDisk ||
0117 thisGeomDet->type() == GeometricDet::PixelPhase2ReducedDisk)
0118 theNegPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0119 else if (thisGeomDet->type() == GeometricDet::PixelPhase2TDRDisk)
0120 theNegPxlFwdLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, false));
0121 else if (thisGeomDet->type() == GeometricDet::PixelPhase2DoubleDisk)
0122 theNegPxlFwdLayers.push_back(aPhase2EndcapLayerDoubleDiskBuilder.build(thisGeomDet, theGeomDetGeometry));
0123 } else if (thisGeomDet->positionBounds().z() > 0) {
0124 if (thisGeomDet->type() == GeometricDet::PixelPhase2FullDisk ||
0125 thisGeomDet->type() == GeometricDet::PixelPhase2ReducedDisk)
0126 thePosPxlFwdLayers.push_back(aPhase1PixelForwardLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0127 else if (thisGeomDet->type() == GeometricDet::PixelPhase2TDRDisk)
0128 thePosPxlFwdLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, false));
0129 else if (thisGeomDet->type() == GeometricDet::PixelPhase2DoubleDisk)
0130 thePosPxlFwdLayers.push_back(aPhase2EndcapLayerDoubleDiskBuilder.build(thisGeomDet, theGeomDetGeometry));
0131
0132 } else {
0133 edm::LogError("TkDetLayers") << "In PixelPhase2EndCap the disks are neither PixelPhase2FullDisk nor "
0134 "PixelPhase2ReducedDisk nor PixelPhase2TDRDisk...";
0135 }
0136 }
0137 }
0138
0139 if (theGeomDetLayer->type() == GeometricDet::TID) {
0140 auto const &theTIDGeometricDetLayers = theGeomDetLayer->components();
0141 for (auto const &thisGeomDet : theTIDGeometricDetLayers) {
0142 if (thisGeomDet->positionBounds().z() < 0)
0143 theNegTIDLayers.push_back(aTIDLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0144 else
0145 thePosTIDLayers.push_back(aTIDLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0146 }
0147 }
0148
0149 if (theGeomDetLayer->type() == GeometricDet::OTPhase2EndCap) {
0150 auto const &theTIDGeometricDetLayers = theGeomDetLayer->components();
0151 for (auto const &thisGeomDet : theTIDGeometricDetLayers) {
0152 if (thisGeomDet->positionBounds().z() < 0)
0153 theNegTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, useBrothers));
0154 else
0155 thePosTIDLayers.push_back(aPhase2EndcapLayerBuilder.build(thisGeomDet, theGeomDetGeometry, useBrothers));
0156 }
0157 }
0158
0159 if (theGeomDetLayer->type() == GeometricDet::TEC) {
0160 auto const &theTECGeometricDetLayers = theGeomDetLayer->components();
0161 for (auto const &thisGeomDet : theTECGeometricDetLayers) {
0162 if (thisGeomDet->positionBounds().z() < 0)
0163 theNegTECLayers.push_back(aTECLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0164 else
0165 thePosTECLayers.push_back(aTECLayerBuilder.build(thisGeomDet, theGeomDetGeometry));
0166 }
0167 }
0168 }
0169
0170 return new GeometricSearchTracker(thePxlBarLayers,
0171 theTIBLayers,
0172 theTOBLayers,
0173 theNegPxlFwdLayers,
0174 theNegTIDLayers,
0175 theNegTECLayers,
0176 thePosPxlFwdLayers,
0177 thePosTIDLayers,
0178 thePosTECLayers,
0179 tTopo);
0180 }
0181
0182 GeometricSearchTracker *GeometricSearchTrackerBuilder::build(const GeometricDet *theGeometricTracker,
0183 const TrackerGeometry *theGeomDetGeometry,
0184 const TrackerTopology *tTopo,
0185 const MTDGeometry *mtd,
0186 const MTDTopology *mTopo,
0187 const bool usePhase2Stacks) {
0188
0189 GeometricSearchTracker *theSearchTrack = this->build(theGeometricTracker, theGeomDetGeometry, tTopo, usePhase2Stacks);
0190
0191 theSearchTrack->addDetLayerGeometry();
0192 theSearchTrack->mtdDetLayerGeometry->buildLayers(mtd, mTopo);
0193 theSearchTrack->mtdDetLayerGeometry->sortLayers();
0194
0195 std::vector<const BarrelDetLayer *> barrel;
0196 for (auto &&e : theSearchTrack->mtdDetLayerGeometry->allBarrelLayers()) {
0197 auto p = dynamic_cast<const BarrelDetLayer *>(e);
0198 if (p) {
0199 barrel.push_back(p);
0200 }
0201 }
0202 std::vector<const ForwardDetLayer *> backward;
0203 for (auto &&e : theSearchTrack->mtdDetLayerGeometry->allBackwardLayers()) {
0204 auto p = dynamic_cast<const ForwardDetLayer *>(e);
0205 if (p) {
0206 backward.push_back(p);
0207 }
0208 }
0209 std::vector<const ForwardDetLayer *> forward;
0210 for (auto &&e : theSearchTrack->mtdDetLayerGeometry->allForwardLayers()) {
0211 auto p = dynamic_cast<const ForwardDetLayer *>(e);
0212 if (p) {
0213 forward.push_back(p);
0214 }
0215 }
0216
0217 theSearchTrack->addMTDLayers(barrel, backward, forward);
0218 return theSearchTrack;
0219 }