Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:58:01

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    };
0061 
0062     /// default c'tor
0063     DetType( ) : _type(0) {}
0064 
0065     /** initialize with a ulong containing all properties, e.g.
0066      *  DetType type( DetType::TRACKER | DetType::STRIP | DetType::BARREL ) ;
0067      */
0068     DetType( unsigned long types ) : _type( types ){}
0069     
0070     /// set additional properties
0071     inline void set(  unsigned long prop ) {
0072       _type |= prop ;
0073     }
0074     
0075     /// unset the given properties
0076     inline void unset(  unsigned long prop ) {
0077       _type &= ~prop ;
0078     }
0079     
0080     /// true if detector has all properties
0081     inline bool is( unsigned long prop ) const {
0082       return ( _type & prop ) == prop ;
0083     }
0084 
0085     /// true if detector has none of the given properties
0086     inline bool isNot( unsigned long prop ) const {
0087       return ( _type & prop ) == 0 ;
0088     }
0089 
0090     /// return the flag word
0091     inline unsigned long to_ulong() const {
0092       return _type ;
0093     }
0094 
0095   private:
0096     unsigned long _type ;
0097   } ;
0098   
0099   inline std::ostream& operator<<( std::ostream& os , const DetType& t  ){
0100     
0101     os << "DetType( " << std::hex << "0x" << t._type << ") : " << std::dec ;
0102     if( t.is( DetType::TRACKER      ) ) os << "TRACKER, " ;
0103     if( t.is( DetType::CALORIMETER  ) ) os << "CALORIMETER, " ;
0104     if( t.is( DetType::CHERENKOV    ) ) os << "CHERENKOV, " ;
0105     if( t.is( DetType::ENDCAP       ) ) os << "ENDCAP, " ;
0106     if( t.is( DetType::BARREL       ) ) os << "BARREL, " ;
0107     if( t.is( DetType::FORWARD      ) ) os << "FORWARD, " ;
0108     if( t.is( DetType::VERTEX       ) ) os << "VERTEX, " ;
0109     if( t.is( DetType::STRIP        ) ) os << "STRIP, " ;
0110     if( t.is( DetType::PIXEL        ) ) os << "PIXEL, " ;
0111     if( t.is( DetType::GASEOUS      ) ) os << "GASEOUS, " ;
0112     if( t.is( DetType::WIRE     ) ) os << "WIRE, " ;
0113     if( t.is( DetType::ELECTROMAGNETIC      ) ) os << "ELECTROMAGNETIC, " ;
0114     if( t.is( DetType::HADRONIC     ) ) os << "HADRONIC, " ;
0115     if( t.is( DetType::MUON     ) ) os << "MUON, " ;
0116     if( t.is( DetType::SUPPORT      ) ) os << "SUPPORT, " ;
0117     if( t.is( DetType::BEAMPIPE     ) ) os << "BEAMPIPE, " ;
0118     if( t.is( DetType::COIL         ) ) os << "COIL, " ;
0119     if( t.is( DetType::AUXILIARY    ) ) os << "AUXILIARY, " ;
0120 
0121     return os ;
0122   }
0123 
0124   
0125 } /* End namespace dd4hep        */
0126 
0127 #endif // DD4HEP_DETTYPE_H