BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
compare_trees.cxx File Reference
#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]
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 26 of file compare_trees.cxx.

26 {
27 if(argc<3){
28 cout << "please append two root files' names you want to compare " << endl;
29 return 1;
30 }
31
32
33 TFile f1(argv[1]);
34 TTree *t1(0);
35 TFile f2(argv[2]);
36 TTree *t2(0);
37
38 int m_flag(0);
39 TH1F *h1 = new TH1F("h1","h1",100000,-100000,100000);
40 TH1F *h2 = new TH1F("h2","h2",100000,-100000,100000);
41
42 for(int i=0; i<num_item; i++){
43 m_flag = 0;
44 t1 = (TTree*)f1.Get(str_name_list[i]);
45 t2 = (TTree*)f2.Get(str_name_list[i]);
46 TObjArray *l_b1 = t1->GetListOfBranches();
47 TObjArray *l_b2 = t1->GetListOfBranches();
48 if(l_b1->GetSize() != l_b2->GetSize()){
49 cout << "tree " << str_name_list[i] << " is different" << endl;
50 break;
51 }
52 // cout << "size " << l_b1->GetEntries() << endl;
53 for(int j=0; j<l_b1->GetEntries(); j++){
54 // cout << "j= " << j << " branch name " << l_b1->At(j)->GetName() << endl;
55 t1->Project("h1", l_b1->At(j)->GetName());
56 t2->Project("h2", l_b2->At(j)->GetName());
57 if(h1->GetMean() - h2->GetMean()){
58 cout << "tree " << str_name_list[i] << " is different" << endl;
59 m_flag = 1;
60 break;
61 }
62 }// end of loop branches in trees
63 if(m_flag) continue;
64 else cout << "tree " << str_name_list[i] << " is same" << endl;
65 }// end of loop tree
66
67 return 0;
68}
TFile * f1
TString str_name_list[num_item]
int const num_item

Variable Documentation

◆ num_item

int const num_item = 9

Definition at line 15 of file compare_trees.cxx.

Referenced by main().

◆ str_name_list

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().