ROOTPWA
listwaves.cc
Go to the documentation of this file.
1 
2 //
3 // Copyright 2009 Sebastian Neubert
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 // tool to list the waves contained in a root fitlog
22 #include "TFile.h"
23 #include "TTree.h"
24 #include "TFitBin.h"
25 #include <string>
26 #include <iostream>
27 #include <map>
28 
29 using namespace std;
30 char *progname;
31 int lineno = 1; // global variables needed for lex (not understood)
32 
33 int main(int argc, char** argv){
34 
35  progname=argv[0];
36 
37 
38 
39  TFile* f=TFile::Open(argv[1]);
40  TTree* tree=(TTree*)f->Get("pwa");
41 
42  TFitBin* bin=new TFitBin();
43 
44  tree->SetBranchAddress("fitbin",&bin);
45 
46  tree->GetEntry(0);
47  int nw=bin->nwaves();
48  std::vector<double> intens(nw,0);
49 
50  int n=tree->GetEntries();
51  int usedbins=0;
52  for(int i=0;i<n;++i){
53  tree->GetEntry(i);
54  double I=bin->intens();
55  if(I>1000){
56  for(int j=0;j<nw;++j){
57  // calculate relative intensity
58  intens[j]+=bin->intens(j)/I;
59  } // end loop over waves
60  ++usedbins;
61  }
62  }// end loop over mnass bins
63 
64 
65  // sort the wavenames
66  std::map<TString,double> waves;
67  std::map<double, TString> waves2;
68 
69 
70  for(int j=0;j<nw;++j){
71  // normalize relatve intensities to number of bins!
72  waves[bin->wavename(j)]=intens[j]/(double)usedbins;
73  waves2[intens[j]/(double)usedbins]=bin->wavename(j);
74  }// end loop over waves
75 
76 
77 
78 
79  // print outcome:
80 
81  std::cout<<"Wavename | ID"<<std::endl;
82  for(int j=0;j<nw;++j){
83  std::cout<<bin->wavename(j)<<" | "<<j<<std::endl;
84  }
85 
86  std::cout<<"Wavename | Relative Intensity (sorted by name)"<<std::endl;
87  std::map<TString,double>::iterator wit=waves.begin();
88  while(wit!=waves.end()){
89  std::cout<<wit->first<<" | "<<wit->second<<std::endl;
90  ++wit;
91  }
92 
93  std::cout<<"----------------------------------------------------"<<std::endl;
94  std::cout<<"Wavename | Relative Intensity (sorted by intensity)"<<std::endl;
95  std::map<double,TString>::iterator wit2=waves2.end();
96  while(wit2!=waves2.begin()){
97  --wit2;
98  std::cout<<wit2->second<<" | "<<wit2->first<<std::endl;
99  }
100 
101 }
102 
103 // dummy function needed since we link to but do not use minuit.o
104 int mnparm(int, string, double, double, double, double) {
105  cerr << "this is impossible" << endl;
106  throw "aFit";
107  return 0;
108 }