File indexing completed on 2021-02-14 12:49:08
0001 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0002 #include "DetectorDescription/DDCMS/interface/DDFilteredView.h"
0003 #include "Geometry/TrackerNumberingBuilder/plugins/CmsDetConstruction.h"
0004 #include "Geometry/TrackerNumberingBuilder/plugins/ExtractStringFromDDD.h"
0005 #include "DataFormats/DetId/interface/DetId.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008 template <class FilteredView>
0009 void CmsDetConstruction<FilteredView>::buildSmallDetsforGlued(FilteredView& fv,
0010 GeometricDet* mother,
0011 const std::string& attribute) {
0012 GeometricDet* det = new GeometricDet(&fv,
0013 CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0014 ExtractStringFromDDD<FilteredView>::getString(attribute, &fv)));
0015 if (det->stereo()) {
0016 uint32_t temp = 1;
0017 det->setGeographicalID(DetId(temp));
0018 } else {
0019 uint32_t temp = 2;
0020 det->setGeographicalID(DetId(temp));
0021 }
0022
0023 mother->addComponent(det);
0024 }
0025
0026 template <class FilteredView>
0027 void CmsDetConstruction<FilteredView>::buildSmallDetsforStack(FilteredView& fv,
0028 GeometricDet* mother,
0029 const std::string& attribute) {
0030 GeometricDet* det = new GeometricDet(&fv,
0031 CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0032 ExtractStringFromDDD<FilteredView>::getString(attribute, &fv)));
0033
0034 if (det->isLowerSensor()) {
0035 uint32_t temp = 1;
0036 det->setGeographicalID(DetId(temp));
0037 } else if (det->isUpperSensor()) {
0038 uint32_t temp = 2;
0039 det->setGeographicalID(DetId(temp));
0040 } else {
0041 edm::LogError("DetConstruction") << " module defined in a Stack but not upper either lower!? ";
0042 }
0043 mother->addComponent(det);
0044 }
0045
0046
0047
0048
0049
0050
0051 template <>
0052 void CmsDetConstruction<DDFilteredView>::buildComponent(DDFilteredView& fv,
0053 GeometricDet* mother,
0054 const std::string& attribute) {
0055
0056
0057
0058 const std::string& myTopologicalNameInXMLs = ExtractStringFromDDD<DDFilteredView>::getString(attribute, &fv);
0059 const GeometricDet::GDEnumType& myTopologicalType =
0060 CmsTrackerLevelBuilder<DDFilteredView>::theCmsTrackerStringToEnum.type(myTopologicalNameInXMLs);
0061
0062 GeometricDet* det = new GeometricDet(&fv, myTopologicalType);
0063
0064 const bool isPhase1ModuleWith2Sensors = (myTopologicalType == GeometricDet::mergedDet);
0065 const bool isPhase2ModuleWith2Sensors = (myTopologicalType == GeometricDet::OTPhase2Stack);
0066
0067
0068 if (isPhase1ModuleWith2Sensors || isPhase2ModuleWith2Sensors) {
0069
0070 bool dodets = fv.firstChild();
0071 while (dodets) {
0072
0073 if (isPhase1ModuleWith2Sensors) {
0074 buildSmallDetsforGlued(fv, det, attribute);
0075 }
0076
0077 else if (isPhase2ModuleWith2Sensors) {
0078 buildSmallDetsforStack(fv, det, attribute);
0079 }
0080
0081 dodets = fv.nextSibling();
0082 }
0083
0084 fv.parent();
0085 }
0086
0087
0088
0089
0090
0091 mother->addComponent(det);
0092 }
0093
0094
0095
0096
0097
0098
0099 template <>
0100 void CmsDetConstruction<cms::DDFilteredView>::buildComponent(cms::DDFilteredView& fv,
0101 GeometricDet* mother,
0102 const std::string& attribute) {
0103
0104
0105
0106 const std::string& myTopologicalNameInXMLs = ExtractStringFromDDD<cms::DDFilteredView>::getString(attribute, &fv);
0107 const GeometricDet::GDEnumType& myTopologicalType =
0108 CmsTrackerLevelBuilder<cms::DDFilteredView>::theCmsTrackerStringToEnum.type(myTopologicalNameInXMLs);
0109 GeometricDet* det = new GeometricDet(&fv, myTopologicalType);
0110
0111 const bool isPhase1ModuleWith2Sensors = (myTopologicalType == GeometricDet::mergedDet);
0112 const bool isPhase2ModuleWith2Sensors = (myTopologicalType == GeometricDet::OTPhase2Stack);
0113
0114
0115 if (isPhase1ModuleWith2Sensors || isPhase2ModuleWith2Sensors) {
0116
0117 if (!fv.firstChild()) {
0118 edm::LogError("CmsDetConstruction::buildComponent. Cannot go down to sensor volume.");
0119 return;
0120 }
0121
0122
0123 const int sensorHierarchyLevel = fv.level();
0124
0125
0126 while (fv.level() == sensorHierarchyLevel) {
0127
0128 if (isPhase1ModuleWith2Sensors) {
0129 buildSmallDetsforGlued(fv, det, attribute);
0130 }
0131
0132 else if (isPhase2ModuleWith2Sensors) {
0133 buildSmallDetsforStack(fv, det, attribute);
0134 }
0135
0136
0137
0138
0139 fv.firstChild();
0140 }
0141 }
0142
0143
0144
0145 else {
0146
0147 fv.firstChild();
0148 }
0149
0150
0151 mother->addComponent(det);
0152 }