Commit in lcio/rootio on rio_v00-00
readevent.C+177added 1.1.2.1
lciotree.C+2-21.1.2.1 -> 1.1.2.2
+179-2
1 added + 1 modified, total 2 files
added readevent: read event branches

lcio/rootio
readevent.C added at 1.1.2.1
diff -N readevent.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ readevent.C	16 Sep 2009 08:42:15 -0000	1.1.2.1
@@ -0,0 +1,177 @@
+#include "TTree.h"
+#include "TFile.h"
+#include "TBranch.h"
+#ifndef __CINT__ 
+#include "include/IMPL/ReconstructedParticleImpl.h"
+#include "include/IMPL/LCEventImpl.h"
+#include "include/IMPL/TrackImpl.h"
+#endif
+#include <vector>
+
+//---------  loop over particles in the events  ------------
+  
+#define FILEN "DST01-06_ppr004_bbcsdu.rlcio"
+
+
+void readevent() {
+
+  //just in case this script is executed multiple times
+  delete gROOT->GetListOfFiles()->FindObject( FILEN );
+  delete gROOT->GetListOfCanvases()->FindObject("c1");
+  
+
+  if (!TClassTable::GetDict("IMPL::LCEventImpl")) {
+    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( FILEN ,"READ");
+   
+  if (!f) { return; }
+  
+  TTree *t; f->GetObject("LCIO",t);
+
+  
+
+  //   // ---- create a few histograms ---------
+
+  TH1F *htot = new TH1F("hetot","total energy from MCPs",100,0.,1000.);
+  htot->SetFillColor(48);
+  
+  TH1F *hepfo = new TH1F("hepfo","total energy from PFOs",100,0.,1000.);
+  hepfo->SetFillColor(32);
+
+  TH2F *herm = new TH2F("herm","mcp energy vs PFO energy",100,0.,100.,100,0.,100.);
+  herm->SetFillColor(40);
+
+
+  //   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);
+  
+  
+  
+  
+  std::vector<TBranch*> branches ;
+
+  //---------  loop over particles in the events  ------------
+  
+  IMPL::LCEventImpl* evt = new IMPL::LCEventImpl ; // 0 ;
+  TBranch* bevt = t->GetBranch("LCEvent") ; 
+  bevt->SetAddress( &evt ) ;
+  branches.push_back( bevt ) ;
+
+  IMPL::LCCollectionVec* col = new IMPL::LCCollectionVec ;
+  branches.push_back( t->GetBranch("MCParticlesSkimmed") ) ;  
+  branches.back()->SetAddress( &col ) ;
+  
+  IMPL::LCCollectionVec* cpfo = new IMPL::LCCollectionVec ;
+  branches.push_back( t->GetBranch("PandoraPFOs") ) ;  
+  branches.back()->SetAddress( &cpfo ) ;
+
+
+  IMPL::LCCollectionVec* crml = new IMPL::LCCollectionVec ;
+  branches.push_back( t->GetBranch("RecoMCTruthLink") ) ;  
+  branches.back()->SetAddress( &crml ) ;
+
+  
+  int nBranches = branches.size() ;
+
+  //***************************************************************************************************
+ 
+  int nevt = t->GetEntries();
+ 
+  //  for (Int_t i = 0; i < nevt ; i++) {
+  for (Int_t i = 0; i < 1 ; i++) {
+   
+    Long64_t tentry = t->LoadTree(i);
+   
+    for (Int_t k = 0; k < nBranches ; k++) {
+     
+      int nbyte  = branches[k]->GetEntry(tentry);
+     
+      //       cout << " read " << nbyte << " bytes for branch " << branches[k]->GetName()  
+      // 	   << std::endl ;
+    }
+   
+
+    int nMCP = col->getNumberOfElements() ;
+    double eMCP = 0.0 ;
+    for(int j=0;j<nMCP ;++j){
+     
+      EVENT::MCParticle* mcp = dynamic_cast<EVENT::MCParticle*>( col->getElementAt(j) ) ;
+
+      cout << " -- " << mcp << endl ;
+     
+      if( mcp->getGeneratorStatus() == 1 )
+	eMCP += mcp->getEnergy() ;
+    }
+    htot->Fill(eMCP) ;
+   
+   
+    int nPFO = cpfo->getNumberOfElements() ;
+    double ePFO = 0.0 ;
+    for(int j=0;j<nPFO ;++j){
+     
+      EVENT::ReconstructedParticle* pfo = dynamic_cast<EVENT::ReconstructedParticle*>( cpfo->getElementAt(j) ) ;
+     
+      ePFO += pfo->getEnergy() ;
+    }
+    hepfo->Fill(ePFO) ;
+   
+
+    // check reco mc link:
+
+    int nrml = crml->getNumberOfElements() ;
+
+    for(int j=0;j<nrml ;++j){
+      
+      EVENT::LCRelation* rel = dynamic_cast<EVENT::LCRelation*>( crml->getElementAt(j) ) ;
+      
+      EVENT::ReconstructedParticle* pfo =  dynamic_cast<EVENT::ReconstructedParticle*>( rel->getFrom() ) ;
+      EVENT::MCParticle* mcp =  dynamic_cast<EVENT::MCParticle*>( rel->getTo() ) ;
+      
+      cout << " ++ " << mcp << endl ;
+
+      herm->Fill( pfo->getEnergy() ,   mcp->getEnergy()   ) ;
+
+    }
+    
+
+
+  }
+  //***************************************************************************************************
+ 
+ 
+  // 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)  ;
+  hepfo->Draw();
+  c1->cd(3)  ;
+  herm->Draw();
+  
+  
+  
+}
+

lcio/rootio
lciotree.C 1.1.2.1 -> 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- lciotree.C	13 Jul 2009 12:19:50 -0000	1.1.2.1
+++ lciotree.C	16 Sep 2009 08:42:15 -0000	1.1.2.2
@@ -25,11 +25,11 @@
     
   
   
-  TFile *f = TFile::Open("dst.root","READ");
+  TFile *f = TFile::Open("DST01-06_ppr004_bbcsdu.rlcio","READ");
    
   if (!f) { return; }
   
-  TTree *t; f->GetObject("lciotree",t);
+  TTree *t; f->GetObject("LCIO",t);
 
   //  t->Draw("PandoraPFOs.getEnergy()" ) ;
   //   t->Draw("PandoraPFOs.getTracks().size()" ) ;
CVSspam 0.2.8