Main Page   Class Hierarchy   Data Structures   File List   Data Fields   Globals  

scatter_hist.C

Go to the documentation of this file.
00001 #include "scatter_hist.h"
00002 
00003 scatter_hist* initialize_scatter_hist(sdyn* b) {
00004 
00005   if(b == NULL)
00006     return NULL;
00007 
00008   scatter_hist* hi = new scatter_hist();
00009 
00010   hi->init_scatter_exp(b);
00011   hi->final_scatter_exp(b);
00012   hi->set_id_scenario(1);
00013   hi->set_n_found(0);
00014   hi->set_resonance(false);
00015 
00016   return hi;
00017 }
00018 
00019 void scatter_hist::inc_id_scenario() {
00020 
00021   id_scenario = past->get_id_scenario()+1;
00022 
00023 }
00024 
00025 scatter_hist* scatter_hist::get_identical_scatter_hist() {
00026 
00027   scatter_hist *ha = NULL;
00028   for_all_scatter_hist(scatter_hist, this, ho) {
00029     if(this == ha) {
00030       ha = ho;
00031       break;
00032     }
00033   }
00034 
00035   return ha;
00036 }
00037 
00038 void scatter_hist::put_scatter_hist(ostream& s, bool verbose) {
00039 
00040      if (verbose) {
00041        s << "put_history of scatter" << flush << endl;
00042      }
00043 
00044      //     int i;
00045      for_all_scatter_hist(scatter_hist, this->get_first(), hi) {
00046        // s << *hi << " \t";
00047        //       for (int i = 0; i < max(0, 7 - strlen(dummy_string)); i++)
00048        //        cerr << " ";
00049 
00050        s << *hi << endl;
00051 
00052        //       for(i=0; i<N_RHO_ZONE_MAX; i++) 
00053        //        s << hi->get_nhits(i);
00054        //       for(i=0; i<2-floor(log10(hi->get_nhits(i)+0.1)); i++)
00055        //        s << " ";
00056        //       cerr << endl;
00057      }
00058        
00059 }
00060 scatter_hist* scatter_hist::contains(scatter_hist *hi) {
00061 
00062   for_all_scatter_hist(scatter_hist, get_first(), ha) {
00063     if(hi->identical_to(ha)) { 
00064       return ha;
00065     }
00066   }
00067 
00068   return NULL;
00069 }
00070 
00071 void scatter_hist::add_scatter_hist(scatter_exp he, int zone) {
00072 
00073     scatter_hist *hi = new scatter_hist(he);
00074     if (!hi) {
00075       cerr << "hi==NULL in add_scatter_hist(istream& s)" << endl;
00076       exit(-1);
00077     }
00078 
00079     if(hi->get_initial_form() == NULL || hi->get_final_form() == NULL)
00080       return;
00081 
00082     scatter_hist *identical_scenario = this->contains(hi);
00083     
00084     if (identical_scenario == NULL) {
00085       int n_scenario = 0;
00086       for_all_scatter_hist(scatter_hist, get_first(), ho) {
00087         n_scenario = max(n_scenario, ho->get_id_scenario());
00088       }
00089 
00090       hi->set_id_scenario(n_scenario+1);
00091       hi->set_n_found(1);
00092       for(int i=0; i< N_RHO_ZONE_MAX; i++) 
00093         hi->n_hits[i] = 0;
00094       hi->n_hits[zone] = 1;
00095 
00096       scatter_hist *ha = get_last();
00097       ha->set_future(hi);
00098       hi->set_past(ha);
00099     }
00100     else {
00101       identical_scenario->inc_n_found(); 
00102       identical_scenario->n_hits[zone]++;
00103     }
00104 
00105 }
00106 
00107 void scatter_hist::add_scatter_hist(istream& s) {
00108 
00109     scatter_hist *hi = new scatter_hist(cin);
00110     if (!hi) {
00111       cerr << "hi==NULL in add_scatter_hist(istream& s)" << endl;
00112       exit(-1);
00113     }
00114 
00115     scatter_hist *identical_scenario = this->contains(hi);
00116     
00117     if (identical_scenario == NULL) {
00118       int n_scenario = 0;
00119       for_all_scatter_hist(scatter_hist, get_first(), ho) {
00120         n_scenario = max(n_scenario, ho->get_id_scenario());
00121       }
00122       hi->set_id_scenario(n_scenario+1);
00123       hi->set_n_found(1);
00124       hi->n_hits[n_zone] = 1;
00125 
00126       scatter_hist *ha = get_last();
00127       ha->set_future(hi);
00128       hi->set_past(ha);
00129     }
00130     else {
00131       //      delete hi;
00132       identical_scenario->inc_n_found(); 
00133       identical_scenario->n_hits[n_zone]++;
00134     }
00135 }
00136 
00137 void scatter_hist::put_state(ostream & s) {
00138  
00139   s << "put_state" << endl;
00140   s << id_scenario << " " << initial_form << " " << final_form << endl;
00141 }
00142 
00143 void put_state(scatter_hist * hi, ostream & s) {
00144 
00145   for_all_scatter_hist(scatter_hist, hi, ha) {
00146     ha->put_state(s);
00147   }
00148 
00149   s << endl;
00150 }
00151 
00152 #ifdef TOOLBOX
00153 
00154 void main(int argc, char **argv) {
00155 
00156     check_help();
00157     extern char *poptarg;
00158     int c;
00159     char* param_string = "c:";
00160 
00161     real cpu_time_check;
00162     while ((c = pgetopt(argc, argv, param_string)) != -1)
00163         switch(c) {
00164             case 'c': cpu_time_check = atof(poptarg);
00165                       break;
00166             case '?': params_to_usage(cerr, argv[0], param_string);
00167                       get_help();
00168         }            
00169 
00170     scatter_hist *hi = new scatter_hist(cin);
00171     if (!hi) {
00172       cerr << "hi==NULL in main" << endl;
00173       exit(-1);
00174     }
00175 
00176     do {
00177 
00178       hi->add_scatter_hist(cin);
00179     }
00180     while (!cin.eof());
00181 
00182     hi->put_scatter_hist(cerr);
00183 }
00184 
00185 
00186 #endif

Generated at Sun Feb 24 09:57:14 2002 for STARLAB by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001