/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/DedxCalibAlg/DedxCalibAlg-00-01-15/share/shell/genRawScript/realnewrun.cxx

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <fstream>
00003 #include <iomanip>
00004 #include <cstring>
00005 #include <string>
00006 #include <vector>
00007 #include <TFile.h>
00008 #include <TTree.h>
00009 #include <TString.h>
00010 #include <TBranch.h>
00011 #include <TLeaf.h>
00012 #include <TH1F.h>
00013 #include <cstdio>
00014 
00015 using namespace std;
00016 
00017 int main(int argc, char *argv[]){
00018   if(argc<5){
00019     cout << "please append two root files' names you want to compare " << endl;
00020     cout << "realnewrun.exe new.root treename old.root treename [output.root]" << endl;
00021     return 1;
00022   }
00023 
00024 
00025   TFile f1(argv[1]);
00026   TTree *t1 = (TTree*)f1.Get(argv[2]);
00027   TFile f2(argv[3]);
00028   TTree *t2 = (TTree*)f2.Get(argv[4]);
00029   TString str_output = "output.root";
00030   if(argc>5) str_output = argv[5];
00031   TFile f3(str_output,"recreate");
00032   TTree *t3 = new TTree("track","track");
00033   int newrun, newevt;
00034   t3->Branch("run", &newrun, "run/I");
00035   t3->Branch("event", &newevt, "event/I");
00036 
00037   int run, evt;
00038   t1->SetBranchAddress("run", &run);
00039   t1->SetBranchAddress("event", &evt);
00040   char str[255];
00041   for(int i=0; i<t1->GetEntries(); i++){
00042     t1->GetEntry(i);
00043     sprintf(str, "run==%d && event==%d", run, evt);
00044     if(t2->GetEntries(str)>0) cout << "str: " << str << "  run: " << run << "  event: " << evt << endl;
00045     else{
00046       newrun = run;
00047       newevt = evt;
00048       t3->Fill();
00049     }
00050   }
00051 
00052   f1.Close();
00053   f2.Close();
00054   f3.cd();
00055   t3->Write();
00056   f3.Close();
00057   return 0;
00058 }

Generated on Tue Nov 29 23:12:45 2016 for BOSS_7.0.2 by  doxygen 1.4.7