Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-12 23:30:37

0001 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
0002 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 
0006 using namespace std;
0007 
0008 GeometricSearchTracker::GeometricSearchTracker(const vector<BarrelDetLayer const*>& pxlBar,
0009                                                const vector<BarrelDetLayer const*>& tib,
0010                                                const vector<BarrelDetLayer const*>& tob,
0011                                                const vector<ForwardDetLayer const*>& negPxlFwd,
0012                                                const vector<ForwardDetLayer const*>& negTid,
0013                                                const vector<ForwardDetLayer const*>& negTec,
0014                                                const vector<ForwardDetLayer const*>& posPxlFwd,
0015                                                const vector<ForwardDetLayer const*>& posTid,
0016                                                const vector<ForwardDetLayer const*>& posTec,
0017                                                const TrackerTopology* tTopo)
0018     : thePixelBarrelLayers(pxlBar.begin(), pxlBar.end()),
0019       theTibLayers(tib.begin(), tib.end()),
0020       theTobLayers(tob.begin(), tob.end()),
0021       theNegPixelForwardLayers(negPxlFwd.begin(), negPxlFwd.end()),
0022       theNegTidLayers(negTid.begin(), negTid.end()),
0023       theNegTecLayers(negTec.begin(), negTec.end()),
0024       thePosPixelForwardLayers(posPxlFwd.begin(), posPxlFwd.end()),
0025       thePosTidLayers(posTid.begin(), posTid.end()),
0026       thePosTecLayers(posTec.begin(), posTec.end()),
0027       theTrkTopo(tTopo) {
0028   theBarrelLayers.assign(thePixelBarrelLayers.begin(), thePixelBarrelLayers.end());
0029   theBarrelLayers.insert(theBarrelLayers.end(), theTibLayers.begin(), theTibLayers.end());
0030   theBarrelLayers.insert(theBarrelLayers.end(), theTobLayers.begin(), theTobLayers.end());
0031 
0032   theNegForwardLayers.assign(theNegPixelForwardLayers.begin(), theNegPixelForwardLayers.end());
0033   theNegForwardLayers.insert(theNegForwardLayers.end(), theNegTidLayers.begin(), theNegTidLayers.end());
0034   theNegForwardLayers.insert(theNegForwardLayers.end(), theNegTecLayers.begin(), theNegTecLayers.end());
0035 
0036   thePosForwardLayers.assign(thePosPixelForwardLayers.begin(), thePosPixelForwardLayers.end());
0037   thePosForwardLayers.insert(thePosForwardLayers.end(), thePosTidLayers.begin(), thePosTidLayers.end());
0038   thePosForwardLayers.insert(thePosForwardLayers.end(), thePosTecLayers.begin(), thePosTecLayers.end());
0039 
0040   theForwardLayers.assign(theNegForwardLayers.begin(), theNegForwardLayers.end());
0041   theForwardLayers.insert(theForwardLayers.end(), thePosForwardLayers.begin(), thePosForwardLayers.end());
0042   theAllLayers.assign(theBarrelLayers.begin(), theBarrelLayers.end());
0043   theAllLayers.insert(theAllLayers.end(), theForwardLayers.begin(), theForwardLayers.end());
0044 
0045   // number the layers
0046   int sq = 0;
0047   for (auto l : theAllLayers)
0048     const_cast<DetLayer&>(*l).setSeqNum(sq++);
0049 
0050   edm::LogInfo("TkDetLayers") << "------ GeometricSearchTracker constructed with: ------"
0051                               << "\n"
0052                               << "n pxlBarLayers: " << this->pixelBarrelLayers().size() << "\n"
0053                               << "n tibLayers:    " << this->tibLayers().size() << "\n"
0054                               << "n tobLayers:    " << this->tobLayers().size() << "\n"
0055                               << "n negPxlFwdLayers: " << this->negPixelForwardLayers().size() << "\n"
0056                               << "n posPxlFwdLayers: " << this->posPixelForwardLayers().size() << "\n"
0057                               << "n negTidLayers: " << this->negTidLayers().size() << "\n"
0058                               << "n posTidLayers: " << this->posTidLayers().size() << "\n"
0059                               << "n negTecLayers: " << this->negTecLayers().size() << "\n"
0060                               << "n posTecLayers: " << this->posTecLayers().size() << "\n"
0061 
0062                               << "n barreLayers:  " << this->barrelLayers().size() << "\n"
0063                               << "n negforwardLayers: " << this->negForwardLayers().size() << "\n"
0064                               << "n posForwardLayers: " << this->posForwardLayers().size()
0065                               << "\nn Total :     " << theAllLayers.size() << " " << sq << std::endl;
0066 
0067   for (auto l : theAllLayers)
0068     edm::LogInfo("TkDetLayers") << (*l).seqNum() << ": " << (*l).subDetector() << ", ";
0069   edm::LogInfo("TkDetLayers") << std::endl;
0070 }
0071 
0072 GeometricSearchTracker::~GeometricSearchTracker() {
0073   for (auto l : theAllLayers)
0074     delete const_cast<DetLayer*>(l);
0075 }
0076 
0077 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0078 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0079 
0080 const DetLayer* GeometricSearchTracker::idToLayer(const DetId& id) const {
0081   //If it's a tracker Det
0082   if (id.det() == DetId::Detector::Tracker) {
0083     switch (id.subdetId()) {
0084       case StripSubdetector::TIB:
0085         return theTibLayers[theTrkTopo->tibLayer(id) - 1];
0086         break;
0087 
0088       case StripSubdetector::TOB:
0089         return theTobLayers[theTrkTopo->tobLayer(id) - 1];
0090         break;
0091 
0092       case StripSubdetector::TID:
0093         if (theTrkTopo->tidSide(id) == 1) {
0094           return theNegTidLayers[theTrkTopo->tidWheel(id) - 1];
0095         } else if (theTrkTopo->tidSide(id) == 2) {
0096           return thePosTidLayers[theTrkTopo->tidWheel(id) - 1];
0097         }
0098         break;
0099 
0100       case StripSubdetector::TEC:
0101         if (theTrkTopo->tecSide(id) == 1) {
0102           return theNegTecLayers[theTrkTopo->tecWheel(id) - 1];
0103         } else if (theTrkTopo->tecSide(id) == 2) {
0104           return thePosTecLayers[theTrkTopo->tecWheel(id) - 1];
0105         }
0106         break;
0107 
0108       case PixelSubdetector::PixelBarrel:
0109         return thePixelBarrelLayers[theTrkTopo->pxbLayer(id) - 1];
0110         break;
0111 
0112       case PixelSubdetector::PixelEndcap:
0113         if (theTrkTopo->pxfSide(id) == 1) {
0114           return theNegPixelForwardLayers[theTrkTopo->pxfDisk(id) - 1];
0115         } else if (theTrkTopo->pxfSide(id) == 2) {
0116           return thePosPixelForwardLayers[theTrkTopo->pxfDisk(id) - 1];
0117         }
0118         break;
0119 
0120       default:
0121         edm::LogError("TkDetLayers") << "ERROR:layer not found!";
0122         // throw(something);
0123     }
0124     return nullptr;  //just to avoid compile warnings
0125   } else if (id.det() == DetId::Forward && id.subdetId() == FastTime) {
0126     //If it's MTD
0127     return mtdDetLayerGeometry->idToLayer(id);
0128   }
0129   return nullptr;  //just to avoid compile warnings
0130 }
0131 
0132 void GeometricSearchTracker::addDetLayerGeometry() { mtdDetLayerGeometry = new MTDDetLayerGeometry(); }
0133 
0134 void GeometricSearchTracker::addMTDLayers(const std::vector<BarrelDetLayer const*>& btl,
0135                                           const std::vector<ForwardDetLayer const*>& negEtl,
0136                                           const std::vector<ForwardDetLayer const*>& posEtl) {
0137   //Barrel
0138   theBTLLayers.assign(btl.begin(), btl.end());
0139   theBarrelLayers.insert(theBarrelLayers.end(), theBTLLayers.begin(), theBTLLayers.end());
0140   //Endcap
0141   theNegETLLayers.assign(negEtl.begin(), negEtl.end());
0142   thePosETLLayers.assign(posEtl.begin(), posEtl.end());
0143   theETLLayers.assign(negEtl.begin(), negEtl.end());
0144   theETLLayers.insert(theETLLayers.end(), posEtl.begin(), posEtl.end());
0145   theNegForwardLayers.insert(theNegForwardLayers.end(), theNegETLLayers.begin(), theNegETLLayers.end());
0146   thePosForwardLayers.insert(thePosForwardLayers.end(), thePosETLLayers.begin(), thePosETLLayers.end());
0147   //Reordering of tracker + MTD layers
0148   theForwardLayers.clear();
0149   theAllLayers.clear();
0150   theForwardLayers.assign(theNegForwardLayers.begin(), theNegForwardLayers.end());
0151   theForwardLayers.insert(theForwardLayers.end(), thePosForwardLayers.begin(), thePosForwardLayers.end());
0152   theAllLayers.assign(theBarrelLayers.begin(), theBarrelLayers.end());
0153   theAllLayers.insert(theAllLayers.end(), theForwardLayers.begin(), theForwardLayers.end());
0154 
0155   // number the layers
0156   int sq = 0;
0157   for (auto l : theAllLayers)
0158     const_cast<DetLayer&>(*l).setSeqNum(sq++);
0159 
0160   edm::LogInfo("MTDDetLayers") << "------ GeometricSearchTracker+MTD constructed with: ------"
0161                                << "\n"
0162                                << "n pxlBarLayers: " << this->pixelBarrelLayers().size() << "\n"
0163                                << "n tibLayers:    " << this->tibLayers().size() << "\n"
0164                                << "n tobLayers:    " << this->tobLayers().size() << "\n"
0165                                << "n negPxlFwdLayers: " << this->negPixelForwardLayers().size() << "\n"
0166                                << "n posPxlFwdLayers: " << this->posPixelForwardLayers().size() << "\n"
0167                                << "n negTidLayers: " << this->negTidLayers().size() << "\n"
0168                                << "n posTidLayers: " << this->posTidLayers().size() << "\n"
0169                                << "n negTecLayers: " << this->negTecLayers().size() << "\n"
0170                                << "n posTecLayers: " << this->posTecLayers().size() << "\n"
0171                                << "n barreLayers:  " << this->barrelLayers().size() << "\n"
0172                                << "n negforwardLayers: " << this->negForwardLayers().size() << "\n"
0173                                << "n posForwardLayers: " << this->posForwardLayers().size() << "\n"
0174                                << "n MTDbarrelLayers: " << this->theBTLLayers.size() << "\n"
0175                                << "n MTDnegLayers: " << this->theNegETLLayers.size() << "\n"
0176                                << "n MTDposLayers: " << this->thePosETLLayers.size() << "\n"
0177                                << "\nn Total :     " << theAllLayers.size() << std::endl;
0178 }