1 void writeTextFile(
const char* inRootFile=
2 "links/P00hk.nofield.refitOS.undoPTCME.slice/dip5.typec.slice.root",
4 "links/P00hk.nofield.refitOS.undoPTCME.slice")
6 cout <<
"in root=" << inRootFile << endl
7 <<
"out dir=" << outDir << endl;
9 TFile inRoot(inRootFile);
11 cout <<
"Cannot open " << inRootFile << endl;
14 TIterator* iterator = inRoot.GetListOfKeys()->MakeIterator();
17 TString outText = inRootFile;
18 outText.Replace(0,outText.Last(
'/')+1,
"");
19 outText.ReplaceAll(
".root",
".txt");
20 outText.Prepend(
"/"); outText.Prepend(outDir);
22 ofstream os(outText.Data());
23 if(!os){cout <<
"huh?" << endl;
return; }
27 int count(0),nLimit(5);
28 while( (key=dynamic_cast<TKey*>(iterator->Next())) != 0){
30 TH1* h = (TH1*)inRoot.Get(key->GetName());
31 if(h->GetDimension()!=1)
continue;
35 int nBin = h->GetNbinsX();
36 os <<
"name: " << h->GetName() << endl
37 <<
"title: " << h->GetTitle() << endl
38 <<
"bins: " << h->GetNbinsX() << endl;
40 if(ary=h->GetXaxis()->GetXbins()){
41 os <<
"isarray" << endl;
42 for(
int i=0; i<ary->GetSize();i++){
43 os << ary->At(i) <<
" ";
47 os <<
"notarray" << endl;
48 <<
"min: " << h->GetXaxis()->GetBinLowEdge(1) << endl
49 <<
"max: " << h->GetXaxis()->GetBinUpEdge(h->GetNbinsX()) << endl;
52 for(
int i=1; i<=nBin; i++){
53 os <<
"bin=" << i <<
" value: " << h->GetBinContent(i)
54 <<
" error: " << h->GetBinError(i) << endl;