/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/root/TChainExample.cpp File Reference

#include <map>
#include "TKey.h"
#include <TROOT.h>
#include <TList.h>
#include <TTree.h>
#include <TFile.h>
#include <TChain.h>
#include "TChainElement.h"
#include <iostream>
#include "Log.hh"
#include "MicroException.hh"
#include <string>
#include "root/CaloRun.hh"
#include "root/CaloEvent.hh"

Include dependency graph for TChainExample.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file TChainExample.cpp.

00024                               {
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 }


Generated on Mon Jan 7 13:17:25 2013 for MicromegasFramework by  doxygen 1.4.7