LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LCIOTypeInfo.h
Go to the documentation of this file.
1 #ifndef LCIOTypeInfo_h
2 #define LCIOTypeInfo_h 1
3 
4 #include "EVENT/LCIO.h"
5 #include "EVENT/LCObject.h"
6 #include "EVENT/LCCollection.h"
8 #include "EVENT/CalorimeterHit.h"
10 #include "EVENT/SimTrackerHit.h"
11 #include "EVENT/TrackerHit.h"
12 #include "EVENT/TrackerHitPlane.h"
14 #include "EVENT/TPCHit.h"
15 #include "EVENT/TrackerRawData.h"
16 #include "EVENT/TrackerData.h"
17 #include "EVENT/TrackerPulse.h"
18 #include "EVENT/LCIO.h"
19 #include "EVENT/MCParticle.h"
20 #include "EVENT/LCFloatVec.h"
21 #include "EVENT/LCIntVec.h"
22 #include "EVENT/LCStrVec.h"
23 #include "EVENT/Track.h"
24 #include "EVENT/Cluster.h"
26 #include "EVENT/LCGenericObject.h"
27 #include "EVENT/LCRelation.h"
28 #include "EVENT/Vertex.h"
29 
30 #include <vector>
31 #include <sstream>
32 #include <typeinfo>
33 
34 
35 namespace UTIL{
36 
41  template <class T>
42  const char* lctypename() ;
43 
46  template <class T>
47  const char* lctypename() {
48  return lctypename< typename T::lcobject_type >() ;
49  }
50 
51  // specializations for all known LCObject subclasses
52  // - yes this is not OO at its best ...
53  template<> const char* lctypename<EVENT::MCParticle>() { return EVENT::LCIO::MCPARTICLE ; }
54  template<> const char* lctypename<EVENT::SimCalorimeterHit>() { return EVENT::LCIO::SIMCALORIMETERHIT ; }
55  template<> const char* lctypename<EVENT::CalorimeterHit>() { return EVENT::LCIO::CALORIMETERHIT ; }
56  template<> const char* lctypename<EVENT::RawCalorimeterHit>() { return EVENT::LCIO::RAWCALORIMETERHIT ; }
57  template<> const char* lctypename<EVENT::SimTrackerHit>() { return EVENT::LCIO::SIMTRACKERHIT ; }
58  template<> const char* lctypename<EVENT::TrackerRawData>() { return EVENT::LCIO::TRACKERRAWDATA ; }
59  template<> const char* lctypename<EVENT::TrackerData>() { return EVENT::LCIO::TRACKERDATA ; }
60  template<> const char* lctypename<EVENT::TrackerPulse>() { return EVENT::LCIO::TRACKERPULSE ; }
61  template<> const char* lctypename<EVENT::TrackerHit>() { return EVENT::LCIO::TRACKERHIT ; }
62  template<> const char* lctypename<EVENT::TrackerHitPlane>() { return EVENT::LCIO::TRACKERHITPLANE ; }
63  template<> const char* lctypename<EVENT::TrackerHitZCylinder>() { return EVENT::LCIO::TRACKERHITZCYLINDER ; }
64  template<> const char* lctypename<EVENT::LCStrVec>() { return EVENT::LCIO::LCSTRVEC ; }
65  template<> const char* lctypename<EVENT::LCFloatVec>() { return EVENT::LCIO::LCFLOATVEC ; }
66  template<> const char* lctypename<EVENT::LCIntVec>() { return EVENT::LCIO::LCINTVEC ; }
67  template<> const char* lctypename<EVENT::Track>() { return EVENT::LCIO::TRACK ; }
68  template<> const char* lctypename<EVENT::Cluster>() { return EVENT::LCIO::CLUSTER ; }
69  template<> const char* lctypename<EVENT::ReconstructedParticle>() { return EVENT::LCIO::RECONSTRUCTEDPARTICLE ; }
70  template<> const char* lctypename<EVENT::LCRelation>() { return EVENT::LCIO::LCRELATION ; }
71  template<> const char* lctypename<EVENT::LCGenericObject>() { return EVENT::LCIO::LCGENERICOBJECT ; }
72  template<> const char* lctypename<EVENT::Vertex>() { return EVENT::LCIO::VERTEX ; }
73 
74 
80  template <class T>
81  const char* lctypename(const T* /*t*/) {
82  return lctypename< typename T::lcobject_type >() ;
83  }
84 
85 
91  template<> const char* lctypename<EVENT::LCObject>(const EVENT::LCObject* o) {
92 
93  if( dynamic_cast<const EVENT::MCParticle*>(o) != 0 ) return lctypename<EVENT::MCParticle>() ;
94 
95  if( dynamic_cast<const EVENT::SimCalorimeterHit*>(o) != 0 ) return lctypename<EVENT::SimCalorimeterHit>() ;
96  if( dynamic_cast<const EVENT::CalorimeterHit*>(o) != 0 ) return lctypename<EVENT::CalorimeterHit>() ;
97  if( dynamic_cast<const EVENT::RawCalorimeterHit*>(o) != 0 ) return lctypename<EVENT::RawCalorimeterHit>() ;
98  if( dynamic_cast<const EVENT::SimTrackerHit*>(o) != 0 ) return lctypename<EVENT::SimTrackerHit>() ;
99  if( dynamic_cast<const EVENT::TrackerRawData*>(o) != 0 ) return lctypename<EVENT::TrackerRawData>() ;
100  if( dynamic_cast<const EVENT::TrackerData*>(o) != 0 ) return lctypename<EVENT::TrackerData>() ;
101  if( dynamic_cast<const EVENT::TrackerPulse*>(o) != 0 ) return lctypename<EVENT::TrackerPulse>() ;
102  if( dynamic_cast<const EVENT::TrackerHit*>(o) != 0 ) return lctypename<EVENT::TrackerHit>() ;
103  if( dynamic_cast<const EVENT::TrackerHitPlane*>(o) != 0 ) return lctypename<EVENT::TrackerHitPlane>() ;
104  if( dynamic_cast<const EVENT::TrackerHitZCylinder*>(o) != 0 ) return lctypename<EVENT::TrackerHitZCylinder>() ;
105  if( dynamic_cast<const EVENT::LCStrVec*>(o) != 0 ) return lctypename<EVENT::LCStrVec>() ;
106  if( dynamic_cast<const EVENT::LCFloatVec*>(o) != 0 ) return lctypename<EVENT::LCFloatVec>() ;
107  if( dynamic_cast<const EVENT::LCIntVec*>(o) != 0 ) return lctypename<EVENT::LCIntVec>() ;
108  if( dynamic_cast<const EVENT::Track*>(o) != 0 ) return lctypename<EVENT::Track>() ;
109  if( dynamic_cast<const EVENT::Cluster*>(o) != 0 ) return lctypename<EVENT::Cluster>() ;
110  if( dynamic_cast<const EVENT::ReconstructedParticle*>(o) != 0 ) return lctypename<EVENT::ReconstructedParticle>() ;
111  if( dynamic_cast<const EVENT::LCRelation*>(o) != 0 ) return lctypename<EVENT::LCRelation>() ;
112  if( dynamic_cast<const EVENT::LCGenericObject*>(o) != 0 ) return lctypename<EVENT::LCGenericObject>() ;
113  if( dynamic_cast<const EVENT::Vertex*>(o) != 0 ) return lctypename<EVENT::Vertex>() ;
114 
115  return "UNKNOWN" ;
116  }
117 
118 
119 
120 // /** Provides some type information for LCIO classes.
121 // *
122 // * @author gaede
123 // * @version Id:$
124 // */
125 // template <class T>
126 // class LCIOTypeInfo {
127 
128 // const T* _t ;
129 // public:
130 
131 // typedef T lcobject_type ;
132 
133 // LCIOTypeInfo(const T* t) : _t(t) {}
134 
135 // /** Allow conversions to base class' LCIOTypeInfo
136 // */
137 // template<class T2>
138 // operator LCIOTypeInfo<T2>() { return LCIOTypeInfo<T2>( _t ) ; }
139 
140 // const char* lctypename() {
141 // return UTIL::lctypename<T>() ;
142 // }
143 
144 // private:
145 // void ensure_T_is_LCObject() { const EVENT::LCObject* o = t ; }
146 // } ;
147 
148 
149 } // namespace
150 #endif
The generic object that is held in an LCCollection.
Definition: LCObject.h:30
const char * lctypename()
Template that returns the LCIO type name as used in the LCCollctions (and files), e...
Definition: LCIOTypeInfo.h:47