Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:13:54

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DD4hep/DetectorSelector.h>
0016 #include <DD4hep/Detector.h>
0017 
0018 using namespace dd4hep;
0019 
0020 /// Access a set of subdetectors according to the sensitive type.
0021 const DetectorSelector::Result& DetectorSelector::detectors(const std::string& type)
0022 {
0023   return description.detectors(type);
0024 }
0025 
0026 /// Access a set of subdetectors according to several sensitive types.
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 /** return a vector with all detectors that have all the type properties in
0048  *  includeFlag set but none of the properties given in excludeFlag
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(""); // Just to ensure the geometry is closed....
0056   for( const auto& i : entries )  {
0057     DetElement det(i.second);
0058     if ( det.parent().isValid() )  { // Exclude 'world'
0059       //fixme: what to do with compounds - add their daughters  ?
0060       // ...
0061       if( ( det.typeFlag() &  includeFlag ) == includeFlag &&
0062           ( det.typeFlag() &  excludeFlag ) ==  0 )
0063         result.emplace_back( det ) ;
0064     }
0065   }
0066   return result;
0067 }