00001 #include <fstream>
00002
00003 void writeFile(const char* inRootFile)
00004 {
00005 TFile inRoot(inRootFile);
00006 if(!inRoot.IsOpen()){
00007 cout << "Cannot open " << inRootFile << endl;
00008 return;
00009 }
00010 TIterator* iterator = inRoot.GetListOfKeys()->MakeIterator();
00011 TKey* key;
00012
00013 TString outText = inRootFile;
00014 outText.Replace(0,outText.Last('/')+1,"");
00015
00016 ofstream os(outText.Data());
00017
00018 char buf[500];
00019
00020 int count(0);
00021 while( (key=dynamic_cast<TKey*>(iterator->Next())) != 0){
00022 cout << key->GetName() << endl;
00023 TH1* h = (TH1*)inRoot.Get(key->GetName());
00024 if(h->GetDimension()!=1) continue;
00025
00026 if(++count>1) break;
00027
00028 int nBin = h->GetNbinsX();
00029 os << "name: " << h->GetName() << endl
00030 << "title: " << h->GetTitle() << endl
00031 << "bins: " << h->GetNbinsX() << endl
00032 << "min: " << h->GetXaxis()->GetBinLowEdge(1)
00033 << ", max: " << h->GetXaxis()->GetBinUpEdge(h->GetNbinsX()) << endl;
00034
00035 for(int i=1; i<=nBin; i++){
00036 os << "bin: " << i << " value: " << (float)h->GetBinContent(i)
00037 << " error: " << (float)h->GetBinError(i) << endl;
00038 }
00039 }
00040
00041 }
00042
00043
00044 void readFile(const char* textFile)
00045 {
00046
00047
00048 }
00049