00001
00002 #include <map>
00003 #include "TKey.h"
00004 #include <TROOT.h>
00005 #include <TKey.h>
00006 #include <TList.h>
00007 #include <TTree.h>
00008 #include <TFile.h>
00009 #include <TChain.h>
00010 #include "TChainElement.h"
00011 #include <iostream>
00012 #include "Log.hh"
00013
00014 #include "MicroException.hh"
00015 #include <string>
00016
00017 #include "root/CaloRun.hh"
00018 #include "root/CaloEvent.hh"
00019
00020
00021 using namespace std;
00022
00023
00024 int main(int argc, char**argv){
00025
00026
00027 TChain chain("T");
00028 chain.Add("/lapp_data/LC/data/TB2012/SPS_H2_may_2012/Production/CaloHits/DHCAL_714372_DHCAL_714372_I0_0.CaloHit.root");
00029 chain.Add("/lapp_data/LC/data/TB2012/SPS_H2_may_2012/Production/CaloHits/DHCAL_714372_DHCAL_714372_I1_0.CaloHit.root");
00030 chain.Add("/lapp_data/LC/data/TB2012/SPS_H2_may_2012/Production/CaloHits/DHCAL_714372_DHCAL_714372_I2_0.CaloHit.root");
00031 chain.Add("/lapp_data/LC/data/TB2012/SPS_H2_may_2012/Production/CaloHits/DHCAL_714372_DHCAL_714372_I3_0.CaloHit.root");
00032 chain.Add("/lapp_data/LC/data/TB2012/SPS_H2_may_2012/Production/CaloHits/DHCAL_714372_DHCAL_714372_I4_0.CaloHit.root");
00033
00034 TObjArray *fileElements=chain.GetListOfFiles();
00035 TIter next(fileElements);
00036 TChainElement *chEl=0;
00037 while (( chEl=(TChainElement*)next() )) {
00038 TFile f(chEl->GetTitle());
00039
00040
00041 TIter nextkey(f.GetListOfKeys());
00042 TKey *key;
00043 while (key = (TKey*)nextkey())
00044 {
00045 TTree *tree = (TTree*)key->ReadObj();
00046 cout << tree->GetName() <<endl;
00047 CaloRun *run=NULL;
00048 try
00049 {
00050 run=dynamic_cast<CaloRun *>(tree->GetUserInfo()->First());
00051 if ( run != NULL )
00052 {
00053 cout << "Run Id: " << run->GetRunId() << endl ;
00054 }
00055 }
00056 catch (...) {}
00057
00058 CaloEvent *evt = new CaloEvent();
00059 TBranch *branch= tree->GetBranch("CaloEvent");
00060 branch->SetAddress(&evt);
00061 int nbEntries = tree->GetEntries();
00062 cout << "Nb event:" << nbEntries << endl;
00063
00064 }
00065 }
00066 return 1;
00067 }