Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:51

0001 #include "FastSimulation/Tracking/interface/TrackingLayer.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0004 
0005 const TrackingLayer::eqfct TrackingLayer::_eqfct;
0006 
0007 TrackingLayer::TrackingLayer() : _subDet(Det::UNKNOWN), _side(Side::BARREL), _layerNumber(0) {}
0008 
0009 TrackingLayer TrackingLayer::createFromDetId(const DetId& detId, const TrackerTopology& trackerTopology) {
0010   TrackingLayer trackingLayer;
0011   uint32_t subdet = detId.subdetId();
0012   //BPix
0013   if (subdet == PixelSubdetector::PixelBarrel) {
0014     trackingLayer._subDet = TrackingLayer::Det::PXB;
0015     trackingLayer._side = TrackingLayer::Side::BARREL;
0016     trackingLayer._layerNumber = trackerTopology.pxbLayer(detId);
0017   }
0018   //FPix
0019   else if (subdet == PixelSubdetector::PixelEndcap) {
0020     trackingLayer._subDet = TrackingLayer::Det::PXD;
0021     if (trackerTopology.pxfSide(detId) == 1) {
0022       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0023     } else if (trackerTopology.pxfSide(detId) == 2) {
0024       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0025     } else {
0026       throw cms::Exception("FastSimulation/Tracking")
0027           << "Tracker hit for seeding in FPix seems neither on positive nor on negative disk side: "
0028           << trackerTopology.print(detId).c_str();
0029     }
0030     trackingLayer._layerNumber = trackerTopology.pxfDisk(detId);
0031   }
0032   //TIB
0033   else if (subdet == StripSubdetector::TIB) {
0034     trackingLayer._subDet = TrackingLayer::Det::TIB;
0035     trackingLayer._side = TrackingLayer::Side::BARREL;
0036     trackingLayer._layerNumber = trackerTopology.tibLayer(detId);
0037   }
0038   //TID
0039   else if (subdet == StripSubdetector::TID) {
0040     trackingLayer._subDet = TrackingLayer::Det::TID;
0041     if (trackerTopology.tidSide(detId) == 1) {
0042       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0043     } else if (trackerTopology.tidSide(detId) == 2) {
0044       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0045     } else {
0046       throw cms::Exception("FastSimulation/Tracking")
0047           << "Tracker hit for seeding in TID seems neither on positive nor on negative disk side: "
0048           << trackerTopology.print(detId).c_str();
0049     }
0050     trackingLayer._layerNumber = trackerTopology.tidWheel(detId);
0051   }
0052   //TOB
0053   else if (subdet == StripSubdetector::TOB) {
0054     trackingLayer._subDet = TrackingLayer::Det::TOB;
0055     trackingLayer._side = TrackingLayer::Side::BARREL;
0056     trackingLayer._layerNumber = trackerTopology.tobLayer(detId);
0057   }
0058   //TEC
0059   else if (subdet == StripSubdetector::TEC) {
0060     trackingLayer._subDet = TrackingLayer::Det::TEC;
0061     if (trackerTopology.tecSide(detId) == 1) {
0062       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0063     } else if (trackerTopology.tecSide(detId) == 2) {
0064       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0065     } else {
0066       throw cms::Exception("FastSimulation/Tracking")
0067           << "Tracker hit for seeding in TEC seems neither on positive nor on negative disk side: "
0068           << trackerTopology.print(detId).c_str();
0069     }
0070     trackingLayer._layerNumber = trackerTopology.tecWheel(detId);
0071   } else {
0072     throw cms::Exception("FastSimulation/Tracking")
0073         << "Cannot determine seeding layer from DetId:" << trackerTopology.print(detId).c_str() << std::endl;
0074   }
0075   //std::cout<<"LayerSpec::createFromDetId: "<<trackerTopology.print(detId).c_str()<<", parsed="<<seedingLayer.print().c_str()<<std::endl;
0076   return trackingLayer;
0077 }
0078 
0079 TrackingLayer TrackingLayer::createFromString(std::string layerSpecification) {
0080   TrackingLayer trackingLayer;
0081   if (layerSpecification.substr(0, 4) == "BPix") {
0082     trackingLayer._subDet = TrackingLayer::Det::PXB;
0083     trackingLayer._side = TrackingLayer::Side::BARREL;
0084     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(4, 1).c_str());
0085   } else if (layerSpecification.substr(0, 4) == "FPix") {
0086     trackingLayer._subDet = TrackingLayer::Det::PXD;
0087     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(4, 1).c_str());
0088     if (layerSpecification.substr(layerSpecification.size() - 3) == "pos") {
0089       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0090     } else if (layerSpecification.substr(layerSpecification.size() - 3) == "neg") {
0091       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0092     } else {
0093       throw cms::Exception("FastSimulation/Tracking/python")
0094           << "FPix seeding layer configuration '" << layerSpecification.c_str()
0095           << "' does not specify the side correctly!";
0096     }
0097 
0098   } else if (layerSpecification.substr(0, 3) == "TIB") {
0099     trackingLayer._subDet = TrackingLayer::Det::TIB;
0100     trackingLayer._side = TrackingLayer::Side::BARREL;
0101     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(3, 1).c_str());
0102   } else if (layerSpecification.substr(0, 4) == "MTIB") {
0103     trackingLayer._subDet = TrackingLayer::Det::TIB;
0104     trackingLayer._side = TrackingLayer::Side::BARREL;
0105     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(4, 1).c_str());
0106   }
0107 
0108   else if (layerSpecification.substr(0, 3) == "TID") {
0109     trackingLayer._subDet = TrackingLayer::Det::TID;
0110     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(3, 1).c_str());
0111     if (layerSpecification.substr(layerSpecification.size() - 3) == "pos") {
0112       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0113     } else if (layerSpecification.substr(layerSpecification.size() - 3) == "neg") {
0114       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0115     } else {
0116       throw cms::Exception("FastSimulation/Tracking/python")
0117           << "TID seeding layer configuration '" << layerSpecification.c_str()
0118           << "' does not specify the side correctly!";
0119     }
0120   } else if (layerSpecification.substr(0, 4) == "MTID") {
0121     trackingLayer._subDet = TrackingLayer::Det::TID;
0122     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(4, 1).c_str());
0123     if (layerSpecification.substr(layerSpecification.size() - 3) == "pos") {
0124       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0125     } else if (layerSpecification.substr(layerSpecification.size() - 3) == "neg") {
0126       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0127     } else {
0128       throw cms::Exception("FastSimulation/Tracking/python")
0129           << "MTID seeding layer configuration '" << layerSpecification.c_str()
0130           << "' does not specify the side correctly!";
0131     }
0132   } else if (layerSpecification.substr(0, 3) == "TOB") {
0133     trackingLayer._subDet = TrackingLayer::Det::TOB;
0134     trackingLayer._side = TrackingLayer::Side::BARREL;
0135     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(3, 1).c_str());
0136   } else if (layerSpecification.substr(0, 4) == "MTOB") {
0137     trackingLayer._subDet = TrackingLayer::Det::TOB;
0138     trackingLayer._side = TrackingLayer::Side::BARREL;
0139     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(4, 1).c_str());
0140   } else if (layerSpecification.substr(0, 3) == "TEC") {
0141     trackingLayer._subDet = TrackingLayer::Det::TEC;
0142     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(3, 1).c_str());
0143     if (layerSpecification.substr(layerSpecification.size() - 3) == "pos") {
0144       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0145     } else if (layerSpecification.substr(layerSpecification.size() - 3) == "neg") {
0146       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0147     } else {
0148       throw cms::Exception("FastSimulation/Tracking/python")
0149           << "TEC seeding layer configuration '" << layerSpecification.c_str()
0150           << "' does not specify the side correctly!";
0151     }
0152 
0153   } else if (layerSpecification.substr(0, 4) == "MTEC") {
0154     trackingLayer._subDet = TrackingLayer::Det::TEC;
0155     trackingLayer._layerNumber = std::atoi(layerSpecification.substr(4, 1).c_str());
0156     if (layerSpecification.substr(layerSpecification.size() - 3) == "pos") {
0157       trackingLayer._side = TrackingLayer::Side::POS_ENDCAP;
0158     } else if (layerSpecification.substr(layerSpecification.size() - 3) == "neg") {
0159       trackingLayer._side = TrackingLayer::Side::NEG_ENDCAP;
0160     } else {
0161       throw cms::Exception("FastSimulation/Tracking/python")
0162           << "MTEC seeding layer configuration '" << layerSpecification.c_str()
0163           << "' does not specify the side correctly!";
0164     }
0165   } else {
0166     throw cms::Exception("FastSimulation/Tracking/python")
0167         << "Bad data naming in seeding layer configuration."
0168         << "no case sensitive name of ['BPix','FPix','TIB','MTIB','TID','MTID','TOB','TEC','MTEC'] matches '"
0169         << layerSpecification.c_str() << "'";
0170   }
0171   //std::cout<<"LayerSpec::createFromString: "<<layerSpecification.c_str()<<", parsed="<<seedingLayer.print().c_str()<<std::endl;
0172 
0173   return trackingLayer;
0174 }
0175 
0176 std::string TrackingLayer::toString() const {
0177   std::stringstream ss;
0178   switch (_subDet) {
0179     case TrackingLayer::Det::UNKNOWN:
0180       ss << "unknown";
0181       break;
0182     case TrackingLayer::Det::PXB:
0183       ss << " BPix";
0184       break;
0185     case TrackingLayer::Det::PXD:
0186       ss << " FPix";
0187       break;
0188     case TrackingLayer::Det::TIB:
0189       ss << " TIB";
0190       break;
0191     case TrackingLayer::Det::TID:
0192       ss << " TID";
0193       break;
0194     case TrackingLayer::Det::TOB:
0195       ss << " TOB";
0196       break;
0197     case TrackingLayer::Det::TEC:
0198       ss << " TEC";
0199       break;
0200   }
0201   ss << _layerNumber;
0202   switch (_side) {
0203     case TrackingLayer::Side::BARREL:
0204       break;
0205     case Side::NEG_ENDCAP:
0206       ss << "_neg";
0207       break;
0208     case TrackingLayer::Side::POS_ENDCAP:
0209       ss << "_pos";
0210       break;
0211   }
0212 
0213   return ss.str();
0214 }
0215 
0216 std::string TrackingLayer::toIdString() const {
0217   std::stringstream ss;
0218   ss << getSubDetNumber() << ":" << getLayerNumber() << ":" << getSideNumber();
0219   return ss.str();
0220 }