#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <TFile.h>
#include <TTree.h>
#include <TString.h>
#include <TBranch.h>
#include <TLeaf.h>
#include <TH1F.h>
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
Variables | |
int const | num_item = 9 |
TString | str_name_list [num_item] |
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 26 of file compare_trees.cxx.
References f1, f2, genRecEmupikp::i, ganga-rec::j, num_item, and str_name_list.
00026 { 00027 if(argc<3){ 00028 cout << "please append two root files' names you want to compare " << endl; 00029 return 1; 00030 } 00031 00032 00033 TFile f1(argv[1]); 00034 TTree *t1(0); 00035 TFile f2(argv[2]); 00036 TTree *t2(0); 00037 00038 int m_flag(0); 00039 TH1F *h1 = new TH1F("h1","h1",100000,-100000,100000); 00040 TH1F *h2 = new TH1F("h2","h2",100000,-100000,100000); 00041 00042 for(int i=0; i<num_item; i++){ 00043 m_flag = 0; 00044 t1 = (TTree*)f1.Get(str_name_list[i]); 00045 t2 = (TTree*)f2.Get(str_name_list[i]); 00046 TObjArray *l_b1 = t1->GetListOfBranches(); 00047 TObjArray *l_b2 = t1->GetListOfBranches(); 00048 if(l_b1->GetSize() != l_b2->GetSize()){ 00049 cout << "tree " << str_name_list[i] << " is different" << endl; 00050 break; 00051 } 00052 // cout << "size " << l_b1->GetEntries() << endl; 00053 for(int j=0; j<l_b1->GetEntries(); j++){ 00054 // cout << "j= " << j << " branch name " << l_b1->At(j)->GetName() << endl; 00055 t1->Project("h1", l_b1->At(j)->GetName()); 00056 t2->Project("h2", l_b2->At(j)->GetName()); 00057 if(h1->GetMean() - h2->GetMean()){ 00058 cout << "tree " << str_name_list[i] << " is different" << endl; 00059 m_flag = 1; 00060 break; 00061 } 00062 }// end of loop branches in trees 00063 if(m_flag) continue; 00064 else cout << "tree " << str_name_list[i] << " is same" << endl; 00065 }// end of loop tree 00066 00067 return 0; 00068 }
int const num_item = 9 |
TString str_name_list[num_item] |
Initial value:
{"runcalib", "gaincalib", "resolcalib", "wiregcalib", "ggscalib", "ddgcalib", "entracalib", "zdepcalib", "layergcalib"}
Definition at line 16 of file compare_trees.cxx.
Referenced by main().