DD4hep  1.30.0
Detector Description Toolkit for High Energy Physics
DetType.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : F.Gaede
11 //
12 //==========================================================================
13 
14 #ifndef DD4HEP_DETTYPE_H
15 #define DD4HEP_DETTYPE_H
16 
17 #include <ostream>
18 
20 namespace dd4hep {
21 
23 
33  class DetType {
34 
35  friend std::ostream& operator<<(std::ostream& os , const DetType& t ) ;
36 
37  public:
38 
41  IGNORE = 0 ,
42  TRACKER = 1 << 0,
43  CALORIMETER = 1 << 1,
44  CHERENKOV = 1 << 2,
45  ENDCAP = 1 << 3,
46  BARREL = 1 << 4,
47  FORWARD = 1 << 5,
48  VERTEX = 1 << 6,
49  STRIP = 1 << 7,
50  PIXEL = 1 << 8,
51  GASEOUS = 1 << 9,
52  WIRE = 1 << 10,
53  ELECTROMAGNETIC = 1 << 11,
54  HADRONIC = 1 << 12,
55  MUON = 1 << 13,
56  SUPPORT = 1 << 14,
57  BEAMPIPE = 1 << 15,
58  COIL = 1 << 16,
59  AUXILIARY = 1 << 17
60  };
61 
63  DetType( ) : _type(0) {}
64 
68  DetType( unsigned long types ) : _type( types ){}
69 
71  inline void set( unsigned long prop ) {
72  _type |= prop ;
73  }
74 
76  inline void unset( unsigned long prop ) {
77  _type &= ~prop ;
78  }
79 
81  inline bool is( unsigned long prop ) const {
82  return ( _type & prop ) == prop ;
83  }
84 
86  inline bool isNot( unsigned long prop ) const {
87  return ( _type & prop ) == 0 ;
88  }
89 
91  inline unsigned long to_ulong() const {
92  return _type ;
93  }
94 
95  private:
96  unsigned long _type ;
97  } ;
98 
99  inline std::ostream& operator<<( std::ostream& os , const DetType& t ){
100 
101  os << "DetType( " << std::hex << "0x" << t._type << ") : " << std::dec ;
102  if( t.is( DetType::TRACKER ) ) os << "TRACKER, " ;
103  if( t.is( DetType::CALORIMETER ) ) os << "CALORIMETER, " ;
104  if( t.is( DetType::CHERENKOV ) ) os << "CHERENKOV, " ;
105  if( t.is( DetType::ENDCAP ) ) os << "ENDCAP, " ;
106  if( t.is( DetType::BARREL ) ) os << "BARREL, " ;
107  if( t.is( DetType::FORWARD ) ) os << "FORWARD, " ;
108  if( t.is( DetType::VERTEX ) ) os << "VERTEX, " ;
109  if( t.is( DetType::STRIP ) ) os << "STRIP, " ;
110  if( t.is( DetType::PIXEL ) ) os << "PIXEL, " ;
111  if( t.is( DetType::GASEOUS ) ) os << "GASEOUS, " ;
112  if( t.is( DetType::WIRE ) ) os << "WIRE, " ;
113  if( t.is( DetType::ELECTROMAGNETIC ) ) os << "ELECTROMAGNETIC, " ;
114  if( t.is( DetType::HADRONIC ) ) os << "HADRONIC, " ;
115  if( t.is( DetType::MUON ) ) os << "MUON, " ;
116  if( t.is( DetType::SUPPORT ) ) os << "SUPPORT, " ;
117  if( t.is( DetType::BEAMPIPE ) ) os << "BEAMPIPE, " ;
118  if( t.is( DetType::COIL ) ) os << "COIL, " ;
119  if( t.is( DetType::AUXILIARY ) ) os << "AUXILIARY, " ;
120 
121  return os ;
122  }
123 
124 
125 } /* End namespace dd4hep */
126 
127 #endif // DD4HEP_DETTYPE_H
dd4hep::DetType::BARREL
@ BARREL
Definition: DetType.h:46
dd4hep::DetType::isNot
bool isNot(unsigned long prop) const
true if detector has none of the given properties
Definition: DetType.h:86
dd4hep::DetType::is
bool is(unsigned long prop) const
true if detector has all properties
Definition: DetType.h:81
dd4hep::DetType::PIXEL
@ PIXEL
Definition: DetType.h:50
dd4hep::DetType
Helper class for encoding sub detector types in a flag word.
Definition: DetType.h:33
dd4hep::DetType::DetType
DetType()
default c'tor
Definition: DetType.h:63
dd4hep::DetType::HADRONIC
@ HADRONIC
Definition: DetType.h:54
dd4hep::DetType::CHERENKOV
@ CHERENKOV
Definition: DetType.h:44
dd4hep::DetType::ENDCAP
@ ENDCAP
Definition: DetType.h:45
dd4hep::DetType::ELECTROMAGNETIC
@ ELECTROMAGNETIC
Definition: DetType.h:53
dd4hep::DetType::CALORIMETER
@ CALORIMETER
Definition: DetType.h:43
dd4hep::DetType::WIRE
@ WIRE
Definition: DetType.h:52
dd4hep::DetType::COIL
@ COIL
Definition: DetType.h:58
dd4hep::DetType::VERTEX
@ VERTEX
Definition: DetType.h:48
dd4hep::DetType::STRIP
@ STRIP
Definition: DetType.h:49
dd4hep::operator<<
std::ostream & operator<<(std::ostream &os, const DetType &t)
Definition: DetType.h:99
dd4hep::DetType::set
void set(unsigned long prop)
set additional properties
Definition: DetType.h:71
dd4hep::DetType::TRACKER
@ TRACKER
Definition: DetType.h:42
dd4hep::DetType::SUPPORT
@ SUPPORT
Definition: DetType.h:56
dd4hep::DetType::GASEOUS
@ GASEOUS
Definition: DetType.h:51
dd4hep::DetType::IGNORE
@ IGNORE
Definition: DetType.h:41
dd4hep::DetType::to_ulong
unsigned long to_ulong() const
return the flag word
Definition: DetType.h:91
dd4hep::DetType::operator<<
friend std::ostream & operator<<(std::ostream &os, const DetType &t)
Definition: DetType.h:99
dd4hep::DetType::unset
void unset(unsigned long prop)
unset the given properties
Definition: DetType.h:76
dd4hep::DetType::AUXILIARY
@ AUXILIARY
Definition: DetType.h:59
dd4hep::DetType::FORWARD
@ FORWARD
Definition: DetType.h:47
dd4hep::DetType::DetType
DetType(unsigned long types)
Definition: DetType.h:68
dd4hep::DetType::DetectorTypeEnumeration
DetectorTypeEnumeration
Different detector type flags.
Definition: DetType.h:40
dd4hep::DetType::MUON
@ MUON
Definition: DetType.h:55
dd4hep::DetType::BEAMPIPE
@ BEAMPIPE
Definition: DetType.h:57
dd4hep::DetType::_type
unsigned long _type
Definition: DetType.h:96
dd4hep
Namespace for the AIDA detector description toolkit.
Definition: AlignmentsCalib.h:28