File indexing completed on 2024-09-26 05:06:56
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 #include <memory>
0008
0009 template <class FilteredView>
0010 void CmsDetConstruction<FilteredView>::buildSmallDetsforGlued(FilteredView& fv,
0011 GeometricDet* mother,
0012 const std::string& attribute) {
0013 auto det = std::make_unique<GeometricDet>(&fv,
0014 CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0015 ExtractStringFromDDD<FilteredView>::getString(attribute, &fv)));
0016 if (det->stereo()) {
0017 uint32_t temp = 1;
0018 det->setGeographicalID(DetId(temp));
0019 } else {
0020 uint32_t temp = 2;
0021 det->setGeographicalID(DetId(temp));
0022 }
0023
0024 mother->addComponent(det.release());
0025 }
0026
0027 template <class FilteredView>
0028 void CmsDetConstruction<FilteredView>::buildSmallDetsforStack(FilteredView& fv,
0029 GeometricDet* mother,
0030 const std::string& attribute) {
0031 auto det = std::make_unique<GeometricDet>(&fv,
0032 CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0033 ExtractStringFromDDD<FilteredView>::getString(attribute, &fv)));
0034
0035 if (det->isLowerSensor()) {
0036 uint32_t temp = 1;
0037 det->setGeographicalID(DetId(temp));
0038 } else if (det->isUpperSensor()) {
0039 uint32_t temp = 2;
0040 det->setGeographicalID(DetId(temp));
0041 } else {
0042 edm::LogError("DetConstruction") << " module defined in a Stack but not upper either lower!? ";
0043 }
0044 mother->addComponent(det.release());
0045 }
0046
0047 template <class FilteredView>
0048 void CmsDetConstruction<FilteredView>::buildSmallDetsfor3D(FilteredView& fv,
0049 GeometricDet* mother,
0050 const std::string& attribute) {
0051 auto det = std::make_unique<GeometricDet>(&fv,
0052 CmsTrackerLevelBuilder<FilteredView>::theCmsTrackerStringToEnum.type(
0053 ExtractStringFromDDD<FilteredView>::getString(attribute, &fv)));
0054
0055 if (det->isFirstSensor()) {
0056 uint32_t temp = 1;
0057 det->setGeographicalID(DetId(temp));
0058 } else if (det->isSecondSensor()) {
0059 uint32_t temp = 2;
0060 det->setGeographicalID(DetId(temp));
0061 } else {
0062 edm::LogError("DetConstruction") << " module defined in a 3D module but not first or second sensor!? ";
0063 }
0064 mother->addComponent(det.release());
0065 }
0066
0067
0068
0069
0070
0071
0072 template <>
0073 void CmsDetConstruction<DDFilteredView>::buildComponent(DDFilteredView& fv,
0074 GeometricDet* mother,
0075 const std::string& attribute) {
0076
0077
0078
0079 const std::string& myTopologicalNameInXMLs = ExtractStringFromDDD<DDFilteredView>::getString(attribute, &fv);
0080 const GeometricDet::GDEnumType& myTopologicalType =
0081 CmsTrackerLevelBuilder<DDFilteredView>::theCmsTrackerStringToEnum.type(myTopologicalNameInXMLs);
0082
0083 auto det = std::make_unique<GeometricDet>(&fv, myTopologicalType);
0084
0085 const bool isPhase1ModuleWith2Sensors = (myTopologicalType == GeometricDet::mergedDet);
0086 const bool isPhase2ModuleWith2Sensors = (myTopologicalType == GeometricDet::OTPhase2Stack);
0087 const bool isPhase2BarrelModuleWith2Sensors = (myTopologicalType == GeometricDet::ITPhase2Combined);
0088
0089
0090 if (isPhase1ModuleWith2Sensors || isPhase2ModuleWith2Sensors || isPhase2BarrelModuleWith2Sensors) {
0091
0092 bool dodets = fv.firstChild();
0093 while (dodets) {
0094
0095 if (isPhase1ModuleWith2Sensors) {
0096 buildSmallDetsforGlued(fv, det.get(), attribute);
0097 }
0098
0099 else if (isPhase2ModuleWith2Sensors) {
0100 buildSmallDetsforStack(fv, det.get(), attribute);
0101 } else if (isPhase2BarrelModuleWith2Sensors) {
0102 buildSmallDetsfor3D(fv, det.get(), attribute);
0103 }
0104
0105 dodets = fv.nextSibling();
0106 }
0107
0108 fv.parent();
0109 }
0110
0111
0112
0113
0114
0115 mother->addComponent(det.release());
0116 }
0117
0118
0119
0120
0121
0122
0123 template <>
0124 void CmsDetConstruction<cms::DDFilteredView>::buildComponent(cms::DDFilteredView& fv,
0125 GeometricDet* mother,
0126 const std::string& attribute) {
0127
0128
0129
0130 const std::string& myTopologicalNameInXMLs = ExtractStringFromDDD<cms::DDFilteredView>::getString(attribute, &fv);
0131 const GeometricDet::GDEnumType& myTopologicalType =
0132 CmsTrackerLevelBuilder<cms::DDFilteredView>::theCmsTrackerStringToEnum.type(myTopologicalNameInXMLs);
0133 auto det = std::make_unique<GeometricDet>(&fv, myTopologicalType);
0134
0135 const bool isPhase1ModuleWith2Sensors = (myTopologicalType == GeometricDet::mergedDet);
0136 const bool isPhase2ModuleWith2Sensors = (myTopologicalType == GeometricDet::OTPhase2Stack);
0137 const bool isPhase2BarrelModuleWith2Sensors = (myTopologicalType == GeometricDet::ITPhase2Combined);
0138
0139
0140 if (isPhase1ModuleWith2Sensors || isPhase2ModuleWith2Sensors || isPhase2BarrelModuleWith2Sensors) {
0141
0142 if (!fv.firstChild()) {
0143 edm::LogError("CmsDetConstruction::buildComponent. Cannot go down to sensor volume.");
0144 return;
0145 }
0146
0147
0148 const int sensorHierarchyLevel = fv.level();
0149
0150
0151 while (fv.level() == sensorHierarchyLevel) {
0152
0153 if (isPhase1ModuleWith2Sensors) {
0154 buildSmallDetsforGlued(fv, det.get(), attribute);
0155 }
0156
0157 else if (isPhase2ModuleWith2Sensors) {
0158 buildSmallDetsforStack(fv, det.get(), attribute);
0159 } else if (isPhase2BarrelModuleWith2Sensors) {
0160 buildSmallDetsfor3D(fv, det.get(), attribute);
0161 }
0162
0163
0164
0165
0166 fv.firstChild();
0167 }
0168 }
0169
0170
0171
0172 else {
0173
0174 fv.firstChild();
0175 }
0176
0177
0178 mother->addComponent(det.release());
0179 }