lcio/rootio
diff -N README
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ README 13 Jul 2009 12:19:50 -0000 1.1.2.1
@@ -0,0 +1,31 @@
+
+
+The $LCIO/rootio directory contains files related to the test of using ROOT I/O for LCIO.
+
+
+ ROOTDict.mk: example make file for creating an LCIO dictionary (A.Naumann)
+
+ lciotree.C: example macro for reading in an example tree w/ LCIO data
+
+
+additional files added for ROOT I/O :
+
+ $LCIO/src/cpp/src/EXAMPLES/rootio.cc: example main program that creates a root tree
+
+ $LCIO/src/cpp/include/IOIMPL/rootio_templates.h: define some template instantiations used in tree
+
+
+
+
+###############################################################
+
+ Build instructions:
+ -------------------
+export CVSROOT=:pserver:[log in to unmask]:/cvs/lcio
+mkdir lcio
+cd lcio
+cvs co -d rio_v00-00 -r rio_v00-00 lcio
+
+. /data/gaede/root/5.24.00/bin/thisroot.sh
+
+
lcio/rootio
diff -N ROOTDict.mk
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ROOTDict.mk 13 Jul 2009 12:19:50 -0000 1.1.2.1
@@ -0,0 +1,44 @@
+
+ALLH=$(shell find include/ -name '*.h')
+ALLH+=lcio_templates.h
+VETOH+=$(wildcard include/SIO/*.h include/CPPFORT/*.h)
+#VETOH+=./include/UTIL/CellIDDecoder.h ./include/UTIL/PIDHandler.h
+
+#-fg: just need the classes of the EDM:
+#ALLH=$(wildcard include/EVENT/*.h include/IMPL/*.h)
+#ALLH=./include/IMPL/ReconstructedParticleImpl.h ./include/EVENT/ReconstructedParticle.h ./include/EVENT/LCObject.h ./include/EVENT/LCEvent.h ./include/IMPL/LCEventImpl.h ./include/UTIL/LCTypedVector.h
+#ALLH=./include/IMPL/ReconstructedParticleImpl.h ./include/EVENT/ReconstructedParticle.h ./include/EVENT/LCObject.h
+
+
+ALLH:=$(filter-out $(VETOH),$(ALLH))
+ALLHNAMES=$(addprefix dict/,$(subst /,_,$(basename $(ALLH))))
+ALLRCDS=$(addsuffix _dict.cxx,$(ALLHNAMES))
+ALLRCDO=$(ALLRCDS:.cxx=.o)
+
+DICTLIB:=liblcioDict.so
+
+ifeq ($(VERBOSE)$(V),)
+CMDECHO=@
+endif
+
+.PHONY: all clean
+
+all: $(DICTLIB)
+$(DICTLIB): $(ALLRCDO)
+ g++ -shared $^ -o$@
+
+define ROOTCINT_template
+ dict/$$(subst /,_,$$(basename $(1)))_Linkdef.h:
+ $(CMDECHO)mkdir -p dict
+ $(CMDECHO)echo '#pragma link C++ defined_in "'$1'";' > $$@
+ dict/$$(subst /,_,$$(basename $(1)))_dict.cxx: $(1) dict/$$(subst /,_,$$(basename $(1)))_Linkdef.h
+ $(CMDECHO)rootcint -f $$@ -c -DHANDLE_LCIO_EXCEPTIONS=IGNORED_FOR_CINT -Iinclude $(1) dict/$$(subst /,_,$$(basename $(1)))_Linkdef.h
+endef
+
+$(foreach hdr,$(ALLH),$(eval $(call ROOTCINT_template,$(hdr))))
+
+%_dict.o: %_dict.cxx
+ $(CMDECHO)g++ -fPIC -c $^ -Iinclude -I. `root-config --cflags` -o$@
+
+clean:
+ $(CMDECHO)rm -f dict/* $(DICTLIB)
lcio/rootio
diff -N lciotree.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lciotree.C 13 Jul 2009 12:19:50 -0000 1.1.2.1
@@ -0,0 +1,137 @@
+#include "TTree.h"
+#include "TFile.h"
+#include "TBranch.h"
+#ifndef __CINT__
+#include "include/IMPL/ReconstructedParticleImpl.h"
+#include "include/IMPL/TrackImpl.h"
+#endif
+
+ //--------- loop over particles in the events ------------
+
+
+void lciotree() {
+
+
+ if (!TClassTable::GetDict("IMPL::ReconstructedParticleImpl")) {
+ unsigned res ;
+
+ res = gSystem->Load("./lib/liblcio.so");
+ res = gSystem->Load("./lib/liblcioDict.so");
+
+ // if (res != 0 ) {
+ // std::cout << " can't load ./liblcioDict.so ! err = " <<res<<std::endl;
+ // }
+ }
+
+
+
+ TFile *f = TFile::Open("dst.root","READ");
+
+ if (!f) { return; }
+
+ TTree *t; f->GetObject("lciotree",t);
+
+ // t->Draw("PandoraPFOs.getEnergy()" ) ;
+ // t->Draw("PandoraPFOs.getTracks().size()" ) ;
+
+
+ // ---- create a few histograms ---------
+
+ TH1F *htot = new TH1F("hetot","total energy from PFOs",100,0.,1000.);
+ htot->SetFillColor(48);
+
+ TH1F *htphi = new TH1F("htphi","phi of tracks ",48,-1.6,+3.2);
+ htphi->SetFillColor(32);
+
+ TH1F *htphipo = new TH1F("htphipo","phi of tracks - PFOs",48,-1.6,+3.2);
+ htphipo->SetFillColor(30);
+
+ TH1F *hntrk = new TH1F("hntrk","number of tracks PFOs",11,0.,10.);
+ hntrk->SetFillColor(41);
+
+
+
+
+ //--------- loop over particles in the events ------------
+
+
+ std::vector<EVENT::ReconstructedParticle*> * vpfo = 0;
+ std::vector<EVENT::Track*>* vtrk = 0;
+
+// std::vector<IMPL::ReconstructedParticleImpl*> * vpfo = 0;
+// std::vector<IMPL::TrackImpl*>* vtrk = 0;
+
+ TBranch* bpfo = 0;
+ t->SetBranchAddress("PandoraPFOs",&vpfo,&bpfo);
+
+ TBranch* btrk = 0;
+ t->SetBranchAddress("LDCTracks",&vtrk,&btrk);
+
+
+ int nevt = t->GetEntries();
+
+ for (Int_t i = 0; i < nevt ; i++) {
+
+ Long64_t tentry = t->LoadTree(i);
+
+ bpfo->GetEntry(tentry);
+ btrk->GetEntry(tentry);
+
+
+
+ double etot = 0. ;
+
+ for (UInt_t j = 0; j < vtrk->size(); ++j) {
+ EVENT::Track* trk = vtrk->at(j) ;
+ // cout << "vtrk: " << trk << endl ;
+ htphi->Fill( trk->getPhi() ) ;
+ }
+
+
+ for (UInt_t j = 0; j < vpfo->size(); ++j) {
+
+
+ EVENT::ReconstructedParticle* part = vpfo->at(j) ;
+
+ //etot += (*vpfo)[j]->getEnergy() ; // does not work in CINT !!?
+ //etot += vpfo->at(j)->getEnergy() ;
+
+ etot += part->getEnergy() ;
+
+
+ const std::vector< Track * >& trks = part->getTracks() ;
+
+ hntrk->Fill( trks.size() ) ;
+
+ for (UInt_t k = 0; k < trks.size(); ++k) {
+ // cout << " trks: " << trks[k] << endl ;
+ htphipo->Fill( trks[k]->getPhi() ) ;
+ }
+
+ }
+
+ htot->Fill( etot ) ;
+ // cout << " etot : " << etot << endl ;
+
+ }
+
+ // Since we passed the address of a local variable we need
+ // to remove it.
+ t->ResetBranchAddresses();
+
+
+
+ // -------------------------
+ TCanvas *c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500);
+ c1->Divide(2,2);
+ c1->cd(1) ;
+ htot->Draw();
+ c1->cd(2) ;
+ htphi->Draw();
+ c1->cd(3) ;
+ hntrk->Draw();
+ c1->cd(4) ;
+ htphipo->Draw();
+
+
+}