lcio/src/cpp/src/EXAMPLE
diff -u -r1.1.2.1 -r1.1.2.2
--- LCCol2Branch.h 7 Jul 2009 12:57:53 -0000 1.1.2.1
+++ LCCol2Branch.h 13 Jul 2009 08:30:47 -0000 1.1.2.2
@@ -4,15 +4,12 @@
#include "lcio.h"
#include "EVENT/LCEvent.h"
#include "IMPL/LCCollectionVec.h"
-#include "IMPL/ReconstructedParticleImpl.h"
+//#include "IMPL/ReconstructedParticleImpl.h"
#include "UTIL/LCTypedVector.h"
-//#include "TSystem.h"
-//#include "TFile.h"
#include "TTree.h"
-//#include "TClassTable.h"
+//#include "TRefArray.h"
-//typedef IMPL::ReconstructedParticleImpl T ;
class LCBranch{
@@ -39,7 +36,8 @@
tree->Branch( name , &_tv, 16000, 2 );
}
-
+
+
@@ -88,5 +86,46 @@
}; // class
+
+
+// template<>
+// void LCCol2Branch<ReconstructedParticleROOT>::fill( EVENT::LCEvent* evt ){
+
+// _tv->clear() ;
+// _tv->resize( 0 ) ;
+
+
+// try{
+
+// EVENT::LCCollection* col = evt->getCollection( _name ) ;
+
+// int n = col->getNumberOfElements() ;
+
+// _tv->resize( n ) ;
+
+// for( int i=0; i<n ; ++i){
+
+// EVENT::ReconstructedParticle* p = dynamic_cast<EVENT::ReconstructedParticle*>( col->getElementAt(i) ) ;
+
+// (*_tv)[i]->Particle = p ;
+
+// unsigned ntrk = p->getTracks().size() ;
+
+// for( unsigned j=0;j<ntrk;j++){
+
+// ---- TRefs work only for TObjects !!
+// (*_tv)[i]->Tracks.Add( p->getTracks()[j] ) ;
+
+// }
+// }
+
+// } catch(const lcio::DataNotAvailableException& e){
+
+// std::cout << " collection not found : " << _name << std::endl ;
+// }
+// }
+
+
+
#endif
//=============================================================================
lcio/src/cpp/src/EXAMPLE
diff -u -r1.1.2.1 -r1.1.2.2
--- rootio.cc 7 Jul 2009 12:57:53 -0000 1.1.2.1
+++ rootio.cc 13 Jul 2009 08:30:47 -0000 1.1.2.2
@@ -13,13 +13,14 @@
#include "IMPL/LCEventImpl.h"
// #include "EVENT/LCRunHeader.h"
-#include "lcio_templates.h"
+#include "IOIMPL/rootio_templates.h"
#include "LCCol2Branch.h"
#include "TSystem.h"
#include "TFile.h"
#include "TTree.h"
+#include "TRefArray.h"
#include "TClassTable.h"
@@ -28,16 +29,19 @@
static const char* FILEN = "simjob.slcio" ; // default file name
static char* RFILEN = "simjob.root" ; // default file name
-//static char* PFOCOL="ReconstructedParticle" ;
-static char* PFOCOL="PandoraPFOs" ;
-//#define RECOTREE
-//#define EVENTTREE
-
using namespace std ;
using namespace lcio ;
+
+struct RecoWrapper{
+ EVENT::ReconstructedParticle* RecPart ;
+ TRefArray Tracks ;
+} ;
+
+
+
/** example and test code for writing a root file ...
*/
@@ -57,34 +61,6 @@
//---------------------------------------------------------------------------------------------
- // load the LCIO ROOT dictionary
- //
- // if (!TClassTable::GetDict("IMPL::ReconstructedParticleImpl")) {
- // unsigned res ;
-
- // // fg: don't need to load lcio again !?
- // // res = gSystem->Load("./liblcio.so");
- // // if (res != 0 ) {
- // // std::cout << " can't load ./liblcio.so ! err = " << res << std::endl ;
- // // exit(1) ;
- // // }
- // // std::cout << " successfully loaded LCIO library " << std::endl ;
-
- // res = gSystem->Load("./liblcioDict.so");
-
- // if (res != 0 ) {
- // std::cout << " can't load ./liblcioDict.so ! err = " << res << std::endl ;
- // exit(1) ;
- // }
- // std::cout << " successfully loaded LCIO dictionary " << std::endl ;
- // }
-
- // if (!TClassTable::GetDict("IMPL::ReconstructedParticleImpl")) {
- // std::cout << " unknown dictionary for ReconstructedParticleImpl" << std::endl ;
- // exit(1) ;
- // }
-
- //---------------------------------------------------------------------------------------------
// create a ROOT tree with ReconstructedParticles ...
//
@@ -96,6 +72,13 @@
BV _branches ;
_branches.reserve(50) ;
+
+ // --- create branches for lcio collections --------
+ // -> how should we do this in general ? - read the first n events ? ....
+ //
+
+ //_branches.push_back( new LCCol2Branch<ReconstructedParticleROOT>( "PandoraPFOs" , _tree ) ) ;
+
_branches.push_back( new LCCol2Branch<EVENT::ReconstructedParticle>( "PandoraPFOs" , _tree ) ) ;
_branches.push_back( new LCCol2Branch<EVENT::ReconstructedParticle>( "Durham_2Jets" , _tree ) ) ;
_branches.push_back( new LCCol2Branch<EVENT::ReconstructedParticle>( "Durham_3Jets" , _tree ) ) ;
@@ -113,6 +96,7 @@
_branches.push_back( new LCCol2Branch<EVENT::Vertex>( "ZVRESVertices_4Jets" , _tree ) ) ;
_branches.push_back( new LCCol2Branch<EVENT::Vertex>( "ZVRESVertices_5Jets" , _tree ) ) ;
_branches.push_back( new LCCol2Branch<EVENT::Vertex>( "ZVRESVertices_6Jets" , _tree ) ) ;
+
// _branches.push_back( new LCCol2Branch<IMPL::ReconstructedParticleImpl>( "PandoraPFOs" , _tree ) ) ;
// _branches.push_back( new LCCol2Branch<IMPL::ReconstructedParticleImpl>( "Durham_2Jets" , _tree ) ) ;
// _branches.push_back( new LCCol2Branch<IMPL::ReconstructedParticleImpl>( "Durham_3Jets" , _tree ) ) ;
@@ -132,54 +116,6 @@
// _branches.push_back( new LCCol2Branch<IMPL::VertexImpl>( "ZVRESVertices_6Jets" , _tree ) ) ;
-// #ifdef RECOTREE //=======================================================================================
-// IMPL::ReconstructedParticleImpl* _p = new IMPL::ReconstructedParticleImpl() ;
-// // _ep = new IMPL::LCEventImpl() ;
-
-// //LCCollectionVec dummy(LCIO::RECONSTRUCTEDPARTICLE) ;
-
-// // UTIL::LCTypedVector<IMPL::ReconstructedParticleImpl>* _pv = new UTIL::LCTypedVector<IMPL::ReconstructedParticleImpl> ;
-// std::vector<IMPL::ReconstructedParticleImpl*>* _pv = new std::vector<IMPL::ReconstructedParticleImpl*> ;
-
-// //LCTypedVectorReconstructedParticleImpl* _pv = new LCTypedVectorReconstructedParticleImpl ;
-
-// //PFOVec* _pv = new PFOVec ;
-
-// //IMPL::LCCollectionVec* _pv = new IMPL::LCCollectionVec(LCIO::RECONSTRUCTEDPARTICLE) ;
-// // _pv = new PFOVec ;
-// // _np = 0 ;
-
-
-// // _tree->Branch("recopart", &_p);
-// _tree->Branch("recovec", &_pv, 16000, 2 );
-// // _tree->Branch("recovecn", &_np);
-
-// //_tree->Branch("event",&_ep);
-
-// delete _p ;
-// // delete _pv ;
-// // delete _ep ;
-
-// #endif //#ifdef RECOTREE //=======================================================================================
-
-
-// //---------------------------------------------------------------------------------------------
-// // create a ROOT tree with complete LCEvent ...
-// //
-// #ifdef EVENTTREE //=======================================================================================
-
-
-// IMPL::LCEventImpl* _evt = new IMPL::LCEventImpl ;
-
-
-// _tree->Branch("lcevent", &_evt, 16000, 2 );
-
-// delete _evt ;
-
-// #endif //#ifdef EVENTTREE //=======================================================================================
-
-
-
//---------------------------------------------------------------------------------------------
// open the lcio file
//
@@ -189,8 +125,7 @@
int nEvents = 0 ;
-
-
+
//---------------------------------------------------------------------------------------------
// the event loop
while( (evt = lcReader->readNextEvent()) != 0 ) {
@@ -203,66 +138,25 @@
_tree->Fill() ;
-
-
-
-// // LCTOOLS::dumpEvent( evt ) ;
-
-// #ifdef RECOTREE //=======================================================================================
-// try{
-
-// // LCCollectionVec* col = dynamic_cast<LCCollectionVec*>( evt->getCollection( PFOCOL ) );
-// // _pv = col ;
-
-// LCCollection* col = evt->getCollection( PFOCOL ) ;
-
-// UTIL::LCTypedVector<IMPL::ReconstructedParticleImpl> tv(col) ;
-
-// // _pv->assign( tv.begin() , tv.end() ) ;
-
-// _pv = &tv ;
-
-// //_pv->v = tv ;
-// _tree->Fill() ;
-
-// }catch(const DataNotAvailableException& e){
-// std::cout << " collection not found : " << PFOCOL << std::endl ;
-// }
-
-// #endif //#ifdef RECOTREE //=======================================================================================
-
-
-// #ifdef EVENTTREE //=======================================================================================
-
-// _evt = dynamic_cast< IMPL::LCEventImpl* >( evt ) ;
-
-// _tree->Fill() ;
-
-// #endif //#ifdef EVENTTREE //=======================================================================================
-
-
nEvents ++ ;
}
// -------- end of event loop -----------
cout << endl << " " << nEvents << " events copied from file: " << FILEN
<< " to " << RFILEN << std::endl ;
-
- lcReader->close() ;
- delete lcReader ;
_file->Write() ;
delete _file ;
- // delete _tree ;
-
+
+ lcReader->close() ;
+ delete lcReader ;
+
for( BV::const_iterator it = _branches.begin() ; it != _branches.end() ; ++it) {
-
delete (*it) ;
}
-
-
+
return 0 ;
}
-
+