00001 #ifndef LCIO_OPERATORS_H
00002 #define LCIO_OPERATORS_H 1
00003
00005
00006
00007
00008
00009
00011
00012
00013 #include "EVENT/ReconstructedParticle.h"
00014 #include "EVENT/SimCalorimeterHit.h"
00015 #include "EVENT/MCParticle.h"
00016 #include "EVENT/SimTrackerHit.h"
00017 #include "EVENT/TrackerHit.h"
00018 #include "EVENT/TrackerHitPlane.h"
00019 #include "EVENT/TrackerHitZCylinder.h"
00020 #include "EVENT/Track.h"
00021 #include "EVENT/TrackState.h"
00022 #include "EVENT/Cluster.h"
00023 #include "EVENT/CalorimeterHit.h"
00024 #include "EVENT/LCFlag.h"
00025 #include "EVENT/LCIntVec.h"
00026 #include "EVENT/LCRunHeader.h"
00027 #include "EVENT/RawCalorimeterHit.h"
00028
00029 #include "EVENT/TrackerPulse.h"
00030 #include "EVENT/LCFloatVec.h"
00031 #include "EVENT/LCObject.h"
00032 #include "EVENT/TrackerRawData.h"
00033 #include "EVENT/LCCollection.h"
00034 #include "EVENT/LCGenericObject.h"
00035 #include "EVENT/LCParameters.h"
00036 #include "EVENT/TrackerData.h"
00037 #include "EVENT/LCEvent.h"
00038 #include "EVENT/LCIO.h"
00039 #include "EVENT/LCRelation.h"
00040 #include "EVENT/ParticleID.h"
00041 #include "EVENT/Vertex.h"
00042
00043
00044
00045 #include <iostream>
00046 #include <iomanip>
00047 #include <string>
00048 #include <sstream>
00049
00050
00051 namespace UTIL{
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 template <class T>
00064 class lcio_short{
00065 public:
00066 const T* obj;
00067 const EVENT::LCCollection* col;
00068 lcio_short(const T* t, const EVENT::LCCollection* b=NULL) : obj(t), col(b) {}
00069
00070 };
00071
00072
00073
00074 template <class T> lcio_short<T> lcshort( const T* t, const EVENT::LCCollection* b=NULL){ return lcio_short<T>(t,b); }
00075
00080 const std::string& header(const EVENT::Vertex *);
00081 const std::string& tail(const EVENT::Vertex *);
00082 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::Vertex>& sV);
00083
00084
00085
00086
00087 const std::string& header( const EVENT::MCParticle *);
00088 const std::string& tail( const EVENT::MCParticle *);
00089 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::MCParticle>& sV);
00090
00091
00092
00093 const std::string& header( const EVENT::TrackerHit *);
00094 const std::string& tail( const EVENT::TrackerHit *);
00095 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::TrackerHit>& sV);
00096
00097
00098 const std::string& header( const EVENT::TrackerHitPlane *);
00099 const std::string& tail( const EVENT::TrackerHitPlane *);
00100 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::TrackerHitPlane>& sV);
00101
00102
00103 const std::string& header( const EVENT::TrackerHitZCylinder *);
00104 const std::string& tail( const EVENT::TrackerHitZCylinder *);
00105 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::TrackerHitZCylinder>& sV);
00106
00107
00108 const std::string& header( const EVENT::SimTrackerHit *);
00109 const std::string& tail( const EVENT::SimTrackerHit *);
00110 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::SimTrackerHit>& sV);
00111
00112
00113 const std::string& header( const EVENT::CalorimeterHit *);
00114 const std::string& tail( const EVENT::CalorimeterHit *);
00115 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::CalorimeterHit>& sV);
00116
00117
00118 const std::string& header( const EVENT::SimCalorimeterHit *);
00119 const std::string& tail( const EVENT::SimCalorimeterHit *);
00120 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::SimCalorimeterHit>& sV);
00121
00122
00123 const std::string& header( const EVENT::ReconstructedParticle *);
00124 const std::string& tail( const EVENT::ReconstructedParticle *);
00125 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::ReconstructedParticle> & );
00126
00127
00128 const std::string& header( const EVENT::Track *);
00129 const std::string& tail( const EVENT::Track *);
00130 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::Track> &);
00131
00132
00133 const std::string& header( const EVENT::TrackState *);
00134 const std::string& tail( const EVENT::TrackState *);
00135 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::TrackState> &);
00136
00137
00138 const std::string& header( const EVENT::Cluster *);
00139 const std::string& tail( const EVENT::Cluster *);
00140 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::Cluster> &);
00141
00142
00143 const std::string& header( const EVENT::LCRelation *);
00144 const std::string& tail( const EVENT::LCRelation *);
00145 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCRelation> &);
00146
00147
00148 const std::string& header( const EVENT::LCFloatVec *);
00149 const std::string& tail( const EVENT::LCFloatVec *);
00150 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCFloatVec> &);
00151
00152
00153 template <class T>
00154 const std::string & header(){return header((T*)(0)); }
00155 template <class T>
00156 const std::string & tail(){return tail((T)(0)); }
00157
00158
00159 template <class T>
00160 class LCIO_LONG{
00161 public:
00162 LCIO_LONG() = default ;
00163 LCIO_LONG(const LCIO_LONG& ) = default ;
00164 LCIO_LONG& operator=(const LCIO_LONG& ) = default ;
00165 LCIO_LONG(const T& o, const EVENT::LCCollection* c){ obj=&o; col=c;};
00166 const T *object(void) const {return(obj);};
00167 const EVENT::LCCollection *collection(void) const {return(col);};
00168 private:
00169 const T *obj{NULL};
00170 const EVENT::LCCollection *col{NULL};
00171 };
00172
00173
00174 template <class T>
00175 LCIO_LONG<T> lcio_long(const T& o, const EVENT::LCCollection* c){return(LCIO_LONG<T>(o,c));}
00176
00177
00178 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::CalorimeterHit> l);
00179 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::Cluster> l);
00180 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::Track> l);
00181 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::TrackState> l);
00182 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::ReconstructedParticle> ll);
00183 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::SimCalorimeterHit> ll);
00184 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::TrackerHit> ll);
00185 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::TrackerHitPlane> ll);
00186 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::TrackerHitZCylinder> ll);
00187 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::SimTrackerHit> ll);
00188 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::MCParticle> ll);
00189 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::Vertex> ll);
00190 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::LCRelation> ll);
00191 std::ostream& operator<<( std::ostream& out, const LCIO_LONG<EVENT::LCFloatVec> ll);
00192
00193
00194 const std::string& header( const EVENT::LCCollection *);
00195 const std::string& tail( const EVENT::LCCollection *);
00196 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCCollection> &);
00197
00198
00199 const std::string& header( const EVENT::LCEvent *);
00200 const std::string& tail( const EVENT::LCEvent *);
00201 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCEvent> &);
00202
00203
00204 const std::string& header( const EVENT::LCFlag *);
00205 const std::string& tail( const EVENT::LCFlag *);
00206 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCFlag> &);
00207
00208
00209 const std::string& header( const EVENT::LCGenericObject *, const EVENT::LCCollection *v = NULL);
00210 const std::string& tail( const EVENT::LCGenericObject *);
00211 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCGenericObject> &);
00212
00213
00214 const std::string& header( const EVENT::LCIntVec *);
00215 const std::string& tail( const EVENT::LCIntVec *);
00216 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCIntVec> &);
00217
00218
00219 const std::string& header( const EVENT::LCObject *);
00220 const std::string& tail( const EVENT::LCObject *);
00221 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCObject> &);
00222
00223
00224 const std::string& header( const EVENT::LCParameters *);
00225 const std::string& tail( const EVENT::LCParameters *);
00226 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCParameters> &);
00227
00228
00229 const std::string& header( const EVENT::LCRunHeader *);
00230 const std::string& tail( const EVENT::LCRunHeader *);
00231 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCRunHeader> &);
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 const std::string& header( const EVENT::ParticleID *);
00242 const std::string& tail( const EVENT::ParticleID *);
00243 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::ParticleID> &);
00244
00245
00246 const std::string& header( const EVENT::RawCalorimeterHit *);
00247 const std::string& tail( const EVENT::RawCalorimeterHit *);
00248 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::RawCalorimeterHit> &);
00249
00250
00251
00252
00253
00254
00255
00256 const std::string& header( const EVENT::TrackerData *);
00257 const std::string& tail( const EVENT::TrackerData *);
00258 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::TrackerData> &);
00259
00260
00261 const std::string& header( const EVENT::TrackerPulse *);
00262 const std::string& tail( const EVENT::TrackerPulse *);
00263 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::TrackerPulse> &);
00264
00265
00266 const std::string& header( const EVENT::TrackerRawData *);
00267 const std::string& tail( const EVENT::TrackerRawData *);
00268 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::TrackerRawData> &);
00269
00270
00271 const std::string& header( const EVENT::LCIO *);
00272 const std::string& tail( const EVENT::LCIO *);
00273 std::ostream& operator<<( std::ostream& out, const UTIL::lcio_short<EVENT::LCIO> &);
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287 template <class T>
00288 std::string toString(const T* obj) {
00289 std::stringstream ss ;
00290 ss << *obj ;
00291 return ss.str() ;
00292 }
00293
00294 }
00295
00296
00297
00298
00299 namespace EVENT {
00300
00301 std::ostream& operator<<( std::ostream& out, const EVENT::Vertex &v);
00302 std::ostream& operator<<( std::ostream& out, const EVENT::MCParticle &);
00303 std::ostream& operator<<( std::ostream& out, const EVENT::TrackerHit &);
00304 std::ostream& operator<<( std::ostream& out, const EVENT::TrackerHitPlane &);
00305 std::ostream& operator<<( std::ostream& out, const EVENT::TrackerHitZCylinder &);
00306 std::ostream& operator<<( std::ostream& out, const EVENT::SimTrackerHit &);
00307 std::ostream& operator<<( std::ostream& out, const EVENT::CalorimeterHit &);
00308 std::ostream& operator<<( std::ostream& out, const EVENT::ReconstructedParticle &);
00309 std::ostream& operator<<( std::ostream& out, const EVENT::SimCalorimeterHit &);
00310 std::ostream& operator<<( std::ostream& out, const EVENT::Track &);
00311 std::ostream& operator<<( std::ostream& out, const EVENT::TrackState &);
00312 std::ostream& operator<<( std::ostream& out, const EVENT::Cluster &);
00313 std::ostream& operator<<( std::ostream& out, const EVENT::LCRelation &);
00314 std::ostream& operator<<( std::ostream& out, const EVENT::LCFloatVec &);
00315 std::ostream& operator<<( std::ostream& out, const EVENT::LCCollection &);
00316 std::ostream& operator<<( std::ostream& out, const EVENT::LCEvent &);
00317 std::ostream& operator<<( std::ostream& out, const EVENT::LCFlag &);
00318 std::ostream& operator<<( std::ostream& out, const EVENT::LCGenericObject &);
00319 std::ostream& operator<<( std::ostream& out, const EVENT::LCIntVec &);
00320 std::ostream& operator<<( std::ostream& out, const EVENT::LCObject &);
00321 std::ostream& operator<<( std::ostream& out, const EVENT::LCParameters &);
00322 std::ostream& operator<<( std::ostream& out, const EVENT::LCRunHeader &);
00323 std::ostream& operator<<( std::ostream& out, const EVENT::ParticleID &);
00324 std::ostream& operator<<( std::ostream& out, const EVENT::RawCalorimeterHit &);
00325 std::ostream& operator<<( std::ostream& out, const EVENT::TrackerData &);
00326 std::ostream& operator<<( std::ostream& out, const EVENT::TrackerPulse &);
00327 std::ostream& operator<<( std::ostream& out, const EVENT::TrackerRawData &);
00328 std::ostream& operator<<( std::ostream& out, const EVENT::LCIO &);
00329 }
00330
00331 #endif