File indexing completed on 2025-01-18 09:13:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/DetectorSelector.h>
0016 #include <DD4hep/Detector.h>
0017
0018 using namespace dd4hep;
0019
0020
0021 const DetectorSelector::Result& DetectorSelector::detectors(const std::string& type)
0022 {
0023 return description.detectors(type);
0024 }
0025
0026
0027 DetectorSelector::Result
0028 DetectorSelector::detectors(const std::string& type1,
0029 const std::string& type2,
0030 const std::string& type3,
0031 const std::string& type4,
0032 const std::string& type5) {
0033 const std::string* types[] = { &type1, &type2, &type3, &type4, &type5 };
0034 Result result;
0035 for( std::size_t i=0; i<sizeof(types)/sizeof(types[0]); ++i ) {
0036 try {
0037 if ( !types[i]->empty() ) {
0038 const std::vector<DetElement>& v = description.detectors(*(types[i]));
0039 result.insert(std::end(result), std::begin(v), std::end(v));
0040 }
0041 }
0042 catch(...) {}
0043 }
0044 return result;
0045 }
0046
0047
0048
0049
0050 DetectorSelector::Result
0051 DetectorSelector::detectors(unsigned int includeFlag, unsigned int excludeFlag ) const {
0052 Result result;
0053 const Detector::HandleMap& entries = description.detectors();
0054 result.reserve( entries.size() ) ;
0055 description.detectors("");
0056 for( const auto& i : entries ) {
0057 DetElement det(i.second);
0058 if ( det.parent().isValid() ) {
0059
0060
0061 if( ( det.typeFlag() & includeFlag ) == includeFlag &&
0062 ( det.typeFlag() & excludeFlag ) == 0 )
0063 result.emplace_back( det ) ;
0064 }
0065 }
0066 return result;
0067 }