CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
realnewrun.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>
#include <cstdio>

Go to the source code of this file.

Functions

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

Function Documentation

◆ main()

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

Definition at line 17 of file realnewrun.cxx.

17 {
18 if(argc<5){
19 cout << "please append two root files' names you want to compare " << endl;
20 cout << "realnewrun.exe new.root treename old.root treename [output.root]" << endl;
21 return 1;
22 }
23
24
25 TFile f1(argv[1]);
26 TTree *t1 = (TTree*)f1.Get(argv[2]);
27 TFile f2(argv[3]);
28 TTree *t2 = (TTree*)f2.Get(argv[4]);
29 TString str_output = "output.root";
30 if(argc>5) str_output = argv[5];
31 TFile f3(str_output,"recreate");
32 TTree *t3 = new TTree("track","track");
33 int newrun, newevt;
34 t3->Branch("run", &newrun, "run/I");
35 t3->Branch("event", &newevt, "event/I");
36
37 int run, evt;
38 t1->SetBranchAddress("run", &run);
39 t1->SetBranchAddress("event", &evt);
40 char str[255];
41 for(int i=0; i<t1->GetEntries(); i++){
42 t1->GetEntry(i);
43 sprintf(str, "run==%d && event==%d", run, evt);
44 if(t2->GetEntries(str)>0) cout << "str: " << str << " run: " << run << " event: " << evt << endl;
45 else{
46 newrun = run;
47 newevt = evt;
48 t3->Fill();
49 }
50 }
51
52 f1.Close();
53 f2.Close();
54 f3.cd();
55 t3->Write();
56 f3.Close();
57 return 0;
58}
TFile * f1