00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "SeBa_hist.h"
00018
00019 #ifdef TOOLBOX
00020
00021
00022
00023 supernova_type count_supernovae(SeBa_hist *hi) {
00024
00025 supernova_type sn_type = NAT;
00026
00027 if (post_supernova_star(hi->get_primary_type()))
00028 sn_type = type_of_supernova(hi->get_past()->get_primary_type());
00029
00030 if(sn_type == NAT) {
00031 if (post_supernova_star(hi->get_secondary_type()))
00032 sn_type = type_of_supernova(hi->get_past()->get_secondary_type());
00033
00034 return sn_type;
00035 }
00036 }
00037
00038 local int count_supernova_types(SeBa_hist *hi, bool normalize) {
00039
00040 int binaries_read = 0;
00041 supernova_type sn_type;
00042 real n_sn = 0;
00043
00044 real supernovae[no_of_supernova_type];
00045 for(int i=0; i<(int)no_of_supernova_type; i++) {
00046 supernovae[i] = 0;
00047 }
00048
00049 int mergers = 0;
00050 SeBa_hist* next_hi = get_history(hi, cin);
00051 do {
00052
00053 binaries_read++;
00054 for_all_SeBa_hist(SeBa_hist, hi, ha) {
00055
00056 sn_type = count_supernovae(ha);
00057 if(sn_type!=NAT) {
00058 supernovae[(int)sn_type]++;
00059 n_sn++;
00060 }
00061 }
00062
00063 delete hi;
00064 hi = next_hi;
00065 next_hi = get_history(hi, cin);
00066 }
00067 while (next_hi);
00068
00069 if (n_sn<=0) {
00070 cerr << " ---No supernovae---" <<endl;
00071 exit(-1);
00072 }
00073
00074 PRL(n_sn);
00075 if(normalize) {
00076 int p = cerr.precision(LOW_PRECISION);
00077 cerr << "Normalized to 100%"<<endl;
00078 n_sn /= 100;
00079
00080 for (int i = 0; i<no_of_supernova_type-1; i++) {
00081 supernovae[i] /= n_sn;
00082 }
00083 cerr.precision(p);
00084 }
00085
00086 cerr << " Supernova population " << n_sn << endl;
00087 for(int i=NAT; i<no_of_supernova_type; i++)
00088 cerr << type_string((supernova_type)i) << "\t";
00089 cerr << endl;
00090
00091 for(int i=NAT; i<no_of_supernova_type; i++)
00092 cerr << supernovae[i] << "\t";
00093 cerr << endl;
00094
00095 return binaries_read;
00096 }
00097
00098
00099
00100
00101 main(int argc, char ** argv) {
00102
00103 bool normalize = false;
00104 real snap_time = 0;
00105
00106 char *comment;
00107 check_help();
00108
00109 extern char *poptarg;
00110 int c;
00111 char* param_string = "Nt:";
00112
00113 while ((c = pgetopt(argc, argv, param_string)) != -1)
00114 switch(c)
00115 {
00116 case 't': snap_time = atof(poptarg);
00117 break;
00118 case 'N': normalize = !normalize;
00119 break;
00120 case '?': params_to_usage(cerr, argv[0], param_string);
00121 get_help();
00122 exit(1);
00123 }
00124
00125
00126 SeBa_hist* hi = new SeBa_hist;
00127 if (!hi->read_SeBa_hist(cin))
00128 exit(-1);
00129
00130 int binaries_read = count_supernova_types(hi, normalize);
00131
00132 cerr << "Total number of binaries read: " << binaries_read << endl;
00133 }
00134
00135 #endif // endof: TOOLBOX
00136
00137
00138