예제 #1
0
void
OPCollMatrix::output(magnet::xml::XmlStream &XML)
{
  
  XML << magnet::xml::tag("CollCounters") 
      << magnet::xml::tag("TransitionMatrix");
  
  std::map<eventKey, std::pair<unsigned long long, double> > totmap;
  
  typedef std::pair<const counterKey, counterData> locPair;
  
  
  size_t initialsum(0);
  
  typedef std::pair<eventKey,size_t> npair;
  BOOST_FOREACH(const npair& n, initialCounter)
    initialsum += n.second;
  
  BOOST_FOREACH(const locPair& ele, counters)
    {
      XML << magnet::xml::tag("Count")
	  << magnet::xml::attr("Event") << ele.first.first.second
	  << magnet::xml::attr("Name") << getName(ele.first.first.first, Sim)
	  << magnet::xml::attr("lastEvent") << ele.first.second.second
	  << magnet::xml::attr("lastName") << getName(ele.first.second.first, Sim)
	  << magnet::xml::attr("Percent") << 100.0 * ((double) ele.second.count) 
	/ ((double) totalCount)
	  << magnet::xml::attr("mft") << ele.second.totalTime
	/ (Sim->dynamics.units().unitTime() * ((double) ele.second.count))
	  << magnet::xml::endtag("Count");
      
      //Add the total count
      totmap[ele.first.first].first += ele.second.count;
      
      //Add the rate
      totmap[ele.first.first].second += ((double) ele.second.count) 
	/ ele.second.totalTime;
    }
예제 #2
0
  void
  OPCollMatrix::output(magnet::xml::XmlStream &XML)
  {
  
    XML << magnet::xml::tag("CollCounters") 
	<< magnet::xml::tag("TransitionMatrix");
  
    std::map<eventKey, std::pair<size_t, double> > totmap;
  
    typedef std::pair<const counterKey, counterData> locPair;
  
  
    size_t initialsum(0);
  
    typedef std::pair<eventKey,size_t> npair;
    for (const npair& n : initialCounter)
      initialsum += n.second;
  
    for (const locPair& ele : counters)
      {
	XML << magnet::xml::tag("Count")
	    << magnet::xml::attr("Event") << ele.first.first.second
	    << magnet::xml::attr("Name") << getName(ele.first.first.first, Sim)
	    << magnet::xml::attr("lastEvent") << ele.first.second.second
	    << magnet::xml::attr("lastName") << getName(ele.first.second.first, Sim)
	    << magnet::xml::attr("Percent") << 100.0 * ((double) ele.second.count) 
	  / ((double) totalCount)
	    << magnet::xml::attr("mft") << ele.second.totalTime
	  / (Sim->units.unitTime() * ((double) ele.second.count))
	    << magnet::xml::endtag("Count");
      
	//Add the total count
	totmap[ele.first.first].first += ele.second.count;
      
	//Add the rate
	totmap[ele.first.first].second += ((double) ele.second.count) 
	  / ele.second.totalTime;
      }
  
    XML << magnet::xml::endtag("TransitionMatrix")
	<< magnet::xml::tag("Totals");
  
    typedef std::pair<eventKey, std::pair<size_t, double> > mappair;
  
    for (const mappair& mp1 : totmap)
      XML << magnet::xml::tag("TotCount")
	  << magnet::xml::attr("Name") << getName(mp1.first.first, Sim)
	  << magnet::xml::attr("Event") << mp1.first.second
	  << magnet::xml::attr("Percent") 
	  << 100.0 * (((double) mp1.second.first)
		      +((double) initialCounter[mp1.first]))
      / (((double) totalCount) + ((double) initialsum))
	  << magnet::xml::attr("Count") << mp1.second.first + initialCounter[mp1.first]
	  << magnet::xml::attr("EventMeanFreeTime")
	  << Sim->systemTime / ((mp1.second.first + initialCounter[mp1.first])
			      * Sim->units.unitTime())
	  << magnet::xml::endtag("TotCount");
  
    XML << magnet::xml::endtag("Totals")
	<< magnet::xml::endtag("CollCounters");
  }