Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-05 09:10:39

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     : F.Gaede
0011 //
0012 //==========================================================================
0013 
0014 #ifndef DD4HEP_DETTYPE_H
0015 #define DD4HEP_DETTYPE_H
0016 
0017 #include <ostream>
0018 
0019 /// Namespace for the AIDA detector description toolkit
0020 namespace dd4hep {
0021 
0022   /// Helper class for encoding sub detector types in a flag word.
0023   /** 
0024    *  Example:<br>
0025    *  DetType type( DetType::TRACKER | DetType::STRIP | DetType::BARREL ) ; <br>
0026    *  type.is( DetType::ELECTROMAGNETIC  ) ; // false <br>
0027    *  type.isNot( DetType::CALORIMETER  ) ; // true <br>
0028    *  type.is( DetType::STRIP | DetType::BARREL ) ; // true <br>
0029    *
0030    * @author F.gaede, DESY
0031    * @date 05.02.2016
0032    */
0033   class DetType {
0034 
0035     friend std::ostream& operator<<(std::ostream& os , const DetType& t   ) ;
0036 
0037   public:
0038 
0039     /// Different detector type flags
0040     enum DetectorTypeEnumeration {
0041       IGNORE          = 0 ,
0042       TRACKER         = 1 <<  0, 
0043       CALORIMETER     = 1 <<  1, 
0044       CHERENKOV       = 1 <<  2, 
0045       ENDCAP                = 1 <<  3, 
0046       BARREL          = 1 <<  4, 
0047       FORWARD                = 1 <<  5, 
0048       VERTEX                = 1 <<  6, 
0049       STRIP                  = 1 <<  7, 
0050       PIXEL                  = 1 <<  8, 
0051       GASEOUS                = 1 <<  9, 
0052       WIRE                  = 1 << 10, 
0053       ELECTROMAGNETIC = 1 << 11, 
0054       HADRONIC              = 1 << 12, 
0055       MUON                  = 1 << 13, 
0056       SUPPORT         = 1 << 14,
0057       BEAMPIPE        = 1 << 15, 
0058       COIL            = 1 << 16,
0059       AUXILIARY       = 1 << 17,
0060       BACKWARD        = 1 << 18,
0061       FAR             = 1 << 19
0062    };
0063 
0064     /// default c'tor
0065     DetType( ) : _type(0) {}
0066 
0067     /** initialize with a ulong containing all properties, e.g.
0068      *  DetType type( DetType::TRACKER | DetType::STRIP | DetType::BARREL ) ;
0069      */
0070     DetType( unsigned long types ) : _type( types ){}
0071     
0072     /// set additional properties
0073     inline void set(  unsigned long prop ) {
0074       _type |= prop ;
0075     }
0076     
0077     /// unset the given properties
0078     inline void unset(  unsigned long prop ) {
0079       _type &= ~prop ;
0080     }
0081     
0082     /// true if detector has all properties
0083     inline bool is( unsigned long prop ) const {
0084       return ( _type & prop ) == prop ;
0085     }
0086 
0087     /// true if detector has none of the given properties
0088     inline bool isNot( unsigned long prop ) const {
0089       return ( _type & prop ) == 0 ;
0090     }
0091 
0092     /// return the flag word
0093     inline unsigned long to_ulong() const {
0094       return _type ;
0095     }
0096 
0097   private:
0098     unsigned long _type ;
0099   } ;
0100   
0101   inline std::ostream& operator<<( std::ostream& os , const DetType& t  ){
0102     
0103     os << "DetType( " << std::hex << "0x" << t._type << ") : " << std::dec ;
0104     if( t.is( DetType::TRACKER      ) ) os << "TRACKER, " ;
0105     if( t.is( DetType::CALORIMETER  ) ) os << "CALORIMETER, " ;
0106     if( t.is( DetType::CHERENKOV    ) ) os << "CHERENKOV, " ;
0107     if( t.is( DetType::ENDCAP            ) ) os << "ENDCAP, " ;
0108     if( t.is( DetType::BARREL            ) ) os << "BARREL, " ;
0109     if( t.is( DetType::FORWARD            ) ) os << "FORWARD, " ;
0110     if( t.is( DetType::VERTEX            ) ) os << "VERTEX, " ;
0111     if( t.is( DetType::STRIP            ) ) os << "STRIP, " ;
0112     if( t.is( DetType::PIXEL            ) ) os << "PIXEL, " ;
0113     if( t.is( DetType::GASEOUS            ) ) os << "GASEOUS, " ;
0114     if( t.is( DetType::WIRE            ) ) os << "WIRE, " ;
0115     if( t.is( DetType::ELECTROMAGNETIC            ) ) os << "ELECTROMAGNETIC, " ;
0116     if( t.is( DetType::HADRONIC            ) ) os << "HADRONIC, " ;
0117     if( t.is( DetType::MUON            ) ) os << "MUON, " ;
0118     if( t.is( DetType::SUPPORT      ) ) os << "SUPPORT, " ;
0119     if( t.is( DetType::BEAMPIPE     ) ) os << "BEAMPIPE, " ;
0120     if( t.is( DetType::COIL         ) ) os << "COIL, " ;
0121     if( t.is( DetType::AUXILIARY    ) ) os << "AUXILIARY, " ;
0122 
0123     return os ;
0124   }
0125 
0126   
0127 } /* End namespace dd4hep        */
0128 
0129 #endif // DD4HEP_DETTYPE_H