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

#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <TFile.h>
#include <TTree.h>
#include <TString.h>

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 13 of file genRunList.cxx.

References genRecEmupikp::i, and t().

00013                                 {
00014   if(argc<3){
00015     cout << "please append path name and root file name [and tree names] [and tag name]" << endl;
00016     return 1;
00017   }
00018 
00019   TString str_root_file(argv[1]);
00020   str_root_file.Append(argv[2]);
00021   TFile f(str_root_file);
00022   TTree *t(0);
00023   if(argc>3) t = (TTree*)f.Get(argv[3]);
00024   else{
00025     TList *l = f.GetListOfKeys();
00026     if(l->GetEntries()<1){ 
00027       cout << "the root file " << argv[2] << " is empty, check it!" << endl;
00028       return 1;
00029     }
00030     else t = (TTree*)f.Get(l->At(0)->GetName());
00031   }
00032   Long_t m_totnum = t->GetEntries();
00033   //  double m_run(0), m_event(0), m_cur_run(0);
00034   int m_run(0), m_event(0), m_cur_run(0);
00035   char str_run_name[20];
00036   TString str_run_name_II("");
00037   t->SetBranchAddress("run", &m_run);
00038   t->SetBranchAddress("event", &m_event);
00039   ofstream f_out;
00040   cout << "total events: " << m_totnum << endl;
00041   for(Long_t i=0; i<m_totnum; i++){
00042 
00043     t->GetEntry(i);
00044     if(i%10000==0) cout << "i = " << i << "   run: " << m_run << "   event: " << m_event << endl; 
00045     if(m_run != m_cur_run && m_run>1){
00046       if(f_out.is_open()) f_out.close();
00047       int m_temp_run = (int)m_run;
00048       if(argc<5){
00049         sprintf(str_run_name, "%d.txt", m_temp_run);
00050         str_run_name_II = argv[2];
00051         str_run_name_II.ReplaceAll("_","");
00052         str_run_name_II.ReplaceAll(".root","_runnumber");
00053         str_run_name_II.ReplaceAll("runnumber", str_run_name);
00054         cout << "run file: " << str_run_name_II << endl;
00055         f_out.open(str_run_name_II, ios::app);
00056       }
00057       else{
00058         sprintf(str_run_name, "%s_%d.txt", argv[4], m_temp_run);
00059         cout << "run file: " << str_run_name << endl;
00060         f_out.open(str_run_name, ios::app);
00061       }
00062       m_cur_run = m_run;
00063     }
00064     if(!f_out.is_open()){ cout << "cannot open file " << endl; return 1; }
00065     f_out << (long)m_run << "    " << (long)m_event << endl;
00066     // cout << (long)m_run << "    " << (long)m_event << endl;
00067   }
00068   f_out.close();
00069 
00070   return 0;
00071 }


Generated on Tue Nov 29 23:16:43 2016 for BOSS_7.0.2 by  doxygen 1.4.7